Package io.codemodder.ast
Class LocalVariableDeclaration
java.lang.Object
io.codemodder.ast.LocalVariableDeclaration
- All Implemented Interfaces:
LocalDeclaration
- Direct Known Subclasses:
ExpressionStmtVariableDeclaration,ForEachDeclaration,ForInitDeclaration,TryResourceDeclaration
public abstract sealed class LocalVariableDeclaration
extends Object
implements LocalDeclaration
permits ForEachDeclaration, ForInitDeclaration, TryResourceDeclaration, ExpressionStmtVariableDeclaration
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 LocalScopeprotected com.github.javaparser.ast.body.VariableDeclaratorprotected com.github.javaparser.ast.expr.VariableDeclarationExpr -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract LocalScopestatic Optional<LocalVariableDeclaration>fromVariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator vd) For a givenVariableDeclaratorvd, check if it is part of a local declaration and return its associatedLocalVariableDeclarationobject, if applicable.com.github.javaparser.ast.body.VariableDeclaratorThe node where the declaration occurs.getName()Returns the name of the local variable in this declaration as aString.getScope()Returns theLocalScopeof the local variable in this declaration.abstract com.github.javaparser.ast.stmt.StatementReturns theStatementNodethat holds this local declaration.com.github.javaparser.ast.expr.VariableDeclarationExprReturns theVariableDeclarationExprNodethat holds this local declaration.com.github.javaparser.ast.body.VariableDeclaratorReturns theVariableDeclaratorNodethat holds this local declaration.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
getNamein interfaceLocalDeclaration
-
getDeclaration
public com.github.javaparser.ast.body.VariableDeclarator getDeclaration()Description copied from interface:LocalDeclarationThe node where the declaration occurs.- Specified by:
getDeclarationin interfaceLocalDeclaration
-
getScope
Returns theLocalScopeof the local variable in this declaration.- Specified by:
getScopein interfaceLocalDeclaration
-
getVariableDeclarator
public com.github.javaparser.ast.body.VariableDeclarator getVariableDeclarator()Returns theVariableDeclaratorNodethat holds this local declaration. -
getVariableDeclarationExpr
public com.github.javaparser.ast.expr.VariableDeclarationExpr getVariableDeclarationExpr()Returns theVariableDeclarationExprNodethat holds this local declaration. -
getStatement
public abstract com.github.javaparser.ast.stmt.Statement getStatement()Returns theStatementNodethat holds this local declaration. -
findScope
-
toString
-
fromVariableDeclarator
public static Optional<LocalVariableDeclaration> fromVariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator vd) For a givenVariableDeclaratorvd, check if it is part of a local declaration and return its associatedLocalVariableDeclarationobject, if applicable.
-