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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-31 / +442 lines)
Lines 30-35 Link Here
30
 * Non-regression tests for bugs fixed in Java Search engine.
30
 * Non-regression tests for bugs fixed in Java Search engine.
31
 */
31
 */
32
public class JavaSearchBugsTests extends AbstractJavaSearchTests implements IJavaSearchConstants {
32
public class JavaSearchBugsTests extends AbstractJavaSearchTests implements IJavaSearchConstants {
33
	private final static int UI_DECLARATIONS = DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE;
33
	
34
	
34
	public JavaSearchBugsTests(String name) {
35
	public JavaSearchBugsTests(String name) {
35
		super(name);
36
		super(name);
Lines 44-51 Link Here
44
//		org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
45
//		org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
45
//		org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
46
//		org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
46
//		TESTS_PREFIX =  "testBug97547";
47
//		TESTS_PREFIX =  "testBug97547";
47
//		TESTS_NAMES = new String[] { "testBug83304" };
48
//		TESTS_NAMES = new String[] { "testBug100772_ClassAndSubclass04" };
48
//		TESTS_NUMBERS = new int[] { 99600 };
49
		TESTS_NUMBERS = new int[] { 100772 };
49
//		TESTS_RANGE = new int[] { 83304, -1 };
50
//		TESTS_RANGE = new int[] { 83304, -1 };
50
		}
51
		}
51
52
Lines 3329-3362 Link Here
3329
	}
3330
	}
3330
3331
3331
	/**
3332
	/**
3332
	 * Bug 97087: [1.5][search] Can't find reference of generic class's constructor.
3333
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97087"
3334
	 */
3335
	public void testBug97087() throws CoreException {
3336
		workingCopies = new ICompilationUnit[1];
3337
		this.resultCollector.showRule = true;
3338
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java",
3339
			"package b97087;\n" + 
3340
			"public class Bug<Type> {\n" + 
3341
			"    Bug(){}\n" + 
3342
			"}\n" + 
3343
			"class Foo extends Bug<String>{\n" + 
3344
			"    Foo(){}\n" + 
3345
			"}\n" +
3346
			"class Bar extends Bug<Exception>{\n" + 
3347
			"    Bar(){super();}\n" + 
3348
			"}"
3349
		);
3350
		IType type = workingCopies[0].getType("Bug");
3351
		IMethod method= type.getMethods()[0];
3352
		search(method, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3353
		assertSearchResults(
3354
			"src/b97087/Bug.java b97087.Foo() [Foo] EXACT_MATCH\n" + 
3355
			"src/b97087/Bug.java b97087.Bar() [super()] ERASURE_MATCH"
3356
		);
3357
	}
3358
3359
	/**
3360
	 * Bug 96761: [1.5][search] Search for declarations of generic method finds non-overriding method
3333
	 * Bug 96761: [1.5][search] Search for declarations of generic method finds non-overriding method
3361
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=96761"
3334
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=96761"
3362
	 */
3335
	 */
Lines 3416-3422 Link Here
3416
			"src/b96763/Test.java void b96763.Sub.second(Exception) [second] EXACT_MATCH"
3389
			"src/b96763/Test.java void b96763.Sub.second(Exception) [second] EXACT_MATCH"
3417
		);
3390
		);
3418
	}
3391
	}
3419
	public void testBug96763d() throws CoreException {
3392
	public void testBug96763c() throws CoreException {
3420
		workingCopies = new ICompilationUnit[1];
3393
		workingCopies = new ICompilationUnit[1];
3421
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java",
3394
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java",
3422
			"package b96763;\n" + 
3395
			"package b96763;\n" + 
Lines 3436-3441 Link Here
3436
	}
3409
	}
3437
3410
3438
	/**
3411
	/**
3412
	 * Bug 97087: [1.5][search] Can't find reference of generic class's constructor.
3413
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97087"
3414
	 */
3415
	public void testBug97087() throws CoreException {
3416
		workingCopies = new ICompilationUnit[1];
3417
		this.resultCollector.showRule = true;
3418
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java",
3419
			"package b97087;\n" + 
3420
			"public class Bug<Type> {\n" + 
3421
			"    Bug(){}\n" + 
3422
			"}\n" + 
3423
			"class Foo extends Bug<String>{\n" + 
3424
			"    Foo(){}\n" + 
3425
			"}\n" +
3426
			"class Bar extends Bug<Exception>{\n" + 
3427
			"    Bar(){super();}\n" + 
3428
			"}"
3429
		);
3430
		IType type = workingCopies[0].getType("Bug");
3431
		IMethod method= type.getMethods()[0];
3432
		search(method, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3433
		assertSearchResults(
3434
			"src/b97087/Bug.java b97087.Foo() [Foo] EXACT_MATCH\n" + 
3435
			"src/b97087/Bug.java b97087.Bar() [super()] ERASURE_MATCH"
3436
		);
3437
	}
3438
3439
	/**
3440
	 * Bug 97120: 
3441
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97120"
3442
	 */
3443
	public void testBug97120() throws CoreException {
3444
		IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Throwable.class").getType();
3445
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
3446
		TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3447
		new SearchEngine().searchAllTypeNames(
3448
			null,
3449
			"E*".toCharArray(),
3450
			SearchPattern.R_PATTERN_MATCH,
3451
			TYPE,
3452
			scope,
3453
			requestor,
3454
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
3455
			null
3456
		);
3457
		assertSearchResults(
3458
			"Unexpected all type names",
3459
			"java.lang.Error\n" + 
3460
			"java.lang.Exception",
3461
			requestor
3462
		);
3463
	}
3464
3465
	/**
3439
	 * Bug 97322: [search] Search for method references sometimes reports potential match with differing argument count
3466
	 * Bug 97322: [search] Search for method references sometimes reports potential match with differing argument count
3440
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97322"
3467
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97322"
3441
	 */
3468
	 */
Lines 3709-3712 Link Here
3709
			"src/b99600/Test.java int b99600.Test$C2$C3.foo(C1) [foo(C1 c)] EXACT_MATCH"
3736
			"src/b99600/Test.java int b99600.Test$C2$C3.foo(C1) [foo(C1 c)] EXACT_MATCH"
3710
		);
3737
		);
3711
	}
3738
	}
3739
3740
	/**
3741
	 * Bug 100695: [1.5][search] Renaming a field of generic array type has no effect
3742
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=100695"
3743
	 */
3744
	public void testBug100695() throws CoreException {
3745
		workingCopies = new ICompilationUnit[1];
3746
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3747
			"package b100695;\n" + 
3748
			"public class Test {\n" + 
3749
			"	Class<Class>[] foo;\n" + 
3750
			"	Class<Class>[] bar = foo;\n" + 
3751
			"	Test() {\n" + 
3752
			"		foo = null;\n" + 
3753
			"	}\n" + 
3754
			"}\n"
3755
		);
3756
		IField field = workingCopies[0].getType("Test").getField("foo");
3757
		search(field, REFERENCES);
3758
		this.discard = false;
3759
		assertSearchResults(
3760
			"src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + 
3761
			"src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH"
3762
		);
3763
	}
3764
	public void testBug100695a() throws CoreException {
3765
		assertNotNull("There should be working copies!", workingCopies);
3766
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3767
		IField field = workingCopies[0].getType("Test").getField("foo");
3768
		search(field, ALL_OCCURRENCES);
3769
		assertSearchResults(
3770
			"src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + 
3771
			"src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + 
3772
			"src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH"
3773
		);
3774
	}
3775
	public void testBug100695b() throws CoreException {
3776
		workingCopies = new ICompilationUnit[1];
3777
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3778
			"package b100695;\n" + 
3779
			"public class Test {\n" + 
3780
			"	Class<Class> foo;\n" + 
3781
			"	Class<Class> bar = foo;\n" + 
3782
			"	Test() {\n" + 
3783
			"		foo = null;\n" + 
3784
			"	}\n" + 
3785
			"}\n"
3786
		);
3787
		IField field = workingCopies[0].getType("Test").getField("foo");
3788
		search(field, ALL_OCCURRENCES);
3789
		assertSearchResults(
3790
			"src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + 
3791
			"src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + 
3792
			"src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH"
3793
		);
3794
	}
3795
	public void testBug100695c() throws CoreException {
3796
		workingCopies = new ICompilationUnit[1];
3797
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3798
			"package b100695;\n" + 
3799
			"public class Test {\n" + 
3800
			"	Class[] foo;\n" + 
3801
			"	Class[] bar = foo;\n" + 
3802
			"	Test() {\n" + 
3803
			"		foo = null;\n" + 
3804
			"	}\n" + 
3805
			"}\n"
3806
		);
3807
		IField field = workingCopies[0].getType("Test").getField("foo");
3808
		search(field, ALL_OCCURRENCES);
3809
		assertSearchResults(
3810
			"src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + 
3811
			"src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + 
3812
			"src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH"
3813
		);
3814
	}
3815
	public void testBug100695d() throws CoreException {
3816
		workingCopies = new ICompilationUnit[1];
3817
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3818
			"package b100695;\n" + 
3819
			"public class Test {\n" + 
3820
			"	  public Class<Class>[] foo(Class<Class>[] a) {\n" + 
3821
			"		  return a;\n" + 
3822
			"	  }\n" + 
3823
			"	  void bar() {\n" + 
3824
			"		  foo(new Class[0]);\n" + 
3825
			"	  }\n" + 
3826
			"}\n"
3827
		);
3828
		IMethod method = workingCopies[0].getType("Test").getMethods()[0];
3829
		search(method, ALL_OCCURRENCES);
3830
		assertSearchResults(
3831
			"src/b100695/Test.java Class<Class>[] b100695.Test.foo(Class<Class>[]) [foo] EXACT_MATCH\n" + 
3832
			"src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH"
3833
		);
3834
	}
3835
	public void testBug100695e() throws CoreException {
3836
		workingCopies = new ICompilationUnit[1];
3837
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3838
			"package b100695;\n" + 
3839
			"public class Test {\n" + 
3840
			"	  public Class<Class> foo(Class<Class> a) {\n" + 
3841
			"		  return a;\n" + 
3842
			"	  }\n" + 
3843
			"	  void bar() {\n" + 
3844
			"		  foo(null);\n" + 
3845
			"	  }\n" + 
3846
			"}\n"
3847
		);
3848
		IMethod method = workingCopies[0].getType("Test").getMethods()[0];
3849
		search(method, ALL_OCCURRENCES);
3850
		assertSearchResults(
3851
			"src/b100695/Test.java Class<Class> b100695.Test.foo(Class<Class>) [foo] EXACT_MATCH\n" + 
3852
			"src/b100695/Test.java void b100695.Test.bar() [foo(null)] EXACT_MATCH"
3853
		);
3854
	}
3855
	public void testBug100695f() throws CoreException {
3856
		workingCopies = new ICompilationUnit[1];
3857
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java",
3858
			"package b100695;\n" + 
3859
			"public class Test {\n" + 
3860
			"	  public Class[] foo(Class[] a) {\n" + 
3861
			"		  return a;\n" + 
3862
			"	  }\n" + 
3863
			"	  void bar() {\n" + 
3864
			"		  foo(new Class[0]);\n" + 
3865
			"	  }\n" + 
3866
			"}\n"
3867
		);
3868
		IMethod method = workingCopies[0].getType("Test").getMethods()[0];
3869
		search(method, ALL_OCCURRENCES);
3870
		assertSearchResults(
3871
			"src/b100695/Test.java Class[] b100695.Test.foo(Class[]) [foo] EXACT_MATCH\n" + 
3872
			"src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH"
3873
		);
3874
	}
3875
3876
	/**
3877
	 * Bug 100772: [1.5][search] Search for declarations in hierarchy reports to many matches
3878
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=100772"
3879
	 */
3880
	public void testBug100772_ClassAndSubclass01() throws CoreException {
3881
		workingCopies = new ICompilationUnit[1];
3882
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java",
3883
			"package b100772;\n" + 
3884
			"class Test<T> {\n" + 
3885
			"    public void foo(T t) {}\n" + 
3886
			"    public void foo(Class c) {}\n" + 
3887
			"}\n" + 
3888
			"class Sub extends Test<String> {\n" + 
3889
			"    public void foo(String str) {}\n" + 
3890
			"    public void foo(Exception e) {}\n" + 
3891
			"}\n"
3892
		);
3893
		IType type = workingCopies[0].getType("Test");
3894
		IMethod method = type.getMethods()[0];
3895
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3896
		this.discard = false;
3897
		assertSearchResults(
3898
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
3899
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH"
3900
		);
3901
	}
3902
	public void testBug100772_ClassAndSubclass02() throws CoreException {
3903
		assertNotNull("There should be working copies!", workingCopies);
3904
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3905
		IType type = workingCopies[0].getType("Test");
3906
		IMethod method = type.getMethods()[0];
3907
		search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type));
3908
		this.discard = false;
3909
		assertSearchResults(
3910
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
3911
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH"
3912
		);
3913
	}
3914
	public void testBug100772_ClassAndSubclass03() throws CoreException {
3915
		assertNotNull("There should be working copies!", workingCopies);
3916
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3917
		IType type = workingCopies[0].getType("Test");
3918
		IMethod method = type.getMethods()[1];
3919
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3920
		this.discard = false;
3921
		assertSearchResults(
3922
			"src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH"
3923
		);
3924
	}
3925
	public void testBug100772_ClassAndSubclass04() throws CoreException {
3926
//		org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
3927
		assertNotNull("There should be working copies!", workingCopies);
3928
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3929
		IType type = workingCopies[0].getType("Sub");
3930
		IMethod method = type.getMethods()[0];
3931
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3932
		this.discard = false;
3933
		assertSearchResults(
3934
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
3935
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH"
3936
		);
3937
	}
3938
	public void testBug100772_ClassAndSubclass05() throws CoreException {
3939
		assertNotNull("There should be working copies!", workingCopies);
3940
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3941
		IType type = workingCopies[0].getType("Sub");
3942
		IMethod method = type.getMethods()[1];
3943
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3944
		assertSearchResults(
3945
			"src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH"
3946
		);
3947
	}
3948
	public void testBug100772_InterfacesAndClass01() throws CoreException {
3949
		workingCopies = new ICompilationUnit[1];
3950
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java",
3951
			"package b100772;\n" + 
3952
			"interface Test<T> {\n" + 
3953
			"    public void foo(T t);\n" + 
3954
			"    public void foo(Class c);\n" + 
3955
			"}\n" + 
3956
			"interface Sub extends Test<String> {\n" + 
3957
			"    public void foo(String str);\n" + 
3958
			"    public void foo(Exception e);\n" + 
3959
			"}\n" +
3960
			"class X implements Test<String> {\n" + 
3961
			"    public void foo(String str) {}\n" + 
3962
			"    public void foo(Class c) {}\n" + 
3963
			"    public void foo(Exception e) {}\n" + 
3964
			"}\n"
3965
		);
3966
		IType type = workingCopies[0].getType("Test");
3967
		IMethod method = type.getMethods()[0];
3968
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3969
		this.discard = false;
3970
		assertSearchResults(
3971
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
3972
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + 
3973
			"src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH"
3974
		);
3975
	}
3976
	public void testBug100772_InterfacesAndClass02() throws CoreException {
3977
		assertNotNull("There should be working copies!", workingCopies);
3978
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3979
		IType type = workingCopies[0].getType("Test");
3980
		IMethod method = type.getMethods()[0];
3981
		search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type));
3982
		this.discard = false;
3983
		assertSearchResults(
3984
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
3985
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + 
3986
			"src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH"
3987
		);
3988
	}
3989
	public void testBug100772_InterfacesAndClass03() throws CoreException {
3990
		assertNotNull("There should be working copies!", workingCopies);
3991
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
3992
		IType type = workingCopies[0].getType("Test");
3993
		IMethod method = type.getMethods()[1];
3994
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
3995
		this.discard = false;
3996
		assertSearchResults(
3997
			"src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + 
3998
			"src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH"
3999
		);
4000
	}
4001
	public void testBug100772_InterfacesAndClass04() throws CoreException {
4002
		assertNotNull("There should be working copies!", workingCopies);
4003
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4004
		IType type = workingCopies[0].getType("Sub");
4005
		IMethod method = type.getMethods()[0];
4006
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4007
		this.discard = false;
4008
		assertSearchResults(
4009
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
4010
			"src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH"
4011
		);
4012
	}
4013
	public void testBug100772_InterfacesAndClass05() throws CoreException {
4014
		assertNotNull("There should be working copies!", workingCopies);
4015
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4016
		IType type = workingCopies[0].getType("Sub");
4017
		IMethod method = type.getMethods()[1];
4018
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4019
		this.discard = false;
4020
		assertSearchResults(
4021
			"src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH"
4022
		);
4023
	}
4024
	public void testBug100772_InterfacesAndClass06() throws CoreException {
4025
		assertNotNull("There should be working copies!", workingCopies);
4026
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4027
		IType type = workingCopies[0].getType("X");
4028
		IMethod method = type.getMethods()[0];
4029
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4030
		this.discard = false;
4031
		assertSearchResults(
4032
			"src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + 
4033
			"src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH"
4034
		);
4035
	}
4036
	public void testBug100772_InterfacesAndClass07() throws CoreException {
4037
		assertNotNull("There should be working copies!", workingCopies);
4038
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4039
		IType type = workingCopies[0].getType("X");
4040
		IMethod method = type.getMethods()[1];
4041
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4042
		this.discard = false;
4043
		assertSearchResults(
4044
			"src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + 
4045
			"src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH"
4046
		);
4047
	}
4048
	public void testBug100772_InterfacesAndClass08() throws CoreException {
4049
		assertNotNull("There should be working copies!", workingCopies);
4050
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4051
		IType type = workingCopies[0].getType("X");
4052
		IMethod method = type.getMethods()[2];
4053
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4054
		assertSearchResults(
4055
			"src/b100772/Test.java void b100772.X.foo(Exception) [foo] EXACT_MATCH"
4056
		);
4057
	}
4058
	public void testBug100772_Complex01() throws CoreException {
4059
		workingCopies = new ICompilationUnit[1];
4060
		workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java",
4061
			"package b100772;\n" + 
4062
			"public class X<T> implements IX<T> {\n" + 
4063
			"	public void foo(T t) {}\n" + 
4064
			"}\n" + 
4065
			"class XX extends X<String> {\n" + 
4066
			"	public void foo(String s) {}\n" + 
4067
			"	public void foo(Exception e) {}\n" + 
4068
			"}\n" + 
4069
			"interface IX<U> {\n" + 
4070
			"	public void foo(U u);\n" + 
4071
			"}\n" + 
4072
			"class Y implements IX<String> {\n" + 
4073
			"	public void foo(String s) {}\n" + 
4074
			"	public void foo(Exception e) {}\n" + 
4075
			"}\n" + 
4076
			"interface IXX<V extends Exception> extends IX<V> {\n" + 
4077
			"	public void foo(V v);\n" + 
4078
			"}\n" + 
4079
			"class Z extends Y implements IXX<Exception> {\n" + 
4080
			"	public void foo(String s) {}\n" + 
4081
			"	public void foo(Exception e) {}\n" + 
4082
			"}\n"
4083
		);
4084
		IMethod method = workingCopies[0].getType("IX").getMethods()[0];
4085
		search(method, DECLARATIONS);
4086
		this.discard = false;
4087
		assertSearchResults(
4088
			"src/b100772/Test.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + 
4089
			"src/b100772/Test.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + 
4090
			"src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + 
4091
			"src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + 
4092
			"src/b100772/Test.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + 
4093
			"src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH\n" + 
4094
			"src/b100772/Test.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH"
4095
		);
4096
	}
4097
	public void testBug100772_Complex02() throws CoreException {
4098
		assertNotNull("There should be working copies!", workingCopies);
4099
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4100
		IType type = workingCopies[0].getType("Z");
4101
		IMethod method = type.getMethods()[0];
4102
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4103
		this.discard = false;
4104
		assertSearchResults(
4105
			"src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + 
4106
			"src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + 
4107
			"src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH"
4108
		);
4109
	}
4110
	public void testBug100772_Complex03() throws CoreException {
4111
		assertNotNull("There should be working copies!", workingCopies);
4112
		assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length);
4113
		IType type = workingCopies[0].getType("Z");
4114
		IMethod method = type.getMethods()[1];
4115
		search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type));
4116
		assertSearchResults(
4117
			"src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + 
4118
			"src/b100772/Test.java void b100772.Y.foo(Exception) [foo] EXACT_MATCH\n" + 
4119
			"src/b100772/Test.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + 
4120
			"src/b100772/Test.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH"
4121
		);
4122
	}
3712
}
4123
}

Return to bug 100772