| 3345 | } |
| 3346 | |
| 3347 | static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) { |
| 3348 | if (p_call->type == GDScriptParser::Node::PRELOAD) { |
| 3349 | if (p_argidx == 0 && bool(EDITOR_GET("text_editor/completion/complete_file_paths"))) { |
| 3350 | _get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result); |
| 3351 | } |
| 3352 | |
| 3353 | MethodInfo mi(PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "preload", PropertyInfo(Variant::STRING, "path")); |
| 3354 | r_arghint = _make_arguments_hint(mi, p_argidx); |
| 3355 | return; |
| 3356 | } else if (p_call->type != GDScriptParser::Node::CALL) { |
| 3357 | return; |
| 3358 | } |
| 3359 | |
| 3360 | Variant base; |
| 3361 | GDScriptParser::DataType base_type; |
| 3362 | bool _static = false; |
| 3363 | const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_call); |
| 3364 | GDScriptParser::Node::Type callee_type = call->get_callee_type(); |
| 3365 | |
| 3366 | if (callee_type == GDScriptParser::Node::SUBSCRIPT) { |
| 3367 | const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee); |
| 3368 | |
| 3369 | if (subscript->base != nullptr && subscript->base->type == GDScriptParser::Node::IDENTIFIER) { |
| 3370 | const GDScriptParser::IdentifierNode *base_identifier = static_cast<const GDScriptParser::IdentifierNode *>(subscript->base); |
| 3371 | |
| 3372 | Variant::Type method_type = GDScriptParser::get_builtin_type(base_identifier->name); |
| 3373 | if (method_type < Variant::VARIANT_MAX) { |
| 3374 | Variant v; |
| 3375 | Callable::CallError err; |
| 3376 | Variant::construct(method_type, v, nullptr, 0, err); |
| 3377 | if (err.error != Callable::CallError::CALL_OK) { |
| 3378 | return; |
| 3379 | } |
| 3380 | List<MethodInfo> methods; |
| 3381 | v.get_method_list(&methods); |
| 3382 | |
| 3383 | for (MethodInfo &E : methods) { |
| 3384 | if (p_argidx >= E.arguments.size()) { |
| 3385 | continue; |
| 3386 | } |
| 3387 | if (E.name == call->function_name) { |
| 3388 | r_arghint += _make_arguments_hint(E, p_argidx); |
| 3389 | return; |
| 3390 | } |
| 3391 | } |
| 3392 | } |
| 3393 | } |
| 3394 | |
| 3395 | if (subscript->is_attribute) { |
| 3396 | bool found_type = _get_subscript_type(p_context, subscript, base_type, &base); |
| 3397 | |
| 3398 | if (!found_type) { |
| 3399 | GDScriptCompletionIdentifier ci; |
| 3400 | if (_guess_expression_type(p_context, subscript->base, ci)) { |
| 3401 | base_type = ci.type; |
| 3402 | base = ci.value; |
| 3403 | } else { |
| 3404 | return; |
no test coverage detected