-
-
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
bug: Sniper printer drops whitespace after comment if next element is type member with modified modifier list #3697
Comments
Thanks for the bug report, looking forward to the fix! |
So am I, this issue is messing with Sorald's patches :) I've located the problem with the particular case I show in the opening post here, and it's a corner case of corner cases, in particular when there's a comment preceding a modified Overall, the logic for when or when not to print newlines is a bit complicated, and gets really involved when elements are modified, added or deleted. I'm working on a fix, but it's slow going as I still don't fully understand the sniper printer. |
Cool. The expertise you're building while understanding the sniper
architecture will be very valuable for both Sorald and Spoon.
|
I've determined that the import statement newlines is a separate issue, see #3698 |
Alright, after a ton of debugging, I've found that the problem here is as follows: When there is a comment just preceding a type member (method, field, inner type), and the type member's modifiers are altered, things break down. The typical thing that happens is that the whitespace (newline + indentation) between the comment and the type member simply isn't printed. I've however also managed to get the comment to simply disappear. There are also problems with modifiers on local variables. For example, adding the final
// comment here
int a = 2 The problems seem to be very much related to modifier lists, |
The comment disappears entirely whenever an initially non-empty modifier list is emptied. |
This is an entirely separate issue. |
I've encountered a problem where the sniper printer will not insert newlines correctly on modified or new elements. I've encountered this when inserting import statements, as well as when modifying fields. This is a big problem for the fields, because inline comments can cause a modified field to become commented out. For example, if we have this class:
And insert a modifier on the field (say
final
), this is the output:I'm working on figuring out why this happens.
The text was updated successfully, but these errors were encountered: