Example usage for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding outermostEnclosingType

List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding outermostEnclosingType

Introduction

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

Prototype

public final ReferenceBinding outermostEnclosingType() 

Source Link

Usage

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

License:Apache License

/**
 * Returns the top type of the compilation unit that defines
 * {@code binding}.//from  w  w w.jav a  2 s. com
 */
public static String getDefiningCompilationUnitType(ReferenceBinding binding) {
    // Get the compilation unit type name.
    // TODO(rluble): check that this is valid for classes declared in the same compilation unit
    // top scope.
    return asDottedString(binding.outermostEnclosingType().compoundName);
}

From source file:com.redhat.ceylon.eclipse.core.model.mirror.UnknownClassMirror.java

License:Open Source License

public JDTClass(ReferenceBinding klass, IType type) {
    this.type = type;
    bindingRef = new WeakReference<ReferenceBinding>(klass);
    pkg = new JDTPackage(klass.getPackage());
    simpleName = new String(klass.sourceName());
    qualifiedName = JDTUtils.getFullyQualifiedName(klass);
    isPublic = klass.isPublic();/* w w w . ja va2 s  .c  o m*/
    isInterface = klass.isInterface();
    isAbstract = klass.isAbstract();
    isProtected = klass.isProtected();
    isDefaultAccess = klass.isDefault();
    isLocalType = klass.isLocalType();
    isStatic = (klass.modifiers & ClassFileConstants.AccStatic) != 0;
    isFinal = klass.isFinal();
    isEnum = klass.isEnum();
    isBinary = klass.isBinaryBinding();
    isAnonymous = klass.isAnonymousType();
    isJavaSource = (klass instanceof SourceTypeBinding)
            && new String(((SourceTypeBinding) klass).getFileName()).endsWith(".java");
    isAnnotationType = klass.isAnnotationType();
    bindingKey = klass.computeUniqueKey();

    char[] bindingFileName = klass.getFileName();
    int start = CharOperation.lastIndexOf('/', bindingFileName) + 1;
    if (start == 0 || start < CharOperation.lastIndexOf('\\', bindingFileName))
        start = CharOperation.lastIndexOf('\\', bindingFileName) + 1;
    fileName = new String(CharOperation.subarray(bindingFileName, start, -1));

    int jarFileEntrySeparatorIndex = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR,
            bindingFileName);
    if (jarFileEntrySeparatorIndex > 0) {
        char[] jarPart = CharOperation.subarray(bindingFileName, 0, jarFileEntrySeparatorIndex);
        IJavaElement jarPackageFragmentRoot = JavaCore.create(new String(jarPart));
        String jarPath = jarPackageFragmentRoot.getPath().toOSString();
        char[] entryPart = CharOperation.subarray(bindingFileName, jarFileEntrySeparatorIndex + 1,
                bindingFileName.length);
        fullPath = new StringBuilder(jarPath).append("!/").append(entryPart).toString();
    } else {
        fullPath = new String(bindingFileName);
    }

    ReferenceBinding sourceOrClass = klass;
    if (!klass.isBinaryBinding()) {
        sourceOrClass = klass.outermostEnclosingType();
    }
    char[] classFullName = new char[0];
    for (char[] part : sourceOrClass.compoundName) {
        classFullName = CharOperation.concat(classFullName, part, '/');
    }
    char[][] temp = CharOperation.splitOn('.', sourceOrClass.getFileName());
    String extension = temp.length > 1 ? "." + new String(temp[temp.length - 1]) : "";
    javaModelPath = new String(classFullName) + extension;

    if (type == null) {
        annotations = new HashMap<>();
        methods = Collections.emptyList();
        interfaces = Collections.emptyList();
        typeParams = Collections.emptyList();
        fields = Collections.emptyList();
        innerClasses = Collections.emptyList();
    }
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.control.StateHelper.java

License:Open Source License

public static boolean isDefinitelyReadyToProcess(ReferenceBinding type, ReferenceBinding requestingSite,
        int state) {

    if (!(type instanceof SourceTypeBinding))
        return false; // most treatment not needed for binary types
    SourceTypeBinding sourceType = (SourceTypeBinding) type;

    if (TypeBinding.equalsEquals(sourceType.outermostEnclosingType().erasure(),
            requestingSite.outermostEnclosingType().erasure())
            || CharOperation.equals(type.getFileName(), requestingSite.getFileName()))
        return false; // could infinitely recurse to the same inclosing of kind

    if (!StateHelper.isReadyToProcess(sourceType, state))
        return false;

    try {/* w  w  w .  ja va  2  s. com*/
        StateMemento unitState = sourceType.scope.compilationUnitScope().referenceContext.state;
        if (unitState.isReadyToProcess(state))
            return true; // GOAL
    } catch (NullPointerException npe) {
        // be shy, if any enclosing thing was missing don't risk infinite recursion.
    }

    return false;
}