diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-04-08 17:25:01 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-08 17:25:01 -0300 |
commit | 34e367597d570b359b81f0153613b79ab934d09b (patch) | |
tree | 6ec16c98630e3db2984a90d808a5b16d82480051 | |
parent | 3a08f1748b8b0f0c24b4f41ce2cfc8560983d905 (diff) | |
parent | f97ebdcab3bd6e2917c24a5e4d34e1965ac2a987 (diff) |
Merge pull request #16556 from aragar/master
For-in loop variable added to autocompletion
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 87d8fe1bf5..0d52f0a995 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1333,13 +1333,23 @@ static void _find_identifiers_in_block(GDScriptCompletionContext &context, int p for (int i = 0; i < context.block->statements.size(); i++) { - if (context.block->statements[i]->line > p_line) + GDScriptParser::Node *statement = context.block->statements[i]; + if (statement->line > p_line) continue; - if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) { + GDScriptParser::BlockNode::Type statementType = statement->type; + if (statementType == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) { - const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]); + const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(statement); result.insert(lv->name.operator String()); + } else if (statementType == GDScriptParser::BlockNode::TYPE_CONTROL_FLOW) { + + const GDScriptParser::ControlFlowNode *cf = static_cast<const GDScriptParser::ControlFlowNode *>(statement); + if (cf->cf_type == GDScriptParser::ControlFlowNode::CF_FOR) { + + const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(cf->arguments[0]); + result.insert(id->name.operator String()); + } } } } |