14
15
16
17
18
19
20
24
26
27
28
29
30
31
32
33
34
38 cont = cont && self.invokeVisitorOnLazyField(visitor, Fields::fullRegion, [
this]() {
39 return sourceLocationToQCborValue(fullRegion);
41 cont = cont && visitor(
PathEls::Field(Fields::regions), [
this, &self]() ->
DomItem {
43 auto map = Map::fromFileRegionMap(pathFromOwner, regions);
56 Path relative = basePath;
58 for (
const auto &p : std::as_const(relative)) {
59 res = res->insertOrReturnChildAt(p);
71 res = res->subItems().value(rest
.head());
77bool visitTree(
const Tree &base, function_ref<
bool(
const Path &,
const Tree &)> visitor,
82 if (!visitor(pNow, base)) {
85 for (
const auto &childNode : base->subItems()) {
86 if (!visitTree(childNode, visitor, pNow))
96 for (
auto *it = base.get(); it; it = it->parent().get()) {
97 result.prepend(it->path().toString());
103
104
105
109 DomItem fLoc = item.field(Fields::fileLocationsTree);
115 fLoc = o.field(Fields::fileLocationsTree);
120 fLoc = o.field(Fields::fileLocationsTree);
123 if (Node::Ptr fLocPtr = fLoc.ownerAs<Node>())
124 return find(fLocPtr, p);
131 if (loc != SourceLocation()) {
134 SourceLocation &l = p->info().fullRegion;
135 if (loc.begin() < l.begin() || loc.end() > l.end()) {
137 p->info().regions[MainRegion] = l;
150void addRegion(
const Tree &fLoc, FileLocationRegion region, SourceLocation loc)
153 fLoc->info().regions[region] = loc;
154 updateFullLocation(fLoc, loc);
160 const auto ®ions = fLoc->info().regions;
161 if (
auto it = regions.constFind(region); it != regions.constEnd() && it->isValid()) {
165 if (region == MainRegion)
166 return fLoc->info().fullRegion;
168 return SourceLocation{};
172
173
174
175
176
177
178
179
180
181
182
183
184
188 return std::shared_ptr<Node>(
new Node(parent, p));
194 if (
const Ptr p = parent()) {
195 cont = cont && visitor(
PathEls::Field(Fields::parent), [&self, &p]() {
196 return self.copy(p, self.m_ownerPath.dropTail(2), p.get());
199 cont = cont && self.invokeVisitorOnLazyField(visitor, Fields::path, [
this]() {
200 return path().toString();
202 cont = cont && visitor(
PathEls::Field(Fields::subItems), [
this, &self]() {
203 return self.subMapItem(Map(
204 Path::fromField(Fields::subItems),
205 [
this](
const DomItem &map,
const QString &key) {
206 Path p = Path::fromString(key);
207 return map.copy(m_subItems.value(p), map.canonicalPath().withKey(key));
209 [
this](
const DomItem &) {
211 for (
const auto &p : m_subItems.keys())
212 res.insert(p.toString());
215 QLatin1String(
"Node")));
217 cont = cont && visitor(
PathEls::Field(Fields::infoItem), [&self,
this]() {
218 return self.wrap(PathEls::Field(Fields::infoItem), m_info);
225 if (Node::Ptr subEl = m_subItems.value(path)) {
228 return m_subItems.insert(path, Node::instantiate(shared_from_this(), path)).value();
233 return std::shared_ptr<Node>(
new Node(*
this));
A value type that references any element of the Dom.
DomItem container() const
Path canonicalPath() const
DomItem subMapItem(const Map &map) const
DomItem owner() const
The owner of an element, for an qmlObject this is the containing qml file.
Path pathFromOwner() const
Represents a Node of FileLocations tree.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
Ptr insertOrReturnChildAt(const Path &path)
std::shared_ptr< Node > Ptr
static Ptr instantiate(const Ptr &parent=nullptr, const Path &p=Path())
A DomItem that owns other DomItems and is managed through a shared pointer.
Path withPath(const Path &toAdd, bool avoidToAddAsBase=false) const
Returns a copy of this with toAdd appended to it.
Path dropFront(int n=1) const
Provides entities to maintain mappings between elements and their location in a file.
void addRegion(const Tree &fLoc, FileLocationRegion region, SourceLocation loc)
Tree treeOf(const DomItem &)
Tree createTree(const Path &basePath)
QString canonicalPathForTesting(const Tree &base)
QQmlJS::SourceLocation region(const Tree &fLoc, FileLocationRegion region)
bool visitTree(const Tree &base, function_ref< bool(const Path &, const Tree &)> visitor, const Path &basePath=Path())
Tree ensure(const Tree &base, const Path &basePath)
static void updateFullLocation(const Tree &fLoc, SourceLocation loc)
Tree find(const Tree &self, const Path &p)
std::shared_ptr< Node > Tree
Combined button and popup list for selecting options.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const