feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -488,22 +488,22 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
|
|||
void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
|
||||
Pair<String, Variant> pi;
|
||||
pi.first = "PI";
|
||||
pi.second = Math_PI;
|
||||
pi.second = Math::PI;
|
||||
p_constants->push_back(pi);
|
||||
|
||||
Pair<String, Variant> tau;
|
||||
tau.first = "TAU";
|
||||
tau.second = Math_TAU;
|
||||
tau.second = Math::TAU;
|
||||
p_constants->push_back(tau);
|
||||
|
||||
Pair<String, Variant> infinity;
|
||||
infinity.first = "INF";
|
||||
infinity.second = INFINITY;
|
||||
infinity.second = Math::INF;
|
||||
p_constants->push_back(infinity);
|
||||
|
||||
Pair<String, Variant> nan;
|
||||
nan.first = "NAN";
|
||||
nan.second = NAN;
|
||||
nan.second = Math::NaN;
|
||||
p_constants->push_back(nan);
|
||||
}
|
||||
|
||||
|
|
@ -530,9 +530,9 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
|
|||
if (i > 0) {
|
||||
s += ", ";
|
||||
}
|
||||
s += p_args[i].get_slice(":", 0);
|
||||
s += p_args[i].get_slicec(':', 0);
|
||||
if (th) {
|
||||
String type = p_args[i].get_slice(":", 1);
|
||||
String type = p_args[i].get_slicec(':', 1);
|
||||
if (!type.is_empty()) {
|
||||
s += ": " + type;
|
||||
}
|
||||
|
|
@ -722,8 +722,8 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg, co
|
|||
} else if (p_info.type == Variant::ARRAY && p_info.hint == PROPERTY_HINT_ARRAY_TYPE && !p_info.hint_string.is_empty()) {
|
||||
return "Array[" + _trim_parent_class(p_info.hint_string, p_base_class) + "]";
|
||||
} else if (p_info.type == Variant::DICTIONARY && p_info.hint == PROPERTY_HINT_DICTIONARY_TYPE && !p_info.hint_string.is_empty()) {
|
||||
const String key = p_info.hint_string.get_slice(";", 0);
|
||||
const String value = p_info.hint_string.get_slice(";", 1);
|
||||
const String key = p_info.hint_string.get_slicec(';', 0);
|
||||
const String value = p_info.hint_string.get_slicec(';', 1);
|
||||
return "Dictionary[" + _trim_parent_class(key, p_base_class) + ", " + _trim_parent_class(value, p_base_class) + "]";
|
||||
} else if (p_info.type == Variant::NIL) {
|
||||
if (p_is_arg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
|
||||
|
|
@ -921,8 +921,8 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
|||
node.insert_text = node.display.quote(p_quote_style);
|
||||
r_result.insert(node.display, node);
|
||||
|
||||
List<StringName> native_classes;
|
||||
ClassDB::get_inheriters_from_class("Node", &native_classes);
|
||||
LocalVector<StringName> native_classes;
|
||||
ClassDB::get_inheriters_from_class("Node", native_classes);
|
||||
for (const StringName &E : native_classes) {
|
||||
if (!ClassDB::is_class_exposed(E)) {
|
||||
continue;
|
||||
|
|
@ -1091,9 +1091,9 @@ static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite,
|
|||
}
|
||||
}
|
||||
|
||||
static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, bool p_types_only, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth);
|
||||
static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, bool p_types_only, bool p_add_braces, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth);
|
||||
|
||||
static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_types_only, bool p_static, bool p_parent_only, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_types_only, bool p_static, bool p_parent_only, bool p_add_braces, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT);
|
||||
|
||||
if (!p_parent_only) {
|
||||
|
|
@ -1147,12 +1147,14 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
|
|||
continue;
|
||||
}
|
||||
option = ScriptLanguage::CodeCompletionOption(member.function->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, location);
|
||||
if (member.function->parameters.size() > 0 || (member.function->info.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
if (p_add_braces) {
|
||||
if (member.function->parameters.size() > 0 || (member.function->info.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GDScriptParser::ClassNode::Member::SIGNAL:
|
||||
|
|
@ -1183,25 +1185,27 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
|
|||
base_type.type = p_class->base_type;
|
||||
base_type.type.is_meta_type = p_static;
|
||||
|
||||
_find_identifiers_in_base(base_type, p_only_functions, p_types_only, r_result, p_recursion_depth + 1);
|
||||
_find_identifiers_in_base(base_type, p_only_functions, p_types_only, p_add_braces, r_result, p_recursion_depth + 1);
|
||||
}
|
||||
|
||||
static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, bool p_types_only, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, bool p_types_only, bool p_add_braces, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT);
|
||||
|
||||
GDScriptParser::DataType base_type = p_base.type;
|
||||
|
||||
if (!p_types_only && base_type.is_meta_type && base_type.kind != GDScriptParser::DataType::BUILTIN && base_type.kind != GDScriptParser::DataType::ENUM) {
|
||||
ScriptLanguage::CodeCompletionOption option("new", ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, ScriptLanguage::LOCATION_LOCAL);
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
if (p_add_braces) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
while (!base_type.has_no_type()) {
|
||||
switch (base_type.kind) {
|
||||
case GDScriptParser::DataType::CLASS: {
|
||||
_find_identifiers_in_class(base_type.class_type, p_only_functions, p_types_only, base_type.is_meta_type, false, r_result, p_recursion_depth);
|
||||
_find_identifiers_in_class(base_type.class_type, p_only_functions, p_types_only, base_type.is_meta_type, false, p_add_braces, r_result, p_recursion_depth);
|
||||
// This already finds all parent identifiers, so we are done.
|
||||
base_type = GDScriptParser::DataType();
|
||||
} break;
|
||||
|
|
@ -1252,12 +1256,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|||
}
|
||||
int location = p_recursion_depth + _get_method_location(scr->get_class_name(), E.name);
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, location);
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
if (p_add_braces) {
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
}
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
|
@ -1340,12 +1346,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|||
}
|
||||
int location = p_recursion_depth + _get_method_location(type, E.name);
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, location);
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
if (p_add_braces) {
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
}
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
|
@ -1413,12 +1421,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|||
continue;
|
||||
}
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, location);
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
if (p_add_braces) {
|
||||
if (E.arguments.size() || (E.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
}
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
|
@ -1432,14 +1442,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|||
}
|
||||
}
|
||||
|
||||
static void _find_identifiers(const GDScriptParser::CompletionContext &p_context, bool p_only_functions, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
static void _find_identifiers(const GDScriptParser::CompletionContext &p_context, bool p_only_functions, bool p_add_braces, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
|
||||
if (!p_only_functions && p_context.current_suite) {
|
||||
// This includes function parameters, since they are also locals.
|
||||
_find_identifiers_in_suite(p_context.current_suite, r_result);
|
||||
}
|
||||
|
||||
if (p_context.current_class) {
|
||||
_find_identifiers_in_class(p_context.current_class, p_only_functions, false, (!p_context.current_function || p_context.current_function->is_static), false, r_result, p_recursion_depth);
|
||||
_find_identifiers_in_class(p_context.current_class, p_only_functions, false, (!p_context.current_function || p_context.current_function->is_static), false, p_add_braces, r_result, p_recursion_depth);
|
||||
}
|
||||
|
||||
List<StringName> functions;
|
||||
|
|
@ -1448,12 +1458,14 @@ static void _find_identifiers(const GDScriptParser::CompletionContext &p_context
|
|||
for (const StringName &E : functions) {
|
||||
MethodInfo function = GDScriptUtilityFunctions::get_function_info(E);
|
||||
ScriptLanguage::CodeCompletionOption option(String(E), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
|
||||
if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
if (p_add_braces) {
|
||||
if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
option.display += "()";
|
||||
}
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
|
@ -1499,8 +1511,10 @@ static void _find_identifiers(const GDScriptParser::CompletionContext &p_context
|
|||
const char **kwa = _keywords_with_args;
|
||||
while (*kwa) {
|
||||
ScriptLanguage::CodeCompletionOption option(*kwa, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
if (p_add_braces) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)";
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
kwa++;
|
||||
}
|
||||
|
|
@ -1508,10 +1522,13 @@ static void _find_identifiers(const GDScriptParser::CompletionContext &p_context
|
|||
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()) {
|
||||
ScriptLanguage::CodeCompletionOption option(E->get(), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
|
||||
for (const StringName &util_func_name : utility_func_names) {
|
||||
ScriptLanguage::CodeCompletionOption option(util_func_name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)"; // As all utility functions contain an argument or more, this is hardcoded here.
|
||||
if (p_add_braces) {
|
||||
option.insert_text += "(";
|
||||
option.display += U"(\u2026)"; // As all utility functions contain an argument or more, this is hardcoded here.
|
||||
}
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
|
|
@ -1621,6 +1638,16 @@ static GDScriptCompletionIdentifier _type_from_property(const PropertyInfo &p_pr
|
|||
return ci;
|
||||
}
|
||||
|
||||
static GDScriptCompletionIdentifier _callable_type_from_method_info(const MethodInfo &p_method) {
|
||||
GDScriptCompletionIdentifier ci;
|
||||
ci.type.kind = GDScriptParser::DataType::BUILTIN;
|
||||
ci.type.builtin_type = Variant::CALLABLE;
|
||||
ci.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
ci.type.is_constant = true;
|
||||
ci.type.method_info = p_method;
|
||||
return ci;
|
||||
}
|
||||
|
||||
#define MAX_COMPLETION_RECURSION 100
|
||||
struct RecursionCheck {
|
||||
int *counter;
|
||||
|
|
@ -1866,7 +1893,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
|
|||
if (all_is_const && call->function_name == SNAME("get_node") && ClassDB::is_parent_class(native_type.native_type, SNAME("Node")) && args.size()) {
|
||||
String arg1 = args[0];
|
||||
if (arg1.begins_with("/root/")) {
|
||||
String which = arg1.get_slice("/", 2);
|
||||
String which = arg1.get_slicec('/', 2);
|
||||
if (!which.is_empty()) {
|
||||
// Try singletons first
|
||||
if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(which)) {
|
||||
|
|
@ -2458,14 +2485,13 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
r_type.type.kind = GDScriptParser::DataType::BUILTIN;
|
||||
r_type.type.builtin_type = Variant::SIGNAL;
|
||||
r_type.type.method_info = member.signal->method_info;
|
||||
return true;
|
||||
case GDScriptParser::ClassNode::Member::FUNCTION:
|
||||
if (is_static && !member.function->is_static) {
|
||||
return false;
|
||||
}
|
||||
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
r_type.type.kind = GDScriptParser::DataType::BUILTIN;
|
||||
r_type.type.builtin_type = Variant::CALLABLE;
|
||||
r_type = _callable_type_from_method_info(member.function->info);
|
||||
return true;
|
||||
case GDScriptParser::ClassNode::Member::CLASS:
|
||||
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
|
|
@ -2505,6 +2531,12 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
}
|
||||
}
|
||||
|
||||
if (scr->has_method(p_identifier)) {
|
||||
MethodInfo mi = scr->get_method_info(p_identifier);
|
||||
r_type = _callable_type_from_method_info(mi);
|
||||
return true;
|
||||
}
|
||||
|
||||
Ref<Script> parent = scr->get_base_script();
|
||||
if (parent.is_valid()) {
|
||||
base_type.script_type = parent;
|
||||
|
|
@ -2539,23 +2571,35 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
MethodInfo method;
|
||||
if (ClassDB::get_method_info(class_name, p_identifier, &method)) {
|
||||
r_type = _callable_type_from_method_info(method);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} break;
|
||||
case GDScriptParser::DataType::BUILTIN: {
|
||||
Callable::CallError err;
|
||||
Variant tmp;
|
||||
Variant::construct(base_type.builtin_type, tmp, nullptr, 0, err);
|
||||
|
||||
if (err.error != Callable::CallError::CALL_OK) {
|
||||
return false;
|
||||
}
|
||||
bool valid = false;
|
||||
Variant res = tmp.get(p_identifier, &valid);
|
||||
if (valid) {
|
||||
r_type = _type_from_variant(res, p_context);
|
||||
r_type.value = Variant();
|
||||
r_type.type.is_constant = false;
|
||||
if (Variant::has_builtin_method(base_type.builtin_type, p_identifier)) {
|
||||
r_type = _callable_type_from_method_info(Variant::get_builtin_method_info(base_type.builtin_type, p_identifier));
|
||||
return true;
|
||||
} else {
|
||||
Callable::CallError err;
|
||||
Variant tmp;
|
||||
Variant::construct(base_type.builtin_type, tmp, nullptr, 0, err);
|
||||
|
||||
if (err.error != Callable::CallError::CALL_OK) {
|
||||
return false;
|
||||
}
|
||||
bool valid = false;
|
||||
Variant res = tmp.get(p_identifier, &valid);
|
||||
if (valid) {
|
||||
r_type = _type_from_variant(res, p_context);
|
||||
r_type.value = Variant();
|
||||
r_type.type.is_constant = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} break;
|
||||
|
|
@ -2726,6 +2770,22 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool _guess_expecting_callable(GDScriptParser::CompletionContext &p_context) {
|
||||
if (p_context.call.call != nullptr && p_context.call.call->type == GDScriptParser::Node::CALL) {
|
||||
GDScriptParser::CallNode *call_node = static_cast<GDScriptParser::CallNode *>(p_context.call.call);
|
||||
GDScriptCompletionIdentifier ci;
|
||||
if (_guess_expression_type(p_context, call_node->callee, ci)) {
|
||||
if (ci.type.kind == GDScriptParser::DataType::BUILTIN && ci.type.builtin_type == Variant::CALLABLE) {
|
||||
if (p_context.call.argument >= 0 && p_context.call.argument < ci.type.method_info.arguments.size()) {
|
||||
return ci.type.method_info.arguments.get(p_context.call.argument).type == Variant::CALLABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_context, const String &p_enum_hint, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result) {
|
||||
if (!p_enum_hint.contains_char('.')) {
|
||||
// Global constant or in the current class.
|
||||
|
|
@ -2745,8 +2805,8 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co
|
|||
}
|
||||
}
|
||||
} else {
|
||||
String class_name = p_enum_hint.get_slice(".", 0);
|
||||
String enum_name = p_enum_hint.get_slice(".", 1);
|
||||
String class_name = p_enum_hint.get_slicec('.', 0);
|
||||
String enum_name = p_enum_hint.get_slicec('.', 1);
|
||||
|
||||
if (!ClassDB::class_exists(class_name)) {
|
||||
return;
|
||||
|
|
@ -2839,9 +2899,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
// Handle user preference.
|
||||
if (opt.is_quoted()) {
|
||||
opt = opt.unquote().quote(quote_style);
|
||||
if (use_string_names && info.arguments.get(p_argidx).type == Variant::STRING_NAME) {
|
||||
if (use_string_names && info.arguments[p_argidx].type == Variant::STRING_NAME) {
|
||||
opt = "&" + opt;
|
||||
} else if (use_node_paths && info.arguments.get(p_argidx).type == Variant::NODE_PATH) {
|
||||
} else if (use_node_paths && info.arguments[p_argidx].type == Variant::NODE_PATH) {
|
||||
opt = "^" + opt;
|
||||
}
|
||||
}
|
||||
|
|
@ -2852,7 +2912,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
}
|
||||
|
||||
if (p_argidx < method_args) {
|
||||
const PropertyInfo &arg_info = info.arguments.get(p_argidx);
|
||||
const PropertyInfo &arg_info = info.arguments[p_argidx];
|
||||
if (arg_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM | PROPERTY_USAGE_CLASS_IS_BITFIELD)) {
|
||||
_find_enumeration_candidates(p_context, arg_info.class_name, r_result);
|
||||
}
|
||||
|
|
@ -2949,7 +3009,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
if (!s.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
String name = s.get_slice("/", 1);
|
||||
String name = s.get_slicec('/', 1);
|
||||
String path = ("/root/" + name).quote(quote_style);
|
||||
if (use_node_paths) {
|
||||
path = "^" + path;
|
||||
|
|
@ -2968,7 +3028,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
if (!s.begins_with("input/")) {
|
||||
continue;
|
||||
}
|
||||
String name = s.get_slice("/", 1).quote(quote_style);
|
||||
String name = s.get_slicec('/', 1).quote(quote_style);
|
||||
if (use_string_names) {
|
||||
name = "&" + name;
|
||||
}
|
||||
|
|
@ -3267,10 +3327,12 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
for (const StringName &E : methods) {
|
||||
if (Variant::is_builtin_method_static(completion_context.builtin_type, E)) {
|
||||
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
|
||||
if (Variant::get_builtin_method_argument_count(completion_context.builtin_type, E) > 0 || Variant::is_builtin_method_vararg(completion_context.builtin_type, E)) {
|
||||
option.insert_text += "(";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
if (!_guess_expecting_callable(completion_context)) {
|
||||
if (Variant::get_builtin_method_argument_count(completion_context.builtin_type, E) > 0 || Variant::is_builtin_method_vararg(completion_context.builtin_type, E)) {
|
||||
option.insert_text += "(";
|
||||
} else {
|
||||
option.insert_text += "()";
|
||||
}
|
||||
}
|
||||
options.insert(option.display, option);
|
||||
}
|
||||
|
|
@ -3328,7 +3390,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
break;
|
||||
}
|
||||
if (!_guess_expression_type(completion_context, static_cast<const GDScriptParser::AssignmentNode *>(completion_context.node)->assignee, type)) {
|
||||
_find_identifiers(completion_context, false, options, 0);
|
||||
_find_identifiers(completion_context, false, true, options, 0);
|
||||
r_forced = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -3337,7 +3399,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
_find_enumeration_candidates(completion_context, type.enumeration, options);
|
||||
r_forced = options.size() > 0;
|
||||
} else {
|
||||
_find_identifiers(completion_context, false, options, 0);
|
||||
_find_identifiers(completion_context, false, true, options, 0);
|
||||
r_forced = true;
|
||||
}
|
||||
} break;
|
||||
|
|
@ -3345,7 +3407,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
is_function = true;
|
||||
[[fallthrough]];
|
||||
case GDScriptParser::COMPLETION_IDENTIFIER: {
|
||||
_find_identifiers(completion_context, is_function, options, 0);
|
||||
_find_identifiers(completion_context, is_function, !_guess_expecting_callable(completion_context), options, 0);
|
||||
} break;
|
||||
case GDScriptParser::COMPLETION_ATTRIBUTE_METHOD:
|
||||
is_function = true;
|
||||
|
|
@ -3360,7 +3422,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
break;
|
||||
}
|
||||
|
||||
_find_identifiers_in_base(base, is_function, false, options, 0);
|
||||
_find_identifiers_in_base(base, is_function, false, !_guess_expecting_callable(completion_context), options, 0);
|
||||
}
|
||||
} break;
|
||||
case GDScriptParser::COMPLETION_SUBSCRIPT: {
|
||||
|
|
@ -3380,20 +3442,20 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
}
|
||||
}
|
||||
if (!subscript->index || subscript->index->type != GDScriptParser::Node::LITERAL) {
|
||||
_find_identifiers(completion_context, false, options, 0);
|
||||
_find_identifiers(completion_context, false, !_guess_expecting_callable(completion_context), options, 0);
|
||||
}
|
||||
} else if (res) {
|
||||
if (!subscript->is_attribute) {
|
||||
// Quote the options if they are not accessed as attribute.
|
||||
|
||||
HashMap<String, ScriptLanguage::CodeCompletionOption> opt;
|
||||
_find_identifiers_in_base(base, false, false, opt, 0);
|
||||
_find_identifiers_in_base(base, false, false, false, opt, 0);
|
||||
for (const KeyValue<String, CodeCompletionOption> &E : opt) {
|
||||
ScriptLanguage::CodeCompletionOption option(E.value.insert_text.quote(quote_style), E.value.kind, E.value.location);
|
||||
options.insert(option.display, option);
|
||||
}
|
||||
} else {
|
||||
_find_identifiers_in_base(base, false, false, options, 0);
|
||||
_find_identifiers_in_base(base, false, false, !_guess_expecting_callable(completion_context), options, 0);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
|
@ -3437,7 +3499,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
}
|
||||
|
||||
if (found) {
|
||||
_find_identifiers_in_base(base, false, true, options, 0);
|
||||
_find_identifiers_in_base(base, false, true, true, options, 0);
|
||||
}
|
||||
r_forced = true;
|
||||
} break;
|
||||
|
|
@ -3491,21 +3553,21 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
for (const MethodInfo &mi : virtual_methods) {
|
||||
String method_hint = mi.name;
|
||||
if (method_hint.contains_char(':')) {
|
||||
method_hint = method_hint.get_slice(":", 0);
|
||||
method_hint = method_hint.get_slicec(':', 0);
|
||||
}
|
||||
method_hint += "(";
|
||||
|
||||
for (List<PropertyInfo>::ConstIterator arg_itr = mi.arguments.begin(); arg_itr != mi.arguments.end(); ++arg_itr) {
|
||||
if (arg_itr != mi.arguments.begin()) {
|
||||
for (int64_t i = 0; i < mi.arguments.size(); ++i) {
|
||||
if (i > 0) {
|
||||
method_hint += ", ";
|
||||
}
|
||||
String arg = arg_itr->name;
|
||||
String arg = mi.arguments[i].name;
|
||||
if (arg.contains_char(':')) {
|
||||
arg = arg.substr(0, arg.find_char(':'));
|
||||
}
|
||||
method_hint += arg;
|
||||
if (use_type_hint) {
|
||||
method_hint += ": " + _get_visual_datatype(*arg_itr, true, class_name);
|
||||
method_hint += ": " + _get_visual_datatype(mi.arguments[i], true, class_name);
|
||||
}
|
||||
}
|
||||
method_hint += ")";
|
||||
|
|
@ -3578,7 +3640,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
if (!completion_context.current_class) {
|
||||
break;
|
||||
}
|
||||
_find_identifiers_in_class(completion_context.current_class, true, false, false, true, options, 0);
|
||||
_find_identifiers_in_class(completion_context.current_class, true, false, false, true, !_guess_expecting_callable(completion_context), options, 0);
|
||||
} break;
|
||||
}
|
||||
|
||||
|
|
@ -3630,7 +3692,7 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
|
|||
}
|
||||
}
|
||||
|
||||
String st = l.substr(tc, l.length()).strip_edges();
|
||||
String st = l.substr(tc).strip_edges();
|
||||
if (st.is_empty() || st.begins_with("#")) {
|
||||
continue; //ignore!
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue