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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-58 / +73 lines)
Lines 67-82 Link Here
67
	}
67
	}
68
}
68
}
69
class ReferenceCollector extends JavaSearchResultCollector {
69
class ReferenceCollector extends JavaSearchResultCollector {
70
	protected IJavaElement getElement(SearchMatch searchMatch) {
70
	protected void writeLine() throws CoreException {
71
		IJavaElement element = super.getElement(searchMatch);
71
		super.writeLine();
72
		IJavaElement localElement = null;
73
		ReferenceMatch refMatch = (ReferenceMatch) this.match;
72
		ReferenceMatch refMatch = (ReferenceMatch) this.match;
74
		localElement = refMatch.getLocalElement();
73
		IJavaElement localElement = refMatch.getLocalElement();
75
		if (localElement != null) {
74
		if (localElement != null) {
76
			return localElement;
75
			this.line.append("+[");
76
			if (localElement.getElementType() == IJavaElement.ANNOTATION) {
77
				this.line.append('@');
78
				this.line.append(localElement.getElementName());
79
				this.line.append(" on ");
80
				this.line.append(localElement.getParent().getElementName());
81
			} else {
82
				this.line.append(localElement.getElementName());
83
			}
84
			this.line.append(']');
77
		}
85
		}
78
		return element;
79
	}
86
	}
87
80
}
88
}
81
class TypeReferenceCollector extends ReferenceCollector {
89
class TypeReferenceCollector extends ReferenceCollector {
82
	protected void writeLine() throws CoreException {
90
	protected void writeLine() throws CoreException {
Lines 89-95 Link Here
89
			for (int i=0; i<length; i++) {
97
			for (int i=0; i<length; i++) {
90
				IJavaElement other = others[i];
98
				IJavaElement other = others[i];
91
				if (i>0) this.line.append(',');
99
				if (i>0) this.line.append(',');
92
				this.line.append(other.getElementName());
100
				if (other.getElementType() == IJavaElement.ANNOTATION) {
101
					this.line.append('@');
102
					this.line.append(other.getElementName());
103
					this.line.append(" on ");
104
					this.line.append(other.getParent().getElementName());
105
				} else {
106
					this.line.append(other.getElementName());
107
				}
93
			}
108
			}
94
			this.line.append(']');
109
			this.line.append(']');
95
		}
110
		}
Lines 5908-5919 Link Here
5908
	TypeReferenceCollector collector = new TypeReferenceCollector();
5923
	TypeReferenceCollector collector = new TypeReferenceCollector();
5909
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5924
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5910
	assertSearchResults(
5925
	assertSearchResults(
5911
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).TP [Test]\n" +
5926
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[TP]\n" + 
5912
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).clazz [Test]\n" +
5927
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[clazz]\n" + 
5913
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar1 [Test]\n" +
5928
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[localVar1]\n" + 
5914
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar1 [Test]\n" +
5929
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[localVar1]\n" + 
5915
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar2 [Test]\n" +
5930
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[localVar2]\n" + 
5916
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar2 [Test]",
5931
		"src/b110336/Test.java void b110336.Test.method(Class<Test>) [Test]+[localVar2]",
5917
		collector
5932
		collector
5918
	);
5933
	);
5919
}
5934
}
Lines 5936-5948 Link Here
5936
	TypeReferenceCollector collector = new TypeReferenceCollector();
5951
	TypeReferenceCollector collector = new TypeReferenceCollector();
5937
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5952
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5938
	assertSearchResults(
5953
	assertSearchResults(
5939
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1 [Test]\n" +
5954
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1 [Test]\n" + 
5940
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1.c [Test]\n" +
5955
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1.c [Test]\n" + 
5941
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().TP [Test]\n" +
5956
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo() [Test]+[TP]\n" + 
5942
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().o [Test]\n" +
5957
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo() [Test]+[o]\n" + 
5943
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().o [Test]\n" +
5958
		"src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo() [Test]+[o]\n" + 
5944
		"src/b110336/Test.java void b110336.Test.method1(Test).methodParam [Test]\n" +
5959
		"src/b110336/Test.java void b110336.Test.method1(Test) [Test]+[methodParam]\n" + 
5945
		"src/b110336/Test.java void b110336.Test.method1(Test).localVar1 [Test]",
5960
		"src/b110336/Test.java void b110336.Test.method1(Test) [Test]+[localVar1]",
5946
		collector
5961
		collector
5947
	);
5962
	);
5948
}
5963
}
Lines 5960-5966 Link Here
5960
	TypeReferenceCollector collector = new TypeReferenceCollector();
5975
	TypeReferenceCollector collector = new TypeReferenceCollector();
5961
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5976
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5962
	assertSearchResults(
5977
	assertSearchResults(
5963
		"src/b110336/Test.java b110336.Test.TP [X]\n" +
5978
		"src/b110336/Test.java b110336.Test [X]+[TP]\n" + 
5964
		"src/b110336/Test.java b110336.Test.x [X]",
5979
		"src/b110336/Test.java b110336.Test.x [X]",
5965
		collector
5980
		collector
5966
	);
5981
	);
Lines 6004-6015 Link Here
6004
	TypeReferenceCollector collector = new TypeReferenceCollector();
6019
	TypeReferenceCollector collector = new TypeReferenceCollector();
6005
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6020
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6006
	assertSearchResults(
6021
	assertSearchResults(
6007
		"src/b110336/Test.java void b110336.Test.foo().lv1 [Test]+[lv2,lv3]\n" +
6022
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv1]+[lv2,lv3]\n" + 
6008
		"src/b110336/Test.java void b110336.Test.foo().lv2 [Test]\n" +
6023
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv2]\n" + 
6009
		"src/b110336/Test.java void b110336.Test.foo().lv4 [Test]+[lv5,lv6]\n" +
6024
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv4]+[lv5,lv6]\n" + 
6010
		"src/b110336/Test.java void b110336.Test.foo().lv4 [Test]\n" +
6025
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv4]\n" + 
6011
		"src/b110336/Test.java void b110336.Test.foo().lv7 [Test]+[lv8,lv9]\n" +
6026
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv7]+[lv8,lv9]\n" + 
6012
		"src/b110336/Test.java void b110336.Test.foo().lv9 [Test]",
6027
		"src/b110336/Test.java void b110336.Test.foo() [Test]+[lv9]",
6013
		collector
6028
		collector
6014
	);
6029
	);
6015
}
6030
}
Lines 6034-6044 Link Here
6034
	TypeReferenceCollector collector = new TypeReferenceCollector();
6049
	TypeReferenceCollector collector = new TypeReferenceCollector();
6035
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6050
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6036
	assertSearchResults(
6051
	assertSearchResults(
6037
		"src/b110336/Test.java void b110336.Test.foo(Test).test1 [Test]\n" +
6052
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]+[test1]\n" + 
6038
		"src/b110336/Test.java void b110336.Test.foo(Test).test2 [Test]\n" +
6053
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]+[test2]\n" + 
6039
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]\n" +
6054
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]\n" + 
6040
		"src/b110336/Test.java void b110336.Test.foo(Test).test4 [Test]\n" +
6055
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]+[test4]\n" + 
6041
		"src/b110336/Test.java void b110336.Test.foo(Test).test3 [Test]",
6056
		"src/b110336/Test.java void b110336.Test.foo(Test) [Test]+[test3]",
6042
		collector
6057
		collector
6043
	);
6058
	);
6044
}
6059
}
Lines 6058-6069 Link Here
6058
	TypeReferenceCollector collector = new TypeReferenceCollector();
6073
	TypeReferenceCollector collector = new TypeReferenceCollector();
6059
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6074
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6060
	assertSearchResults(
6075
	assertSearchResults(
6061
		"src/b110336/Test.java b110336.Test.{}.lv1 [Test]+[lv2,lv3]\n" +
6076
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv1]+[lv2,lv3]\n" + 
6062
		"src/b110336/Test.java b110336.Test.{}.lv2 [Test]\n" +
6077
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv2]\n" + 
6063
		"src/b110336/Test.java b110336.Test.{}.lv4 [Test]+[lv5,lv6]\n" +
6078
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv4]+[lv5,lv6]\n" + 
6064
		"src/b110336/Test.java b110336.Test.{}.lv4 [Test]\n" +
6079
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv4]\n" + 
6065
		"src/b110336/Test.java b110336.Test.{}.lv7 [Test]+[lv8,lv9]\n" +
6080
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv7]+[lv8,lv9]\n" + 
6066
		"src/b110336/Test.java b110336.Test.{}.lv9 [Test]",
6081
		"src/b110336/Test.java b110336.Test.{} [Test]+[lv9]",
6067
		collector
6082
		collector
6068
	);
6083
	);
6069
}
6084
}
Lines 6083-6094 Link Here
6083
	TypeReferenceCollector collector = new TypeReferenceCollector();
6098
	TypeReferenceCollector collector = new TypeReferenceCollector();
6084
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6099
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
6085
	assertSearchResults(
6100
	assertSearchResults(
6086
		"src/b110336/Test.java b110336.Test.static {}.lv1 [Test]+[lv2,lv3]\n" +
6101
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv1]+[lv2,lv3]\n" + 
6087
		"src/b110336/Test.java b110336.Test.static {}.lv2 [Test]\n" +
6102
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv2]\n" + 
6088
		"src/b110336/Test.java b110336.Test.static {}.lv4 [Test]+[lv5,lv6]\n" +
6103
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv4]+[lv5,lv6]\n" + 
6089
		"src/b110336/Test.java b110336.Test.static {}.lv4 [Test]\n" +
6104
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv4]\n" + 
6090
		"src/b110336/Test.java b110336.Test.static {}.lv7 [Test]+[lv8,lv9]\n" +
6105
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv7]+[lv8,lv9]\n" + 
6091
		"src/b110336/Test.java b110336.Test.static {}.lv9 [Test]",
6106
		"src/b110336/Test.java b110336.Test.static {} [Test]+[lv9]",
6092
		collector
6107
		collector
6093
	);
6108
	);
6094
}
6109
}
Lines 9430-9437 Link Here
9430
	TypeReferenceCollector collector = new TypeReferenceCollector();
9445
	TypeReferenceCollector collector = new TypeReferenceCollector();
9431
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9446
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9432
	assertSearchResults(
9447
	assertSearchResults(
9433
		"src/xy/Try.java @Constants(value=Try.class) [Try]\n" +
9448
		"src/xy/Try.java xy.Try.fTryA [Try]+[@Constants on fTryA]+[@Constants on fTryB]\n" + 
9434
		"src/xy/Try.java @Constants(value=Try.class) [Try]",
9449
		"src/xy/Try.java void xy.Try.tryB(int) [Try]+[@Constants on tryCopy]+[@Constants on tryCopy2]",
9435
		collector
9450
		collector
9436
	);
9451
	);
9437
}
9452
}
Lines 9459-9465 Link Here
9459
	collector.showSelection();
9474
	collector.showSelection();
9460
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9475
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9461
	assertSearchResults(
9476
	assertSearchResults(
9462
		"src/test/Test.java @Annot(clazz=Test.class) [        @Annot(clazz=§|Test|§.class) int x;]",
9477
		"src/test/Test.java void test.Test.method() [        @Annot(clazz=§|Test|§.class) int x;]+[@Annot on x]",
9463
		collector
9478
		collector
9464
	);
9479
	);
9465
}
9480
}
Lines 9475-9481 Link Here
9475
	collector.showSelection();
9490
	collector.showSelection();
9476
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9491
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9477
	assertSearchResults(
9492
	assertSearchResults(
9478
		"src/test/Test.java @Deprecated() [        @§|Deprecated|§ foo() {}]",
9493
		"src/test/Test.java void test.Test.foo() [        @§|Deprecated|§ foo() {}]+[@Deprecated on foo]",
9479
		collector
9494
		collector
9480
	);
9495
	);
9481
}
9496
}
Lines 9501-9511 Link Here
9501
	collector.showSelection();
9516
	collector.showSelection();
9502
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9517
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9503
	assertSearchResults(
9518
	assertSearchResults(
9504
		"src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [    void doA(§|Ref|§ ref) {}]\n" +
9519
		"src/comment5/Ref.java void comment5.Ref.doA(Ref) [    void doA(§|Ref|§ ref) {}]+[ref]\n" + 
9505
		"src/comment5/Ref.java void comment5.Ref.doB(List<Ref>).ref [    void doB(List<§|Ref|§> ref) {}]\n" +
9520
		"src/comment5/Ref.java void comment5.Ref.doB(List<Ref>) [    void doB(List<§|Ref|§> ref) {}]+[ref]\n" + 
9506
		"src/comment5/Ref.java @Tag(value=Ref.class) [    void doC(@Tag(§|Ref|§.class) Ref ref) {}]\n" +
9521
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(§|Ref|§.class) Ref ref) {}]+[@Tag on ref]\n" + 
9507
		"src/comment5/Ref.java void comment5.Ref.doC(Ref).ref [    void doC(@Tag(Ref.class) §|Ref|§ ref) {}]\n" +
9522
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(Ref.class) §|Ref|§ ref) {}]+[ref]\n" + 
9508
		"src/comment5/Ref.java @Tag(value=Ref.class) [    void dontD(@Tag(§|Ref|§.class) Object ref) {}]",
9523
		"src/comment5/Ref.java void comment5.Ref.dontD(Object) [    void dontD(@Tag(§|Ref|§.class) Object ref) {}]+[@Tag on ref]",
9509
		collector
9524
		collector
9510
	);
9525
	);
9511
}
9526
}
Lines 9524-9530 Link Here
9524
	collector.showSelection();
9539
	collector.showSelection();
9525
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9540
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9526
	assertSearchResults(
9541
	assertSearchResults(
9527
		"src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.§|CONST|§)]",
9542
		"src/comment10/Ref.java comment10.Num [@Num(number= Num.§|CONST|§)]+[@Num on Num]",
9528
		collector
9543
		collector
9529
	);
9544
	);
9530
}
9545
}
Lines 9546-9554 Link Here
9546
	collector.showSelection();
9561
	collector.showSelection();
9547
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9562
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9548
	assertSearchResults(
9563
	assertSearchResults(
9549
		"src/comment22/Test.java @Tag() [    @§|Tag|§ Test test1, test2, test3;]\n" +
9564
		"src/comment22/Test.java comment22.Test.test1 [    @§|Tag|§ Test test1, test2, test3;]+[@Tag on test1]+[@Tag on test2,@Tag on test3]\n" + 
9550
		"src/comment22/Test.java @Tag() [        @§|Tag|§ Test local= null;]\n" +
9565
		"src/comment22/Test.java void comment22.Test.method() [        @§|Tag|§ Test local= null;]+[@Tag on local]\n" + 
9551
		"src/comment22/Test.java @Tag() [        @§|Tag|§ Test local1, local2, local3;]",
9566
		"src/comment22/Test.java void comment22.Test.method() [        @§|Tag|§ Test local1, local2, local3;]+[@Tag on local1]+[@Tag on local2,@Tag on local3]",
9552
		collector
9567
		collector
9553
	);
9568
	);
9554
}
9569
}
Lines 9568-9574 Link Here
9568
	collector.showSelection();
9583
	collector.showSelection();
9569
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9584
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9570
	assertSearchResults(
9585
	assertSearchResults(
9571
		"src/test/Test.java @Annot(clazz=test.Test.class) [    @Annot(clazz = §|test.Test|§.class) int x, y;]",
9586
		"src/test/Test.java test.TestMethodReference.x [    @Annot(clazz = §|test.Test|§.class) int x, y;]+[@Annot on x]+[@Annot on y]",
9572
		collector
9587
		collector
9573
	);
9588
	);
9574
}
9589
}
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-20 / +46 lines)
Lines 1706-1726 Link Here
1706
		} catch (Exception e) {
1706
		} catch (Exception e) {
1707
			// it's just for debug purposes... ignore all exceptions in this area
1707
			// it's just for debug purposes... ignore all exceptions in this area
1708
		}
1708
		}
1709
		if (match instanceof TypeReferenceMatch) {
1709
		if (match instanceof ReferenceMatch) {
1710
			try {
1710
			try {
1711
				TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) match;
1711
				ReferenceMatch refMatch = (ReferenceMatch) match;
1712
				JavaElement local = (JavaElement) typeRefMatch.getLocalElement();
1712
				JavaElement local = (JavaElement) refMatch.getLocalElement();
1713
				if (local != null) {
1713
				if (local != null) {
1714
					System.out.println("\tLocal element: "+ local.toStringWithAncestors()); //$NON-NLS-1$
1714
					System.out.println("\tLocal element: "+ local.toStringWithAncestors()); //$NON-NLS-1$
1715
				}
1715
				}
1716
				IJavaElement[] others = typeRefMatch.getOtherElements();
1716
				if (match instanceof TypeReferenceMatch) {
1717
				if (others != null) {
1717
					IJavaElement[] others = ((TypeReferenceMatch) refMatch).getOtherElements();
1718
					int length = others.length;
1718
					if (others != null) {
1719
					if (length > 0) {
1719
						int length = others.length;
1720
						System.out.println("\tOther elements:"); //$NON-NLS-1$
1720
						if (length > 0) {
1721
						for (int i=0; i<length; i++) {
1721
							System.out.println("\tOther elements:"); //$NON-NLS-1$
1722
							JavaElement other = (JavaElement) others[i];
1722
							for (int i=0; i<length; i++) {
1723
							System.out.println("\t\t- "+ other.toStringWithAncestors()); //$NON-NLS-1$
1723
								JavaElement other = (JavaElement) others[i];
1724
								System.out.println("\t\t- "+ other.toStringWithAncestors()); //$NON-NLS-1$
1725
							}
1724
						}
1726
						}
1725
					}
1727
					}
1726
				}
1728
				}
Lines 2187-2200 Link Here
2187
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException {
2189
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException {
2188
	for (int i=0, al=annotations.length; i<al; i++) {
2190
	for (int i=0, al=annotations.length; i<al; i++) {
2189
		Annotation annotationType = annotations[i];
2191
		Annotation annotationType = annotations[i];
2190
		IJavaElement localElement = null;
2192
		IJavaElement localAnnotation = null;
2193
		IJavaElement[] otherAnnotations = null;
2194
		int length = otherElements == null ? 0 : otherElements.length;
2195
		boolean handlesCreated = false;
2191
2196
2192
		// Look for annotation type ref
2197
		// Look for annotation type ref
2193
		TypeReference typeRef = annotationType.type;
2198
		TypeReference typeRef = annotationType.type;
2194
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef);
2199
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef);
2195
		if (level != null && enclosesElement && matchedContainer) {
2200
		if (level != null && enclosesElement && matchedContainer) {
2196
			localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2201
			localAnnotation = createHandle(annotationType, (IAnnotatable) enclosingElement);
2197
			this.patternLocator.matchReportReference(typeRef, enclosingElement, localElement, otherElements, elementBinding, level.intValue(), this);
2202
			if (length > 0) {
2203
				otherAnnotations = new IJavaElement[length];
2204
				for (int o=0; o<length; o++) {
2205
					otherAnnotations[o] = createHandle(annotationType, (IAnnotatable) otherElements[o]);
2206
				}
2207
			}
2208
			handlesCreated = true;
2209
			this.patternLocator.matchReportReference(typeRef, enclosingElement, localAnnotation, otherAnnotations, elementBinding, level.intValue(), this);
2198
		}
2210
		}
2199
2211
2200
		// Look for attribute ref
2212
		// Look for attribute ref
Lines 2204-2213 Link Here
2204
			level = (Integer) nodeSet.matchingNodes.removeKey(pair);
2216
			level = (Integer) nodeSet.matchingNodes.removeKey(pair);
2205
			if (level != null && enclosesElement) {
2217
			if (level != null && enclosesElement) {
2206
				ASTNode reference = (annotationType instanceof SingleMemberAnnotation) ? (ASTNode) annotationType: pair;
2218
				ASTNode reference = (annotationType instanceof SingleMemberAnnotation) ? (ASTNode) annotationType: pair;
2207
				if (localElement == null) {
2219
				if (!handlesCreated) {
2208
					localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2220
					localAnnotation = createHandle(annotationType, (IAnnotatable) enclosingElement);
2221
					if (length > 0) {
2222
						otherAnnotations = new IJavaElement[length];
2223
						for (int o=0; o<length; o++) {
2224
							otherAnnotations[o] = createHandle(annotationType, (IAnnotatable) otherElements[o]);
2225
						}
2226
					}
2227
					handlesCreated = true;
2209
				}
2228
				}
2210
				this.patternLocator.matchReportReference(reference, enclosingElement, localElement, otherElements, pair.binding, level.intValue(), this);
2229
				this.patternLocator.matchReportReference(reference, enclosingElement, localAnnotation, otherAnnotations, pair.binding, level.intValue(), this);
2211
			}
2230
			}
2212
		}
2231
		}
2213
2232
Lines 2223-2232 Link Here
2223
					ASTNode node = nodes[j];
2242
					ASTNode node = nodes[j];
2224
					level = (Integer) nodeSet.matchingNodes.removeKey(node);
2243
					level = (Integer) nodeSet.matchingNodes.removeKey(node);
2225
					if (enclosesElement) {
2244
					if (enclosesElement) {
2226
						if (localElement == null) {
2245
						if (!handlesCreated) {
2227
							localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2246
							localAnnotation = createHandle(annotationType, (IAnnotatable) enclosingElement);
2247
							if (length > 0) {
2248
								otherAnnotations = new IJavaElement[length];
2249
								for (int o=0; o<length; o++) {
2250
									otherAnnotations[o] = createHandle(annotationType, (IAnnotatable) otherElements[o]);
2251
								}
2252
							}
2253
							handlesCreated = true;
2228
						}
2254
						}
2229
						this.patternLocator.matchReportReference(node, enclosingElement, localElement, otherElements, elementBinding, level.intValue(), this);
2255
						this.patternLocator.matchReportReference(node, enclosingElement, localAnnotation, otherAnnotations, elementBinding, level.intValue(), this);
2230
					}
2256
					}
2231
				}
2257
				}
2232
			}
2258
			}
(-)search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java (-2 / +18 lines)
Lines 155-161 Link Here
155
	            	System.arraycopy(this.otherElements, 0, this.otherElements = new IJavaElement[length+10], 0, length);
155
	            	System.arraycopy(this.otherElements, 0, this.otherElements = new IJavaElement[length+10], 0, length);
156
	            }
156
	            }
157
            }
157
            }
158
	    	this.otherElements[this.ptr] = handle;
158
    		if (this.annotation == null) {
159
		    	this.otherElements[this.ptr] = handle;
160
    		} else {
161
		    	IJavaElement annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) handle);
162
		    	if (annotHandle == null) {
163
			    	annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) this.enclosingElement);
164
		    	}
165
		    	this.otherElements[this.ptr] = annotHandle == null ? handle : annotHandle;
166
    		}
159
    	}
167
    	}
160
    } else {
168
    } else {
161
    	if (this.localElements[idx] == null) {
169
    	if (this.localElements[idx] == null) {
Lines 179-185 Link Here
179
	            	System.arraycopy(this.allOtherElements[idx], 0, this.allOtherElements[idx] = new IJavaElement[length+10], 0, length);
187
	            	System.arraycopy(this.allOtherElements[idx], 0, this.allOtherElements[idx] = new IJavaElement[length+10], 0, length);
180
        	    }
188
        	    }
181
	        }
189
	        }
182
 		   	this.allOtherElements[idx][oPtr] = handle;
190
	    	if (this.annotation == null) {
191
	 		   	this.allOtherElements[idx][oPtr] = handle;
192
    		} else {
193
		    	IJavaElement annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) handle);
194
		    	if (annotHandle == null) {
195
			    	annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) this.enclosingElement);
196
		    	}
197
	 		   	this.allOtherElements[idx][oPtr] = annotHandle == null ? handle : annotHandle;
198
    		}
183
    	}
199
    	}
184
    }
200
    }
185
}
201
}
(-)search/org/eclipse/jdt/core/search/TypeReferenceMatch.java (-4 / +1 lines)
Lines 76-85 Link Here
76
 * @since 3.2
76
 * @since 3.2
77
 */
77
 */
78
public final IJavaElement[] getOtherElements() {
78
public final IJavaElement[] getOtherElements() {
79
	if (this.localElement == null || this.localElement.getElementType() != IJavaElement.ANNOTATION) {
79
	return this.otherElements;
80
		return this.otherElements;
81
	}
82
	return null;
83
}
80
}
84
81
85
/**
82
/**

Return to bug 209778