public final class TryCatchFinally extends GoloStatement<TryCatchFinally>
try catch finally
statement.
Represents nodes such as:
try {
# try block
} catch (ex) {
# catch block
} finally {
# finally block
}
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DUMMY_TRY_RESULT_VARIABLE |
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
TryCatchFinally |
catching(java.lang.Object block) |
TryCatchFinally |
catching(java.lang.String exceptionId,
java.lang.Object block)
Defines the catch block.
|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
static TryCatchFinally |
create(java.lang.String exceptionName,
GoloElement<?> tryBlock,
GoloElement<?> catchBlock,
GoloElement<?> finallyBlock)
Creates a complete
try catch finally statement. |
java.lang.String |
dummyExceptionName() |
TryCatchFinally |
finalizing(java.lang.Object block)
Defines the finally block.
|
Block |
getCatchBlock() |
java.lang.String |
getExceptionId()
Get the exception name.
|
int |
getExceptionRefIndex()
Returns the internal index of the exception reference.
|
Block |
getFinallyBlock() |
Block |
getTryBlock() |
boolean |
hasCatchBlock() |
boolean |
hasFinallyBlock() |
boolean |
hasReturn() |
boolean |
isTryCatch()
Check if this statement has only a catch block.
|
boolean |
isTryCatchFinally()
Check if this statement has both a catch block and a finally block.
|
boolean |
isTryFinally()
Check if this statement has only a finally block.
|
boolean |
mustJumpToFinally()
Checks if a return is present in the try or catch block and a finally is present.
|
protected void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected TryCatchFinally |
self() |
static TryCatchFinally |
tryCatch()
Creates an empty
try catch finally statement. |
TryCatchFinally |
trying(java.lang.Object block)
Defines the try block.
|
of
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, inheritedMetadata, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static final java.lang.String DUMMY_TRY_RESULT_VARIABLE
public static TryCatchFinally tryCatch()
try catch finally
statement.public static TryCatchFinally create(java.lang.String exceptionName, GoloElement<?> tryBlock, GoloElement<?> catchBlock, GoloElement<?> finallyBlock)
try catch finally
statement.
Less readable than the fluent API, but useful for meta-generation.
protected TryCatchFinally self()
self
in class GoloElement<TryCatchFinally>
public java.lang.String getExceptionId()
ex
in the previous example.
public int getExceptionRefIndex()
public Block getTryBlock()
public TryCatchFinally trying(java.lang.Object block)
This is a builder method.
block
- a Block
or a statement that will be wrapped.Block.of(Object)
public Block getCatchBlock()
public TryCatchFinally catching(java.lang.String exceptionId, java.lang.Object block)
This is a builder method.
exceptionId
- the name of the catched exception instance.block
- a Block
or a statement that will be wrapped.Block.of(Object)
public TryCatchFinally catching(java.lang.Object block)
public Block getFinallyBlock()
public TryCatchFinally finalizing(java.lang.Object block)
This is a builder method.
block
- a Block
or a statement that will be wrapped.Block.of(Object)
public java.lang.String dummyExceptionName()
public boolean hasFinallyBlock()
public boolean hasCatchBlock()
public boolean mustJumpToFinally()
In this case we must not generate a return but a jump to the finally block.
public boolean hasReturn()
public boolean isTryCatchFinally()
public boolean isTryCatch()
public boolean isTryFinally()
public void accept(GoloIrVisitor visitor)
This method should only call the visitor visitXXXX
method.
The children of this node will be visited by the
GoloElement.walk(GoloIrVisitor)
method.
accept
in class GoloElement<TryCatchFinally>
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<TryCatchFinally>
protected void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
Replace original
with newElement
if original
is a child of this node
and type matches.
replaceElement
in class GoloElement<TryCatchFinally>
original
- the original value to replace. Must be a child of this nodenewElement
- the element to replace with. Type must match.GoloElement.cantReplace()
,
GoloElement.cantReplace(GoloElement, GoloElement)
,
GoloElement.doesNotContain(GoloElement)
,
GoloElement.cantConvert(String, Object)