You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-29 16:16:38 +00:00
Fix code completion for new getnode syntax
This commit is contained in:
@@ -2154,6 +2154,27 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base
|
|||||||
} break;
|
} break;
|
||||||
case GDParser::COMPLETION_PARENT_FUNCTION: {
|
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;
|
} break;
|
||||||
case GDParser::COMPLETION_METHOD:
|
case GDParser::COMPLETION_METHOD:
|
||||||
isfunction=true;
|
isfunction=true;
|
||||||
|
|||||||
@@ -290,8 +290,10 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||||||
} break;
|
} break;
|
||||||
case GDTokenizer::TK_CONSTANT: {
|
case GDTokenizer::TK_CONSTANT: {
|
||||||
|
|
||||||
if (!need_identifier)
|
if (!need_identifier) {
|
||||||
|
done=true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (tokenizer->get_token_constant().get_type()!=Variant::STRING) {
|
if (tokenizer->get_token_constant().get_type()!=Variant::STRING) {
|
||||||
_set_error("Expected string constant or identifier after '$' or '/'.");
|
_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());
|
path+=String(tokenizer->get_token_constant());
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
need_identifier=false;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case GDTokenizer::TK_IDENTIFIER: {
|
case GDTokenizer::TK_IDENTIFIER: {
|
||||||
|
if (!need_identifier) {
|
||||||
if (!need_identifier)
|
done=true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
path+=String(tokenizer->get_token_identifier());
|
path+=String(tokenizer->get_token_identifier());
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
@@ -314,8 +318,10 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||||||
} break;
|
} break;
|
||||||
case GDTokenizer::TK_OP_DIV: {
|
case GDTokenizer::TK_OP_DIV: {
|
||||||
|
|
||||||
if (need_identifier)
|
if (need_identifier) {
|
||||||
|
done=true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
path+="/";
|
path+="/";
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
|||||||
@@ -4230,7 +4230,6 @@ void TextEdit::_update_completion_candidates() {
|
|||||||
String l = text[cursor.line];
|
String l = text[cursor.line];
|
||||||
int cofs = CLAMP(cursor.column,0,l.length());
|
int cofs = CLAMP(cursor.column,0,l.length());
|
||||||
|
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
//look for keywords first
|
//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])) {
|
while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
|
||||||
s=String::chr(l[cofs-1])+s;
|
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;
|
break;
|
||||||
|
|
||||||
cofs--;
|
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;
|
cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4308,8 +4307,9 @@ void TextEdit::_update_completion_candidates() {
|
|||||||
_cancel_completion();
|
_cancel_completion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.is_subsequence_ofi(completion_strings[i])) {
|
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) {
|
if (s != "" && completion_options.find(completion_strings[i]) != -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -4345,6 +4345,7 @@ void TextEdit::_update_completion_candidates() {
|
|||||||
if (completion_options.size()==0) {
|
if (completion_options.size()==0) {
|
||||||
//no options to complete, cancel
|
//no options to complete, cancel
|
||||||
_cancel_completion();
|
_cancel_completion();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1305,6 +1305,7 @@ CodeTextEditor::CodeTextEditor() {
|
|||||||
cs.push_back(".");
|
cs.push_back(".");
|
||||||
cs.push_back(",");
|
cs.push_back(",");
|
||||||
cs.push_back("(");
|
cs.push_back("(");
|
||||||
|
cs.push_back("$");
|
||||||
text_editor->set_completion(true,cs);
|
text_editor->set_completion(true,cs);
|
||||||
idle->connect("timeout", this,"_text_changed_idle_timeout");
|
idle->connect("timeout", this,"_text_changed_idle_timeout");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user