HackStudio: Use Node's name when inserting to the ClassView tree

Previously, when traversing the ClassView tree to find the parent of a
new node, we used the name of the node's declaration to find the path
to the parent in the tree.

However, some nodes in the tree do not have a matching declaration,
which caused a VERIFY failure.

To fix this, we now use the node's name when walking the tree.
We can do this because the node's name should be identical to the name
of its declaration.

Closes #7702.
This commit is contained in:
Itamar 2021-06-04 19:34:24 +03:00 committed by Andreas Kling
parent 2b762ef940
commit c1b2003687
Notes: sideshowbarker 2024-07-18 16:53:49 +09:00

View File

@ -147,8 +147,7 @@ void ClassViewModel::add_declaration(const GUI::AutocompleteProvider::Declaratio
auto& scope = scope_parts[i];
ClassViewNode* next { nullptr };
for (auto& child : parent->children) {
VERIFY(child.declaration);
if (child.declaration->name == scope) {
if (child.name == scope) {
next = &child;
break;
}