### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/ClassFileInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java,v retrieving revision 1.44 diff -u -r1.44 ClassFileInfo.java --- model/org/eclipse/jdt/internal/core/ClassFileInfo.java 7 Mar 2009 01:08:08 -0000 1.44 +++ model/org/eclipse/jdt/internal/core/ClassFileInfo.java 8 Apr 2009 18:21:30 -0000 @@ -57,12 +57,49 @@ private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo) { char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.')); Annotation annotation = new Annotation(parent, new String(typeName)); + while (newElements.containsKey(annotation)) { + annotation.occurrenceCount++; + } 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); + } 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())); + } + } + } + } +} +private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo, String memberName) { + char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.')); + Annotation annotation = new Annotation(parent, new String(typeName)); + annotation.memberValueName = memberName; + while (newElements.containsKey(annotation)) { + annotation.occurrenceCount++; + } + 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, memberName); + } 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())); + } + } } } } Index: model/org/eclipse/jdt/internal/core/Annotation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Annotation.java,v retrieving revision 1.5 diff -u -r1.5 Annotation.java --- model/org/eclipse/jdt/internal/core/Annotation.java 7 Mar 2009 01:08:08 -0000 1.5 +++ model/org/eclipse/jdt/internal/core/Annotation.java 8 Apr 2009 18:21:30 -0000 @@ -26,6 +26,7 @@ public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0]; protected String name; + public String memberValueName; public Annotation(JavaElement parent, String name) { super(parent); @@ -33,7 +34,16 @@ } public boolean equals(Object o) { - if (!(o instanceof Annotation)) return false; + if (!(o instanceof Annotation)) { + return false; + } + Annotation other = (Annotation) o; + if (this.memberValueName == null) { + if (other.memberValueName != null) + return false; + } else if (!this.memberValueName.equals(other.memberValueName)) { + return false; + } return super.equals(o); } @@ -107,6 +117,14 @@ return ((JavaElement)getParent()).getClassFile(); } + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((this.memberValueName == null) ? 0 : this.memberValueName.hashCode()); + result = prime * result + this.name.hashCode(); + return result; + } + protected void toStringName(StringBuffer buffer) { buffer.append('@'); buffer.append(getElementName()); Index: model/org/eclipse/jdt/internal/core/util/Util.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v retrieving revision 1.129 diff -u -r1.129 Util.java --- model/org/eclipse/jdt/internal/core/util/Util.java 7 Mar 2009 00:58:54 -0000 1.129 +++ model/org/eclipse/jdt/internal/core/util/Util.java 8 Apr 2009 18:21:32 -0000 @@ -3098,6 +3098,15 @@ // values are heterogeneous, value kind is thus unknown memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; } + if (value instanceof Annotation) { + Annotation annotation = (Annotation) value; + annotation.memberValueName = memberValuePair.getMemberName(); + for (int j = 0; j < i; j++) { + if (annotation.equals(values[j])) { + annotation.occurrenceCount++; + } + } + } values[i] = value; } if (memberValuePair.valueKind == -1)