Menu

#1149 getBeginLine and getEndLine not working (ECMAScript)

New Tickets
more-info-needed
ECMAScript (9)
PMD
3-Major
Bug
2014-02-01
2013-11-07
No

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

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-02-01

    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

     
  • Andreas Dangel

    Andreas Dangel - 2014-02-01
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
    • Milestone: PMD-5.0.x --> New Tickets
     

Log in to post a comment.