Community
Participate
Working Groups
20051118 An AST dos not get line numbers when the source only has one line. In the example: The second fails (-2 is returned) public void test1() throws Exception { { String s= "package pack1;\npublic class C {}"; ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource(s.toCharArray()); CompilationUnit node= (CompilationUnit) parser.createAST(null); int lineNumber= node.getLineNumber(0); assertEquals(1, lineNumber); } { String s= "package pack1;public class C {}"; ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource(s.toCharArray()); CompilationUnit node= (CompilationUnit) parser.createAST(null); int lineNumber= node.getLineNumber(0); assertEquals(1, lineNumber); } }
I'll fix it.
Fixed and released in HEAD. Regression tests added in org.eclipse.jdt.core.tests.dom.ASTPositionsTest.test004/005
Verified for 3.2 M4 using build I20051212-0010