Package spoon.reflect.code
Interface CtComment
-
- All Superinterfaces:
Cloneable
,CtCodeElement
,CtElement
,CtQueryable
,CtStatement
,CtVisitable
,FactoryAccessor
,Serializable
,SourcePositionHolder
- All Known Subinterfaces:
CtJavaDoc
- All Known Implementing Classes:
CtCommentImpl
,CtJavaDocImpl
public interface CtComment extends CtStatement
This code element defines a comment Example:int x = 0; // a comment
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CtComment.CommentType
-
Field Summary
Fields Modifier and Type Field Description static String
LINE_SEPARATOR
This line separator is used in comments returned bygetContent()
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CtJavaDoc
asJavaDoc()
Utility method to for casting the object, throws an exception if not of the correct typeCtComment
clone()
Clone the element which calls this method in a new object.CtComment.CommentType
getCommentType()
Get the type of the commentString
getContent()
Get the content of the commentString
getRawContent()
<E extends CtComment>
EsetCommentType(CtComment.CommentType commentType)
<E extends CtComment>
EsetContent(String content)
-
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.code.CtStatement
comment, getLabel, insertAfter, insertAfter, insertBefore, insertBefore, setLabel
-
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
-
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
-
-
-
Field Detail
-
LINE_SEPARATOR
static final String LINE_SEPARATOR
This line separator is used in comments returned bygetContent()
. It is OS independent. It has no influence to pretty printed comments, which uses by default OS dependent line separator- See Also:
- Constant Field Values
-
-
Method Detail
-
getContent
String getContent()
Get the content of the comment- Returns:
- the content of the comment
-
getRawContent
String getRawContent()
- Returns:
- the original raw comment from the source file including comment prefix and suffix, indentation (including TABs) original EOLs,
based on the attached position object (the returned value is "derived" from the position).
If the file pointed to in the position object does not exist on disk anymore,
then the empty string "" is returned
Note: the call of
setContent(String)
doesn't influence the returned value, only the value of the position object.
-
getCommentType
CtComment.CommentType getCommentType()
Get the type of the comment- Returns:
- the comment type
-
setCommentType
<E extends CtComment> E setCommentType(CtComment.CommentType commentType)
-
clone
CtComment 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
- Specified by:
clone
in interfaceCtStatement
-
asJavaDoc
CtJavaDoc asJavaDoc()
Utility method to for casting the object, throws an exception if not of the correct type
-
-