Package com.vaadin.copilot
Class ComponentSourceFinder
java.lang.Object
com.vaadin.copilot.ComponentSourceFinder
Finds the source location of a component in the project.
-
Constructor Summary
ConstructorsConstructorDescriptionComponentSourceFinder(com.vaadin.flow.server.VaadinSession vaadinSession) Creates a new component source finder for the given session. -
Method Summary
Modifier and TypeMethodDescription_getSourceLocation(com.vaadin.flow.component.Component component) Gets the source location for the given component.analyzeSourceFileAndGetComponentTypeAndSourceLocation(int nodeId, int uiId) Finds theComponentTypeAndSourceLocationfor given component withnodeIdin ui with iduiIdby analyzing the source code without using the createLocation provided by Flow.analyzeSourceFileAndGetComponentTypeAndSourceLocation(com.vaadin.flow.component.Component component) Finds theComponentTypeAndSourceLocationfor given component with by analyzing the source code without using the createLocation provided by Flow.findInheritanceChain(com.vaadin.flow.component.Component component) Finds inheritance chain of a component by going up for each superclassfindTypeAndSourceLocation(int uiId, int nodeId) Finds the source location of a component.findTypeAndSourceLocation(int uiId, int nodeId, boolean includeChildren) Finds the source location of a component.findTypeAndSourceLocation(com.fasterxml.jackson.databind.JsonNode component) Finds the source location of a component.findTypeAndSourceLocation(com.fasterxml.jackson.databind.JsonNode component, boolean includeChildren) Finds the source location of a component.findTypeAndSourceLocation(com.vaadin.flow.component.Component component, boolean includeChildren) Finds the source location of a component.
-
Constructor Details
-
ComponentSourceFinder
public ComponentSourceFinder(com.vaadin.flow.server.VaadinSession vaadinSession) Creates a new component source finder for the given session.- Parameters:
vaadinSession- the session to use
-
-
Method Details
-
findTypeAndSourceLocation
public ComponentTypeAndSourceLocation findTypeAndSourceLocation(com.fasterxml.jackson.databind.JsonNode component) Finds the source location of a component.- Parameters:
component- the component to find, defined by uiId and nodeId in the given JSON object- Returns:
- the source location of the component
-
findTypeAndSourceLocation
public ComponentTypeAndSourceLocation findTypeAndSourceLocation(com.fasterxml.jackson.databind.JsonNode component, boolean includeChildren) Finds the source location of a component.- Parameters:
component- the component to find, defined by uiId and nodeId in the given JSON object- Returns:
- the source location of the component
-
findTypeAndSourceLocation
Finds the source location of a component.- Parameters:
uiId- the uiId of the componentnodeId- the nodeId of the component- Returns:
- the source location of the component
-
findTypeAndSourceLocation
public ComponentTypeAndSourceLocation findTypeAndSourceLocation(int uiId, int nodeId, boolean includeChildren) Finds the source location of a component.- Parameters:
uiId- the uiId of the componentnodeId- the nodeId of the componentincludeChildren- whether to include children in the search- Returns:
- the source location of the component
-
findTypeAndSourceLocation
public ComponentTypeAndSourceLocation findTypeAndSourceLocation(com.vaadin.flow.component.Component component, boolean includeChildren) Finds the source location of a component.- Parameters:
component- the component to findincludeChildren- whether to include children in the search- Returns:
- the source location of the component
-
analyzeSourceFileAndGetComponentTypeAndSourceLocation
public Optional<ComponentTypeAndSourceLocation> analyzeSourceFileAndGetComponentTypeAndSourceLocation(int nodeId, int uiId) throws IOException Finds theComponentTypeAndSourceLocationfor given component withnodeIdin ui with iduiIdby analyzing the source code without using the createLocation provided by Flow.Note: This method should be used if an operation requires source file instead of creation location for the component
- Parameters:
nodeId- Flow component node iduiId- Flow UI id- Returns:
- ComponentTypeAndSourceLocation if component class analyzed successfully, empty when file or component is not accessible.
- Throws:
IOException- thrown when file operation fails
-
analyzeSourceFileAndGetComponentTypeAndSourceLocation
public Optional<ComponentTypeAndSourceLocation> analyzeSourceFileAndGetComponentTypeAndSourceLocation(com.vaadin.flow.component.Component component) throws IOException Finds theComponentTypeAndSourceLocationfor given component with by analyzing the source code without using the createLocation provided by Flow.Note: This method should be used if an operation requires source file instead of creation location for the component.
Note: This method does not include children and parent info.
- Parameters:
component- Component instance- Returns:
ComponentTypeAndSourceLocationif component class analyzed successfully, empty when file or component is not accessible.- Throws:
IOException- thrown when file operation fails
-
_getSourceLocation
public ComponentTypeAndSourceLocation _getSourceLocation(com.vaadin.flow.component.Component component) Gets the source location for the given component.NOTE that the session must be locked when calling this method.
- Returns:
- the source location of the component
-
findInheritanceChain
Finds inheritance chain of a component by going up for each superclass- Parameters:
component- Flow component- Returns:
- list of classes
-