diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-12 14:53:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-12 14:53:38 +0100 |
commit | f065b34e969f93e5ecc9046e01c5c14c416d2d16 (patch) | |
tree | 7deb98460eee314b515f7d04454f5953d9da4bc2 /modules | |
parent | 234fab949a1ff7214c4de91c66c897535d28e5a7 (diff) | |
parent | a665b3878be70904998c2b918ea6f47019b35e81 (diff) |
Merge pull request #34286 from bojidar-bg/31818-cast-autocomplete
Fix GDScript autocompletion with "as" or typed variables
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 280bc37dc0..97b8dda6d0 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -744,6 +744,14 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G r_type.type.kind = GDScriptParser::DataType::BUILTIN; r_type.type.builtin_type = Variant::ARRAY; } break; + case GDScriptParser::Node::TYPE_CAST: { + const GDScriptParser::CastNode *cn = static_cast<const GDScriptParser::CastNode *>(p_expression); + GDScriptCompletionIdentifier value; + if (_guess_expression_type(p_context, cn->source_node, r_type)) { + r_type.type = cn->get_datatype(); + found = true; + } + } break; case GDScriptParser::Node::TYPE_OPERATOR: { const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_expression); switch (op->op) { @@ -1232,6 +1240,9 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S c.line = last_assign_line; r_type.assigned_expression = last_assigned_expression; if (_guess_expression_type(c, last_assigned_expression, r_type)) { + if (var_type.has_type) { + r_type.type = var_type; + } return true; } } |