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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal -
Field Summary
FieldsFields inherited from class 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 TypeMethodDescriptionasString()clone()Finds the root node of this AST by finding the topmost parent.Return the text of the comment.abstract Stringabstract StringvoidifBlockComment(Consumer<BlockComment> action) voidifJavadocComment(Consumer<JavadocComment> action) voidifLineComment(Consumer<LineComment> action) voidifMarkdownComment(Consumer<MarkdownComment> action) voidbooleanbooleanbooleanbooleanbooleanisOrphan()booleanbooleanremove()Try to remove this node from the parentsetComment(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 Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findByRange, findCompilationUnit, findData, 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, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walkMethods inherited from interface HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOfMethods inherited from interface NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRange
-
Field Details
-
-
commentedNode
-
-
Constructor Details
-
Comment
-
Comment
This constructor is used by the parser and is considered private.
-
-
Method Details
-
getContent
-
setContent
-
isLineComment
public boolean isLineComment() -
asLineComment
-
getCommentedNode
-
setCommentedNode
-
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
-
findRootNode
Description copied from class:NodeFinds the root node of this AST by finding the topmost parent.- Overrides:
findRootNodein classNode
-
clone
-
getMetaModel
- Overrides:
getMetaModelin classNode- Returns:
- get JavaParser specific node introspection information.
-
isBlockComment
public boolean isBlockComment() -
asBlockComment
-
isJavadocComment
public boolean isJavadocComment() -
asJavadocComment
-
ifBlockComment
-
ifJavadocComment
-
ifLineComment
-
toBlockComment
-
toJavadocComment
-
toLineComment
-
getHeader
-
asString
-
isMarkdownComment
public boolean isMarkdownComment() -
asMarkdownComment
-
toMarkdownComment
-
ifMarkdownComment
-
isTraditionalJavadocComment
public boolean isTraditionalJavadocComment() -
asTraditionalJavadocComment
-
toTraditionalJavadocComment
-
ifTraditionalJavadocComment
-