Add an expression as a method argument
ProprietaryAdd a Java expression, such as FacesContext.getCurrentInstance() or this, as an argument to method invocations, for a parameter the method gained.
io. moderne. java. primefaces. AddExpressionMethodArgumentRequired
A method pattern is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: com.google.common..*#*(..).
The pattern format is <PACKAGE>#<METHOD_NAME>(<ARGS>).
..* includes all subpackages of com.google.common.*(..) matches any method name with any number of arguments.
For more specific queries, like Guava's ImmutableMap, use com.google.common.collect.ImmutableMap#*(..) to narrow down the results.
A zero-based index indicating where to insert the new argument.
The Java expression to pass as the new argument.
The fully qualified type of the new parameter, imported when the expression names it. A jakarta. type is taken from javax. instead where the method's class uses javax. in its API.
Optional
Artifacts in this module's type table that declare the types the expression uses, as passed to JavaParser.Builder#classpathFromResources. Separate values with commas.
mod run . --recipe= io. moderne. java. primefaces. AddExpressionMethodArgument \
-P methodPattern= 'org. primefaces. util. MessageFactory getMessage(java. lang. String, .. )' \
-P argumentIndex=0 \
-P expression= 'FacesContext. getCurrentInstance()' \
-P parameterType= jakarta. faces. context. FacesContextInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.