|
Lines 1006-1011
Link Here
|
| 1006 |
suite.addTest(new CompletionTests("testBug343637f")); |
1006 |
suite.addTest(new CompletionTests("testBug343637f")); |
| 1007 |
suite.addTest(new CompletionTests("testBug343637g")); |
1007 |
suite.addTest(new CompletionTests("testBug343637g")); |
| 1008 |
suite.addTest(new CompletionTests("testBug343637h")); |
1008 |
suite.addTest(new CompletionTests("testBug343637h")); |
|
|
1009 |
suite.addTest(new CompletionTests("testBug346454")); |
| 1010 |
suite.addTest(new CompletionTests("testBug346454b")); |
| 1011 |
suite.addTest(new CompletionTests("testBug346454c")); |
| 1012 |
suite.addTest(new CompletionTests("testBug346454c_2")); |
| 1013 |
suite.addTest(new CompletionTests("testBug346454d")); |
| 1014 |
suite.addTest(new CompletionTests("testBug346454e")); |
| 1015 |
suite.addTest(new CompletionTests("testBug346454f")); |
| 1016 |
suite.addTest(new CompletionTests("testBug346454g")); |
| 1017 |
suite.addTest(new CompletionTests("testBug346454h")); |
| 1018 |
suite.addTest(new CompletionTests("testBug346454i")); |
| 1009 |
return suite; |
1019 |
return suite; |
| 1010 |
} |
1020 |
} |
| 1011 |
public CompletionTests(String name) { |
1021 |
public CompletionTests(String name) { |
|
Lines 24008-24011
Link Here
|
| 24008 |
COMPLETION_PROJECT.setOptions(options); |
24018 |
COMPLETION_PROJECT.setOptions(options); |
| 24009 |
} |
24019 |
} |
| 24010 |
} |
24020 |
} |
|
|
24021 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24022 |
// Should not get NegativeArraySizeException or show proposals for types |
| 24023 |
public void testBug346454() throws JavaModelException { |
| 24024 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24025 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24026 |
try { |
| 24027 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24028 |
COMPLETION_PROJECT.setOptions(options); |
| 24029 |
this.workingCopies = new ICompilationUnit[1]; |
| 24030 |
this.workingCopies[0] = getWorkingCopy( |
| 24031 |
"/Completion/src/test/Test.java", |
| 24032 |
"package test;"+ |
| 24033 |
"public class Test<T> {\n" + |
| 24034 |
" public void foo() {\n" + |
| 24035 |
" Test<String> x = new Test<>\n" + |
| 24036 |
" }" + |
| 24037 |
"}\n"); |
| 24038 |
|
| 24039 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24040 |
String str = this.workingCopies[0].getSource(); |
| 24041 |
String completeBehind = "new Test<>"; |
| 24042 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24043 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24044 |
assertResults( |
| 24045 |
"", |
| 24046 |
requestor.getResults()); |
| 24047 |
} finally { |
| 24048 |
// Restore compliance settings. |
| 24049 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24050 |
COMPLETION_PROJECT.setOptions(options); |
| 24051 |
} |
| 24052 |
} |
| 24053 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24054 |
// Should not get NegativeArraySizeException |
| 24055 |
public void testBug346454b() throws JavaModelException { |
| 24056 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24057 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24058 |
try { |
| 24059 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24060 |
COMPLETION_PROJECT.setOptions(options); |
| 24061 |
this.workingCopies = new ICompilationUnit[1]; |
| 24062 |
this.workingCopies[0] = getWorkingCopy( |
| 24063 |
"/Completion/src/test/Test.java", |
| 24064 |
"package test;"+ |
| 24065 |
"public class Test<T> {\n" + |
| 24066 |
" public void foo() {\n" + |
| 24067 |
" Test<String> x = new Test<>.\n" + |
| 24068 |
" }" + |
| 24069 |
"}\n"); |
| 24070 |
|
| 24071 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24072 |
String str = this.workingCopies[0].getSource(); |
| 24073 |
String completeBehind = "new Test<>."; |
| 24074 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24075 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24076 |
assertResults( |
| 24077 |
"", |
| 24078 |
requestor.getResults()); |
| 24079 |
} finally { |
| 24080 |
// Restore compliance settings. |
| 24081 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24082 |
COMPLETION_PROJECT.setOptions(options); |
| 24083 |
} |
| 24084 |
} |
| 24085 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24086 |
// Should get proposals for constructor parameters |
| 24087 |
public void testBug346454c() throws JavaModelException { |
| 24088 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24089 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24090 |
try { |
| 24091 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24092 |
COMPLETION_PROJECT.setOptions(options); |
| 24093 |
this.workingCopies = new ICompilationUnit[1]; |
| 24094 |
this.workingCopies[0] = getWorkingCopy( |
| 24095 |
"/Completion/src/test/Test.java", |
| 24096 |
"package test;"+ |
| 24097 |
"public class Test<T> {\n" + |
| 24098 |
" public Test(int i){}\n" + |
| 24099 |
" public void foo() {\n" + |
| 24100 |
" int j = 1;\n" + |
| 24101 |
" new Test<>()\n" + |
| 24102 |
" }" + |
| 24103 |
"}\n"); |
| 24104 |
|
| 24105 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24106 |
String str = this.workingCopies[0].getSource(); |
| 24107 |
String completeBehind = "new Test<>("; |
| 24108 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24109 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24110 |
assertResults( |
| 24111 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Ltest.Test<>;, (I)V, Test, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24112 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Ltest.Test<>;, (I)V, null, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24113 |
requestor.getResults()); |
| 24114 |
} finally { |
| 24115 |
// Restore compliance settings. |
| 24116 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24117 |
COMPLETION_PROJECT.setOptions(options); |
| 24118 |
} |
| 24119 |
} |
| 24120 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24121 |
// Inference fails but be resilient. At least propose unsubstituted methods. |
| 24122 |
public void testBug346454c_2() throws JavaModelException { |
| 24123 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24124 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24125 |
try { |
| 24126 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24127 |
COMPLETION_PROJECT.setOptions(options); |
| 24128 |
this.workingCopies = new ICompilationUnit[1]; |
| 24129 |
this.workingCopies[0] = getWorkingCopy( |
| 24130 |
"/Completion/src/test/Test.java", |
| 24131 |
"package test;"+ |
| 24132 |
"public class Test<T> {\n" + |
| 24133 |
" public Test(T t){}\n" + |
| 24134 |
" public Test(int i){}\n" + |
| 24135 |
" public void foo() {\n" + |
| 24136 |
" new Test<>()\n" + |
| 24137 |
" }" + |
| 24138 |
"}\n"); |
| 24139 |
|
| 24140 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24141 |
String str = this.workingCopies[0].getSource(); |
| 24142 |
String completeBehind = "new Test<>("; |
| 24143 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24144 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24145 |
assertResults( |
| 24146 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Ltest.Test<>;, (I)V, Test, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24147 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Ltest.Test<>;, (TT;)V, Test, (t), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24148 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Ltest.Test<>;, (I)V, null, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24149 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Ltest.Test<>;, (TT;)V, null, (t), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24150 |
requestor.getResults()); |
| 24151 |
} finally { |
| 24152 |
// Restore compliance settings. |
| 24153 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24154 |
COMPLETION_PROJECT.setOptions(options); |
| 24155 |
} |
| 24156 |
} |
| 24157 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24158 |
// Qualified exp case. Should get proposals for constructor parameters. |
| 24159 |
// This tests changes in CompleteOnQualifiedAllocationExpression |
| 24160 |
public void testBug346454d() throws JavaModelException { |
| 24161 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24162 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24163 |
try { |
| 24164 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24165 |
COMPLETION_PROJECT.setOptions(options); |
| 24166 |
this.workingCopies = new ICompilationUnit[2]; |
| 24167 |
this.workingCopies[0] = getWorkingCopy( |
| 24168 |
"/Completion/src/test/X.java", |
| 24169 |
"package test;"+ |
| 24170 |
"public class X<T> {\n" + |
| 24171 |
" public void foo() {\n" + |
| 24172 |
" new pack.Test<>()\n" + |
| 24173 |
" }" + |
| 24174 |
"}\n"); |
| 24175 |
|
| 24176 |
this.workingCopies[1] = getWorkingCopy( |
| 24177 |
"/Completion/src/pack/Test.java", |
| 24178 |
"package pack;"+ |
| 24179 |
"public class Test<T> {\n" + |
| 24180 |
" public Test(T t){}\n" + |
| 24181 |
" public Test(int i){}\n" + |
| 24182 |
"}\n"); |
| 24183 |
|
| 24184 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24185 |
String str = this.workingCopies[0].getSource(); |
| 24186 |
String completeBehind = " new pack.Test<>("; |
| 24187 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24188 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24189 |
assertResults( |
| 24190 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>;, (I)V, Test, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24191 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>;, (TT;)V, Test, (t), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24192 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>;, (I)V, null, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24193 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>;, (TT;)V, null, (t), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24194 |
requestor.getResults()); |
| 24195 |
} finally { |
| 24196 |
// Restore compliance settings. |
| 24197 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24198 |
COMPLETION_PROJECT.setOptions(options); |
| 24199 |
} |
| 24200 |
} |
| 24201 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24202 |
// Qualified exp case. Should get proposals for constructor completion |
| 24203 |
public void testBug346454e() throws JavaModelException { |
| 24204 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24205 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24206 |
try { |
| 24207 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24208 |
COMPLETION_PROJECT.setOptions(options); |
| 24209 |
this.workingCopies = new ICompilationUnit[2]; |
| 24210 |
this.workingCopies[0] = getWorkingCopy( |
| 24211 |
"/Completion/src/test/X.java", |
| 24212 |
"package test;"+ |
| 24213 |
"public class X<T> {\n" + |
| 24214 |
" public void foo() {\n" + |
| 24215 |
" new pack.Test<>.\n" + |
| 24216 |
" }" + |
| 24217 |
"}\n"); |
| 24218 |
|
| 24219 |
this.workingCopies[1] = getWorkingCopy( |
| 24220 |
"/Completion/src/pack/Test.java", |
| 24221 |
"package pack;"+ |
| 24222 |
"public class Test<T> {\n" + |
| 24223 |
" public Test(T t){}\n" + |
| 24224 |
" public Test(int i){}\n" + |
| 24225 |
"}\n"); |
| 24226 |
|
| 24227 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24228 |
String str = this.workingCopies[0].getSource(); |
| 24229 |
String completeBehind = "new pack.Test<>."; |
| 24230 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24231 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24232 |
assertResults( |
| 24233 |
"", |
| 24234 |
requestor.getResults()); |
| 24235 |
} finally { |
| 24236 |
// Restore compliance settings. |
| 24237 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24238 |
COMPLETION_PROJECT.setOptions(options); |
| 24239 |
} |
| 24240 |
} |
| 24241 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24242 |
// Qualified allocation case. Should get proposals for constructor completion |
| 24243 |
// This tests changes in CompleteOnQualifiedAllocationExpression |
| 24244 |
public void testBug346454f() throws JavaModelException { |
| 24245 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24246 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24247 |
try { |
| 24248 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24249 |
COMPLETION_PROJECT.setOptions(options); |
| 24250 |
this.workingCopies = new ICompilationUnit[2]; |
| 24251 |
this.workingCopies[0] = getWorkingCopy( |
| 24252 |
"/Completion/src/test/Test.java", |
| 24253 |
"package test;" + |
| 24254 |
"import pack.Test;\n"+ |
| 24255 |
"public class X {\n" + |
| 24256 |
" public void foo() {\n" + |
| 24257 |
" Test<String>.T2<String> t = new Test<>().new T2<>()\n" + |
| 24258 |
" }" + |
| 24259 |
"}\n"); |
| 24260 |
|
| 24261 |
this.workingCopies[1] = getWorkingCopy( |
| 24262 |
"/Completion/src/pack/Test.java", |
| 24263 |
"package pack;"+ |
| 24264 |
"public class Test<T> {\n" + |
| 24265 |
" public class T2<Z> {\n" + |
| 24266 |
" public T2(Z z){}\n" + |
| 24267 |
" }" + |
| 24268 |
"}\n"); |
| 24269 |
|
| 24270 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24271 |
String str = this.workingCopies[0].getSource(); |
| 24272 |
String completeBehind = "new Test<>().new T2<>("; |
| 24273 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24274 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24275 |
assertResults( |
| 24276 |
"T2[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>.T2;, (TZ;)V, T2, (z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24277 |
"Test<>.T2[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>.T2;, (TZ;)V, null, (z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24278 |
requestor.getResults()); |
| 24279 |
} finally { |
| 24280 |
// Restore compliance settings. |
| 24281 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24282 |
COMPLETION_PROJECT.setOptions(options); |
| 24283 |
} |
| 24284 |
} |
| 24285 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24286 |
// Qualified allocation case. Should get proposals for constructor completion |
| 24287 |
// This tests changes in CompleteOnQualifiedAllocationExpression |
| 24288 |
public void testBug346454g() throws JavaModelException { |
| 24289 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24290 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24291 |
try { |
| 24292 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24293 |
COMPLETION_PROJECT.setOptions(options); |
| 24294 |
this.workingCopies = new ICompilationUnit[2]; |
| 24295 |
this.workingCopies[0] = getWorkingCopy( |
| 24296 |
"/Completion/src/test/Test.java", |
| 24297 |
"package test;" + |
| 24298 |
"public class X {\n" + |
| 24299 |
" public void foo() {\n" + |
| 24300 |
" new pack.Test<>().new T2<>()\n" + |
| 24301 |
" }" + |
| 24302 |
"}\n"); |
| 24303 |
|
| 24304 |
this.workingCopies[1] = getWorkingCopy( |
| 24305 |
"/Completion/src/pack/Test.java", |
| 24306 |
"package pack;"+ |
| 24307 |
"public class Test<T> {\n" + |
| 24308 |
" public Test(T t){}\n" + |
| 24309 |
" public class T2<Z> {\n" + |
| 24310 |
" public T2(Z z){}\n" + |
| 24311 |
" }" + |
| 24312 |
"}\n"); |
| 24313 |
|
| 24314 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24315 |
String str = this.workingCopies[0].getSource(); |
| 24316 |
String completeBehind = "new pack.Test<>().new T2<>("; |
| 24317 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24318 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24319 |
assertResults( |
| 24320 |
"T2[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>.T2;, (TZ;)V, T2, (z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24321 |
"Test<>.T2[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>.T2;, (TZ;)V, null, (z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24322 |
requestor.getResults()); |
| 24323 |
} finally { |
| 24324 |
// Restore compliance settings. |
| 24325 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24326 |
COMPLETION_PROJECT.setOptions(options); |
| 24327 |
} |
| 24328 |
} |
| 24329 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24330 |
// Allocation case with explicit type args and diamond together. Should not throw exception. |
| 24331 |
// This tests changes in CompleteOnQualifiedAllocationExpression |
| 24332 |
public void testBug346454h() throws JavaModelException { |
| 24333 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24334 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24335 |
try { |
| 24336 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24337 |
COMPLETION_PROJECT.setOptions(options); |
| 24338 |
this.workingCopies = new ICompilationUnit[2]; |
| 24339 |
this.workingCopies[0] = getWorkingCopy( |
| 24340 |
"/Completion/src/test/Test.java", |
| 24341 |
"package test;" + |
| 24342 |
"import pack.Test;\n"+ |
| 24343 |
"public class X {\n" + |
| 24344 |
" public void foo() {\n" + |
| 24345 |
" new <String> Test<>()\n" + |
| 24346 |
" }" + |
| 24347 |
"}\n"); |
| 24348 |
|
| 24349 |
this.workingCopies[1] = getWorkingCopy( |
| 24350 |
"/Completion/src/pack/Test.java", |
| 24351 |
"package pack;"+ |
| 24352 |
"public class Test<T> {\n" + |
| 24353 |
" public <Z> Test(T t, Z z) {\n" + |
| 24354 |
" }" + |
| 24355 |
"}\n"); |
| 24356 |
|
| 24357 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24358 |
String str = this.workingCopies[0].getSource(); |
| 24359 |
String completeBehind = "new <String> Test<>("; |
| 24360 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24361 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24362 |
assertResults( |
| 24363 |
"Test[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>;, <Z:Ljava.lang.Object;>(TT;TZ;)V, Test, (t, z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24364 |
"Test<>[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>;, <Z:Ljava.lang.Object;>(TT;TZ;)V, null, (t, z), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24365 |
requestor.getResults()); |
| 24366 |
} finally { |
| 24367 |
// Restore compliance settings. |
| 24368 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24369 |
COMPLETION_PROJECT.setOptions(options); |
| 24370 |
} |
| 24371 |
} |
| 24372 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346454 |
| 24373 |
// Qualified Allocation case with explicit type args and diamond together. Should not throw exception. |
| 24374 |
// This tests changes in CompleteOnQualifiedAllocationExpression |
| 24375 |
public void testBug346454i() throws JavaModelException { |
| 24376 |
Map options = COMPLETION_PROJECT.getOptions(true); |
| 24377 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
| 24378 |
try { |
| 24379 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); |
| 24380 |
COMPLETION_PROJECT.setOptions(options); |
| 24381 |
this.workingCopies = new ICompilationUnit[2]; |
| 24382 |
this.workingCopies[0] = getWorkingCopy( |
| 24383 |
"/Completion/src/test/Test.java", |
| 24384 |
"package test;" + |
| 24385 |
"import pack.Test;\n"+ |
| 24386 |
"public class X {\n" + |
| 24387 |
" public void foo() {\n" + |
| 24388 |
" new <String> Test<>().new T2<>()\n" + |
| 24389 |
" }" + |
| 24390 |
"}\n"); |
| 24391 |
|
| 24392 |
this.workingCopies[1] = getWorkingCopy( |
| 24393 |
"/Completion/src/pack/Test.java", |
| 24394 |
"package pack;"+ |
| 24395 |
"public class Test<T> {\n" + |
| 24396 |
" public <Z> Test(T t) {\n" + |
| 24397 |
" }\n" + |
| 24398 |
" public class T2<U> {\n" + |
| 24399 |
" public T2(U u) {\n" + |
| 24400 |
" }\n" + |
| 24401 |
" }\n" + |
| 24402 |
"}\n"); |
| 24403 |
|
| 24404 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
| 24405 |
String str = this.workingCopies[0].getSource(); |
| 24406 |
String completeBehind = "new <String> Test<>().new T2<>("; |
| 24407 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 24408 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
| 24409 |
assertResults( |
| 24410 |
"T2[METHOD_REF<CONSTRUCTOR>]{, Lpack.Test<>.T2;, (TU;)V, T2, (u), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + |
| 24411 |
"Test<>.T2[ANONYMOUS_CLASS_DECLARATION]{, Lpack.Test<>.T2;, (TU;)V, null, (u), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 24412 |
requestor.getResults()); |
| 24413 |
} finally { |
| 24414 |
// Restore compliance settings. |
| 24415 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
| 24416 |
COMPLETION_PROJECT.setOptions(options); |
| 24417 |
} |
| 24418 |
} |
| 24011 |
} |
24419 |
} |