Lines 21-28
Link Here
|
21 |
import org.eclipse.jdt.core.dom.ArrayInitializer; |
21 |
import org.eclipse.jdt.core.dom.ArrayInitializer; |
22 |
import org.eclipse.jdt.core.dom.Block; |
22 |
import org.eclipse.jdt.core.dom.Block; |
23 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
23 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
|
|
24 |
import org.eclipse.jdt.core.dom.EmptyStatement; |
24 |
import org.eclipse.jdt.core.dom.Expression; |
25 |
import org.eclipse.jdt.core.dom.Expression; |
25 |
import org.eclipse.jdt.core.dom.ExpressionStatement; |
26 |
import org.eclipse.jdt.core.dom.ExpressionStatement; |
|
|
27 |
import org.eclipse.jdt.core.dom.ForStatement; |
26 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
28 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
27 |
import org.eclipse.jdt.core.dom.MethodDeclaration; |
29 |
import org.eclipse.jdt.core.dom.MethodDeclaration; |
28 |
import org.eclipse.jdt.core.dom.MethodInvocation; |
30 |
import org.eclipse.jdt.core.dom.MethodInvocation; |
Lines 32-37
Link Here
|
32 |
import org.eclipse.jdt.core.dom.StringLiteral; |
34 |
import org.eclipse.jdt.core.dom.StringLiteral; |
33 |
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; |
35 |
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; |
34 |
import org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
36 |
import org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
|
|
37 |
import org.eclipse.jdt.core.dom.VariableDeclarationExpression; |
35 |
|
38 |
|
36 |
public class ASTConverterRecoveryTest extends ConverterTestSetup { |
39 |
public class ASTConverterRecoveryTest extends ConverterTestSetup { |
37 |
public ASTConverterRecoveryTest(String name) { |
40 |
public ASTConverterRecoveryTest(String name) { |
Lines 352-355
Link Here
|
352 |
checkSourceRange(simpleName, ",", source); //$NON-NLS-1$ |
355 |
checkSourceRange(simpleName, ",", source); //$NON-NLS-1$ |
353 |
|
356 |
|
354 |
} |
357 |
} |
|
|
358 |
|
359 |
// check RECOVERED flag (insert tokens) |
360 |
public void test0006() throws JavaModelException { |
361 |
this.workingCopies = new ICompilationUnit[1]; |
362 |
this.workingCopies[0] = getWorkingCopy( |
363 |
"/Converter/src/test/X.java", |
364 |
"package test;\n"+ |
365 |
"\n"+ |
366 |
"public class X {\n"+ |
367 |
" void foo() {\n"+ |
368 |
" bar()\n"+ |
369 |
" }\n"+ |
370 |
"}\n"); |
371 |
|
372 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
373 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
374 |
|
375 |
assertASTNodeEquals( |
376 |
"package test;\n" + |
377 |
"public class X {\n" + |
378 |
" void foo(){\n" + |
379 |
" bar();\n" + |
380 |
" }\n" + |
381 |
"}\n", |
382 |
result); |
383 |
|
384 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
385 |
assertNotNull(node); |
386 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
387 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
388 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
389 |
Block block = methodDeclaration.getBody(); |
390 |
assertTrue("Flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) == 0); |
391 |
List statements = block.statements(); |
392 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
393 |
Statement statement = (Statement) statements.get(0); |
394 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
395 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
396 |
checkSourceRange(expressionStatement, "bar()", source); //$NON-NLS-1$ |
397 |
assertTrue("Not flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) != 0); |
398 |
Expression expression = expressionStatement.getExpression(); |
399 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
400 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
401 |
checkSourceRange(methodInvocation, "bar()", source); //$NON-NLS-1$ |
402 |
assertTrue("Flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) == 0); |
403 |
} |
404 |
|
405 |
// check RECOVERED flag (insert tokens) |
406 |
public void test0007() throws JavaModelException { |
407 |
this.workingCopies = new ICompilationUnit[1]; |
408 |
this.workingCopies[0] = getWorkingCopy( |
409 |
"/Converter/src/test/X.java", |
410 |
"package test;\n"+ |
411 |
"\n"+ |
412 |
"public class X {\n"+ |
413 |
" void foo() {\n"+ |
414 |
" bar(baz()\n"+ |
415 |
" }\n"+ |
416 |
"}\n"); |
417 |
|
418 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
419 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
420 |
|
421 |
assertASTNodeEquals( |
422 |
"package test;\n" + |
423 |
"public class X {\n" + |
424 |
" void foo(){\n" + |
425 |
" bar(baz());\n" + |
426 |
" }\n" + |
427 |
"}\n", |
428 |
result); |
429 |
|
430 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
431 |
assertNotNull(node); |
432 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
433 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
434 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
435 |
Block block = methodDeclaration.getBody(); |
436 |
assertTrue("Flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) == 0); |
437 |
List statements = block.statements(); |
438 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
439 |
Statement statement = (Statement) statements.get(0); |
440 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
441 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
442 |
checkSourceRange(expressionStatement, "bar(baz()", source); //$NON-NLS-1$ |
443 |
assertTrue("Not flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) != 0); |
444 |
Expression expression = expressionStatement.getExpression(); |
445 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
446 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
447 |
checkSourceRange(methodInvocation, "bar(baz()", source); //$NON-NLS-1$ |
448 |
assertTrue("Not flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) != 0); |
449 |
List arguments = methodInvocation.arguments(); |
450 |
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$ |
451 |
Expression argument = (Expression) arguments.get(0); |
452 |
assertTrue("Not a method invocation", argument.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
453 |
MethodInvocation methodInvocation2 = (MethodInvocation) argument; |
454 |
checkSourceRange(methodInvocation2, "baz()", source); //$NON-NLS-1$ |
455 |
assertTrue("Flag as RECOVERED", (methodInvocation2.getFlags() & ASTNode.RECOVERED) == 0); |
456 |
} |
457 |
|
458 |
// check RECOVERED flag (insert tokens) |
459 |
public void test0008() throws JavaModelException { |
460 |
this.workingCopies = new ICompilationUnit[1]; |
461 |
this.workingCopies[0] = getWorkingCopy( |
462 |
"/Converter/src/test/X.java", |
463 |
"package test;\n"+ |
464 |
"\n"+ |
465 |
"public class X {\n"+ |
466 |
" void foo() {\n"+ |
467 |
" for(int i\n"+ |
468 |
" }\n"+ |
469 |
"}\n"); |
470 |
|
471 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
472 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
473 |
|
474 |
assertASTNodeEquals( |
475 |
"package test;\n" + |
476 |
"public class X {\n" + |
477 |
" void foo(){\n" + |
478 |
" for (int i; ; ) ;\n" + |
479 |
" }\n" + |
480 |
"}\n", |
481 |
result); |
482 |
|
483 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
484 |
assertNotNull(node); |
485 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
486 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
487 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
488 |
Block block = methodDeclaration.getBody(); |
489 |
assertTrue("Not flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) != 0); |
490 |
List statements = block.statements(); |
491 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
492 |
Statement statement = (Statement) statements.get(0); |
493 |
assertTrue("Not a for statement", statement.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$ |
494 |
ForStatement forStatement = (ForStatement) statement; |
495 |
checkSourceRange(forStatement, "for(int i", source); //$NON-NLS-1$ |
496 |
assertTrue("Not flag as RECOVERED", (forStatement.getFlags() & ASTNode.RECOVERED) != 0); |
497 |
List initializers = forStatement.initializers(); |
498 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
499 |
Expression expression = (Expression)initializers.get(0); |
500 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.VARIABLE_DECLARATION_EXPRESSION); //$NON-NLS-1$ |
501 |
VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression)expression; |
502 |
checkSourceRange(variableDeclarationExpression, "int i", source); //$NON-NLS-1$ |
503 |
assertTrue("Not flag as RECOVERED", (variableDeclarationExpression.getFlags() & ASTNode.RECOVERED) != 0); |
504 |
List fragments = variableDeclarationExpression.fragments(); |
505 |
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$ |
506 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment)fragments.get(0); |
507 |
checkSourceRange(fragment, "i", source); //$NON-NLS-1$ |
508 |
assertTrue("Not flag as RECOVERED", (fragment.getFlags() & ASTNode.RECOVERED) != 0); |
509 |
SimpleName name = fragment.getName(); |
510 |
checkSourceRange(name, "i", source); //$NON-NLS-1$ |
511 |
assertTrue("Flag as RECOVERED", (name.getFlags() & ASTNode.RECOVERED) == 0); |
512 |
Statement statement2 = forStatement.getBody(); |
513 |
assertTrue("Not an empty statement", statement2.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$ |
514 |
EmptyStatement emptyStatement = (EmptyStatement)statement2; |
515 |
checkSourceRange(emptyStatement, "i", source); //$NON-NLS-1$ |
516 |
assertTrue("Not flag as RECOVERED", (emptyStatement.getFlags() & ASTNode.RECOVERED) != 0); |
517 |
} |
518 |
|
519 |
// check RECOVERED flag (remove tokens) |
520 |
public void test0009() throws JavaModelException { |
521 |
this.workingCopies = new ICompilationUnit[1]; |
522 |
this.workingCopies[0] = getWorkingCopy( |
523 |
"/Converter/src/test/X.java", |
524 |
"package test;\n"+ |
525 |
"\n"+ |
526 |
"public class X {\n"+ |
527 |
" void foo() {\n"+ |
528 |
" bar(baz());#\n"+ |
529 |
" }\n"+ |
530 |
"}\n"); |
531 |
|
532 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
533 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
534 |
|
535 |
assertASTNodeEquals( |
536 |
"package test;\n" + |
537 |
"public class X {\n" + |
538 |
" void foo(){\n" + |
539 |
" bar(baz());\n" + |
540 |
" }\n" + |
541 |
"}\n", |
542 |
result); |
543 |
|
544 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
545 |
assertNotNull(node); |
546 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
547 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
548 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
549 |
Block block = methodDeclaration.getBody(); |
550 |
assertTrue("Not flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) != 0); |
551 |
List statements = block.statements(); |
552 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
553 |
Statement statement = (Statement) statements.get(0); |
554 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
555 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
556 |
checkSourceRange(expressionStatement, "bar(baz());", source); //$NON-NLS-1$ |
557 |
assertTrue("Flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) == 0); |
558 |
Expression expression = expressionStatement.getExpression(); |
559 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
560 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
561 |
checkSourceRange(methodInvocation, "bar(baz())", source); //$NON-NLS-1$ |
562 |
assertTrue("Flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) == 0); |
563 |
List arguments = methodInvocation.arguments(); |
564 |
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$ |
565 |
Expression argument = (Expression) arguments.get(0); |
566 |
assertTrue("Not a method invocation", argument.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
567 |
MethodInvocation methodInvocation2 = (MethodInvocation) argument; |
568 |
checkSourceRange(methodInvocation2, "baz()", source); //$NON-NLS-1$ |
569 |
assertTrue("Flag as RECOVERED", (methodInvocation2.getFlags() & ASTNode.RECOVERED) == 0); |
570 |
} |
571 |
|
572 |
// check RECOVERED flag (remove tokens) |
573 |
public void test0010() throws JavaModelException { |
574 |
this.workingCopies = new ICompilationUnit[1]; |
575 |
this.workingCopies[0] = getWorkingCopy( |
576 |
"/Converter/src/test/X.java", |
577 |
"package test;\n"+ |
578 |
"\n"+ |
579 |
"public class X {\n"+ |
580 |
" void foo() {\n"+ |
581 |
" bar(baz())#;\n"+ |
582 |
" }\n"+ |
583 |
"}\n"); |
584 |
|
585 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
586 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
587 |
|
588 |
assertASTNodeEquals( |
589 |
"package test;\n" + |
590 |
"public class X {\n" + |
591 |
" void foo(){\n" + |
592 |
" bar(baz());\n" + |
593 |
" }\n" + |
594 |
"}\n", |
595 |
result); |
596 |
|
597 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
598 |
assertNotNull(node); |
599 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
600 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
601 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
602 |
Block block = methodDeclaration.getBody(); |
603 |
assertTrue("Flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) == 0); |
604 |
List statements = block.statements(); |
605 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
606 |
Statement statement = (Statement) statements.get(0); |
607 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
608 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
609 |
checkSourceRange(expressionStatement, "bar(baz())#;", source); //$NON-NLS-1$ |
610 |
assertTrue("Not flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) != 0); |
611 |
Expression expression = expressionStatement.getExpression(); |
612 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
613 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
614 |
checkSourceRange(methodInvocation, "bar(baz())", source); //$NON-NLS-1$ |
615 |
assertTrue("Flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) == 0); |
616 |
List arguments = methodInvocation.arguments(); |
617 |
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$ |
618 |
Expression argument = (Expression) arguments.get(0); |
619 |
assertTrue("Not a method invocation", argument.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
620 |
MethodInvocation methodInvocation2 = (MethodInvocation) argument; |
621 |
checkSourceRange(methodInvocation2, "baz()", source); //$NON-NLS-1$ |
622 |
assertTrue("Flag as RECOVERED", (methodInvocation2.getFlags() & ASTNode.RECOVERED) == 0); |
623 |
} |
624 |
|
625 |
// check RECOVERED flag (remove tokens) |
626 |
public void test0011() throws JavaModelException { |
627 |
this.workingCopies = new ICompilationUnit[1]; |
628 |
this.workingCopies[0] = getWorkingCopy( |
629 |
"/Converter/src/test/X.java", |
630 |
"package test;\n"+ |
631 |
"\n"+ |
632 |
"public class X {\n"+ |
633 |
" void foo() {\n"+ |
634 |
" bar(baz()#);\n"+ |
635 |
" }\n"+ |
636 |
"}\n"); |
637 |
|
638 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
639 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
640 |
|
641 |
assertASTNodeEquals( |
642 |
"package test;\n" + |
643 |
"public class X {\n" + |
644 |
" void foo(){\n" + |
645 |
" bar(baz());\n" + |
646 |
" }\n" + |
647 |
"}\n", |
648 |
result); |
649 |
|
650 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
651 |
assertNotNull(node); |
652 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
653 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
654 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
655 |
Block block = methodDeclaration.getBody(); |
656 |
assertTrue("Flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) == 0); |
657 |
List statements = block.statements(); |
658 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
659 |
Statement statement = (Statement) statements.get(0); |
660 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
661 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
662 |
checkSourceRange(expressionStatement, "bar(baz()#);", source); //$NON-NLS-1$ |
663 |
assertTrue("Flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) == 0); |
664 |
Expression expression = expressionStatement.getExpression(); |
665 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
666 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
667 |
checkSourceRange(methodInvocation, "bar(baz()#)", source); //$NON-NLS-1$ |
668 |
assertTrue("Not flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) != 0); |
669 |
List arguments = methodInvocation.arguments(); |
670 |
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$ |
671 |
Expression argument = (Expression) arguments.get(0); |
672 |
assertTrue("Not a method invocation", argument.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
673 |
MethodInvocation methodInvocation2 = (MethodInvocation) argument; |
674 |
checkSourceRange(methodInvocation2, "baz()", source); //$NON-NLS-1$ |
675 |
assertTrue("Flag as RECOVERED", (methodInvocation2.getFlags() & ASTNode.RECOVERED) == 0); |
676 |
} |
677 |
|
678 |
// check RECOVERED flag (insert tokens) |
679 |
public void test0012() throws JavaModelException { |
680 |
this.workingCopies = new ICompilationUnit[1]; |
681 |
this.workingCopies[0] = getWorkingCopy( |
682 |
"/Converter/src/test/X.java", |
683 |
"package test;\n"+ |
684 |
"\n"+ |
685 |
"public class X {\n"+ |
686 |
" void foo() {\n"+ |
687 |
" bar()#\n"+ |
688 |
" }\n"+ |
689 |
"}\n"); |
690 |
|
691 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
692 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
693 |
|
694 |
assertASTNodeEquals( |
695 |
"package test;\n" + |
696 |
"public class X {\n" + |
697 |
" void foo(){\n" + |
698 |
" bar();\n" + |
699 |
" }\n" + |
700 |
"}\n", |
701 |
result); |
702 |
|
703 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
704 |
assertNotNull(node); |
705 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
706 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
707 |
assertTrue("Flag as RECOVERED", (methodDeclaration.getFlags() & ASTNode.RECOVERED) == 0); |
708 |
Block block = methodDeclaration.getBody(); |
709 |
assertTrue("Flag as RECOVERED", (block.getFlags() & ASTNode.RECOVERED) == 0); |
710 |
List statements = block.statements(); |
711 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
712 |
Statement statement = (Statement) statements.get(0); |
713 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
714 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
715 |
checkSourceRange(expressionStatement, "bar()#", source); //$NON-NLS-1$ |
716 |
assertTrue("Not flag as RECOVERED", (expressionStatement.getFlags() & ASTNode.RECOVERED) != 0); |
717 |
Expression expression = expressionStatement.getExpression(); |
718 |
assertTrue("Not a method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$ |
719 |
MethodInvocation methodInvocation = (MethodInvocation)expression; |
720 |
checkSourceRange(methodInvocation, "bar()", source); //$NON-NLS-1$ |
721 |
assertTrue("Flag as RECOVERED", (methodInvocation.getFlags() & ASTNode.RECOVERED) == 0); |
722 |
} |
355 |
} |
723 |
} |