1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 17:37:35 +00:00

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.
This commit is contained in:
Itamar 2021-06-05 17:57:13 +03:00 committed by Andreas Kling
parent 8f074222e8
commit dcdb0c7035
6 changed files with 71 additions and 77 deletions

View file

@ -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) {