Summary: | AST.lineNumber(position) is not working, if the class didn't have a new line at the end of file. | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Kelvin <kelvin> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | Olivier_Thomann |
Version: | 2.1 | ||
Target Milestone: | 2.1 M4 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Kelvin
2002-11-26 18:48:17 EST
I could not reproduce with latest. Could you please let me know what code you used and which build? I tried the following code: assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$ CompilationUnit compilationUnit = (CompilationUnit) result; ASTNode node = getASTNode(compilationUnit, 0, 0); assertNotNull("No node", node); assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration methodDeclaration = (MethodDeclaration) node; SimpleName name = methodDeclaration.getName(); assertEquals("wrong line number", 3, compilationUnit.lineNumber(name.getStartPosition())); with your first test case (the one without any line break at the end). I got the proper answer. I tried with the binding resolution, it worked as well. I need more information in order to reproduce. Do you have any errors in your code? Add CC. Without further information, I will close it as WORKSFORME. Close as WORKSFORME. Please reopen if you have more information or better steps to reproduce. |