Package org.openrewrite.java
Class JavaTemplate.Builder
java.lang.Object
org.openrewrite.java.JavaTemplate.Builder
- Enclosing class:
- JavaTemplate
-
Method Summary
Modifier and TypeMethodDescriptionbuild()A template snippet is context-sensitive when it refers to the class, variables, methods, or other symbols visible from its insertion scope.doAfterVariableSubstitution(Consumer<String> afterVariableSubstitution) doBeforeParseTemplate(Consumer<String> beforeParseTemplate) javaParser(org.openrewrite.java.JavaParser.Builder<?, ?> javaParser) staticImports(String... fullyQualifiedMemberTypeNames)
-
Method Details
-
contextSensitive
A template snippet is context-sensitive when it refers to the class, variables, methods, or other symbols visible from its insertion scope. When a template is completely self-contained, it is not context-sensitive. Context-free template snippets can be cached, since it does not matter where the resulting LST elements will be inserted. Since the LST elements in a context-sensitive snippet vary depending on where they are inserted the resulting LST elements cannot be reused between different insertion points and are not cached.An example of a context-free snippet might be something like this, to be used as a local variable declaration:
int i = 1;An example of a context-sensitive snippet is:
int i = a; This cannot be made sense of without the surrounding scope which includes the declaration of "a". -
imports
-
staticImports
-
javaParser
-
doAfterVariableSubstitution
-
doBeforeParseTemplate
-
build
-