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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-11 / +181 lines)
Lines 64-80 Link Here
64
		matches.add(searchMatch);
64
		matches.add(searchMatch);
65
	}
65
	}
66
}
66
}
67
class TypeReferencesCollector extends JavaSearchResultCollector {
67
class ReferenceCollector extends JavaSearchResultCollector {
68
	protected IJavaElement getElement(SearchMatch searchMatch) {
68
	protected IJavaElement getElement(SearchMatch searchMatch) {
69
		IJavaElement element = super.getElement(searchMatch);
69
		IJavaElement element = super.getElement(searchMatch);
70
		IJavaElement localElement = null;
70
		IJavaElement localElement = null;
71
		TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) match;
71
		ReferenceMatch refMatch = (ReferenceMatch) match;
72
		localElement = typeRefMatch.getLocalElement();
72
		localElement = refMatch.getLocalElement();
73
		if (localElement != null) {
73
		if (localElement != null) {
74
			return localElement;
74
			return localElement;
75
		}
75
		}
76
		return element;
76
		return element;
77
	}
77
	}
78
}
79
class TypeReferenceCollector extends ReferenceCollector {
78
	protected void writeLine() throws CoreException {
80
	protected void writeLine() throws CoreException {
79
		super.writeLine();
81
		super.writeLine();
80
		TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match;
82
		TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match;
Lines 5749-5755 Link Here
5749
		"}\n"
5751
		"}\n"
5750
	);
5752
	);
5751
	IType type = this.workingCopies[0].getType("Test");
5753
	IType type = this.workingCopies[0].getType("Test");
5752
	TypeReferencesCollector collector = new TypeReferencesCollector();
5754
	TypeReferenceCollector collector = new TypeReferenceCollector();
5753
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5755
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5754
	assertSearchResults(
5756
	assertSearchResults(
5755
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).TP [Test]\n" +
5757
		"src/b110336/Test.java void b110336.Test.method(Class<Test>).TP [Test]\n" +
Lines 5777-5783 Link Here
5777
		"}\n"
5779
		"}\n"
5778
	);
5780
	);
5779
	IType type = this.workingCopies[0].getType("Test");
5781
	IType type = this.workingCopies[0].getType("Test");
5780
	TypeReferencesCollector collector = new TypeReferencesCollector();
5782
	TypeReferenceCollector collector = new TypeReferenceCollector();
5781
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5783
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5782
	assertSearchResults(
5784
	assertSearchResults(
5783
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1 [Test]\n" +
5785
		"src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1 [Test]\n" +
Lines 5801-5807 Link Here
5801
		"class X {}\n"
5803
		"class X {}\n"
5802
	);
5804
	);
5803
	IType type = this.workingCopies[0].getType("X");
5805
	IType type = this.workingCopies[0].getType("X");
5804
	TypeReferencesCollector collector = new TypeReferencesCollector();
5806
	TypeReferenceCollector collector = new TypeReferenceCollector();
5805
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5807
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5806
	assertSearchResults(
5808
	assertSearchResults(
5807
		"src/b110336/Test.java b110336.Test.TP [X]\n" +
5809
		"src/b110336/Test.java b110336.Test.TP [X]\n" +
Lines 5820-5826 Link Here
5820
		"}\n"
5822
		"}\n"
5821
	);
5823
	);
5822
	IType type = this.workingCopies[0].getType("Test");
5824
	IType type = this.workingCopies[0].getType("Test");
5823
	TypeReferencesCollector collector = new TypeReferencesCollector();
5825
	TypeReferenceCollector collector = new TypeReferenceCollector();
5824
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5826
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5825
	assertSearchResults(
5827
	assertSearchResults(
5826
		"src/b110336/Test.java b110336.Test.a1Test [Test]+[b1Test,c1Test]\n" +
5828
		"src/b110336/Test.java b110336.Test.a1Test [Test]+[b1Test,c1Test]\n" +
Lines 5845-5851 Link Here
5845
		"}\n"
5847
		"}\n"
5846
	);
5848
	);
5847
	IType type = this.workingCopies[0].getType("Test");
5849
	IType type = this.workingCopies[0].getType("Test");
5848
	TypeReferencesCollector collector = new TypeReferencesCollector();
5850
	TypeReferenceCollector collector = new TypeReferenceCollector();
5849
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5851
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5850
	assertSearchResults(
5852
	assertSearchResults(
5851
		"src/b110336/Test.java void b110336.Test.foo().lv1 [Test]+[lv2,lv3]\n" +
5853
		"src/b110336/Test.java void b110336.Test.foo().lv1 [Test]+[lv2,lv3]\n" +
Lines 5875-5881 Link Here
5875
		"}\n"
5877
		"}\n"
5876
	);
5878
	);
5877
	IType type = this.workingCopies[0].getType("Test");
5879
	IType type = this.workingCopies[0].getType("Test");
5878
	TypeReferencesCollector collector = new TypeReferencesCollector();
5880
	TypeReferenceCollector collector = new TypeReferenceCollector();
5879
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5881
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5880
	assertSearchResults(
5882
	assertSearchResults(
5881
		"src/b110336/Test.java void b110336.Test.foo(Test).test1 [Test]\n" +
5883
		"src/b110336/Test.java void b110336.Test.foo(Test).test1 [Test]\n" +
Lines 5899-5905 Link Here
5899
		"}\n"
5901
		"}\n"
5900
	);
5902
	);
5901
	IType type = this.workingCopies[0].getType("Test");
5903
	IType type = this.workingCopies[0].getType("Test");
5902
	TypeReferencesCollector collector = new TypeReferencesCollector();
5904
	TypeReferenceCollector collector = new TypeReferenceCollector();
5903
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5905
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5904
	assertSearchResults(
5906
	assertSearchResults(
5905
		"src/b110336/Test.java b110336.Test.{}.lv1 [Test]+[lv2,lv3]\n" +
5907
		"src/b110336/Test.java b110336.Test.{}.lv1 [Test]+[lv2,lv3]\n" +
Lines 5924-5930 Link Here
5924
		"}\n"
5926
		"}\n"
5925
	);
5927
	);
5926
	IType type = this.workingCopies[0].getType("Test");
5928
	IType type = this.workingCopies[0].getType("Test");
5927
	TypeReferencesCollector collector = new TypeReferencesCollector();
5929
	TypeReferenceCollector collector = new TypeReferenceCollector();
5928
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5930
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
5929
	assertSearchResults(
5931
	assertSearchResults(
5930
		"src/b110336/Test.java b110336.Test.static {}.lv1 [Test]+[lv2,lv3]\n" +
5932
		"src/b110336/Test.java b110336.Test.static {}.lv1 [Test]+[lv2,lv3]\n" +
Lines 9210-9215 Link Here
9210
}
9212
}
9211
9213
9212
/**
9214
/**
9215
 * @bug 209778: [search] TypeReferenceMatch#getOtherElements() fails for match in annotation
9216
 * @test Ensure that the local element is no longer a local variable
9217
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209778"
9218
 */
9219
public void testBug209778() throws CoreException {
9220
	workingCopies = new ICompilationUnit[1];
9221
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/xy/Try.java",
9222
		"package xy;\n" + 
9223
		"\n" + 
9224
		"public class Try {\n" + 
9225
		"        void tryB(int tryKind) {\n" + 
9226
		"                @Constants(Try.class) int tryCopy, tryCopy2= tryKind;\n" + 
9227
		"        }\n" + 
9228
		"        @Constants(value= Try.class) Object fTryA, fTryB;\n" + 
9229
		"}\n" + 
9230
		"\n" + 
9231
		"@interface Constants {\n" + 
9232
		"        Class<?> value();\n" + 
9233
		"}"
9234
	);
9235
	IType type = workingCopies[0].getType("Try");
9236
	TypeReferenceCollector collector = new TypeReferenceCollector();
9237
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9238
	assertSearchResults(
9239
		"src/xy/Try.java @Constants(value=Try.class) [Try]+[fTryB]\n" + 
9240
		"src/xy/Try.java @Constants(value=Try.class) [Try]+[tryCopy2]",
9241
		collector
9242
	);
9243
}
9244
9245
/**
9246
 * @bug 209996: [search] Add a way to access the most local enclosing annotation for reference search matches
9247
 * @test Verify the behavior of the new Search API {@link ReferenceMatch#getLocalElement()}
9248
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209996"
9249
 */
9250
public void testBug209996a() throws CoreException {
9251
	workingCopies = new ICompilationUnit[1];
9252
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java",
9253
		"package test;\n" +
9254
		"public class Test {\n" +
9255
		"    void method() {\n" +
9256
		"        @Annot(clazz=Test.class) int x;\n" +
9257
		"    }\n" +
9258
		"}\n" + 
9259
		"@interface Annot {\n" + 
9260
		"    Class clazz();\n" + 
9261
		"}\n"
9262
	);
9263
	IType type = workingCopies[0].getType("Test");
9264
	ReferenceCollector collector = new ReferenceCollector();
9265
	collector.showSelection = true;
9266
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9267
	assertSearchResults(
9268
		"src/test/Test.java @Annot(clazz=Test.class) [        @Annot(clazz=§|Test|§.class) int x;]",
9269
		collector
9270
	);
9271
}
9272
public void testBug209996b() throws CoreException {
9273
	workingCopies = new ICompilationUnit[1];
9274
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java",
9275
		"package test;\n" +
9276
		"public class Test {\n" +
9277
	"        @Deprecated foo() {}\n" +
9278
		"}\n"
9279
	);
9280
	ReferenceCollector collector = new ReferenceCollector();
9281
	collector.showSelection = true;
9282
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9283
	assertSearchResults(
9284
		"src/test/Test.java @Deprecated() [        @§|Deprecated|§ foo() {}]",
9285
		collector
9286
	);
9287
}
9288
public void testBug209996_c5() throws CoreException {
9289
	workingCopies = new ICompilationUnit[1];
9290
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment5/Ref.java",
9291
		"package comment5;\n" + 
9292
		"public class Ref {\n" + 
9293
		"    void doA(Ref ref) {}\n" + 
9294
		"    void doB(List<Ref> ref) {}\n" + 
9295
		"    void doC(@Tag(Ref.class) Ref ref) {}\n" + 
9296
		"    void dontD(@Tag(Ref.class) Object ref) {}\n" + 
9297
		"}\n" + 
9298
		"\n" + 
9299
		"@interface Tag {\n" + 
9300
		"    Class value();\n" + 
9301
		"}\n" + 
9302
		"class List<T> {\n" + 
9303
		"}\n"
9304
	);
9305
	IType type = workingCopies[0].getType("Ref");
9306
	ReferenceCollector collector = new ReferenceCollector();
9307
	collector.showSelection = true;
9308
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9309
	assertSearchResults(
9310
		"src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [    void doA(§|Ref|§ ref) {}]\n" + 
9311
		"src/comment5/Ref.java void comment5.Ref.doB(List<Ref>).ref [    void doB(List<§|Ref|§> ref) {}]\n" + 
9312
		"src/comment5/Ref.java @Tag(value=Ref.class) [    void doC(@Tag(§|Ref|§.class) Ref ref) {}]\n" + 
9313
		"src/comment5/Ref.java void comment5.Ref.doC(Ref).ref [    void doC(@Tag(Ref.class) §|Ref|§ ref) {}]\n" + 
9314
		"src/comment5/Ref.java @Tag(value=Ref.class) [    void dontD(@Tag(§|Ref|§.class) Object ref) {}]",
9315
		collector
9316
	);
9317
}
9318
public void testBug209996_c10() throws CoreException {
9319
	workingCopies = new ICompilationUnit[1];
9320
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment10/Ref.java",
9321
		"package comment10;\n" +
9322
		"@Num(number= Num.CONST)\n" + 
9323
		"@interface Num {\n" + 
9324
		"    public static final int CONST= 42;\n" + 
9325
		"    int number();\n" + 
9326
		"}\n"
9327
	);
9328
	IField field = workingCopies[0].getType("Num").getField("CONST");
9329
	ReferenceCollector collector = new ReferenceCollector();
9330
	collector.showSelection = true;
9331
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9332
	assertSearchResults(
9333
		"src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.§|CONST|§)]",
9334
		collector
9335
	);
9336
}
9337
public void testBug209996_c22_3() throws CoreException {
9338
	workingCopies = new ICompilationUnit[1];
9339
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment22/Test.java",
9340
		"package comment22;\n" +
9341
		"public class Test {\n" + 
9342
		"    @Tag Test test1, test2, test3;\n" + 
9343
		"    void method() {\n" + 
9344
		"        @Tag Test local= null;\n" + 
9345
		"        @Tag Test local1, local2, local3;\n" + 
9346
		"    }\n" + 
9347
		"}\n" + 
9348
		"@interface Tag {}\n"
9349
	);
9350
	IType type = workingCopies[0].getType("Tag");
9351
	TypeReferenceCollector collector = new TypeReferenceCollector();
9352
	collector.showSelection = true;
9353
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9354
	assertSearchResults(
9355
		"src/comment22/Test.java @Tag() [    @§|Tag|§ Test test1, test2, test3;]+[test2,test3]\n" + 
9356
		"src/comment22/Test.java @Tag() [        @§|Tag|§ Test local= null;]\n" + 
9357
		"src/comment22/Test.java @Tag() [        @§|Tag|§ Test local1, local2, local3;]+[local2,local3]",
9358
		collector
9359
	);
9360
}
9361
public void testBug209996_c22_4() throws CoreException {
9362
	workingCopies = new ICompilationUnit[1];
9363
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java",
9364
		"package test;\n" +
9365
		"public class TestMethodReference {\n" + 
9366
		"    @Annot(clazz = test.Test.class) int x, y;\n" + 
9367
		"}\n" + 
9368
		"@interface Annot {\n" + 
9369
		"    Class clazz();\n" + 
9370
		"}\n"
9371
	);
9372
	IType type = workingCopies[0].getType("Test");
9373
	TypeReferenceCollector collector = new TypeReferenceCollector();
9374
	collector.showSelection = true;
9375
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9376
	assertSearchResults(
9377
		"src/test/Test.java @Annot(clazz=test.Test.class) [    @Annot(clazz = §|test.Test|§.class) int x, y;]+[y]",
9378
		collector
9379
	);
9380
}
9381
9382
/**
9213
 * @bug 210689: [search] Type references are not found in import declarations when JUnit tests only use working copies
9383
 * @bug 210689: [search] Type references are not found in import declarations when JUnit tests only use working copies
9214
 * @test Ensure that import references are found when searching on working copies not written on disk
9384
 * @test Ensure that import references are found when searching on working copies not written on disk
9215
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210689"
9385
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210689"
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java (-8 / +8 lines)
Lines 1005-1019 Link Here
1005
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1005
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1006
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1006
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1007
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1007
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1008
		"src/test02/Test.java test02.Test.field [	§|Test|§<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@47] EXACT_MATCH\n" + 
1009
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1010
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends §|B|§, ? super C> field = new Test<A, Z<String>, X<String>> () {@65] EXACT_MATCH\n" + 
1011
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super §|C|§> field = new Test<A, Z<String>, X<String>> () {@76] EXACT_MATCH\n" + 
1012
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1008
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1013
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1009
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1014
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1010
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1015
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1011
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1016
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1012
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1013
		"src/test02/Test.java test02.Test.field [	§|Test|§<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@47] EXACT_MATCH\n" + 
1014
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1015
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends §|B|§, ? super C> field = new Test<A, Z<String>, X<String>> () {@65] EXACT_MATCH\n" + 
1016
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super §|C|§> field = new Test<A, Z<String>, X<String>> () {@76] EXACT_MATCH\n" + 
1017
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	§|Test|§<? super A, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@290] EXACT_MATCH\n" + 
1017
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	§|Test|§<? super A, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@290] EXACT_MATCH\n" + 
1018
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super §|A|§, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@303] EXACT_MATCH\n" + 
1018
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super §|A|§, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@303] EXACT_MATCH\n" + 
1019
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
1019
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
Lines 1054-1067 Link Here
1054
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1054
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1055
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1055
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1056
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1056
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1057
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1058
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends §|B|§, ? super C> field = new Test<A, Z<String>, X<String>> () {@65] EXACT_MATCH\n" + 
1059
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super §|C|§> field = new Test<A, Z<String>, X<String>> () {@76] EXACT_MATCH\n" + 
1060
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1057
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1061
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1058
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1062
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1059
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1063
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1060
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1064
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1061
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1062
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1063
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends §|B|§, ? super C> field = new Test<A, Z<String>, X<String>> () {@65] EXACT_MATCH\n" + 
1064
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super §|C|§> field = new Test<A, Z<String>, X<String>> () {@76] EXACT_MATCH\n" + 
1065
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super §|A|§, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@303] EXACT_MATCH\n" + 
1065
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super §|A|§, B, ? extends C> foo(Test<? extends A, ? super B, C> param) {@303] EXACT_MATCH\n" + 
1066
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
1066
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
1067
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, B, ? extends §|C|§> foo(Test<? extends A, ? super B, C> param) {@319] EXACT_MATCH\n" + 
1067
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, B, ? extends §|C|§> foo(Test<? extends A, ? super B, C> param) {@319] EXACT_MATCH\n" + 
Lines 1097-1108 Link Here
1097
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1097
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<§|String|§>>, Z<String>>();@257] EXACT_MATCH\n" + 
1098
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1098
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, §|Z|§<String>>();@267] EXACT_MATCH\n" + 
1099
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1099
		"src/test02/Test.java Test<X<Y<Z<String>>>,Y<Z<String>>,Z<String>> test02.Test.field:<anonymous>#1.bar() [			return new Test<X<Y<Z<String>>>, Y<Z<String>>, Z<§|String|§>>();@269] EXACT_MATCH\n" + 
1100
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1101
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1100
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<§|A|§, Z<String>, X<String>> () {@96] EXACT_MATCH\n" + 
1102
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1101
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, §|Z|§<String>, X<String>> () {@99] EXACT_MATCH\n" + 
1103
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1102
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<§|String|§>, X<String>> () {@101] EXACT_MATCH\n" + 
1104
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1103
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, §|X|§<String>> () {@110] EXACT_MATCH\n" + 
1105
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1104
		"src/test02/Test.java test02.Test.field [	Test<A, ? extends B, ? super C> field = new Test<A, Z<String>, X<§|String|§>> () {@112] EXACT_MATCH\n" + 
1105
		"src/test02/Test.java test02.Test.field [	Test<§|A|§, ? extends B, ? super C> field = new Test<A, Z<String>, X<String>> () {@52] EXACT_MATCH\n" + 
1106
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
1106
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, §|B|§, ? extends C> foo(Test<? extends A, ? super B, C> param) {@306] EXACT_MATCH\n" + 
1107
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, B, ? extends C> foo(Test<? extends A, ? super B, §|C|§> param) {@355] EXACT_MATCH\n" + 
1107
		"src/test02/Test.java Test<? super A,B,? extends C> test02.Test.foo(Test<? extends A,? super B,C>) [	Test<? super A, B, ? extends C> foo(Test<? extends A, ? super B, §|C|§> param) {@355] EXACT_MATCH\n" + 
1108
		"src/test02/Test.java test02.C [class C extends X<§|String|§> {}@428] EXACT_MATCH"
1108
		"src/test02/Test.java test02.C [class C extends X<§|String|§> {}@428] EXACT_MATCH"
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (+26 lines)
Lines 162-167 Link Here
162
				} else if (element instanceof IPackageDeclaration) {
162
				} else if (element instanceof IPackageDeclaration) {
163
					IPackageDeclaration packageDeclaration = (IPackageDeclaration)element;
163
					IPackageDeclaration packageDeclaration = (IPackageDeclaration)element;
164
					unit = (ICompilationUnit)packageDeclaration.getAncestor(IJavaElement.COMPILATION_UNIT);
164
					unit = (ICompilationUnit)packageDeclaration.getAncestor(IJavaElement.COMPILATION_UNIT);
165
				} else if (element instanceof IAnnotation) {
166
					line.append(" ");
167
					append((IAnnotation)element);
168
					unit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
165
				}
169
				}
166
				if (resource instanceof IFile) {
170
				if (resource instanceof IFile) {
167
					char[] contents = getSource(resource, element, unit);
171
					char[] contents = getSource(resource, element, unit);
Lines 273-278 Link Here
273
		private boolean showSuperInvocation() {
277
		private boolean showSuperInvocation() {
274
			return (this.showFlavors & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0;
278
			return (this.showFlavors & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0;
275
		}
279
		}
280
		protected void append(IAnnotation annotation) throws JavaModelException {
281
			line.append("@");
282
			line.append(annotation.getElementName());
283
			line.append('(');
284
			IMemberValuePair[] pairs = annotation.getMemberValuePairs();
285
			int length = pairs == null ? 0 : pairs.length;
286
			for (int i=0; i<length; i++) {
287
				line.append(pairs[i].getMemberName());
288
				line.append('=');
289
				Object value = pairs[i].getValue();
290
				switch (pairs[i].getValueKind()) {
291
					case IMemberValuePair.K_CLASS:
292
						line.append(value);
293
						line.append(".class");
294
						break;
295
					default:
296
						line.append(value);
297
					break;
298
				}
299
			}
300
			line.append(')');
301
		}
276
		protected void append(IField field) throws JavaModelException {
302
		protected void append(IField field) throws JavaModelException {
277
			append(field.getDeclaringType());
303
			append(field.getDeclaringType());
278
			line.append(".");
304
			line.append(".");
(-)search/org/eclipse/jdt/core/search/PackageReferenceMatch.java (-17 / +17 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.IJavaElement;
14
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.internal.core.search.matching.InternalReferenceMatch;
15
16
16
/**
17
/**
17
 * A Java search match that represents a package reference.
18
 * A Java search match that represents a package reference.
Lines 22-43 Link Here
22
 * 
23
 * 
23
 * @since 3.0
24
 * @since 3.0
24
 */
25
 */
25
public class PackageReferenceMatch extends SearchMatch {
26
public class PackageReferenceMatch extends InternalReferenceMatch {
26
27
27
	/**
28
/**
28
	 * Creates a new package reference match.
29
 * Creates a new package reference match.
29
	 * 
30
 * 
30
	 * @param enclosingElement the inner-most enclosing member that references this package
31
 * @param enclosingElement the inner-most enclosing member that references this package
31
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
32
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
32
	 * @param offset the offset the match starts at, or -1 if unknown
33
 * @param offset the offset the match starts at, or -1 if unknown
33
	 * @param length the length of the match, or -1 if unknown
34
 * @param length the length of the match, or -1 if unknown
34
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
35
 * @param insideDocComment <code>true</code> if this search match is inside a doc
35
	 * comment, and <code>false</code> otherwise
36
 * 		comment, and <code>false</code> otherwise
36
	 * @param participant the search participant that created the match
37
 * @param participant the search participant that created the match
37
	 * @param resource the resource of the element
38
 * @param resource the resource of the element
38
	 */
39
 */
39
	public PackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
40
public PackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
40
		super(enclosingElement, accuracy, offset, length, participant, resource);
41
	super(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
41
		setInsideDocComment(insideDocComment);
42
}
42
	}
43
}
43
}
(-)search/org/eclipse/jdt/core/search/FieldReferenceMatch.java (-44 / +45 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.IJavaElement;
14
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.internal.core.search.matching.InternalReferenceMatch;
15
16
16
/**
17
/**
17
 * A Java search match that represents a field reference.
18
 * A Java search match that represents a field reference.
Lines 22-71 Link Here
22
 * 
23
 * 
23
 * @since 3.0
24
 * @since 3.0
24
 */
25
 */
25
public class FieldReferenceMatch extends SearchMatch {
26
public class FieldReferenceMatch extends InternalReferenceMatch {
26
27
27
	private boolean isReadAccess;
28
private boolean isReadAccess;
28
	private boolean isWriteAccess;
29
private boolean isWriteAccess;
30
31
/**
32
 * Creates a new field reference match.
33
 * 
34
 * @param enclosingElement the inner-most enclosing member that references
35
 * 		this field
36
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
37
 * @param offset the offset the match starts at, or -1 if unknown
38
 * @param length the length of the match, or -1 if unknown
39
 * @param isReadAccess whether the match represents a read access
40
 * @param isWriteAccess whether the match represents a write access
41
 * @param insideDocComment <code>true</code> if this search match is inside a
42
 *            doc comment, and <code>false</code> otherwise
43
 * @param participant the search participant that created the match
44
 * @param resource the resource of the element
45
 */
46
public FieldReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean isReadAccess, boolean isWriteAccess, boolean insideDocComment, SearchParticipant participant, IResource resource) {
47
	super(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
48
	this.isReadAccess = isReadAccess;
49
	this.isWriteAccess = isWriteAccess;
50
}
51
52
/**
53
 * Returns whether the field reference is a read access to the field.
54
 * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
55
 * 
56
 * @return whether the field reference is a read access to the field.
57
 */
58
public final boolean isReadAccess() {
59
	return this.isReadAccess;
60
}
61
62
/**
63
 * Returns whether the field reference is a write access to the field.
64
 * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
65
 * 
66
 * @return whether the field reference is a write access to the field.
67
 */
68
public final boolean isWriteAccess() {
69
	return this.isWriteAccess;
70
}
29
71
30
	/**
31
	 * Creates a new field reference match.
32
	 * 
33
	 * @param enclosingElement the inner-most enclosing member that references this field
34
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
35
	 * @param offset the offset the match starts at, or -1 if unknown
36
	 * @param length the length of the match, or -1 if unknown
37
	 * @param isReadAccess whether the match represents a read access
38
	 * @param isWriteAccess whether the match represents a write access
39
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
40
	 * comment, and <code>false</code> otherwise
41
	 * @param participant the search participant that created the match
42
	 * @param resource the resource of the element
43
	 */
44
	public FieldReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean isReadAccess, boolean isWriteAccess, boolean insideDocComment, SearchParticipant participant, IResource resource) {
45
		super(enclosingElement, accuracy, offset, length, participant, resource);
46
		this.isReadAccess = isReadAccess;
47
		this.isWriteAccess = isWriteAccess;
48
		setInsideDocComment(insideDocComment);
49
	}
50
	
51
	/**
52
	 * Returns whether the field reference is a read access to the field.
53
	 * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
54
	 * 
55
	 * @return whether the field reference is a read access to the field.
56
	 */
57
	public final boolean isReadAccess() {
58
		return this.isReadAccess;
59
	}
60
61
	/**
62
	 * Returns whether the field reference is a write access to the field.
63
	 * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
64
	 * 
65
	 * @return whether the field reference is a write access to the field.
66
	 */
67
	public final boolean isWriteAccess() {
68
		return this.isWriteAccess;
69
	}
70
	
71
}
72
}
(-)search/org/eclipse/jdt/core/search/MethodReferenceMatch.java (-100 / +100 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.IJavaElement;
14
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.internal.core.search.matching.InternalReferenceMatch;
15
16
16
/**
17
/**
17
 * A Java search match that represents a method reference.
18
 * A Java search match that represents a method reference.
Lines 22-129 Link Here
22
 * 
23
 * 
23
 * @since 3.0
24
 * @since 3.0
24
 */
25
 */
25
public class MethodReferenceMatch extends SearchMatch {
26
public class MethodReferenceMatch extends InternalReferenceMatch {
26
	private boolean constructor;
27
	private boolean constructor;
27
	private boolean synthetic;
28
	private boolean synthetic;
28
	private boolean superInvocation;
29
	private boolean superInvocation;
29
30
30
	/**
31
/**
31
	 * Creates a new method reference match.
32
 * Creates a new method reference match.
32
	 * 
33
 * 
33
	 * @param enclosingElement the inner-most enclosing member that references this method
34
 * @param enclosingElement the inner-most enclosing member that references this method
34
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
35
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
35
	 * @param offset the offset the match starts at, or -1 if unknown
36
 * @param offset the offset the match starts at, or -1 if unknown
36
	 * @param length the length of the match, or -1 if unknown
37
 * @param length the length of the match, or -1 if unknown
37
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
38
 * @param insideDocComment <code>true</code> if this search match is inside a doc
38
	 * comment, and <code>false</code> otherwise
39
 * 		comment, and <code>false</code> otherwise
39
	 * @param participant the search participant that created the match
40
 * @param participant the search participant that created the match
40
	 * @param resource the resource of the element
41
 * @param resource the resource of the element
41
	 */
42
 */
42
	public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
43
public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
43
		super(enclosingElement, accuracy, offset, length, participant, resource);
44
	super(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
44
		setInsideDocComment(insideDocComment);
45
}
45
	}
46
46
47
/**
47
	/**
48
 * Creates a new method reference match.
48
	 * Creates a new method reference match.
49
 * 
49
	 * 
50
 * @param enclosingElement the inner-most enclosing member that references this method
50
	 * @param enclosingElement the inner-most enclosing member that references this method
51
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
51
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
52
 * @param offset the offset the match starts at, or -1 if unknown
52
	 * @param offset the offset the match starts at, or -1 if unknown
53
 * @param length the length of the match, or -1 if unknown
53
	 * @param length the length of the match, or -1 if unknown
54
 * @param constructor <code>true</code> if this search match a constructor
54
	 * @param constructor <code>true</code> if this search match a constructor
55
 * 		<code>false</code> otherwise
55
	 * <code>false</code> otherwise
56
 * @param synthetic <code>true</code> if this search match a synthetic element
56
	 * @param synthetic <code>true</code> if this search match a synthetic element
57
 * 		<code>false</code> otherwise
57
	 * <code>false</code> otherwise
58
 * @param insideDocComment <code>true</code> if this search match is inside a doc
58
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
59
 * comment, and <code>false</code> otherwise
59
	 * comment, and <code>false</code> otherwise
60
 * @param participant the search participant that created the match
60
	 * @param participant the search participant that created the match
61
 * @param resource the resource of the element
61
	 * @param resource the resource of the element
62
 * @since 3.1
62
	 * @since 3.1
63
 */
63
	 */
64
public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean insideDocComment, SearchParticipant participant, IResource resource) {
64
	public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean insideDocComment, SearchParticipant participant, IResource resource) {
65
	this(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
65
		this(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
66
	this.constructor = constructor;
66
		this.constructor = constructor;
67
	this.synthetic = synthetic;
67
		this.synthetic = synthetic;
68
}
68
	}
69
69
70
/**
70
	/**
71
 * Creates a new method reference match.
71
	 * Creates a new method reference match.
72
 * 
72
	 * 
73
 * @param enclosingElement the inner-most enclosing member that references this method
73
	 * @param enclosingElement the inner-most enclosing member that references this method
74
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
74
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
75
 * @param offset the offset the match starts at, or -1 if unknown
75
	 * @param offset the offset the match starts at, or -1 if unknown
76
 * @param length the length of the match, or -1 if unknown
76
	 * @param length the length of the match, or -1 if unknown
77
 * @param constructor <code>true</code> if this search matches a constructor
77
	 * @param constructor <code>true</code> if this search matches a constructor
78
 * 		<code>false</code> otherwise
78
	 * <code>false</code> otherwise
79
 * @param synthetic <code>true</code> if this search matches a synthetic element
79
	 * @param synthetic <code>true</code> if this search matches a synthetic element
80
 * 		<code>false</code> otherwise
80
	 * <code>false</code> otherwise
81
 * @param superInvocation <code>true</code> if this search matches a super-type invocation
81
	 * @param superInvocation <code>true</code> if this search matches a super-type invocation
82
 * 		element <code>false</code> otherwise
82
	 * element <code>false</code> otherwise
83
 * @param insideDocComment <code>true</code> if this search match is inside a doc
83
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
84
 * 		comment, and <code>false</code> otherwise
84
	 * comment, and <code>false</code> otherwise
85
 * @param participant the search participant that created the match
85
	 * @param participant the search participant that created the match
86
 * @param resource the resource of the element
86
	 * @param resource the resource of the element
87
 * @since 3.3
87
	 * @since 3.3
88
 */
88
	 */
89
public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean superInvocation, boolean insideDocComment, SearchParticipant participant, IResource resource) {
89
	public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean superInvocation, boolean insideDocComment, SearchParticipant participant, IResource resource) {
90
	this(enclosingElement, accuracy, offset, length, constructor, synthetic, insideDocComment, participant, resource);
90
		this(enclosingElement, accuracy, offset, length, constructor, synthetic, insideDocComment, participant, resource);
91
	this.superInvocation = superInvocation;
91
		this.superInvocation = superInvocation;
92
}
92
	}
93
93
94
/**
94
	/**
95
 * Returns whether the reference is on a constructor.
95
	 * Returns whether the reference is on a constructor.
96
 *
96
	 *
97
 * @return Returns whether the reference is on a constructor or not.
97
	 * @return Returns whether the reference is on a constructor or not.
98
 * @since 3.1
98
	 * @since 3.1
99
 */
99
	 */
100
public final boolean isConstructor() {
100
	public final boolean isConstructor() {
101
	return this.constructor;
101
		return this.constructor;
102
}
102
	}
103
103
	
104
/**
104
	/**
105
 * Returns whether the reference is on a synthetic element.
105
	 * Returns whether the reference is on a synthetic element.
106
 * Note that this field is only used for constructor reference. This happens when default constructor
106
	 * Note that this field is only used for constructor reference. This happens when default constructor
107
 * declaration is used or implicit super constructor is called.
107
	 * declaration is used or implicit super constructor is called.
108
 * 
108
	 * 
109
 * @return whether the reference is synthetic or not.
109
	 * @return whether the reference is synthetic or not.
110
 * @since 3.1
110
	 * @since 3.1
111
 */
111
	 */
112
public final boolean isSynthetic() {
112
	public final boolean isSynthetic() {
113
	return this.synthetic;
113
		return this.synthetic;
114
}
114
	}
115
115
116
/**
116
	/**
117
 * Returns whether the reference is on a message sent from a type
117
	 * Returns whether the reference is on a message sent from a type
118
 * which is a super type of the searched method declaring type.
118
	 * which is a super type of the searched method declaring type.
119
 * If <code>true</code>, the method called at run-time may or may not be
119
	 * If <code>true</code>, the method called at run-time may or may not be
120
 * the search target, depending on the run-time type of the receiver object.
120
	 * the search target, depending on the run-time type of the receiver object.
121
 * 
121
	 * 
122
 * @return <code>true</code> if the reference is on a message sent from
122
	 * @return <code>true</code> if the reference is on a message sent from
123
 * a super-type of the searched method declaring class, <code>false </code> otherwise
123
	 * a super-type of the searched method declaring class, <code>false </code> otherwise
124
 * @since 3.3
124
	 * @since 3.3
125
 */
125
	 */
126
public boolean isSuperInvocation() {
126
	public boolean isSuperInvocation() {
127
	return this.superInvocation;
127
		return this.superInvocation;
128
}
128
	}
129
}
129
}
(-)search/org/eclipse/jdt/core/search/TypeReferenceMatch.java (-67 / +80 lines)
Lines 11-17 Link Here
11
package org.eclipse.jdt.core.search;
11
package org.eclipse.jdt.core.search;
12
12
13
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.IJavaElement;
14
import org.eclipse.jdt.core.*;
15
import org.eclipse.jdt.internal.core.search.matching.InternalReferenceMatch;
15
16
16
/**
17
/**
17
 * A Java search match that represents a type reference.
18
 * A Java search match that represents a type reference.
Lines 22-96 Link Here
22
 * 
23
 * 
23
 * @since 3.0
24
 * @since 3.0
24
 */
25
 */
25
public class TypeReferenceMatch extends SearchMatch {
26
public class TypeReferenceMatch extends InternalReferenceMatch {
26
27
27
	private IJavaElement localElement;
28
	private IJavaElement[] otherElements;
28
	private IJavaElement[] otherElements;
29
29
30
	/**
30
/**
31
	 * Creates a new type reference match.
31
 * Creates a new type reference match.
32
	 * 
32
 * 
33
	 * @param enclosingElement the inner-most enclosing member that references this type
33
 * @param enclosingElement the inner-most enclosing member that references this type
34
	 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
34
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
35
	 * @param offset the offset the match starts at, or -1 if unknown
35
 * @param offset the offset the match starts at, or -1 if unknown
36
	 * @param length the length of the match, or -1 if unknown
36
 * @param length the length of the match, or -1 if unknown
37
	 * @param insideDocComment <code>true</code> if this search match is inside a doc
37
 * @param insideDocComment <code>true</code> if this search match is inside a doc
38
	 * comment, and <code>false</code> otherwise
38
 * 				comment, and <code>false</code> otherwise
39
	 * @param participant the search participant that created the match
39
 * @param participant the search participant that created the match
40
	 * @param resource the resource of the element
40
 * @param resource the resource of the element
41
	 */
41
 */
42
	public TypeReferenceMatch(IJavaElement enclosingElement, int accuracy,	int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
42
public TypeReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
43
		super(enclosingElement, accuracy, offset, length, participant, resource);
43
	super(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
44
		setInsideDocComment(insideDocComment);
44
}
45
	}
45
46
46
/**
47
	/**
47
 * Returns other elements also enclosing the type reference. This typically can
48
	 * Returns the local element of this search match.
48
 * happen for multiple fields or local variable declarations.
49
	 * This may be a local variable which declaring type is the referenced one
49
 *<p>
50
	 * or a type parameter which extends it.
50
 * For example,
51
	 * 
51
 * <ul>
52
	 * @return the element of the search match, or <code>null</code> if none or there's
52
 * 	<li>searching for the references to the type <code>Test</code> in
53
	 * 	no more specific local element than the element itself ({@link SearchMatch#getElement()}).
53
 *         <pre>
54
	 * @since 3.2
54
 *         public class Test {
55
	 */
55
 *             Test test1, test2, test3;
56
	public final IJavaElement getLocalElement() {
56
 *             void method() {}
57
		return this.localElement;
57
 *         }
58
	}
58
 *         </pre>
59
59
 * 		will return one match whose other elements is an array of two fields: 
60
	/**
60
 * 		{@link IField test2} and {@link IField test3}.
61
	 * Returns other enclosing elements of this search match.
61
 * 	</li>
62
	 *
62
 * 	<li>searching for the references to the type <code>Test</code> in
63
	 * If {@link #getLocalElement()} is not <code>null</code>, these may be other
63
 * 		<pre>
64
	 * local elements such as additional local variables of a multiple local
64
 *         public class Test {
65
	 * variables declaration. Otherwise, these may be other elements such as
65
 *             String str;
66
	 * additional fields of a multiple fields declaration.
66
 *             void method() {
67
	 * 
67
 *                 Test local1, local2, local3;
68
	 * @return the other elements of the search match, or <code>null</code> if none
68
 *             }
69
	 * @since 3.2
69
 *         }
70
	 */
70
 *         </pre>
71
	public final IJavaElement[] getOtherElements() {
71
 * 		will return one match whose other elements is an array of two local 
72
 * 		variables: {@link ILocalVariable local2} and {@link ILocalVariable local3}.
73
 * 	</li>
74
 * </ul>
75
 * 
76
 * @return the other elements of the search match, or <code>null</code> if none
77
 */
78
public final IJavaElement[] getOtherElements() {
79
//	IJavaElement localElement = localElement();
80
//	if (localElement == null || localElement.getElementType() != IJavaElement.ANNOTATION) {
72
		return this.otherElements;
81
		return this.otherElements;
73
	}
82
//	}
83
//	return null;
84
}
74
85
75
	/**
86
/**
76
	 * Sets the local element of this search match.
87
 * Sets the local element of this search match.
77
	 * 
88
 * 
78
	 * @param localElement A more specific local element that corresponds to the match,
89
 * @param localElement A more specific local element that corresponds to the match,
79
	 * 	or <code>null</code> if none
90
 * 	or <code>null</code> if none
80
	 * @since 3.2
91
 * @since 3.2
81
	 */
92
 */
82
	public final void setLocalElement(IJavaElement localElement) {
93
public final void setLocalElement(IJavaElement localElement) {
83
		this.localElement = localElement;
94
	localElement(localElement);
84
	}
95
}
85
96
86
	/**
97
/**
87
	 * Sets the other elements of this search match.
98
 * Sets the other elements of this search match.
88
	 * 
99
 * 
89
	 * @param otherElements the other elements of the match,
100
 * @see #getOtherElements()
90
	 * 	or <code>null</code> if none
101
 * 
91
	 * @since 3.2
102
 * @param otherElements the other elements of the match,
92
	 */
103
 * 	or <code>null</code> if none
93
	public final void setOtherElements(IJavaElement[] otherElements) {
104
 * @since 3.2
94
		this.otherElements = otherElements;
105
 */
95
	}
106
public final void setOtherElements(IJavaElement[] otherElements) {
107
	this.otherElements = otherElements;
108
}
96
}
109
}
(-)buildnotes_jdt-core.html (+84 lines)
Lines 58-63 Link Here
58
	 <code>BatchCompiler#compiler(String, PrintWriter, PrintWriter, CompilationProgress)</code> and
58
	 <code>BatchCompiler#compiler(String, PrintWriter, PrintWriter, CompilationProgress)</code> and
59
	 <code>BatchCompiler#compiler(String[], PrintWriter, PrintWriter, CompilationProgress)</code>.
59
	 <code>BatchCompiler#compiler(String[], PrintWriter, PrintWriter, CompilationProgress)</code>.
60
	 See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=217233">217233</a> for more details.</li>
60
	 See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=217233">217233</a> for more details.</li>
61
<li>All search reference matches may now have a local element. Clients can access
62
this local element using the <code>getLocalElement()</code> method on the new
63
<code>ReferenceMatch</code> API class:<pre>
64
 * Returns the local element of this search match, or <code>null</code> if none.
65
 * A local element is the inner most element that contains the reference and that is not
66
 * reachable by navigating from the root of the {@link IJavaModel} using 
67
 * {@link IParent#getChildren()}.
68
 *
69
 * Known element types for local elements are {@link IJavaElement#ANNOTATION}, 
70
 * {@link IJavaElement#LOCAL_VARIABLE} and {@link IJavaElement#TYPE_PARAMETER}.
71
 * However clients should not assume that this set of element types is closed as
72
 * other types of elements may be returned in the future, e.g. if new types
73
 * of elements are added in the Java model. Clients can only assume that the
74
 * {@link IJavaElement#getParent() parent} chain of this local element eventually leads 
75
 * to the element from {@link #getElement()}.
76
 *
77
 * The local element being an {@link IAnnotation} is the most usal case. For example,
78
 *
79
 *    . searching for the references to the method <code>Annot.clazz()</code> in
80
 * 
81
 *             public class Test {
82
 *                 void method() {
83
 *                     &#0064;Annot(clazz=Test.class) int x;
84
 *                 }
85
 *             }
86
 * 
87
 *      will return one {@link MethodReferenceMatch} match whose local element
88
 *      is the {@link IAnnotation} '<code>Annot</code>'.
89
 *
90
 *    . searching for the references to the type <code>Deprecated</code> in
91
 * 
92
 *             public class Test {
93
 *                &#0064;Deprecated void method() {}
94
 *             }
95
 * 
96
 *      will return one {@link TypeReferenceMatch} match whose local element
97
 *      is the {@link IAnnotation} '<code>Deprecated</code>'.
98
 *
99
 *    . searching for the references to the field <code>CONST</code> in
100
 * 
101
 *              &#0064;Num(number= Num.CONST)
102
 *              &#0064;interface Num {
103
 *                  public static final int CONST= 42;
104
 *                  int number();
105
 *              }
106
 * 
107
 *      will return one {@link FieldReferenceMatch} match whose local element
108
 *      is the {@link IAnnotation} '<code>Num</code>'.
109
 *
110
 * A local element may also be a {@link ILocalVariable} whose type is the referenced type. For example,
111
 *
112
 *    . searching for the references to the type <code>Test</code> in
113
 * 
114
 *         public class Test {
115
 *             void foo() {
116
 *                Test local;
117
 *             }
118
 *         }
119
 * 
120
 *      will return one {@link TypeReferenceMatch} match whose local element
121
 *      is the {@link ILocalVariable} '<code>local</code>'.
122
 *
123
 * Or a local element may be an {@link ITypeParameter} that extends the referenced type. For example,
124
 *
125
 *    . searching for the references to the type <code>Test</code> in 
126
 * 
127
 *         public class X< T extends Test> {
128
 *         }
129
 * 
130
 *      will return one {@link TypeReferenceMatch} match whose local element
131
 *      is the {@link ITypeParameter} '<code>T</code>'.
132
 * 
133
 * @return the local element of this search match, or <code>null</code> if none.
134
 * 
135
 * @since 3.4
136
 */
137
public IJavaElement getLocalElement() {
138
	return null;
139
}
140
</pre>
141
See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=209996">bug 209996</a>
142
for more details.
143
</li>
144
61
</ul>
145
</ul>
62
146
63
<h3>Problem Reports Fixed</h3>
147
<h3>Problem Reports Fixed</h3>
(-)search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-4 / +10 lines)
Lines 307-313 Link Here
307
/*
307
/*
308
 * Look for annotations references
308
 * Look for annotations references
309
 */
309
 */
310
void matchAnnotations(SearchPattern pattern, MatchLocator locator, ClassFile classFile, IBinaryType binaryType) throws CoreException {
310
private void matchAnnotations(SearchPattern pattern, MatchLocator locator, ClassFile classFile, IBinaryType binaryType) throws CoreException {
311
	// Only process TypeReference patterns
311
	// Only process TypeReference patterns
312
	switch (((InternalSearchPattern)pattern).kind) {
312
	switch (((InternalSearchPattern)pattern).kind) {
313
		case TYPE_REF_PATTERN:
313
		case TYPE_REF_PATTERN:
Lines 329-335 Link Here
329
	BinaryTypeBinding binaryTypeBinding = null;
329
	BinaryTypeBinding binaryTypeBinding = null;
330
	if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) {
330
	if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) {
331
		classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey());
331
		classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey());
332
		SearchMatch match = new TypeReferenceMatch(classFileBinaryType, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
332
		TypeReferenceMatch match = new TypeReferenceMatch(classFileBinaryType, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
333
		// TODO 3.4 M7 (frederic) - bug 209996: see how create the annotation handle from the binary and put it in the local element
334
		match.setLocalElement(null);
333
		locator.report(match);
335
		locator.report(match);
334
	}
336
	}
335
337
Lines 343-349 Link Here
343
					IMethod methodHandle = classFileBinaryType.getMethod(
345
					IMethod methodHandle = classFileBinaryType.getMethod(
344
						new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()),
346
						new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()),
345
						CharOperation.toStrings(Signature.getParameterTypes(convertClassFileFormat(method.getMethodDescriptor()))));
347
						CharOperation.toStrings(Signature.getParameterTypes(convertClassFileFormat(method.getMethodDescriptor()))));
346
					SearchMatch match = new TypeReferenceMatch(methodHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
348
					TypeReferenceMatch match = new TypeReferenceMatch(methodHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
349
					// TODO 3.4 M7 (frederic) - bug 209996: see how create the annotation handle from the binary and put it in the local element
350
					match.setLocalElement(null);
347
					locator.report(match);
351
					locator.report(match);
348
			}
352
			}
349
		}
353
		}
Lines 356-362 Link Here
356
			FieldInfo field = fields[i];
360
			FieldInfo field = fields[i];
357
			if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) {
361
			if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) {
358
					IField fieldHandle = classFileBinaryType.getField(new String(field.getName()));
362
					IField fieldHandle = classFileBinaryType.getField(new String(field.getName()));
359
					SearchMatch match = new TypeReferenceMatch(fieldHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
363
					TypeReferenceMatch match = new TypeReferenceMatch(fieldHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
364
					// TODO 3.4 M7 (frederic) - bug 209996: see how create the annotation handle from the binary and put it in the local element
365
					match.setLocalElement(null);
360
					locator.report(match);
366
					locator.report(match);
361
			}
367
			}
362
		}
368
		}
(-)search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java (-2 / +7 lines)
Lines 313-322 Link Here
313
	}
313
	}
314
	return false;
314
	return false;
315
}
315
}
316
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
317
	matchReportReference(reference, element, null, null, elementBinding, accuracy, locator);
318
}
316
/**
319
/**
317
 * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#matchReportReference(org.eclipse.jdt.internal.compiler.ast.ASTNode, org.eclipse.jdt.core.IJavaElement, Binding, int, org.eclipse.jdt.internal.core.search.matching.MatchLocator)
320
 * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#matchReportReference(org.eclipse.jdt.internal.compiler.ast.ASTNode, org.eclipse.jdt.core.IJavaElement, Binding, int, org.eclipse.jdt.internal.core.search.matching.MatchLocator)
318
 */
321
 */
319
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
322
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
320
	MethodBinding methodBinding = (reference instanceof MessageSend) ? ((MessageSend)reference).binding: ((elementBinding instanceof MethodBinding) ? (MethodBinding) elementBinding : null);
323
	MethodBinding methodBinding = (reference instanceof MessageSend) ? ((MessageSend)reference).binding: ((elementBinding instanceof MethodBinding) ? (MethodBinding) elementBinding : null);
321
	if (this.isDeclarationOfReferencedMethodsPattern) {
324
	if (this.isDeclarationOfReferencedMethodsPattern) {
322
		if (methodBinding == null) return;
325
		if (methodBinding == null) return;
Lines 331-337 Link Here
331
			reportDeclaration(methodBinding, locator, declPattern.knownMethods);
334
			reportDeclaration(methodBinding, locator, declPattern.knownMethods);
332
		}
335
		}
333
	} else {
336
	} else {
334
		match = locator.newMethodReferenceMatch(element, elementBinding, accuracy, -1, -1, false /*not constructor*/, false/*not synthetic*/, reference);
337
		MethodReferenceMatch methodReferenceMatch = locator.newMethodReferenceMatch(element, elementBinding, accuracy, -1, -1, false /*not constructor*/, false/*not synthetic*/, reference);
338
		methodReferenceMatch.localElement(localElement);
339
		this.match = methodReferenceMatch;
335
		if (this.pattern.findReferences && reference instanceof MessageSend) {
340
		if (this.pattern.findReferences && reference instanceof MessageSend) {
336
			IJavaElement focus = ((InternalSearchPattern) this.pattern).focus;
341
			IJavaElement focus = ((InternalSearchPattern) this.pattern).focus;
337
			// verify closest match if pattern was bound
342
			// verify closest match if pattern was bound
(-)search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java (-57 lines)
Lines 332-394 Link Here
332
		locator.report(match);
332
		locator.report(match);
333
	}
333
	}
334
}
334
}
335
/**
336
 * Reports the match of the given reference. Also provide a scope to look for possible local and other elements.
337
 */
338
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, Scope scope, int accuracy, MatchLocator locator) throws CoreException {
339
	if (scope == null || (scope.kind != Scope.BLOCK_SCOPE && scope.kind != Scope.METHOD_SCOPE)) {
340
		matchReportReference(reference, element, elementBinding, accuracy, locator);
341
		return;
342
	}
343
	
344
	// Look if some block scope local variable declarations include reference start position
345
	BlockScope blockScope = (BlockScope) scope;
346
	LocalDeclaration[] localDeclarations = blockScope.findLocalVariableDeclarations(reference.sourceStart);
347
	IJavaElement localElement = null;
348
	IJavaElement[] otherElements = null;
349
350
	// Some local variable declaration are matching
351
	if (localDeclarations != null) {
352
		int length = localDeclarations.length;
353
354
		// Set local element to first matching local declaration
355
		int idx = 0;
356
		for (; idx<length; idx++) {
357
			if (localDeclarations[idx] == null) break;
358
			if (reference.sourceStart == localDeclarations[idx].declarationSourceStart) {
359
				localElement = locator.createHandle(localDeclarations[idx], element);
360
				break;
361
			}
362
			if (idx>0 && localDeclarations[idx].sourceStart > reference.sourceStart) {
363
				localElement = locator.createHandle(localDeclarations[idx-1], element);
364
				break;
365
			}
366
		}
367
		if (localElement == null && idx > 0) {
368
			if (reference.sourceEnd < localDeclarations[idx-1].declarationEnd) {
369
				localElement = locator.createHandle(localDeclarations[idx-1], element);
370
			}
371
		}
372
		
373
		// Store other local variable declarations in other elements
374
		int size = 0;
375
		for (int j=1; j<length; j++) {
376
			if (localDeclarations[j] == null) break;
377
			if (reference.sourceStart == localDeclarations[j].declarationSourceStart) {
378
				if (otherElements == null) {
379
					otherElements = new IJavaElement[length-j];
380
				}
381
				otherElements[size++] = locator.createHandle(localDeclarations[j], element);
382
			}
383
		}
384
		if (size > 0 && size != (length-1)) {
385
			System.arraycopy(otherElements, 0, otherElements = new IJavaElement[size], 0, size);
386
		}
387
	}
388
	
389
	// Report match with local and other elements if any
390
	matchReportReference(reference, element, localElement, otherElements, elementBinding, accuracy, locator);
391
}
392
protected void matchReportReference(QualifiedNameReference qNameRef, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
335
protected void matchReportReference(QualifiedNameReference qNameRef, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
393
	Binding binding = qNameRef.binding;
336
	Binding binding = qNameRef.binding;
394
	TypeBinding typeBinding = null;
337
	TypeBinding typeBinding = null;
(-)search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java (-2 / +8 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.IPackageFragment;
16
import org.eclipse.jdt.core.IPackageFragment;
17
import org.eclipse.jdt.core.IPackageFragmentRoot;
17
import org.eclipse.jdt.core.IPackageFragmentRoot;
18
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.core.JavaModelException;
19
import org.eclipse.jdt.core.search.PackageReferenceMatch;
19
import org.eclipse.jdt.core.search.SearchPattern;
20
import org.eclipse.jdt.core.search.SearchPattern;
20
import org.eclipse.jdt.core.compiler.CharOperation;
21
import org.eclipse.jdt.core.compiler.CharOperation;
21
import org.eclipse.jdt.internal.compiler.ast.*;
22
import org.eclipse.jdt.internal.compiler.ast.*;
Lines 186-191 Link Here
186
	}
187
	}
187
}
188
}
188
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
189
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
190
	matchReportReference(reference, element, null, null, elementBinding, accuracy, locator);
191
}
192
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
189
	long[] positions = null;
193
	long[] positions = null;
190
	int last = -1;
194
	int last = -1;
191
	if (reference instanceof ImportReference) {
195
	if (reference instanceof ImportReference) {
Lines 259-266 Link Here
259
	if (last > positions.length) last = positions.length;
263
	if (last > positions.length) last = positions.length;
260
	int sourceStart = (int) (positions[0] >>> 32);
264
	int sourceStart = (int) (positions[0] >>> 32);
261
	int sourceEnd = ((int) positions[last - 1]);
265
	int sourceEnd = ((int) positions[last - 1]);
262
	match = locator.newPackageReferenceMatch(element, accuracy, sourceStart, sourceEnd-sourceStart+1, reference);
266
	PackageReferenceMatch packageReferenceMatch = locator.newPackageReferenceMatch(element, accuracy, sourceStart, sourceEnd-sourceStart+1, reference);
263
	locator.report(match);
267
	packageReferenceMatch.localElement(localElement);
268
	this.match = packageReferenceMatch;
269
	locator.report(this.match);
264
}
270
}
265
protected int referenceType() {
271
protected int referenceType() {
266
	return IJavaElement.PACKAGE_FRAGMENT;
272
	return IJavaElement.PACKAGE_FRAGMENT;
(-)search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java (-7 / +1 lines)
Lines 398-404 Link Here
398
			match = locator.newTypeReferenceMatch(element, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
398
			match = locator.newTypeReferenceMatch(element, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
399
			break;
399
			break;
400
		case IJavaElement.FIELD:
400
		case IJavaElement.FIELD:
401
			match = locator.newFieldReferenceMatch(element, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
401
			match = locator.newFieldReferenceMatch(element, null, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
402
			break;
402
			break;
403
		case IJavaElement.LOCAL_VARIABLE:
403
		case IJavaElement.LOCAL_VARIABLE:
404
			match = locator.newLocalVariableReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference);
404
			match = locator.newLocalVariableReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference);
Lines 417-428 Link Here
417
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
417
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
418
	matchReportReference(reference, element, elementBinding, accuracy, locator);
418
	matchReportReference(reference, element, elementBinding, accuracy, locator);
419
}
419
}
420
/**
421
 * Reports the match of the given reference. Also provide a scope to look for potential other elements.
422
 */
423
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, Scope scope, int accuracy, MatchLocator locator) throws CoreException {
424
	matchReportReference(reference, element, elementBinding, accuracy, locator);
425
}
426
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
420
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
427
    return locator.newDeclarationMatch(element, elementBinding, accuracy, reference.sourceStart, length);
421
    return locator.newDeclarationMatch(element, elementBinding, accuracy, reference.sourceStart, length);
428
}
422
}
(-)search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java (-9 / +12 lines)
Lines 137-142 Link Here
137
	return super.matchReference(node, nodeSet, writeOnlyAccess);
137
	return super.matchReference(node, nodeSet, writeOnlyAccess);
138
}
138
}
139
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
139
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
140
	matchReportReference(reference, element, null, null, elementBinding, accuracy, locator);
141
}
142
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements,Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
140
	if (this.isDeclarationOfAccessedFieldsPattern) {
143
	if (this.isDeclarationOfAccessedFieldsPattern) {
141
		// need exact match to be able to open on type ref
144
		// need exact match to be able to open on type ref
142
		if (accuracy != SearchMatch.A_ACCURATE) return;
145
		if (accuracy != SearchMatch.A_ACCURATE) return;
Lines 166-183 Link Here
166
		int lastIndex = importRef.tokens.length - 1;
169
		int lastIndex = importRef.tokens.length - 1;
167
		int start = (int) ((positions[lastIndex]) >>> 32);
170
		int start = (int) ((positions[lastIndex]) >>> 32);
168
		int end = (int) positions[lastIndex];
171
		int end = (int) positions[lastIndex];
169
		match = locator.newFieldReferenceMatch(element, elementBinding, accuracy, start, end-start+1, importRef);
172
		match = locator.newFieldReferenceMatch(element, localElement, elementBinding, accuracy, start, end-start+1, importRef);
170
		locator.report(match);
173
		locator.report(match);
171
	} else if (reference instanceof FieldReference) {
174
	} else if (reference instanceof FieldReference) {
172
		FieldReference fieldReference = (FieldReference) reference;
175
		FieldReference fieldReference = (FieldReference) reference;
173
		long position = fieldReference.nameSourcePosition;
176
		long position = fieldReference.nameSourcePosition;
174
		int start = (int) (position >>> 32);
177
		int start = (int) (position >>> 32);
175
		int end = (int) position;
178
		int end = (int) position;
176
		match = locator.newFieldReferenceMatch(element, elementBinding, accuracy, start, end-start+1, fieldReference);
179
		match = locator.newFieldReferenceMatch(element, localElement, elementBinding, accuracy, start, end-start+1, fieldReference);
177
		locator.report(match);
180
		locator.report(match);
178
	} else if (reference instanceof SingleNameReference) {
181
	} else if (reference instanceof SingleNameReference) {
179
		int offset = reference.sourceStart;
182
		int offset = reference.sourceStart;
180
		match = locator.newFieldReferenceMatch(element, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
183
		match = locator.newFieldReferenceMatch(element, localElement, elementBinding, accuracy, offset, reference.sourceEnd-offset+1, reference);
181
		locator.report(match);
184
		locator.report(match);
182
	} else if (reference instanceof QualifiedNameReference) {
185
	} else if (reference instanceof QualifiedNameReference) {
183
		QualifiedNameReference qNameRef = (QualifiedNameReference) reference;
186
		QualifiedNameReference qNameRef = (QualifiedNameReference) reference;
Lines 190-203 Link Here
190
		if (matchesName(this.pattern.name, qNameRef.tokens[indexOfFirstFieldBinding]) && !(nameBinding instanceof LocalVariableBinding)) {
193
		if (matchesName(this.pattern.name, qNameRef.tokens[indexOfFirstFieldBinding]) && !(nameBinding instanceof LocalVariableBinding)) {
191
			FieldBinding fieldBinding = nameBinding instanceof FieldBinding ? (FieldBinding) nameBinding : null;
194
			FieldBinding fieldBinding = nameBinding instanceof FieldBinding ? (FieldBinding) nameBinding : null;
192
			if (fieldBinding == null) {
195
			if (fieldBinding == null) {
193
				matches[indexOfFirstFieldBinding] = locator.newFieldReferenceMatch(element, elementBinding, accuracy, -1, -1, reference);
196
				matches[indexOfFirstFieldBinding] = locator.newFieldReferenceMatch(element, localElement, elementBinding, accuracy, -1, -1, reference);
194
			} else {
197
			} else {
195
				switch (matchField(fieldBinding, false)) {
198
				switch (matchField(fieldBinding, false)) {
196
					case ACCURATE_MATCH:
199
					case ACCURATE_MATCH:
197
						matches[indexOfFirstFieldBinding] = locator.newFieldReferenceMatch(element, elementBinding, SearchMatch.A_ACCURATE, -1, -1, reference);
200
						matches[indexOfFirstFieldBinding] = locator.newFieldReferenceMatch(element, localElement, elementBinding, SearchMatch.A_ACCURATE, -1, -1, reference);
198
						break;
201
						break;
199
					case INACCURATE_MATCH:
202
					case INACCURATE_MATCH:
200
						match = locator.newFieldReferenceMatch(element, elementBinding, SearchMatch.A_INACCURATE, -1, -1, reference);
203
						match = locator.newFieldReferenceMatch(element, localElement, elementBinding, SearchMatch.A_INACCURATE, -1, -1, reference);
201
						if (fieldBinding.type != null && fieldBinding.type.isParameterizedType() && this.pattern.hasTypeArguments()) {
204
						if (fieldBinding.type != null && fieldBinding.type.isParameterizedType() && this.pattern.hasTypeArguments()) {
202
							updateMatch((ParameterizedTypeBinding) fieldBinding.type, this.pattern.getTypeArguments(), locator);
205
							updateMatch((ParameterizedTypeBinding) fieldBinding.type, this.pattern.getTypeArguments(), locator);
203
						}
206
						}
Lines 213-226 Link Here
213
			if (matchesName(this.pattern.name, token)) {
216
			if (matchesName(this.pattern.name, token)) {
214
				FieldBinding otherBinding = qNameRef.otherBindings == null ? null : qNameRef.otherBindings[i-(indexOfFirstFieldBinding+1)];
217
				FieldBinding otherBinding = qNameRef.otherBindings == null ? null : qNameRef.otherBindings[i-(indexOfFirstFieldBinding+1)];
215
				if (otherBinding == null) {
218
				if (otherBinding == null) {
216
					matches[i] = locator.newFieldReferenceMatch(element, elementBinding, accuracy, -1, -1, reference);
219
					matches[i] = locator.newFieldReferenceMatch(element, localElement, elementBinding, accuracy, -1, -1, reference);
217
				} else {
220
				} else {
218
					switch (matchField(otherBinding, false)) {
221
					switch (matchField(otherBinding, false)) {
219
						case ACCURATE_MATCH:
222
						case ACCURATE_MATCH:
220
							matches[i] = locator.newFieldReferenceMatch(element, elementBinding, SearchMatch.A_ACCURATE, -1, -1, reference);
223
							matches[i] = locator.newFieldReferenceMatch(element, localElement, elementBinding, SearchMatch.A_ACCURATE, -1, -1, reference);
221
							break;
224
							break;
222
						case INACCURATE_MATCH:
225
						case INACCURATE_MATCH:
223
							match = locator.newFieldReferenceMatch(element, elementBinding, SearchMatch.A_INACCURATE, -1, -1, reference);
226
							match = locator.newFieldReferenceMatch(element, localElement, elementBinding, SearchMatch.A_INACCURATE, -1, -1, reference);
224
							if (otherBinding.type != null && otherBinding.type.isParameterizedType() && this.pattern.hasTypeArguments()) {
227
							if (otherBinding.type != null && otherBinding.type.isParameterizedType() && this.pattern.hasTypeArguments()) {
225
								updateMatch((ParameterizedTypeBinding) otherBinding.type, this.pattern.getTypeArguments(), locator);
228
								updateMatch((ParameterizedTypeBinding) otherBinding.type, this.pattern.getTypeArguments(), locator);
226
							}
229
							}
(-)search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java (-2 / +2 lines)
Lines 214-220 Link Here
214
	}
214
	}
215
	weakestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
215
	weakestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
216
}
216
}
217
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
217
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
218
	PatternLocator weakestPattern = null;
218
	PatternLocator weakestPattern = null;
219
	int level = IMPOSSIBLE_MATCH;
219
	int level = IMPOSSIBLE_MATCH;
220
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
220
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
Lines 226-232 Link Here
226
			level = newLevel;
226
			level = newLevel;
227
		}
227
		}
228
	}
228
	}
229
	weakestPattern.matchReportReference(reference, element, elementBinding, accuracy, locator);
229
	weakestPattern.matchReportReference(reference, element, localElement, otherElements, elementBinding, accuracy, locator);
230
}
230
}
231
public int resolveLevel(ASTNode node) {
231
public int resolveLevel(ASTNode node) {
232
	int level = ACCURATE_MATCH;
232
	int level = ACCURATE_MATCH;
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-96 / +152 lines)
Lines 21-26 Link Here
21
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.runtime.*;
22
import org.eclipse.core.runtime.*;
23
import org.eclipse.jdt.core.Flags;
23
import org.eclipse.jdt.core.Flags;
24
import org.eclipse.jdt.core.IAnnotatable;
25
import org.eclipse.jdt.core.IAnnotation;
24
import org.eclipse.jdt.core.IClassFile;
26
import org.eclipse.jdt.core.IClassFile;
25
import org.eclipse.jdt.core.IJavaElement;
27
import org.eclipse.jdt.core.IJavaElement;
26
import org.eclipse.jdt.core.IJavaModelStatusConstants;
28
import org.eclipse.jdt.core.IJavaModelStatusConstants;
Lines 35-41 Link Here
35
import org.eclipse.jdt.core.Signature;
37
import org.eclipse.jdt.core.Signature;
36
import org.eclipse.jdt.core.compiler.*;
38
import org.eclipse.jdt.core.compiler.*;
37
import org.eclipse.jdt.core.search.*;
39
import org.eclipse.jdt.core.search.*;
38
import org.eclipse.jdt.internal.compiler.ASTVisitor;
39
import org.eclipse.jdt.internal.compiler.CompilationResult;
40
import org.eclipse.jdt.internal.compiler.CompilationResult;
40
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
41
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
41
import org.eclipse.jdt.internal.compiler.ast.*;
42
import org.eclipse.jdt.internal.compiler.ast.*;
Lines 48-54 Link Here
48
import org.eclipse.jdt.internal.compiler.lookup.*;
49
import org.eclipse.jdt.internal.compiler.lookup.*;
49
import org.eclipse.jdt.internal.compiler.parser.*;
50
import org.eclipse.jdt.internal.compiler.parser.*;
50
import org.eclipse.jdt.internal.compiler.problem.*;
51
import org.eclipse.jdt.internal.compiler.problem.*;
51
import org.eclipse.jdt.internal.compiler.util.HashtableOfIntValues;
52
import org.eclipse.jdt.internal.compiler.util.Messages;
52
import org.eclipse.jdt.internal.compiler.util.Messages;
53
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
53
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
54
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
54
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
Lines 146-191 Link Here
146
146
147
private final boolean searchPackageDeclaration;
147
private final boolean searchPackageDeclaration;
148
148
149
/**
150
 * An ast visitor that visits local type declarations.
151
 */
152
public class LocalDeclarationVisitor extends ASTVisitor {
153
	IJavaElement enclosingElement;
154
	Binding enclosingElementBinding;
155
	MatchingNodeSet nodeSet;
156
	HashtableOfIntValues occurrencesCounts = new HashtableOfIntValues(); // key = class name (char[]), value = occurrenceCount (int)
157
	public LocalDeclarationVisitor(IJavaElement enclosingElement, Binding enclosingElementBinding, MatchingNodeSet nodeSet) {
158
		this.enclosingElement = enclosingElement;
159
		this.enclosingElementBinding = enclosingElementBinding;
160
		this.nodeSet = nodeSet;
161
	}
162
	public boolean visit(TypeDeclaration typeDeclaration, BlockScope unused) {
163
		try {
164
			char[] simpleName;
165
			if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {				
166
				simpleName = CharOperation.NO_CHAR;
167
			} else {
168
				simpleName = typeDeclaration.name;
169
			}
170
			int occurrenceCount = occurrencesCounts.get(simpleName);
171
			if (occurrenceCount == HashtableOfIntValues.NO_VALUE) {
172
				occurrenceCount = 1;
173
			} else {
174
				occurrenceCount = occurrenceCount + 1;
175
			}
176
			occurrencesCounts.put(simpleName, occurrenceCount);
177
			if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {				
178
				reportMatching(typeDeclaration, this.enclosingElement, -1, nodeSet, occurrenceCount);
179
			} else {
180
				Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeDeclaration);
181
				reportMatching(typeDeclaration, this.enclosingElement, level != null ? level.intValue() : -1, nodeSet, occurrenceCount);
182
			}
183
			return false; // don't visit members as this was done during reportMatching(...)
184
		} catch (CoreException e) {
185
			throw new WrappedCoreException(e);
186
		}
187
	}
188
}
189
public static class WorkingCopyDocument extends JavaSearchDocument {
149
public static class WorkingCopyDocument extends JavaSearchDocument {
190
	public org.eclipse.jdt.core.ICompilationUnit workingCopy;
150
	public org.eclipse.jdt.core.ICompilationUnit workingCopy;
191
	WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) {
151
	WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) {
Lines 600-606 Link Here
600
	return ((IType) parent).getInitializer(occurrenceCount);
560
	return ((IType) parent).getInitializer(occurrenceCount);
601
}
561
}
602
/**
562
/**
603
 * Create an handle for a local variable declartion (may be a local variable or type parameter).
563
 * Create an handle for a local variable declaration (may be a local variable or type parameter).
604
 */
564
 */
605
protected IJavaElement createHandle(AbstractVariableDeclaration variableDeclaration, IJavaElement parent) {
565
protected IJavaElement createHandle(AbstractVariableDeclaration variableDeclaration, IJavaElement parent) {
606
	switch (variableDeclaration.getKind()) {
566
	switch (variableDeclaration.getKind()) {
Lines 629-634 Link Here
629
	}
589
	}
630
	return null;
590
	return null;
631
}
591
}
592
/**
593
 * Create an handle for a local variable declaration (may be a local variable or type parameter).
594
 */
595
protected IJavaElement createHandle(Annotation annotation, IAnnotatable parent) {
596
	if (parent == null) return null;
597
	TypeReference typeRef = annotation.type;
598
	char[][] typeName = typeRef.getTypeName();
599
	String name = new String(typeName[typeName.length-1]);
600
	try {
601
		IAnnotation[] annotations = parent.getAnnotations();
602
		int length = annotations == null ? 0 : annotations.length;
603
		for (int i=0; i<length; i++) {
604
			if (annotations[i].getElementName().equals(name)) {
605
				return annotations[i];
606
			}
607
		}
608
	}
609
	catch (JavaModelException jme) {
610
		// skip
611
	}
612
	return null;
613
}
614
/*
615
 * Create handles for a list of fields
616
 */
617
private IJavaElement[] createHandles(FieldDeclaration[] fields, TypeDeclaration type, IJavaElement parent) {
618
	IJavaElement[] otherElements = null;
619
	if (fields != null) {
620
		int length = fields.length;
621
		int size = 0;
622
		while (size<length && fields[size] != null) {
623
			size++;
624
		}
625
		otherElements = new IJavaElement[size];
626
		for (int j=0; j<size; j++) {
627
			otherElements[j] = createHandle(fields[j], type, parent);
628
		}
629
	}
630
	return otherElements;
631
}
632
/*
632
/*
633
 * Creates hierarchy resolver if needed. 
633
 * Creates hierarchy resolver if needed. 
634
 * Returns whether focus is visible.
634
 * Returns whether focus is visible.
Lines 1387-1399 Link Here
1387
	}
1387
	}
1388
}
1388
}
1389
1389
1390
public SearchMatch newFieldReferenceMatch(
1390
public FieldReferenceMatch newFieldReferenceMatch(
1391
		IJavaElement enclosingElement,
1391
		IJavaElement enclosingElement,
1392
		IJavaElement localElement,
1392
		Binding enclosingBinding,
1393
		Binding enclosingBinding,
1393
		int accuracy,
1394
		int accuracy,  
1394
		int offset,  
1395
		int offset,
1395
		int length,
1396
		int length, ASTNode reference) {
1396
		ASTNode reference) {
1397
	int bits = reference.bits;
1397
	int bits = reference.bits;
1398
	boolean isCompoundAssigned = (bits & ASTNode.IsCompoundAssigned) != 0;
1398
	boolean isCompoundAssigned = (bits & ASTNode.IsCompoundAssigned) != 0;
1399
	boolean isReadAccess = isCompoundAssigned || (bits & ASTNode.IsStrictlyAssigned) == 0;
1399
	boolean isReadAccess = isCompoundAssigned || (bits & ASTNode.IsStrictlyAssigned) == 0;
Lines 1411-1419 Link Here
1411
	boolean insideDocComment = (bits & ASTNode.InsideJavadoc) != 0;
1411
	boolean insideDocComment = (bits & ASTNode.InsideJavadoc) != 0;
1412
	SearchParticipant participant = getParticipant(); 
1412
	SearchParticipant participant = getParticipant(); 
1413
	IResource resource = this.currentPossibleMatch.resource;
1413
	IResource resource = this.currentPossibleMatch.resource;
1414
	if (enclosingBinding != null)
1414
	if (enclosingBinding != null) {
1415
		enclosingElement = ((JavaElement) enclosingElement).resolved(enclosingBinding);
1415
		enclosingElement = ((JavaElement) enclosingElement).resolved(enclosingBinding);
1416
	return new FieldReferenceMatch(enclosingElement, accuracy, offset, length, isReadAccess, isWriteAccess, insideDocComment, participant, resource);
1416
	}
1417
	FieldReferenceMatch match = new FieldReferenceMatch(enclosingElement, accuracy, offset, length, isReadAccess, isWriteAccess, insideDocComment, participant, resource);
1418
	match.localElement(localElement);
1419
	return match;
1417
}
1420
}
1418
1421
1419
public SearchMatch newLocalVariableReferenceMatch(
1422
public SearchMatch newLocalVariableReferenceMatch(
Lines 1442-1448 Link Here
1442
	return new LocalVariableReferenceMatch(enclosingElement, accuracy, offset, length, isReadAccess, isWriteAccess, insideDocComment, participant, resource);
1445
	return new LocalVariableReferenceMatch(enclosingElement, accuracy, offset, length, isReadAccess, isWriteAccess, insideDocComment, participant, resource);
1443
}
1446
}
1444
1447
1445
public SearchMatch newMethodReferenceMatch(
1448
public MethodReferenceMatch newMethodReferenceMatch(
1446
		IJavaElement enclosingElement,
1449
		IJavaElement enclosingElement,
1447
		Binding enclosingBinding,
1450
		Binding enclosingBinding,
1448
		int accuracy,
1451
		int accuracy,
Lines 1460-1466 Link Here
1460
	return new MethodReferenceMatch(enclosingElement, accuracy, offset, length, isConstructor, isSynthetic, isOverridden, insideDocComment, participant, resource);
1463
	return new MethodReferenceMatch(enclosingElement, accuracy, offset, length, isConstructor, isSynthetic, isOverridden, insideDocComment, participant, resource);
1461
}
1464
}
1462
1465
1463
public SearchMatch newPackageReferenceMatch(
1466
public PackageReferenceMatch newPackageReferenceMatch(
1464
		IJavaElement enclosingElement,
1467
		IJavaElement enclosingElement,
1465
		int accuracy,
1468
		int accuracy,
1466
		int offset,  
1469
		int offset,  
Lines 2073-2086 Link Here
2073
2076
2074
	// handle nodes for the local type first
2077
	// handle nodes for the local type first
2075
	if ((method.bits & ASTNode.HasLocalType) != 0) {
2078
	if ((method.bits & ASTNode.HasLocalType) != 0) {
2076
		if (enclosingElement == null)
2079
		if (enclosingElement == null) {
2077
			enclosingElement = createHandle(method, parent);
2080
			enclosingElement = createHandle(method, parent);
2078
		LocalDeclarationVisitor localDeclarationVisitor = new LocalDeclarationVisitor(enclosingElement, method.binding, nodeSet);
2081
		}
2082
		// Traverse method declaration to report matches both in local types declaration
2083
		// and in local variables declaration
2084
		ASTNode[] nodes = typeInHierarchy ? nodeSet.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd) : null;
2085
		boolean report = (this.matchContainer & PatternLocator.METHOD_CONTAINER) != 0 && encloses(enclosingElement);
2086
		MemberDeclarationVisitor declarationVisitor = new MemberDeclarationVisitor(enclosingElement, report ? nodes : null, nodeSet, this);
2079
		try {
2087
		try {
2080
			method.traverse(localDeclarationVisitor, (ClassScope) null);
2088
			method.traverse(declarationVisitor, (ClassScope) null);
2081
		} catch (WrappedCoreException e) {
2089
		} catch (WrappedCoreException e) {
2082
			throw e.coreException;
2090
			throw e.coreException;
2083
		}
2091
		}
2092
		// Report all nodes and remove them
2093
		if (nodes != null) {
2094
			int length = nodes.length;
2095
			for (int i = 0; i < length; i++) {
2096
				Integer level = (Integer) nodeSet.matchingNodes.removeKey(nodes[i]);
2097
				if (report && level != null) {
2098
	    	        this.patternLocator.matchReportReference(nodes[i], enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), method.binding, level.intValue(), this);
2099
				}
2100
			}
2101
		}
2084
	}
2102
	}
2085
2103
2086
	// report the type parameters
2104
	// report the type parameters
Lines 2097-2103 Link Here
2097
		if (enclosingElement == null) {
2115
		if (enclosingElement == null) {
2098
			enclosingElement = createHandle(method, parent);
2116
			enclosingElement = createHandle(method, parent);
2099
		}
2117
		}
2100
		reportMatching(method.annotations, enclosingElement, method.binding, nodeSet, true, true);
2118
		reportMatching(method.annotations, enclosingElement, null, method.binding, nodeSet, true, true);
2101
	}
2119
	}
2102
2120
2103
	// references in this method
2121
	// references in this method
Lines 2105-2117 Link Here
2105
		ASTNode[] nodes = nodeSet.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
2123
		ASTNode[] nodes = nodeSet.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
2106
		if (nodes != null) {
2124
		if (nodes != null) {
2107
			if ((this.matchContainer & PatternLocator.METHOD_CONTAINER) != 0) {
2125
			if ((this.matchContainer & PatternLocator.METHOD_CONTAINER) != 0) {
2108
				if (enclosingElement == null)
2126
				if (enclosingElement == null) {
2109
					enclosingElement = createHandle(method, parent);
2127
					enclosingElement = createHandle(method, parent);
2128
				}
2110
				if (encloses(enclosingElement)) {
2129
				if (encloses(enclosingElement)) {
2111
					for (int i = 0, l = nodes.length; i < l; i++) {
2130
					if (((InternalSearchPattern)this.pattern).mustResolve) {
2112
						ASTNode node = nodes[i];
2131
						// Visit only if the pattern must resolve
2113
						Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2132
						MemberDeclarationVisitor declarationVisitor = new MemberDeclarationVisitor(enclosingElement, nodes, nodeSet, this);
2114
						this.patternLocator.matchReportReference(node, enclosingElement, method.binding, method.scope, level.intValue(), this);
2133
						method.traverse(declarationVisitor, (ClassScope) null);
2134
						int length = nodes.length;
2135
						for (int i = 0; i < length; i++) {
2136
							Integer level = (Integer) nodeSet.matchingNodes.removeKey(nodes[i]);
2137
			    	        this.patternLocator.matchReportReference(nodes[i], enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), method.binding, level.intValue(), this);
2138
						}
2139
					} else {
2140
						for (int i = 0, l = nodes.length; i < l; i++) {
2141
							ASTNode node = nodes[i];
2142
							Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2143
							this.patternLocator.matchReportReference(node, enclosingElement, null, null, method.binding, level.intValue(), this);
2144
						}
2115
					}
2145
					}
2116
					return;
2146
					return;
2117
				}
2147
				}
Lines 2125-2140 Link Here
2125
}
2155
}
2126
/**
2156
/**
2127
 * Report matching in annotations.
2157
 * Report matching in annotations.
2158
 * @param otherElements TODO
2128
 */
2159
 */
2129
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException {
2160
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException {
2130
	for (int i=0, al=annotations.length; i<al; i++) {
2161
	for (int i=0, al=annotations.length; i<al; i++) {
2131
		Annotation annotationType = annotations[i];
2162
		Annotation annotationType = annotations[i];
2163
		IJavaElement localElement = null;
2132
2164
2133
		// Look for annotation type ref
2165
		// Look for annotation type ref
2134
		TypeReference typeRef = annotationType.type;
2166
		TypeReference typeRef = annotationType.type;
2135
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef);
2167
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef);
2136
		if (level != null && matchedContainer) {
2168
		if (level != null && matchedContainer) {
2137
			this.patternLocator.matchReportReference(typeRef, enclosingElement, elementBinding, level.intValue(), this);
2169
			localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2170
			this.patternLocator.matchReportReference(typeRef, enclosingElement, localElement, otherElements, elementBinding, level.intValue(), this);
2138
		}
2171
		}
2139
		
2172
		
2140
		// Look for attribute ref
2173
		// Look for attribute ref
Lines 2144-2150 Link Here
2144
			level = (Integer) nodeSet.matchingNodes.removeKey(pair);
2177
			level = (Integer) nodeSet.matchingNodes.removeKey(pair);
2145
			if (level != null && enclosesElement) {
2178
			if (level != null && enclosesElement) {
2146
				ASTNode reference = (annotationType instanceof SingleMemberAnnotation) ? (ASTNode) annotationType: pair;
2179
				ASTNode reference = (annotationType instanceof SingleMemberAnnotation) ? (ASTNode) annotationType: pair;
2147
				this.patternLocator.matchReportReference(reference, enclosingElement, pair.binding, level.intValue(), this);
2180
				if (localElement == null) {
2181
					localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2182
				}
2183
				this.patternLocator.matchReportReference(reference, enclosingElement, localElement, otherElements, pair.binding, level.intValue(), this);
2148
			}
2184
			}
2149
		}
2185
		}
2150
		
2186
		
Lines 2160-2166 Link Here
2160
					ASTNode node = nodes[j];
2196
					ASTNode node = nodes[j];
2161
					level = (Integer) nodeSet.matchingNodes.removeKey(node);
2197
					level = (Integer) nodeSet.matchingNodes.removeKey(node);
2162
					if (enclosesElement) {
2198
					if (enclosesElement) {
2163
						this.patternLocator.matchReportReference(node, enclosingElement, elementBinding, level.intValue(), this);
2199
						if (localElement == null) {
2200
							localElement = createHandle(annotationType, (IAnnotatable) enclosingElement);
2201
						}
2202
						this.patternLocator.matchReportReference(node, enclosingElement, localElement, otherElements, elementBinding, level.intValue(), this);
2164
					}
2203
					}
2165
				}
2204
				}
2166
			}
2205
			}
Lines 2235-2241 Link Here
2235
					ASTNode node = nodes[i];
2274
					ASTNode node = nodes[i];
2236
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2275
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2237
					if (encloses(element)) {
2276
					if (encloses(element)) {
2238
						this.patternLocator.matchReportReference(node, element, null/*no binding*/, level.intValue(), this);
2277
						this.patternLocator.matchReportReference(node, element, null, null, null/*no binding*/, level.intValue(), this);
2239
					}
2278
					}
2240
				}
2279
				}
2241
			}
2280
			}
Lines 2247-2253 Link Here
2247
		if (pkg != null && pkg.annotations != null) {
2286
		if (pkg != null && pkg.annotations != null) {
2248
			IJavaElement element = createPackageDeclarationHandle(unit);
2287
			IJavaElement element = createPackageDeclarationHandle(unit);
2249
			if (element != null) {
2288
			if (element != null) {
2250
				reportMatching(pkg.annotations, element, null, nodeSet, true, encloses(element));
2289
				reportMatching(pkg.annotations, element, null, null, nodeSet, true, encloses(element));
2251
			}
2290
			}
2252
		}
2291
		}
2253
2292
Lines 2300-2321 Link Here
2300
2339
2301
	// handle the nodes for the local type first
2340
	// handle the nodes for the local type first
2302
	if ((field.bits & ASTNode.HasLocalType) != 0) {
2341
	if ((field.bits & ASTNode.HasLocalType) != 0) {
2303
		if (enclosingElement == null)
2342
		if (enclosingElement == null) {
2304
			enclosingElement = createHandle(field, type, parent);
2343
			enclosingElement = createHandle(field, type, parent);
2305
		LocalDeclarationVisitor localDeclarationVisitor = new LocalDeclarationVisitor(enclosingElement, field.binding, nodeSet);
2344
		}
2345
		// Traverse field declaration(s) to report matches both in local types declaration
2346
		// and in local variables declaration
2347
		int fieldEnd = field.endPart2Position == 0 ? field.declarationSourceEnd : field.endPart2Position;
2348
		ASTNode[] nodes = typeInHierarchy ? nodeSet.matchingNodes(field.sourceStart, fieldEnd) : null;
2349
		boolean report = (this.matchContainer & PatternLocator.FIELD_CONTAINER) != 0 && encloses(enclosingElement);
2350
		MemberDeclarationVisitor declarationVisitor = new MemberDeclarationVisitor(enclosingElement, report ? nodes : null, nodeSet, this);
2306
		try {
2351
		try {
2307
			field.traverse(localDeclarationVisitor, null);
2352
			field.traverse(declarationVisitor, (MethodScope) null);
2308
		} catch (WrappedCoreException e) {
2353
		} catch (WrappedCoreException e) {
2309
			throw e.coreException;
2354
			throw e.coreException;
2310
		}
2355
		}
2356
		// Report all nodes and remove them
2357
		if (nodes != null) {
2358
			int length = nodes.length;
2359
			for (int i = 0; i < length; i++) {
2360
				ASTNode node = nodes[i];
2361
				Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2362
				if (report && level != null) {
2363
					if (node instanceof TypeDeclaration) {
2364
						// use field declaration to report match (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88174)
2365
						AllocationExpression allocation = ((TypeDeclaration)node).allocation;
2366
						if (allocation != null && allocation.enumConstant != null) {
2367
							node = field;
2368
						}
2369
					}
2370
	    	        this.patternLocator.matchReportReference(node, enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), field.binding, level.intValue(), this);
2371
				}
2372
			}
2373
		}
2311
	}
2374
	}
2312
2375
2313
	// report annotations
2376
	// report annotations
2377
	IJavaElement[] otherElements = null;
2314
	if (field.annotations != null) {
2378
	if (field.annotations != null) {
2315
		if (enclosingElement == null) {
2379
		if (enclosingElement == null) {
2316
			enclosingElement = createHandle(field, type, parent);
2380
			enclosingElement = createHandle(field, type, parent);
2317
		}
2381
		}
2318
		reportMatching(field.annotations, enclosingElement, field.binding, nodeSet, true, true);
2382
		if (otherFields != null) {
2383
			otherElements = createHandles(otherFields, type, parent);
2384
		}
2385
		reportMatching(field.annotations, enclosingElement, otherElements, field.binding, nodeSet, true, true);
2319
	}
2386
	}
2320
2387
2321
	if (typeInHierarchy) {
2388
	if (typeInHierarchy) {
Lines 2333-2349 Link Here
2333
						for (int i = 0, l = nodes.length; i < l; i++) {
2400
						for (int i = 0, l = nodes.length; i < l; i++) {
2334
							ASTNode node = nodes[i];
2401
							ASTNode node = nodes[i];
2335
							Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2402
							Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2336
							IJavaElement[] otherElements = null;
2403
							if (otherFields != null && otherElements == null) {
2337
							if (otherFields != null) {
2404
								otherElements = createHandles(otherFields, type, parent);
2338
								int length = otherFields.length;
2339
								int size = 0;
2340
								while (size<length && otherFields[size] != null) {
2341
									size++;
2342
								}
2343
								otherElements = new IJavaElement[size];
2344
								for (int j=0; j<size; j++) {
2345
									otherElements[j] = createHandle(otherFields[j], type, parent);
2346
								}
2347
							}
2405
							}
2348
							this.patternLocator.matchReportReference(node, enclosingElement, null, otherElements, field.binding, level.intValue(), this);
2406
							this.patternLocator.matchReportReference(node, enclosingElement, null, otherElements, field.binding, level.intValue(), this);
2349
						}
2407
						}
Lines 2357-2370 Link Here
2357
		ASTNode[] nodes = nodeSet.matchingNodes(field.sourceStart, fieldEnd);
2415
		ASTNode[] nodes = nodeSet.matchingNodes(field.sourceStart, fieldEnd);
2358
		if (nodes != null) {
2416
		if (nodes != null) {
2359
			if ((this.matchContainer & PatternLocator.FIELD_CONTAINER) == 0) {
2417
			if ((this.matchContainer & PatternLocator.FIELD_CONTAINER) == 0) {
2360
				for (int i = 0, l = nodes.length; i < l; i++)
2418
				for (int i = 0, l = nodes.length; i < l; i++) {
2361
					nodeSet.matchingNodes.removeKey(nodes[i]);
2419
					nodeSet.matchingNodes.removeKey(nodes[i]);
2420
				}
2362
			} else {
2421
			} else {
2363
				if (enclosingElement == null) {
2422
				if (enclosingElement == null) {
2364
					enclosingElement = createHandle(field, type, parent);
2423
					enclosingElement = createHandle(field, type, parent);
2365
				}
2424
				}
2366
				if (encloses(enclosingElement)) {
2425
				if (encloses(enclosingElement)) {
2367
					for (int i = 0, l = nodes.length; i < l; i++) {
2426
					MemberDeclarationVisitor declarationVisitor = new MemberDeclarationVisitor(enclosingElement, nodes, nodeSet, this);
2427
					field.traverse(declarationVisitor, (MethodScope) null);
2428
					int length = nodes.length;
2429
					for (int i = 0; i < length; i++) {
2368
						ASTNode node = nodes[i];
2430
						ASTNode node = nodes[i];
2369
						Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2431
						Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2370
						if (node instanceof TypeDeclaration) {
2432
						if (node instanceof TypeDeclaration) {
Lines 2374-2386 Link Here
2374
								node = field;
2436
								node = field;
2375
							}
2437
							}
2376
						}
2438
						}
2377
						// Set block scope for initializer in case there would have other local and other elements to report
2439
		    	        this.patternLocator.matchReportReference(node, enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), field.binding, level.intValue(), this);
2378
						BlockScope blockScope = null;
2379
						if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
2380
							Block block = ((Initializer)field).block;
2381
							if (block != null) blockScope = block.scope;
2382
						}
2383
						this.patternLocator.matchReportReference(node, enclosingElement, field.binding, blockScope, level.intValue(), this);
2384
					}
2440
					}
2385
					return;
2441
					return;
2386
				}
2442
				}
Lines 2426-2432 Link Here
2426
2482
2427
	// report annotations
2483
	// report annotations
2428
	if (type.annotations != null) {
2484
	if (type.annotations != null) {
2429
		reportMatching(type.annotations, enclosingElement, type.binding, nodeSet, matchedClassContainer, enclosesElement);
2485
		reportMatching(type.annotations, enclosingElement, null, type.binding, nodeSet, matchedClassContainer, enclosesElement);
2430
	}
2486
	}
2431
2487
2432
	// report references in javadoc
2488
	// report references in javadoc
Lines 2441-2447 Link Here
2441
					ASTNode node = nodes[i];
2497
					ASTNode node = nodes[i];
2442
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2498
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2443
					if (enclosesElement) {
2499
					if (enclosesElement) {
2444
						this.patternLocator.matchReportReference(node, enclosingElement, type.binding, level.intValue(), this);
2500
						this.patternLocator.matchReportReference(node, enclosingElement, null, null, type.binding, level.intValue(), this);
2445
					}
2501
					}
2446
				}
2502
				}
2447
			}
2503
			}
Lines 2454-2460 Link Here
2454
		if (superType != null) {
2510
		if (superType != null) {
2455
			Integer level = (Integer) nodeSet.matchingNodes.removeKey(superType);
2511
			Integer level = (Integer) nodeSet.matchingNodes.removeKey(superType);
2456
			if (level != null && matchedClassContainer)
2512
			if (level != null && matchedClassContainer)
2457
				this.patternLocator.matchReportReference(superType, enclosingElement, type.binding, level.intValue(), this);
2513
				this.patternLocator.matchReportReference(superType, enclosingElement, null, null, type.binding, level.intValue(), this);
2458
		}
2514
		}
2459
	} else {
2515
	} else {
2460
		TypeReference superClass = type.superclass;
2516
		TypeReference superClass = type.superclass;
Lines 2639-2651 Link Here
2639
				for (int i = 0, l = nodes.length; i < l; i++) {
2695
				for (int i = 0, l = nodes.length; i < l; i++) {
2640
					ASTNode node = nodes[i];
2696
					ASTNode node = nodes[i];
2641
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2697
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
2642
					this.patternLocator.matchReportReference(node, enclosingElement, elementBinding, level.intValue(), this);
2698
					this.patternLocator.matchReportReference(node, enclosingElement, null, null, elementBinding, level.intValue(), this);
2643
				}
2699
				}
2644
		}
2700
		}
2645
	} else if (encloses(enclosingElement)) {
2701
	} else if (encloses(enclosingElement)) {
2646
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(superReference);
2702
		Integer level = (Integer) nodeSet.matchingNodes.removeKey(superReference);
2647
		if (level != null && matchedClassContainer)
2703
		if (level != null && matchedClassContainer)
2648
			this.patternLocator.matchReportReference(superReference, enclosingElement, elementBinding, level.intValue(), this);
2704
			this.patternLocator.matchReportReference(superReference, enclosingElement, null, null, elementBinding, level.intValue(), this);
2649
	}
2705
	}
2650
}
2706
}
2651
protected boolean typeInHierarchy(ReferenceBinding binding) {
2707
protected boolean typeInHierarchy(ReferenceBinding binding) {
(-)search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java (-2 / +2 lines)
Lines 249-255 Link Here
249
	if (closestPattern != null)
249
	if (closestPattern != null)
250
		closestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
250
		closestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
251
}
251
}
252
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
252
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
253
	PatternLocator closestPattern = null;
253
	PatternLocator closestPattern = null;
254
	int level = IMPOSSIBLE_MATCH;
254
	int level = IMPOSSIBLE_MATCH;
255
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
255
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
Lines 262-268 Link Here
262
		}
262
		}
263
	}
263
	}
264
	if (closestPattern != null)
264
	if (closestPattern != null)
265
		closestPattern.matchReportReference(reference, element, elementBinding, accuracy, locator);
265
		closestPattern.matchReportReference(reference, element, localElement, otherElements, elementBinding, accuracy, locator);
266
}
266
}
267
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
267
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
268
	PatternLocator closestPattern = null;
268
	PatternLocator closestPattern = null;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java (+3 lines)
Lines 53-58 Link Here
53
	
53
	
54
	public void traverse(ASTVisitor visitor, BlockScope scope) {
54
	public void traverse(ASTVisitor visitor, BlockScope scope) {
55
		if (visitor.visit(this, scope)) {
55
		if (visitor.visit(this, scope)) {
56
			if (this.type != null) {
57
				this.type.traverse(visitor, scope);
58
			}
56
			if (this.memberValue != null) {
59
			if (this.memberValue != null) {
57
				this.memberValue.traverse(visitor, scope);
60
				this.memberValue.traverse(visitor, scope);
58
			}
61
			}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java (-1 / +5 lines)
Lines 35-41 Link Here
35
	}
35
	}
36
	
36
	
37
	public void traverse(ASTVisitor visitor, BlockScope scope) {
37
	public void traverse(ASTVisitor visitor, BlockScope scope) {
38
		visitor.visit(this, scope);
38
		if (visitor.visit(this, scope)) {
39
			if (this.type != null) {
40
				this.type.traverse(visitor, scope);
41
			}
42
		}
39
		visitor.endVisit(this, scope);
43
		visitor.endVisit(this, scope);
40
	}
44
	}
41
}
45
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java (+3 lines)
Lines 60-65 Link Here
60
	
60
	
61
	public void traverse(ASTVisitor visitor, BlockScope scope) {
61
	public void traverse(ASTVisitor visitor, BlockScope scope) {
62
		if (visitor.visit(this, scope)) {
62
		if (visitor.visit(this, scope)) {
63
			if (this.type != null) {
64
				this.type.traverse(visitor, scope);
65
			}
63
			if (this.memberValuePairs != null) {
66
			if (this.memberValuePairs != null) {
64
				int memberValuePairsLength = this.memberValuePairs.length;
67
				int memberValuePairsLength = this.memberValuePairs.length;
65
				for (int i = 0; i < memberValuePairsLength; i++)
68
				for (int i = 0; i < memberValuePairsLength; i++)
(-)search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java (+269 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jdt.core.IAnnotatable;
15
import org.eclipse.jdt.core.IJavaElement;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.internal.compiler.ASTVisitor;
18
import org.eclipse.jdt.internal.compiler.ast.*;
19
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
20
import org.eclipse.jdt.internal.compiler.util.HashtableOfIntValues;
21
import org.eclipse.jdt.internal.core.search.matching.MatchLocator.WrappedCoreException;
22
23
/**
24
 * Specific visitor of field or method declaration which can identify and store
25
 * the local and  other elements of one or several matching nodes.
26
 * <p>
27
 * This visitor can also peek up local or anonymous type declaration and restart
28
 * a new {@link MatchLocator} traverse on this type.
29
 * </p>
30
 */
31
class MemberDeclarationVisitor extends ASTVisitor {
32
	// Matches information
33
	private final MatchLocator locator;
34
	private final IJavaElement enclosingElement;
35
	private final MatchingNodeSet nodeSet;
36
	private final ASTNode[] matchingNodes;
37
	private final ASTNode matchingNode;
38
39
	// Local type storage
40
	HashtableOfIntValues occurrencesCounts = new HashtableOfIntValues(); // key = class name (char[]), value = occurrenceCount (int)
41
	int nodesCount = 0;
42
43
	// Local and other elements storage
44
	IJavaElement currentDeclaration;
45
	private Annotation annotation;
46
	private LocalDeclaration localDeclaration;
47
	IJavaElement localElement;
48
	IJavaElement[] localElements, otherElements;
49
	IJavaElement[][] allOtherElements;
50
	int ptr = -1;
51
	int[] ptrs;
52
53
public MemberDeclarationVisitor(IJavaElement element, ASTNode[] nodes, MatchingNodeSet set, MatchLocator locator) {
54
	this.enclosingElement = element;
55
	this.nodeSet = set;
56
	this.locator = locator;
57
	if (nodes == null) {
58
		this.matchingNode = null;
59
		this.matchingNodes = null;
60
	} else {
61
		this.nodesCount = nodes.length;
62
		if (nodes.length == 1) {
63
			this.matchingNode = nodes[0];
64
			this.matchingNodes = null;
65
		} else {
66
			this.matchingNode = null;
67
			this.matchingNodes = nodes;
68
			this.localElements = new IJavaElement[this.nodesCount];
69
			this.ptrs = new int[this.nodesCount];
70
			this.allOtherElements = new IJavaElement[this.nodesCount][];
71
		}
72
	}
73
}
74
public void endVisit(Argument argument, BlockScope scope) {
75
    this.localDeclaration = null;
76
}
77
public void endVisit(LocalDeclaration declaration, BlockScope scope) {
78
    this.localDeclaration = null;
79
}
80
public void endVisit(MarkerAnnotation markerAnnotation, BlockScope unused) {
81
	this.annotation = null;
82
}
83
public void endVisit(NormalAnnotation normalAnnotation, BlockScope unused) {
84
	this.annotation = null;
85
}
86
public void endVisit(SingleMemberAnnotation singleMemberAnnotation, BlockScope unused) {
87
	this.annotation = null;
88
}
89
IJavaElement getLocalElement(int idx) {
90
	if (this.nodesCount == 1) {
91
		return this.localElement;
92
	}
93
	if (this.localElements != null) {
94
		return this.localElements[idx];
95
	}
96
	return null;
97
}
98
IJavaElement[] getOtherElements(int idx) {
99
	if (this.nodesCount == 1) {
100
		if (this.otherElements != null) {
101
			int length = this.otherElements.length;
102
			if (this.ptr < (length-1)) {
103
				System.arraycopy(this.otherElements, 0, this.otherElements = new IJavaElement[this.ptr+1], 0, this.ptr+1);
104
			}
105
		}
106
		return this.otherElements;
107
	}
108
	IJavaElement[] elements = this.allOtherElements == null ? null : this.allOtherElements[idx];
109
	if (elements != null) {
110
		int length = elements.length;
111
		if (this.ptrs[idx] < (length-1)) {
112
			System.arraycopy(elements, 0, elements = this.allOtherElements[idx] = new IJavaElement[this.ptrs[idx]+1], 0, this.ptrs[idx]+1);
113
		}
114
	}
115
	return elements;
116
}
117
private int matchNode(ASTNode reference) {
118
	if (this.matchingNode != null) {
119
		if (this.matchingNode == reference) return 0;
120
	} else {
121
	    int length = this.matchingNodes.length;
122
		for (int i=0; i<length; i++) {
123
			if (this.matchingNodes[i] == reference)  { // == is intentional
124
				return i;
125
			}
126
		}
127
	}
128
	return -1;
129
}
130
/*
131
 * Store the handle for the reference of the given index (e.g. peek in #matchingNodes
132
 * or #matchingNode).
133
 * Note that for performance reason, matching node and associated handles are
134
 * not stored in array when there's only one reference to identify.
135
 */
136
private void storeHandle(int idx) {
137
	if (this.localDeclaration == null) return;
138
	IJavaElement handle = locator.createHandle(this.localDeclaration, this.enclosingElement);
139
    if (this.nodesCount == 1) {
140
    	if (this.localElement == null) {
141
    		if (this.annotation == null) {
142
		    	this.localElement =  handle;
143
    		} else {
144
		    	IJavaElement annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) handle);
145
		    	if (annotHandle == null) {
146
			    	annotHandle = this.locator.createHandle(this.annotation, (IAnnotatable) this.enclosingElement);
147
		    	}
148
		    	this.localElement = annotHandle == null ? handle : annotHandle;
149
    		}
150
    	} else {
151
	    	if (++this.ptr == 0) {
152
	    		this.otherElements = new IJavaElement[10];
153
	    	} else {
154
	            int length = this.otherElements.length;
155
	            if (this.ptr == length) {
156
	            	System.arraycopy(this.otherElements, 0, this.otherElements = new IJavaElement[length+10], 0, length);
157
	            }
158
            }
159
	    	this.otherElements[this.ptr] = handle;
160
    	}
161
    } else {
162
    	if (this.localElements[idx] == null) {
163
	    	if (this.annotation == null) {
164
		    	this.localElements[idx] =  handle;
165
    		} else {
166
		    	IJavaElement annotHandle = locator.createHandle(this.annotation, (IAnnotatable) handle);
167
		    	if (annotHandle == null) {
168
			    	annotHandle = locator.createHandle(this.annotation, (IAnnotatable) this.enclosingElement);
169
		    	}
170
		    	this.localElements[idx] = annotHandle == null ? handle : annotHandle;
171
    		}
172
			this.ptrs[idx] = -1;
173
	    } else {
174
	        int oPtr = ++this.ptrs[idx];
175
	    	if (oPtr== 0) {
176
    			this.allOtherElements[idx] = new IJavaElement[10];
177
    		} else {
178
            	int length = this.allOtherElements[idx].length;
179
	            if (oPtr == length) {
180
	            	System.arraycopy(this.allOtherElements[idx], 0, this.allOtherElements[idx] = new IJavaElement[length+10], 0, length);
181
        	    }
182
	        }
183
 		   	this.allOtherElements[idx][oPtr] = handle;
184
    	}
185
    }
186
}
187
public boolean visit(Argument argument, BlockScope scope) {
188
    this.localDeclaration = argument;
189
    return true;
190
}
191
public boolean visit(LocalDeclaration declaration, BlockScope scope) {
192
    this.localDeclaration = declaration;
193
    return true;
194
}
195
public boolean visit(MarkerAnnotation markerAnnotation, BlockScope unused) {
196
	this.annotation = markerAnnotation;
197
	return true;
198
}
199
public boolean visit(NormalAnnotation normalAnnotation, BlockScope unused) {
200
	this.annotation = normalAnnotation;
201
	return true;
202
}
203
public boolean visit(QualifiedNameReference nameReference, BlockScope unused) {
204
	if (this.nodesCount > 0){
205
		int idx = matchNode(nameReference);
206
		if (idx >= 0) {
207
			storeHandle(idx);
208
		}
209
	}
210
	return false;
211
}
212
public boolean visit(QualifiedTypeReference typeReference, BlockScope unused) {
213
	if (this.nodesCount > 0){
214
		int idx = matchNode(typeReference);
215
		if (idx >= 0) {
216
			storeHandle(idx);
217
		}
218
	}
219
	return false;
220
}
221
public boolean visit(SingleMemberAnnotation singleMemberAnnotation, BlockScope unused) {
222
	this.annotation = singleMemberAnnotation;
223
	return true;
224
}
225
public boolean visit(SingleNameReference nameReference, BlockScope unused) {
226
	if (this.nodesCount > 0){
227
		int idx = matchNode(nameReference);
228
		if (idx >= 0) {
229
			storeHandle(idx);
230
		}
231
	}
232
	return false;
233
}
234
public boolean visit(SingleTypeReference typeReference, BlockScope unused) {
235
	if (this.nodesCount > 0){
236
		int idx = matchNode(typeReference);
237
		if (idx >= 0) {
238
			storeHandle(idx);
239
		}
240
	}
241
	return false;
242
}
243
public boolean visit(TypeDeclaration typeDeclaration, BlockScope unused) {
244
	try {
245
		char[] simpleName;
246
		if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {				
247
			simpleName = CharOperation.NO_CHAR;
248
		} else {
249
			simpleName = typeDeclaration.name;
250
		}
251
		int occurrenceCount = occurrencesCounts.get(simpleName);
252
		if (occurrenceCount == HashtableOfIntValues.NO_VALUE) {
253
			occurrenceCount = 1;
254
		} else {
255
			occurrenceCount = occurrenceCount + 1;
256
		}
257
		occurrencesCounts.put(simpleName, occurrenceCount);
258
		if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {				
259
			this.locator.reportMatching(typeDeclaration, this.enclosingElement, -1, nodeSet, occurrenceCount);
260
		} else {
261
			Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeDeclaration);
262
			this.locator.reportMatching(typeDeclaration, this.enclosingElement, level != null ? level.intValue() : -1, nodeSet, occurrenceCount);
263
		}
264
		return false; // don't visit members as this was done during reportMatching(...)
265
	} catch (CoreException e) {
266
		throw new WrappedCoreException(e);
267
	}
268
}
269
}
(-)search/org/eclipse/jdt/core/search/ReferenceMatch.java (+128 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.search;
12
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.*;
15
16
/**
17
 * An abstract Java search match that represents a reference.
18
 * 
19
 * @since 3.4
20
 */
21
public abstract class ReferenceMatch extends SearchMatch {
22
23
/**
24
 * Creates a new reference match.
25
 * 
26
 * @param enclosingElement the inner-most enclosing member that references this java element
27
 * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
28
 * @param offset the offset the match starts at, or -1 if unknown
29
 * @param length the length of the match, or -1 if unknown
30
 * @param insideDocComment <code>true</code> if this search match is inside a doc
31
 * 		comment, and <code>false</code> otherwise
32
 * @param participant the search participant that created the match
33
 * @param resource the resource of the element
34
 */
35
public ReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
36
	super(enclosingElement, accuracy, offset, length, participant, resource);
37
	setInsideDocComment(insideDocComment);
38
}
39
40
/**
41
 * Returns the local element of this search match, or <code>null</code> if none.
42
 * A local element is the inner-most element that contains the reference and that is
43
 * not reachable by navigating from the root of the {@link IJavaModel} using 
44
 * {@link IParent#getChildren()}.
45
 * <p>
46
 * Known element types for local elements are {@link IJavaElement#ANNOTATION}, 
47
 * {@link IJavaElement#LOCAL_VARIABLE} and {@link IJavaElement#TYPE_PARAMETER}.<br>
48
 * However clients should not assume that this set of element types is closed as
49
 * other types of elements may be returned in the future, e.g. if new types
50
 * of elements are added in the Java model. Clients can only assume that the
51
 * {@link IJavaElement#getParent() parent} chain of this local element eventually
52
 * leads to the element from {@link #getElement()}.
53
 * </p><p>
54
 * The local element being an {@link IAnnotation} is the most usual case. For example,
55
 * <ul>
56
 * 	<li>searching for the references to the method <code>Annot.clazz()</code> in
57
 * 			<pre>
58
 *             public class Test {
59
 *                 void method() {
60
 *                     &#0064;Annot(clazz=Test.class) int x;
61
 *                 }
62
 *             }</pre>
63
 * 			will return one {@link MethodReferenceMatch} match whose local element
64
 * 			is the {@link IAnnotation} '<code>Annot</code>'.<br><br>
65
 * 	</li>
66
 *		<li>searching for the references to the type <code>Deprecated</code> in
67
 *				<pre>
68
 *             public class Test {
69
 *                &#0064;Deprecated void method() {}
70
 *             }</pre>
71
 * 			will return one {@link TypeReferenceMatch} match whose local element
72
 * 			is the {@link IAnnotation} '<code>Deprecated</code>'.<br><br>
73
 * 	</li>
74
 * 	<li>searching for the references to the field <code>CONST</code> in
75
 * 			<pre>
76
 *              &#0064;Num(number= Num.CONST)
77
 *              &#0064;interface Num {
78
 *                  public static final int CONST= 42;
79
 *                  int number();
80
 *              }</pre>
81
 * 			will return one {@link FieldReferenceMatch} match whose local element
82
 * 			is the {@link IAnnotation} '<code>Num</code>'.<br><br>
83
 * 	</li>
84
 * </ul>
85
 * </p><p>
86
 * A local element may also be a {@link ILocalVariable} whose type is the referenced
87
 * type. For example,
88
 * <ul>
89
 * 	<li>searching for the references to the type <code>Test</code> in
90
 * 		<pre>
91
 *         public class Test {
92
 *             void foo() {
93
 *                Test local;
94
 *             }
95
 *         }</pre>
96
 * 		will return one {@link TypeReferenceMatch} match whose local element
97
 * 		is the {@link ILocalVariable} '<code>local</code>'.<br><br>
98
 * 	</li>
99
 * </ul>
100
 * Or a local element may be an {@link ITypeParameter} that extends the referenced
101
 * type. For example,
102
 * <ul>
103
 * 	<li>searching for the references to the type <code>Test</code> in 
104
 * 		<pre>
105
 *         public class X&lt; T extends Test&gt; {
106
 *         }</pre>
107
 * 		will return one {@link TypeReferenceMatch} match whose local element
108
 * 		is the {@link ITypeParameter} '<code>T</code>'.<br><br>
109
 * </ul>
110
 * </p>
111
 * 
112
 * @return the local element of this search match, or <code>null</code> if none.
113
 * 
114
 * @since 3.4
115
 */
116
final public IJavaElement getLocalElement() {
117
	return localElement();
118
}
119
120
/**
121
 * Return the stored local element.
122
 * 
123
 * @see org.eclipse.jdt.core.search.ReferenceMatch#getLocalElement()
124
 */
125
protected IJavaElement localElement() {
126
	return null;
127
}
128
}
(-)search/org/eclipse/jdt/internal/core/search/matching/InternalReferenceMatch.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
12
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jdt.core.*;
15
import org.eclipse.jdt.core.search.*;
16
17
/**
18
 * An intermediate class to store data in the search match and access them
19
 * in a private manner.
20
 * 
21
 * @since 3.4
22
 */
23
public abstract class InternalReferenceMatch extends ReferenceMatch {
24
25
	IJavaElement localElement;
26
27
public InternalReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
28
	super(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
29
}
30
31
/**
32
 * Return the stored local element.
33
 * 
34
 * @see org.eclipse.jdt.core.search.ReferenceMatch#getLocalElement()
35
 */
36
protected IJavaElement localElement() {
37
	return this.localElement;
38
}
39
40
/**
41
 * Store the local element in the match.
42
 * 
43
 * @param element The local element to be stored
44
 */
45
public void localElement(IJavaElement element) {
46
	this.localElement = element;
47
}
48
}

Return to bug 209996