Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 25613 Details for
Bug 100041
[javadoc][dom] Wrong positions when javadoc comment inside method declaration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Bundle all test cases in one patch
v01-model.txt (text/plain), 12.27 KB, created by
Frederic Fusier
on 2005-08-03 08:55:54 EDT
(
hide
)
Description:
Bundle all test cases in one patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-08-03 08:55:54 EDT
Size:
12.27 KB
patch
obsolete
>Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java,v >retrieving revision 1.62 >diff -u -r1.62 ASTConverterJavadocTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 14 Jun 2005 08:11:20 -0000 1.62 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 3 Aug 2005 12:51:57 -0000 >@@ -113,16 +113,7 @@ > // Run test cases subset > COPY_DIR = false; > System.err.println("WARNING: only subset of tests will be executed!!!"); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_15a")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_15b")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_15c")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_15d")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_15e")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_14a")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_14b")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_14c")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_14d")); >- suite.addTest(new ASTConverterJavadocTest("testBug93880_14e")); >+ suite.addTest(new ASTConverterJavadocTest("testBug100041")); > return suite; > } > >@@ -2822,5 +2813,165 @@ > parser.setSource(source.toCharArray()); > parser.createAST(null); > } >- >+ >+ /** >+ * Bug 100041: [javadoc] Infinit loop in DocCommentParser >+ * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=100041" >+ */ >+ public void testBug100041() throws JavaModelException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/X.java", >+ "package javadoc.b100041;\n" + >+ "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" + >+ "}" >+ ); >+ CompilationUnit compilUnit = verifyComments(workingCopies[0]); >+ if (docCommentSupport.equals(JavaCore.ENABLED)) { >+ // Get comment >+ List unitComments = compilUnit.getCommentList(); >+ assertEquals("Wrong number of comments", 1, unitComments.size()); >+ Comment comment = (Comment) unitComments.get(0); >+ int commentStart = comment.getStartPosition(); >+ int commentEnd = commentStart+comment.getLength(); >+ >+ // Get local variable declaration >+ ASTNode node = getASTNode(compilUnit, 0, 1, 0); >+ assertEquals("Expected if statement for node: "+node, ASTNode.IF_STATEMENT, node.getNodeType()); >+ IfStatement ifStatement = (IfStatement) node; >+ assertTrue("Invalid start position for IfStatement: "+ifStatement, ifStatement.getStartPosition() > commentEnd); >+ Statement statement = ifStatement.getThenStatement(); >+ assertEquals("Expected block for node: "+statement, ASTNode.BLOCK, statement.getNodeType()); >+ Block block = (Block) statement; >+ assertTrue("Invalid start position for Block: "+block, block.getStartPosition() > commentEnd); >+ List statements = block.statements(); >+ assertEquals("Invalid number of statements for block: "+block, 1, statements.size()); >+ statement = (Statement) statements.get(0); >+ assertEquals("Expected variable declaration statement for node: "+statement, ASTNode.VARIABLE_DECLARATION_STATEMENT, statement.getNodeType()); >+ VariableDeclarationStatement varDecl = (VariableDeclarationStatement) statement; >+ assertTrue("Invalid start position for : VariableDeclarationStatement"+varDecl, varDecl.getStartPosition() > commentEnd); >+ } >+ } >+ public void testBug100041b() throws JavaModelException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/X.java", >+ "package javadoc.b100041;\n" + >+ "class X {\n" + >+ " static Object object;\n" + >+ " static void foo() {\n" + >+ " /**\n" + >+ " * javadoc comment.\n" + >+ " */\n" + >+ " if (object instanceof String)\n" + >+ " return;\n" + >+ " }\n" + >+ "}" >+ ); >+ CompilationUnit compilUnit = verifyComments(workingCopies[0]); >+ if (docCommentSupport.equals(JavaCore.ENABLED)) { >+ // Get comment >+ List unitComments = compilUnit.getCommentList(); >+ assertEquals("Wrong number of comments", 1, unitComments.size()); >+ Comment comment = (Comment) unitComments.get(0); >+ int commentStart = comment.getStartPosition(); >+ int commentEnd = commentStart+comment.getLength(); >+ >+ // Get local variable declaration >+ ASTNode node = getASTNode(compilUnit, 0, 1, 0); >+ assertEquals("Expected if statement for node: "+node, ASTNode.IF_STATEMENT, node.getNodeType()); >+ IfStatement ifStatement = (IfStatement) node; >+ assertTrue("Invalid start position for IfStatement: "+ifStatement, ifStatement.getStartPosition() > commentEnd); >+ Statement statement = ifStatement.getThenStatement(); >+ assertEquals("Expected block for node: "+statement, ASTNode.RETURN_STATEMENT, statement.getNodeType()); >+ ReturnStatement returnStatement = (ReturnStatement) statement; >+ assertTrue("Invalid start position for Block: "+returnStatement, returnStatement.getStartPosition() > commentEnd); >+ } >+ } >+ public void testBug100041c() throws JavaModelException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/Z.java", >+ "package javadoc.b100041;\n" + >+ "public class Z {\n" + >+ " /** C1 */\n" + >+ " class Z1 {}\n" + >+ " /** C2 */\n" + >+ " Z1 z1;\n" + >+ " /** C3 */\n" + >+ " public static void foo(Object object) {\n" + >+ " /** C4 */\n" + >+ " class ZZ {\n" + >+ " /** C5 */\n" + >+ " ZZ zz;\n" + >+ " /** C6 */\n" + >+ " public void bar() {}\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+ CompilationUnit compilUnit = verifyComments(workingCopies[0]); >+ if (docCommentSupport.equals(JavaCore.ENABLED)) { >+ // Get comments >+ List unitComments = compilUnit.getCommentList(); >+ int size = unitComments.size(); >+ assertEquals("Wrong number of comments", 6, size); >+ Javadoc[] javadocs = new Javadoc[size]; >+ Iterator iterator = unitComments.iterator(); >+ for (int i=0; i<size; i++) { >+ Comment comment = (Comment) iterator.next(); >+ assertEquals("Expect javadoc for comment: "+comment, ASTNode.JAVADOC, comment.getNodeType()); >+ javadocs[i] = (Javadoc) comment; >+ } >+ >+ // Verify member type declaration start >+ ASTNode node = getASTNode(compilUnit, 0, 0); >+ assertEquals("Expected type declaration for node: "+node, ASTNode.TYPE_DECLARATION, node.getNodeType()); >+ TypeDeclaration typeDeclaration = (TypeDeclaration) node; >+ int javadocStart = javadocs[0].getStartPosition(); >+ assertEquals("Invalid start position for TypeDeclaration: "+typeDeclaration, typeDeclaration.getStartPosition(), javadocStart); >+ >+ // Verify field declaration start >+ node = getASTNode(compilUnit, 0, 1); >+ assertEquals("Expected field declaration for node: "+node, ASTNode.FIELD_DECLARATION, node.getNodeType()); >+ FieldDeclaration fieldDeclaration = (FieldDeclaration) node; >+ javadocStart = javadocs[1].getStartPosition(); >+ assertEquals("Invalid start position for FieldDeclaration: "+fieldDeclaration, fieldDeclaration.getStartPosition(), javadocStart); >+ >+ // Verify method declaration start >+ node = getASTNode(compilUnit, 0, 2); >+ assertEquals("Expected method declaration for node: "+node, ASTNode.METHOD_DECLARATION, node.getNodeType()); >+ MethodDeclaration methodDeclaration = (MethodDeclaration) node; >+ javadocStart = javadocs[2].getStartPosition(); >+ assertEquals("Invalid start position for MethodDeclaration: "+methodDeclaration, methodDeclaration.getStartPosition(), javadocStart); >+ >+ // Verify local type declaration start >+ node = getASTNode(compilUnit, 0, 2, 0); >+ assertEquals("Expected type declaration for node: "+node, ASTNode.TYPE_DECLARATION_STATEMENT, node.getNodeType()); >+ typeDeclaration = (TypeDeclaration) ((TypeDeclarationStatement) node).getDeclaration(); >+ javadocStart = javadocs[3].getStartPosition(); >+ assertEquals("Invalid start position for TypeDeclaration: "+typeDeclaration, typeDeclaration.getStartPosition(), javadocStart); >+ >+ // Verify field declaration start >+ List bodyDeclarations = typeDeclaration.bodyDeclarations(); >+ node = (ASTNode) bodyDeclarations.get(0); >+ assertEquals("Expected field declaration for node: "+node, ASTNode.FIELD_DECLARATION, node.getNodeType()); >+ fieldDeclaration = (FieldDeclaration) node; >+ javadocStart = javadocs[4].getStartPosition(); >+ assertEquals("Invalid start position for FieldDeclaration: "+fieldDeclaration, fieldDeclaration.getStartPosition(), javadocStart); >+ >+ // Verify method declaration start >+ node = (ASTNode) bodyDeclarations.get(1); >+ assertEquals("Expected method declaration for node: "+node, ASTNode.METHOD_DECLARATION, node.getNodeType()); >+ methodDeclaration = (MethodDeclaration) node; >+ javadocStart = javadocs[5].getStartPosition(); >+ assertEquals("Invalid start position for MethodDeclaration: "+methodDeclaration, methodDeclaration.getStartPosition(), javadocStart); >+ } >+ } > } >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.57.2.1 >diff -u -r1.57.2.1 ASTConverterTestAST3_2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 30 Jun 2005 21:09:46 -0000 1.57.2.1 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 3 Aug 2005 12:52:03 -0000 >@@ -106,7 +106,7 @@ > > static { > // TESTS_NAMES = new String[] {"test0602"}; >-// TESTS_NUMBERS = new int[] { 611 }; >+// TESTS_NUMBERS = new int[] { 614 }; > } > public static Test suite() { > return buildTestSuite(ASTConverterTestAST3_2.class); >@@ -6591,4 +6591,57 @@ > workingCopy.discardWorkingCopy(); > } > } >+ >+ /* >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=100041 >+ */ >+ public void test0614() 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(); >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 100041
:
23090
|
23091
|
25611
|
25612
| 25613