List of usage examples for org.eclipse.jdt.internal.compiler.env IBinaryAnnotation getElementValuePairs
IBinaryElementValuePair[] getElementValuePairs();
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java
License:Open Source License
private void generateAnnotationInfo(JavaElement parent, char[] parameterName, HashMap newElements, IBinaryAnnotation annotationInfo, String memberValuePairName) { char[] typeName = org.eclipse.jdt.core.Signature .toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.')); Annotation annotation = new Annotation(parent, parent.manager, new String(typeName), memberValuePairName); while (newElements.containsKey(annotation)) { annotation.occurrenceCount++;//from w ww . j a v a 2 s .co m } newElements.put(annotation, annotationInfo); IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs(); for (int i = 0, length = pairs.length; i < length; i++) { Object value = pairs[i].getValue(); if (value instanceof IBinaryAnnotation) { generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, new String(pairs[i].getName())); } else if (value instanceof Object[]) { // if the value is an array, it can have no more than 1 dimension - no need to recurse Object[] valueArray = (Object[]) value; for (int j = 0, valueArrayLength = valueArray.length; j < valueArrayLength; j++) { Object nestedValue = valueArray[j]; if (nestedValue instanceof IBinaryAnnotation) { generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) nestedValue, new String(pairs[i].getName())); } } } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.BinaryIndexer.java
License:Open Source License
private void addBinaryAnnotation(IBinaryAnnotation annotation) { addAnnotationTypeReference(replace('/', '.', Signature.toCharArray(annotation.getTypeName()))); IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs(); if (valuePairs != null) { for (int j = 0, vpLength = valuePairs.length; j < vpLength; j++) { IBinaryElementValuePair valuePair = valuePairs[j]; addMethodReference(valuePair.getName(), 0); Object pairValue = valuePair.getValue(); addPairValue(pairValue);//w w w .j a v a 2 s. co m } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.ClassFileMatchLocator.java
License:Open Source License
private boolean checkAnnotation(IBinaryAnnotation annotation, TypeReferencePattern pattern) { if (checkTypeName(pattern.simpleName, pattern.qualification, convertClassFileFormat(Signature.toCharArray(annotation.getTypeName())), pattern.isCaseSensitive, pattern.isCamelCase)) {//from www .j ava 2s. co m return true; } IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs(); if (valuePairs != null) { for (int j = 0, vpLength = valuePairs.length; j < vpLength; j++) { IBinaryElementValuePair valuePair = valuePairs[j]; Object pairValue = valuePair.getValue(); if (pairValue instanceof IBinaryAnnotation) { if (checkAnnotation((IBinaryAnnotation) pairValue, pattern)) { return true; } } } } return false; }
From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java
License:Open Source License
private void updateAnnotation(IBinaryAnnotation annotation) { updateChars(annotation.getTypeName()); IBinaryElementValuePair[] pairs = annotation.getElementValuePairs(); for (int j = 0; j < pairs.length; j++) { updateChars(pairs[j].getName()); final Object value = pairs[j].getValue(); if (value instanceof Object[]) { Object[] values = (Object[]) value; for (int n = 0; n < values.length; n++) { updateAnnotationValue(values[n]); }//from w w w.j a va 2 s .com } else { updateAnnotationValue(value); } } }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonAnnotation(IBinaryAnnotation annotation) { JsonObject object = new JsonObject(); object.add("typeName", annotation.getTypeName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(annotation.getTypeName()))); object.add("elementValuePairs", toJsonElementValuePairs(annotation.getElementValuePairs())); return object; }
From source file:org.jboss.tools.seam.internal.core.scanner.lib.TypeScanner.java
License:Open Source License
public static String getValue(IBinaryAnnotation a, String method) { try {//w w w . j a v a2 s . c om IBinaryElementValuePair[] ps = a.getElementValuePairs(); if (ps != null) for (int i = 0; i < ps.length; i++) { if (method.equals(new String(ps[i].getName()))) { Object v = ps[i].getValue(); if (v == null) return null; if (v instanceof EnumConstantSignature) { EnumConstantSignature cs = (EnumConstantSignature) v; char[] cv = cs.getEnumConstantName(); return cv == null ? null : new String(cv); } else if (v instanceof Constant) { Constant ic = (Constant) v; return ic.stringValue(); } v = v.toString(); return (String) v; } } } catch (Throwable e) { SeamCorePlugin.getPluginLog().logError(e); } return null; }