From dff507056b168589e9efb7419031e941aee22ee0 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Tue, 7 May 2024 11:51:59 +0200 Subject: [PATCH] Remove uses of `J.ClassDeclaration#getAnnotations()` This is also covered by `J.ClassDeclaration#getPadding()` --- .../org/openrewrite/kotlin/format/NormalizeFormatVisitor.java | 2 +- .../openrewrite/kotlin/format/WrappingAndBracesVisitor.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openrewrite/kotlin/format/NormalizeFormatVisitor.java b/src/main/java/org/openrewrite/kotlin/format/NormalizeFormatVisitor.java index bd53221c..5587205e 100644 --- a/src/main/java/org/openrewrite/kotlin/format/NormalizeFormatVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/format/NormalizeFormatVisitor.java @@ -63,7 +63,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, P if (!c.getPadding().getKind().getPrefix().isEmpty()) { c = concatenatePrefix(c, c.getPadding().getKind().getPrefix()); - c = c.getAnnotations().withKind(c.getPadding().getKind().withPrefix(Space.EMPTY)); + c = c.getPadding().withKind(c.getPadding().getKind().withPrefix(Space.EMPTY)); return c; } diff --git a/src/main/java/org/openrewrite/kotlin/format/WrappingAndBracesVisitor.java b/src/main/java/org/openrewrite/kotlin/format/WrappingAndBracesVisitor.java index 42ab2053..1b4f97df 100644 --- a/src/main/java/org/openrewrite/kotlin/format/WrappingAndBracesVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/format/WrappingAndBracesVisitor.java @@ -188,7 +188,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, P if (!k.getPrefix().getWhitespace().contains("\n")) { k = k.withPrefix(withNewline(k.getPrefix())); } - c = c.getAnnotations().withKind(k); + c = c.getPadding().withKind(k); } if (!c.getLeadingAnnotations().isEmpty()) { @@ -207,7 +207,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, P Space kindPrefix = kind.getPrefix(); if (!kindPrefix.getWhitespace().contains("\n") && kindPrefix.getComments().isEmpty()) { kindPrefix = kindPrefix.withWhitespace("\n" + kindPrefix.getWhitespace()); - c = c.getAnnotations().withKind(kind.withPrefix(kindPrefix)); + c = c.getPadding().withKind(kind.withPrefix(kindPrefix)); } } }