summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_editor.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-06-19 10:53:21 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-06-19 10:53:21 +0200
commitcd87b0bf84fa530d7b86a372dd09e4d9adcfa3a5 (patch)
tree9ffd48944f60d1bd64361212e94bfc8d32cd9020 /modules/gdscript/gdscript_editor.cpp
parent4949e96b0b614420638d76ce922116cfb1f0594a (diff)
parent51f74af2ac57e23164bf3a41e50a544fd481a917 (diff)
downloadredot-engine-cd87b0bf84fa530d7b86a372dd09e4d9adcfa3a5.tar.gz
Merge pull request #93057 from HolonProduction/not-enough-code-paths
Autocompletion: Add support for string name option in more places
Diffstat (limited to 'modules/gdscript/gdscript_editor.cpp')
-rw-r--r--modules/gdscript/gdscript_editor.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index fcabb7c4a8..8da829907e 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -2787,9 +2787,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (opt.is_quoted()) {
opt = opt.unquote().quote(quote_style);
if (use_string_names && info.arguments.get(p_argidx).type == Variant::STRING_NAME) {
- opt = opt.indent("&");
+ opt = "&" + opt;
} else if (use_node_paths && info.arguments.get(p_argidx).type == Variant::NODE_PATH) {
- opt = opt.indent("^");
+ opt = "^" + opt;
}
}
ScriptLanguage::CodeCompletionOption option(opt, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
@@ -2824,7 +2824,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (E.usage & (PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_INTERNAL)) {
continue;
}
- ScriptLanguage::CodeCompletionOption option(E.name.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
+ String name = E.name.quote(quote_style);
+ if (use_node_paths) {
+ name = "^" + name;
+ }
+ ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
r_result.insert(option.display, option);
}
script = script->get_base_script();
@@ -2838,7 +2842,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
while (clss) {
for (GDScriptParser::ClassNode::Member member : clss->members) {
if (member.type == GDScriptParser::ClassNode::Member::VARIABLE) {
- ScriptLanguage::CodeCompletionOption option(member.get_name().quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
+ String name = member.get_name().quote(quote_style);
+ if (use_node_paths) {
+ name = "^" + name;
+ }
+ ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
r_result.insert(option.display, option);
}
}
@@ -2861,7 +2869,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (E.usage & (PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_INTERNAL)) {
continue;
}
- ScriptLanguage::CodeCompletionOption option(E.name.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
+ String name = E.name.quote(quote_style);
+ if (use_node_paths) {
+ name = "^" + name;
+ }
+ ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
r_result.insert(option.display, option);
}
}
@@ -2877,8 +2889,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
continue;
}
String name = s.get_slice("/", 1);
- ScriptLanguage::CodeCompletionOption option("/root/" + name, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH);
- option.insert_text = option.display.quote(quote_style);
+ String path = ("/root/" + name).quote(quote_style);
+ if (use_node_paths) {
+ path = "^" + path;
+ }
+ ScriptLanguage::CodeCompletionOption option(path, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH);
r_result.insert(option.display, option);
}
}
@@ -2892,9 +2907,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (!s.begins_with("input/")) {
continue;
}
- String name = s.get_slice("/", 1);
+ String name = s.get_slice("/", 1).quote(quote_style);
+ if (use_string_names) {
+ name = "&" + name;
+ }
ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
- option.insert_text = option.display.quote(quote_style);
r_result.insert(option.display, option);
}
}