summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_editor.cpp
diff options
context:
space:
mode:
authorBen <benguilliat@gmail.com>2022-12-02 00:37:53 -0500
committerRémi Verschelde <rverschelde@gmail.com>2023-06-19 15:29:25 +0200
commit080346733461afc426da9511a459feb128cc1e42 (patch)
tree1dc386f287aff6fce1f7a237bb4da1401c653c09 /modules/gdscript/gdscript_editor.cpp
parentc79183817df84faaa7a67a32c00c5a2bd46dc632 (diff)
downloadredot-engine-080346733461afc426da9511a459feb128cc1e42.tar.gz
Fix "Go to definition" for GDScript type hints
Fixes #68475.
Diffstat (limited to 'modules/gdscript/gdscript_editor.cpp')
-rw-r--r--modules/gdscript/gdscript_editor.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index f3b1266bda..cd34feb8b3 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -3533,6 +3533,33 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return OK;
}
} break;
+ case GDScriptParser::COMPLETION_TYPE_ATTRIBUTE: {
+ if (context.node == nullptr || context.node->type != GDScriptParser::Node::TYPE) {
+ break;
+ }
+ const GDScriptParser::TypeNode *type = static_cast<const GDScriptParser::TypeNode *>(context.node);
+
+ GDScriptParser::DataType base_type;
+ const GDScriptParser::IdentifierNode *prev = nullptr;
+ for (const GDScriptParser::IdentifierNode *E : type->type_chain) {
+ if (E->name == p_symbol && prev != nullptr) {
+ base_type = prev->get_datatype();
+ break;
+ }
+ prev = E;
+ }
+ if (base_type.kind != GDScriptParser::DataType::CLASS) {
+ GDScriptCompletionIdentifier base;
+ if (!_guess_expression_type(context, prev, base)) {
+ break;
+ }
+ base_type = base.type;
+ }
+
+ if (_lookup_symbol_from_base(base_type, p_symbol, is_function, r_result) == OK) {
+ return OK;
+ }
+ } break;
case GDScriptParser::COMPLETION_OVERRIDE_METHOD: {
GDScriptParser::DataType base_type = context.current_class->base_type;
@@ -3540,6 +3567,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return OK;
}
} break;
+ case GDScriptParser::COMPLETION_PROPERTY_DECLARATION_OR_TYPE:
case GDScriptParser::COMPLETION_TYPE_NAME_OR_VOID:
case GDScriptParser::COMPLETION_TYPE_NAME: {
GDScriptParser::DataType base_type = context.current_class->get_datatype();