I'm trying to extract the number of lines from my source code in Eclipse with the jdt package.
I found a similar question here : https://stackoverflow.com/questions/11126857/eclipse-astnode-to-source-code-line-number/11131452#11131452 Unni Kris answer wasn't a working solution.
I have a class that extract compilationUnits, with a parser it create an AST. I then proceed to attach a visitor to the ASTNode.
In my visitor class I tried the following:
public boolean visit(CompilationUnit node) {
int lineNumber = node.getLineNumber(node.getStartPosition()) ;
System.out.println("Nombre de Ligne : " + lineNumber);
return super.visit(node);
}
which gave me "1" number of line. The workspace I'm trying to extract metrics from have at least a dozen lines for each class.
Thank you.