-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rewrite to no-indent keeps end comment #12954
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Deprecating "empty colonized template bodies" may be undesirable because accepting it was intentional; however, it is an excuse to use the phrase "empty colonized template bodies" outside a sci-fi context or academic paper. |
Could you propose that separately then? Personally I don't like it, but I also don't like that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
@dwijnand Rebased and kept only the feature described. I'll propose deprecating empty body after colon separately; I don't feel strongly about it, except that "end marker is optional" strikes me as a useful rule that should not be violated lightly. (Note to self for later.) Also dropped converting the converse, end comment to end marker, because it was just a heuristic that did not verify the identifier. Probably auto-end-marking is a more useful and consistent feature, for which there is a ticket; maybe the conversion can be done then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Som
pbuf.indexWhere(p => p.span.start == span.start && p.span.end == span.end) match { | ||
case i if i >= 0 => pbuf.update(i, Patch(span, replacement)) | ||
case _ => pbuf += Patch(span, replacement) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this to be the root cause of #17187
object A:
object B:
def a = 2
When rewriting to no-indent, we want to add }\n
and then }\n
at the exact same position. But this piece of code only keep the second patch, which leads to the incorrect:
object A {
object B {
def a = 2
}
Tested also this: class C:
def f = 42
end C And it is rewritten to this: class C {
def f = 42
}
end C |
@adpi2 it looks like it introduced "replace" semantics for "patch at a point". I don't remember now why. There is a tweak to "overlaps" to include overlaps if exactly one point. |
This adds in a test to ensure that the issue reported in scala#17399 is indeed fixed with scala#12954. This case is a bit different, so best to also just have it covered with a test. Closes scala#17399
Preserve end marker as end comment, since if it was worth having an end marker, it's worth commenting.
is rewritten to