Package spoon.reflect.code
Interface CtStatement
- All Superinterfaces:
Cloneable
,CtCodeElement
,CtElement
,CtQueryable
,CtVisitable
,FactoryAccessor
,Serializable
,SourcePositionHolder
- All Known Subinterfaces:
CtAssert<T>
,CtAssignment<T,A>
,CtBlock<R>
,CtBreak
,CtCase<S>
,CtCFlowBreak
,CtClass<T>
,CtCodeSnippetStatement
,CtComment
,CtConstructorCall<T>
,CtContinue
,CtDo
,CtEnum<T>
,CtFor
,CtForEach
,CtIf
,CtInterface<T>
,CtInvocation<T>
,CtJavaDoc
,CtLabelledFlowBreak
,CtLocalVariable<T>
,CtLoop
,CtNewClass<T>
,CtOperatorAssignment<T,A>
,CtRecord
,CtReturn<R>
,CtSwitch<S>
,CtSynchronized
,CtThrow
,CtTry
,CtTryWithResource
,CtUnaryOperator<T>
,CtWhile
,CtYieldStatement
- All Known Implementing Classes:
CtAssertImpl
,CtAssignmentImpl
,CtBlockImpl
,CtBreakImpl
,CtCaseImpl
,CtClassImpl
,CtCodeSnippetStatementImpl
,CtCommentImpl
,CtConstructorCallImpl
,CtContinueImpl
,CtDoImpl
,CtEnumImpl
,CtForEachImpl
,CtForImpl
,CtIfImpl
,CtInterfaceImpl
,CtInvocationImpl
,CtJavaDocImpl
,CtLocalVariableImpl
,CtLoopImpl
,CtNewClassImpl
,CtOperatorAssignmentImpl
,CtRecordImpl
,CtReturnImpl
,CtStatementImpl
,CtSwitchImpl
,CtSynchronizedImpl
,CtThrowImpl
,CtTryImpl
,CtTryWithResourceImpl
,CtUnaryOperatorImpl
,CtWhileImpl
,CtYieldStatementImpl
This abstract code element represents all the statements, which can be part
of a block.
- See Also:
CtBlock
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the element which calls this method in a new object.void
comment()
Comments the statement (eg `// call()`).getLabel()
Gets the label of this statement if defined.<T extends CtStatement>
TinsertAfter(CtStatement statement)
Inserts a statement after the current statement.<T extends CtStatement>
TinsertAfter(CtStatementList statements)
Inserts a statement list before the current statement.<T extends CtStatement>
TinsertBefore(CtStatement statement)
Inserts a statement given as parameter before the current statement (this).<T extends CtStatement>
TinsertBefore(CtStatementList statements)
Inserts a statement list before the current statement.<T extends CtStatement>
TSets the label of this statement.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
-
Method Details
-
insertAfter
Inserts a statement after the current statement.- Throws:
ParentNotInitializedException
-
insertAfter
<T extends CtStatement> T insertAfter(CtStatementList statements) throws ParentNotInitializedExceptionInserts a statement list before the current statement.- Throws:
ParentNotInitializedException
-
insertBefore
Inserts a statement given as parameter before the current statement (this).- Throws:
ParentNotInitializedException
-
insertBefore
<T extends CtStatement> T insertBefore(CtStatementList statements) throws ParentNotInitializedExceptionInserts a statement list before the current statement.- Throws:
ParentNotInitializedException
-
getLabel
String getLabel()Gets the label of this statement if defined.- Returns:
- the label's name (null if undefined)
-
setLabel
Sets the label of this statement. -
comment
void comment()Comments the statement (eg `// call()`). Implemented as a replacement of the statement with a CtComment having the statement as text. -
clone
CtStatement 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
-