mirror of
https://github.com/godotengine/godot.git
synced 2025-01-19 08:22:01 +00:00
Fix code completion for new getnode syntax
This commit is contained in:
parent
8b912d1115
commit
8963ca3d17
@ -2154,6 +2154,27 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base
|
||||
} break;
|
||||
case GDParser::COMPLETION_PARENT_FUNCTION: {
|
||||
|
||||
} break;
|
||||
case GDParser::COMPLETION_GET_NODE: {
|
||||
|
||||
if (p_owner) {
|
||||
List<String> opts;
|
||||
p_owner->get_argument_options("get_node",0,&opts);
|
||||
|
||||
for (List<String>::Element *E=opts.front();E;E=E->next()) {
|
||||
|
||||
String opt = E->get().strip_edges();
|
||||
if (opt.begins_with("\"") && opt.ends_with("\"")) {
|
||||
String idopt=opt.substr(1,opt.length()-2);
|
||||
if (idopt.replace("/","_").is_valid_identifier()) {
|
||||
options.insert(idopt);
|
||||
} else {
|
||||
options.insert(opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} break;
|
||||
case GDParser::COMPLETION_METHOD:
|
||||
isfunction=true;
|
||||
|
@ -290,8 +290,10 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
||||
} break;
|
||||
case GDTokenizer::TK_CONSTANT: {
|
||||
|
||||
if (!need_identifier)
|
||||
if (!need_identifier) {
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tokenizer->get_token_constant().get_type()!=Variant::STRING) {
|
||||
_set_error("Expected string constant or identifier after '$' or '/'.");
|
||||
@ -300,12 +302,14 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
||||
|
||||
path+=String(tokenizer->get_token_constant());
|
||||
tokenizer->advance();
|
||||
need_identifier=false;
|
||||
|
||||
} break;
|
||||
case GDTokenizer::TK_IDENTIFIER: {
|
||||
|
||||
if (!need_identifier)
|
||||
if (!need_identifier) {
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
|
||||
path+=String(tokenizer->get_token_identifier());
|
||||
tokenizer->advance();
|
||||
@ -314,8 +318,10 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
||||
} break;
|
||||
case GDTokenizer::TK_OP_DIV: {
|
||||
|
||||
if (need_identifier)
|
||||
if (need_identifier) {
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
|
||||
path+="/";
|
||||
tokenizer->advance();
|
||||
|
@ -4230,7 +4230,6 @@ void TextEdit::_update_completion_candidates() {
|
||||
String l = text[cursor.line];
|
||||
int cofs = CLAMP(cursor.column,0,l.length());
|
||||
|
||||
|
||||
String s;
|
||||
|
||||
//look for keywords first
|
||||
@ -4279,14 +4278,14 @@ void TextEdit::_update_completion_candidates() {
|
||||
|
||||
while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
|
||||
s=String::chr(l[cofs-1])+s;
|
||||
if (l[cofs-1]=='\'' || l[cofs-1]=='"')
|
||||
if (l[cofs-1]=='\'' || l[cofs-1]=='"' || l[cofs-1]=='$')
|
||||
break;
|
||||
|
||||
cofs--;
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) {
|
||||
if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
@ -4308,8 +4307,9 @@ void TextEdit::_update_completion_candidates() {
|
||||
_cancel_completion();
|
||||
return;
|
||||
}
|
||||
|
||||
if (s.is_subsequence_ofi(completion_strings[i])) {
|
||||
// don't remove duplicates if no input is provided
|
||||
// don't remove duplicates if no input is provided
|
||||
if (s != "" && completion_options.find(completion_strings[i]) != -1) {
|
||||
continue;
|
||||
}
|
||||
@ -4345,6 +4345,7 @@ void TextEdit::_update_completion_candidates() {
|
||||
if (completion_options.size()==0) {
|
||||
//no options to complete, cancel
|
||||
_cancel_completion();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
@ -1305,6 +1305,7 @@ CodeTextEditor::CodeTextEditor() {
|
||||
cs.push_back(".");
|
||||
cs.push_back(",");
|
||||
cs.push_back("(");
|
||||
cs.push_back("$");
|
||||
text_editor->set_completion(true,cs);
|
||||
idle->connect("timeout", this,"_text_changed_idle_timeout");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user