Fix autocompletion of built-in functions in GDScript
This commit is contained in:
parent
ceee1abc28
commit
e270d1cce3
3 changed files with 37 additions and 1 deletions
|
@ -641,6 +641,7 @@ public:
|
|||
|
||||
static UtilityFunctionType get_utility_function_type(const StringName &p_name);
|
||||
|
||||
static MethodInfo get_utility_function_info(const StringName &p_name);
|
||||
static int get_utility_function_argument_count(const StringName &p_name);
|
||||
static Variant::Type get_utility_function_argument_type(const StringName &p_name, int p_arg);
|
||||
static String get_utility_function_argument_name(const StringName &p_name, int p_arg);
|
||||
|
|
|
@ -1333,6 +1333,28 @@ Variant::UtilityFunctionType Variant::get_utility_function_type(const StringName
|
|||
return bfi->type;
|
||||
}
|
||||
|
||||
MethodInfo Variant::get_utility_function_info(const StringName &p_name) {
|
||||
MethodInfo info;
|
||||
const VariantUtilityFunctionInfo *bfi = utility_function_table.lookup_ptr(p_name);
|
||||
if (bfi) {
|
||||
info.name = p_name;
|
||||
if (bfi->returns_value && bfi->return_type == Variant::NIL) {
|
||||
info.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
info.return_val.type = bfi->return_type;
|
||||
if (bfi->is_vararg) {
|
||||
info.flags |= METHOD_FLAG_VARARG;
|
||||
}
|
||||
for (int i = 0; i < bfi->argnames.size(); ++i) {
|
||||
PropertyInfo arg;
|
||||
arg.type = bfi->get_arg_type(i);
|
||||
arg.name = bfi->argnames[i];
|
||||
info.arguments.push_back(arg);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
int Variant::get_utility_function_argument_count(const StringName &p_name) {
|
||||
const VariantUtilityFunctionInfo *bfi = utility_function_table.lookup_ptr(p_name);
|
||||
if (!bfi) {
|
||||
|
|
|
@ -1089,6 +1089,15 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
|
|||
kwa++;
|
||||
}
|
||||
|
||||
List<StringName> utility_func_names;
|
||||
Variant::get_utility_function_list(&utility_func_names);
|
||||
|
||||
for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) {
|
||||
ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
|
||||
option.insert_text += "(";
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
|
||||
for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) {
|
||||
if (!E.value().is_singleton) {
|
||||
|
@ -2325,7 +2334,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
|
||||
GDScriptCompletionIdentifier connect_base;
|
||||
|
||||
if (GDScriptUtilityFunctions::function_exists(call->function_name)) {
|
||||
if (Variant::has_utility_function(call->function_name)) {
|
||||
MethodInfo info = Variant::get_utility_function_info(call->function_name);
|
||||
r_arghint = _make_arguments_hint(info, p_argidx);
|
||||
return;
|
||||
} else if (GDScriptUtilityFunctions::function_exists(call->function_name)) {
|
||||
MethodInfo info = GDScriptUtilityFunctions::get_function_info(call->function_name);
|
||||
r_arghint = _make_arguments_hint(info, p_argidx);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue