Class SourceSyncChecker

java.lang.Object
com.vaadin.copilot.rewriter.SourceSyncChecker

public class SourceSyncChecker extends Object
The SourceSyncChecker is responsible for monitoring changes to Java source files during development to identify scenarios where source files may be out of sync with the running application or route view is deleted by the user.
  • Constructor Details

    • SourceSyncChecker

      public SourceSyncChecker(com.vaadin.flow.internal.DevModeHandlerManager devModeHandler, Executor startupExecutor)
      Starts the source file watcher with the given application configuration.

      Starting the watchers walks and hashes the whole source tree, which can be slow on large trees, network/virtualized drives, or when antivirus software scans every file open. That work is therefore performed asynchronously on a background thread so it does not block the Copilot connect thread (which would otherwise stall Copilot.handleConnect, leaving the browser UI loaded but empty and blocking other sessions on the shared session map lock). Callers that need the watchers to be running can wait via awaitWatchersStarted(long, TimeUnit).

      Parameters:
      devModeHandler - flow dev mode handler for registering file watcher shut down
      startupExecutor - executor used to run the source-tree walk off the calling thread (typically VaadinService.getExecutor())
  • Method Details

    • maybeOutOfSync

      public boolean maybeOutOfSync(ComponentInfoNotFoundException exception)
      Looks for file has been updated since the startup. Additionally, caches exceptions that happens without any files changes.
      Parameters:
      exception - Exception that happens when finding component info fails.
      Returns:
      true if file may be out of sync, false otherwise
    • addDeletedView

      public void addDeletedView(String qualifiedClassName)
      Stores the given class name as the view is removed
      Parameters:
      qualifiedClassName - fully qualified class name of a view
    • addDeletedView

      public void addDeletedView(com.vaadin.flow.component.Component component)
      Stores component class into the deleted views list so that SuggestRestartException can be thrown when it is requested
      Parameters:
      component - Flow node
    • throwIfViewDeleted

      public void throwIfViewDeleted(ComponentTypeAndSourceLocation componentTypeAndSourceLocation) throws SuggestRestartException
      Throws an exception if class from the given componentTypeAndSourceLocation is deleted during the lifetime of the application.
      Parameters:
      componentTypeAndSourceLocation -
      Throws:
      SuggestRestartException - is thrown when file is not present
    • isViewDeleted

      public boolean isViewDeleted(String qualifiedClassName)