Groovy
  1. Groovy
  2. GROOVY-4761

Incorrect source location for method call expression

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.8-rc-2
    • Fix Version/s: 4.0
    • Component/s: parser, parser-antlr
    • Labels:
      None

      Description

      In this class, the source location for the StaticMethodCallExpression is incorrect. The start column coincides with the column for '3' and the end includes the whitespace until the comment starts.

      class StaticTrying {
      	
      	public static Class staticMethod(arg) {
      		
      	}
      	
      	def foo() {
      		def a = staticMethod 3  // extra whitespace
      	}
      }
      

      I'm not too concerned about the invalid end column, but the start column problem is affecting Groovy-Eclipse.

      I delved a little bit into this. Here is when the situation happens:

      1. when the method declaration takes 1 or more parameters
      2. the method declaration can be either static or non-static
      3. the method call takes exactly 1 argument
      4. does not use parens
      5. is part of a declaration expression.

      Because of parts 4 and 5, this problem can only occur on Groovy 1.8 because on 1.7 it would be a parsing error.

      I tracked this down to an invalid source location for the Antlr AST node being passed into AntlrParserPlugin.methodCallExpression().

      I originally reported this bug in GRECLIPSE-1031.

        Activity

        Andrew Eisenberg created issue -
        Andrew Eisenberg made changes -
        Field Original Value New Value
        Link This issue relates to GRECLIPSE-1031 [ GRECLIPSE-1031 ]
        Jochen Theodorou made changes -
        Fix Version/s 4.0 [ 18928 ]
        Assignee blackdrag blackdrag [ blackdrag ]
        Jochen Theodorou made changes -
        Component/s lexer [ 10440 ]
        Component/s parser-antlr [ 11322 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733689 ] Default workflow, editable Closed status [ 12745517 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971236 ] Default workflow, editable Closed status [ 12979051 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Andrew Eisenberg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development