mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
GDScript completion: Handle quote style ad-hoc to remove editor dependency
`core` and `scene` shouldn't depend on `editor`, so they can't query this style setting in `get_argument_options`. But we can handle it after the fact in GDScript's completion code. Also cleans up a couple extra unused invalid includes in `core`.
This commit is contained in:
parent
865b62b1cd
commit
b85dfd990e
8 changed files with 22 additions and 62 deletions
|
@ -2222,8 +2222,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
if (obj) {
|
||||
List<String> options;
|
||||
obj->get_argument_options(p_method, p_argidx, &options);
|
||||
for (const String &F : options) {
|
||||
ScriptCodeCompletionOption option(F, ScriptCodeCompletionOption::KIND_FUNCTION);
|
||||
for (String &opt : options) {
|
||||
if (opt.is_quoted()) {
|
||||
opt = opt.unquote().quote(quote_style); // Handle user preference.
|
||||
}
|
||||
ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_FUNCTION);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
|
@ -2643,23 +2646,26 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
}
|
||||
} break;
|
||||
case GDScriptParser::COMPLETION_GET_NODE: {
|
||||
// Handles the `$Node/Path` or `$"Some NodePath"` syntax specifically.
|
||||
if (p_owner) {
|
||||
List<String> opts;
|
||||
p_owner->get_argument_options("get_node", 0, &opts);
|
||||
|
||||
for (const String &E : opts) {
|
||||
r_forced = true;
|
||||
String opt = E.strip_edges();
|
||||
if (opt.is_quoted()) {
|
||||
r_forced = true;
|
||||
String idopt = opt.unquote();
|
||||
if (idopt.replace("/", "_").is_valid_identifier()) {
|
||||
ScriptCodeCompletionOption option(idopt, ScriptCodeCompletionOption::KIND_NODE_PATH);
|
||||
options.insert(option.display, option);
|
||||
} else {
|
||||
ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_NODE_PATH);
|
||||
options.insert(option.display, option);
|
||||
}
|
||||
// Remove quotes so that we can handle user preferred quote style,
|
||||
// or handle NodePaths which are valid identifiers and don't need quotes.
|
||||
opt = opt.unquote();
|
||||
}
|
||||
// The path needs quotes if it's not a valid identifier (with an exception
|
||||
// for "/" as path separator, which also doesn't require quotes).
|
||||
if (!opt.replace("/", "_").is_valid_identifier()) {
|
||||
opt = opt.quote(quote_style); // Handle user preference.
|
||||
}
|
||||
ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_NODE_PATH);
|
||||
options.insert(option.display, option);
|
||||
}
|
||||
|
||||
// Get autoloads.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue