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

wip: Fix Issue with CtClass::compileAndReplaceSnippets #3817

Closed
wants to merge 2 commits into from

Conversation

lapplislazuli
Copy link

@lapplislazuli lapplislazuli commented Mar 2, 2021

Fix #3687
Fix #3688

Hi there,

as requested in #3687 here is the PR.
I thought it would be ok to make on PR for #3687 and #3688 as they are tightly coupled.

For 3687 it does work now, I just added a check that there is a next element.

For 3688 it does not work, and the error is produced in line 99 of src/test/java/spoon/test/snippets/SnippetTest.java .
When I comment the CtPath-Stitching out, another test fails.

However, I think that the issue is a bit more complex with comments being part (or not being part) of the AST.
I feel like there must be an additional filter how to handle comments in this.

@monperrus
Copy link
Collaborator

Thanks for the PR @Twonki! Any idea why CI fails?

@monperrus monperrus changed the title wip: Fix 3687 & 3688 wip: Fix Issue with CtClass::compileAndReplaceSnippets Mar 12, 2021
@lapplislazuli
Copy link
Author

Good morning @monperrus , thanks for reaching out.

The CI is "intentionally" failing as I added a test to produce the bug in #3688 .

In the Bug weird things happen - if I try to add a snippet after a comment, and run compileSnippet, at first it does everything nicely but once I compile it again the snippet is gone and the line below is duplicated.

This is a bit of troubling, as first of all I would expect that compilation doesn't do something when run twice.
Also it seems the issue is a bit deeper than a quick fix,
I think the reason is somewhere in the Placement / Handling of comments in comparison to statements.
It seems where to find next statements in text and next statements in logic do not fully align when comments are in play.

@monperrus
Copy link
Collaborator

Closed per #3888

Thanks for the useful test case!

@monperrus monperrus closed this Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants