org.extendj.ast
node type TryWithResources

General Info

Production
TryWithResources : TryStmt ::= Resource:ResourceDeclaration* Block CatchClause* [Finally:Block];
Type Hierarchy:
java.lang.Object
  extended by beaver.Symbol
      extended by org.extendj.ast.ASTNode<ASTNode>
          extended by org.extendj.ast.Stmt
              extended by org.extendj.ast.TryStmt
                  extended by org.extendj.ast.TryWithResources
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable<ASTNode>, org.jastadd.util.PrettyPrintable

Description

The JSR 334 try with resources statement.
Source
Declared in /home/jesper/git/extendj/java7/grammar/TryWithResources.ast at line 4

Member Filters

API level:

Aspect:

Constructors

public TryWithResources()
 
Source
Declared in /home/jesper/git/extendj/ASTNode at line 1
public TryWithResources(List<ResourceDeclaration> p0,
                        Block p1,
                        List<CatchClause> p2,
                        Opt<Block> p3)
 
Source
Declared in /home/jesper/git/extendj/ASTNode at line 16

Attributes

This attribute computes whether or not the TWR statement has a catch clause which handles the exception.
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 86
Aspect
TryWithResources
Returns true if exceptions of type exceptionType are handled in the try-with-resources statement or any containing statement within the directly enclosing method or initializer block.
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 100
Aspect
TryWithResources
Lookup the close method declaration for the resource which is being used.
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 125
Aspect
TryWithResources
@ASTNodeAnnotation.Attribute
syn org.extendj.ast.SimpleSet localLookup(java.lang.String name)
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 162
Aspect
TryWithResources
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 169
Aspect
TryWithResources
@ASTNodeAnnotation.Attribute
syn boolean isDAafter(org.extendj.ast.Variable v)
Overrides:isDAafter in class TryStmt
Source
Declared in /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag at line 257
Aspect
DA
True if the automatic closing of resources in this try-with-resources statement may throw an exception of type catchType.
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 251
Aspect
TryWithResources
True if the resource initialization of this try-with-resources statement may throw an exception of type catchType.
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 271
Aspect
TryWithResources
The block of the try statement can throw an exception of a type assignable to the given type.
Overrides:catchableException in class TryStmt
Source
Declared in /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag at line 268
Aspect
ExceptionHandling
An NTA which is used for code generation. This NTA will handle the recursive nature of code generation for try-with-resources statements.
Source
Declared in /home/jesper/git/extendj/java7/backend/TryWithResources.jrag at line 39
Aspect
TryWithResources
Inherit the handlesException attribute from methoddecl.
Overrides:handlesException in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 113
Aspect
TryWithResources
Overrides:typeError in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 140
Aspect
TryWithResources
Overrides:typeRuntimeException in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 141
Aspect
TryWithResources
@ASTNodeAnnotation.Attribute
inh org.extendj.ast.SimpleSet lookupVariable(java.lang.String name)
Overrides:lookupVariable in class Stmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 179
Aspect
TryWithResources
@ASTNodeAnnotation.Attribute
inh boolean resourcePreviouslyDeclared(java.lang.String name)
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 183
Aspect
TryWithResources

Methods

public void prettyPrint(org.jastadd.util.PrettyPrinter out)
Specified by:prettyPrint in interface org.jastadd.util.PrettyPrintableOverrides:prettyPrint in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/PrettyPrint.jadd at line 50
Aspect
Java7PrettyPrint
public void exceptionHandling()
Exception error checks.
Overrides:exceptionHandling in class ASTNode<ASTNode>
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 63
Aspect
TryWithResources
protected boolean reachedException(TypeDecl catchType)
Returns true if the try-with-resources statement can throw an exception of type (or a subtype of) catchType.
Overrides:reachedException in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 222
Aspect
TryWithResources
public void createBCode(org.extendj.ast.CodeGeneration gen)
Code generation for the try-with-resources statement.
Overrides:createBCode in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/backend/TryWithResources.jrag at line 81
Aspect
TryWithResources
public void init$Children()
Initializes the child array to the correct size. Initializes List and Opt nta children.
Overrides:init$Children in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 10
protected int numChildren()
Overrides:numChildren in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 25
public boolean mayHaveRewrite()
Overrides:mayHaveRewrite in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 31
public void flushAttrCache()
Overrides:flushAttrCache in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 37
public void flushCollectionCache()
Overrides:flushCollectionCache in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 52
public void flushRewriteCache()
Overrides:flushRewriteCache in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 58
public TryWithResources clone()
                       throws java.lang.CloneNotSupportedException
Overrides:clone in class TryStmt
Throws:
java.lang.CloneNotSupportedException
Source
Declared in /home/jesper/git/extendj/ASTNode at line 64
public TryWithResources copy()
Overrides:copy in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 71
@Deprecated
public TryWithResources fullCopy()
Deprecated. Please use treeCopy or treeCopyNoTransform instead

Create a deep copy of the AST subtree at this node. The copy is dangling, i.e. has no parent.

Overrides:fullCopy in class TryStmt
Returns:
dangling copy of the subtree at this node
Source
Declared in /home/jesper/git/extendj/ASTNode at line 90
public TryWithResources treeCopyNoTransform()
Create a deep copy of the AST subtree at this node. The copy is dangling, i.e. has no parent.
Overrides:treeCopyNoTransform in class TryStmt
Returns:
dangling copy of the subtree at this node
Source
Declared in /home/jesper/git/extendj/ASTNode at line 100
public TryWithResources treeCopy()
Create a deep copy of the AST subtree at this node. The subtree of this node is traversed to trigger rewrites before copy. The copy is dangling, i.e. has no parent.
Overrides:treeCopy in class TryStmt
Returns:
dangling copy of the subtree at this node
Source
Declared in /home/jesper/git/extendj/ASTNode at line 125
protected boolean is$Equal(ASTNode node)
Overrides:is$Equal in class TryStmt
Source
Declared in /home/jesper/git/extendj/ASTNode at line 132
Replaces the Resource list.
Parameters:
list - The new list node to be used as the Resource list.
public int getNumResource()
Retrieves the number of children in the Resource list.
Returns:
Number of children in the Resource list.
Retrieves the number of children in the Resource list. Calling this method will not trigger rewrites.
Returns:
Number of children in the Resource list.
Retrieves the element at index i in the Resource list.
Parameters:
i - Index of the element to return.
Returns:
The element at position i in the Resource list.
public boolean hasResource()
Check whether the Resource list has any children.
Returns:
true if it has at least one child, false otherwise.
public void addResource(ResourceDeclaration node)
Append an element to the Resource list.
Parameters:
node - The element to append to the Resource list.
public void setResource(ResourceDeclaration node,
                        int i)
Replaces the Resource list element at index i with the new node node.
Parameters:
node - The new node to replace the old list element.
i - The list index of the node to be replaced.
Retrieves the Resource list.
Returns:
The node representing the Resource list.
Retrieves the Resource list.

This method does not invoke AST transformations.

Returns:
The node representing the Resource list.
Retrieves the Resource list.
Returns:
The node representing the Resource list.
Retrieves the Resource list.

This method does not invoke AST transformations.

Returns:
The node representing the Resource list.
public void setBlock(Block node)
Replaces the Block child.
Overrides:setBlock in class TryStmt
Parameters:
node - The new node to replace the Block child.
Retrieves the Block child.
Overrides:getBlock in class TryStmt
Returns:
The current node used as the Block child.
Retrieves the Block child.

This method does not invoke AST transformations.

Overrides:getBlockNoTransform in class TryStmt
Returns:
The current node used as the Block child.
public void setCatchClauseList(List<CatchClause> list)
Replaces the CatchClause list.
Overrides:setCatchClauseList in class TryStmt
Parameters:
list - The new list node to be used as the CatchClause list.
public int getNumCatchClause()
Retrieves the number of children in the CatchClause list.
Overrides:getNumCatchClause in class TryStmt
Returns:
Number of children in the CatchClause list.
Retrieves the number of children in the CatchClause list. Calling this method will not trigger rewrites.
Overrides:getNumCatchClauseNoTransform in class TryStmt
Returns:
Number of children in the CatchClause list.
Retrieves the element at index i in the CatchClause list.
Overrides:getCatchClause in class TryStmt
Parameters:
i - Index of the element to return.
Returns:
The element at position i in the CatchClause list.
public boolean hasCatchClause()
Check whether the CatchClause list has any children.
Overrides:hasCatchClause in class TryStmt
Returns:
true if it has at least one child, false otherwise.
public void addCatchClause(CatchClause node)
Append an element to the CatchClause list.
Overrides:addCatchClause in class TryStmt
Parameters:
node - The element to append to the CatchClause list.
public void setCatchClause(CatchClause node,
                           int i)
Replaces the CatchClause list element at index i with the new node node.
Overrides:setCatchClause in class TryStmt
Parameters:
node - The new node to replace the old list element.
i - The list index of the node to be replaced.
Retrieves the CatchClause list.
Overrides:getCatchClauseList in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.

This method does not invoke AST transformations.

Overrides:getCatchClauseListNoTransform in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.
Overrides:getCatchClauses in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.

This method does not invoke AST transformations.

Overrides:getCatchClausesNoTransform in class TryStmt
Returns:
The node representing the CatchClause list.
public void setFinallyOpt(Opt<Block> opt)
Replaces the optional node for the Finally child. This is the Opt node containing the child Finally, not the actual child!
Overrides:setFinallyOpt in class TryStmt
Parameters:
opt - The new node to be used as the optional node for the Finally child.
public void setFinally(Block node)
Replaces the (optional) Finally child.
Overrides:setFinally in class TryStmt
Parameters:
node - The new node to be used as the Finally child.
public boolean hasFinally()
Check whether the optional Finally child exists.
Overrides:hasFinally in class TryStmt
Returns:
true if the optional Finally child exists, false if it does not.
public Block getFinally()
Retrieves the (optional) Finally child.
Overrides:getFinally in class TryStmt
Returns:
The Finally child, if it exists. Returns null otherwise.
Retrieves the optional node for the Finally child. This is the Opt node containing the child Finally, not the actual child!
Overrides:getFinallyOpt in class TryStmt
Returns:
The optional node for child the Finally child.
Retrieves the optional node for child Finally. This is the Opt node containing the child Finally, not the actual child!

This method does not invoke AST transformations.

Overrides:getFinallyOptNoTransform in class TryStmt
Returns:
The optional node for child Finally.
Retrieves the ExceptionHandler child.

This method does not invoke AST transformations.

Overrides:getExceptionHandlerNoTransform in class TryStmt
Returns:
The current node used as the ExceptionHandler child.
Retrieves the child position of the optional child ExceptionHandler.
Overrides:getExceptionHandlerChildPosition in class TryStmt
Returns:
The the child position of the optional child ExceptionHandler.
public boolean Define_handlesException(ASTNode caller,
                                       ASTNode child,
                                       TypeDecl exceptionType)
Overrides:Define_handlesException in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 113
protected boolean canDefine_handlesException(ASTNode caller,
                                             ASTNode child,
                                             TypeDecl exceptionType)
public boolean Define_reachableCatchClause(ASTNode caller,
                                           ASTNode child,
                                           TypeDecl exceptionType)
Overrides:Define_reachableCatchClause in class TryStmt
Source
Declared in /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag at line 185
protected boolean canDefine_reachableCatchClause(ASTNode caller,
                                                 ASTNode child,
                                                 TypeDecl exceptionType)
public org.extendj.ast.SimpleSet Define_lookupVariable(ASTNode caller,
                                                       ASTNode child,
                                                       java.lang.String name)
Overrides:Define_lookupVariable in class ASTNode<ASTNode>
Source
Declared in /home/jesper/git/extendj/java8/frontend/LookupVariable.jrag at line 30
protected boolean canDefine_lookupVariable(ASTNode caller,
                                           ASTNode child,
                                           java.lang.String name)
public org.extendj.ast.VariableScope Define_outerScope(ASTNode caller,
                                                       ASTNode child)
Overrides:Define_outerScope in class ASTNode<ASTNode>
Source
Declared in /home/jesper/git/extendj/java8/frontend/NameCheck.jrag at line 30
protected boolean canDefine_outerScope(ASTNode caller,
                                       ASTNode child)
public boolean Define_resourcePreviouslyDeclared(ASTNode caller,
                                                 ASTNode child,
                                                 java.lang.String name)
Overrides:Define_resourcePreviouslyDeclared in class ASTNode<ASTNode>
Source
Declared in /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag at line 183
protected boolean canDefine_resourcePreviouslyDeclared(ASTNode caller,
                                                       ASTNode child,
                                                       java.lang.String name)
public boolean Define_isDAbefore(ASTNode caller,
                                 ASTNode child,
                                 org.extendj.ast.Variable v)
Overrides:Define_isDAbefore in class TryStmt
Source
Declared in /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag at line 255
protected boolean canDefine_isDAbefore(ASTNode caller,
                                       ASTNode child,
                                       org.extendj.ast.Variable v)
public int Define_localNum(ASTNode caller,
                           ASTNode child)
Overrides:Define_localNum in class TryStmt
Source
Declared in /home/jesper/git/extendj/java7/backend/MultiCatch.jrag at line 64
protected boolean canDefine_localNum(ASTNode caller,
                                     ASTNode child)
Overrides:rewriteTo in class TryStmt
public org.extendj.ast.SimpleSet lookupVariable(java.lang.String name)
public boolean isDUafterFinally(org.extendj.ast.Variable v)
public boolean isDAafterFinally(org.extendj.ast.Variable v)
public org.extendj.ast.FinallyHost enclosingFinally(Stmt branch)

Fields

protected java.util.Map localLookup_String_values
protected java.util.Map isDAafter_Variable_values
protected java.util.Map catchableException_TypeDecl_values
protected boolean getTransformed_computed
protected java.util.Map handlesException_TypeDecl_values
protected boolean typeError_computed
protected java.util.Map lookupVariable_String_values

Inherited Members

Attributes inherited from org.extendj.ast.TryStmt

Attributes inherited from org.extendj.ast.Stmt

Attributes inherited from org.extendj.ast.ASTNode

Methods inherited from class org.extendj.ast.TryStmt

Methods inherited from class org.extendj.ast.Stmt

Methods inherited from class org.extendj.ast.ASTNode

Methods inherited from class beaver.Symbol

getColumn
getEnd
getId
getLine
getStart
makePosition

Methods inherited from class java.lang.Object

equals
finalize
getClass
hashCode
notify
notifyAll
wait
wait
wait

Fields inherited from org.extendj.ast.TryStmt

Fields inherited from org.extendj.ast.Stmt

Fields inherited from org.extendj.ast.ASTNode

Fields inherited from beaver.Symbol

end
id
start
value