Class ThrowStmt
- java.lang.Object
-
- com.tonic.analysis.source.ast.stmt.ThrowStmt
-
-
Constructor Summary
Constructors Constructor Description ThrowStmt(Expression exception)Creates a throw statement with an unknown source position.ThrowStmt(Expression exception, SourceLocation location)Creates a throw statement and adopts the thrown expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.List<ASTNode>getChildren()Lists the direct children a node holds, in source order.ExpressiongetException()SourceLocationgetLocation()Gets the source location of this node.ASTNodegetParent()Gets the parent node in the AST tree.voidsetException(Expression exception)Replaces the thrown expression, adopting the new one and detaching the old.voidsetLocation(SourceLocation location)Sets this statement's source location.voidsetParent(ASTNode parent)Sets the enclosing node.StringtoString()ThrowStmtwithExpression(Expression exception)Replaces the thrown expression in place, for chaining.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Constructor Detail
-
ThrowStmt
public ThrowStmt(Expression exception, SourceLocation location)
Creates a throw statement and adopts the thrown expression.- Parameters:
exception- the expression to throwlocation- source position, null for unknown- Throws:
NullPointerException- if the exception expression is null
-
ThrowStmt
public ThrowStmt(Expression exception)
Creates a throw statement with an unknown source position.- Parameters:
exception- the expression to throw- Throws:
NullPointerException- if the exception expression is null
-
-
Method Detail
-
getException
public Expression getException()
- Returns:
- the exception
-
setException
public void setException(Expression exception)
Replaces the thrown expression, adopting the new one and detaching the old.- Parameters:
exception- the new expression to throw, may be null
-
getLocation
public SourceLocation getLocation()
Description copied from interface:ASTNodeGets the source location of this node.- Specified by:
getLocationin interfaceASTNode- Returns:
- the location
-
getParent
public ASTNode getParent()
Description copied from interface:ASTNodeGets the parent node in the AST tree.
-
setParent
public void setParent(ASTNode parent)
Sets the enclosing node.
-
withExpression
public ThrowStmt withExpression(Expression exception)
Replaces the thrown expression in place, for chaining.- Parameters:
exception- the new expression to throw- Returns:
- this statement
- Throws:
NullPointerException- if the exception expression is null
-
getChildren
public List<ASTNode> getChildren()
Description copied from interface:ASTNodeLists the direct children a node holds, in source order.- Specified by:
getChildrenin interfaceASTNode- Returns:
- the direct children, empty for a leaf
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
setLocation
public void setLocation(SourceLocation location)
Description copied from interface:StatementSets this statement's source location.- Specified by:
setLocationin interfaceStatement- Parameters:
location- the provenance to stamp, or null forSourceLocation.UNKNOWN
-
-