Class UVariableDecl
java.lang.Object
com.sun.source.util.SimpleTreeVisitor<Choice<Unifier>, Unifier>
com.google.errorprone.refaster.UTree<com.sun.tools.javac.tree.JCTree.JCStatement>
com.google.errorprone.refaster.UVariableDecl
- All Implemented Interfaces:
com.google.common.base.Function<UStatement.UnifierWithUnconsumedStatements, Choice<UStatement.UnifierWithUnconsumedStatements>>, Unifiable<Tree>, UStatement, StatementTree, Tree, TreeVisitor<Choice<Unifier>, Unifier>, VariableTree, Serializable, Function<UStatement.UnifierWithUnconsumedStatements, Choice<UStatement.UnifierWithUnconsumedStatements>>
public abstract class UVariableDecl
extends UTree<com.sun.tools.javac.tree.JCTree.JCStatement>
implements VariableTree
A
UTree
representation of a local variable declaration.
A UVariableDecl
can be unified with any variable declaration which has a matching type
and initializer. Annotations and modifiers are preserved for the corresponding replacement, as
well as the variable name. ULocalVarIdent
instances are used to represent references to
local variables.
As a result, we can modify variable declarations and initializations in target code while preserving variable names and other contextual information.
- Author:
- lowasser@google.com (Louis Wasserman)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface UStatement
UStatement.UnifierWithUnconsumedStatements
-
Field Summary
Fields inherited from class SimpleTreeVisitor
DEFAULT_VALUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R,
D> R accept
(TreeVisitor<R, D> visitor, D data) static UVariableDecl
create
(CharSequence identifier, UExpression type) static UVariableDecl
create
(CharSequence identifier, UExpression type, @Nullable UExpression initializer) abstract @Nullable UExpression
getKind()
abstract StringName
getName()
abstract UExpression
getType()
com.sun.tools.javac.tree.JCTree.JCVariableDecl
com.sun.tools.javac.tree.JCTree.JCVariableDecl
inlineImplicitType
(Inliner inliner) com.sun.tools.javac.util.List
<com.sun.tools.javac.tree.JCTree.JCStatement> inlineStatements
(Inliner inliner) visitVariable
(VariableTree decl, Unifier unifier) Methods inherited from class UTree
defaultAction, unify
Methods inherited from class SimpleTreeVisitor
visit, visit, visitAnnotatedType, visitAnnotation, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.common.base.Function
equals
-
Constructor Details
-
UVariableDecl
public UVariableDecl()
-
-
Method Details
-
create
public static UVariableDecl create(CharSequence identifier, UExpression type, @Nullable UExpression initializer) -
create
-
getName
- Specified by:
getName
in interfaceVariableTree
-
getType
- Specified by:
getType
in interfaceVariableTree
-
getInitializer
- Specified by:
getInitializer
in interfaceVariableTree
-
visitVariable
- Specified by:
visitVariable
in interfaceTreeVisitor<Choice<Unifier>, Unifier>
- Overrides:
visitVariable
in classSimpleTreeVisitor<Choice<Unifier>, Unifier>
-
inline
public com.sun.tools.javac.tree.JCTree.JCVariableDecl inline(Inliner inliner) throws CouldNotResolveImportException - Throws:
CouldNotResolveImportException
-
inlineImplicitType
public com.sun.tools.javac.tree.JCTree.JCVariableDecl inlineImplicitType(Inliner inliner) throws CouldNotResolveImportException - Throws:
CouldNotResolveImportException
-
getKind
-
accept
-
getModifiers
- Specified by:
getModifiers
in interfaceVariableTree
-
getNameExpression
- Specified by:
getNameExpression
in interfaceVariableTree
-
inlineStatements
public com.sun.tools.javac.util.List<com.sun.tools.javac.tree.JCTree.JCStatement> inlineStatements(Inliner inliner) throws CouldNotResolveImportException - Specified by:
inlineStatements
in interfaceUStatement
- Throws:
CouldNotResolveImportException
-
apply
public Choice<UStatement.UnifierWithUnconsumedStatements> apply(UStatement.UnifierWithUnconsumedStatements state) - Specified by:
apply
in interfacecom.google.common.base.Function<UStatement.UnifierWithUnconsumedStatements, Choice<UStatement.UnifierWithUnconsumedStatements>>
- Specified by:
apply
in interfaceFunction<UStatement.UnifierWithUnconsumedStatements, Choice<UStatement.UnifierWithUnconsumedStatements>>
-