Example usage for org.eclipse.jdt.core Flags isDeprecated

List of usage examples for org.eclipse.jdt.core Flags isDeprecated

Introduction

In this page you can find the example usage for org.eclipse.jdt.core Flags isDeprecated.

Prototype

public static boolean isDeprecated(int flags) 

Source Link

Document

Returns whether the given integer includes the indication that the element is deprecated (@deprecated tag in Javadoc comment).

Usage

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isDeprecated(IMember member) throws JavaModelException {
    return Flags.isDeprecated(member.getFlags());
}

From source file:com.redhat.ceylon.eclipse.code.explorer.JavaElementImageProvider.java

License:Open Source License

private int computeJavaAdornmentFlags(IJavaElement element, int renderFlags) {
    int flags = 0;
    if (showOverlayIcons(renderFlags)) {
        try {/*  w  ww.ja v  a  2s .com*/
            if (element instanceof IMember) {
                IMember member = (IMember) element;

                int modifiers = member.getFlags();
                if (Flags.isAbstract(modifiers) && confirmAbstract(member))
                    flags |= JavaElementImageDescriptor.ABSTRACT;
                if (Flags.isFinal(modifiers) || isInterfaceOrAnnotationField(member)
                        || isEnumConstant(member, modifiers))
                    flags |= JavaElementImageDescriptor.FINAL;
                if (Flags.isStatic(modifiers) || isInterfaceOrAnnotationFieldOrType(member)
                        || isEnumConstant(member, modifiers))
                    flags |= JavaElementImageDescriptor.STATIC;

                if (Flags.isDeprecated(modifiers))
                    flags |= JavaElementImageDescriptor.DEPRECATED;

                int elementType = element.getElementType();
                if (elementType == IJavaElement.METHOD) {
                    if (((IMethod) element).isConstructor())
                        flags |= JavaElementImageDescriptor.CONSTRUCTOR;
                    if (Flags.isSynchronized(modifiers)) // collides with 'super' flag
                        flags |= JavaElementImageDescriptor.SYNCHRONIZED;
                    if (Flags.isNative(modifiers))
                        flags |= JavaElementImageDescriptor.NATIVE;
                }

                if (member.getElementType() == IJavaElement.TYPE) {
                    if (JavaModelUtil.hasMainMethod((IType) member)) {
                        flags |= JavaElementImageDescriptor.RUNNABLE;
                    }
                }

                if (member.getElementType() == IJavaElement.FIELD) {
                    if (Flags.isVolatile(modifiers))
                        flags |= JavaElementImageDescriptor.VOLATILE;
                    if (Flags.isTransient(modifiers))
                        flags |= JavaElementImageDescriptor.TRANSIENT;
                }
            } else if (element instanceof ILocalVariable
                    && Flags.isFinal(((ILocalVariable) element).getFlags())) {
                flags |= JavaElementImageDescriptor.FINAL;
            }
        } catch (JavaModelException e) {
            // do nothing. Can't compute runnable adornment or get flags
        }
    }
    return flags;
}

From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java

License:Open Source License

/**
 * Explores the Java type representing an annotation and create the matching Ariadne annotation in the
 * given Ariadne types container.//from w ww  .  j  av a  2  s  . c  o  m
 * 
 * @param iType
 *            The Java annotation
 * @param typesContainer
 *            The Ariadne types container
 * @param monitor
 *            The progress monitor
 * @return The Ariadne annotation created
 */
private Annotation exploreAnnotation(IType iType, TypesContainer typesContainer, IProgressMonitor monitor) {
    Annotation annotation = null;
    try {
        List<Type> types = typesContainer.getTypes();
        for (Type aType : types) {
            if (aType instanceof Annotation
                    && aType.getQualifiedName().equals(iType.getFullyQualifiedParameterizedName())) {
                annotation = (Annotation) aType;
            }
        }

        if (annotation == null) {
            annotation = CodeFactory.eINSTANCE.createAnnotation();
            annotation.setQualifiedName(iType.getFullyQualifiedParameterizedName());
        }

        if (annotation != null) {
            typesContainer.getTypes().add(annotation);

            String javadoc = this.getJavadoc(iType, monitor);
            annotation.setDescription(javadoc);
            annotation.setVersion(this.getVersionFromJavadoc(javadoc));

            int flags = iType.getFlags();

            if (Flags.isDeprecated(flags)) {
                // Add the property "Deprecated"
                this.addDeprecatedProperty(annotation);
            }
            annotation.setVisibility(this.getVisibility(iType, false));

            // Explore the fields
            IField[] fields = iType.getFields();
            for (IField iField : fields) {
                this.exploreField(iField, annotation, monitor);
            }

            // Set up the annotations dependencies
            IAnnotation[] annotations = iType.getAnnotations();
            for (IAnnotation iAnnotation : annotations) {
                Annotation ariadneAnnotation = this.getOrCreateAnnotation(iAnnotation);
                if (ariadneAnnotation != null) {
                    annotation.getAnnotations().add(ariadneAnnotation);
                }
            }

            // Set up the reference dependencies (import)
            ICompilationUnit compilationUnit = iType.getCompilationUnit();
            if (compilationUnit != null) {
                IImportDeclaration[] imports = compilationUnit.getImports();
                for (IImportDeclaration iImportDeclaration : imports) {
                    if (!iImportDeclaration.getElementName().endsWith("*")) { //$NON-NLS-1$
                        Classifier classifier = this.getOrCreateClassifier(iImportDeclaration.getElementName());
                        if (classifier != null) {
                            VersionedDependency versionedDependency = CoreFactory.eINSTANCE
                                    .createVersionedDependency();
                            versionedDependency.setVersionedElement(classifier);
                            annotation.getVersionedDependencies().add(versionedDependency);
                        }
                    } else {
                        // TODO Support "*" import
                    }
                }
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return annotation;
}

From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java

License:Open Source License

/**
 * Explores the Java type representing a classifier (enumeration, interface, class) and create the
 * matching Ariadne classifier in the given types container.
 * /*  w  w w.j av  a 2  s.c  om*/
 * @param iType
 *            The Java class, enumeration or interface
 * @param typesContainer
 *            The Ariadne types container
 * @param monitor
 *            The progress monitor
 * @return The Ariadne classifier created
 */
private Classifier exploreClassifier(IType iType, TypesContainer typesContainer, IProgressMonitor monitor) {
    Classifier classifier = null;
    try {
        List<Type> types = typesContainer.getTypes();
        for (Type aType : types) {
            if (aType instanceof Classifier
                    && aType.getQualifiedName().equals(iType.getFullyQualifiedParameterizedName())) {
                classifier = (Classifier) aType;
            }
        }

        if (classifier == null) {
            classifier = CodeFactory.eINSTANCE.createClassifier();
            classifier.setName(iType.getElementName());
            classifier.setQualifiedName(iType.getFullyQualifiedParameterizedName());
        }

        if (classifier != null) {
            typesContainer.getTypes().add(classifier);

            String javadoc = this.getJavadoc(iType, monitor);
            classifier.setDescription(javadoc);
            classifier.setVersion(this.getVersionFromJavadoc(javadoc));

            int flags = iType.getFlags();
            if (Flags.isInterface(flags)) {
                classifier.setKind(ClassifierKind.INTERFACE);
            } else if (Flags.isEnum(flags)) {
                classifier.setKind(ClassifierKind.ENUMERATION);
            } else {
                classifier.setKind(ClassifierKind.CLASS);
            }

            if (Flags.isDeprecated(flags)) {
                // Add the property "Deprecated"
                this.addDeprecatedProperty(classifier);
            }
            classifier.setFinal(Flags.isFinal(flags));
            classifier.setStatic(Flags.isStatic(flags));
            classifier.setVisibility(this.getVisibility(iType, false));

            // Explore the methods
            IMethod[] methods = iType.getMethods();
            for (IMethod iMethod : methods) {
                if (iMethod.isConstructor()) {
                    this.exploreConstructor(iMethod, classifier, Flags.isInterface(flags), monitor);
                } else {
                    this.exploreOperation(iMethod, classifier, Flags.isInterface(flags), monitor);
                }

            }

            // Explore the fields
            IField[] fields = iType.getFields();
            for (IField iField : fields) {
                this.exploreField(iField, classifier, Flags.isInterface(flags), monitor);
            }

            // Set up the annotations dependencies
            IAnnotation[] annotations = iType.getAnnotations();
            for (IAnnotation iAnnotation : annotations) {
                Annotation ariadneAnnotation = this.getOrCreateAnnotation(iAnnotation);
                if (ariadneAnnotation != null) {
                    classifier.getAnnotations().add(ariadneAnnotation);
                }
            }

            // Set up the reference dependencies (import)
            ICompilationUnit compilationUnit = iType.getCompilationUnit();
            if (compilationUnit != null) {
                IImportDeclaration[] imports = compilationUnit.getImports();
                for (IImportDeclaration iImportDeclaration : imports) {
                    if (!iImportDeclaration.getElementName().endsWith("*")) { //$NON-NLS-1$
                        Classifier ariadneClassifier = this
                                .getOrCreateClassifier(iImportDeclaration.getElementName());
                        if (ariadneClassifier != null) {
                            VersionedDependency versionedDependency = CoreFactory.eINSTANCE
                                    .createVersionedDependency();
                            versionedDependency.setVersionedElement(ariadneClassifier);
                            classifier.getVersionedDependencies().add(versionedDependency);
                        }
                    } else {
                        // TODO Support "*" import
                    }
                }
            }

            // Set up the inhenritance dependencies
            String superclassName = iType.getSuperclassName();
            Classifier ariadneClassifier = this.getOrCreateClassifier(superclassName);
            if (ariadneClassifier != null) {
                classifier.getSuperTypes().add(ariadneClassifier);
            }

            String[] superInterfaceNames = iType.getSuperInterfaceNames();
            for (String superInterfaceName : superInterfaceNames) {
                ariadneClassifier = this.getOrCreateClassifier(superInterfaceName);
                if (ariadneClassifier != null) {
                    classifier.getSuperTypes().add(ariadneClassifier);
                }
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return classifier;
}

From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java

License:Open Source License

/**
 * Explores the given Java constructor and create a matching Ariadne constructor in the given Ariadne
 * classifier.//from www .  j a v a2s .c  o m
 * 
 * @param iMethod
 *            The Java method to analyzed
 * @param classifier
 *            The Ariadne classifier
 * @param isInterface
 *            Indicates if the Java classifier containing the method is an interface
 * @param monitor
 *            The progress monitor
 */
private void exploreConstructor(IMethod iMethod, Classifier classifier, boolean isInterface,
        IProgressMonitor monitor) {
    Constructor constructor = null;
    for (Constructor aConstructor : classifier.getConstructors()) {
        if (aConstructor.getQualifiedName().equals(this.getQualifiedName(iMethod, isInterface))) {
            constructor = aConstructor;
        }
    }

    if (constructor == null) {
        constructor = CodeFactory.eINSTANCE.createConstructor();
        constructor.setQualifiedName(this.getQualifiedName(iMethod, isInterface));
        constructor.setName(iMethod.getElementName());
    }

    if (constructor != null) {
        String javadoc = this.getJavadoc(iMethod, monitor);
        constructor.setDescription(javadoc);
        constructor.setVersion(this.getVersionFromJavadoc(javadoc));
        constructor.setVisibility(this.getVisibility(iMethod, isInterface));

        try {
            int flags = iMethod.getFlags();

            constructor.setFinal(Flags.isFinal(flags));
            constructor.setStatic(Flags.isStatic(flags));
            if (Flags.isDeprecated(flags)) {
                // Add the property "Deprecated"
                this.addDeprecatedProperty(constructor);
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }

        try {
            // Explore parameters
            ILocalVariable[] parameters = iMethod.getParameters();
            // If we don't have any parameters yet, we create them
            if (parameters.length > 0 && constructor.getParameters().size() == 0) {
                for (ILocalVariable iLocalVariable : parameters) {
                    String typeSignature = iLocalVariable.getTypeSignature();

                    Parameter parameter = CodeFactory.eINSTANCE.createParameter();
                    parameter.setQualifiedName(Signature.toString(typeSignature));
                    parameter.setFinal(Flags.isFinal(iLocalVariable.getFlags()));
                    if (Flags.isDeprecated(iLocalVariable.getFlags())) {
                        // Add the property "Deprecated"
                        this.addDeprecatedProperty(parameter);
                    }
                    constructor.getParameters().add(parameter);

                    // Set the typing dependency
                    String signature = Signature.toString(iLocalVariable.getTypeSignature());
                    Classifier ariadneClassifier = this.getOrCreateClassifier(signature);
                    if (ariadneClassifier != null) {
                        parameter.getTypes().add(ariadneClassifier);
                    }
                }
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }
    }
}

From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java

License:Open Source License

/**
 * Explores the given Java method and create a matching Ariadne operation in the given Ariadne classifier.
 * //  w  w  w.  j  a  v a 2s . co  m
 * @param iMethod
 *            The Java method to analyzed
 * @param classifier
 *            The Ariadne classifier
 * @param isInterface
 *            Indicates if the Java classifier containing the method is an interface
 * @param monitor
 *            The progress monitor
 */
private void exploreOperation(IMethod iMethod, Classifier classifier, boolean isInterface,
        IProgressMonitor monitor) {
    Operation operation = null;
    List<Operation> operations = classifier.getOperations();
    for (Operation anOperation : operations) {
        if (anOperation.getQualifiedName().equals(this.getQualifiedName(iMethod, isInterface))) {
            operation = anOperation;
        }
    }

    if (operation == null) {
        operation = CodeFactory.eINSTANCE.createOperation();
        operation.setQualifiedName(this.getQualifiedName(iMethod, isInterface));
        operation.setName(iMethod.getElementName());
        classifier.getOperations().add(operation);
    }

    if (operation != null) {
        String javadoc = this.getJavadoc(iMethod, monitor);
        operation.setDescription(javadoc);
        operation.setVersion(this.getVersionFromJavadoc(javadoc));
        operation.setVisibility(this.getVisibility(iMethod, isInterface));

        try {
            int flags = iMethod.getFlags();

            operation.setFinal(Flags.isFinal(flags));
            operation.setStatic(Flags.isStatic(flags));
            if (Flags.isDeprecated(flags)) {
                // Add the property "Deprecated"
                this.addDeprecatedProperty(operation);
            }

            // Set the return type
            String returnType = Signature.toString(iMethod.getReturnType());
            Classifier ariadneClassifier = this.getOrCreateClassifier(returnType);
            if (ariadneClassifier != null) {
                operation.getReturnTypes().add(ariadneClassifier);
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }

        try {
            // Explore parameters
            ILocalVariable[] parameters = iMethod.getParameters();
            // If we don't have any parameters yet, we create them
            if (parameters.length > 0 && operation.getParameters().size() == 0) {
                for (ILocalVariable iLocalVariable : parameters) {
                    String typeSignature = iLocalVariable.getTypeSignature();

                    Parameter parameter = CodeFactory.eINSTANCE.createParameter();
                    parameter.setName(iLocalVariable.getElementName());
                    parameter.setQualifiedName(
                            Signature.toString(typeSignature) + ' ' + iLocalVariable.getElementName());
                    parameter.setFinal(Flags.isFinal(iLocalVariable.getFlags()));
                    if (Flags.isDeprecated(iLocalVariable.getFlags())) {
                        // Add the property "Deprecated"
                        this.addDeprecatedProperty(parameter);
                    }
                    operation.getParameters().add(parameter);

                    // Set the typing dependency
                    String signature = Signature.toString(iLocalVariable.getTypeSignature());
                    Classifier ariadneClassifier = this.getOrCreateClassifier(signature);
                    if (ariadneClassifier != null) {
                        parameter.getTypes().add(ariadneClassifier);
                    }
                }
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }
    }
}

From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java

License:Open Source License

/**
 * Explores the given Java field and created a matching Ariadne field in the given Ariadne classifier.
 * /* w  w w .  j  a v a2s  . c  o m*/
 * @param iField
 *            The Java field to analyze
 * @param classifier
 *            The Ariadne classifier
 * @param isInInterface
 *            Indicates if the given field is located in a Java interface
 * @param monitor
 *            The progress monitor
 */
private void exploreField(IField iField, Classifier classifier, boolean isInInterface,
        IProgressMonitor monitor) {
    Field field = null;
    List<Field> fields = classifier.getFields();
    for (Field aField : fields) {
        if (aField.getQualifiedName().equals(this.getQualifiedName(iField, isInInterface))) {
            field = aField;
        }
    }

    if (field == null) {
        field = CodeFactory.eINSTANCE.createField();
        field.setQualifiedName(this.getQualifiedName(iField, isInInterface));
        field.setName(iField.getElementName());
        classifier.getFields().add(field);
    }

    if (field != null) {
        String javadoc = this.getJavadoc(iField, monitor);
        field.setDescription(javadoc);
        field.setVersion(this.getVersionFromJavadoc(javadoc));
        field.setVisibility(this.getVisibility(iField, isInInterface));

        try {
            int flags = iField.getFlags();

            field.setFinal(Flags.isFinal(flags));
            field.setStatic(Flags.isStatic(flags));
            if (Flags.isDeprecated(flags)) {
                // Add the property "Deprecated"
                this.addDeprecatedProperty(field);
            }

            // Set the typing dependency
            String signature = Signature.toString(iField.getTypeSignature());
            Classifier ariadneClassifier = this.getOrCreateClassifier(signature);
            if (ariadneClassifier != null) {
                field.getTypes().add(ariadneClassifier);
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.java

License:Apache License

private ICompletionProposal proposeConstructor(char[] simpleTypeName, int parameterCount, char[] signature,
        char[][] parameterTypes, char[][] parameterNames, int modifiers, char[] packageName, int typeModifiers,
        int accessibility, char[] typeName, char[] fullyQualifiedName, boolean isQualified, int extraFlags) {

    // only show context information and only for methods
    // that exactly match the name. This happens when we are at the
    // start of an argument or an open paren
    String simpleTypeNameStr = String.valueOf(simpleTypeName);
    String fullyQualifiedNameStr = String.valueOf(fullyQualifiedName);
    if (contextOnly && !completionExpression.equals(simpleTypeNameStr)
            && !completionExpression.equals(fullyQualifiedNameStr)) {
        return null;
    }/*www. j  a va 2  s  .  c  o  m*/

    char[] typeCompletion;
    if (isQualified) {
        typeCompletion = fullyQualifiedName;
        if (packageName == null || packageName.length == 0) {
            typeCompletion = simpleTypeName;
        }
    } else {
        typeCompletion = simpleTypeName;
    }

    float relevanceMultiplier = 1;
    relevanceMultiplier += accessibility == IAccessRule.K_ACCESSIBLE ? 2 : -1;
    relevanceMultiplier += computeRelevanceForCaseMatching(this.completionExpression.toCharArray(),
            simpleTypeName);

    int augmentedModifiers = modifiers;
    if (Flags.isDeprecated(typeModifiers)) {
        augmentedModifiers |= Flags.AccDeprecated;
    }

    if (parameterCount == -1) {
        // default constructor
        parameterNames = CharOperation.NO_CHAR_CHAR;
        parameterTypes = CharOperation.NO_CHAR_CHAR;
    } else {
        int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length;
        if (parameterCount != parameterNamesLength) {
            parameterNames = null;
        }
    }

    GroovyCompletionProposal proposal = createProposal(
            contextOnly ? CompletionProposal.METHOD_REF : CompletionProposal.CONSTRUCTOR_INVOCATION,
            offset - 1);
    char[] declarationSignature = CompletionEngine.createNonGenericTypeSignature(packageName, typeName);
    proposal.setDeclarationSignature(declarationSignature);

    if (contextOnly) {
        proposal.setReplaceRange(actualCompletionPosition, actualCompletionPosition);
        proposal.setTokenRange(actualCompletionPosition, actualCompletionPosition);
        proposal.setCompletion(CharOperation.NO_CHAR);
    } else {
        // otherwise this is a normal constructor proposal
        proposal.setCompletion(this.completionExpression.toCharArray());
        // looks strange, but this is just copying similar code in
        // CompletionEngine.java
        proposal.setReplaceRange(this.offset + this.replaceLength, this.offset + this.replaceLength);
        proposal.setTokenRange(this.offset, this.actualCompletionPosition);
        proposal.setCompletion(new char[] { '(', ')' });

        // provides the import statement
        GroovyCompletionProposal typeProposal = createTypeProposal(packageName, typeModifiers, accessibility,
                typeName, fullyQualifiedName, isQualified, typeCompletion, augmentedModifiers,
                declarationSignature);
        proposal.setRequiredProposals(new CompletionProposal[] { typeProposal });
    }

    if (signature == null) {
        proposal.setSignature(createConstructorSignature(parameterTypes, isQualified));
    } else {
        char[] copy = new char[signature.length];
        System.arraycopy(signature, 0, copy, 0, copy.length);
        CharOperation.replace(copy, '/', '.');
        proposal.setSignature(copy);
    }

    if (parameterNames != null) {
        proposal.setParameterNames(parameterNames);
    } else {
        proposal.setHasNoParameterNamesFromIndex(true);
        if (mockEngine == null) {
            // used for caching types only
            mockEngine = new CompletionEngine(null, new CompletionRequestor() {

                @Override
                public void accept(CompletionProposal proposal) {

                }
            }, null, null, null, null);
        }
        proposal.setCompletionEngine(mockEngine);
    }

    proposal.setDeclarationPackageName(packageName);
    proposal.setDeclarationTypeName(simpleTypeName);
    proposal.setParameterTypeNames(parameterTypes);
    // proposal.setParameterPackageNames(); not right
    proposal.setName(simpleTypeName);

    proposal.setIsContructor(true);

    proposal.setRelevance(Relevance.MEDIUM_HIGH.getRelevance(relevanceMultiplier));

    proposal.setFlags(augmentedModifiers);

    proposal.setTypeName(simpleTypeName);
    proposal.setAccessibility(typeModifiers);
    proposal.setPackageName(packageName);

    LazyJavaCompletionProposal lazyProposal = new GroovyJavaMethodCompletionProposal(proposal, javaContext,
            getProposalOptions());
    lazyProposal.setRelevance(proposal.getRelevance());
    if (proposal.hasParameters()) {
        lazyProposal.setTriggerCharacters(ProposalUtils.METHOD_WITH_ARGUMENTS_TRIGGERS);
    } else {
        lazyProposal.setTriggerCharacters(ProposalUtils.METHOD_TRIGGERS);
    }
    ImportRewrite r = groovyRewriter.getImportRewrite(monitor);
    if (r != null) {
        ReflectionUtils.setPrivateField(LazyJavaTypeCompletionProposal.class, "fImportRewrite", lazyProposal,
                r);
    }
    if (contextOnly) {
        ((GroovyJavaMethodCompletionProposal) lazyProposal).contextOnly();
    }

    return lazyProposal;
}

From source file:org.eclipse.ajdt.internal.ui.lazystart.ImageDecorator.java

License:Open Source License

private int computeJavaAdornmentFlags(IJavaElement element) {
    int flags = 0;
    if (true && element instanceof IMember) {
        try {// w  w w. ja  v a  2s  . c o  m
            IMember member = (IMember) element;

            if (element.getElementType() == IJavaElement.METHOD && ((IMethod) element).isConstructor())
                flags |= JavaElementImageDescriptor.CONSTRUCTOR;

            int modifiers = member.getFlags();
            if (Flags.isAbstract(modifiers) && confirmAbstract(member))
                flags |= JavaElementImageDescriptor.ABSTRACT;
            if (Flags.isFinal(modifiers) || isInterfaceField(member))
                flags |= JavaElementImageDescriptor.FINAL;
            if (Flags.isSynchronized(modifiers) && confirmSynchronized(member))
                flags |= JavaElementImageDescriptor.SYNCHRONIZED;
            if (Flags.isStatic(modifiers) || isInterfaceField(member))
                flags |= JavaElementImageDescriptor.STATIC;

            if (Flags.isDeprecated(modifiers))
                flags |= JavaElementImageDescriptor.DEPRECATED;

            if (member.getElementType() == IJavaElement.TYPE) {
                if (JavaModelUtil.hasMainMethod((IType) member)) {
                    flags |= JavaElementImageDescriptor.RUNNABLE;
                }
            }
        } catch (JavaModelException e) {
            // do nothing. Can't compute runnable adornment or get flags
            // can be ignored
        }
    }
    return flags;
}

From source file:org.eclipse.jst.jsp.ui.internal.java.views.TypeNameLabelProvider.java

License:Open Source License

private ImageDescriptor getImageDescriptor(TypeNameMatch match) {
    // TODO use isInner
    // final boolean isInner = match.getTypeContainerName().indexOf('.') != -1;
    final int modifiers = match.getModifiers();

    ImageDescriptor desc = getTypeImageDescriptor(modifiers);
    int adornmentFlags = 0;
    if (Flags.isFinal(modifiers)) {
        adornmentFlags |= JavaElementImageDescriptor.FINAL;
    }/*from w w  w  .ja  va2  s . co m*/
    if (Flags.isAbstract(modifiers) && !Flags.isInterface(modifiers)) {
        adornmentFlags |= JavaElementImageDescriptor.ABSTRACT;
    }
    if (Flags.isStatic(modifiers)) {
        adornmentFlags |= JavaElementImageDescriptor.STATIC;
    }
    if (Flags.isDeprecated(modifiers)) {
        adornmentFlags |= JavaElementImageDescriptor.DEPRECATED;
    }

    return new JavaElementImageDescriptor(desc, adornmentFlags, BIG_SIZE);
}