32#ifdef QmlDomAddCodeStr
34 QString codeStr = self.fileObject().field(Fields::code).value().toString();
36 if (loc.offset < codeStr.
length() && loc.end() <= codeStr.
length())
43 cont = cont && self.dvValueLazyField(visitor, Fields::fullRegion, [
this]() {
46 cont = cont && self.dvItemField(visitor, Fields::regions, [
this, &self, &loc2str]() {
47 return self.subMapItem(Map::fromMapRef<SourceLocation>(
48 self.pathFromOwner().field(Fields::regions),
regions,
50 return map.subLocationItem(key, el, loc2str(el));
54 && self.dvItemField(visitor, Fields::preCommentLocations, [
this, &self, &loc2str]() {
56 self.pathFromOwner().field(Fields::preCommentLocations),
60 return map.subListItem(List::fromQListRef<SourceLocation>(
61 map.pathFromOwner().appendComponent(key), el,
62 [&loc2str](DomItem &list, const PathEls::PathComponent &idx,
64 return list.subLocationItem(idx, el, loc2str(el));
69 && self.dvItemField(visitor, Fields::postCommentLocations, [
this, &self, &loc2str]() {
71 self.pathFromOwner().field(Fields::postCommentLocations),
75 return map.subListItem(List::fromQListRef<SourceLocation>(
76 map.pathFromOwner().appendComponent(
key),
el,
79 return list.subLocationItem(idx, el, loc2str(el));
89 preCommentLocations[k];
90 postCommentLocations[k];
103FileLocations::findAttachedInfo(
DomItem &
item, AttachedInfo::FindOptions options)
145 fLoc->info().regions[locName] = loc;
146 updateFullLocation(fLoc, loc);
150 addRegion(fLoc, locName.
toString(), loc);
175 cont = cont && self.dvItemField(visitor, Fields::parent, [&self,
p]() {
176 return self.copy(
p, self.m_ownerPath.dropTail(2),
p.get());
179 && self.dvValueLazyField(visitor, Fields::path, [
this]() {
return path().toString(); });
180 cont = cont && self.dvItemField(visitor, Fields::subItems, [
this, &self]() {
181 return self.subMapItem(
Map(
182 Path::Field(Fields::subItems),
185 return map.copy(m_subItems.value(
p),
map.canonicalPath().
key(
key));
189 for (
auto p : m_subItems.keys())
190 res.insert(
p.toString());
195 cont = cont && self.dvItemField(visitor, Fields::infoItem, [&self,
this]() {
196 return infoItem(self);
228 for (
auto p :
path) {
242 if (!self)
return nullptr;
244 if (removed != self->path())
261 AttachedInfo::FindOptions options)
269 p =
item.pathFromOwner();
270 fLoc =
o.field(fieldName);
273 p =
c.pathFromOwner().path(
o.canonicalPath().last()).path(
p);
275 fLoc =
o.field(fieldName);
283 res.foundTree = foundTree;
287 Path foundTreePath =
res.rootTreePath.value();
288 if (
res.lookupPath) {
289 foundTreePath = foundTreePath.
key(
res.lookupPath.head().toString());
290 for (
Path pEl :
res.lookupPath.mid(1))
291 foundTreePath = foundTreePath.
field(Fields::subItems).
key(pEl.toString());
293 res.foundTreePath = foundTreePath;
301 cont = cont && self.dvWrapField(visitor, Fields::expr,
expr);
321 item, Fields::updatedScriptExpressions, options);
346#include "moc_qqmldomattachedinfo_p.cpp"
Key key(const T &value, const Key &defaultKey=Key()) const
static bool visitTree(Ptr base, function_ref< bool(Path, Ptr)>visitor, Path basePath=Path())
static Ptr treePtr(DomItem &item, QStringView fieldName)
static Ptr ensure(Ptr self, Path path, PathType pType=PathType::Relative)
static Ptr createTree(Path p=Path())
static AttachedInfoLookupResult< Ptr > findAttachedInfo(DomItem &item, QStringView fieldName, AttachedInfo::FindOptions options)
Attached info creates a tree to attach extra info to DomItems.
static Ptr find(Ptr self, Path p, PathType pType=PathType::Relative)
static AttachedInfoLookupResult< Ptr > findAttachedInfo(DomItem &item, QStringView treeFieldName, FindOptions options=AttachedInfo::FindOption::None)
static Ptr ensure(Ptr self, Path path, PathType pType=PathType::Relative)
Returns that the AttachedInfo corresponding to the given path, creating it if it does not exists.
std::shared_ptr< AttachedInfo > Ptr
std::shared_ptr< T > ownerAs()
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
bool iterateDirectSubpaths(DomItem &self, DirectVisitor)
QMap< QString, SourceLocation > regions
Path key(QString name) const
Path field(QString name) const
Path mid(int offset, int length) const
Path dropFront(int n=1) const
static Tree createTree(Path basePath)
std::shared_ptr< AttachedInfoT< UpdatedScriptExpression > > Tree
static Tree treePtr(DomItem &)
static bool visitTree(Tree base, function_ref< bool(Path, Tree)> visitor, Path basePath=Path())
static Tree ensure(Tree base, Path basePath, AttachedInfo::PathType pType)
static AttachedInfoLookupResult< Tree > findAttachedInfo(DomItem &item, AttachedInfo::FindOptions options=AttachedInfo::FindOption::Default)
std::shared_ptr< ScriptExpression > expr
static const UpdatedScriptExpression * exprPtr(DomItem &)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor)
QString toString() const
Returns a deep copy of this string view's data as a QString.
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 & insert(qsizetype i, QChar c)
qsizetype length() const
Returns the number of characters in this string.
QMap< QString, QString > map
[6]
QMLDOM_EXPORT QCborValue locationToData(SourceLocation loc, QStringView strValue=u"")
Combined button and popup list for selecting options.
GLsizei const GLchar *const * path
QLatin1StringView QLatin1String
QList< QPair< QString, QString > > Map
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent