Package org.openrewrite
Class SourceVisitor<R>
- java.lang.Object
-
- org.openrewrite.SourceVisitor<R>
-
- Direct Known Subclasses:
CompositeSourceVisitor
,FindIndent
public abstract class SourceVisitor<R> extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected int
cycle
-
Constructor Summary
Constructors Constructor Description SourceVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<SourceVisitor<R>>
andThen()
Used to build up pipelines of visitors.void
andThen(SourceVisitor<R> visitor)
abstract R
defaultTo(Tree t)
Cursor
getCursor()
java.lang.String
getName()
java.lang.Iterable<io.micrometer.core.instrument.Tag>
getTags()
boolean
isIdempotent()
Determines whether this visitor can be run multiple times as a top-level rule.void
nextCycle()
R
reduce(R r1, R r2)
Some sensible defaults for reduce (boolean OR, list concatenation, or else just the value of r1).protected void
setCursoringOn()
Validated
validate()
R
visit(java.util.List<? extends Tree> trees)
R
visit(Tree tree)
R
visitAfter(R r, java.util.List<? extends Tree> trees)
R
visitAfter(R r, Tree tree)
R
visitTree(Tree tree)
-
-
-
Method Detail
-
getTags
public java.lang.Iterable<io.micrometer.core.instrument.Tag> getTags()
-
setCursoringOn
protected void setCursoringOn()
-
andThen
public java.util.List<SourceVisitor<R>> andThen()
Used to build up pipelines of visitors.- Returns:
- Other visitors that are run after this one.
-
andThen
public void andThen(SourceVisitor<R> visitor)
-
isIdempotent
public boolean isIdempotent()
Determines whether this visitor can be run multiple times as a top-level rule. In the case of a visitor which mutates the underlying tree, indicates that running once or N times will yield the same mutation.- Returns:
- If true, this visitor can be run multiple times.
-
validate
public Validated validate()
-
getName
public java.lang.String getName()
-
getCursor
public Cursor getCursor()
-
nextCycle
public void nextCycle()
-
reduce
public R reduce(R r1, R r2)
Some sensible defaults for reduce (boolean OR, list concatenation, or else just the value of r1). Override if your particular visitor needs to reduce values in a different way.- Parameters:
r1
- The left side to reduce.r2
- The right side to reduce.- Returns:
- The reduced value.
-
-