Example usage for org.eclipse.jdt.internal.compiler.env IBinaryType isLocal

List of usage examples for org.eclipse.jdt.internal.compiler.env IBinaryType isLocal

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env IBinaryType isLocal.

Prototype

boolean isLocal();

Source Link

Document

Answer true if the receiver is a local class.

Usage

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

License:Open Source License

public boolean isLocal() throws JavaModelException {
    IBinaryType info = (IBinaryType) getElementInfo();
    return info.isLocal();
}

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

License:Open Source License

public String sourceFileName(IBinaryType info) {
    char[] sourceFileName = info.sourceFileName();
    if (sourceFileName == null) {
        /*//ww w.  j  av a2 s . c o  m
         * We assume that this type has been compiled from a file with its name
         * For example, A.class comes from A.java and p.A.class comes from a file A.java
         * in the folder p.
         */
        if (info.isMember()) {
            IType enclosingType = getDeclaringType();
            if (enclosingType == null)
                return null; // play it safe
            while (enclosingType.getDeclaringType() != null) {
                enclosingType = enclosingType.getDeclaringType();
            }
            return enclosingType.getElementName() + Util.defaultJavaExtension();
        } else if (info.isLocal() || info.isAnonymous()) {
            String typeQualifiedName = getTypeQualifiedName();
            int dollar = typeQualifiedName.indexOf('$');
            if (dollar == -1) {
                // malformed inner type: name doesn't contain a dollar
                return getElementName() + Util.defaultJavaExtension();
            }
            return typeQualifiedName.substring(0, dollar) + Util.defaultJavaExtension();
        } else {
            return getElementName() + Util.defaultJavaExtension();
        }
    } else {
        int index = CharOperation.lastIndexOf('/', sourceFileName);
        return new String(sourceFileName, index + 1, sourceFileName.length - index - 1);
    }
}

From source file:org.eclipse.che.jdt.BinaryTypeConvector.java

License:Open Source License

public static String toJsonBinaryType(IBinaryType type) {
    JsonObject object = new JsonObject();
    object.add("annotations", toJsonAnnotations(type.getAnnotations()));
    object.add("enclosingMethod", type.getEnclosingMethod() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.getEnclosingMethod())));
    object.add("enclosingTypeName", type.getEnclosingTypeName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.getEnclosingTypeName())));
    object.add("fields", toJsonFields(type.getFields()));
    object.add("genericSignature", type.getGenericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.getGenericSignature())));
    object.add("interfaceNames", toJsonArrayString(type.getInterfaceNames()));
    object.add("memberTypes", toJsonMemberTypes(type.getMemberTypes()));
    object.add("methods", toJsonMethods(type.getMethods()));
    object.add("missingTypeNames", toJsonMissingTypeNames(type.getMissingTypeNames()));
    object.add("name",
            type.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.getName())));
    object.add("sourceName", type.getSourceName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.getSourceName())));
    object.add("superclassName", type.getSuperclassName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.getSuperclassName())));
    object.add("tagBits", new JsonPrimitive(String.valueOf(type.getTagBits())));
    object.add("anonymous", new JsonPrimitive(type.isAnonymous()));
    object.add("local", new JsonPrimitive(type.isLocal()));
    object.add("member", new JsonPrimitive(type.isMember()));
    object.add("sourceFileName", type.sourceFileName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(type.sourceFileName())));
    object.add("modifiers", new JsonPrimitive(type.getModifiers()));
    object.add("binaryType", new JsonPrimitive(type.isBinaryType()));
    object.add("fileName",
            type.getFileName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.getFileName())));
    return gson.toJson(object);
}