Lines 37-42
Link Here
|
37 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
37 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
38 |
import org.eclipse.jdt.internal.core.search.indexing.IndexManager; |
38 |
import org.eclipse.jdt.internal.core.search.indexing.IndexManager; |
39 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
39 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
|
|
40 |
import org.eclipse.jdt.internal.core.search.matching.MethodPattern; |
40 |
|
41 |
|
41 |
/** |
42 |
/** |
42 |
* Non-regression tests for bugs fixed in Java Search engine. |
43 |
* Non-regression tests for bugs fixed in Java Search engine. |
Lines 45-51
Link Here
|
45 |
|
46 |
|
46 |
static { |
47 |
static { |
47 |
// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; |
48 |
// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; |
48 |
// TESTS_NAMES = new String[] {"testBug400905_0002"}; |
49 |
// TESTS_NAMES = new String[] {"testBug429012"}; |
49 |
} |
50 |
} |
50 |
|
51 |
|
51 |
public JavaSearchBugs8Tests(String name) { |
52 |
public JavaSearchBugs8Tests(String name) { |
Lines 160-165
Link Here
|
160 |
suite.addTest(new JavaSearchBugs8Tests("test430159b")); |
161 |
suite.addTest(new JavaSearchBugs8Tests("test430159b")); |
161 |
suite.addTest(new JavaSearchBugs8Tests("test430159c")); |
162 |
suite.addTest(new JavaSearchBugs8Tests("test430159c")); |
162 |
suite.addTest(new JavaSearchBugs8Tests("test430159d")); |
163 |
suite.addTest(new JavaSearchBugs8Tests("test430159d")); |
|
|
164 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0001")); |
165 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0002")); |
166 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0003")); |
167 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0004")); |
168 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0005")); |
169 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0006")); |
170 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0007")); |
171 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0008")); |
172 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0009")); |
173 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0010")); |
174 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0011")); |
175 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0012")); |
176 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0013")); |
177 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0014")); |
178 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0015")); |
179 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0016")); |
180 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0017")); |
181 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0018")); |
182 |
suite.addTest(new JavaSearchBugs8Tests("testBug429012_0019")); |
163 |
return suite; |
183 |
return suite; |
164 |
} |
184 |
} |
165 |
class TestCollector extends JavaSearchResultCollector { |
185 |
class TestCollector extends JavaSearchResultCollector { |
Lines 3770-3775
Link Here
|
3770 |
assertSearchResults("" |
3790 |
assertSearchResults("" |
3771 |
); |
3791 |
); |
3772 |
} |
3792 |
} |
|
|
3793 |
/** |
3794 |
* @bug 429012 |
3795 |
* @test tests search for Reference expression - super:: form, without type arguments |
3796 |
* |
3797 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3798 |
* |
3799 |
*/ |
3800 |
public void testBug429012_0001() throws CoreException { |
3801 |
this.workingCopies = new ICompilationUnit[1]; |
3802 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3803 |
"interface I {\n" + |
3804 |
" void foo(int x);\n" + |
3805 |
"}\n" + |
3806 |
"public class X extends Y {\n" + |
3807 |
" public static void main(String [] args) {\n" + |
3808 |
" new X().doit();\n" + |
3809 |
" }\n" + |
3810 |
" void doit() {\n" + |
3811 |
" I i = super::foo;\n" + |
3812 |
" i.foo(10); \n" + |
3813 |
" }\n" + |
3814 |
"}\n" + |
3815 |
"class Y {\n" + |
3816 |
" public void foo(int x) {\n" + |
3817 |
" System.out.println(x);\n" + |
3818 |
" }\n" + |
3819 |
"}\n" |
3820 |
); |
3821 |
IType type = this.workingCopies[0].getType("Y"); |
3822 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
3823 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
3824 |
assertSearchResults( |
3825 |
"src/b429012/X.java void b429012.X.doit() [foo] EXACT_MATCH" |
3826 |
); |
3827 |
} |
3828 |
|
3829 |
/** |
3830 |
* @bug 429012 |
3831 |
* @test tests search for Reference expression - super:: form, with type arguments |
3832 |
* |
3833 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3834 |
* |
3835 |
*/ |
3836 |
public void testBug429012_0002() throws CoreException { |
3837 |
this.workingCopies = new ICompilationUnit[1]; |
3838 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3839 |
"interface I {\n" + |
3840 |
" void foo(int x);\n" + |
3841 |
"}\n" + |
3842 |
"public class X extends Y {\n" + |
3843 |
" public static void main(String [] args) {\n" + |
3844 |
" new X().doit();\n" + |
3845 |
" }\n" + |
3846 |
" void doit() {\n" + |
3847 |
" I i = super::<String>foo;\n" + |
3848 |
" i.foo(10); \n" + |
3849 |
" }\n" + |
3850 |
"}\n" + |
3851 |
"class Y {\n" + |
3852 |
" public void foo(int x) {\n" + |
3853 |
" System.out.println(x);\n" + |
3854 |
" }\n" + |
3855 |
"}\n" |
3856 |
); |
3857 |
IType type = this.workingCopies[0].getType("Y"); |
3858 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
3859 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
3860 |
assertSearchResults( |
3861 |
"src/b429012/X.java void b429012.X.doit() [foo] EXACT_MATCH" |
3862 |
); |
3863 |
} |
3864 |
|
3865 |
/** |
3866 |
* @bug 429012 |
3867 |
* @test tests search for Reference expression - SimpleName:: form, without type arguments. |
3868 |
* |
3869 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3870 |
* |
3871 |
*/ |
3872 |
public void testBug429012_0003() throws CoreException { |
3873 |
this.workingCopies = new ICompilationUnit[1]; |
3874 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3875 |
"interface I {\n" + |
3876 |
" public void doit();\n" + |
3877 |
"}\n" + |
3878 |
"class Y {\n" + |
3879 |
" Y() {}\n" + |
3880 |
" Y(int i) {}\n" + |
3881 |
"}\n" + |
3882 |
"\n" + |
3883 |
"public class X {\n" + |
3884 |
" X(int i) {} \n" + |
3885 |
" static void foo() {}\n" + |
3886 |
" static void foo(int i) {}\n" + |
3887 |
" I i = X :: foo;\n" + |
3888 |
" I j = Y :: new;\n" + |
3889 |
" public static void main() { \n" + |
3890 |
" Y y = new Y(); \n" + |
3891 |
" foo(); \n" + |
3892 |
" }\n" + |
3893 |
"}\n" |
3894 |
); |
3895 |
IType type = this.workingCopies[0].getType("X"); |
3896 |
IMethod method = type.getMethod("foo", null); |
3897 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
3898 |
assertSearchResults( |
3899 |
"src/b429012/X.java b429012.X.i [foo] EXACT_MATCH" |
3900 |
); |
3901 |
} |
3902 |
|
3903 |
/** |
3904 |
* @bug 429012 |
3905 |
* @test tests search for Reference expression - SimpleName:: form, with type arguments. |
3906 |
* |
3907 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3908 |
* |
3909 |
*/ |
3910 |
public void testBug429012_0004() throws CoreException { |
3911 |
this.workingCopies = new ICompilationUnit[1]; |
3912 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3913 |
"interface I {\n" + |
3914 |
" void foo(int x);\n" + |
3915 |
"}\n" + |
3916 |
"public class X {\n" + |
3917 |
" public static void main(String [] args) {\n" + |
3918 |
" I i = Y::<String>foo;\n" + |
3919 |
" i.foo(10); \n" + |
3920 |
" }\n" + |
3921 |
"}\n" + |
3922 |
"class Y {\n" + |
3923 |
" public static void foo(int x) {\n" + |
3924 |
" System.out.println(x);\n" + |
3925 |
" }\n" + |
3926 |
"}\n" |
3927 |
); |
3928 |
IType type = this.workingCopies[0].getType("Y"); |
3929 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
3930 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
3931 |
assertSearchResults( |
3932 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
3933 |
); |
3934 |
} |
3935 |
|
3936 |
/** |
3937 |
* @bug 429012 |
3938 |
* @test tests search for Reference expression - QualifiedName:: form, without type arguments. |
3939 |
* |
3940 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3941 |
* |
3942 |
*/ |
3943 |
public void testBug429012_0005() throws CoreException { |
3944 |
this.workingCopies = new ICompilationUnit[1]; |
3945 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3946 |
"interface I {\n" + |
3947 |
" void foo(int x);\n" + |
3948 |
"}\n" + |
3949 |
"public class X {\n" + |
3950 |
" public static void main(String [] args) {\n" + |
3951 |
" I i = Y.Z::foo;\n" + |
3952 |
" i.foo(10); \n" + |
3953 |
" }\n" + |
3954 |
"}\n" + |
3955 |
"class Y {\n" + |
3956 |
" static class Z {\n" + |
3957 |
" public static void foo(int x) {\n" + |
3958 |
" System.out.println(x);\n" + |
3959 |
" }\n" + |
3960 |
" }\n" + |
3961 |
"}\n" |
3962 |
); |
3963 |
IType type = this.workingCopies[0].getType("Y").getType("Z"); |
3964 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
3965 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
3966 |
assertSearchResults( |
3967 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
3968 |
); |
3969 |
} |
3970 |
|
3971 |
/** |
3972 |
* @bug 429012 |
3973 |
* @test tests search for Reference expression - QualifiedName:: form, with type arguments. |
3974 |
* |
3975 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
3976 |
* |
3977 |
*/ |
3978 |
public void testBug429012_0006() throws CoreException { |
3979 |
this.workingCopies = new ICompilationUnit[1]; |
3980 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
3981 |
"interface I {\n" + |
3982 |
" void foo(int x);\n" + |
3983 |
"}\n" + |
3984 |
"public class X {\n" + |
3985 |
" public static void main(String [] args) {\n" + |
3986 |
" I i = Y.Z::<String>foo;\n" + |
3987 |
" i.foo(10); \n" + |
3988 |
" }\n" + |
3989 |
"}\n" + |
3990 |
"class Y {\n" + |
3991 |
" static class Z {\n" + |
3992 |
" public static void foo(int x) {\n" + |
3993 |
" System.out.println(x);\n" + |
3994 |
" }\n" + |
3995 |
" }\n" + |
3996 |
"}\n" |
3997 |
); |
3998 |
IType type = this.workingCopies[0].getType("Y").getType("Z"); |
3999 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4000 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4001 |
assertSearchResults( |
4002 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4003 |
); |
4004 |
} |
4005 |
|
4006 |
/** |
4007 |
* @bug 429012 |
4008 |
* @test tests search for Reference expression - Primary:: form, without type arguments. |
4009 |
* |
4010 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4011 |
* |
4012 |
*/ |
4013 |
public void testBug429012_0007() throws CoreException { |
4014 |
this.workingCopies = new ICompilationUnit[1]; |
4015 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4016 |
"interface I {\n" + |
4017 |
" void foo(int x);\n" + |
4018 |
"}\n" + |
4019 |
"public class X {\n" + |
4020 |
" public static void main(String [] args) {\n" + |
4021 |
" I i = new Y()::foo;\n" + |
4022 |
" i.foo(10); \n" + |
4023 |
" }\n" + |
4024 |
"}\n" + |
4025 |
"class Y {\n" + |
4026 |
" void foo(int x) {\n" + |
4027 |
" System.out.println(x);\n" + |
4028 |
" }\n" + |
4029 |
"}\n" |
4030 |
); |
4031 |
IType type = this.workingCopies[0].getType("Y"); |
4032 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4033 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4034 |
assertSearchResults( |
4035 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4036 |
); |
4037 |
} |
4038 |
|
4039 |
/** |
4040 |
* @bug 429012 |
4041 |
* @test tests search for Reference expression - Primary:: form, with type arguments. |
4042 |
* |
4043 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4044 |
* |
4045 |
*/ |
4046 |
public void testBug429012_0008() throws CoreException { |
4047 |
this.workingCopies = new ICompilationUnit[1]; |
4048 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4049 |
"interface I {\n" + |
4050 |
" void foo(int x);\n" + |
4051 |
"}\n" + |
4052 |
"public class X {\n" + |
4053 |
" public static void main(String [] args) {\n" + |
4054 |
" I i = new Y()::<String>foo;\n" + |
4055 |
" i.foo(10); \n" + |
4056 |
" }\n" + |
4057 |
"}\n" + |
4058 |
"class Y {\n" + |
4059 |
" void foo(int x) {\n" + |
4060 |
" System.out.println(x);\n" + |
4061 |
" }\n" + |
4062 |
"}\n" |
4063 |
); |
4064 |
IType type = this.workingCopies[0].getType("Y"); |
4065 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4066 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4067 |
assertSearchResults( |
4068 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4069 |
); |
4070 |
} |
4071 |
|
4072 |
/** |
4073 |
* @bug 429012 |
4074 |
* @test tests search for Reference expression - X<T>:: form, without type arguments |
4075 |
* |
4076 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4077 |
* |
4078 |
*/ |
4079 |
public void testBug429012_0009() throws CoreException { |
4080 |
this.workingCopies = new ICompilationUnit[1]; |
4081 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4082 |
"interface I {\n" + |
4083 |
" void foo(Y<String> y, int x);\n" + |
4084 |
"}\n" + |
4085 |
"public class X {\n" + |
4086 |
" public X() {\n" + |
4087 |
" super();\n" + |
4088 |
" }\n" + |
4089 |
" public static void main(String[] args) {\n" + |
4090 |
" I i = Y<String>::foo;\n" + |
4091 |
" i.foo(new Y<String>(), 10);\n" + |
4092 |
" }\n" + |
4093 |
"}\n" + |
4094 |
"class Y<T> {\n" + |
4095 |
" Y() {\n" + |
4096 |
" super();\n" + |
4097 |
" }\n" + |
4098 |
" void foo(int x) {\n" + |
4099 |
" System.out.println(x);\n" + |
4100 |
" }\n" + |
4101 |
"}\n" |
4102 |
); |
4103 |
IType type = this.workingCopies[0].getType("Y"); |
4104 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4105 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4106 |
assertSearchResults( |
4107 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4108 |
); |
4109 |
} |
4110 |
|
4111 |
|
4112 |
/** |
4113 |
* @bug 429012 |
4114 |
* @test tests search for Reference expression - X<T>:: form, with type arguments |
4115 |
* |
4116 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4117 |
* |
4118 |
*/ |
4119 |
public void testBug429012_0010() throws CoreException { |
4120 |
this.workingCopies = new ICompilationUnit[1]; |
4121 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4122 |
"interface I {\n" + |
4123 |
" void foo(Y<String> y, int x);\n" + |
4124 |
"}\n" + |
4125 |
"public class X {\n" + |
4126 |
" public X() {\n" + |
4127 |
" super();\n" + |
4128 |
" }\n" + |
4129 |
" public static void main(String[] args) {\n" + |
4130 |
" I i = Y<String>::<String>foo;\n" + |
4131 |
" i.foo(new Y<String>(), 10);\n" + |
4132 |
" }\n" + |
4133 |
"}\n" + |
4134 |
"class Y<T> {\n" + |
4135 |
" Y() {\n" + |
4136 |
" super();\n" + |
4137 |
" }\n" + |
4138 |
" void foo(int x) {\n" + |
4139 |
" System.out.println(x);\n" + |
4140 |
" }\n" + |
4141 |
"}\n" |
4142 |
); |
4143 |
IType type = this.workingCopies[0].getType("Y"); |
4144 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4145 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4146 |
assertSearchResults( |
4147 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4148 |
); |
4149 |
} |
4150 |
|
4151 |
/** |
4152 |
* @bug 429012 |
4153 |
* @test tests search for Reference expression - X<T>.Name :: form, without type arguments |
4154 |
* |
4155 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4156 |
* |
4157 |
*/ |
4158 |
public void testBug429012_0011() throws CoreException { |
4159 |
this.workingCopies = new ICompilationUnit[1]; |
4160 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4161 |
"interface I {\n" + |
4162 |
" void foo(Y<String>.Z z, int x);\n" + |
4163 |
"}\n" + |
4164 |
"public class X {\n" + |
4165 |
" @SuppressWarnings(\"unused\")\n" + |
4166 |
" public static void main(String [] args) {\n" + |
4167 |
" I i = Y<String>.Z::foo;\n" + |
4168 |
" i.foo(new Y<String>().new Z(), 10); \n" + |
4169 |
" }\n" + |
4170 |
"}\n" + |
4171 |
"class Y<T> {\n" + |
4172 |
" class Z {\n" + |
4173 |
" void foo(int x) {\n" + |
4174 |
" System.out.println(x);\n" + |
4175 |
" }\n" + |
4176 |
" }\n" + |
4177 |
"}\n" + |
4178 |
"\n" |
4179 |
); |
4180 |
IType type = this.workingCopies[0].getType("Y"); |
4181 |
type = type.getType("Z"); |
4182 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4183 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4184 |
assertSearchResults( |
4185 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4186 |
); |
4187 |
} |
4188 |
|
4189 |
/** |
4190 |
* @bug 429012 |
4191 |
* @test tests search for Reference expression - X<T>.Name :: form, with type arguments |
4192 |
* |
4193 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4194 |
* |
4195 |
*/ |
4196 |
public void testBug429012_0012() throws CoreException { |
4197 |
this.workingCopies = new ICompilationUnit[1]; |
4198 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4199 |
"interface I {\n" + |
4200 |
" void foo(Y<String>.Z z, int x);\n" + |
4201 |
"}\n" + |
4202 |
"public class X {\n" + |
4203 |
" @SuppressWarnings(\"unused\")\n" + |
4204 |
" public static void main(String [] args) {\n" + |
4205 |
" I i = Y<String>.Z::<String>foo;\n" + |
4206 |
" i.foo(new Y<String>().new Z(), 10); \n" + |
4207 |
" }\n" + |
4208 |
"}\n" + |
4209 |
"class Y<T> {\n" + |
4210 |
" class Z {\n" + |
4211 |
" void foo(int x) {\n" + |
4212 |
" System.out.println(x);\n" + |
4213 |
" }\n" + |
4214 |
" }\n" + |
4215 |
"}\n" + |
4216 |
"\n" |
4217 |
); |
4218 |
IType type = this.workingCopies[0].getType("Y"); |
4219 |
type = type.getType("Z"); |
4220 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4221 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4222 |
assertSearchResults( |
4223 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4224 |
); |
4225 |
} |
4226 |
|
4227 |
/** |
4228 |
* @bug 429012 |
4229 |
* @test tests search for Reference expression - X<T>.Y<K> :: form, without type arguments |
4230 |
* |
4231 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4232 |
* |
4233 |
*/ |
4234 |
public void testBug429012_0013() throws CoreException { |
4235 |
this.workingCopies = new ICompilationUnit[1]; |
4236 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4237 |
"interface I {\n" + |
4238 |
" void foo(Y<String>.Z<String> z, int x);\n" + |
4239 |
"}\n" + |
4240 |
"public class X {\n" + |
4241 |
" public static void main(String [] args) {\n" + |
4242 |
" I i = Y<String>.Z<String>::foo;\n" + |
4243 |
" i.foo(new Y<String>().new Z<String>(), 10); \n" + |
4244 |
" }\n" + |
4245 |
"}\n" + |
4246 |
"class Y<T> {\n" + |
4247 |
" class Z<K> {\n" + |
4248 |
" void foo(int x) {\n" + |
4249 |
" System.out.println(x);\n" + |
4250 |
" }\n" + |
4251 |
" }\n" + |
4252 |
"}\n" + |
4253 |
"\n" |
4254 |
); |
4255 |
IType type = this.workingCopies[0].getType("Y"); |
4256 |
type = type.getType("Z"); |
4257 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4258 |
search(method, METHOD_REFERENCE_EXPRESSION, ERASURE_RULE); |
4259 |
assertSearchResults( |
4260 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4261 |
); |
4262 |
} |
4263 |
|
4264 |
/** |
4265 |
* @bug 429012 |
4266 |
* @test tests search for Reference expression - X<T>.Y<K> :: form, with type arguments |
4267 |
* |
4268 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4269 |
* |
4270 |
*/ |
4271 |
public void testBug429012_0014() throws CoreException { |
4272 |
this.workingCopies = new ICompilationUnit[1]; |
4273 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4274 |
"interface I {\n" + |
4275 |
" void foo(Y<String>.Z<String> z, int x);\n" + |
4276 |
"}\n" + |
4277 |
"public class X {\n" + |
4278 |
" public static void main(String [] args) {\n" + |
4279 |
" I i = Y<String>.Z<String>::<String>foo;\n" + |
4280 |
" i.foo(new Y<String>().new Z<String>(), 10); \n" + |
4281 |
" }\n" + |
4282 |
"}\n" + |
4283 |
"class Y<T> {\n" + |
4284 |
" class Z<K> {\n" + |
4285 |
" void foo(int x) {\n" + |
4286 |
" System.out.println(x);\n" + |
4287 |
" }\n" + |
4288 |
" }\n" + |
4289 |
"}\n" + |
4290 |
"\n" |
4291 |
); |
4292 |
IType type = this.workingCopies[0].getType("Y"); |
4293 |
type = type.getType("Z"); |
4294 |
IMethod method = type.getMethod("foo", new String[] {"I"}); |
4295 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4296 |
assertSearchResults( |
4297 |
"src/b429012/X.java void b429012.X.main(String[]) [foo] EXACT_MATCH" |
4298 |
); |
4299 |
} |
4300 |
|
4301 |
/** |
4302 |
* @bug 429012 |
4303 |
* @test tests search for Reference expression - X<T>.Y<K> :: new form, with type arguments |
4304 |
* |
4305 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012" |
4306 |
* |
4307 |
*/ |
4308 |
public void testBug429012_0015() throws CoreException { |
4309 |
this.workingCopies = new ICompilationUnit[1]; |
4310 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429012/X.java", |
4311 |
"interface I {\n" + |
4312 |
" void foo(Y<String> y);\n" + |
4313 |
"}\n" + |
4314 |
"public class X {\n" + |
4315 |
" public static void main(String [] args) {\n" + |
4316 |
" I i = Y<String>.Z<String>::<String>new;\n" + |
4317 |
" i.foo(new Y<String>()); \n" + |
4318 |
" }\n" + |
4319 |
"}\n" + |
4320 |
"class Y<T> {\n" + |
4321 |
" class Z<K> {\n" + |
4322 |
" Z(Y<String> y) {\n" + |
4323 |
" System.out.println(\"Y<T>.Z<K>::new\");\n" + |
4324 |
" }\n" + |
4325 |
" Z1(Y<String> y) {\n" + |
4326 |
" System.out.println(\"Y<T>.Z<K>::new\");\n" + |
4327 |
" }\n" + |
4328 |
" }\n" + |
4329 |
"}\n" |
4330 |
); |
4331 |
IType type = this.workingCopies[0].getType("Y"); |
4332 |
type = type.getType("Z"); |
4333 |
IMethod method = type.getMethod("Z", new String[] {"QY<QString;>;"}); |
4334 |
search(method, METHOD_REFERENCE_EXPRESSION, EXACT_RULE); |
4335 |
assertSearchResults( |
4336 |
"src/b429012/X.java void b429012.X.main(String[]) [Y<String>.Z<String>::<String>new] EXACT_MATCH" |
4337 |
); |
4338 |
}// https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012, [1.8][search] Add finegrain (limitTo) option for method reference expressions |
4339 |
public void testBug429012_0016() throws CoreException { |
4340 |
this.workingCopies = new ICompilationUnit[1]; |
4341 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b429498/X.java", |
4342 |
"interface I {\n" + |
4343 |
" public void doit();\n" + |
4344 |
"}\n" + |
4345 |
"public class X {\n" + |
4346 |
" static void foo() {}\n" + |
4347 |
" static void foo(int i) {}\n" + |
4348 |
" I i = X :: foo;\n" + |
4349 |
" static void bar() {foo();}\n" + |
4350 |
"}\n" |
4351 |
); |
4352 |
String str = this.workingCopies[0].getSource(); |
4353 |
String selection = "foo"; |
4354 |
int start = str.indexOf(selection); |
4355 |
int length = selection.length(); |
4356 |
|
4357 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
4358 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], METHOD_REFERENCE_EXPRESSION, ERASURE_RULE); |
4359 |
|
4360 |
new SearchEngine(this.workingCopies).search(pattern, |
4361 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
4362 |
getJavaSearchWorkingCopiesScope(), |
4363 |
this.resultCollector, |
4364 |
null); |
4365 |
assertSearchResults( |
4366 |
"src/b429498/X.java b429498.X.i [foo] EXACT_MATCH" |
4367 |
); |
4368 |
} |
4369 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012, [1.8][search] Add finegrain (limitTo) option for method reference expressions |
4370 |
public void testBug429012_0017() throws CoreException { |
4371 |
this.workingCopies = new ICompilationUnit[1]; |
4372 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", |
4373 |
"interface I { \n" + |
4374 |
" int thrice(int p);\n" + |
4375 |
"}\n" + |
4376 |
"class Y {\n" + |
4377 |
" int goo(int x) { return 3 * x; } \n" + |
4378 |
"}\n" + |
4379 |
"public class X extends Y {\n" + |
4380 |
" public void main(String[] args) { \n" + |
4381 |
" I i = this::goo;\n" + |
4382 |
" i = super::goo;\n" + |
4383 |
" }\n" + |
4384 |
"}\n" |
4385 |
); |
4386 |
|
4387 |
search(this.workingCopies[0].getType("Y").getMethod("goo", new String[] { "I" }), METHOD_REFERENCE_EXPRESSION); |
4388 |
assertSearchResults( |
4389 |
"src/test/Test.java void test.X.main(String[]) [goo] EXACT_MATCH\n" + |
4390 |
"src/test/Test.java void test.X.main(String[]) [goo] EXACT_MATCH" |
4391 |
); |
4392 |
} |
4393 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012, [1.8][search] Add finegrain (limitTo) option for method reference expressions |
4394 |
public void testBug429012_0018() throws CoreException { |
4395 |
this.workingCopies = new ICompilationUnit[1]; |
4396 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", |
4397 |
"interface I { \n" + |
4398 |
" int thrice(int p);\n" + |
4399 |
"}\n" + |
4400 |
"class Y {\n" + |
4401 |
" int goo(int x) { return 3 * x; } \n" + |
4402 |
"}\n" + |
4403 |
"public class X extends Y {\n" + |
4404 |
" public void main(String[] args) { \n" + |
4405 |
" I i = this::goo;\n" + |
4406 |
" i = super::goo;\n" + |
4407 |
" }\n" + |
4408 |
"}\n" |
4409 |
); |
4410 |
|
4411 |
search(this.workingCopies[0].getType("Y").getMethod("goo", new String[] { "I" }), THIS_REFERENCE | METHOD_REFERENCE_EXPRESSION); |
4412 |
assertSearchResults( |
4413 |
"src/test/Test.java void test.X.main(String[]) [goo] EXACT_MATCH\n" + |
4414 |
"src/test/Test.java void test.X.main(String[]) [goo] EXACT_MATCH" |
4415 |
); |
4416 |
} |
4417 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=429012, [1.8][search] Add finegrain (limitTo) option for method reference expressions |
4418 |
public void testBug429012_0019() throws CoreException { |
4419 |
this.workingCopies = new ICompilationUnit[1]; |
4420 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", |
4421 |
"interface I { \n" + |
4422 |
" int thrice(int p);\n" + |
4423 |
"}\n" + |
4424 |
"class Y {\n" + |
4425 |
" static class Z {\n" + |
4426 |
" static int goo(int x) { return 3 * x; } \n" + |
4427 |
" I i = Z::goo;\n" + |
4428 |
" }\n" + |
4429 |
"}\n" + |
4430 |
"public class X extends Y.Z {\n" + |
4431 |
" public void main(String[] args) { \n" + |
4432 |
" I i = Y.Z::goo;\n" + |
4433 |
" }\n" + |
4434 |
"}\n" |
4435 |
); |
4436 |
|
4437 |
search(this.workingCopies[0].getType("Y").getType("Z").getMethod("goo", new String[] { "I" }), METHOD_REFERENCE_EXPRESSION); |
4438 |
assertSearchResults( |
4439 |
"src/test/Test.java test.Y$Z.i [goo] EXACT_MATCH\n" + |
4440 |
"src/test/Test.java void test.X.main(String[]) [goo] EXACT_MATCH" |
4441 |
); |
4442 |
} |
3773 |
// Add new tests in JavaSearchBugs8Tests |
4443 |
// Add new tests in JavaSearchBugs8Tests |
3774 |
} |
4444 |
} |
3775 |
|
4445 |
|