4#ifndef QMLDOMATTACHEDINFO_P_H
5#define QMLDOMATTACHEDINFO_P_H
28template<
typename TreePtr>
58 SetRootTreePath = 0x1,
59 SetFoundTreePath = 0x2,
68 DomType kind()
const override {
return kindValue; }
74 return std::static_pointer_cast<AttachedInfo>(doCopy(self));
84 static Ptr ensure(Ptr self,
Path path, PathType pType = PathType::Relative);
85 static Ptr find(Ptr self,
Path p, PathType pType = PathType::Relative);
88 FindOptions options = AttachedInfo::FindOption::None);
91 return findAttachedInfo(
item, fieldName, FindOption::None).foundTree;
97 if (pType == PathType::Canonical)
98 p =
p.mid(m_path.length());
99 Path resPath = self.canonicalPath();
101 resPath = resPath.
field(Fields::subItems).
key(pEl.toString());
103 return self.copy(resPtr, resPath);
110 return itemAtPath(self,
p, pType).
field(Fields::infoItem);
114 PathType pType = PathType::Relative)
117 if (pType == PathType::Canonical)
118 p =
p.mid(m_path.length());
119 Path resPath = self.canonicalPath();
121 resPath = resPath.
field(Fields::subItems).
key(pEl.toString());
129 PathType pType = PathType::Relative)
131 return ensureItemAtPath(self,
p, pType).
field(Fields::infoItem);
138 return const_cast<AttachedInfo *
>(
this)->infoItem(self);
153template<
typename Info>
157 constexpr static DomType kindValue = DomType::AttachedInfo;
158 using Ptr = std::shared_ptr<AttachedInfoT>;
166 auto end =
o.m_subItems.end();
167 auto i =
o.m_subItems.begin();
169 m_subItems.insert(
i.key(),
Ptr(
170 new AttachedInfoT(*std::static_pointer_cast<AttachedInfoT>(
i.value()).get())));
179 return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::ensure(self,
path, pType));
183 return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::find(self,
p, pType));
187 AttachedInfo::FindOptions options)
189 return AttachedInfo::findAttachedInfo(
item, fieldName, options)
190 .template as<AttachedInfoT>();
194 return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::treePtr(
item, fieldName));
199 if (visitor(pNow,
base)) {
203 if (!visitTree(std::static_pointer_cast<AttachedInfoT>(
it.value()), visitor, pNow))
221 return std::static_pointer_cast<AttachedInfoT>(doCopy(self));
224 Ptr parent()
const {
return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::parent()); }
240 using Tree = std::shared_ptr<AttachedInfoT<FileLocations>>;
241 constexpr static DomType kindValue = DomType::FileLocations;
246 static Tree createTree(
Path basePath);
247 static Tree ensure(Tree
base,
Path basePath,
258 AttachedInfo::FindOptions options = AttachedInfo::FindOption::Default);
276 using Tree = std::shared_ptr<AttachedInfoT<UpdatedScriptExpression>>;
277 constexpr static DomType kindValue = DomType::UpdatedScriptExpression;
281 static Tree createTree(
Path basePath);
287 AttachedInfo::FindOptions options = AttachedInfo::FindOption::Default);
289 static Tree treePtr(
DomItem &);
296 std::shared_ptr<ScriptExpression>
expr;
std::optional< Path > rootTreePath
std::optional< Path > foundTreePath
AttachedInfoLookupResult< std::shared_ptr< T > > as() const
AttachedInfoT(Ptr parent=nullptr, Path p=Path())
Ptr makeCopy(DomItem &self) const
static bool visitTree(Ptr base, function_ref< bool(Path, Ptr)>visitor, Path basePath=Path())
static Ptr treePtr(DomItem &item, QStringView fieldName)
static Ptr find(Ptr self, Path p, PathType pType=PathType::Relative)
std::shared_ptr< AttachedInfoT > Ptr
const Info & info() const
static Ptr ensure(Ptr self, Path path, PathType pType=PathType::Relative)
DomItem infoItem(DomItem &self) override
AttachedInfo::Ptr instantiate(AttachedInfo::Ptr parent, Path p=Path()) const override
static Ptr createTree(Path p=Path())
std::shared_ptr< OwningItem > doCopy(DomItem &) const override
AttachedInfoT(const AttachedInfoT &o)
static AttachedInfoLookupResult< Ptr > findAttachedInfo(DomItem &item, QStringView fieldName, AttachedInfo::FindOptions options)
Attached info creates a tree to attach extra info to DomItems.
AttachedInfo(Ptr parent=nullptr, Path p=Path())
DomItem infoAtPath(DomItem &self, Path p, PathType pType=PathType::Relative) const
void setSubItems(QMap< Path, Ptr > v)
Path canonicalPath(DomItem &self) const override
virtual AttachedInfo::Ptr instantiate(AttachedInfo::Ptr parent, Path p=Path()) const =0
AttachedInfo::Ptr makeCopy(DomItem &self) const
DomItem infoItem(DomItem &self) const
MutableDomItem ensureInfoAtPath(MutableDomItem &self, Path p, PathType pType=PathType::Relative)
virtual DomItem infoItem(DomItem &self)=0
static Ptr treePtr(DomItem &item, QStringView fieldName)
MutableDomItem ensureItemAtPath(MutableDomItem &self, Path p, PathType pType=PathType::Relative)
QMap< Path, Ptr > m_subItems
std::shared_ptr< AttachedInfo > Ptr
std::weak_ptr< AttachedInfo > m_parent
DomItem itemAtPath(DomItem &self, Path p, PathType pType=PathType::Relative) const
QMap< Path, Ptr > subItems() const
DomItem field(QStringView name)
Represents and maintains a mapping between elements and their location in a file.
SourceLocation fullRegion
QMap< QString, QList< SourceLocation > > preCommentLocations
std::shared_ptr< AttachedInfoT< FileLocations > > Tree
QMap< QString, QList< SourceLocation > > postCommentLocations
static Tree find(Tree self, Path p, AttachedInfo::PathType pType=AttachedInfo::PathType::Relative)
QMap< QString, SourceLocation > regions
MutableDomItem field(QStringView name)
Path key(QString name) const
Path path(Path toAdd, bool avoidToAddAsBase=false) const
Path field(QString name) const
std::shared_ptr< AttachedInfoT< UpdatedScriptExpression > > Tree
std::shared_ptr< ScriptExpression > expr
\macro QT_RESTRICTED_CAST_FROM_ASCII
const_iterator cbegin() const
const_iterator cend() const
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
GLsizei const GLfloat * v
[13]
GLsizei const GLchar *const * path
static QT_BEGIN_NAMESPACE const uint Default
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent