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<com.sun.source.tree.Tree>
,UStatement
,com.sun.source.tree.StatementTree
,com.sun.source.tree.Tree
,com.sun.source.tree.TreeVisitor<Choice<Unifier>,
,Unifier> com.sun.source.tree.VariableTree
,Serializable
,Function<UStatement.UnifierWithUnconsumedStatements,
Choice<UStatement.UnifierWithUnconsumedStatements>>
public abstract class UVariableDecl
extends UTree<com.sun.tools.javac.tree.JCTree.JCStatement>
implements com.sun.source.tree.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 com.sun.source.tree.Tree
com.sun.source.tree.Tree.Kind
Nested classes/interfaces inherited from interface com.google.errorprone.refaster.UStatement
UStatement.UnifierWithUnconsumedStatements
-
Field Summary
Fields inherited from class com.sun.source.util.SimpleTreeVisitor
DEFAULT_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<R,
D> R accept
(com.sun.source.tree.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
com.sun.source.tree.Tree.Kind
getKind()
com.sun.source.tree.ModifiersTree
abstract StringName
getName()
com.sun.source.tree.ExpressionTree
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
(com.sun.source.tree.VariableTree decl, Unifier unifier) Methods inherited from class com.google.errorprone.refaster.UTree
defaultAction, unify
Methods inherited from class com.sun.source.util.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 java.lang.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 interfacecom.sun.source.tree.VariableTree
-
getType
- Specified by:
getType
in interfacecom.sun.source.tree.VariableTree
-
getInitializer
- Specified by:
getInitializer
in interfacecom.sun.source.tree.VariableTree
-
visitVariable
-
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
public com.sun.source.tree.Tree.Kind getKind()- Specified by:
getKind
in interfacecom.sun.source.tree.Tree
-
accept
public <R,D> R accept(com.sun.source.tree.TreeVisitor<R, D> visitor, D data) - Specified by:
accept
in interfacecom.sun.source.tree.Tree
-
getModifiers
public com.sun.source.tree.ModifiersTree getModifiers()- Specified by:
getModifiers
in interfacecom.sun.source.tree.VariableTree
-
getNameExpression
public com.sun.source.tree.ExpressionTree getNameExpression()- Specified by:
getNameExpression
in interfacecom.sun.source.tree.VariableTree
-
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>>
-