mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-26 19:32:06 -05:00
LanguageServers/Cpp: Make find declaration of enums work
This commit is contained in:
parent
4335bd453d
commit
7fa7c7d63c
2 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
virtual bool is_class() const { return false; }
|
||||
virtual bool is_function() const { return false; }
|
||||
virtual bool is_namespace() const { return false; }
|
||||
virtual bool is_enum() const { return false; }
|
||||
bool is_member() const { return parent() != nullptr && parent()->is_declaration() && verify_cast<Declaration>(parent())->is_struct_or_class(); }
|
||||
const Name* name() const { return m_name; }
|
||||
StringView full_name() const;
|
||||
|
@ -655,6 +656,7 @@ public:
|
|||
virtual ~EnumDeclaration() override = default;
|
||||
virtual const char* class_name() const override { return "EnumDeclaration"; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_enum() const override { return true; }
|
||||
|
||||
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
|
|
Loading…
Add table
Reference in a new issue