Class JavaFileSourceProvider

java.lang.Object
com.vaadin.copilot.javarewriter.JavaFileSourceProvider

public class JavaFileSourceProvider extends Object
Provider that makes sure same JavaRewriter is served for the same file so same file should not be overwritten in the same operation.
  • Field Details

    • UNDO_LABEL

      public static final String UNDO_LABEL
  • Constructor Details

    • JavaFileSourceProvider

      public JavaFileSourceProvider()
      Creates a new Java file source provider that does not use the built in lexical preservation parser.
    • JavaFileSourceProvider

      public JavaFileSourceProvider(boolean javaParserLexicalPreservation)
      Creates a new Java file source provider.
      Parameters:
      javaParserLexicalPreservation - true to use the built in lexical preservation parser, false to use the custom, faster implementation which sometimes produces incorrect results.
  • Method Details

    • getJavaSource

      public JavaSource getJavaSource(File sourceFile) throws IOException
      Retrieves a JavaSource representation of the specified Java source file.

      If the source has already been loaded previously, the cached JavaSource is returned. Otherwise, the file is read from disk, validated to ensure it is not a Kotlin file, and then parsed into a new JavaSource instance which is cached for future use.

      Parameters:
      sourceFile - the Java source file to load
      Returns:
      the JavaSource representation of the given file
      Throws:
      IOException - if an I/O error occurs while reading the file
      KotlinNotSupportedException - if the file is determined to be a Kotlin file
    • saveComponentInfoSourceFiles

      public void saveComponentInfoSourceFiles(ComponentInfo componentInfo)
    • clear

      public void clear()
      Clears all cached JavaSource objects from memory.

      Note: This method should be called anytime a new Java related operation begins.