![]() |
Qt 6.x
The Qt SDK
|
Represents a comment. More...
#include <qqmldomcomments_p.h>
Public Member Functions | |
DomType | kind () const |
Comment (QString c, int newlinesBefore=1) | |
Comment (QStringView c, int newlinesBefore=1) | |
bool | iterateDirectSubpaths (DomItem &self, DirectVisitor visitor) |
Expose attributes to the Dom. | |
int | newlinesBefore () const |
void | setNewlinesBefore (int n) |
QStringView | rawComment () const |
CommentInfo | info () const |
void | write (OutWriter &lw, SourceLocation *commentLocation=nullptr) const |
Static Public Attributes | |
static constexpr DomType | kindValue = DomType::Comment |
Friends | |
bool | operator== (const Comment &c1, const Comment &c2) |
bool | operator!= (const Comment &c1, const Comment &c2) |
Represents a comment.
Comments are not needed for execute the program, so they are aimed to the programmer, and have few functions: explaining code, adding extra info/context (who did write, when licensing,...) or disabling code. Being for the programmer and being non functional it is difficult to treat them properly. So preserving them as much as possible is the best course of action.
To acheive this comment is represented by \list
the comments are stored with the whitespace surrounding them, from the preceding newline (and recording if a newline is required before it) until the newline after.
A comment has methods to write it out again (write) and expose it to the Dom (iterateDirectSubpaths).
Definition at line 71 of file qqmldomcomments_p.h.
|
inline |
Definition at line 77 of file qqmldomcomments_p.h.
|
inline |
Definition at line 81 of file qqmldomcomments_p.h.
|
inline |
Definition at line 89 of file qqmldomcomments_p.h.
Referenced by write().
bool QQmlJS::Dom::Comment::iterateDirectSubpaths | ( | DomItem & | self, |
DirectVisitor | visitor | ||
) |
Expose attributes to the Dom.
Definition at line 193 of file qqmldomcomments.cpp.
References newlinesBefore(), and rawComment().
|
inline |
Definition at line 75 of file qqmldomcomments_p.h.
|
inline |
Definition at line 86 of file qqmldomcomments_p.h.
Referenced by iterateDirectSubpaths(), and write().
|
inline |
Definition at line 88 of file qqmldomcomments_p.h.
Referenced by QQmlJS::Dom::AstComments::collectComments(), and iterateDirectSubpaths().
|
inline |
Definition at line 87 of file qqmldomcomments_p.h.
void QQmlJS::Dom::Comment::write | ( | OutWriter & | lw, |
SourceLocation * | commentLocation = nullptr |
||
) | const |
Definition at line 201 of file qqmldomcomments.cpp.
References QQmlJS::Dom::CommentInfo::comment(), QQmlJS::Dom::LineWriter::endSourceLocation(), QQmlJS::Dom::OutWriter::ensureNewline(), QQmlJS::Dom::OutWriter::ensureSpace(), QQmlJS::Dom::OutWriter::indentNextlines, info(), QQmlJS::Dom::OutWriter::lineWriter, QStringView::mid(), newlinesBefore(), QQmlJS::Dom::CommentInfo::postWhitespace(), QQmlJS::Dom::CommentInfo::preWhitespace(), QQmlJS::Dom::LineWriter::startSourceLocation(), and QQmlJS::Dom::OutWriter::write().
Definition at line 96 of file qqmldomcomments_p.h.
Definition at line 92 of file qqmldomcomments_p.h.
|
staticconstexpr |
Definition at line 74 of file qqmldomcomments_p.h.