Example usage for org.eclipse.jdt.internal.compiler.lookup ClassScope referenceType

List of usage examples for org.eclipse.jdt.internal.compiler.lookup ClassScope referenceType

Introduction

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

Prototype

public TypeDeclaration referenceType() 

Source Link

Usage

From source file:com.android.build.gradle.tasks.annotations.Extractor.java

License:Apache License

@Nullable
private static String getFqn(@NonNull ClassScope scope) {
    TypeDeclaration typeDeclaration = scope.referenceType();
    if (typeDeclaration != null && typeDeclaration.binding != null) {
        return new String(typeDeclaration.binding.readableName());
    }//from  w  w  w.j  a va2 s  .co  m
    return null;
}

From source file:com.google.gwt.dev.javac.JdtUtil.java

License:Apache License

public static AnnotationBinding getAnnotation(Binding binding, String nameToFind) {
    if (binding instanceof SourceTypeBinding) {
        ClassScope scope = ((SourceTypeBinding) binding).scope;
        return scope != null ? getAnnotation(scope.referenceType().annotations, nameToFind) : null;
    } else if (binding instanceof ReferenceBinding) {
        return getAnnotation(((ReferenceBinding) binding).getAnnotations(), nameToFind);
    } else if (binding instanceof SyntheticMethodBinding) {
        return null;
    } else if (binding instanceof MethodBinding) {
        AbstractMethodDeclaration abMethod = safeSourceMethod((MethodBinding) binding);
        return abMethod != null ? getAnnotation(abMethod.annotations, nameToFind) : null;
    } else if (binding instanceof FieldBinding) {
        return getAnnotation(((FieldBinding) binding).sourceField().annotations, nameToFind);
    } else {//  www  . jav  a  2s . c  o  m
        return null;
    }
}

From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.java

License:Open Source License

private void rememberAllTypes(CompilationUnitDeclaration parsedUnit, org.eclipse.jdt.core.ICompilationUnit cu,
        boolean includeLocalTypes) {
    TypeDeclaration[] types = parsedUnit.types;
    if (types != null) {
        for (int i = 0, length = types.length; i < length; i++) {
            TypeDeclaration type = types[i];
            rememberWithMemberTypes(type, cu.getType(new String(type.name)));
        }/*from   w  ww  .  ja v a  2s .  co m*/
    }
    if (includeLocalTypes && parsedUnit.localTypes != null) {
        HandleFactory factory = new HandleFactory();
        HashSet existingElements = new HashSet(parsedUnit.localTypeCount);
        HashMap knownScopes = new HashMap(parsedUnit.localTypeCount);
        for (int i = 0; i < parsedUnit.localTypeCount; i++) {
            LocalTypeBinding localType = parsedUnit.localTypes[i];
            ClassScope classScope = localType.scope;
            TypeDeclaration typeDecl = classScope.referenceType();
            IType typeHandle = (IType) factory.createElement(classScope, cu, existingElements, knownScopes);
            rememberWithMemberTypes(typeDecl, typeHandle);
        }
    }
}