Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.56 diff -u -r1.56 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 3 Jun 2005 00:59:55 -0000 1.56 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 14 Jun 2005 18:46:13 -0000 @@ -70,6 +70,7 @@ import org.eclipse.jdt.core.dom.NullLiteral; import org.eclipse.jdt.core.dom.PackageDeclaration; import org.eclipse.jdt.core.dom.ParenthesizedExpression; +import org.eclipse.jdt.core.dom.PrimitiveType; import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.ReturnStatement; import org.eclipse.jdt.core.dom.SimpleName; @@ -105,7 +106,7 @@ static { // TESTS_NAMES = new String[] {"test0602"}; -// TESTS_NUMBERS = new int[] { 611 }; +// TESTS_NUMBERS = new int[] { 613 }; } public static Test suite() { return buildTestSuite(ASTConverterTestAST3_2.class); @@ -6493,4 +6494,57 @@ workingCopy.discardWorkingCopy(); } } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=99982 + */ + public void test0613() throws JavaModelException { + ICompilationUnit workingCopy = null; + try { + String contents = + "class X {\n" + + " static Object object;\n" + + " static void foo() {\n" + + " /**\n" + + " * javadoc comment.\n" + + " */\n" + + " if (object instanceof String) {\n" + + " final String clr = null;\n" + + " }\n" + + " }\n" + + "}"; + workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); + ASTNode node = buildAST( + contents, + workingCopy); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 0); + node = getASTNode(unit, 0, 1, 0); + assertNotNull("No node", node); + assertEquals("Not an if statement", ASTNode.IF_STATEMENT, node.getNodeType()); + IfStatement ifStatement = (IfStatement) node; + String expectedSource = "if (object instanceof String) {\n" + + " final String clr = null;\n" + + " }"; + checkSourceRange(ifStatement, expectedSource, contents); + Statement statement = ifStatement.getThenStatement(); + assertNotNull("No then statement", statement); + assertEquals("not a block", ASTNode.BLOCK, statement.getNodeType()); + Block block = (Block) statement; + expectedSource = "{\n" + + " final String clr = null;\n" + + " }"; + checkSourceRange(block, expectedSource, contents); + List statements = block.statements(); + assertEquals("Wrong size", 1, statements.size()); + Statement statement2 = (Statement) statements.get(0); + assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, statement2.getNodeType()); + VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) statement2; + checkSourceRange(variableDeclarationStatement, "final String clr = null;", contents); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } + } }