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 Details

    • vde

      protected com.github.javaparser.ast.expr.VariableDeclarationExpr vde
    • vd

      protected com.github.javaparser.ast.body.VariableDeclarator vd
    • scope

      protected LocalScope scope
  • Constructor Details

    • LocalVariableDeclaration

      public LocalVariableDeclaration()
  • Method Details

    • getName

      public String getName()
      Returns the name of the local variable in this declaration as a String.
      Specified by:
      getName in interface LocalDeclaration
    • getDeclaration

      public com.github.javaparser.ast.body.VariableDeclarator getDeclaration()
      Description copied from interface: LocalDeclaration
      The node where the declaration occurs.
      Specified by:
      getDeclaration in interface LocalDeclaration
    • getScope

      public LocalScope getScope()
      Returns the LocalScope of the local variable in this declaration.
      Specified by:
      getScope in interface LocalDeclaration
    • getVariableDeclarator

      public com.github.javaparser.ast.body.VariableDeclarator getVariableDeclarator()
      Returns the VariableDeclarator Node that holds this local declaration.
    • getVariableDeclarationExpr

      public com.github.javaparser.ast.expr.VariableDeclarationExpr getVariableDeclarationExpr()
      Returns the VariableDeclarationExpr Node that holds this local declaration.
    • getStatement

      public abstract com.github.javaparser.ast.stmt.Statement getStatement()
      Returns the Statement Node that holds this local declaration.
    • findScope

      protected abstract LocalScope findScope()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromVariableDeclarator

      public static Optional<LocalVariableDeclaration> fromVariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator vd)
      For a given VariableDeclarator vd, check if it is part of a local declaration and return its associated LocalVariableDeclaration object, if applicable.