Added yield() signal smart autocompletion.

This commit is contained in:
Juan Linietsky 2016-08-06 22:11:03 -03:00
parent 3d7c10e9ce
commit 6671c6bdc7
3 changed files with 34 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -375,7 +375,8 @@ public:
COMPLETION_METHOD,
COMPLETION_CALL_ARGUMENTS,
COMPLETION_INDEX,
COMPLETION_VIRTUAL_FUNC
COMPLETION_VIRTUAL_FUNC,
COMPLETION_YIELD,
};