Added quote_style argument to get_argument_options().

This commit is contained in:
Relintai 2023-12-10 16:02:08 +01:00
parent 9df5649c1b
commit 191e9e152e
20 changed files with 28 additions and 61 deletions

View File

@ -136,11 +136,8 @@ void Input::_bind_methods() {
ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected"))); ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
} }
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 String &quote_style) const {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
String pf = p_function; String pf = p_function;
if (p_idx == 0 && if (p_idx == 0 &&
(pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" ||

View File

@ -126,7 +126,7 @@ public:
virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0; virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
virtual void action_release(const StringName &p_action) = 0; virtual void action_release(const StringName &p_action) = 0;
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
virtual bool is_emulating_touch_from_mouse() const = 0; virtual bool is_emulating_touch_from_mouse() const = 0;
virtual bool is_emulating_mouse_from_touch() const = 0; virtual bool is_emulating_mouse_from_touch() const = 0;

View File

@ -2059,7 +2059,7 @@ void ObjectDB::debug_objects(DebugFunc p_func) {
rw_lock.read_unlock(); rw_lock.read_unlock();
} }
void Object::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { void Object::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
} }
int ObjectDB::get_object_count() { int ObjectDB::get_object_count() {

View File

@ -774,7 +774,7 @@ public:
virtual void get_translatable_strings(List<String> *p_strings) const; virtual void get_translatable_strings(List<String> *p_strings) const;
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
StringName tr(const StringName &p_message) const; // translate message (internationalization) StringName tr(const StringName &p_message) const; // translate message (internationalization)
StringName trt(const StringName &p_message, const String &p_locale) const; // translate message (translate_to) (internationalization) StringName trt(const StringName &p_message, const String &p_locale) const; // translate message (translate_to) (internationalization)

View File

@ -2309,7 +2309,7 @@ static void _find_call_arguments(const CScriptCompletionContext &p_context, cons
Object *obj = base.operator Object *(); Object *obj = base.operator Object *();
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, quote_style);
for (List<String>::Element *F = options.front(); F; F = F->next()) { for (List<String>::Element *F = options.front(); F; F = F->next()) {
ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION); ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
r_result.insert(option.display, option); r_result.insert(option.display, option);
@ -2611,7 +2611,7 @@ Error CScriptLanguage::complete_code(const String &p_code, const String &p_path,
case CScriptParser::COMPLETION_GET_NODE: { case CScriptParser::COMPLETION_GET_NODE: {
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, quote_style);
for (List<String>::Element *E = opts.front(); E; E = E->next()) { for (List<String>::Element *E = opts.front(); E; E = E->next()) {
String opt = E->get().strip_edges(); String opt = E->get().strip_edges();

View File

@ -2330,7 +2330,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
Object *obj = base.operator Object *(); Object *obj = base.operator Object *();
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, quote_style);
for (List<String>::Element *F = options.front(); F; F = F->next()) { for (List<String>::Element *F = options.front(); F; F = F->next()) {
ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION); ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
r_result.insert(option.display, option); r_result.insert(option.display, option);
@ -2632,7 +2632,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
case GDScriptParser::COMPLETION_GET_NODE: { case GDScriptParser::COMPLETION_GET_NODE: {
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, quote_style);
for (List<String>::Element *E = opts.front(); E; E = E->next()) { for (List<String>::Element *E = opts.front(); E; E = E->next()) {
String opt = E->get().strip_edges(); String opt = E->get().strip_edges();

View File

@ -280,13 +280,7 @@ void SpriteFrames::_set_animations(const Array &p_animations) {
} }
} }
void AnimatedSprite::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { void AnimatedSprite::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
if (p_idx == 0 && p_function == "play" && frames.is_valid()) { if (p_idx == 0 && p_function == "play" && frames.is_valid()) {
List<StringName> al; List<StringName> al;
frames->get_animation_list(&al); frames->get_animation_list(&al);
@ -294,7 +288,7 @@ void AnimatedSprite::get_argument_options(const StringName &p_function, int p_id
r_options->push_back(quote_style + String(E->get()) + quote_style); r_options->push_back(quote_style + String(E->get()) + quote_style);
} }
} }
Node::get_argument_options(p_function, p_idx, r_options); Node::get_argument_options(p_function, p_idx, r_options, quote_style);
} }
void SpriteFrames::_bind_methods() { void SpriteFrames::_bind_methods() {

View File

@ -194,7 +194,7 @@ public:
bool is_flipped_v() const; bool is_flipped_v() const;
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const;
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
AnimatedSprite(); AnimatedSprite();
}; };

View File

@ -440,13 +440,7 @@ SpatialMaterial::BillboardMode SpriteBase3D::get_billboard_mode() const {
return billboard_mode; return billboard_mode;
} }
void AnimatedSprite3D::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { void AnimatedSprite3D::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
if (p_idx == 0 && p_function == "play" && frames.is_valid()) { if (p_idx == 0 && p_function == "play" && frames.is_valid()) {
List<StringName> al; List<StringName> al;
frames->get_animation_list(&al); frames->get_animation_list(&al);
@ -454,7 +448,7 @@ void AnimatedSprite3D::get_argument_options(const StringName &p_function, int p_
r_options->push_back(quote_style + String(E->get()) + quote_style); r_options->push_back(quote_style + String(E->get()) + quote_style);
} }
} }
Node::get_argument_options(p_function, p_idx, r_options); Node::get_argument_options(p_function, p_idx, r_options, quote_style);
} }
void SpriteBase3D::_bind_methods() { void SpriteBase3D::_bind_methods() {

View File

@ -247,7 +247,7 @@ public:
virtual Rect2 get_item_rect() const; virtual Rect2 get_item_rect() const;
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const;
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
AnimatedSprite3D(); AnimatedSprite3D();
}; };

View File

@ -1630,13 +1630,7 @@ NodePath AnimationPlayer::get_root() const {
return root; return root;
} }
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 String &quote_style) const {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#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;
@ -1645,7 +1639,7 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
r_options->push_back(quote_style + String(E->get()) + quote_style); r_options->push_back(quote_style + String(E->get()) + quote_style);
} }
} }
Node::get_argument_options(p_function, p_idx, r_options); Node::get_argument_options(p_function, p_idx, r_options, quote_style);
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED

View File

@ -384,7 +384,7 @@ public:
void clear_caches(); ///< must be called by hand if an animation was modified after added void clear_caches(); ///< must be called by hand if an animation was modified after added
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Ref<AnimatedValuesBackup> backup_animated_values(Node *p_root_override = NULL); Ref<AnimatedValuesBackup> backup_animated_values(Node *p_root_override = NULL);

View File

@ -2659,14 +2659,8 @@ bool Control::is_visibility_clip_disabled() const {
return data.disable_visibility_clip; return data.disable_visibility_clip;
} }
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 String &quote_style) const {
#ifdef TOOLS_ENABLED Node::get_argument_options(p_function, p_idx, r_options, quote_style);
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
Node::get_argument_options(p_function, p_idx, r_options);
if (p_idx == 0) { if (p_idx == 0) {
List<StringName> sn; List<StringName> sn;

View File

@ -519,7 +519,7 @@ public:
void set_disable_visibility_clip(bool p_ignore); void set_disable_visibility_clip(bool p_ignore);
bool is_visibility_clip_disabled() const; bool is_visibility_clip_disabled() const;
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const;
Control(); Control();

View File

@ -3413,12 +3413,12 @@ static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<S
} }
} }
void Node::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { void Node::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
String pf = p_function; String pf = p_function;
if ((pf == "has_node" || pf == "get_node") && p_idx == 0) { if ((pf == "has_node" || pf == "get_node") && p_idx == 0) {
_add_nodes_to_options(this, this, r_options); _add_nodes_to_options(this, this, r_options);
} }
Object::get_argument_options(p_function, p_idx, r_options); Object::get_argument_options(p_function, p_idx, r_options, quote_style);
} }
void Node::clear_internal_tree_resource_paths() { void Node::clear_internal_tree_resource_paths() {

View File

@ -568,7 +568,7 @@ public:
bool is_owned_by_parent() const; bool is_owned_by_parent() const;
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
void clear_internal_tree_resource_paths(); void clear_internal_tree_resource_paths();

View File

@ -2431,7 +2431,7 @@ bool SceneTree::is_using_font_oversampling() const {
return use_font_oversampling; return use_font_oversampling;
} }
void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
if (p_function == "change_scene") { if (p_function == "change_scene") {
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
List<String> directories; List<String> directories;

View File

@ -441,7 +441,7 @@ public:
void drop_files(const Vector<String> &p_files, int p_from_screen = 0); void drop_files(const Vector<String> &p_files, int p_from_screen = 0);
void global_menu_action(const Variant &p_id, const Variant &p_meta); void global_menu_action(const Variant &p_id, const Variant &p_meta);
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
//network API //network API

View File

@ -233,13 +233,7 @@ void ShaderMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader");
} }
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 String &quote_style) const {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#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()) {
@ -250,7 +244,7 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
} }
} }
} }
Resource::get_argument_options(p_function, p_idx, r_options); Resource::get_argument_options(p_function, p_idx, r_options, quote_style);
} }
bool ShaderMaterial::_can_do_next_pass() const { bool ShaderMaterial::_can_do_next_pass() const {

View File

@ -84,7 +84,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
virtual bool _can_do_next_pass() const; virtual bool _can_do_next_pass() const;