Class Comment
java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.comments.Comment
- All Implemented Interfaces:
NodeWithRange<Node>,NodeWithTokenRange<Node>,Observable,Visitable,HasParentNode<Node>,Cloneable
- Direct Known Subclasses:
BlockComment,JavadocComment,LineComment
Abstract class for all AST nodes that represent comments.
- Author:
- Julio Vilmar Gesser
- See Also:
BlockComment,LineComment,JavadocComment
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal -
Field Summary
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY -
Constructor Summary
ConstructorsConstructorDescriptionComment(TokenRange tokenRange, String content)This constructor is used by the parser and is considered private. -
Method Summary
Modifier and TypeMethodDescriptionclone()Finds the root node of this AST by finding the topmost parent.Return the text of the comment.voidifBlockComment(Consumer<BlockComment> action)voidifJavadocComment(Consumer<JavadocComment> action)voidifLineComment(Consumer<LineComment> action)booleanbooleanbooleanbooleanisOrphan()booleanremove()Try to remove this node from the parentbooleanbooleansetComment(Comment comment)Use this to store additional information to this node.setCommentedNode(Node commentedNode)Sets the commentedNodesetContent(String content)Sets the text of the comment.Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, isRegistered, notifyPropertyChange, register, register, registerForSubtree, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walkMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, hasParentNode, isDescendantOfMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRange
-
Constructor Details
-
Comment
-
Comment
This constructor is used by the parser and is considered private.
-
-
Method Details
-
getContent
Return the text of the comment.- Returns:
- text of the comment
-
setContent
Sets the text of the comment.- Parameters:
content- the text of the comment to set
-
isLineComment
public boolean isLineComment() -
asLineComment
-
getCommentedNode
-
setCommentedNode
Sets the commentedNode- Parameters:
commentedNode- the commentedNode, can be null- Returns:
- this, the Comment
-
isOrphan
public boolean isOrphan() -
setComment
Description copied from class:NodeUse this to store additional information to this node.- Overrides:
setCommentin classNode- Parameters:
comment- to be set
-
remove
public boolean remove()Description copied from class:NodeTry to remove this node from the parent -
findRootNode
Description copied from class:NodeFinds the root node of this AST by finding the topmost parent.- Overrides:
findRootNodein classNode
-
remove
-
clone
-
getMetaModel
- Overrides:
getMetaModelin classNode- Returns:
- get JavaParser specific node introspection information.
-
replace
-
isBlockComment
public boolean isBlockComment() -
asBlockComment
-
isJavadocComment
public boolean isJavadocComment() -
asJavadocComment
-
ifBlockComment
-
ifJavadocComment
-
ifLineComment
-
toBlockComment
-
toJavadocComment
-
toLineComment
-