Example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileReader isMember

List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileReader isMember

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileReader isMember.

Prototype

@Override
    public boolean isMember() 

Source Link

Usage

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

License:Open Source License

/**
 * Creates an IMethod from the given method declaration and type.
 *//*from  ww w  .  j av a  2s. com*/
protected IJavaElement createHandle(AbstractMethodDeclaration method, IJavaElement parent) {
    if (!(parent instanceof IType))
        return parent;

    IType type = (IType) parent;
    Argument[] arguments = method.arguments;
    int argCount = arguments == null ? 0 : arguments.length;
    if (type.isBinary()) {
        // don't cache the methods of the binary type
        // fall thru if its a constructor with a synthetic argument... find it the slower way
        ClassFileReader reader = classFileReader(type);
        if (reader != null) {
            // build arguments names
            boolean firstIsSynthetic = false;
            if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261
                firstIsSynthetic = true;
                argCount++;
            }
            char[][] argumentTypeNames = new char[argCount][];
            for (int i = 0; i < argCount; i++) {
                char[] typeName = null;
                if (i == 0 && firstIsSynthetic) {
                    typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray();
                } else if (arguments != null) {
                    TypeReference typeRef = arguments[firstIsSynthetic ? i - 1 : i].type;
                    typeName = CharOperation.concatWith(typeRef.getTypeName(), '.');
                    for (int k = 0, dim = typeRef.dimensions(); k < dim; k++)
                        typeName = CharOperation.concat(typeName, new char[] { '[', ']' });
                }
                if (typeName == null) {
                    // invalid type name
                    return null;
                }
                argumentTypeNames[i] = typeName;
            }
            // return binary method
            IMethod binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames);
            if (binaryMethod == null) {
                // when first attempt fails, try with similar matches if any...
                PossibleMatch similarMatch = this.currentPossibleMatch.getSimilarMatch();
                while (similarMatch != null) {
                    type = ((ClassFile) similarMatch.openable).getType();
                    binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames);
                    if (binaryMethod != null) {
                        return binaryMethod;
                    }
                    similarMatch = similarMatch.getSimilarMatch();
                }
            }
            return binaryMethod;
        }
        if (BasicSearchEngine.VERBOSE) {
            System.out.println("Not able to createHandle for the method " + //$NON-NLS-1$
                    CharOperation.charToString(method.selector) + " May miss some results"); //$NON-NLS-1$
        }
        return null;
    }

    String[] parameterTypeSignatures = new String[argCount];
    if (arguments != null) {
        for (int i = 0; i < argCount; i++) {
            TypeReference typeRef = arguments[i].type;
            char[] typeName = CharOperation.concatWith(typeRef.getParameterizedTypeName(), '.');
            parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
        }
    }

    return createMethodHandle(type, new String(method.selector), parameterTypeSignatures);
}

From source file:org.springframework.ide.eclipse.core.java.TypeStructure.java

License:Open Source License

public TypeStructure(ClassFileReader cfr) {
    //It shouldn't really matter what arguments we provide to the constructor
    // since this class implements all the methods, except for getTypeAnnotations,
    // which just returns 'null'. So all that really matters is we pass in 
    // something that doesn't make the super constructor crash. We will nevertheless
    // try our best to pass in sensible values.
    super(cfr.getModifiers(), computeQualification(cfr), cfr.getSourceName(), cfr.getEnclosingTypeName(),
            (char[][]) null, '?' //?? appears not used in super class, so not sure what its for
    );/* w ww.  j  av  a2 s  .com*/

    this.enclosingTypeName = cfr.getEnclosingTypeName();
    this.isLocal = cfr.isLocal();
    this.isAnonymous = cfr.isAnonymous();
    this.isMember = cfr.isMember();
    this.sourceFileName = cfr.sourceFileName();
    this.fileName = cfr.getFileName();
    this.tagBits = cfr.getTagBits();
    this.isBinaryType = cfr.isBinaryType();
    this.binFields = cfr.getFields();
    if (binFields == null)
        binFields = NoField;
    this.binMethods = cfr.getMethods();
    if (binMethods == null)
        binMethods = NoMethod;
    this.memberTypes = cfr.getMemberTypes();
    this.annotations = cfr.getAnnotations();
    this.sourceName = cfr.getSourceName();
    this.className = cfr.getName(); // slashes...
    this.modifiers = cfr.getModifiers();
    this.genericSignature = cfr.getGenericSignature();
    // if (this.genericSignature.length == 0) {
    // this.genericSignature = null;
    // }
    this.superclassName = cfr.getSuperclassName(); // slashes...
    interfaces = cfr.getInterfaceNames();

}