Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Issue when badly attempt to add comments onto CtLiteral nodes. #4727

Closed
yijiangtian opened this issue May 11, 2022 · 2 comments
Closed

Comments

@yijiangtian
Copy link

Describe the bug
Errors occurs while model building. code like case (1/*org.apache.coyote.Constants.STAGE_PARSE*/) . spoon attemp to add comments onto literal node (maybe since the parentheses).

[ERROR] "/* org.apache.coyote.Constants.STAGE_PARSE */" cannot be added into the AST, with parent class spoon.support.reflect.code.CtLiteralImpl at (/home/ling/Sources/projects/tomcat/java/org/apache/catalina/manager/StatusTransformer.java:403)

To Reproduce

Input:

switch (stage) {
        case (1/*org.apache.coyote.Constants.STAGE_PARSE*/):   // issue
            stageStr = "P";
            fullStatus = false;
            break;
        case (2/*org.apache.coyote.Constants.STAGE_PREPARE*/):
            stageStr = "P";
            fullStatus = false;
            break;
        case (3/*org.apache.coyote.Constants.STAGE_SERVICE*/):
            stageStr = "S";
            break;
}

Processing with Spoon:

/*Code calling spoon on the input and triggering the bug.*/

Output:

/*Output code or stacktrace if unexpected Exception is raised*/

Note that you can also open a pull request reproducing the issue and reference that, instead of writing additional information here.

Operating system, JDK and Spoon version used

  • OS: Unbuntu 20.04
  • JDK:Openjdk-11
  • Spoon version:10.0
@yijiangtian yijiangtian changed the title [Bug] Bug description [Bug] Issue when falsely attempt to add comments onto CtLiteral nodes. May 12, 2022
@yijiangtian yijiangtian changed the title [Bug] Issue when falsely attempt to add comments onto CtLiteral nodes. [Bug] Issue when badly attempt to add comments onto CtLiteral nodes. May 12, 2022
@algomaster99
Copy link
Contributor

Hi @yijiangtian !

Can you check if your issue is resolved now? You may use the latest SNAPSHOT version or 10.2.0-beta-15 in your project's POM. This might have been fixed by #4836 .

@yijiangtian
Copy link
Author

Thanks @algomaster99 The fix seems to have been successful and it works well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants