summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gd_editor.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-25 00:34:32 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-25 00:34:32 -0300
commitb1c0e45b03aa14453846c9a888763077eef2476b (patch)
treedd0436d887330c110b3b768bab2398a826a4d4b7 /modules/gdscript/gd_editor.cpp
parenta7e8aa405394c383c7d84e667c9a4165b2cfaf3b (diff)
downloadredot-engine-b1c0e45b03aa14453846c9a888763077eef2476b.tar.gz
Implemented, The Amazing Zylann Hack (tm), fixes #10603
Diffstat (limited to 'modules/gdscript/gd_editor.cpp')
-rw-r--r--modules/gdscript/gd_editor.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 863009f1a7..95091831a9 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -930,6 +930,20 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+ if (context.block->if_condition && context.block->if_condition->type == GDParser::Node::TYPE_OPERATOR && static_cast<const GDParser::OperatorNode *>(context.block->if_condition)->op == GDParser::OperatorNode::OP_IS) {
+ //is used, check if identifier is in there! this helps resolve in blocks that are (if (identifier is value)): which are very common..
+ //super dirty hack, but very useful
+ //credit: Zylann
+ //TODO: this could be hacked to detect ANDed conditions too..
+ const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->if_condition);
+ if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) {
+ //bingo
+ if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) {
+ return true;
+ }
+ }
+ }
+
GDCompletionIdentifier gdi = _get_native_class(context);
if (gdi.obj_type != StringName()) {
bool valid;