Java Code Examples for org.eclipse.jdt.core.IJavaElement#FIELD
The following examples show how to use
org.eclipse.jdt.core.IJavaElement#FIELD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaElementHistoryPageSource.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns true if the given IJavaElement maps to a JavaNode. The JavaHistoryAction uses this * function to determine whether a selected Java element can be replaced by some piece of code * from the local history. * * @param je the Java element * @return <code>true</code> if there are editions available for the given Java element, * <code>false</code> otherwise * * */ public static boolean hasEdition(IJavaElement je) { if (je instanceof IMember && ((IMember)je).isBinary()) return false; switch (je.getElementType()) { case IJavaElement.COMPILATION_UNIT: case IJavaElement.TYPE: case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: return true; } return false; }
Example 2
Source File: JdtRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected EClass getExpectedJvmType(IJavaElement javaElement) { try { switch (javaElement.getElementType()) { case IJavaElement.TYPE: if (((IType) javaElement).isEnum()) return TypesPackage.Literals.JVM_ENUMERATION_TYPE; else return TypesPackage.Literals.JVM_TYPE; case IJavaElement.METHOD: if (((IMethod) javaElement).isConstructor()) return TypesPackage.Literals.JVM_CONSTRUCTOR; else return TypesPackage.Literals.JVM_OPERATION; case IJavaElement.FIELD: if (((IField) javaElement).isEnumConstant()) return TypesPackage.Literals.JVM_ENUMERATION_LITERAL; else return TypesPackage.Literals.JVM_FIELD; default: return null; } } catch (JavaModelException exc) { throw new WrappedException(exc); } }
Example 3
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isPushDownAvailable(final IMember member) throws JavaModelException { if (!member.exists()) return false; final int type= member.getElementType(); if (type != IJavaElement.METHOD && type != IJavaElement.FIELD) return false; if (JdtFlags.isEnum(member)) return false; if (!Checks.isAvailable(member)) return false; if (JdtFlags.isStatic(member)) return false; if (type == IJavaElement.METHOD) { final IMethod method= (IMethod) member; if (method.isConstructor()) return false; if (JdtFlags.isNative(method)) return false; final IType declaring= method.getDeclaringType(); if (declaring != null && declaring.isAnnotation()) return false; } return true; }
Example 4
Source File: JavaCompareUtilities.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
static ImageDescriptor getImageDescriptor(int type) { switch (type) { case IJavaElement.INITIALIZER: case IJavaElement.METHOD: return getImageDescriptor("obj16/compare_method.gif"); //$NON-NLS-1$ case IJavaElement.FIELD: return getImageDescriptor("obj16/compare_field.gif"); //$NON-NLS-1$ case IJavaElement.PACKAGE_DECLARATION: return JavaPluginImages.DESC_OBJS_PACKDECL; case IJavaElement.IMPORT_DECLARATION: return JavaPluginImages.DESC_OBJS_IMPDECL; case IJavaElement.IMPORT_CONTAINER: return JavaPluginImages.DESC_OBJS_IMPCONT; case IJavaElement.COMPILATION_UNIT: return JavaPluginImages.DESC_OBJS_CUNIT; } return ImageDescriptor.getMissingImageDescriptor(); }
Example 5
Source File: JdtRenameRefactoringProcessorFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public JavaRenameProcessor createRenameProcessor(IJavaElement element) { try { switch (element.getElementType()) { case IJavaElement.TYPE: return new RenameTypeProcessor((IType) element); case IJavaElement.FIELD: if (((IField) element).getDeclaringType().isEnum()) return new RenameEnumConstProcessor((IField) element); else return new RenameFieldProcessor((IField) element); case IJavaElement.METHOD: if(((IMethod)element).isConstructor()) break; if (Flags.isStatic(((IMethod) element).getFlags()) || Flags.isPrivate(((IMethod) element).getFlags())) return new RenameNonVirtualMethodProcessor((IMethod) element); else return new RenameVirtualMethodProcessor((IMethod) element); case IJavaElement.TYPE_PARAMETER: return new RenameTypeParameterProcessor((ITypeParameter)element); case IJavaElement.LOCAL_VARIABLE: return new RenameLocalVariableProcessor((ILocalVariable)element); } } catch (JavaModelException exc) { LOG.error("Error creating refactoring processor for " + element.getElementName(), exc); } return null; }
Example 6
Source File: JavaElementImageProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean isInterfaceOrAnnotationField(IMember element) throws JavaModelException { // always show the final symbol on interface fields if (element.getElementType() == IJavaElement.FIELD) { return JavaModelUtil.isInterfaceOrAnnotation(element.getDeclaringType()); } return false; }
Example 7
Source File: TypedSource.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static TypedSource[] createTypedSources(IJavaElement elem, SourceTuple tuple) throws CoreException { if (! ReorgUtils.isInsideCompilationUnit(elem)) return null; if (elem.getElementType() == IJavaElement.IMPORT_CONTAINER) return createTypedSourcesForImportContainer(tuple, (IImportContainer)elem); else if (elem.getElementType() == IJavaElement.FIELD) return new TypedSource[] {create(getFieldSource((IField)elem, tuple), elem.getElementType())}; return new TypedSource[] {create(getSourceOfDeclararationNode(elem, tuple.unit), elem.getElementType())}; }
Example 8
Source File: RenameEnumConstProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private RefactoringStatus initialize(JavaRefactoringArguments extended) { final String handle= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT); if (handle != null) { final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(extended.getProject(), handle, false); if (element == null || !element.exists() || element.getElementType() != IJavaElement.FIELD) return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.RENAME_ENUM_CONSTANT); else fField= (IField) element; } else return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT)); final String name= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME); if (name != null && !"".equals(name)) //$NON-NLS-1$ setNewElementName(name); else return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME)); final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES); if (references != null) { setUpdateReferences(Boolean.valueOf(references).booleanValue()); } else return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES)); final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES); if (matches != null) { setUpdateTextualMatches(Boolean.valueOf(matches).booleanValue()); } else return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES)); return new RefactoringStatus(); }
Example 9
Source File: DeleteChangeCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Change createDeleteChange(IJavaElement javaElement) throws JavaModelException { Assert.isTrue(! ReorgUtils.isInsideCompilationUnit(javaElement)); switch(javaElement.getElementType()){ case IJavaElement.PACKAGE_FRAGMENT_ROOT: return createPackageFragmentRootDeleteChange((IPackageFragmentRoot)javaElement); case IJavaElement.PACKAGE_FRAGMENT: return createSourceManipulationDeleteChange((IPackageFragment)javaElement); case IJavaElement.COMPILATION_UNIT: return createSourceManipulationDeleteChange((ICompilationUnit)javaElement); case IJavaElement.CLASS_FILE: //if this assert fails, it means that a precondition is missing Assert.isTrue(((IClassFile)javaElement).getResource() instanceof IFile); return createDeleteChange(((IClassFile)javaElement).getResource()); case IJavaElement.JAVA_MODEL: //cannot be done Assert.isTrue(false); return null; case IJavaElement.JAVA_PROJECT: //handled differently Assert.isTrue(false); return null; case IJavaElement.TYPE: case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: Assert.isTrue(false);//not done here return new NullChange(); default: Assert.isTrue(false);//there's no more kinds return new NullChange(); } }
Example 10
Source File: JavaElementUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String createSignature(IMember member){ switch (member.getElementType()){ case IJavaElement.FIELD: return createFieldSignature((IField)member); case IJavaElement.TYPE: return BasicElementLabels.getJavaElementName(((IType)member).getFullyQualifiedName('.')); case IJavaElement.INITIALIZER: return RefactoringCoreMessages.JavaElementUtil_initializer; case IJavaElement.METHOD: return createMethodSignature((IMethod)member); default: Assert.isTrue(false); return null; } }
Example 11
Source File: RenameEnumConstProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private RefactoringStatus initialize(JavaRefactoringArguments extended) { final String handle= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT); if (handle != null) { final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(extended.getProject(), handle, false); if (element == null || !element.exists() || element.getElementType() != IJavaElement.FIELD) { return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.RENAME_ENUM_CONSTANT); } else { fField= (IField) element; } } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT)); } final String name= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME); if (name != null && !"".equals(name)) { setNewElementName(name); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME)); } final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES); if (references != null) { setUpdateReferences(Boolean.valueOf(references).booleanValue()); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES)); } final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES); if (matches != null) { setUpdateTextualMatches(Boolean.valueOf(matches).booleanValue()); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES)); } return new RefactoringStatus(); }
Example 12
Source File: JavaSearchPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
final static boolean isSearchableType(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.TYPE: case IJavaElement.FIELD: case IJavaElement.METHOD: return true; } return false; }
Example 13
Source File: JavaElementUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static String createSignature(IMember member){ switch (member.getElementType()){ case IJavaElement.FIELD: return createFieldSignature((IField)member); case IJavaElement.TYPE: return BasicElementLabels.getJavaElementName(((IType)member).getFullyQualifiedName('.')); case IJavaElement.INITIALIZER: return RefactoringCoreMessages.JavaElementUtil_initializer; case IJavaElement.METHOD: return createMethodSignature((IMethod)member); default: Assert.isTrue(false); return null; } }
Example 14
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static boolean isEnumConstant(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.FIELD && isEnum(member); }
Example 15
Source File: GenericRefactoringHandleTransplanter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public final IJavaElement transplantHandle(IJavaElement element) { IJavaElement parent= element.getParent(); if (parent != null) { parent= transplantHandle(parent); // recursive } switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return transplantHandle((IJavaModel) element); case IJavaElement.JAVA_PROJECT: return transplantHandle((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return transplantHandle((IJavaProject) parent, (IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return transplantHandle((IPackageFragmentRoot) parent, (IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return transplantHandle((IPackageFragment) parent, (ICompilationUnit) element); case IJavaElement.CLASS_FILE: return transplantHandle((IPackageFragment) parent, (IClassFile) element); case IJavaElement.TYPE: return transplantHandle(parent, (IType) element); case IJavaElement.FIELD: return transplantHandle((IType) parent, (IField) element); case IJavaElement.METHOD: return transplantHandle((IType) parent, (IMethod) element); case IJavaElement.INITIALIZER: return transplantHandle((IType) parent, (IInitializer) element); case IJavaElement.PACKAGE_DECLARATION: return transplantHandle((ICompilationUnit) parent, (IPackageDeclaration) element); case IJavaElement.IMPORT_CONTAINER: return transplantHandle((ICompilationUnit) parent, (IImportContainer) element); case IJavaElement.IMPORT_DECLARATION: return transplantHandle((IImportContainer) parent, (IImportDeclaration) element); case IJavaElement.LOCAL_VARIABLE: return transplantHandle((ILocalVariable) element); case IJavaElement.TYPE_PARAMETER: return transplantHandle((IMember) parent, (ITypeParameter) element); case IJavaElement.ANNOTATION: return transplantHandle((IAnnotatable) parent, (IAnnotation) element); default: throw new IllegalArgumentException(element.toString()); } }
Example 16
Source File: ParameterGuesser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public Variable createVariable(IJavaElement element, IType enclosingType, String expectedType, int positionScore) throws JavaModelException { int variableType; int elementType= element.getElementType(); String elementName= element.getElementName(); String typeSignature; switch (elementType) { case IJavaElement.FIELD: { IField field= (IField) element; if (field.getDeclaringType().equals(enclosingType)) { variableType= Variable.FIELD; } else { variableType= Variable.INHERITED_FIELD; } if (field.isResolved()) { typeSignature= new BindingKey(field.getKey()).toSignature(); } else { typeSignature= field.getTypeSignature(); } break; } case IJavaElement.LOCAL_VARIABLE: { ILocalVariable locVar= (ILocalVariable) element; variableType= Variable.LOCAL; typeSignature= locVar.getTypeSignature(); break; } case IJavaElement.METHOD: { IMethod method= (IMethod) element; if (isMethodToSuggest(method)) { if (method.getDeclaringType().equals(enclosingType)) { variableType= Variable.METHOD; } else { variableType= Variable.INHERITED_METHOD; } if (method.isResolved()) { typeSignature= Signature.getReturnType(new BindingKey(method.getKey()).toSignature()); } else { typeSignature= method.getReturnType(); } elementName= elementName + "()"; //$NON-NLS-1$ } else { return null; } break; } default: return null; } String type= Signature.toString(typeSignature); boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type); return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore, NO_TRIGGERS, getImageDescriptor(element)); }
Example 17
Source File: RenameFieldProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private RefactoringStatus initialize(JavaRefactoringArguments extended) { final String handle= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT); if (handle != null) { final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(extended.getProject(), handle, false); if (element == null || !element.exists() || element.getElementType() != IJavaElement.FIELD) { return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.RENAME_FIELD); } else { fField= (IField) element; } } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT)); } final String name= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME); if (name != null && !"".equals(name)) { setNewElementName(name); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME)); } final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES); if (references != null) { fUpdateReferences= Boolean.valueOf(references).booleanValue(); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES)); } final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES); if (matches != null) { fUpdateTextualMatches= Boolean.valueOf(matches).booleanValue(); } else { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES)); } final String getters= extended.getAttribute(ATTRIBUTE_RENAME_GETTER); if (getters != null) { fRenameGetter= Boolean.valueOf(getters).booleanValue(); } else { fRenameGetter= false; } final String setters= extended.getAttribute(ATTRIBUTE_RENAME_SETTER); if (setters != null) { fRenameSetter= Boolean.valueOf(setters).booleanValue(); } else { fRenameSetter= false; } final String delegate= extended.getAttribute(ATTRIBUTE_DELEGATE); if (delegate != null) { fDelegateUpdating= Boolean.valueOf(delegate).booleanValue(); } else { fDelegateUpdating= false; } final String deprecate= extended.getAttribute(ATTRIBUTE_DEPRECATE); if (deprecate != null) { fDelegateDeprecation= Boolean.valueOf(deprecate).booleanValue(); } else { fDelegateDeprecation= false; } return new RefactoringStatus(); }
Example 18
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private static boolean isEnumConstant(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.FIELD && isEnum(member); }
Example 19
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Computes the content description for the call hierarchy computation. * * @param includeMask the include mask * @return the content description * @since 3.7 */ private String computeContentDescription(int includeMask) { // see also HistoryAction.getElementLabel(IMember[]) String scopeDescription= fSearchScopeActions.getFullDescription(includeMask); if (fInputElements.length == 1) { IMember element= fInputElements[0]; String elementName= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); String[] args= new String[] { elementName, scopeDescription }; if (fCurrentCallMode == CALL_MODE_CALLERS) { switch (element.getElementType()) { case IJavaElement.TYPE: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToConstructors, args); case IJavaElement.FIELD: switch (this.fCurrentFieldMode) { case IJavaSearchConstants.READ_ACCESSES: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldRead, args); case IJavaSearchConstants.WRITE_ACCESSES: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldWrite, args); default: // all references return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToField, args); } case IJavaElement.METHOD: case IJavaElement.INITIALIZER: default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMethod, args); } } else { switch (element.getElementType()) { case IJavaElement.TYPE: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromConstructors, args); case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod, args); } } } else { if (fCurrentCallMode == CALL_MODE_CALLERS) { switch (fInputElements.length) { case 0: Assert.isTrue(false); return null; case 2: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_2, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_more, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); } } else { switch (fInputElements.length) { case 0: Assert.isTrue(false); return null; case 2: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_2, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_more, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); } } } }
Example 20
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Appends the label for a Java element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags. */ public void appendElementLabel(IJavaElement element, long flags) { int type= element.getElementType(); IPackageFragmentRoot root= null; if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) root= JavaModelUtil.getPackageFragmentRoot(element); if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) { appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); fBuffer.append(JavaElementLabels.CONCAT_STRING); } switch (type) { case IJavaElement.METHOD: appendMethodLabel((IMethod) element, flags); break; case IJavaElement.FIELD: appendFieldLabel((IField) element, flags); break; case IJavaElement.LOCAL_VARIABLE: appendLocalVariableLabel((ILocalVariable) element, flags); break; case IJavaElement.TYPE_PARAMETER: appendTypeParameterLabel((ITypeParameter) element, flags); break; case IJavaElement.INITIALIZER: appendInitializerLabel((IInitializer) element, flags); break; case IJavaElement.TYPE: appendTypeLabel((IType) element, flags); break; case IJavaElement.CLASS_FILE: appendClassFileLabel((IClassFile) element, flags); break; case IJavaElement.COMPILATION_UNIT: appendCompilationUnitLabel((ICompilationUnit) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT: appendPackageFragmentLabel((IPackageFragment) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags); break; case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.PACKAGE_DECLARATION: appendDeclarationLabel(element, flags); break; case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: fBuffer.append(element.getElementName()); break; default: fBuffer.append(element.getElementName()); } if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) { int offset= fBuffer.length(); fBuffer.append(JavaElementLabels.CONCAT_STRING); appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); if (getFlag(flags, JavaElementLabels.COLORIZE)) { fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); } } }