View | Details | Raw Unified | Return to bug 271561 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClassFileInfo.java (-1 / +38 lines)
Lines 57-68 Link Here
57
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo) {
57
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo) {
58
	char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.'));
58
	char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.'));
59
	Annotation annotation = new Annotation(parent, new String(typeName));
59
	Annotation annotation = new Annotation(parent, new String(typeName));
60
	while (newElements.containsKey(annotation)) {
61
		annotation.occurrenceCount++;
62
	}
63
	newElements.put(annotation, annotationInfo);
64
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
65
	for (int i = 0, length = pairs.length; i < length; i++) {
66
		Object value = pairs[i].getValue();
67
		if (value instanceof IBinaryAnnotation) {
68
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, new String(pairs[i].getName()));
69
		} else if (value instanceof Object[]) {
70
			// if the value is an array, it can have no more than 1 dimension - no need to recurse
71
			Object[] valueArray = (Object[]) value;
72
			for (int j = 0, valueArrayLength = valueArray.length; j < valueArrayLength; j++) {
73
				Object nestedValue = valueArray[j];
74
				if (nestedValue instanceof IBinaryAnnotation) {
75
					generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) nestedValue, new String(pairs[i].getName()));
76
				}
77
			}
78
		}
79
	}
80
}
81
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo, String memberName) {
82
	char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.'));
83
	Annotation annotation = new Annotation(parent, new String(typeName));
84
	annotation.memberValueName = memberName;
85
	while (newElements.containsKey(annotation)) {
86
		annotation.occurrenceCount++;
87
	}
60
	newElements.put(annotation, annotationInfo);
88
	newElements.put(annotation, annotationInfo);
61
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
89
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
62
	for (int i = 0, length = pairs.length; i < length; i++) {
90
	for (int i = 0, length = pairs.length; i < length; i++) {
63
		Object value = pairs[i].getValue();
91
		Object value = pairs[i].getValue();
64
		if (value instanceof IBinaryAnnotation) {
92
		if (value instanceof IBinaryAnnotation) {
65
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value);
93
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, new String(pairs[i].getName()));
94
		} else if (value instanceof Object[]) {
95
			// if the value is an array, it can have no more than 1 dimension - no need to recurse
96
			Object[] valueArray = (Object[]) value;
97
			for (int j = 0, valueArrayLength = valueArray.length; j < valueArrayLength; j++) {
98
				Object nestedValue = valueArray[j];
99
				if (nestedValue instanceof IBinaryAnnotation) {
100
					generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) nestedValue, new String(pairs[i].getName()));
101
				}
102
			}
66
		}
103
		}
67
	}
104
	}
68
}
105
}
(-)model/org/eclipse/jdt/internal/core/Annotation.java (-1 / +20 lines)
Lines 26-31 Link Here
26
	public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0];
26
	public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0];
27
27
28
	protected String name;
28
	protected String name;
29
	// require to distinguish same annotations in different member value pairs
30
	public String memberValueName;
29
31
30
	public Annotation(JavaElement parent, String name) {
32
	public Annotation(JavaElement parent, String name) {
31
		super(parent);
33
		super(parent);
Lines 33-39 Link Here
33
	}
35
	}
34
36
35
	public boolean equals(Object o) {
37
	public boolean equals(Object o) {
36
		if (!(o instanceof Annotation)) return false;
38
		if (!(o instanceof Annotation)) {
39
			return false;
40
		}
41
		Annotation other = (Annotation) o;
42
		if (this.memberValueName == null) {
43
			if (other.memberValueName != null)
44
				return false;
45
		} else if (!this.memberValueName.equals(other.memberValueName)) {
46
			return false;
47
		}
37
		return super.equals(o);
48
		return super.equals(o);
38
	}
49
	}
39
50
Lines 107-112 Link Here
107
		return ((JavaElement)getParent()).getClassFile();
118
		return ((JavaElement)getParent()).getClassFile();
108
	}
119
	}
109
120
121
	public int hashCode() {
122
		final int prime = 31;
123
		int result = super.hashCode();
124
		result = prime * result + ((this.memberValueName == null) ? 0 : this.memberValueName.hashCode());
125
		result = prime * result + this.name.hashCode();
126
		return result;
127
	}
128
110
	protected void toStringName(StringBuffer buffer) {
129
	protected void toStringName(StringBuffer buffer) {
111
		buffer.append('@');
130
		buffer.append('@');
112
		buffer.append(getElementName());
131
		buffer.append(getElementName());
(-)model/org/eclipse/jdt/internal/core/util/Util.java (-2 / +13 lines)
Lines 3065-3071 Link Here
3065
		}
3065
		}
3066
		return typeArguments;
3066
		return typeArguments;
3067
	}
3067
	}
3068
	public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation) {
3068
	public static Annotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation) {
3069
		char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
3069
		char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
3070
		return new Annotation(parent, new String(typeName));
3070
		return new Annotation(parent, new String(typeName));
3071
	}
3071
	}
Lines 3075-3081 Link Here
3075
			return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
3075
			return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
3076
		} else if (binaryValue instanceof IBinaryAnnotation) {
3076
		} else if (binaryValue instanceof IBinaryAnnotation) {
3077
			memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
3077
			memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
3078
			return getAnnotation(parent, (IBinaryAnnotation) binaryValue);
3078
			Annotation annotation = getAnnotation(parent, (IBinaryAnnotation) binaryValue);
3079
			annotation.memberValueName = memberValuePair.getMemberName();
3080
			return annotation;
3079
		} else if (binaryValue instanceof ClassSignature) {
3081
		} else if (binaryValue instanceof ClassSignature) {
3080
			memberValuePair.valueKind = IMemberValuePair.K_CLASS;
3082
			memberValuePair.valueKind = IMemberValuePair.K_CLASS;
3081
			char[] className = Signature.toCharArray(CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
3083
			char[] className = Signature.toCharArray(CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
Lines 3098-3103 Link Here
3098
					// values are heterogeneous, value kind is thus unknown
3100
					// values are heterogeneous, value kind is thus unknown
3099
					memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
3101
					memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
3100
				}
3102
				}
3103
				if (value instanceof Annotation) {
3104
					Annotation annotation = (Annotation) value;
3105
					annotation.memberValueName = memberValuePair.getMemberName();
3106
					for (int j = 0; j < i; j++) {
3107
						if (annotation.equals(values[j])) {
3108
							annotation.occurrenceCount++;
3109
						}
3110
					}
3111
				}
3101
				values[i] = value;
3112
				values[i] = value;
3102
			}
3113
			}
3103
			if (memberValuePair.valueKind == -1)
3114
			if (memberValuePair.valueKind == -1)

Return to bug 271561