mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-26 19:32:06 -05:00
LanguageServers/Cpp: Make find declaration for a declaration node work
The CppComprehensionEngine can now find the declaration of a declaration node of type class/namespace/function.
This commit is contained in:
parent
abc420b15a
commit
4335bd453d
1 changed files with 12 additions and 2 deletions
|
@ -474,11 +474,21 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node)
|
|||
|
||||
static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, String name)
|
||||
{
|
||||
|
||||
if (node.parent() && node.parent()->is_name()) {
|
||||
if (&node != verify_cast<Name>(node.parent())->name()) {
|
||||
auto& name_node = *verify_cast<Name>(node.parent());
|
||||
if (&node != name_node.name()) {
|
||||
// Node is part of scope reference chain
|
||||
return TargetDeclaration { TargetDeclaration::Type::Scope, name };
|
||||
}
|
||||
if (name_node.parent() && name_node.parent()->is_declaration()) {
|
||||
auto declaration = verify_cast<Declaration>(name_node.parent());
|
||||
if (declaration->is_struct_or_class()) {
|
||||
return TargetDeclaration { TargetDeclaration::Type::Type, name };
|
||||
}
|
||||
if (declaration->is_function()) {
|
||||
return TargetDeclaration { TargetDeclaration::Type::Function, name };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((node.parent() && node.parent()->is_function_call()) || (node.parent()->is_name() && node.parent()->parent() && node.parent()->parent()->is_function_call())) {
|
||||
|
|
Loading…
Add table
Reference in a new issue