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 (+37 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
	}
60
	newElements.put(annotation, annotationInfo);
63
	newElements.put(annotation, annotationInfo);
61
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
64
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
62
	for (int i = 0, length = pairs.length; i < length; i++) {
65
	for (int i = 0, length = pairs.length; i < length; i++) {
63
		Object value = pairs[i].getValue();
66
		Object value = pairs[i].getValue();
64
		if (value instanceof IBinaryAnnotation) {
67
		if (value instanceof IBinaryAnnotation) {
65
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value);
68
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value);
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
	}
88
	newElements.put(annotation, annotationInfo);
89
	IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs();
90
	for (int i = 0, length = pairs.length; i < length; i++) {
91
		Object value = pairs[i].getValue();
92
		if (value instanceof IBinaryAnnotation) {
93
			generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, memberName);
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 / +19 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
	public String memberValueName;
29
30
30
	public Annotation(JavaElement parent, String name) {
31
	public Annotation(JavaElement parent, String name) {
31
		super(parent);
32
		super(parent);
Lines 33-39 Link Here
33
	}
34
	}
34
35
35
	public boolean equals(Object o) {
36
	public boolean equals(Object o) {
36
		if (!(o instanceof Annotation)) return false;
37
		if (!(o instanceof Annotation)) {
38
			return false;
39
		}
40
		Annotation other = (Annotation) o;
41
		if (this.memberValueName == null) {
42
			if (other.memberValueName != null)
43
				return false;
44
		} else if (!this.memberValueName.equals(other.memberValueName)) {
45
			return false;
46
		}
37
		return super.equals(o);
47
		return super.equals(o);
38
	}
48
	}
39
49
Lines 107-112 Link Here
107
		return ((JavaElement)getParent()).getClassFile();
117
		return ((JavaElement)getParent()).getClassFile();
108
	}
118
	}
109
119
120
	public int hashCode() {
121
		final int prime = 31;
122
		int result = super.hashCode();
123
		result = prime * result + ((this.memberValueName == null) ? 0 : this.memberValueName.hashCode());
124
		result = prime * result + this.name.hashCode();
125
		return result;
126
	}
127
110
	protected void toStringName(StringBuffer buffer) {
128
	protected void toStringName(StringBuffer buffer) {
111
		buffer.append('@');
129
		buffer.append('@');
112
		buffer.append(getElementName());
130
		buffer.append(getElementName());
(-)model/org/eclipse/jdt/internal/core/util/Util.java (+9 lines)
Lines 3098-3103 Link Here
3098
					// values are heterogeneous, value kind is thus unknown
3098
					// values are heterogeneous, value kind is thus unknown
3099
					memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
3099
					memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
3100
				}
3100
				}
3101
				if (value instanceof Annotation) {
3102
					Annotation annotation = (Annotation) value;
3103
					annotation.memberValueName = memberValuePair.getMemberName();
3104
					for (int j = 0; j < i; j++) {
3105
						if (annotation.equals(values[j])) {
3106
							annotation.occurrenceCount++;
3107
						}
3108
					}
3109
				}
3101
				values[i] = value;
3110
				values[i] = value;
3102
			}
3111
			}
3103
			if (memberValuePair.valueKind == -1)
3112
			if (memberValuePair.valueKind == -1)

Return to bug 271561