Package io.codemodder.ast
Class LocalVariableDeclaration
java.lang.Object
io.codemodder.ast.LocalVariableDeclaration
- All Implemented Interfaces:
LocalDeclaration
- Direct Known Subclasses:
ExpressionStmtVariableDeclaration
,ForEachDeclaration
,ForInitDeclaration
,TryResourceDeclaration
Holds the nodes in the AST that represents several types of local declaration of a variable. See
Java Language
Specification - Section 6.1 for all the possible ways a local variable can be declarared.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LocalScope
protected com.github.javaparser.ast.body.VariableDeclarator
protected com.github.javaparser.ast.expr.VariableDeclarationExpr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract LocalScope
static Optional<LocalVariableDeclaration>
fromVariableDeclarator
(com.github.javaparser.ast.body.VariableDeclarator vd) For a givenVariableDeclarator
vd
, check if it is part of a local declaration and return its associatedLocalVariableDeclaration
object, if applicable.com.github.javaparser.ast.body.VariableDeclarator
The node where the declaration occurs.getName()
Returns the name of the local variable in this declaration as aString
.getScope()
Returns theLocalScope
of the local variable in this declaration.abstract com.github.javaparser.ast.stmt.Statement
Returns theStatement
Node
that holds this local declaration.com.github.javaparser.ast.expr.VariableDeclarationExpr
Returns theVariableDeclarationExpr
Node
that holds this local declaration.com.github.javaparser.ast.body.VariableDeclarator
Returns theVariableDeclarator
Node
that holds this local declaration.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.codemodder.ast.LocalDeclaration
findAllMethodCalls, findAllReferences, isReference
-
Field Details
-
vde
protected com.github.javaparser.ast.expr.VariableDeclarationExpr vde -
vd
protected com.github.javaparser.ast.body.VariableDeclarator vd -
scope
-
-
Constructor Details
-
LocalVariableDeclaration
public LocalVariableDeclaration()
-
-
Method Details
-
getName
Returns the name of the local variable in this declaration as aString
.- Specified by:
getName
in interfaceLocalDeclaration
-
getDeclaration
public com.github.javaparser.ast.body.VariableDeclarator getDeclaration()Description copied from interface:LocalDeclaration
The node where the declaration occurs.- Specified by:
getDeclaration
in interfaceLocalDeclaration
-
getScope
Returns theLocalScope
of the local variable in this declaration.- Specified by:
getScope
in interfaceLocalDeclaration
-
getVariableDeclarator
public com.github.javaparser.ast.body.VariableDeclarator getVariableDeclarator()Returns theVariableDeclarator
Node
that holds this local declaration. -
getVariableDeclarationExpr
public com.github.javaparser.ast.expr.VariableDeclarationExpr getVariableDeclarationExpr()Returns theVariableDeclarationExpr
Node
that holds this local declaration. -
getStatement
public abstract com.github.javaparser.ast.stmt.Statement getStatement()Returns theStatement
Node
that holds this local declaration. -
findScope
-
toString
-
fromVariableDeclarator
public static Optional<LocalVariableDeclaration> fromVariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator vd) For a givenVariableDeclarator
vd
, check if it is part of a local declaration and return its associatedLocalVariableDeclaration
object, if applicable.
-