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

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

Introduction

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

Prototype

char[][][] getMissingTypeNames();

Source Link

Document

Answer the list of missing type names which were referenced from the problem classfile.

Usage

From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java

License:Open Source License

public byte[] digest(IBinaryType classFile) {

    // type level comparison
    // modifiers// ww w .j  a  v  a2 s  .  c o m
    updateInt(classFile.getModifiers());

    // only consider a portion of the tagbits which indicate a structural change for dependents
    // e.g. @Override change has no influence outside
    long OnlyStructuralTagBits = TagBits.AnnotationTargetMASK // different @Target status ?
            | TagBits.AnnotationDeprecated // different @Deprecated status ?
            | TagBits.AnnotationRetentionMASK // different @Retention status ?
            | TagBits.HierarchyHasProblems; // different hierarchy status ?

    // meta-annotations
    updateLong(classFile.getTagBits() & OnlyStructuralTagBits);
    // annotations
    updateAnnotations(classFile.getAnnotations());

    // generic signature
    updateChars(classFile.getGenericSignature());
    // superclass
    updateChars(classFile.getSuperclassName());
    // interfaces
    char[][] interfacesNames = classFile.getInterfaceNames();
    if (interfacesNames != null) {
        for (int i = 0; i < interfacesNames.length; i++) {
            updateChars(interfacesNames[i]);
        }
    }

    // member types
    IBinaryNestedType[] memberTypes = classFile.getMemberTypes();
    if (memberTypes != null) {
        for (int i = 0; i < memberTypes.length; i++) {
            updateChars(memberTypes[i].getName());
            updateInt(memberTypes[i].getModifiers());
        }
    }

    // fields
    FieldInfo[] fieldInfos = (FieldInfo[]) classFile.getFields();
    if (fieldInfos != null) {
        for (int i = 0; i < fieldInfos.length; i++) {
            updateField(fieldInfos[i]);
        }
    }

    // methods
    MethodInfo[] methodInfos = (MethodInfo[]) classFile.getMethods();
    if (methodInfos != null) {
        for (int i = 0; i < methodInfos.length; i++) {
            updateMethod(methodInfos[i]);
        }
    }

    // missing types
    char[][][] missingTypes = classFile.getMissingTypeNames();
    if (missingTypes != null) {
        for (int i = 0; i < missingTypes.length; i++) {
            for (int j = 0; j < missingTypes[i].length; j++) {
                if (j > 0) {
                    updateChar('.'); // don't ask why
                }
                updateChars(missingTypes[i][j]);
            }
        }
    }

    return digester.digest();
}

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);
}