Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 236-239
Link Here
|
236 |
buf.append("}\n"); |
236 |
buf.append("}\n"); |
237 |
assertEqualString(preview, buf.toString()); |
237 |
assertEqualString(preview, buf.toString()); |
238 |
} |
238 |
} |
|
|
239 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
240 |
public void test0007() throws Exception { |
241 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0007", false, null); |
242 |
StringBuffer buf= new StringBuffer(); |
243 |
buf.append("package test0007;\n"); |
244 |
buf.append("public class X {\n"); |
245 |
buf.append(" List/**/getUsers() {}\n"); |
246 |
buf.append("}\n"); |
247 |
|
248 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
249 |
|
250 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
251 |
|
252 |
astRoot.recordModifications(); |
253 |
|
254 |
AST ast = astRoot.getAST(); |
255 |
|
256 |
List types = astRoot.types(); |
257 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
258 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
259 |
|
260 |
methodDecl.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID)); |
261 |
|
262 |
String preview = evaluateRewrite(cu, astRoot); |
263 |
|
264 |
buf= new StringBuffer(); |
265 |
buf.append("package test0007;\n"); |
266 |
buf.append("public class X {\n"); |
267 |
buf.append(" void getUsers() {}\n"); |
268 |
buf.append("}\n"); |
269 |
assertEqualString(preview, buf.toString()); |
270 |
} |
271 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
272 |
public void test0008() throws Exception { |
273 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0008", false, null); |
274 |
StringBuffer buf= new StringBuffer(); |
275 |
buf.append("package test0008;\n"); |
276 |
buf.append("public class X {\n"); |
277 |
buf.append(" List /**/getUsers() {}\n"); |
278 |
buf.append("}\n"); |
279 |
|
280 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
281 |
|
282 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
283 |
|
284 |
astRoot.recordModifications(); |
285 |
|
286 |
AST ast = astRoot.getAST(); |
287 |
|
288 |
List types = astRoot.types(); |
289 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
290 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
291 |
|
292 |
methodDecl.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID)); |
293 |
|
294 |
String preview = evaluateRewrite(cu, astRoot); |
295 |
|
296 |
buf= new StringBuffer(); |
297 |
buf.append("package test0008;\n"); |
298 |
buf.append("public class X {\n"); |
299 |
buf.append(" void getUsers() {}\n"); |
300 |
buf.append("}\n"); |
301 |
assertEqualString(preview, buf.toString()); |
302 |
} |
303 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
304 |
public void test0009() throws Exception { |
305 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0009", false, null); |
306 |
StringBuffer buf= new StringBuffer(); |
307 |
buf.append("package test0009;\n"); |
308 |
buf.append("public class X {\n"); |
309 |
buf.append(" List/**/ getUsers() {}\n"); |
310 |
buf.append("}\n"); |
311 |
|
312 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
313 |
|
314 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
315 |
|
316 |
astRoot.recordModifications(); |
317 |
|
318 |
AST ast = astRoot.getAST(); |
319 |
|
320 |
List types = astRoot.types(); |
321 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
322 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
323 |
|
324 |
methodDecl.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID)); |
325 |
|
326 |
String preview = evaluateRewrite(cu, astRoot); |
327 |
|
328 |
buf= new StringBuffer(); |
329 |
buf.append("package test0009;\n"); |
330 |
buf.append("public class X {\n"); |
331 |
buf.append(" void getUsers() {}\n"); |
332 |
buf.append("}\n"); |
333 |
assertEqualString(preview, buf.toString()); |
334 |
} |
335 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
336 |
public void test0010() throws Exception { |
337 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0010", false, null); |
338 |
StringBuffer buf= new StringBuffer(); |
339 |
buf.append("package test0010;\n"); |
340 |
buf.append("public class X {\n"); |
341 |
buf.append(" void getUsers(List/**/list) {}\n"); |
342 |
buf.append("}\n"); |
343 |
|
344 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
345 |
|
346 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
347 |
|
348 |
astRoot.recordModifications(); |
349 |
|
350 |
AST ast = astRoot.getAST(); |
351 |
|
352 |
List types = astRoot.types(); |
353 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
354 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
355 |
List parameters = methodDecl.parameters(); |
356 |
SingleVariableDeclaration variableDeclaration = (SingleVariableDeclaration) parameters.get(0); |
357 |
variableDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT)); |
358 |
|
359 |
String preview = evaluateRewrite(cu, astRoot); |
360 |
|
361 |
buf= new StringBuffer(); |
362 |
buf.append("package test0010;\n"); |
363 |
buf.append("public class X {\n"); |
364 |
buf.append(" void getUsers(int list) {}\n"); |
365 |
buf.append("}\n"); |
366 |
assertEqualString(preview, buf.toString()); |
367 |
} |
368 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
369 |
public void test0011() throws Exception { |
370 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0011", false, null); |
371 |
StringBuffer buf= new StringBuffer(); |
372 |
buf.append("package test0011;\n"); |
373 |
buf.append("public class X {\n"); |
374 |
buf.append(" void getUsers(int i, List/**/list) {}\n"); |
375 |
buf.append("}\n"); |
376 |
|
377 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
378 |
|
379 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
380 |
|
381 |
astRoot.recordModifications(); |
382 |
|
383 |
AST ast = astRoot.getAST(); |
384 |
|
385 |
List types = astRoot.types(); |
386 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
387 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
388 |
List parameters = methodDecl.parameters(); |
389 |
SingleVariableDeclaration variableDeclaration = (SingleVariableDeclaration) parameters.get(1); |
390 |
variableDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT)); |
391 |
|
392 |
String preview = evaluateRewrite(cu, astRoot); |
393 |
|
394 |
buf= new StringBuffer(); |
395 |
buf.append("package test0011;\n"); |
396 |
buf.append("public class X {\n"); |
397 |
buf.append(" void getUsers(int i, int list) {}\n"); |
398 |
buf.append("}\n"); |
399 |
assertEqualString(preview, buf.toString()); |
400 |
} |
401 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
402 |
public void test0012() throws Exception { |
403 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0012", false, null); |
404 |
StringBuffer buf= new StringBuffer(); |
405 |
buf.append("package test0012;\n"); |
406 |
buf.append("public class X {\n"); |
407 |
buf.append(" void getUsers(int i, List.../**/list) {}\n"); |
408 |
buf.append("}\n"); |
409 |
|
410 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
411 |
|
412 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
413 |
|
414 |
astRoot.recordModifications(); |
415 |
|
416 |
AST ast = astRoot.getAST(); |
417 |
|
418 |
List types = astRoot.types(); |
419 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
420 |
MethodDeclaration methodDecl= (MethodDeclaration) list.get(0); |
421 |
List parameters = methodDecl.parameters(); |
422 |
SingleVariableDeclaration variableDeclaration = (SingleVariableDeclaration) parameters.get(1); |
423 |
variableDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT)); |
424 |
|
425 |
String preview = evaluateRewrite(cu, astRoot); |
426 |
|
427 |
buf= new StringBuffer(); |
428 |
buf.append("package test0012;\n"); |
429 |
buf.append("public class X {\n"); |
430 |
buf.append(" void getUsers(int i, int.../**/list) {}\n"); |
431 |
buf.append("}\n"); |
432 |
assertEqualString(preview, buf.toString()); |
433 |
} |
434 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192233 |
435 |
public void test0013() throws Exception { |
436 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0013", false, null); |
437 |
StringBuffer buf= new StringBuffer(); |
438 |
buf.append("package test0013;\n"); |
439 |
buf.append("public class X {\n"); |
440 |
buf.append(" List/**/list;\n"); |
441 |
buf.append("}\n"); |
442 |
|
443 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
444 |
|
445 |
CompilationUnit astRoot= createCU(cu, false, AST.JLS3); |
446 |
|
447 |
astRoot.recordModifications(); |
448 |
|
449 |
AST ast = astRoot.getAST(); |
450 |
|
451 |
List types = astRoot.types(); |
452 |
List list= ((TypeDeclaration) types.get(0)).bodyDeclarations(); |
453 |
FieldDeclaration fieldDeclaration= (FieldDeclaration) list.get(0); |
454 |
fieldDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT)); |
455 |
|
456 |
String preview = evaluateRewrite(cu, astRoot); |
457 |
|
458 |
buf= new StringBuffer(); |
459 |
buf.append("package test0013;\n"); |
460 |
buf.append("public class X {\n"); |
461 |
buf.append(" int list;\n"); |
462 |
buf.append("}\n"); |
463 |
assertEqualString(preview, buf.toString()); |
464 |
} |
239 |
} |
465 |
} |