4#ifndef QQMLDOMCOMMENTS_P_H
5#define QQMLDOMCOMMENTS_P_H
23#include <QtQml/private/qqmljsast_p.h>
24#include <QtQml/private/qqmljsengine_p.h>
26#include <QtCore/QMultiMap>
27#include <QtCore/QHash>
28#include <QtCore/QStack>
29#include <QtCore/QCoreApplication>
49 return rawComment.
mid(commentContentBegin, commentContentEnd - commentContentEnd);
54 return rawComment.
mid(commentEnd, rawComment.size() - commentEnd);
67 bool hasStartNewline =
false;
68 bool hasEndNewline =
false;
69 int nContentNewlines = 0;
78 constexpr static DomType kindValue = DomType::Comment;
85 : m_comment(
c), m_location(loc), m_newlinesBefore(newlinesBefore), m_type(
type)
90 : m_comment(
c), m_location(loc), m_newlinesBefore(newlinesBefore), m_type(
type)
105 return c1.m_newlinesBefore ==
c2.m_newlinesBefore && c1.m_comment ==
c2.m_comment;
112 int m_newlinesBefore;
119 constexpr static DomType kindValue = DomType::CommentedElement;
128 return c1.m_preComments ==
c2.m_preComments && c1.m_postComments ==
c2.m_postComments;
137 if (comment.
type() == Comment::CommentType::Pre)
138 m_preComments.append(comment);
140 m_postComments.append(comment);
143 const QList<Comment> &
preComments()
const {
return m_preComments;}
147 QList<Comment> m_preComments;
148 QList<Comment> m_postComments;
154 constexpr static DomType kindValue = DomType::RegionComments;
161 return c1.m_regionComments ==
c2.m_regionComments;
168 const QMap<FileLocationRegion, CommentedElement> &
regionComments()
const {
return m_regionComments;}
171 if (comment.
type() == Comment::CommentType::Pre)
172 return addPreComment(comment, region);
174 return addPostComment(comment, region);
180 auto &preList = m_regionComments[region].preComments();
182 m_regionComments[region].addComment(comment);
183 return Path::Field(Fields::regionComments)
185 .
field(Fields::preComments)
189 Path addPostComment(
const Comment &comment, FileLocationRegion region)
191 auto &postList = m_regionComments[region].postComments();
192 index_type idx = postList.size();
193 m_regionComments[region].addComment(comment);
194 return Path::Field(Fields::regionComments)
195 .key(fileLocationRegionName(region))
196 .field(Fields::postComments)
200 QMap<FileLocationRegion, CommentedElement> m_regionComments;
208 return std::make_shared<AstComments>(*
this);
212 constexpr static DomType kindValue = DomType::AstComments;
217 return std::static_pointer_cast<AstComments>(doCopy(self));
223 :
OwningItem(
o), m_engine(
o.m_engine), m_commentedElements(
o.m_commentedElements)
229 return m_commentedElements;
234 return m_commentedElements;
239 if (m_commentedElements.contains(
n))
240 return &(m_commentedElements[
n]);
246 std::shared_ptr<Engine> m_engine;
247 QHash<AST::Node *, CommentedElement> m_commentedElements;
257 const std::shared_ptr<AstComments> &astComments);
void accept(BaseVisitor *visitor)
std::shared_ptr< AttachedInfoT< FileLocations > > Tree
Path key(const QString &name) const
Path field(const QString &name) const
Path index(index_type i) const
A vistor that visits all the AST:Node.
void endVisit(AST::Elision *el) override
bool visit(AST::UiPublicMember *el) override
bool visit(AST::UiParameterList *el) override
bool visit(AST::UiEnumDeclaration *el) override
void throwRecursionDepthError() override
bool visit(AST::UiQualifiedId *el) override
bool visit(AST::UiScriptBinding *el) override
bool visit(AST::TemplateLiteral *el) override
bool visit(AST::UiObjectBinding *el) override
static QSet< int > uiKinds()
returns a set with all Ui* Nodes (i.e.
void endVisit(AST::UiEnumMemberList *el) override
bool visit(AST::UiObjectDefinition *el) override
void endVisit(AST::UiPublicMember *el) override
bool visit(AST::UiInlineComponent *el) override
void endVisit(AST::UiParameterList *el) override
void endVisit(AST::UiImport *el) override
bool visit(AST::UiArrayBinding *el) override
bool visit(AST::UiSourceElement *el) override
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString fileLocationRegionName(FileLocationRegion region)
Combined button and popup list for selecting options.
#define Q_DECLARE_TR_FUNCTIONS(context)
GLuint const GLint * locations
gzip write("uncompressed data")