Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 QHash< AST::Node *, CommentedElement > & commentedElements () const
 
QHash< AST::Node *, CommentedElement > & commentedElements ()
 
CommentedElementcommentForNode (AST::Node *n)
 
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
 
Path pathFromOwner (const DomItem &) 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
 
bool iterateDirectSubpathsConst (const DomItem &self, DirectVisitor) 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 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 200 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 218 of file qqmldomcomments_p.h.

◆ AstComments() [2/2]

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

Definition at line 219 of file qqmldomcomments_p.h.

Member Function Documentation

◆ 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 217 of file qqmldomcomments_p.h.

◆ commentedElements() [1/2]

QHash< AST::Node *, CommentedElement > & QQmlJS::Dom::AstComments::commentedElements ( )
inline

Definition at line 229 of file qqmldomcomments_p.h.

◆ commentedElements() [2/2]

const QHash< AST::Node *, CommentedElement > & QQmlJS::Dom::AstComments::commentedElements ( ) const
inline

Definition at line 224 of file qqmldomcomments_p.h.

◆ commentForNode()

CommentedElement * QQmlJS::Dom::AstComments::commentForNode ( AST::Node * n)
inline

Definition at line 234 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 203 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 659 of file qqmldomcomments.cpp.

References post().

+ Here is the call graph for this function:

◆ kind()

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

Implements QQmlJS::Dom::DomBase.

Definition at line 210 of file qqmldomcomments_p.h.

◆ makeCopy()

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

Definition at line 212 of file qqmldomcomments_p.h.

Member Data Documentation

◆ kindValue

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

Definition at line 209 of file qqmldomcomments_p.h.


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