Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQmlJS::Dom::AstComments Class Referencefinal

Associates comments with AST::Node *. More...

#include <qqmldomcomments_p.h>

Inheritance diagram for QQmlJS::Dom::AstComments:
Collaboration diagram for QQmlJS::Dom::AstComments:

Public Member Functions

DomType kind () const override
bool iterateDirectSubpaths (const DomItem &self, DirectVisitor) const override
std::shared_ptr< AstCommentsmakeCopy (const DomItem &self) const
Path canonicalPath (const DomItem &self) const override
 AstComments (const std::shared_ptr< Engine > &e)
 AstComments (const AstComments &o)
const CommentedElementcommentForNode (AST::Node *n, CommentAnchor location) const
std::pair< QList< Comment >, QList< Comment > > collectPreAndPostComments () const
void addComment (AST::Node *n, CommentAnchor location, const Comment &comment)
QMultiMap< quint32, const QList< Comment > * > allCommentsInNode (AST::Node *n)
Public Member Functions inherited from QQmlJS::Dom::OwningItem
 OwningItem (const OwningItem &o)
 OwningItem (int derivedFrom=0)
 OwningItem (int derivedFrom, const QDateTime &lastDataUpdateAt)
 OwningItem (const OwningItem &&)=delete
OwningItemoperator= (const OwningItem &&)=delete
bool iterateDirectSubpaths (const DomItem &self, DirectVisitor) const override
std::shared_ptr< OwningItemmakeCopy (const DomItem &self) const
Path pathFromOwner () const override final
DomItem containingObject (const DomItem &self) const override
int derivedFrom () const
virtual int revision () const
QDateTime createdAt () const
virtual QDateTime lastDataUpdateAt () const
virtual void refreshedDataAt (QDateTime tNew)
virtual bool frozen () const
virtual bool freeze ()
QDateTime frozenAt () const
virtual void addError (const DomItem &self, ErrorMessage &&msg)
void addErrorLocal (ErrorMessage &&msg)
void clearErrors (const ErrorGroups &groups=ErrorGroups({}))
bool iterateErrors (const DomItem &self, function_ref< bool(const DomItem &source, const ErrorMessage &msg)> visitor, const Path &inPath=Path())
QMultiMap< Path, ErrorMessagelocalErrors () const
virtual bool iterateSubOwners (const DomItem &self, function_ref< bool(const DomItem &owner)> visitor)
QBasicMutexmutex () const
Public Member Functions inherited from QQmlJS::Dom::DomBase
virtual ~DomBase ()=default
DomBasedomBase ()
const DomBasedomBase () const
virtual DomKind domKind () const
virtual void dump (const DomItem &, const Sink &sink, int indent, FilterT filter) const
virtual quintptr id () const
QString typeName () const
virtual QList< QStringfields (const DomItem &self) const
virtual DomItem field (const DomItem &self, QStringView name) const
virtual index_type indexes (const DomItem &self) const
virtual DomItem index (const DomItem &self, index_type index) const
virtual QSet< QString > const keys (const DomItem &self) const
virtual DomItem key (const DomItem &self, const QString &name) const
virtual QString canonicalFilePath (const DomItem &self) const
virtual void writeOut (const DomItem &self, OutWriter &lw) const
virtual QCborValue value () const

Static Public Attributes

static constexpr DomType kindValue = DomType::AstComments

Protected Types

using CommentKey = std::pair<AST::Node *, CommentAnchor>

Protected Member Functions

std::shared_ptr< OwningItemdoCopy (const DomItem &) const override

Additional Inherited Members

Public Types inherited from QQmlJS::Dom::DomBase
using FilterT = function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)>
Static Public Member Functions inherited from QQmlJS::Dom::OwningItem
static int nextRevision ()

Detailed Description

Associates comments with AST::Node *.

Stores the comments associated with javascript AST::Node pointers.

Comments are associated to the largest closest node with the following algorithm: \list

  • comments of a node can either be preComments or postComments (before or after the element)
  • define start and end for each element, if two elements start (or end) at the same place the first (larger) wins.
  • associate the comments either with the element just before or just after unless the comments is inside an element (meaning that going back there is a start before finding an end, or going forward an end is met before a start).
  • to choose between the element before or after, we look at the start of the comment, if it is on a new line then associating it as preComment to the element after is preferred, otherwise post comment of the previous element (inline element). This is the only space dependent choice, making comment assignment quite robust
  • if the comment is intrinsically inside all elements then it is moved to before the smallest element. This is the largest reorganization performed, and it is still quite small and difficult to trigger.
  • 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. This allows a better reproduction of the comments. \endlist

Definition at line 228 of file qqmldomcomments_p.h.

Member Typedef Documentation

◆ CommentKey

Definition at line 236 of file qqmldomcomments_p.h.

Constructor & Destructor Documentation

◆ AstComments() [1/2]

QQmlJS::Dom::AstComments::AstComments ( const std::shared_ptr< Engine > & e)
inline

Definition at line 248 of file qqmldomcomments_p.h.

◆ AstComments() [2/2]

QQmlJS::Dom::AstComments::AstComments ( const AstComments & o)
inline

Definition at line 249 of file qqmldomcomments_p.h.

References AstComments().

Referenced by AstComments().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ addComment()

void QQmlJS::Dom::AstComments::addComment ( AST::Node * n,
CommentAnchor location,
const Comment & comment )
inline

Definition at line 272 of file qqmldomcomments_p.h.

◆ allCommentsInNode()

QMultiMap< quint32, const QList< Comment > * > QQmlJS::Dom::AstComments::allCommentsInNode ( AST::Node * n)

◆ canonicalPath()

Path QQmlJS::Dom::AstComments::canonicalPath ( const DomItem & self) const
inlineoverridevirtual

Implements QQmlJS::Dom::OwningItem.

Definition at line 247 of file qqmldomcomments_p.h.

◆ collectPreAndPostComments()

std::pair< QList< Comment >, QList< Comment > > QQmlJS::Dom::AstComments::collectPreAndPostComments ( ) const
inline

Definition at line 261 of file qqmldomcomments_p.h.

◆ commentForNode()

const CommentedElement * QQmlJS::Dom::AstComments::commentForNode ( AST::Node * n,
CommentAnchor location ) const
inline

Definition at line 255 of file qqmldomcomments_p.h.

◆ doCopy()

std::shared_ptr< OwningItem > QQmlJS::Dom::AstComments::doCopy ( const DomItem & ) const
inlineoverrideprotectedvirtual

Implements QQmlJS::Dom::OwningItem.

Definition at line 231 of file qqmldomcomments_p.h.

◆ iterateDirectSubpaths()

bool QQmlJS::Dom::AstComments::iterateDirectSubpaths ( const DomItem & self,
DirectVisitor visitor ) const
overridevirtual

Implements QQmlJS::Dom::DomBase.

Definition at line 786 of file qqmldomcomments.cpp.

◆ kind()

DomType QQmlJS::Dom::AstComments::kind ( ) const
inlineoverridevirtual

Implements QQmlJS::Dom::DomBase.

Definition at line 240 of file qqmldomcomments_p.h.

References kindValue.

◆ makeCopy()

std::shared_ptr< AstComments > QQmlJS::Dom::AstComments::makeCopy ( const DomItem & self) const
inline

Definition at line 242 of file qqmldomcomments_p.h.

Member Data Documentation

◆ kindValue

DomType QQmlJS::Dom::AstComments::kindValue = DomType::AstComments
staticconstexpr

Definition at line 239 of file qqmldomcomments_p.h.

Referenced by kind().


The documentation for this class was generated from the following files: