List of usage examples for org.eclipse.jdt.internal.compiler.env IBinaryType getGenericSignature
char[] getGenericSignature();
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryType.java
License:Open Source License
/** * @see org.eclipse.jdt.core.IType#getSuperclassTypeSignature() * @since 3.0//w w w.ja v a2 s. c om */ public String getSuperclassTypeSignature() throws JavaModelException { IBinaryType info = (IBinaryType) getElementInfo(); char[] genericSignature = info.getGenericSignature(); if (genericSignature != null) { int signatureLength = genericSignature.length; // skip type parameters int index = 0; if (genericSignature[0] == '<') { int count = 1; while (count > 0 && ++index < signatureLength) { switch (genericSignature[index]) { case '<': count++; break; case '>': count--; break; } } index++; } int start = index; index = org.eclipse.jdt.internal.compiler.util.Util.scanClassTypeSignature(genericSignature, start) + 1; char[] superclassSig = CharOperation.subarray(genericSignature, start, index); return new String(ClassFile.translatedName(superclassSig)); } else { char[] superclassName = info.getSuperclassName(); if (superclassName == null) { return null; } return new String(Signature.createTypeSignature(ClassFile.translatedName(superclassName), true)); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryType.java
License:Open Source License
/** * @see org.eclipse.jdt.core.IType#getSuperInterfaceTypeSignatures() * @since 3.0//from w w w. j a v a 2s .c o m */ public String[] getSuperInterfaceTypeSignatures() throws JavaModelException { IBinaryType info = (IBinaryType) getElementInfo(); char[] genericSignature = info.getGenericSignature(); if (genericSignature != null) { ArrayList interfaces = new ArrayList(); int signatureLength = genericSignature.length; // skip type parameters int index = 0; if (genericSignature[0] == '<') { int count = 1; while (count > 0 && ++index < signatureLength) { switch (genericSignature[index]) { case '<': count++; break; case '>': count--; break; } } index++; } // skip superclass index = org.eclipse.jdt.internal.compiler.util.Util.scanClassTypeSignature(genericSignature, index) + 1; while (index < signatureLength) { int start = index; index = org.eclipse.jdt.internal.compiler.util.Util.scanClassTypeSignature(genericSignature, start) + 1; char[] interfaceSig = CharOperation.subarray(genericSignature, start, index); interfaces.add(new String(ClassFile.translatedName(interfaceSig))); } int size = interfaces.size(); String[] result = new String[size]; interfaces.toArray(result); return result; } else { char[][] names = info.getInterfaceNames(); int length; if (names == null || (length = names.length) == 0) { return CharOperation.NO_STRINGS; } names = ClassFile.translatedNames(names); String[] strings = new String[length]; for (int i = 0; i < length; i++) { strings[i] = new String(Signature.createTypeSignature(names[i], true)); } return strings; } }
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryType.java
License:Open Source License
/** * @see org.eclipse.jdt.core.IType#getTypeParameterSignatures() * @since 3.0/* ww w. j a v a 2 s .co m*/ */ public String[] getTypeParameterSignatures() throws JavaModelException { IBinaryType info = (IBinaryType) getElementInfo(); char[] genericSignature = info.getGenericSignature(); if (genericSignature == null) return CharOperation.NO_STRINGS; char[] dotBaseSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.'); char[][] typeParams = Signature.getTypeParameters(dotBaseSignature); return CharOperation.toStrings(typeParams); }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java
License:Open Source License
/** * Creates the handles for <code>BinaryMember</code>s defined in this * <code>ClassFile</code> and adds them to the * <code>JavaModelManager</code>'s cache. *//*ww w. j ava2 s . co m*/ protected void readBinaryChildren(ClassFile classFile, HashMap newElements, IBinaryType typeInfo) { ArrayList childrenHandles = new ArrayList(); BinaryType type = (BinaryType) classFile.getType(); ArrayList typeParameterHandles = new ArrayList(); if (typeInfo != null) { //may not be a valid class file generateAnnotationsInfos(type, typeInfo.getAnnotations(), typeInfo.getTagBits(), newElements); generateTypeParameterInfos(type, typeInfo.getGenericSignature(), newElements, typeParameterHandles); generateFieldInfos(type, typeInfo, newElements, childrenHandles); generateMethodInfos(type, typeInfo, newElements, childrenHandles, typeParameterHandles); generateInnerClassHandles(type, typeInfo, childrenHandles); // Note inner class are separate openables that are not opened here: no need to pass in newElements } this.binaryChildren = new JavaElement[childrenHandles.size()]; childrenHandles.toArray(this.binaryChildren); int typeParameterHandleSize = typeParameterHandles.size(); if (typeParameterHandleSize == 0) { this.typeParameters = TypeParameter.NO_TYPE_PARAMETERS; } else { this.typeParameters = new ITypeParameter[typeParameterHandleSize]; typeParameterHandles.toArray(this.typeParameters); } }
From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java
License:Open Source License
public byte[] digest(IBinaryType classFile) { // type level comparison // modifiers//from ww w. jav a 2s.co 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); }