### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/ASTConverter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v retrieving revision 1.238 diff -u -r1.238 ASTConverter.java --- dom/org/eclipse/jdt/core/dom/ASTConverter.java 29 Mar 2006 02:54:50 -0000 1.238 +++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 27 Apr 2006 13:31:40 -0000 @@ -3302,7 +3302,14 @@ comment = docComment; } else { end = -end; - if (positions[0]>0) { // Block comment have positive start position + if (positions[0] == 0) { // we cannot know without testing chars again + if (this.docParser.scanner.source[1] == '/') { + comment = new LineComment(this.ast); + } else { + comment = new BlockComment(this.ast); + } + } + else if (positions[0]>0) { // Block comment have positive start position comment = new BlockComment(this.ast); } else { // Line comment have negative start and end position start = -start; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java,v retrieving revision 1.70 diff -u -r1.70 ASTConverterJavadocTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 29 Mar 2006 04:03:06 -0000 1.70 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 27 Apr 2006 13:31:49 -0000 @@ -114,7 +114,7 @@ // Run test cases subset COPY_DIR = false; System.err.println("WARNING: only subset of tests will be executed!!!"); - suite.addTest(new ASTConverterJavadocTest("testBug125903")); + suite.addTest(new ASTConverterJavadocTest("testBug130752")); return suite; } @@ -3285,4 +3285,64 @@ assertEquals("Tag name should be empty", tag.getTagName(), "@"); } } + + /** + * @bug 130752: [comments] first BlockComment parsed as LineComment + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=130752" + */ + public void testBug130752() throws JavaModelException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b130752/Test.java", + "/* Ceci n'est pas\n" + + " * une ligne. */\n" + + "package javadoc.b130752;\n" + + "public class Test {\n" + + "}\n" + ); + CompilationUnit compilUnit = (CompilationUnit) runConversion(workingCopies[0], true); + verifyWorkingCopiesComments(); + if (docCommentSupport.equals(JavaCore.ENABLED)) { + // Verify comment type + List unitComments = compilUnit.getCommentList(); + assertEquals("Wrong number of comments", 1, unitComments.size()); + Comment comment = (Comment) unitComments.get(0); + assertEquals("Comment should be javadoc", comment.getNodeType(), ASTNode.BLOCK_COMMENT); + } + } + public void testBug130752b() throws JavaModelException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b130752/Test.java", + "// Line comment\n" + + "package javadoc.b130752;\n" + + "public class Test {\n" + + "}\n" + ); + CompilationUnit compilUnit = (CompilationUnit) runConversion(workingCopies[0], true); + verifyWorkingCopiesComments(); + if (docCommentSupport.equals(JavaCore.ENABLED)) { + // Verify comment type + List unitComments = compilUnit.getCommentList(); + assertEquals("Wrong number of comments", 1, unitComments.size()); + Comment comment = (Comment) unitComments.get(0); + assertEquals("Comment should be javadoc", comment.getNodeType(), ASTNode.LINE_COMMENT); + } + } + public void testBug130752c() throws JavaModelException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b130752/Test.java", + "/** Javadoc comment */\n" + + "package javadoc.b130752;\n" + + "public class Test {\n" + + "}\n" + ); + CompilationUnit compilUnit = (CompilationUnit) runConversion(workingCopies[0], true); + verifyWorkingCopiesComments(); + if (docCommentSupport.equals(JavaCore.ENABLED)) { + // Verify comment type + List unitComments = compilUnit.getCommentList(); + assertEquals("Wrong number of comments", 1, unitComments.size()); + Comment comment = (Comment) unitComments.get(0); + assertEquals("Comment should be javadoc", comment.getNodeType(), ASTNode.JAVADOC); + } + } }