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
This code element defines a comment
Example:
int x = 0;
// a comment
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
This line separator is used in comments returned bygetContent()
. -
Method Summary
Modifier and TypeMethodDescriptionUtility method to for casting the object, throws an exception if not of the correct typeclone()
Clone the element which calls this method in a new object.Get the type of the commentGet the content of the comment<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 Details
-
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 Details
-
getContent
String getContent()Get the content of the comment- Returns:
- the content of the comment
-
setContent
-
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
-
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
-