groovy
  1. groovy
  2. GROOVY-3437

Line / column issues in the AST

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ast builder, parser-antlr
    • Labels:
      None
    • Number of attachments :
      0

      Description

      While integrating and extending Hamlet's AST browser in the Groovy swing console, I noticed that some AST nodes still not had the right line / column information.

      A few examples:

      • Binary expressions
        assert annotationsOfIdField[0]    instanceof Id
        

        The binary expression between the assert and instanceof: the end of the line / col info is right before instance of, instead of being after the last closing square bracket

      • Statements
        If there are spaces at the end of a line statement, the space is also accounted in the lin / col info, instead of being the last character of the statement
      • Annotations
        Perhaps it's as designed, but I was wondering what should be the start / end of an annotation.
        @Target([ElementType.TYPE])
        

        Here, the annotation node has a start after the @ and the end before the open parentheses.
        Should the whole expression be highlighted, or just the class name of the annotation?

      • GStrings
        GStrings have problems with their various sub parts: the constant strings and the variables interpolated.
        With this example:
        def gs1 = "-$a-${b}-${->c}-" 
        

        The first constant string represents "-$ instead of just the minus sign.
        The second and third constant are -$ instead of just the minus sign again.
        And the last constant is -", instead of just the minus sign, it's going one character too far.
        Now on to the variables.
        Variable a is okay.
        Varible b is actually

        {b}

        and I think it should be just b
        And the closure expression is jut right too.

      • MapEntryExpression
        Whenever there's a map entry, a named parameter, etc, a MapEntryExpression is used, but the line / col of MapEntryExpression is just surrounding the column, instead of the whole key + colon + value.
        Another problem with MEE is that the value goes up to the next comma or closing square bracket (including all potential whitespace), instead of just stopping at the end of the expression or constant.
      • SpreadMapExpression
        def m = [a  :1  , b: 2 ]
        def map = [abc: 1, bcd: 2, *:m , cde: 3]
        

        The SME highlights just the star *, and the m variable is highlighted till the comma, instead of just the m character.

        Issue Links

          Activity

          Hide
          Guillaume Laforge added a comment -

          The case for the annotations is fixed in trunk and 1.6.
          The other ones are probably related to the Antlr grammar (not APP).

          Show
          Guillaume Laforge added a comment - The case for the annotations is fixed in trunk and 1.6. The other ones are probably related to the Antlr grammar (not APP).
          Hide
          Guillaume Laforge added a comment -

          This issue is split into the following issues:
          GROOVY-5313, GROOVY-5312, GROOVY-5311, GROOVY-5310, and GROOVY-5309

          Show
          Guillaume Laforge added a comment - This issue is split into the following issues: GROOVY-5313 , GROOVY-5312 , GROOVY-5311 , GROOVY-5310 , and GROOVY-5309

            People

            • Assignee:
              Guillaume Laforge
              Reporter:
              Guillaume Laforge
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: