summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-08-06 22:11:03 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-08-06 22:11:03 -0300
commit6671c6bdc78864bbe1d27c508ec9528f3b683ca2 (patch)
tree5363b49c0aab2cd1cfb6a198b7f5e9a9e79c80ec /modules
parent3d7c10e9ceda7d57a2df0461e6f9b6c81c052f1d (diff)
Added yield() signal smart autocompletion.
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gd_editor.cpp17
-rw-r--r--modules/gdscript/gd_parser.cpp15
-rw-r--r--modules/gdscript/gd_parser.h3
3 files changed, 34 insertions, 1 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 48f747ada9..2e5fb82f37 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -2389,7 +2389,24 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base
}
}
} break;
+ case GDParser::COMPLETION_YIELD: {
+ const GDParser::Node *node = p.get_completion_node();
+
+ GDCompletionIdentifier t;
+ if (!_guess_expression_type(context,node,p.get_completion_line(),t))
+ break;
+
+ if (t.type==Variant::OBJECT && t.obj_type!=StringName()) {
+
+ List<MethodInfo> sigs;
+ ObjectTypeDB::get_signal_list(t.obj_type,&sigs);
+ for (List<MethodInfo>::Element *E=sigs.front();E;E=E->next()) {
+ options.insert("\""+E->get().name+"\"");
+ }
+ }
+
+ } break;
}
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index e829fa86b4..a6794564db 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -378,6 +378,21 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
tokenizer->advance();
+ if (tokenizer->get_token()==GDTokenizer::TK_CURSOR) {
+
+
+ completion_cursor=StringName();
+ completion_node=object;
+ completion_type=COMPLETION_YIELD;
+ completion_class=current_class;
+ completion_function=current_function;
+ completion_line=tokenizer->get_token_line();
+ completion_argument=0;
+ completion_block=current_block;
+ completion_found=true;
+ tokenizer->advance();
+ }
+
Node *signal = _parse_and_reduce_expression(p_parent,p_static);
if (!signal)
return NULL;
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 4afc534a8c..2d6b52c473 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -375,7 +375,8 @@ public:
COMPLETION_METHOD,
COMPLETION_CALL_ARGUMENTS,
COMPLETION_INDEX,
- COMPLETION_VIRTUAL_FUNC
+ COMPLETION_VIRTUAL_FUNC,
+ COMPLETION_YIELD,
};