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

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

Introduction

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

Prototype

int AccInterface

To view the source code for org.eclipse.jdt.core Flags AccInterface.

Click Source Link

Document

Interface property flag.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.BasicSearchEngine.java

License:Open Source License

boolean match(char patternTypeSuffix, int modifiers) {
    switch (patternTypeSuffix) {
    case IIndexConstants.CLASS_SUFFIX:
        return (modifiers & (Flags.AccAnnotation | Flags.AccInterface | Flags.AccEnum)) == 0;
    case IIndexConstants.CLASS_AND_INTERFACE_SUFFIX:
        return (modifiers & (Flags.AccAnnotation | Flags.AccEnum)) == 0;
    case IIndexConstants.CLASS_AND_ENUM_SUFFIX:
        return (modifiers & (Flags.AccAnnotation | Flags.AccInterface)) == 0;
    case IIndexConstants.INTERFACE_SUFFIX:
        return (modifiers & Flags.AccInterface) != 0;
    case IIndexConstants.INTERFACE_AND_ANNOTATION_SUFFIX:
        return (modifiers & (Flags.AccInterface | Flags.AccAnnotation)) != 0;
    case IIndexConstants.ENUM_SUFFIX:
        return (modifiers & Flags.AccEnum) != 0;
    case IIndexConstants.ANNOTATION_TYPE_SUFFIX:
        return (modifiers & Flags.AccAnnotation) != 0;
    }//from   w ww  .  ja v  a  2  s  .  com
    return true;
}

From source file:com.salesforce.ide.ui.editors.apex.outline.icon.OutlineViewIconProvider.java

License:Open Source License

public Image handle(InterfaceDecl element) {
    AccessorFlags flags = computeAccessorFlags(element.modifiers);
    int accessorFlags_JVM = flags.accessorFlags_JVM;
    int accessorFlags_JDT = flags.accessorFlags_JDT;

    accessorFlags_JVM |= Flags.AccInterface;

    return getTypeImage(accessorFlags_JVM, accessorFlags_JDT, false);
}

From source file:com.salesforce.ide.ui.editors.apex.outline.icon.OutlineViewIconProvider.java

License:Open Source License

@Override
public Image handle(InnerInterfaceMember element) {
    AccessorFlags flags = computeAccessorFlags(element.body.modifiers);
    int accessorFlags_JVM = flags.accessorFlags_JVM;
    int accessorFlags_JDT = flags.accessorFlags_JDT;

    accessorFlags_JVM |= Flags.AccInterface;

    return getTypeImage(accessorFlags_JVM, accessorFlags_JDT, true);
}

From source file:org.eclipse.ajdt.internal.ui.editor.quickfix.AJSerialVersionHashOperation.java

License:Open Source License

private static Long calculateSerialVersionId(IClassFileReader cfReader) throws IOException {
    // implementing algorithm specified on http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#4100

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    DataOutputStream doos = new DataOutputStream(os);
    doos.writeUTF(getClassName(cfReader.getClassName())); // class name
    int mod = getClassModifiers(cfReader);
    //      System.out.println(Integer.toHexString(mod) + ' ' + Flags.toString(mod));

    int classModifiers = mod & (Flags.AccPublic | Flags.AccFinal | Flags.AccInterface | Flags.AccAbstract);

    doos.writeInt(classModifiers); // class modifiers
    char[][] interfaces = getSortedInterfacesNames(cfReader);
    for (int i = 0; i < interfaces.length; i++) {
        doos.writeUTF(getClassName(interfaces[i]));
    }//w  w  w . ja  v  a 2 s .c om
    IFieldInfo[] sortedFields = getSortedFields(cfReader);
    for (int i = 0; i < sortedFields.length; i++) {
        IFieldInfo curr = sortedFields[i];
        int flags = curr.getAccessFlags();
        if (!Flags.isPrivate(flags) || (!Flags.isStatic(flags) && !Flags.isTransient(flags))) {
            doos.writeUTF(new String(curr.getName()));
            doos.writeInt(flags & (Flags.AccPublic | Flags.AccPrivate | Flags.AccProtected | Flags.AccStatic
                    | Flags.AccFinal | Flags.AccVolatile | Flags.AccTransient)); // field modifiers
            doos.writeUTF(new String(curr.getDescriptor()));
        }
    }
    if (hasStaticClassInitializer(cfReader)) {
        doos.writeUTF(STATIC_CLASS_INITIALIZER);
        doos.writeInt(Flags.AccStatic);
        doos.writeUTF("()V"); //$NON-NLS-1$
    }
    IMethodInfo[] sortedMethods = getSortedMethods(cfReader);
    for (int i = 0; i < sortedMethods.length; i++) {
        IMethodInfo curr = sortedMethods[i];
        int flags = curr.getAccessFlags();
        if (!Flags.isPrivate(flags) && !curr.isClinit()) {
            doos.writeUTF(new String(curr.getName()));
            doos.writeInt(flags & (Flags.AccPublic | Flags.AccPrivate | Flags.AccProtected | Flags.AccStatic
                    | Flags.AccFinal | Flags.AccSynchronized | Flags.AccNative | Flags.AccAbstract
                    | Flags.AccStrictfp)); // method modifiers
            doos.writeUTF(getClassName(curr.getDescriptor()));
        }
    }
    doos.flush();
    return computeHash(os.toByteArray());
}

From source file:org.eclipse.emf.importer.java.builder.JavaEcoreBuilder.java

License:Open Source License

/**
 * Walks the type either as an EClass or an ENum to analyze either the methods or the fields.
 *//*  w w w  .  j ava  2 s .  co m*/
protected void analyzeType(JType type) {
    // Check whether this has @model annotation contents.
    // If not, it might be a package interface, for backwards compatibility.
    //
    String modelAnnotation = getModelAnnotation(type.getComment());
    boolean isEClassifier = false;
    String kind = null;

    if (modelAnnotation != null) {
        kind = getModelAnnotationAttribute(modelAnnotation, "kind");
        isEClassifier = !"package".equals(kind);
    }

    if (isEClassifier) {
        // Get the package name and see if there's an EPackage for it.
        //
        EPackage ePackage = getEPackage(type);

        // If it's an interface, then it will be treated as an EClass
        //
        if ((type.getFlags() & Flags.AccInterface) != 0 || "class".equals(kind)) {
            EClass eClass = EcoreFactory.eINSTANCE.createEClass();
            eModelElementToJNodeMap.put(eClass, type);
            eClass.setName(type.getName());
            ePackage.getEClassifiers().add(eClass);
            eClass.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
            EcoreUtil.setDocumentation(eClass, getModelDocumentation(type.getComment()));

            analyzeTypeParameters(eClass.getETypeParameters(), type.getTypeParameters(), modelAnnotation);

            String[] superInterfaces = type.getSuperInterfaces();
            String extend = getExtendsAnnotation(type.getComment());
            if (extend != null) {
                List<String> superInterfaceList = new ArrayList<String>(Arrays.asList(superInterfaces));
                Diagnostic diagnostic = EcoreValidator.EGenericTypeBuilder.INSTANCE
                        .parseTypeArgumentList(extend);
                if (diagnostic.getSeverity() == Diagnostic.OK) {
                    @SuppressWarnings("unchecked")
                    List<EGenericType> eTypeArguments = (List<EGenericType>) diagnostic.getData().get(0);
                    for (EGenericType eGenericType : eTypeArguments) {
                        superInterfaceList.remove(EcoreUtil.toJavaInstanceTypeName(eGenericType));
                    }
                }
                superInterfaces = new String[superInterfaceList.size()];
                superInterfaceList.toArray(superInterfaces);
            }

            // Create a generic super type with an EClass as the classifier for each super interface in the Java representation.
            //
            List<EGenericType> javaEGenericSuperTypes = new ArrayList<EGenericType>();
            for (String superType : superInterfaces) {
                Diagnostic diagnostic = EcoreValidator.EGenericTypeBuilder.INSTANCE
                        .parseInstanceTypeName(superType);
                if (diagnostic.getSeverity() == Diagnostic.OK) {
                    EGenericType eGenericSuperType = (EGenericType) diagnostic.getData().get(0);
                    EClass eSuperClass = EcoreFactory.eINSTANCE.createEClass();
                    eSuperClass.setAbstract(true);
                    eSuperClass.setInterface(true);
                    eSuperClass.setInstanceTypeName(eGenericSuperType.getEClassifier().getInstanceTypeName());
                    eGenericSuperType.setEClassifier(eSuperClass);
                    javaEGenericSuperTypes.add(eGenericSuperType);
                }
            }

            // Create a generic super type with an EClass as the classifier for each super interface in the @model representation
            //
            List<EGenericType> ecoreEGenericSuperTypes = null;
            String superTypes = getModelAnnotationAttribute(modelAnnotation, "superTypes");
            if (superTypes != null) {
                ecoreEGenericSuperTypes = new ArrayList<EGenericType>();
                for (EGenericType ecoreEGenericSuperType : analyzeEGenericTypes(superTypes)) {
                    EClass eSuperClass = EcoreFactory.eINSTANCE.createEClass();
                    eSuperClass.setAbstract(true);
                    eSuperClass.setInterface(true);
                    eSuperClass
                            .setInstanceTypeName(ecoreEGenericSuperType.getEClassifier().getInstanceTypeName());
                    ecoreEGenericSuperType.setEClassifier(eSuperClass);
                    ecoreEGenericSuperTypes.add(ecoreEGenericSuperType);
                }
            }

            // Filter out explicit EObject from super types, except in the Ecore package itself, or if it appears in the @model superTypes.
            //
            if (!javaEGenericSuperTypes.isEmpty()
                    && javaEGenericSuperTypes.get(0).getERawType().getInstanceTypeName().endsWith("EObject")
                    && (ecoreEGenericSuperTypes == null
                            || !ecoreEGenericSuperTypes.isEmpty() && !ecoreEGenericSuperTypes.get(0)
                                    .getERawType().getInstanceTypeName().endsWith("EObject"))
                    && !EcorePackage.eNS_URI.equals(ePackage.getNsURI())) {
                EGenericType superType = resolve(eClass,
                        javaEGenericSuperTypes.get(0).getERawType().getInstanceTypeName(),
                        RequiredClassifierType.CLASS, false);
                EClassifier superClass = superType.getEClassifier();
                if (superClass.getEPackage() != null
                        && EcorePackage.eNS_URI.equals(superClass.getEPackage().getNsURI())
                        && "EObject".equals(superClass.getName())) {
                    javaEGenericSuperTypes.remove(0);
                }
            }

            // Match them and accumulate the appropriate result.
            //
            match(eClass.getEGenericSuperTypes(), javaEGenericSuperTypes, ecoreEGenericSuperTypes);

            String isInterface = getModelAnnotationAttribute(modelAnnotation, "interface");
            eClass.setInterface("true".equals(isInterface));

            String isAbstract = getModelAnnotationAttribute(modelAnnotation, "abstract");
            eClass.setAbstract("true".equals(isAbstract) || isAbstract == null && eClass.isInterface());

            // Walk the methods.
            //
            for (JMethod method : facadeHelper.getChildren(type, JMethod.class)) {
                analyzeMethod(eClass, method);
            }

            // Additional attributes and references may be defined directly on the interface in order to allow the
            // get accessor method to have suppressed visibility.
            //
            String features = getModelAnnotationAttribute(modelAnnotation, "features");
            if (features != null) {
                for (StringTokenizer stringTokenizer = new StringTokenizer(features, " "); stringTokenizer
                        .hasMoreTokens();) {
                    String feature = stringTokenizer.nextToken();
                    if (eClass.getEStructuralFeature(feature) == null) {
                        analyzeMethod(eClass, getFilteredModelAnnotations(modelAnnotation, feature),
                                "get" + Character.toUpperCase(feature.charAt(0)) + feature.substring(1),
                                "java.lang.Object", EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY,
                                EMPTY_STRING_ARRAY);
                    } else {
                        warning(CodeGenEcorePlugin.INSTANCE.getString("_UI_DuplicateFeature_message",
                                new Object[] { feature, eClass.getName() }));
                    }
                }
            }
        }
        // Otherwise it's treated as an EEnum
        //
        else {
            EEnum eEnum = EcoreFactory.eINSTANCE.createEEnum();
            eModelElementToJNodeMap.put(eEnum, type);
            eEnum.setName(type.getName());
            ePackage.getEClassifiers().add(eEnum);
            eEnum.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
            EcoreUtil.setDocumentation(eEnum, getModelDocumentation(type.getComment()));

            // Walk the fields.
            //
            for (JField field : facadeHelper.getChildren(type, JField.class)) {
                analyzeEnumLiteral(eEnum, field);
            }
        }
    }
    // Find Packages and Factories
    else {
        JPackage jPackage = facadeHelper.getPackage(type);
        String qualifiedPackageName = jPackage != null ? jPackage.getQualifiedName() : null;

        String typeName = type.getName();
        boolean isEPackage = false;
        if (typeName.endsWith("Package") && typeName.length() > 7) {
            String packagePrefix = typeName.substring(0, typeName.length() - 7);

            // It's definitely a package if it was declared as such.
            //
            if ("package".equals(kind)) {
                isEPackage = true;
            }

            int index = qualifiedPackageName == null ? -1 : qualifiedPackageName.lastIndexOf(".");
            String name = index == -1 ? qualifiedPackageName : qualifiedPackageName.substring(index + 1);
            String nsURI = "http:///"
                    + (qualifiedPackageName == null ? "null" : qualifiedPackageName.replace('.', '/'))
                    + ".ecore";
            String nsPrefix = qualifiedPackageName == null ? "null" : qualifiedPackageName;

            List<EClass> eClasses = new ArrayList<EClass>();
            List<EDataType> eDataTypes = new ArrayList<EDataType>();
            Map<Object, Integer> ordering = new HashMap<Object, Integer>();

            // It's definitely a package if expected constants eNAME, eNS_PREFIX, or eNS_URI appear.
            //
            for (JNode node : type.getChildren()) {
                if (node instanceof JField) {
                    JField field = (JField) node;
                    String fieldName = field.getName();
                    String fieldType = field.getType();
                    if ("eNAME".equals(fieldName)) {
                        isEPackage = true;
                        name = field.getInitializer();
                        name = name.substring(1, name.length() - 1);
                    } else if ("eNS_URI".equals(fieldName)) {
                        isEPackage = true;
                        nsURI = field.getInitializer();
                        nsURI = nsURI.substring(1, nsURI.length() - 1);
                    } else if ("eNS_PREFIX".equals(fieldName)) {
                        isEPackage = true;
                        nsPrefix = field.getInitializer();
                        nsPrefix = nsPrefix.substring(1, nsPrefix.length() - 1);
                    } else if ("int".equals(fieldType) && !fieldName.endsWith("FEATURE_COUNT")) {
                        try {
                            String initializer = field.getInitializer();
                            int plusIndex = initializer.lastIndexOf("+");
                            if (plusIndex != -1) {
                                initializer = initializer.substring(plusIndex + 1);
                            }
                            initializer = initializer.trim();
                            int value = Integer.parseInt(initializer);
                            ordering.put(fieldName, value);
                        } catch (NumberFormatException exception) {
                            // This will catch inherited features, or additional things we don't want to worry about.
                        }
                    }
                } else if (node instanceof JMethod) {
                    JMethod method = (JMethod) node;
                    String methodAnnotation = getModelAnnotation(method.getComment());
                    if (methodAnnotation != null) {
                        String returnType = method.getReturnType();
                        if (returnType != null) {
                            if (returnType.endsWith("EDataType")) {
                                EDataType eDataType = EcoreFactory.eINSTANCE.createEDataType();
                                eDataType.setInstanceTypeName(
                                        getModelAnnotationAttribute(methodAnnotation, "instanceClass"));
                                eDataType.setName(method.getName().substring(3));
                                String isSerializable = getModelAnnotationAttribute(methodAnnotation,
                                        "serializable");
                                if ("false".equals(isSerializable)) {
                                    eDataType.setSerializable(false);
                                }

                                String typeParameterNames = getModelAnnotationAttribute(methodAnnotation,
                                        "typeParameters");
                                if (typeParameterNames != null) {
                                    for (StringTokenizer stringTokenizer = new StringTokenizer(
                                            typeParameterNames, " "); stringTokenizer.hasMoreTokens();) {
                                        String typeParameterName = stringTokenizer.nextToken();
                                        ETypeParameter eTypeParameter = EcoreFactory.eINSTANCE
                                                .createETypeParameter();
                                        eTypeParameter.setName(typeParameterName);
                                        String typeParameterModelAnnotation = getFilteredModelAnnotations(
                                                methodAnnotation, typeParameterName);
                                        String bounds = getModelAnnotationAttribute(
                                                typeParameterModelAnnotation, "bounds");
                                        if (bounds != null) {
                                            eTypeParameter.getEBounds().addAll(analyzeEGenericTypes(bounds));
                                            for (EGenericType eBound : eTypeParameter.getEBounds()) {
                                                ecoreEGenericTypeToJavaEGenericTypeMap.put(eBound, null);
                                            }
                                        }

                                        eDataType.getETypeParameters().add(eTypeParameter);
                                    }
                                }

                                eDataTypes.add(eDataType);
                                eDataType.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                                EcoreUtil.setDocumentation(eDataType,
                                        getModelDocumentation(method.getComment()));
                            } else if (returnType.endsWith("EClass")) {
                                EClass eClass = EcoreFactory.eINSTANCE.createEClass();
                                String instanceClass = getModelAnnotationAttribute(methodAnnotation,
                                        "instanceClass");
                                if (instanceClass != null) {
                                    eClass.setInterface(true);
                                    eClass.setAbstract(true);
                                    eClass.setInstanceTypeName(instanceClass);
                                    eClass.setName(method.getName().substring(3));

                                    String typeParameterNames = getModelAnnotationAttribute(methodAnnotation,
                                            "typeParameters");
                                    if (typeParameterNames != null) {
                                        for (StringTokenizer stringTokenizer = new StringTokenizer(
                                                typeParameterNames, " "); stringTokenizer.hasMoreTokens();) {
                                            String typeParameterName = stringTokenizer.nextToken();
                                            ETypeParameter eTypeParameter = EcoreFactory.eINSTANCE
                                                    .createETypeParameter();
                                            eTypeParameter.setName(typeParameterName);
                                            String typeParameterModelAnnotation = getFilteredModelAnnotations(
                                                    methodAnnotation, typeParameterName);
                                            String bounds = getModelAnnotationAttribute(
                                                    typeParameterModelAnnotation, "bounds");
                                            if (bounds != null) {
                                                eTypeParameter.getEBounds()
                                                        .addAll(analyzeEGenericTypes(bounds));
                                                for (EGenericType eBound : eTypeParameter.getEBounds()) {
                                                    ecoreEGenericTypeToJavaEGenericTypeMap.put(eBound, null);
                                                }
                                            }

                                            eClass.getETypeParameters().add(eTypeParameter);
                                        }
                                    }

                                    eClasses.add(eClass);
                                } else {
                                    eClass.setInstanceTypeName("java.util.Map$Entry");
                                    eClass.setName(method.getName().substring(3));
                                    eClasses.add(eClass);

                                    String features = getModelAnnotationAttribute(methodAnnotation, "features");
                                    if (features != null) {
                                        for (StringTokenizer stringTokenizer = new StringTokenizer(features,
                                                " "); stringTokenizer.hasMoreTokens();) {
                                            String feature = stringTokenizer.nextToken();
                                            analyzeMethod(eClass,
                                                    getFilteredModelAnnotations(methodAnnotation, feature),
                                                    "get" + Character.toUpperCase(feature.charAt(0))
                                                            + feature.substring(1),
                                                    "java.lang.Object", EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY,
                                                    EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY);
                                        }
                                    } else {
                                        analyzeMethod(eClass,
                                                getFilteredModelAnnotations(methodAnnotation, "key"), "getKey",
                                                "java.lang.Object", EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY,
                                                EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY);

                                        analyzeMethod(eClass,
                                                getFilteredModelAnnotations(methodAnnotation, "value"),
                                                "getValue", "java.lang.Object", EMPTY_STRING_ARRAY,
                                                EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY);
                                    }
                                }
                                eClass.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                                EcoreUtil.setDocumentation(eClass, getModelDocumentation(method.getComment()));
                            }
                        }
                    }
                }
            }

            if (isEPackage || !eClasses.isEmpty() || !eDataTypes.isEmpty()) {
                EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
                ePackageToOrderingMap.put(ePackage, ordering);
                eModelElementToJNodeMap.put(ePackage, type);
                ePackage.setNsURI(nsURI);
                ePackage.setNsPrefix(nsPrefix);
                ePackage.setName(name);
                ePackage.getEClassifiers().addAll(eClasses);
                ePackage.getEClassifiers().addAll(eDataTypes);
                if (modelAnnotation != null) {
                    ePackage.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
                }
                EcoreUtil.setDocumentation(ePackage, getModelDocumentation(type.getComment()));

                ePackageToPrefixMap.put(ePackage, packagePrefix);

                EPackage existingEPackage = packageNameToEPackageMap.get(qualifiedPackageName);
                if (existingEPackage != null) {
                    ePackage.getEClassifiers().addAll(existingEPackage.getEClassifiers());
                    ePackage.getEAnnotations().addAll(existingEPackage.getEAnnotations());
                }

                packageNameToEPackageMap.put(qualifiedPackageName, ePackage);
            }
        }
    }
}

From source file:org.eclipse.emf.test.tools.merger.facade.FacadeAPITest.java

License:Open Source License

@Test
public void testFacadeFlags() {
    assertEquals(Flags.AccAbstract, FacadeFlags.ABSTRACT);
    assertEquals(Flags.AccAnnotation, FacadeFlags.ANNOTATION);
    assertEquals(Flags.AccBridge, FacadeFlags.BRIDGE);
    assertEquals(Flags.AccDefault, FacadeFlags.DEFAULT);
    assertEquals(Flags.AccDeprecated, FacadeFlags.DEPRECATED);
    assertEquals(Flags.AccEnum, FacadeFlags.ENUM);
    assertEquals(Flags.AccFinal, FacadeFlags.FINAL);
    assertEquals(Flags.AccInterface, FacadeFlags.INTERFACE);
    assertEquals(Flags.AccNative, FacadeFlags.NATIVE);
    assertEquals(Flags.AccPrivate, FacadeFlags.PRIVATE);
    assertEquals(Flags.AccProtected, FacadeFlags.PROTECTED);
    assertEquals(Flags.AccPublic, FacadeFlags.PUBLIC);
    assertEquals(Flags.AccStatic, FacadeFlags.STATIC);
    assertEquals(Flags.AccStrictfp, FacadeFlags.STRICTFP);
    assertEquals(Flags.AccSuper, FacadeFlags.SUPER);
    assertEquals(Flags.AccSynchronized, FacadeFlags.SYNCHRONIZED);
    assertEquals(Flags.AccSynthetic, FacadeFlags.SYNTHETIC);
    assertEquals(Flags.AccTransient, FacadeFlags.TRANSIENT);
    assertEquals(Flags.AccVarargs, FacadeFlags.VARARGS);
    assertEquals(Flags.AccVolatile, FacadeFlags.VOLATILE);
}

From source file:org.eclipse.xtext.common.types.xtext.ui.JdtTypesProposalProvider.java

License:Open Source License

/**
 * Compute the JVM modifiers that corresponds to the given description.
 *
 * <p>This function fixes the issue related to the missed modifiers given to the content assist.
 *
 * @param context the current content assist context.
 * @param description the description.//from w  w  w  .  j av a 2  s .co m
 * @return the JVM modifiers.
 * @since 2.11
 */
protected int getDirtyStateModifiers(ContentAssistContext context, IEObjectDescription description) {
    EObject eobject = description.getEObjectOrProxy();
    if (eobject.eIsProxy()) {
        eobject = EcoreUtil.resolve(eobject, context.getResource().getResourceSet());
    }
    int accessModifiers = Flags.AccPublic;
    int otherModifiers = 0;
    if (eobject instanceof JvmMember) {
        final JvmMember member = (JvmMember) eobject;
        switch (member.getVisibility()) {
        case PUBLIC:
            accessModifiers = Flags.AccPublic;
            break;
        case PRIVATE:
            accessModifiers = Flags.AccPrivate;
            break;
        case PROTECTED:
            accessModifiers = Flags.AccProtected;
            break;
        case DEFAULT:
        default:
            accessModifiers = Flags.AccDefault;
            break;
        }
        if (DeprecationUtil.isDeprecated(member)) {
            otherModifiers |= Flags.AccDeprecated;
        }
        if (eobject instanceof JvmDeclaredType) {
            final JvmDeclaredType type = (JvmDeclaredType) eobject;
            if (type.isFinal()) {
                otherModifiers |= Flags.AccFinal;
            }
            if (type.isAbstract()) {
                otherModifiers |= Flags.AccAbstract;
            }
            if (type.isStatic()) {
                otherModifiers |= Flags.AccStatic;
            }
            if (type instanceof JvmEnumerationType) {
                otherModifiers |= Flags.AccEnum;
            } else if (type instanceof JvmAnnotationType) {
                otherModifiers |= Flags.AccAnnotation;
            } else if (type instanceof JvmGenericType) {
                if (((JvmGenericType) type).isInterface()) {
                    otherModifiers |= Flags.AccInterface;
                }
            }
        }
    }
    return accessModifiers | otherModifiers;
}

From source file:org.eclipse.xtext.xbase.ui.labeling.XbaseImages.java

License:Open Source License

public Image forInterface(JvmVisibility visibility) {
    return getJdtImage(JavaElementImageProvider.getTypeImageDescriptor(false, true,
            toFlags(visibility) | Flags.AccInterface, false));
}

From source file:org.eclipse.xtext.xbase.ui.labeling.XbaseImages2.java

License:Open Source License

/**
 * @param visibility//from   w  w  w  . jav  a 2s. com
 *            the visibility of the interface
 * @param adornments
 *            OR-ed flags from {@link JavaElementImageDescriptor} to denote decorations
 */
public ImageDescriptor forInterface(JvmVisibility visibility, int adornments) {
    return getDecorated(getTypeImageDescriptor(true, false, toFlags(visibility) | Flags.AccInterface, false),
            adornments);
}

From source file:org.summer.dsl.xbase.ui.labeling.XbaseImages2.java

License:Open Source License

/**
 * @param visibility//from  w  w w . j  a v a2  s. c o  m
 *            the visibility of the interface
 * @param adornments
 *            OR-ed flags from {@link JavaElementImageDescriptor} to denote decorations
 */
public ImageDescriptor forInterface(JvmVisibility visibility, int adornments) {
    return getDecorated(getTypeImageDescriptor(false, true, toFlags(visibility) | Flags.AccInterface, false),
            adornments);
}