Class KotlinModifier

java.lang.Object
com.vaadin.copilot.kotlinrewriter.KotlinModifier
All Implemented Interfaces:
ClassDeclarationModifier

public class KotlinModifier extends Object implements ClassDeclarationModifier
Edits the header of a Kotlin class: the annotations above it and the types it implements.

The Kotlin counterpart of JavaModifier, and like every other writer here it splices text at offsets rather than mutating the tree — so a file Copilot applies a theme to comes back byte-identical except on the lines the theme needed.

The two shapes it has to get right, neither of which Java has:

  • An annotation goes below any annotation already there and directly above the class keyword, which is not simply the start of the declaration: a KDoc comment is a child of the declaration in Kotlin PSI, so the declaration's own offset is the start of the documentation.
  • An interface joins a supertype list, which may be absent (class App), already present (class App : VerticalLayout()), and which follows the primary constructor and the type parameters rather than the name.