Browse Source

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.
Itamar 4 năm trước cách đây
mục cha
commit
c1b2003687

+ 1 - 2
Userland/DevTools/HackStudio/ClassViewWidget.cpp

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