Example usage for org.eclipse.jdt.internal.compiler.env IBinaryField getTypeName

List of usage examples for org.eclipse.jdt.internal.compiler.env IBinaryField getTypeName

Introduction

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

Prototype

char[] getTypeName();

Source Link

Document

Answer the resolved name of the receiver's type in the class file format as specified in section 4.3.2 of the Java 2 VM spec.

Usage

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

License:Open Source License

public String getTypeSignature() throws JavaModelException {
    IBinaryField info = (IBinaryField) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature != null) {
        return new String(ClassFile.translatedName(genericSignature));
    }//ww w.j a va  2  s  .c o  m
    return new String(ClassFile.translatedName(info.getTypeName()));
}

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

License:Open Source License

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
    if (!pattern.findDeclarations)
        return false; // only relevant when finding declarations
    if (!(binaryInfo instanceof IBinaryField))
        return false;

    IBinaryField field = (IBinaryField) binaryInfo;
    if (!pattern.matchesName(pattern.name, field.getName()))
        return false;
    if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification,
            pattern.isCaseSensitive(), pattern.isCamelCase()))
        return false;

    char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
    return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature,
            pattern.isCaseSensitive(), pattern.isCamelCase());
}

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

License:Open Source License

private static JsonElement toJsonField(IBinaryField field) {
    JsonObject object = new JsonObject();
    object.addProperty("modifiers", field.getModifiers());
    object.add("constant", toJsonConstant(field.getConstant()));
    object.add("genericSignature", field.getGenericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(field.getGenericSignature())));
    object.add("name",
            field.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.getName())));
    object.addProperty("tagBits", String.valueOf(field.getTagBits()));
    object.add("typeName", field.getTypeName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(field.getTypeName())));
    object.add("annotations", toJsonAnnotations(field.getAnnotations()));
    return object;
}

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

License:Open Source License

private boolean hasStructuralChanges(ClassFileReader reader, TypeStructure existingType, int flags) {
    if (existingType == null) {
        return true;
    }//  ww w. j  ava 2 s.  c o m

    // modifiers
    if (!modifiersEqual(reader.getModifiers(), existingType.modifiers)) {
        return true;
    }

    // generic signature
    if (!CharOperation.equals(reader.getGenericSignature(), existingType.genericSignature)) {
        return true;
    }

    // superclass name
    if (!CharOperation.equals(reader.getSuperclassName(), existingType.superclassName)) {
        return true;
    }

    // class level annotations
    if ((flags & FLAG_ANNOTATION) != 0) {
        IBinaryAnnotation[] existingAnnotations = existingType.getAnnotations();
        IBinaryAnnotation[] newAnnotations = reader.getAnnotations();
        if (!annotationsEqual(existingAnnotations, newAnnotations, flags)) {
            return true;
        }
    }

    // tag bits; standard annotations like @Deprecated
    if (reader.getTagBits() != existingType.getTagBits()) {
        return true;
    }

    // interfaces
    char[][] existingIfs = existingType.interfaces;
    char[][] newIfsAsChars = reader.getInterfaceNames();
    if (newIfsAsChars == null) {
        newIfsAsChars = EMPTY_CHAR_ARRAY;
    } // damn I'm lazy...
    if (existingIfs == null) {
        existingIfs = EMPTY_CHAR_ARRAY;
    }
    if (existingIfs.length != newIfsAsChars.length)
        return true;
    new_interface_loop: for (int i = 0; i < newIfsAsChars.length; i++) {
        for (int j = 0; j < existingIfs.length; j++) {
            if (CharOperation.equals(existingIfs[j], newIfsAsChars[i])) {
                continue new_interface_loop;
            }
        }
        return true;
    }

    // fields
    IBinaryField[] newFields = reader.getFields();
    if (newFields == null) {
        newFields = TypeStructure.NoField;
    }

    IBinaryField[] existingFs = existingType.binFields;
    if (newFields.length != existingFs.length)
        return true;
    new_field_loop: for (int i = 0; i < newFields.length; i++) {
        IBinaryField field = newFields[i];
        char[] fieldName = field.getName();
        for (int j = 0; j < existingFs.length; j++) {
            if (CharOperation.equals(existingFs[j].getName(), fieldName)) {
                if (!modifiersEqual(field.getModifiers(), existingFs[j].getModifiers())) {
                    return true;
                }
                if (!CharOperation.equals(existingFs[j].getTypeName(), field.getTypeName())) {
                    return true;
                }
                if ((flags & FLAG_ANNOTATION) != 0) {
                    if (!annotationsEqual(field.getAnnotations(), existingFs[j].getAnnotations(), flags)) {
                        return true;
                    }
                }
                continue new_field_loop;
            }
        }
        return true;
    }

    // methods
    IBinaryMethod[] newMethods = reader.getMethods();
    if (newMethods == null) {
        newMethods = TypeStructure.NoMethod;
    }

    IBinaryMethod[] existingMs = existingType.binMethods;
    if (newMethods.length != existingMs.length)
        return true;
    new_method_loop: for (int i = 0; i < newMethods.length; i++) {
        IBinaryMethod method = newMethods[i];
        char[] methodName = method.getSelector();
        for (int j = 0; j < existingMs.length; j++) {
            if (CharOperation.equals(existingMs[j].getSelector(), methodName)) {
                // candidate match
                if (!CharOperation.equals(method.getMethodDescriptor(), existingMs[j].getMethodDescriptor())) {
                    continue; // might be overloading
                } else {
                    // matching sigs
                    if (!modifiersEqual(method.getModifiers(), existingMs[j].getModifiers())) {
                        return true;
                    }
                    if ((flags & FLAG_ANNOTATION) != 0) {
                        if (!annotationsEqual(method.getAnnotations(), existingMs[j].getAnnotations(), flags)) {
                            return true;
                        }

                        if (!parameterAnnotationsEquals(method, existingMs[j], flags)) {
                            return true;
                        }

                    }
                    continue new_method_loop;
                }
            }
        }
        return true; // (no match found)
    }

    return false;
}