Class SynchronizedStmt
- java.lang.Object
-
- com.tonic.analysis.source.ast.stmt.SynchronizedStmt
-
-
Constructor Summary
Constructors Constructor Description SynchronizedStmt(Expression lock, Statement body)Creates a synchronized block with an unknown location.SynchronizedStmt(Expression lock, Statement body, SourceLocation location)Creates a synchronized block and parents the lock and body to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.StatementgetBody()List<ASTNode>getChildren()Lists the direct children a node holds, in source order.SourceLocationgetLocation()Gets the source location of this node.ExpressiongetLock()ASTNodegetParent()Gets the parent node in the AST tree.voidsetBody(Statement body)Replaces the guarded body, reparenting old and new nodes.voidsetLocation(SourceLocation location)Sets this statement's source location.voidsetLock(Expression lock)Replaces the monitor expression, reparenting old and new nodes.voidsetParent(ASTNode parent)Sets the enclosing AST node.StringtoString()SynchronizedStmtwithBody(Statement body)Replaces the guarded body, reparenting old and new nodes.SynchronizedStmtwithLock(Expression lock)Replaces the monitor expression, reparenting old and new nodes.-
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
-
SynchronizedStmt
public SynchronizedStmt(Expression lock, Statement body, SourceLocation location)
Creates a synchronized block and parents the lock and body to it.- Parameters:
lock- the monitor expressionbody- the guarded bodylocation- source location, or null for unknown- Throws:
NullPointerException- if lock or body is null
-
SynchronizedStmt
public SynchronizedStmt(Expression lock, Statement body)
Creates a synchronized block with an unknown location.- Parameters:
lock- the monitor expressionbody- the guarded body- Throws:
NullPointerException- if lock or body is null
-
-
Method Detail
-
getLock
public Expression getLock()
- Returns:
- the lock
-
setLock
public void setLock(Expression lock)
Replaces the monitor expression, reparenting old and new nodes.- Parameters:
lock- the new monitor expression
-
getBody
public Statement getBody()
- Returns:
- the body
-
setBody
public void setBody(Statement body)
Replaces the guarded body, reparenting old and new nodes.- Parameters:
body- the new body
-
getLocation
public SourceLocation getLocation()
Description copied from interface:ASTNodeGets the source location of this node.- Specified by:
getLocationin interfaceASTNode- Returns:
- the source location, or null if unknown
-
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 AST node.
-
withLock
public SynchronizedStmt withLock(Expression lock)
Replaces the monitor expression, reparenting old and new nodes.- Parameters:
lock- the new monitor expression- Returns:
- this statement
- Throws:
NullPointerException- if lock is null
-
withBody
public SynchronizedStmt withBody(Statement body)
Replaces the guarded body, reparenting old and new nodes.- Parameters:
body- the new body- Returns:
- this statement
- Throws:
NullPointerException- if body 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
-
-