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

ClassCodeExpressionTransformer does not visit all expressions

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

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2.0-rc-2
    • None
    • ast builder
    • None

    Description

      When testing the ClassCodeExpressionTransformer I found out that not all of my expressions got visited (i.e. DeclarationExpression). I found out that the method visitExpressionStatement() does not call the visit method for the subnodes like the ClassCodeVisitor does.

      When overriding the method visitExpressionStatement() and adding a:

       
        public void visitExpressionStatement(ExpressionStatement es) {
          es.setExpression(transform(es.getExpression()));
        
          es.getExpression().visit(this);
        }  
      

      my transformations worked again. I have not checked if all the other visit...() methods do call the necessary visit() methods for the branches of the AST, but this addition to the ClassCodeExpressionTransformer fixed my problems.

      I added a test case. When you add the part that is commented out, the test runs "good".

      Could you please check the ClassCodeExpressionTransformer?

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            blorgo71 Andreas Vorgeitz

            Dates

              Created:
              Updated:

              Slack

                Issue deployment