Lines 70-75
Link Here
|
70 |
import org.eclipse.jdt.core.dom.NullLiteral; |
70 |
import org.eclipse.jdt.core.dom.NullLiteral; |
71 |
import org.eclipse.jdt.core.dom.PackageDeclaration; |
71 |
import org.eclipse.jdt.core.dom.PackageDeclaration; |
72 |
import org.eclipse.jdt.core.dom.ParenthesizedExpression; |
72 |
import org.eclipse.jdt.core.dom.ParenthesizedExpression; |
|
|
73 |
import org.eclipse.jdt.core.dom.PrimitiveType; |
73 |
import org.eclipse.jdt.core.dom.QualifiedName; |
74 |
import org.eclipse.jdt.core.dom.QualifiedName; |
74 |
import org.eclipse.jdt.core.dom.ReturnStatement; |
75 |
import org.eclipse.jdt.core.dom.ReturnStatement; |
75 |
import org.eclipse.jdt.core.dom.SimpleName; |
76 |
import org.eclipse.jdt.core.dom.SimpleName; |
Lines 105-111
Link Here
|
105 |
|
106 |
|
106 |
static { |
107 |
static { |
107 |
// TESTS_NAMES = new String[] {"test0602"}; |
108 |
// TESTS_NAMES = new String[] {"test0602"}; |
108 |
// TESTS_NUMBERS = new int[] { 611 }; |
109 |
// TESTS_NUMBERS = new int[] { 613 }; |
109 |
} |
110 |
} |
110 |
public static Test suite() { |
111 |
public static Test suite() { |
111 |
return buildTestSuite(ASTConverterTestAST3_2.class); |
112 |
return buildTestSuite(ASTConverterTestAST3_2.class); |
Lines 6493-6496
Link Here
|
6493 |
workingCopy.discardWorkingCopy(); |
6494 |
workingCopy.discardWorkingCopy(); |
6494 |
} |
6495 |
} |
6495 |
} |
6496 |
} |
|
|
6497 |
|
6498 |
/* |
6499 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=99982 |
6500 |
*/ |
6501 |
public void test0613() throws JavaModelException { |
6502 |
ICompilationUnit workingCopy = null; |
6503 |
try { |
6504 |
String contents = |
6505 |
"class X {\n" + |
6506 |
" static Object object;\n" + |
6507 |
" static void foo() {\n" + |
6508 |
" /**\n" + |
6509 |
" * javadoc comment.\n" + |
6510 |
" */\n" + |
6511 |
" if (object instanceof String) {\n" + |
6512 |
" final String clr = null;\n" + |
6513 |
" }\n" + |
6514 |
" }\n" + |
6515 |
"}"; |
6516 |
workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); |
6517 |
ASTNode node = buildAST( |
6518 |
contents, |
6519 |
workingCopy); |
6520 |
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); |
6521 |
CompilationUnit unit = (CompilationUnit) node; |
6522 |
assertProblemsSize(unit, 0); |
6523 |
node = getASTNode(unit, 0, 1, 0); |
6524 |
assertNotNull("No node", node); |
6525 |
assertEquals("Not an if statement", ASTNode.IF_STATEMENT, node.getNodeType()); |
6526 |
IfStatement ifStatement = (IfStatement) node; |
6527 |
String expectedSource = "if (object instanceof String) {\n" + |
6528 |
" final String clr = null;\n" + |
6529 |
" }"; |
6530 |
checkSourceRange(ifStatement, expectedSource, contents); |
6531 |
Statement statement = ifStatement.getThenStatement(); |
6532 |
assertNotNull("No then statement", statement); |
6533 |
assertEquals("not a block", ASTNode.BLOCK, statement.getNodeType()); |
6534 |
Block block = (Block) statement; |
6535 |
expectedSource = "{\n" + |
6536 |
" final String clr = null;\n" + |
6537 |
" }"; |
6538 |
checkSourceRange(block, expectedSource, contents); |
6539 |
List statements = block.statements(); |
6540 |
assertEquals("Wrong size", 1, statements.size()); |
6541 |
Statement statement2 = (Statement) statements.get(0); |
6542 |
assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, statement2.getNodeType()); |
6543 |
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) statement2; |
6544 |
checkSourceRange(variableDeclarationStatement, "final String clr = null;", contents); |
6545 |
} finally { |
6546 |
if (workingCopy != null) |
6547 |
workingCopy.discardWorkingCopy(); |
6548 |
} |
6549 |
} |
6496 |
} |
6550 |
} |