Merge pull request #43350 from gvekan/fix-load-autocomplete
Fix completion for built-in load() function
This commit is contained in:
commit
0efe6dff5f
@ -2315,11 +2315,6 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||||||
|
|
||||||
if (GDScriptParser::get_builtin_function(call->function_name) < GDScriptFunctions::FUNC_MAX) {
|
if (GDScriptParser::get_builtin_function(call->function_name) < GDScriptFunctions::FUNC_MAX) {
|
||||||
MethodInfo info = GDScriptFunctions::get_info(GDScriptParser::get_builtin_function(call->function_name));
|
MethodInfo info = GDScriptFunctions::get_info(GDScriptParser::get_builtin_function(call->function_name));
|
||||||
|
|
||||||
if ((info.name == "load" || info.name == "preload") && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) {
|
|
||||||
_get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result);
|
|
||||||
}
|
|
||||||
|
|
||||||
r_arghint = _make_arguments_hint(info, p_argidx);
|
r_arghint = _make_arguments_hint(info, p_argidx);
|
||||||
return;
|
return;
|
||||||
} else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) {
|
} else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) {
|
||||||
|
@ -2486,26 +2486,28 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE)) {
|
// Arguments.
|
||||||
// Arguments.
|
CompletionType ct = COMPLETION_CALL_ARGUMENTS;
|
||||||
push_completion_call(call);
|
if (get_builtin_function(call->function_name) == GDScriptFunctions::RESOURCE_LOAD) {
|
||||||
make_completion_context(COMPLETION_CALL_ARGUMENTS, call, 0, true);
|
ct = COMPLETION_RESOURCE_PATH;
|
||||||
int argument_index = 0;
|
|
||||||
do {
|
|
||||||
make_completion_context(COMPLETION_CALL_ARGUMENTS, call, argument_index++, true);
|
|
||||||
if (check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE)) {
|
|
||||||
// Allow for trailing comma.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ExpressionNode *argument = parse_expression(false);
|
|
||||||
if (argument == nullptr) {
|
|
||||||
push_error(R"(Expected expression as the function argument.)");
|
|
||||||
} else {
|
|
||||||
call->arguments.push_back(argument);
|
|
||||||
}
|
|
||||||
} while (match(GDScriptTokenizer::Token::COMMA));
|
|
||||||
pop_completion_call();
|
|
||||||
}
|
}
|
||||||
|
push_completion_call(call);
|
||||||
|
int argument_index = 0;
|
||||||
|
do {
|
||||||
|
make_completion_context(ct, call, argument_index++, true);
|
||||||
|
if (check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE)) {
|
||||||
|
// Allow for trailing comma.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ExpressionNode *argument = parse_expression(false);
|
||||||
|
if (argument == nullptr) {
|
||||||
|
push_error(R"(Expected expression as the function argument.)");
|
||||||
|
} else {
|
||||||
|
call->arguments.push_back(argument);
|
||||||
|
}
|
||||||
|
ct = COMPLETION_CALL_ARGUMENTS;
|
||||||
|
} while (match(GDScriptTokenizer::Token::COMMA));
|
||||||
|
pop_completion_call();
|
||||||
|
|
||||||
pop_multiline();
|
pop_multiline();
|
||||||
consume(GDScriptTokenizer::Token::PARENTHESIS_CLOSE, R"*(Expected closing ")" after call arguments.)*");
|
consume(GDScriptTokenizer::Token::PARENTHESIS_CLOSE, R"*(Expected closing ")" after call arguments.)*");
|
||||||
|
Loading…
Reference in New Issue
Block a user