summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-06-05 17:57:13 +0300
committerAndreas Kling <kling@serenityos.org>2021-06-09 22:26:46 +0200
commitdcdb0c7035d78ca8dedfe33372a6b39e63660028 (patch)
treee5421e51ce4f9db14766dfd39ac30f88a48bb263 /Userland/DevTools
parent8f074222e806d7d090bfee380bc87e5995e526fb (diff)
downloadserenity-dcdb0c7035d78ca8dedfe33372a6b39e63660028.zip
LibCpp: Support non-field class members
Previously, we had a special ASTNode for class members, "MemberDeclaration", which only represented fields. This commit removes MemberDeclaration and instead uses regular Declaration nodes for representing the members of a class. This means that we can now also parse methods, inner-classes, and other declarations that appear inside of a class.
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp
index 04fb565436..acfab18d8e 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp
+++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp
@@ -293,7 +293,9 @@ Vector<CppComprehensionEngine::PropertyInfo> CppComprehensionEngine::properties_
Vector<PropertyInfo> properties;
for (auto& member : struct_or_class.m_members) {
- properties.append({ member.m_name, member.m_type });
+ if (!member.is_variable_declaration())
+ continue;
+ properties.append({ member.m_name, ((VariableDeclaration&)member).m_type });
}
return properties;
}
@@ -453,7 +455,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa
bool match_function = target_decl.value().type == TargetDeclaration::Function && symbol.declaration->is_function();
bool match_variable = target_decl.value().type == TargetDeclaration::Variable && symbol.declaration->is_variable_declaration();
bool match_type = target_decl.value().type == TargetDeclaration::Type && symbol.declaration->is_struct_or_class();
- bool match_property = target_decl.value().type == TargetDeclaration::Property && symbol.declaration->is_member();
+ bool match_property = target_decl.value().type == TargetDeclaration::Property && symbol.declaration->parent()->is_declaration() && ((Declaration*)symbol.declaration->parent())->is_struct_or_class();
bool match_parameter = target_decl.value().type == TargetDeclaration::Variable && symbol.declaration->is_parameter();
if (match_property) {