Class KotlinComponentResolver
java.lang.Object
com.vaadin.copilot.kotlinrewriter.KotlinComponentResolver
Resolves a selected component to its place in a Kotlin source.
The Kotlin counterpart of ComponentInfoFinder, and the single entry
point for both reading and writing. That matters more than it sounds: the
panel and an edit must land on the same constructor call, and the hard part
of agreeing is the occurrence rule below, which neither caller should be
re-deriving.
-
Constructor Summary
ConstructorsConstructorDescriptionKotlinComponentResolver(KotlinFileSourceProvider sources, Function<com.vaadin.flow.component.Component, List<ComponentTypeAndSourceLocation>> siblings) -
Method Summary
Modifier and TypeMethodDescriptionresolve(ComponentTypeAndSourceLocation location) Resolves the component, or returns empty.resolveOrThrow(ComponentTypeAndSourceLocation location) Resolves the component, or throws explaining why it could not be.
-
Constructor Details
-
KotlinComponentResolver
public KotlinComponentResolver(KotlinFileSourceProvider sources, Function<com.vaadin.flow.component.Component, List<ComponentTypeAndSourceLocation>> siblings) - Parameters:
sources- where parsed sources come from, so edits to one file accumulatesiblings- the selected component's peers under its parent, used to work out which of several same-line creations it is
-
-
Method Details
-
resolveOrThrow
public KotlinComponentInfo resolveOrThrow(ComponentTypeAndSourceLocation location) throws IOException Resolves the component, or throws explaining why it could not be.- Parameters:
location- the selected component's type and location- Returns:
- the resolved component
- Throws:
IOException- if the source cannot be readCopilotException- if the component cannot be located in the source
-
resolve
public Optional<KotlinComponentInfo> resolve(ComponentTypeAndSourceLocation location) throws IOException Resolves the component, or returns empty.- Parameters:
location- the selected component's type and location- Returns:
- the resolved component, or empty when it cannot be located
- Throws:
IOException- if the source cannot be read
-