Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5726

Source locations of command chain expressions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.4
    • 3.0.10, 4.0.1
    • Compiler
    • None

    Description

      Source locations of command chain expressions are incorrect. Consider the following snippet (no whitespace before or after expression):

      foo bar baz

      Type that into the groovyConsole and inspect the AST. Expand a few sections and see that the this.foo(bar) method call has a columnNumber of 5, whic is incorrect. Expand one more level and see that the foo constant expression has a columnNumber of 1, which is correct.

      In Groovy-Eclipse, we have put a bit of a kludgy patch in to make it work. At the end of the methodCallExpression(AST) method, immediately before the return statement, we added this text:

              // in the case of Groovy 1.8 command expressions, the slocs are incorrect for the start of the method
              if (!implicitThis && methodCallNode.getText().equals("<command>")) {
                  ret.setStart(objectExpression.getStart());
                  ret.setLineNumber(objectExpression.getLineNumber());
                  ret.setColumnNumber(objectExpression.getColumnNumber());
                  ret.setEnd(arguments.getEnd());
                  ret.setLastLineNumber(arguments.getLastLineNumber());
                  ret.setLastColumnNumber(arguments.getLastColumnNumber());
              }
      

      I'm not particularly happy with this solution, but it works for us. Perhaps you can come up with something better.

      Attachments

        Activity

          People

            emilles Eric Milles
            werdna Andrew Eisenberg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: