Merge pull request #53303 from akien-mga/53295-gdscript-completion-quote-style
This commit is contained in:
commit
bb201c5887
8 changed files with 22 additions and 62 deletions
|
@ -35,10 +35,6 @@
|
||||||
#include "core/input/input_map.h"
|
#include "core/input/input_map.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
|
static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
|
||||||
"a",
|
"a",
|
||||||
"b",
|
"b",
|
||||||
|
@ -162,9 +158,6 @@ void Input::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
|
||||||
|
|
||||||
String pf = p_function;
|
String pf = p_function;
|
||||||
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" ||
|
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" ||
|
||||||
pf == "is_action_just_pressed" || pf == "is_action_just_released" ||
|
pf == "is_action_just_pressed" || pf == "is_action_just_released" ||
|
||||||
|
@ -179,10 +172,9 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
||||||
r_options->push_back(name.quote(quote_style));
|
r_options->push_back(name.quote());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
|
void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "core/io/file_access.h"
|
#include "core/io/file_access.h"
|
||||||
#include "core/os/midi_driver.h"
|
#include "core/os/midi_driver.h"
|
||||||
#include "core/version_generated.gen.h"
|
#include "core/version_generated.gen.h"
|
||||||
#include "servers/audio_server.h"
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2222,8 +2222,11 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
||||||
if (obj) {
|
if (obj) {
|
||||||
List<String> options;
|
List<String> options;
|
||||||
obj->get_argument_options(p_method, p_argidx, &options);
|
obj->get_argument_options(p_method, p_argidx, &options);
|
||||||
for (const String &F : options) {
|
for (String &opt : options) {
|
||||||
ScriptCodeCompletionOption option(F, ScriptCodeCompletionOption::KIND_FUNCTION);
|
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);
|
r_result.insert(option.display, option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2643,24 +2646,27 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case GDScriptParser::COMPLETION_GET_NODE: {
|
case GDScriptParser::COMPLETION_GET_NODE: {
|
||||||
|
// Handles the `$Node/Path` or `$"Some NodePath"` syntax specifically.
|
||||||
if (p_owner) {
|
if (p_owner) {
|
||||||
List<String> opts;
|
List<String> opts;
|
||||||
p_owner->get_argument_options("get_node", 0, &opts);
|
p_owner->get_argument_options("get_node", 0, &opts);
|
||||||
|
|
||||||
for (const String &E : opts) {
|
for (const String &E : opts) {
|
||||||
|
r_forced = true;
|
||||||
String opt = E.strip_edges();
|
String opt = E.strip_edges();
|
||||||
if (opt.is_quoted()) {
|
if (opt.is_quoted()) {
|
||||||
r_forced = true;
|
// Remove quotes so that we can handle user preferred quote style,
|
||||||
String idopt = opt.unquote();
|
// or handle NodePaths which are valid identifiers and don't need quotes.
|
||||||
if (idopt.replace("/", "_").is_valid_identifier()) {
|
opt = opt.unquote();
|
||||||
ScriptCodeCompletionOption option(idopt, ScriptCodeCompletionOption::KIND_NODE_PATH);
|
}
|
||||||
options.insert(option.display, option);
|
// The path needs quotes if it's not a valid identifier (with an exception
|
||||||
} else {
|
// 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);
|
ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_NODE_PATH);
|
||||||
options.insert(option.display, option);
|
options.insert(option.display, option);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get autoloads.
|
// Get autoloads.
|
||||||
OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
|
OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "scene/2d/skeleton_2d.h"
|
#include "scene/2d/skeleton_2d.h"
|
||||||
|
|
||||||
void AnimatedValuesBackup::update_skeletons() {
|
void AnimatedValuesBackup::update_skeletons() {
|
||||||
|
@ -1493,18 +1492,12 @@ NodePath AnimationPlayer::get_root() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
|
||||||
#else
|
|
||||||
const String quote_style = "\"";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String pf = p_function;
|
String pf = p_function;
|
||||||
if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) {
|
if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) {
|
||||||
List<StringName> al;
|
List<StringName> al;
|
||||||
get_animation_list(&al);
|
get_animation_list(&al);
|
||||||
for (const StringName &name : al) {
|
for (const StringName &name : al) {
|
||||||
r_options->push_back(String(name).quote(quote_style));
|
r_options->push_back(String(name).quote());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::get_argument_options(p_function, p_idx, r_options);
|
Node::get_argument_options(p_function, p_idx, r_options);
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/string/print_string.h"
|
#include "core/string/print_string.h"
|
||||||
#include "core/string/translation.h"
|
#include "core/string/translation.h"
|
||||||
|
|
||||||
#include "scene/gui/label.h"
|
#include "scene/gui/label.h"
|
||||||
#include "scene/gui/panel.h"
|
#include "scene/gui/panel.h"
|
||||||
#include "scene/main/canvas_layer.h"
|
#include "scene/main/canvas_layer.h"
|
||||||
|
@ -48,7 +47,6 @@
|
||||||
#include "servers/text_server.h"
|
#include "servers/text_server.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2762,12 +2760,6 @@ bool Control::is_visibility_clip_disabled() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
|
||||||
#else
|
|
||||||
const String quote_style = "\"";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Node::get_argument_options(p_function, p_idx, r_options);
|
Node::get_argument_options(p_function, p_idx, r_options);
|
||||||
|
|
||||||
if (p_idx == 0) {
|
if (p_idx == 0) {
|
||||||
|
@ -2787,7 +2779,7 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List
|
||||||
|
|
||||||
sn.sort_custom<StringName::AlphCompare>();
|
sn.sort_custom<StringName::AlphCompare>();
|
||||||
for (const StringName &name : sn) {
|
for (const StringName &name : sn) {
|
||||||
r_options->push_back(String(name).quote(quote_style));
|
r_options->push_back(String(name).quote());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,6 @@
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(Node::ProcessMode);
|
VARIANT_ENUM_CAST(Node::ProcessMode);
|
||||||
|
@ -2536,17 +2532,11 @@ NodePath Node::get_import_path() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
|
static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
|
||||||
#else
|
|
||||||
const String quote_style = "\"";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (p_node != p_base && !p_node->get_owner()) {
|
if (p_node != p_base && !p_node->get_owner()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String n = p_base->get_path_to(p_node);
|
String n = p_base->get_path_to(p_node);
|
||||||
r_options->push_back(n.quote(quote_style));
|
r_options->push_back(n.quote());
|
||||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||||
_add_nodes_to_options(p_base, p_node->get_child(i), r_options);
|
_add_nodes_to_options(p_base, p_node->get_child(i), r_options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,6 @@
|
||||||
|
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
|
|
||||||
|
@ -268,19 +263,13 @@ void ShaderMaterial::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
|
||||||
#else
|
|
||||||
const String quote_style = "\"";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String f = p_function.operator String();
|
String f = p_function.operator String();
|
||||||
if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
|
if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
|
||||||
if (shader.is_valid()) {
|
if (shader.is_valid()) {
|
||||||
List<PropertyInfo> pl;
|
List<PropertyInfo> pl;
|
||||||
shader->get_param_list(&pl);
|
shader->get_param_list(&pl);
|
||||||
for (const PropertyInfo &E : pl) {
|
for (const PropertyInfo &E : pl) {
|
||||||
r_options->push_back(E.name.replace_first("shader_param/", "").quote(quote_style));
|
r_options->push_back(E.name.replace_first("shader_param/", "").quote());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue