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

Line / column issues in the AST

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • None
    • None
    • ast builder, parser-antlr2
    • None

    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.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            guillaume Guillaume Sauthier
            guillaume Guillaume Sauthier
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment