Class ASTResource

java.lang.Object
net.sourceforge.pmd.lang.ast.impl.AbstractNode<B,N>
net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
net.sourceforge.pmd.lang.java.ast.ASTResource
All Implemented Interfaces:
GenericNode<JavaNode>, JjtreeNode<JavaNode>, Node, TextAvailableNode, JavaNode, Reportable

public final class ASTResource extends AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
A resource of a try-with-resources. This contains another node that represents the resource, according to the grammar below.

In the case of concise try-with resources, the subexpressions are required to be only field accesses or variable references to compile.


 Resource ::= LocalVariableDeclaration
            | PrimaryExpression

 
  • Field Details

  • Method Details

    • acceptVisitor

      protected <P, R> R acceptVisitor(JavaVisitor<? super P,? extends R> visitor, P data)
    • isConciseResource

      public boolean isConciseResource()
      Returns true if this appears as an expression, and not as a local variable declaration.
    • getStableName

      @Deprecated public String getStableName()
      Deprecated.
      Since 7.1.0. This method is not very useful because the expression might be complex and not have a real "name". In this case we return the expression pretty printed.
      Gets the name with which the resource can be accessed in the body of the try statement. If this is a concise resource, then returns the sequence of names that identifies the expression. If this has a local variable declaration, then returns the name of the variable.
    • asLocalVariableDeclaration

      public @Nullable ASTLocalVariableDeclaration asLocalVariableDeclaration()
    • getInitializer

      public ASTExpression getInitializer()
      Returns the initializer of the expression. If this is a concise resource, then returns that expression. If this is a local variable declaration, returns the initializer of the variable.
    • jjtClose

      public void jjtClose()
      Overrides:
      jjtClose in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • acceptVisitor

      public final <P, R> R acceptVisitor(AstVisitor<? super P,? extends R> visitor, P data)
      Specified by:
      acceptVisitor in interface Node
    • addChild

      protected void addChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      addChild in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • insertChild

      protected void insertChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      insertChild in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • removeChildAtIndex

      protected void removeChildAtIndex(int childIndex)
      Overrides:
      removeChildAtIndex in class AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setImage

      protected void setImage(String image)
      Overrides:
      setImage in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setFirstToken

      protected void setFirstToken(JavaccToken token)
      Overrides:
      setFirstToken in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setLastToken

      protected void setLastToken(JavaccToken token)
      Overrides:
      setLastToken in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • enlargeLeft

      protected void enlargeLeft(JavaccToken child)
      Overrides:
      enlargeLeft in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setChild

      protected void setChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      setChild in class AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • getSymbolTable

      public @NonNull JSymbolTable getSymbolTable()
      Description copied from interface: JavaNode
      Returns the symbol table for the program point represented by this node.
      Specified by:
      getSymbolTable in interface JavaNode
    • getTypeSystem

      public TypeSystem getTypeSystem()
      Description copied from interface: JavaNode
      Returns the type system with which this node was created. This is the object responsible for representing types in the compilation unit.
      Specified by:
      getTypeSystem in interface JavaNode
    • getRoot

      public final @NonNull ASTCompilationUnit getRoot()
      Specified by:
      getRoot in interface JavaNode
      Specified by:
      getRoot in interface Node
    • getXPathNodeName

      public final String getXPathNodeName()
      Specified by:
      getXPathNodeName in interface Node