-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
fix: Fix sniper printer failing to prepend whitespace to top-added CtModifiable #3856
Merged
monperrus
merged 10 commits into
INRIA:master
from
slarse:issue/3855-fix-sniper-printer-failing-to-prepend-whitespace
Mar 25, 2021
Merged
fix: Fix sniper printer failing to prepend whitespace to top-added CtModifiable #3856
monperrus
merged 10 commits into
INRIA:master
from
slarse:issue/3855-fix-sniper-printer-failing-to-prepend-whitespace
Mar 25, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slarse
changed the title
fix: Fix sniper printer failing to prepend whitespace top-added CtModifiable
wip: fix: Fix sniper printer failing to prepend whitespace top-added CtModifiable
Mar 23, 2021
slarse
changed the title
wip: fix: Fix sniper printer failing to prepend whitespace top-added CtModifiable
review: fix: Fix sniper printer failing to prepend whitespace top-added CtModifiable
Mar 23, 2021
slarse
changed the title
review: fix: Fix sniper printer failing to prepend whitespace top-added CtModifiable
review: fix: Fix sniper printer failing to prepend whitespace to top-added CtModifiable
Mar 23, 2021
I could try that, but I'd still need a Windows environment to do it (otherwise, no failures :). I do have a Windows system, I just don't have it set up for any kind of development. I'll get around to it eventually! |
monperrus
changed the title
review: fix: Fix sniper printer failing to prepend whitespace to top-added CtModifiable
fix: Fix sniper printer failing to prepend whitespace to top-added CtModifiable
Mar 25, 2021
Thanks @slarse! |
slarse
deleted the
issue/3855-fix-sniper-printer-failing-to-prepend-whitespace
branch
March 25, 2021 07:21
Merged
woutersmeenk
pushed a commit
to woutersmeenk/spoon
that referenced
this pull request
Aug 29, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #3855
This fixes a bug causing the sniper printer to not prepend whitespace to type members and local variables added at the start of a non-empty collection. For example, given this class:
adding a new field
private int otherInt = 3
at the top would be printed like so:The same thing applies to local variables in non-empty statement lists.
The bug is caused by the sniper printer looking the source fragment of any
CtModifiable
orModifierKind
only by role, which causes any source fragment belonging to aCtModifiable
to match any otherCtModifiable
. This itself is required to avoid other corner cases, it appears. Thus, the sniper always thinks it finds a match for a newly createdCtModifiable
when the collection it's added in is non-empty, and then does not print the "synthetic" whitespace.The fix is simply to require any
CtModifiable
to already exist (have a valid source position) to be matched by role alone, see 5a03df6.Note: The test cases fail on Windows due to containing literal newlines. All test cases in the sniper printer tests that contain literal newlines fail on Windows. That's an issue that isn't related to this particular patch, so the new test cases currently ignore Windows. I need to debug the newline problem separately. Most likely, somewhere CRLF line endings are inserted instead of LF line endings, even though the sniper printer should respect the line endings of the original source file.