@Override public IAnnotation[] getAnnotations() throws JavaModelException { AnnotatableInfo info = (AnnotatableInfo) getElementInfo(); return info.annotations; } @Override
/** * @see ICompilationUnit#getType(String) */ @Override public IType getType(String typeName) { return new SourceType(this, typeName); } /**
/** * @see IType * @deprecated */ @Override public void codeComplete(char[] snippet,int insertion,int position,char[][] localVariableTypeNames,char[][] localVariableNames,int[] localVariableModifiers,boolean isStatic,ICompletionRequestor requestor) throws JavaModelException { codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor, DefaultWorkingCopyOwner.PRIMARY); } /**
@Override public IMethod[] findMethods(IMethod method) { try { return findMethods(method, getMethods()); } catch (JavaModelException e) { // if type doesn't exist, no matching method can exist return null; } } @Override
buffer.append(tabString(tab)); if (info == null) { if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isEnum()) { buffer.append("enum "); //$NON-NLS-1$ } else if (isAnnotation()) { buffer.append("@interface "); //$NON-NLS-1$ } else if (isInterface()) { buffer.append("interface "); //$NON-NLS-1$ } else { buffer.append("class "); //$NON-NLS-1$ if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$
JavaProject project = (JavaProject) getJavaProject(); SearchableEnvironment environment = project.newSearchableNameEnvironment(owner); CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor); String source = getCompilationUnit().getSource(); if (source != null && insertion > -1 && insertion < source.length()) { fakeSource, null, getElementName(), getParent());
private TypeDeclaration convert(SourceType typeHandle, CompilationResult compilationResult) throws JavaModelException { SourceTypeElementInfo typeInfo = (SourceTypeElementInfo) typeHandle.getElementInfo(); if (typeInfo.isAnonymousMember()) throw new AnonymousMemberFound(); if (typeHandle.isAnonymous()) { type.name = CharOperation.NO_CHAR; type.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType); } else { if (typeHandle.isLocal()) { type.bits |= ASTNode.IsLocalType;
public IJavaElement[] getChildrenForCategory(String category) throws JavaModelException { IJavaElement[] children = getChildren(); int length = children.length; if (length == 0) return NO_ELEMENTS; SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo(); HashMap categories = info.getCategories(); if (categories == null) return NO_ELEMENTS; IJavaElement[] result = new IJavaElement[length]; int index = 0; for (int i = 0; i < length; i++) { IJavaElement child = children[i]; String[] elementCategories = (String[]) categories.get(child); if (elementCategories != null) for (int j = 0, length2 = elementCategories.length; j < length2; j++) { if (elementCategories[j].equals(category)) result[index++] = child; } } if (index == 0) return NO_ELEMENTS; if (index < length) System.arraycopy(result, 0, result = new IJavaElement[index], 0, index); return result; } /**
/** * @see IType */ @Override public IMethod[] getMethods() throws JavaModelException { ArrayList list = getChildrenOfType(METHOD); IMethod[] array= new IMethod[list.size()]; list.toArray(array); return array; } /**
protected void resolveDuplicates(IJavaElement handle) { // For anonymous source types, the occurrence count should be in the context // of the enclosing type. if (handle instanceof SourceType && ((SourceType) handle).isAnonymous()) { Object key = handle.getParent().getAncestor(IJavaElement.TYPE); int occurenceCount = this.localOccurrenceCounts.get(key); if (occurenceCount == -1) this.localOccurrenceCounts.put(key, 1); else { this.localOccurrenceCounts.put(key, ++occurenceCount); ((SourceType)handle).localOccurrenceCount = occurenceCount; } } } /**
public IJavaElement getPrimaryElement(boolean checkOwner) { if (checkOwner) { CompilationUnit cu = (CompilationUnit)getAncestor(COMPILATION_UNIT); if (cu.isPrimary()) return this; } IJavaElement primaryParent = this.parent.getPrimaryElement(false); switch (primaryParent.getElementType()) { case IJavaElement.COMPILATION_UNIT: return ((ICompilationUnit)primaryParent).getType(this.name); case IJavaElement.TYPE: return ((IType)primaryParent).getType(this.name); case IJavaElement.FIELD: case IJavaElement.INITIALIZER: case IJavaElement.METHOD: return ((IMember)primaryParent).getType(this.name, this.occurrenceCount); } return this; } /**
buffer.append(tabString(tab)); if (info == null) { if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isEnum()) { buffer.append("enum "); //$NON-NLS-1$ } else if (isAnnotation()) { buffer.append("@interface "); //$NON-NLS-1$ } else if (isInterface()) { buffer.append("interface "); //$NON-NLS-1$ } else { buffer.append("class "); //$NON-NLS-1$ if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$
JavaProject project = (JavaProject) getJavaProject(); SearchableEnvironment environment = project.newSearchableNameEnvironment(owner); CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor); String source = getCompilationUnit().getSource(); if (source != null && insertion > -1 && insertion < source.length()) { fakeSource, null, getElementName(), getParent());
private TypeDeclaration convert(SourceType typeHandle, CompilationResult compilationResult) throws JavaModelException { SourceTypeElementInfo typeInfo = (SourceTypeElementInfo) typeHandle.getElementInfo(); if (typeInfo.isAnonymousMember()) throw new AnonymousMemberFound(); if (typeHandle.isAnonymous()) { type.name = CharOperation.NO_CHAR; type.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType); } else { if (typeHandle.isLocal()) { type.bits |= ASTNode.IsLocalType;
public IJavaElement[] getChildrenForCategory(String category) throws JavaModelException { IJavaElement[] children = getChildren(); int length = children.length; if (length == 0) return NO_ELEMENTS; SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo(); HashMap categories = info.getCategories(); if (categories == null) return NO_ELEMENTS; IJavaElement[] result = new IJavaElement[length]; int index = 0; for (int i = 0; i < length; i++) { IJavaElement child = children[i]; String[] elementCategories = (String[]) categories.get(child); if (elementCategories != null) for (int j = 0, length2 = elementCategories.length; j < length2; j++) { if (elementCategories[j].equals(category)) result[index++] = child; } } if (index == 0) return NO_ELEMENTS; if (index < length) System.arraycopy(result, 0, result = new IJavaElement[index], 0, index); return result; } /**
public IMethod[] findMethods(IMethod method) { try { return findMethods(method, getMethods()); } catch (JavaModelException e) { // if type doesn't exist, no matching method can exist return null; } } public IAnnotation[] getAnnotations() throws JavaModelException {
/** * @see IType */ @Override public IField[] getFields() throws JavaModelException { ArrayList list = getChildrenOfType(FIELD); IField[] array= new IField[list.size()]; list.toArray(array); return array; } /**
protected void resolveDuplicates(IJavaElement handle) { // For anonymous source types, the occurrence count should be in the context // of the enclosing type. if (handle instanceof SourceType && ((SourceType) handle).isAnonymous()) { Object key = handle.getParent().getAncestor(IJavaElement.TYPE); int occurenceCount = this.localOccurrenceCounts.get(key); if (occurenceCount == -1) this.localOccurrenceCounts.put(key, 1); else { this.localOccurrenceCounts.put(key, ++occurenceCount); ((SourceType)handle).localOccurrenceCount = occurenceCount; } } } /**
public IJavaElement getPrimaryElement(boolean checkOwner) { if (checkOwner) { CompilationUnit cu = (CompilationUnit)getAncestor(COMPILATION_UNIT); if (cu.isPrimary()) return this; } IJavaElement primaryParent = this.parent.getPrimaryElement(false); switch (primaryParent.getElementType()) { case IJavaElement.COMPILATION_UNIT: return ((ICompilationUnit)primaryParent).getType(this.name); case IJavaElement.TYPE: return ((IType)primaryParent).getType(this.name); case IJavaElement.FIELD: case IJavaElement.INITIALIZER: case IJavaElement.METHOD: return ((IMember)primaryParent).getType(this.name, this.occurrenceCount); } return this; } /**
buffer.append(tabString(tab)); if (info == null) { if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$ } else { toStringName(buffer); if (isEnum()) { buffer.append("enum "); //$NON-NLS-1$ } else if (isAnnotation()) { buffer.append("@interface "); //$NON-NLS-1$ } else if (isInterface()) { buffer.append("interface "); //$NON-NLS-1$ } else { buffer.append("class "); //$NON-NLS-1$ if (isAnonymous()) { buffer.append("<anonymous #"); //$NON-NLS-1$ buffer.append(this.occurrenceCount); buffer.append(">"); //$NON-NLS-1$