Class RemoveAnnotationKotlinMixin

java.lang.Object
org.openrewrite.TreeVisitor<org.openrewrite.java.tree.J,org.openrewrite.ExecutionContext>
org.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
org.openrewrite.kotlin.KotlinVisitor<org.openrewrite.ExecutionContext>
org.openrewrite.kotlin.KotlinIsoVisitor<org.openrewrite.ExecutionContext>
org.openrewrite.kotlin.RemoveAnnotationKotlinMixin

public class RemoveAnnotationKotlinMixin extends KotlinIsoVisitor<org.openrewrite.ExecutionContext>
Visitor mixin composed with RemoveAnnotationVisitor via the TreeVisitorAdapter SPI mechanism (registered at META-INF/services/org.openrewrite.java.RemoveAnnotationVisitor).

Reason: file-scope annotations like @file:OptIn(...) live on K.CompilationUnit.annotations — Kotlin-specific structure that the upstream JavaIsoVisitor-based RemoveAnnotationVisitor never sees. Its declaration-level cleanup hooks (visitClassDeclaration / visitMethodDeclaration / visitVariableDeclarations) only fire for J nodes, leaving stranded blank lines where a file-scope annotation used to sit.

This mixin overrides the K-specific visitCompilationUnit. It calls super to drive the normal Kotlin traversal — which routes each file-level J.Annotation back through the proxy to the base's removal logic — and then, if the annotation list shrank, runs NormalizeFormatVisitor + BlankLinesVisitor on the result to absorb stranded whitespace without paying for full auto-format.