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

Wrapping rule should not prevent comments for interfaces on separate lines #1457

Merged
merged 5 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ public class WrappingRule : Rule(
// put entries on separate lines
// TODO: group emit()s below with the one above into one (similar to ParameterListWrappingRule)
for (c in node.children()) {
if (c.elementType == COMMA && !c.treeNext.isWhiteSpaceWithNewline()) {
if (
c.elementType == COMMA &&
paul-dingemans marked this conversation as resolved.
Show resolved Hide resolved
!c.treeNext.isWhiteSpaceWithNewline() &&
!(c.nextLeaf() is PsiWhiteSpace && c.nextLeaf()?.nextLeaf()?.isPartOfComment() == true)
paul-dingemans marked this conversation as resolved.
Show resolved Hide resolved
) {
requireNewlineAfterLeaf(
nodeAfterWhichNewlineIsRequired = c,
autoCorrect = autoCorrect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ internal class WrappingRuleTest {
).isEmpty()
}

@Test
fun testLintClassImplementsListWithComments() {
assertThat(
WrappingRule().lint(
"""
interface ThingOne {}
interface ThingTwo {}
class BusyClass :
ThingOne, // this comment should be legal
paul-dingemans marked this conversation as resolved.
Show resolved Hide resolved
ThingTwo {

}

paul-dingemans marked this conversation as resolved.
Show resolved Hide resolved
""".trimIndent()
)
).isEmpty()
}

paul-dingemans marked this conversation as resolved.
Show resolved Hide resolved
@Test
fun testLintNewlineAfterEqAllowed() {
assertThat(
Expand Down