com.vaadin.copilot.javarewriter.
Class LumoRewriterUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addClassNameWithArgs
(ComponentInfo component, List<com.github.javaparser.ast.expr.Expression> arguments) Creates addClassNames(...) statement with given arguments if there is none.
static void
addLumoUtilityImport
(com.github.javaparser.ast.CompilationUnit compilationUnit) static List<com.github.javaparser.ast.expr.Expression>
getLumoMethodArgExpressions
(String lumoInnerClassName, List<String> classNames) Converts given class names to LumoUtility field access expressions.
static List<com.github.javaparser.ast.expr.Expression>
getLumoMethodArgExpressions
(List<String> lumoInnerClassNames, List<String> classNames) Converts given class names of given lumo inner class name lists and return all.
static void
removeClassNameArgs
(ComponentInfo component, String... lumoUtilityClassNames) Searches addClassName, addClassNames, setClassName methods for given component and then remove given lumo utility class names.
static void
removeSetThemeArgs
(List<com.github.javaparser.ast.expr.MethodCallExpr> methodCallExprList, String argName) static void
removeThemeArgs
(List<com.github.javaparser.ast.expr.MethodCallExpr> methodCallStatements, List<String> args) Removes arguments from
getThemeList().add()
orgetThemeList().addAll()
.static void
removeThemeArgStartsWith
(List<com.github.javaparser.ast.expr.MethodCallExpr> methodCallStatements, String startsWith) Removes arguments from
getThemeList().add()
orgetThemeList().addAll()
.
-
Constructor Details
-
LumoRewriterUtil
public LumoRewriterUtil()
-
-
Method Details
-
removeThemeArgStartsWith
public static void removeThemeArgStartsWith(List<com.github.javaparser.ast.expr.MethodCallExpr> methodCallStatements, String startsWith) Removes arguments from
getThemeList().add()
orgetThemeList().addAll()
. If there is no arguments left after removing, removes the method.Parameters:
methodCallStatements
- Method calls of the given nodestartsWith
- string literal args to be removed -
removeSetThemeArgs
-
removeThemeArgs
public static void removeThemeArgs(List<com.github.javaparser.ast.expr.MethodCallExpr> methodCallStatements, List<String> args) Removes arguments from
getThemeList().add()
orgetThemeList().addAll()
. If there is no arguments left after removing, removes the method.Parameters:
methodCallStatements
- Method calls of the given nodeargs
- exact string literals to be removed -
addClassNameWithArgs
public static boolean addClassNameWithArgs(ComponentInfo component, List<com.github.javaparser.ast.expr.Expression> arguments) Creates addClassNames(...) statement with given arguments if there is none. Adds arguments to existing one.
Parameters:
component
- the component to add class namearguments
- class name arguments. Most likely StringLiteral or FieldAccessExpr generated for LumoUtility.Returns:
true if added successfully, false otherwise.
-
removeClassNameArgs
Searches addClassName, addClassNames, setClassName methods for given component and then remove given lumo utility class names. e.g. if self-start is given for removal, LumoUtility.AlignSelf.START and "self-start" are removed from args.
Parameters:
component
- the component to remove class nameslumoUtilityClassNames
- Utility class names such as "align-items", "gap-m" -
addLumoUtilityImport
public static void addLumoUtilityImport(com.github.javaparser.ast.CompilationUnit compilationUnit) -
getLumoMethodArgExpressions
public static List<com.github.javaparser.ast.expr.Expression> getLumoMethodArgExpressions(String lumoInnerClassName, List<String> classNames) Converts given class names to LumoUtility field access expressions. e.g. items-center becomes AlignItems.CENTER
Parameters:
lumoInnerClassName
- Inner class name of LumoUtility class. e.g. AlignSelf, AlignItems etc...classNames
- html class namesReturns:
list of expressions.
-
getLumoMethodArgExpressions
public static List<com.github.javaparser.ast.expr.Expression> getLumoMethodArgExpressions(List<String> lumoInnerClassNames, List<String> classNames) Converts given class names of given lumo inner class name lists and return all.
Parameters:
lumoInnerClassNames
- List of lumo inner class names e.g. Gap, Gap.Row, Gap.ColumnclassNames
- class names to look up in given lumo classesReturns:
List of expression to add to a method as arguments
-