Example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants JAVA_LANG_SUPPRESSWARNINGS

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants JAVA_LANG_SUPPRESSWARNINGS

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants JAVA_LANG_SUPPRESSWARNINGS.

Prototype

null JAVA_LANG_SUPPRESSWARNINGS

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants JAVA_LANG_SUPPRESSWARNINGS.

Click Source Link

Usage

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

License:Open Source License

private void addBinaryStandardAnnotations(long annotationTagBits) {
    if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
        return;/*w ww .jav  a 2  s.  com*/
    }
    if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
        addBinaryTargetAnnotation(annotationTagBits);
    }
    if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_RETENTION;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
        addBinaryRetentionAnnotation(annotationTagBits);
    }
    if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_DEPRECATED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationDocumented) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationInherited) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_INHERITED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationOverride) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_OVERRIDE;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationSuppressWarnings) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SUPPRESSWARNINGS;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SAFEVARARGS;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
}

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

License:Open Source License

private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {
    if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
        return false;
    }//w w w.  j av  a  2  s  .  c o m
    if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)
                || ((annotationTagBits & TARGET_ANNOTATION_BITS) != 0
                        && checkAnnotationTypeReference(JAVA_LANG_ANNOTATION_ELEMENTTYPE, pattern))) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_RETENTION;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)
                || checkAnnotationTypeReference(
                        CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.'),
                        pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_DEPRECATED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationDocumented) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationInherited) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_INHERITED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationOverride) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_OVERRIDE;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationSuppressWarnings) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SUPPRESSWARNINGS;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SAFEVARARGS;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    return false;
}

From source file:lombok.eclipse.handlers.EclipseHandlerUtil.java

License:Open Source License

public static Annotation[] addSuppressWarningsAll(EclipseNode node, ASTNode source,
        Annotation[] originalAnnotationArray) {
    Annotation[] anns = addAnnotation(source, originalAnnotationArray, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS,
            new StringLiteral(ALL, 0, 0, 0));

    if (Boolean.TRUE.equals(
            node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) {
        MemberValuePair mvp = new MemberValuePair(JUSTIFICATION, 0, 0,
                new StringLiteral(GENERATED_CODE, 0, 0, 0));
        anns = addAnnotation(source, anns, EDU_UMD_CS_FINDBUGS_ANNOTATIONS_SUPPRESSFBWARNINGS, mvp);
    }//from  w  w w. j  av a  2 s.c o  m

    return anns;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java

License:Open Source License

public void computeId() {
    // try to avoid multiple checks against a package/type name
    switch (this.compoundName.length) {

    case 3:/*from www . ja v  a  2 s.  c  om*/
        if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]))
            return;

        char[] packageName = this.compoundName[1];
        if (packageName.length == 0)
            return; // just to be safe
        char[] typeName = this.compoundName[2];
        if (typeName.length == 0)
            return; // just to be safe
        // remaining types MUST be in java.*.*
        if (!CharOperation.equals(TypeConstants.LANG, this.compoundName[1])) {
            switch (packageName[0]) {
            case 'i':
                if (CharOperation.equals(packageName, TypeConstants.IO)) {
                    switch (typeName[0]) {
                    case 'E':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_IO_EXTERNALIZABLE[2]))
                            this.id = TypeIds.T_JavaIoExternalizable;
                        return;
                    case 'I':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_IO_IOEXCEPTION[2]))
                            this.id = TypeIds.T_JavaIoException;
                        return;
                    case 'O':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_IO_OBJECTSTREAMEXCEPTION[2]))
                            this.id = TypeIds.T_JavaIoObjectStreamException;
                        return;
                    case 'P':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_IO_PRINTSTREAM[2]))
                            this.id = TypeIds.T_JavaIoPrintStream;
                        return;
                    case 'S':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_IO_SERIALIZABLE[2]))
                            this.id = TypeIds.T_JavaIoSerializable;
                        return;
                    }
                }
                return;
            case 'u':
                if (CharOperation.equals(packageName, TypeConstants.UTIL)) {
                    switch (typeName[0]) {
                    case 'C':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_UTIL_COLLECTION[2]))
                            this.id = TypeIds.T_JavaUtilCollection;
                        return;
                    case 'I':
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_UTIL_ITERATOR[2]))
                            this.id = TypeIds.T_JavaUtilIterator;
                        return;
                    }
                }
                return;
            }
            return;
        }

        // remaining types MUST be in java.lang.*
        switch (typeName[0]) {
        case 'A':
            switch (typeName.length) {
            case 13:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_AUTOCLOSEABLE[2]))
                    this.id = TypeIds.T_JavaLangAutoCloseable;
                return;
            case 14:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ASSERTIONERROR[2]))
                    this.id = TypeIds.T_JavaLangAssertionError;
                return;
            }
            return;
        case 'B':
            switch (typeName.length) {
            case 4:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_BYTE[2]))
                    this.id = TypeIds.T_JavaLangByte;
                return;
            case 7:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_BOOLEAN[2]))
                    this.id = TypeIds.T_JavaLangBoolean;
                return;
            }
            return;
        case 'C':
            switch (typeName.length) {
            case 5:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_CLASS[2]))
                    this.id = TypeIds.T_JavaLangClass;
                return;
            case 9:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_CHARACTER[2]))
                    this.id = TypeIds.T_JavaLangCharacter;
                else if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_CLONEABLE[2]))
                    this.id = TypeIds.T_JavaLangCloneable;
                return;
            case 22:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_CLASSNOTFOUNDEXCEPTION[2]))
                    this.id = TypeIds.T_JavaLangClassNotFoundException;
                return;
            }
            return;
        case 'D':
            switch (typeName.length) {
            case 6:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_DOUBLE[2]))
                    this.id = TypeIds.T_JavaLangDouble;
                return;
            case 10:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_DEPRECATED[2]))
                    this.id = TypeIds.T_JavaLangDeprecated;
                return;
            }
            return;
        case 'E':
            switch (typeName.length) {
            case 4:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ENUM[2]))
                    this.id = TypeIds.T_JavaLangEnum;
                return;
            case 5:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ERROR[2]))
                    this.id = TypeIds.T_JavaLangError;
                return;
            case 9:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_EXCEPTION[2]))
                    this.id = TypeIds.T_JavaLangException;
                return;
            }
            return;
        case 'F':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_FLOAT[2]))
                this.id = TypeIds.T_JavaLangFloat;
            return;
        case 'I':
            switch (typeName.length) {
            case 7:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_INTEGER[2]))
                    this.id = TypeIds.T_JavaLangInteger;
                return;
            case 8:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ITERABLE[2]))
                    this.id = TypeIds.T_JavaLangIterable;
                return;
            case 24:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ILLEGALARGUMENTEXCEPTION[2]))
                    this.id = TypeIds.T_JavaLangIllegalArgumentException;
                return;
            }
            return;
        case 'L':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_LONG[2]))
                this.id = TypeIds.T_JavaLangLong;
            return;
        case 'N':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_NOCLASSDEFERROR[2]))
                this.id = TypeIds.T_JavaLangNoClassDefError;
            return;
        case 'O':
            switch (typeName.length) {
            case 6:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_OBJECT[2]))
                    this.id = TypeIds.T_JavaLangObject;
                return;
            case 8:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_OVERRIDE[2]))
                    this.id = TypeIds.T_JavaLangOverride;
                return;
            }
            return;
        case 'R':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION[2]))
                this.id = TypeIds.T_JavaLangRuntimeException;
            break;
        case 'S':
            switch (typeName.length) {
            case 5:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_SHORT[2]))
                    this.id = TypeIds.T_JavaLangShort;
                return;
            case 6:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_STRING[2]))
                    this.id = TypeIds.T_JavaLangString;
                else if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_SYSTEM[2]))
                    this.id = TypeIds.T_JavaLangSystem;
                return;
            case 11:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_SAFEVARARGS[2]))
                    this.id = TypeIds.T_JavaLangSafeVarargs;
                return;
            case 12:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_STRINGBUFFER[2]))
                    this.id = TypeIds.T_JavaLangStringBuffer;
                return;
            case 13:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_STRINGBUILDER[2]))
                    this.id = TypeIds.T_JavaLangStringBuilder;
                return;
            case 16:
                if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS[2]))
                    this.id = TypeIds.T_JavaLangSuppressWarnings;
                return;
            }
            return;
        case 'T':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_THROWABLE[2]))
                this.id = TypeIds.T_JavaLangThrowable;
            return;
        case 'V':
            if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_VOID[2]))
                this.id = TypeIds.T_JavaLangVoid;
            return;
        }
        break;

    case 4:
        if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]))
            return;
        packageName = this.compoundName[1];
        if (packageName.length == 0)
            return; // just to be safe

        packageName = this.compoundName[2];
        if (packageName.length == 0)
            return; // just to be safe
        typeName = this.compoundName[3];
        if (typeName.length == 0)
            return; // just to be safe
        switch (packageName[0]) {
        case 'a':
            if (CharOperation.equals(packageName, TypeConstants.ANNOTATION)) {
                switch (typeName[0]) {
                case 'A':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION[3]))
                        this.id = TypeIds.T_JavaLangAnnotationAnnotation;
                    return;
                case 'D':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED[3]))
                        this.id = TypeIds.T_JavaLangAnnotationDocumented;
                    return;
                case 'E':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE[3]))
                        this.id = TypeIds.T_JavaLangAnnotationElementType;
                    return;
                case 'I':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_INHERITED[3]))
                        this.id = TypeIds.T_JavaLangAnnotationInherited;
                    return;
                case 'R':
                    switch (typeName.length) {
                    case 9:
                        if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_RETENTION[3]))
                            this.id = TypeIds.T_JavaLangAnnotationRetention;
                        return;
                    case 15:
                        if (CharOperation.equals(typeName,
                                TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY[3]))
                            this.id = TypeIds.T_JavaLangAnnotationRetentionPolicy;
                        return;
                    }
                    return;
                case 'T':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_ANNOTATION_TARGET[3]))
                        this.id = TypeIds.T_JavaLangAnnotationTarget;
                    return;
                }
            }
            return;
        case 'i':
            if (CharOperation.equals(packageName, TypeConstants.INVOKE)) {
                if (typeName.length == 0)
                    return; // just to be safe
                switch (typeName[0]) {
                case 'M':
                    if (CharOperation.equals(typeName,
                            TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE[3]))
                        this.id = TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature;
                    return;
                }
            }
            return;
        case 'r':
            if (CharOperation.equals(packageName, TypeConstants.REFLECT)) {
                switch (typeName[0]) {
                case 'C':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_REFLECT_CONSTRUCTOR[2]))
                        this.id = TypeIds.T_JavaLangReflectConstructor;
                    return;
                case 'F':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_REFLECT_FIELD[2]))
                        this.id = TypeIds.T_JavaLangReflectField;
                    return;
                case 'M':
                    if (CharOperation.equals(typeName, TypeConstants.JAVA_LANG_REFLECT_METHOD[2]))
                        this.id = TypeIds.T_JavaLangReflectMethod;
                    return;
                }
            }
            return;
        }
        break;
    case 5:
        if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]))
            return;
        packageName = this.compoundName[1];
        if (packageName.length == 0)
            return; // just to be safe

        if (CharOperation.equals(TypeConstants.LANG, packageName)) {
            packageName = this.compoundName[2];
            if (packageName.length == 0)
                return; // just to be safe
            switch (packageName[0]) {
            case 'i':
                if (CharOperation.equals(packageName, TypeConstants.INVOKE)) {
                    typeName = this.compoundName[3];
                    if (typeName.length == 0)
                        return; // just to be safe
                    switch (typeName[0]) {
                    case 'M':
                        char[] memberTypeName = this.compoundName[4];
                        if (memberTypeName.length == 0)
                            return; // just to be safe
                        if (CharOperation.equals(typeName,
                                TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE[3])
                                && CharOperation.equals(memberTypeName,
                                        TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE[4]))
                            this.id = TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature;
                        return;
                    }
                }
                return;
            }
            return;
        }
    }
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.LiftingEnvironment.java

License:Open Source License

/**
 * Create a method that initializes all caches introduced in a given team.
 * Only create method declaration, no statements yet.
 * (see fillGeneratedMethods()).// ww  w. j  av a2  s.c om
 *
 * @param teamType the type to add the method to.
 * @return the _OT$initCaches method
 */
private static MethodDeclaration generateInitCaches(TypeDeclaration teamType) {
    MethodDeclaration initMethod = AstConverter.findAndAdjustCopiedMethod(teamType, IOTConstants.OT_INIT_CACHES,
            null);
    if (initMethod == null) {
        AstGenerator gen = new AstGenerator(teamType.sourceStart, teamType.sourceEnd);
        gen.shiftPosition(); // don't let @SuppressWarnings interfere with non-generated code.

        initMethod = gen.method(teamType.compilationResult, ClassFileConstants.AccPrivate, // no overriding!!
                TypeBinding.BOOLEAN, IOTConstants.OT_INIT_CACHES, null);
        initMethod.statements = new Statement[0]; // to be filled by fillInitCaches()
        initMethod.annotations = new Annotation[] { // in case base type is a raw type
                gen.singleStringsMemberAnnotation(TypeConstants.JAVA_LANG_SUPPRESSWARNINGS,
                        new char[][] { "all".toCharArray() }) //$NON-NLS-1$   
        };
        AstEdit.addMethod(teamType, initMethod);
        initMethod.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // prevent 'unused' warning

        if (teamType.isRole()) {
            TypeDeclaration ifcPart = teamType.getRoleModel().getInterfaceAst();
            if (ifcPart != teamType) {
                AbstractMethodDeclaration methodIfcPart = TypeAnalyzer.findMethodDecl(ifcPart,
                        IOTConstants.OT_INIT_CACHES, 0);
                if (methodIfcPart == null) {
                    methodIfcPart = AstConverter.genRoleIfcMethod(teamType.enclosingType, initMethod);
                    AstEdit.addMethod(ifcPart, methodIfcPart);
                }
            }
        }

        // Serialization: generate restore methods to initialize caches/register roles:
        SerializationGenerator.generateRestoreMethods(teamType, gen);
    }

    return initMethod;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.ReflectionGenerator.java

License:Open Source License

/**
 * Generate methods//from   www.j  av  a 2s  .c  om
 *       boolean hasRole(Object aBase);
 *     boolean hasRole(Object aBase, Class roleType);
 *       Object  getRole(Object aBase);
 *     Object  getRole(Object aBase, Class roleType);
 *      void    unregisterRole(Object _OT$role_arg)
 *      void    unregisterRole(Object _OT$role_arg, Class class_arg)
 * Due to the similarities, we create all six methods simultaneously.
 *
 * @param teamDecl
 * @param weavingScheme TODO
 */
public static void createRoleQueryMethods(TypeDeclaration teamDecl, WeavingScheme weavingScheme) {
    if (TypeAnalyzer.isOrgObjectteamsTeam(teamDecl.binding)
            || Protections.hasClassKindProblem(teamDecl.binding))
        return;
    long sourceLevel = teamDecl.scope.compilerOptions().sourceLevel;
    AstGenerator gen = new AstGenerator(sourceLevel, teamDecl.sourceStart, teamDecl.sourceEnd);
    AstGenerator gen2 = gen;
    if (sourceLevel >= ClassFileConstants.JDK1_5) {
        // gen2 produces positions that have a slight offset against the type:
        // we're adding @SuppressWarnings("all") which shouldn't affect other diagnostics
        // against the type's positions! (see usage of gen2 for more comments).
        gen2 = new AstGenerator(teamDecl.sourceStart, teamDecl.sourceEnd);
        gen2.shiftPosition();
    }

    TypeBinding booleanBinding = TypeBinding.BOOLEAN;
    TypeBinding objectBinding = teamDecl.scope.getJavaLangObject();
    ReferenceBinding classBinding = teamDecl.scope.getJavaLangClass();
    TypeBinding stringBinding = teamDecl.scope.getJavaLangString();
    TypeBinding hashMapBinding = teamDecl.scope.getType(WEAK_HASH_MAP, 3);
    TypeBinding objectArrayBinding;
    try {
        objectArrayBinding = Config.getLookupEnvironment().createArrayType(objectBinding, 1);
    } catch (NotConfiguredException e) {
        e.logWarning("Not creating reflective methods"); //$NON-NLS-1$
        return;
    }
    TypeReference objectCollectionRef;
    TypeReference wildcardCollectionRef;
    TypeReference roleTypeRef;
    TypeReference roleArrayTypeRef;
    if (sourceLevel >= ClassFileConstants.JDK1_5) {
        objectCollectionRef = gen.parameterizedQualifiedTypeReference(COLLECTION,
                new TypeBinding[] { objectBinding });
        wildcardCollectionRef = gen.parameterizedQualifiedTypeReference(COLLECTION,
                new TypeReference[] { new Wildcard(Wildcard.UNBOUND) });
        roleTypeRef = gen.singleTypeReference(T);
        roleArrayTypeRef = gen.arrayTypeReference(T, 1);
    } else {
        objectCollectionRef = gen.qualifiedTypeReference(COLLECTION);
        wildcardCollectionRef = gen.qualifiedTypeReference(COLLECTION);
        roleTypeRef = gen.typeReference(objectBinding);
        roleArrayTypeRef = gen.typeReference(objectArrayBinding);
    }

    MethodDeclaration hasRole1 = findOrGeneratePublicMethod(teamDecl, booleanBinding, HAS_ROLE, // boolean hasRole(Object _OT$base_arg)
            new Argument[] { gen.argument(_OT_BASE_ARG, gen.singleTypeReference(objectBinding)) }, gen);
    MethodDeclaration hasRole2 = findOrGeneratePublicMethod( // boolean hasRole(Object _OT$base_arg, java.lang.Class class_arg)
            teamDecl, booleanBinding, HAS_ROLE,
            new Argument[] { gen.argument(_OT_BASE_ARG, gen.singleTypeReference(objectBinding)),
                    gen.argument(CLASS_ARG, gen.qualifiedTypeReference(classBinding.compoundName)) },
            gen);
    MethodDeclaration getRole1 = findOrGeneratePublicMethod( // Object getRole(Object _OT$base_arg)
            teamDecl, objectBinding, GET_ROLE,
            new Argument[] { gen2.argument(_OT_BASE_ARG, gen.singleTypeReference(objectBinding)) }, gen2);
    if (sourceLevel >= ClassFileConstants.JDK1_5) {
        getRole1.annotations = new Annotation[] {
                // report neither potential null access nor unnecessary SuppressWarnings:
                // (first_name is accessed in ctor call for DuplicateRoleException without explicit null-check.)
                gen2.singleStringsMemberAnnotation(TypeConstants.JAVA_LANG_SUPPRESSWARNINGS,
                        new char[][] { "all".toCharArray() }) //$NON-NLS-1$
                // Note: would like to say @SuppressWarnings({"null", "suppressWarnings"}).
                // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252518
        };
    }
    MethodDeclaration getRole2 = findOrGeneratePublicMethod( // <T> T getRole(Object _OT$base_arg, java.lang.Class<T> class_arg)
            teamDecl, roleTypeRef, GET_ROLE,
            new Argument[] { gen.argument(_OT_BASE_ARG, gen.singleTypeReference(objectBinding)), gen.argument( // java.lang.Class<T> class_arg
                    CLASS_ARG, gen.parameterizedQualifiedTypeReference(classBinding.compoundName,
                            new TypeReference[] { gen.singleTypeReference(T) })) },
            gen);
    if (sourceLevel >= ClassFileConstants.JDK1_5)
        getRole2.typeParameters = new TypeParameter[] { gen.unboundedTypeParameter(T) };
    MethodDeclaration getARoles1 = findOrGeneratePublicMethod( // Object[] getAllRoles()
            teamDecl, objectArrayBinding, GET_ALL_ROLES, null, gen);
    MethodDeclaration getARoles2 = findOrGeneratePublicMethod( // <T> T[] getAllRoles(Class<T> class_arg)
            teamDecl, roleArrayTypeRef, GET_ALL_ROLES, new Argument[] { gen.argument( // java.lang.Class<T> class_arg
                    CLASS_ARG, gen.parameterizedQualifiedTypeReference(classBinding.compoundName,
                            new TypeReference[] { gen.singleTypeReference(T) })) },
            gen);
    if (sourceLevel >= ClassFileConstants.JDK1_5)
        getARoles2.typeParameters = new TypeParameter[] { gen.unboundedTypeParameter(T) };
    MethodDeclaration unregRole1 = findOrGeneratePublicMethod( // void unregisterRole(Object _OT$base_arg)
            teamDecl, TypeBinding.VOID, UNREGISTER_ROLE,
            new Argument[] { gen.argument(_OT_ROLE_ARG, gen.singleTypeReference(objectBinding)) }, gen2);
    if (sourceLevel >= ClassFileConstants.JDK1_5) {
        unregRole1.annotations = new Annotation[] {
                // found_base is accessed to call remove(role) without explicit null-check. [see also getRole1 above].
                gen2.singleStringsMemberAnnotation(TypeConstants.JAVA_LANG_SUPPRESSWARNINGS,
                        new char[][] { "all".toCharArray() }) //$NON-NLS-1$
        };
    }
    MethodDeclaration unregRole2 = findOrGeneratePublicMethod( // void unregisterRole(Object _OT$base_arg, Class class_arg)
            teamDecl, TypeBinding.VOID, UNREGISTER_ROLE,
            new Argument[] { gen.argument(_OT_ROLE_ARG, gen.singleTypeReference(objectBinding)),
                    gen.argument(CLASS_ARG, gen.qualifiedTypeReference(classBinding.compoundName)) },
            gen);

    RoleModel[] roles = teamDecl.getTeamModel().getRoles(false/*no synth ifc*/);
    int h1 = 0; // hasRole1
    int g1 = 0; // getRole1
    int ga = 0; // getAllRoles1
    int g2 = 0; // getAllRoles2
    int m2 = 0; // hasRole2, getRole2
    int u1 = 0; // unregRole1
    int u2 = 0; // unregRole2
    Statement[] hasStats1 = new Statement[roles.length]; // at most this many elements..
    Statement[] hasStats2 = new Statement[roles.length]; // .. compact below.
    Statement[] getStats1 = new Statement[roles.length + 2]; // ... (plus 2 locals)
    Statement[] getStats2 = new Statement[roles.length]; // ...
    Statement[] getAStats1 = new Statement[roles.length + 1]; // ... (plus 1 local)
    Statement[] getAStats2 = new Statement[roles.length + 2]; // ... (plus prefix (1 local) + postfix (1 block))
    Statement[] unregStats1 = new Statement[roles.length + 3]; // ... (plus 3 locals)
    Statement[] unregStats2 = new Statement[roles.length]; // ...

    getStats1[g1++] = gen.localVariable(FIRST_RESULT, objectBinding, gen.nullLiteral());
    getStats1[g1++] = gen.localVariable(FIRST_NAME, stringBinding, gen.nullLiteral());
    getAStats1[ga++] = gen.localVariable(FIRST_RESULT, objectCollectionRef, createMTList(gen, objectBinding));
    getAStats2[g2++] = gen.localVariable(VALUES, wildcardCollectionRef, gen.nullLiteral());
    unregStats1[u1++] = gen2.localVariable(FIRST_NAME, stringBinding, gen2.nullLiteral());
    unregStats1[u1++] = gen2.localVariable(FIRST_CACHE, hashMapBinding.erasure(), gen2.nullLiteral());
    unregStats1[u1++] = gen2.localVariable(FOUND_BASE, objectBinding, gen2.nullLiteral());
    HashSet<String> processedCaches = new HashSet<String>();
    for (int i = 0; i < roles.length; i++) {
        if (roles[i].isSynthInterface())
            continue;
        if (TypeAnalyzer.isTopConfined(roles[i].getBinding()))
            continue;
        if (roles[i].isIgnoreFurtherInvestigation())
            continue;
        RoleModel boundRootRole = roles[i].getBoundRootRole();
        if (boundRootRole != null && boundRootRole.isIgnoreFurtherInvestigation())
            continue;
        char[] cacheName = LiftingEnvironment.getCacheName(boundRootRole);
        if (cacheName != null) {
            String cacheString = new String(cacheName); // String for hashing!
            ReferenceBinding roleType = roles[i].getInterfacePartBinding();
            if (!processedCaches.contains(cacheString)) {
                // one lookup per cache:
                processedCaches.add(cacheString);
                hasStats1[h1++] = createIfContainsTrue(cacheName, gen);
                getStats1[g1++] = createIfContainsGet(cacheName, gen2, g1 == 3);
                getAStats1[ga++] = createAddAll(cacheName, gen);
                unregStats1[u1++] = createRememberIfContains(roleType, cacheName, gen2, u1 == 4);
            }
            // one lookup per bound role class:
            hasStats2[m2] = createIfTypeEqualAndContains(roleType, cacheName, gen, objectBinding);
            getStats2[m2++] = createIfTypeEqualAndGet(roleType, cacheName, gen);
            getAStats2[g2++] = createIfTypeEqualFetchValues(roleType, cacheName, gen);
            unregStats2[u2++] = createRemove(roleType, cacheName, gen, weavingScheme);
        }
    }
    if (g2 > 1)
        getAStats2[g2++] = createFilterValues(gen);
    else
        getAStats2[g2++] = createThrowNoSuchRole(gen); // no caches to search
    boolean needsAllMethods = needToImplementITeamMethods(teamDecl);
    if (h1 > 0 || needsAllMethods) {
        System.arraycopy(hasStats1, 0, hasStats1 = new Statement[h1 + 1], 0, h1);
        System.arraycopy(getStats1, 0, getStats1 = new Statement[g1 + 1], 0, g1);
        System.arraycopy(getAStats1, 0, getAStats1 = new Statement[ga + 1], 0, ga);
        System.arraycopy(unregStats1, 0, unregStats1 = new Statement[(u1 > 3) ? (u1 + 1) : u1], 0, u1);
        // no role instance found means: return false:
        hasStats1[h1] = gen.returnStatement(gen.booleanLiteral(false));
        // no duplicate means: return first_result;
        getStats1[g1] = gen.returnStatement(gen.singleNameReference(FIRST_RESULT));
        getAStats1[ga] = gen
                .returnStatement(gen.messageSend(gen.singleNameReference(FIRST_RESULT), TO_ARRAY, null));
        // no duplicate means: if found remove from first_cache;
        if (u1 > 3)
            unregStats1[u1] = createRemoveIfFound(gen2, weavingScheme); // if u1 <= 3 this would not be reachable due to definite null
        hasRole1.setStatements(hasStats1);
        getRole1.setStatements(getStats1);
        getARoles1.setStatements(getAStats1);
        unregRole1.setStatements(unregStats1);
        checkedAddMethod(teamDecl, hasRole1);
        checkedAddMethod(teamDecl, getRole1);
        checkedAddMethod(teamDecl, getARoles1);
        checkedAddMethod(teamDecl, unregRole1);
    }
    if (m2 > 0 || needsAllMethods) {
        System.arraycopy(hasStats2, 0, hasStats2 = new Statement[m2 + 1], 0, m2);
        System.arraycopy(getStats2, 0, getStats2 = new Statement[m2 + 1], 0, m2);
        System.arraycopy(unregStats2, 0, unregStats2 = new Statement[u2 + 1], 0, u2);
        // role class not found means: illegal argument:
        hasStats2[m2] = createThrowNoSuchRole(gen);
        getStats2[m2] = createThrowNoSuchRole(gen);
        unregStats2[u2] = createThrowNoSuchRole(gen);
        hasRole2.setStatements(hasStats2);
        getRole2.setStatements(getStats2);
        unregRole2.setStatements(unregStats2);
        checkedAddMethod(teamDecl, hasRole2);
        checkedAddMethod(teamDecl, getRole2);
        checkedAddMethod(teamDecl, unregRole2);
    }
    if (g2 > 2 || needsAllMethods) {
        System.arraycopy(getAStats2, 0, getAStats2 = new Statement[g2], 0, g2);
        getARoles2.setStatements(getAStats2);
        checkedAddMethod(teamDecl, getARoles2);
    }
}