Package spoon.reflect.code
Interface CtStatementList
- All Superinterfaces:
Cloneable
,CtCodeElement
,CtElement
,CtQueryable
,CtVisitable
,FactoryAccessor
,Iterable<CtStatement>
,Serializable
,SourcePositionHolder
- All Known Implementing Classes:
CtBlockImpl
,CtCaseImpl
,CtStatementListImpl
This code element represents a list of statements. It is not a valid Java
program element and is never used directly, on contrary to
a
CtBlock
.-
Method Summary
Modifier and TypeMethodDescription<T extends CtStatementList>
TaddStatement(int index, CtStatement statement)
Inserts the given statement at a specific position in the list of statements Shifts the statement currently at that position (if any) and any subsequent statements to the right (adds one to their indices).<T extends CtStatementList>
TaddStatement(CtStatement statement)
Adds a statement at the end of the list.clone()
Clone the element which calls this method in a new object.<T extends CtStatement>
TGets the last statement of this block.<T extends CtStatement>
TgetStatement(int i)
Gets the ith statement of this block.Returns the statement list.<T extends CtStatementList>
TinsertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement)
Inserts the given statement after a set of insertion points given by a filter.<T extends CtStatementList>
TinsertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)
Inserts the given statement list after a set of insertion points given by a filter.<T extends CtStatementList>
TinsertBefore(Filter<? extends CtStatement> insertionPoints, CtStatement statement)
Inserts the given statement before a set of insertion points given by a filter.<T extends CtStatementList>
TinsertBefore(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)
Inserts the given statement list before a set of insertion points given by a filter.<T extends CtStatementList>
TinsertBegin(CtStatement statement)
Inserts the given statement at the beginning of the block.<T extends CtStatementList>
TinsertBegin(CtStatementList statements)
Inserts the given statement list at the beginning of the block.<T extends CtStatementList>
TinsertEnd(CtStatement statement)
Inserts the given statement at the end of the block.<T extends CtStatementList>
TinsertEnd(CtStatementList statements)
Inserts the given statements at the end of the block.void
removeStatement(CtStatement statement)
Removes a statement.<T extends CtStatementList>
TsetStatements(List<CtStatement> statements)
Sets the statement list.Methods inherited from interface spoon.reflect.code.CtCodeElement
partiallyEvaluate
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getStatements
List<CtStatement> getStatements()Returns the statement list. -
setStatements
Sets the statement list. -
addStatement
Adds a statement at the end of the list. -
addStatement
Inserts the given statement at a specific position in the list of statements Shifts the statement currently at that position (if any) and any subsequent statements to the right (adds one to their indices). -
insertBegin
Inserts the given statement at the beginning of the block. -
insertBegin
Inserts the given statement list at the beginning of the block. -
insertEnd
Inserts the given statement at the end of the block. -
insertEnd
Inserts the given statements at the end of the block. -
insertBefore
<T extends CtStatementList> T insertBefore(Filter<? extends CtStatement> insertionPoints, CtStatement statement)Inserts the given statement before a set of insertion points given by a filter. -
insertBefore
<T extends CtStatementList> T insertBefore(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)Inserts the given statement list before a set of insertion points given by a filter. -
insertAfter
<T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement)Inserts the given statement after a set of insertion points given by a filter. -
insertAfter
<T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)Inserts the given statement list after a set of insertion points given by a filter. -
getStatement
Gets the ith statement of this block. -
getLastStatement
Gets the last statement of this block. -
removeStatement
Removes a statement. -
clone
CtStatementList clone()Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtCodeElement
- Specified by:
clone
in interfaceCtElement
-