getBeginLine and getEndLine not working (ECMAScript)
A source code analyzer
Brought to you by:
adangel,
juansotuyo
Hello,
Bug #1043 was closed but it still doesn’t work :-(
This PMD Code:
public Object visit(ASTScope node, Object data) { System.out.println("Scope from " + node.getBeginLine() + " to " + node.getEndLine()); return super.visit(node, data); }
Apply to this ECMA script:
1: function f(x){ 2: if (x) { 3: return 1; 4: } else { 5: return 0; 6: } 7: }
Should give this output:
Scope from 2 to 4 Scope from 4 to 6
But give:
Scope from 1 to 1 Scope from 1 to 1
The PMD Rule Designer show the right line numbers.
Tested with PMD 5.0.3 and 5.0.5
Regards
Hm... I can't reproduce this. For me, it works. The Designer uses the same logic (node.getBeginLine(), node.getEndLine(), ...) and it works. A unit test, that creates a sample rule also works.
Can you verify, that you have not accidently an older PMD version in the classpath, when you execute your custom rule?
Thanks,
Andreas