mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
GDScript: Add support for variadic functions
This commit is contained in:
parent
3b963ab8b6
commit
ee121ef80e
33 changed files with 416 additions and 65 deletions
|
@ -778,7 +778,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool
|
|||
if (p_arg_idx >= p_info.arguments.size()) {
|
||||
arghint += String::chr(0xFFFF);
|
||||
}
|
||||
arghint += "...";
|
||||
arghint += "...args: Array"; // `MethodInfo` does not support the rest parameter name.
|
||||
if (p_arg_idx >= p_info.arguments.size()) {
|
||||
arghint += String::chr(0xFFFF);
|
||||
}
|
||||
|
@ -796,9 +796,9 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
|
|||
arghint = "(";
|
||||
} else {
|
||||
if (p_function->get_datatype().builtin_type == Variant::NIL) {
|
||||
arghint = "void " + p_function->identifier->name.operator String() + "(";
|
||||
arghint = "void " + p_function->identifier->name + "(";
|
||||
} else {
|
||||
arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name.operator String() + "(";
|
||||
arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name + "(";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,6 +870,20 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
|
|||
}
|
||||
}
|
||||
|
||||
if (p_function->is_vararg()) {
|
||||
if (!p_function->parameters.is_empty()) {
|
||||
arghint += ", ";
|
||||
}
|
||||
if (p_arg_idx >= p_function->parameters.size()) {
|
||||
arghint += String::chr(0xFFFF);
|
||||
}
|
||||
const GDScriptParser::ParameterNode *rest_param = p_function->rest_parameter;
|
||||
arghint += "..." + rest_param->identifier->name + ": " + rest_param->get_datatype().to_string();
|
||||
if (p_arg_idx >= p_function->parameters.size()) {
|
||||
arghint += String::chr(0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
arghint += ")";
|
||||
|
||||
return arghint;
|
||||
|
@ -3610,6 +3624,15 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
method_hint += ": " + _get_visual_datatype(mi.arguments[i], true, class_name);
|
||||
}
|
||||
}
|
||||
if (mi.flags & METHOD_FLAG_VARARG) {
|
||||
if (!mi.arguments.is_empty()) {
|
||||
method_hint += ", ";
|
||||
}
|
||||
method_hint += "...args"; // `MethodInfo` does not support the rest parameter name.
|
||||
if (use_type_hint) {
|
||||
method_hint += ": Array";
|
||||
}
|
||||
}
|
||||
method_hint += ")";
|
||||
if (use_type_hint) {
|
||||
method_hint += " -> " + _get_visual_datatype(mi.return_val, false, class_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue