Package com.vaadin.copilot.javarewriter
Class OptimisticPreviewMarker
java.lang.Object
com.vaadin.copilot.javarewriter.OptimisticPreviewMarker
Maintains line-comment markers that associate optimistic preview components
with their live source locations.
Structural preview rewrites replace AST nodes, making previously captured
ComponentInfo instances stale. The markers written by this utility
identify the current creation and attachment statements so callers can
rebuild component information from the rewritten source tree.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(ComponentInfo component, String optimisticComponentId) Adds creation and attachment markers for a component's current source locations.static ComponentInfofind(JavaSource source, String optimisticComponentId) Resolves live component locations identified by a creation marker in a source tree.static List<ComponentInfo> findAll(JavaSource source) Recreates every component that has a creation marker in a source tree.static voidremove(JavaSource source, String componentId) Removes a component identity from all creation and attachment markers in the current source.
-
Field Details
-
CREATE_ID
Prefix of a line comment that identifies a component creation statement.- See Also:
-
ATTACH_ID
Prefix of a line comment that identifies a component attachment statement.- See Also:
-
-
Method Details
-
add
Adds creation and attachment markers for a component's current source locations.- Parameters:
component- component information whose locations are markedoptimisticComponentId- stable browser-to-preview identity to add to the markers
-
find
Resolves live component locations identified by a creation marker in a source tree. This deliberately rebuilds theComponentInfo; AST nodes from before a structural rewrite must not be reused.- Parameters:
source- source tree containing the markeroptimisticComponentId- stable component identity- Returns:
- a component backed by live AST nodes, or
nullwhen absent
-
findAll
Recreates every component that has a creation marker in a source tree. This is used when a structural operation needs the live hierarchy rather than a single component identified by a browser ID.- Parameters:
source- source tree containing preview markers- Returns:
- component information rebuilt from the marked live AST nodes
-
remove
Removes a component identity from all creation and attachment markers in the current source. Marker comments without remaining identities are removed.- Parameters:
source- source tree whose marker comments are updatedcomponentId- identity to remove
-