Merge pull request #35199 from dalexeev/master

Fix function arguments hint format in GDScript editor
This commit is contained in:
Rémi Verschelde 2020-01-16 15:53:28 +01:00 committed by GitHub
commit 4998983bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -555,7 +555,7 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = tr
} }
if (p_info.type == Variant::NIL) { if (p_info.type == Variant::NIL) {
if (p_isarg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) { if (p_isarg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
return "var"; return "Variant";
} else { } else {
return "void"; return "void";
} }
@ -1736,14 +1736,12 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E; E = E->next()) { for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E; E = E->next()) {
if (i > 0) { if (i > 0) {
arghint += ", "; arghint += ", ";
} else {
arghint += " ";
} }
if (i == p_arg_idx) { if (i == p_arg_idx) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
} }
arghint += _get_visual_datatype(E->get(), true) + " " + E->get().name; arghint += E->get().name + ": " + _get_visual_datatype(E->get(), true);
if (i - def_args >= 0) { if (i - def_args >= 0) {
arghint += String(" = ") + p_info.default_arguments[i - def_args].get_construct_string(); arghint += String(" = ") + p_info.default_arguments[i - def_args].get_construct_string();
@ -1759,8 +1757,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
if (p_info.flags & METHOD_FLAG_VARARG) { if (p_info.flags & METHOD_FLAG_VARARG) {
if (p_info.arguments.size() > 0) { if (p_info.arguments.size() > 0) {
arghint += ", "; arghint += ", ";
} else {
arghint += " ";
} }
if (p_arg_idx >= p_info.arguments.size()) { if (p_arg_idx >= p_info.arguments.size()) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
@ -1770,9 +1766,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
} }
} }
if (p_info.arguments.size() > 0 || (p_info.flags & METHOD_FLAG_VARARG)) {
arghint += " ";
}
arghint += ")"; arghint += ")";
@ -1787,14 +1780,12 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
for (int i = 0; i < p_function->arguments.size(); i++) { for (int i = 0; i < p_function->arguments.size(); i++) {
if (i > 0) { if (i > 0) {
arghint += ", "; arghint += ", ";
} else {
arghint += " ";
} }
if (i == p_arg_idx) { if (i == p_arg_idx) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
} }
arghint += p_function->argument_types[i].to_string() + " " + p_function->arguments[i].operator String(); arghint += p_function->arguments[i].operator String() + ": " + p_function->argument_types[i].to_string();
if (i - def_args >= 0) { if (i - def_args >= 0) {
String def_val = "<unknown>"; String def_val = "<unknown>";
@ -1818,9 +1809,6 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
} }
} }
if (p_function->arguments.size() > 0) {
arghint += " ";
}
arghint += ")"; arghint += ")";
return arghint; return arghint;