public static String annotationToString(IBinaryAnnotation annotation) { StringBuffer buffer = new StringBuffer(); buffer.append('@'); buffer.append(annotation.getTypeName()); IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs(); if (valuePairs != null) { buffer.append('('); buffer.append("\n\t"); //$NON-NLS-1$ for (int i = 0, len = valuePairs.length; i < len; i++) { if (i > 0) buffer.append(",\n\t"); //$NON-NLS-1$ buffer.append(valuePairs[i]); } buffer.append(')'); } return buffer.toString(); }
static AnnotationBinding createAnnotation(IBinaryAnnotation annotationInfo, LookupEnvironment env, char[][][] missingTypeNames) { IBinaryElementValuePair[] binaryPairs = annotationInfo.getElementValuePairs(); int length = binaryPairs == null ? 0 : binaryPairs.length; ElementValuePair[] pairs = length == 0 ? Binding.NO_ELEMENT_VALUE_PAIRS : new ElementValuePair[length]; for (int i = 0; i < length; i++) pairs[i] = new ElementValuePair(binaryPairs[i].getName(), convertMemberValue(binaryPairs[i].getValue(), env, missingTypeNames, false), null); char[] typeName = annotationInfo.getTypeName(); LookupEnvironment env2 = annotationInfo.isExternalAnnotation() ? env.root : env; ReferenceBinding annotationType = env2.getTypeFromConstantPoolName(typeName, 1, typeName.length - 1, false, missingTypeNames); return env2.createUnresolvedAnnotation(annotationType, pairs); }
public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) { char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.')); return new Annotation(parent, new String(typeName), memberValuePairName); }
public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }
if (annotation.isDeprecatedAnnotation()) { AnnotationBinding[] annotationBindings = createAnnotations(new IBinaryAnnotation[] { annotation }, this.environment, missingTypeNames); setAnnotations(annotationBindings, true); // force storing
public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) { char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.')); return new Annotation(parent, new String(typeName), memberValuePairName); }
public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }
public static String annotationToString(IBinaryAnnotation annotation) { StringBuffer buffer = new StringBuffer(); buffer.append('@'); buffer.append(annotation.getTypeName()); IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs(); if (valuePairs != null) { buffer.append('('); buffer.append("\n\t"); //$NON-NLS-1$ for (int i = 0, len = valuePairs.length; i < len; i++) { if (i > 0) buffer.append(",\n\t"); //$NON-NLS-1$ buffer.append(valuePairs[i]); } buffer.append(')'); } return buffer.toString(); }
public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) { char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.')); return new Annotation(parent, new String(typeName), memberValuePairName); }
static AnnotationBinding createAnnotation(IBinaryAnnotation annotationInfo, LookupEnvironment env, char[][][] missingTypeNames) { // temporary debug for Bug 532176 - [10] NPE during reconcile if (annotationInfo instanceof AnnotationInfo) { RuntimeException ex = ((AnnotationInfo) annotationInfo).exceptionDuringDecode; if (ex != null) new IllegalStateException("Accessing annotation with decode error", ex).printStackTrace(); //$NON-NLS-1$ } //-- IBinaryElementValuePair[] binaryPairs = annotationInfo.getElementValuePairs(); int length = binaryPairs == null ? 0 : binaryPairs.length; ElementValuePair[] pairs = length == 0 ? Binding.NO_ELEMENT_VALUE_PAIRS : new ElementValuePair[length]; for (int i = 0; i < length; i++) pairs[i] = new ElementValuePair(binaryPairs[i].getName(), convertMemberValue(binaryPairs[i].getValue(), env, missingTypeNames, false), null); char[] typeName = annotationInfo.getTypeName(); LookupEnvironment env2 = annotationInfo.isExternalAnnotation() ? env.root : env; ReferenceBinding annotationType = env2.getTypeFromConstantPoolName(typeName, 1, typeName.length - 1, false, missingTypeNames); return env2.createUnresolvedAnnotation(annotationType, pairs); }
public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }
private boolean hasStructuralAnnotationChanges(IBinaryAnnotation[] currentAnnotations, IBinaryAnnotation[] otherAnnotations) { if (currentAnnotations == otherAnnotations) return false; int currentAnnotationsLength = currentAnnotations == null ? 0 : currentAnnotations.length; int otherAnnotationsLength = otherAnnotations == null ? 0 : otherAnnotations.length; if (currentAnnotationsLength != otherAnnotationsLength) return true; for (int i = 0; i < currentAnnotationsLength; i++) { if (!CharOperation.equals(currentAnnotations[i].getTypeName(), otherAnnotations[i].getTypeName())) return true; IBinaryElementValuePair[] currentPairs = currentAnnotations[i].getElementValuePairs(); IBinaryElementValuePair[] otherPairs = otherAnnotations[i].getElementValuePairs(); int currentPairsLength = currentPairs == null ? 0 : currentPairs.length; int otherPairsLength = otherPairs == null ? 0 : otherPairs.length; if (currentPairsLength != otherPairsLength) return true; for (int j = 0; j < currentPairsLength; j++) { if (!CharOperation.equals(currentPairs[j].getName(), otherPairs[j].getName())) return true; if (!currentPairs[j].getValue().equals(otherPairs[j].getValue())) return true; } } return false; }
public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) { char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.')); return new Annotation(parent, new String(typeName), memberValuePairName); }
public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }
private Boolean matchAnnotations(IBinaryAnnotation currentAnnotation, IBinaryAnnotation otherAnnotation) { if (!CharOperation.equals(currentAnnotation.getTypeName(), otherAnnotation.getTypeName())) return true; IBinaryElementValuePair[] currentPairs = currentAnnotation.getElementValuePairs(); IBinaryElementValuePair[] otherPairs = otherAnnotation.getElementValuePairs(); int currentPairsLength = currentPairs == null ? 0 : currentPairs.length; int otherPairsLength = otherPairs == null ? 0 : otherPairs.length;
Map<String, String> gleanNamedType(File classfile) throws IOException { // use jdt class reader to avoid extra runtime dependency, otherwise could use asm try { ClassFileReader type = ClassFileReader.read(classfile); IBinaryAnnotation[] annotations = type.getAnnotations(); if (annotations != null) { for (IBinaryAnnotation annotation : annotations) { if ("Ljavax/inject/Named;".equals(new String(annotation.getTypeName()))) { return Collections.singletonMap(new String(type.getName()).replace('/', '.'), null); } } } } catch (ClassFormatException e) { // silently ignore classes we can't read/parse } return null; }
public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }
private Boolean matchAnnotations(IBinaryAnnotation currentAnnotation, IBinaryAnnotation otherAnnotation) { if (!CharOperation.equals(currentAnnotation.getTypeName(), otherAnnotation.getTypeName())) return true; IBinaryElementValuePair[] currentPairs = currentAnnotation.getElementValuePairs(); IBinaryElementValuePair[] otherPairs = otherAnnotation.getElementValuePairs(); int currentPairsLength = currentPairs == null ? 0 : currentPairs.length; int otherPairsLength = otherPairs == null ? 0 : otherPairs.length;
Map<String, String> gleanNamedType(File classfile) throws IOException { // use jdt class reader to avoid extra runtime dependency, otherwise could use asm try { ClassFileReader type = ClassFileReader.read(classfile); IBinaryAnnotation[] annotations = type.getAnnotations(); if (annotations != null) { for (IBinaryAnnotation annotation : annotations) { if ("Ljavax/inject/Named;".equals(new String(annotation.getTypeName()))) { return Collections.singletonMap(new String(type.getName()).replace('/', '.'), null); } } } } catch (ClassFormatException e) { // silently ignore classes we can't read/parse } return null; }
@Override public IMemberValuePair[] getMemberValuePairs() throws JavaModelException { Object info = getElementInfo(); if (info instanceof AnnotationInfo) return ((AnnotationInfo) info).members; IBinaryElementValuePair[] binaryAnnotations = ((IBinaryAnnotation) info).getElementValuePairs(); int length = binaryAnnotations.length; IMemberValuePair[] result = new IMemberValuePair[length]; for (int i = 0; i < length; i++) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations[i]; MemberValuePair memberValuePair = new MemberValuePair(new String(binaryAnnotation.getName())); memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, binaryAnnotation.getValue()); result[i] = memberValuePair; } return result; }