Skip to content

Commit

Permalink
Don't enforce LF before annotations on primary constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Oct 2, 2023
1 parent fa88e44 commit a66d25d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIsoVisitor;
import org.openrewrite.kotlin.marker.OmitBraces;
import org.openrewrite.kotlin.marker.PrimaryConstructor;
import org.openrewrite.kotlin.style.WrappingAndBracesStyle;

import java.util.List;
Expand Down Expand Up @@ -97,6 +98,10 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
@Override
public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, P p) {
J.MethodDeclaration m = super.visitMethodDeclaration(method, p);
if (m.getMarkers().findFirst(PrimaryConstructor.class).isPresent()) {
return m;
}

m = m.withLeadingAnnotations(withNewlines(m.getLeadingAnnotations()));

List<J.Modifier> modifiers = method.getModifiers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,15 @@ class Test {}
)
);
}

@Test
void primaryConstructorAnnotations() {
rewriteRun(
kotlin(
"""
class T @Suppress constructor()
"""
)
);
}
}

0 comments on commit a66d25d

Please sign in to comment.