Class SourceProviders

java.lang.Object
com.vaadin.copilot.SourceProviders

public final class SourceProviders extends Object
The parsed sources one rewrite operation works on, per language.

Each language's provider caches the files it has parsed, which is what lets several edits to one file accumulate into a single write. That has to survive for the whole operation rather than the whole session: a batch of property changes is one operation and must write once, while a retained parse tree would pin the Kotlin PSI graph in memory until the developer restarted.

Composition rather than one merged provider, because JavaFileSourceProvider.getJavaSource(java.io.File) throwing for .kt is doing useful work: every handler Copilot has not ported yet keeps refusing Kotlin cleanly without a check of its own. Merging them into the SourceFileProvider the design calls for means renaming 121 references and is better done on its own.

  • Constructor Details

    • SourceProviders

      public SourceProviders()
  • Method Details

    • java

      public JavaFileSourceProvider java()
      Returns:
      the Java sources for this operation
    • kotlin

      public KotlinFileSourceProvider kotlin()
      The Kotlin sources for this operation, created on first use.

      Lazily, because the first Kotlin parse builds the compiler's PSI environment — around 240 ms and a few MB — and a project with no Kotlin in it should never pay that.

      Returns:
      the Kotlin sources
    • setWriteMode

      public void setWriteMode(boolean writeMode)
      Parameters:
      writeMode - false to collect edits without writing them, true to write on the next save