1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LanguageServers/Cpp: Make find declaration of enums work

This commit is contained in:
Itamar 2022-02-27 21:24:14 +02:00 committed by Andreas Kling
parent 4335bd453d
commit 7fa7c7d63c
2 changed files with 5 additions and 3 deletions

View file

@ -482,7 +482,7 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, S
}
if (name_node.parent() && name_node.parent()->is_declaration()) {
auto declaration = verify_cast<Declaration>(name_node.parent());
if (declaration->is_struct_or_class()) {
if (declaration->is_struct_or_class() || declaration->is_enum()) {
return TargetDeclaration { TargetDeclaration::Type::Type, name };
}
if (declaration->is_function()) {
@ -517,7 +517,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa
auto symbol_matches = [&](const Symbol& symbol) {
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_type = target_decl.value().type == TargetDeclaration::Type && (symbol.declaration->is_struct_or_class() || symbol.declaration->is_enum());
bool match_property = target_decl.value().type == TargetDeclaration::Property && symbol.declaration->parent()->is_declaration() && verify_cast<Declaration>(symbol.declaration->parent())->is_struct_or_class();
bool match_parameter = target_decl.value().type == TargetDeclaration::Variable && symbol.declaration->is_parameter();
bool match_scope = target_decl.value().type == TargetDeclaration::Scope && (symbol.declaration->is_namespace() || symbol.declaration->is_struct_or_class());
@ -990,7 +990,7 @@ GUI::AutocompleteProvider::TokenInfo::SemanticType CppComprehensionEngine::get_s
return GUI::AutocompleteProvider::TokenInfo::SemanticType::Member;
return GUI::AutocompleteProvider::TokenInfo::SemanticType::Variable;
}
if (decl->is_struct_or_class())
if (decl->is_struct_or_class() || decl->is_enum())
return GUI::AutocompleteProvider::TokenInfo::SemanticType::CustomType;
if (decl->is_namespace())
return GUI::AutocompleteProvider::TokenInfo::SemanticType::Namespace;