Skip to content

Commit

Permalink
Added quote_style argument to get_argument_options().
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Dec 10, 2023
1 parent 9df5649 commit 191e9e1
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 61 deletions.
5 changes: 1 addition & 4 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,8 @@ void Input::_bind_methods() {
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

const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";

String pf = p_function;
if (p_idx == 0 &&
(pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" ||
Expand Down
2 changes: 1 addition & 1 deletion core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Input : public Object {
virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 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_mouse_from_touch() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ void ObjectDB::debug_objects(DebugFunc p_func) {
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() {
Expand Down
2 changes: 1 addition & 1 deletion core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ class Object {

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 trt(const StringName &p_message, const String &p_locale) const; // translate message (translate_to) (internationalization)
Expand Down
4 changes: 2 additions & 2 deletions modules/cscript/cscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,7 @@ static void _find_call_arguments(const CScriptCompletionContext &p_context, cons
Object *obj = base.operator Object *();
if (obj) {
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()) {
ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
r_result.insert(option.display, option);
Expand Down Expand Up @@ -2611,7 +2611,7 @@ Error CScriptLanguage::complete_code(const String &p_code, const String &p_path,
case CScriptParser::COMPLETION_GET_NODE: {
if (p_owner) {
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()) {
String opt = E->get().strip_edges();
Expand Down
4 changes: 2 additions & 2 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
Object *obj = base.operator Object *();
if (obj) {
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()) {
ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
r_result.insert(option.display, option);
Expand Down Expand Up @@ -2632,7 +2632,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
case GDScriptParser::COMPLETION_GET_NODE: {
if (p_owner) {
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()) {
String opt = E->get().strip_edges();
Expand Down
10 changes: 2 additions & 8 deletions scene/2d/animated_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,15 @@ 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 {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif

void AnimatedSprite::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
if (p_idx == 0 && p_function == "play" && frames.is_valid()) {
List<StringName> al;
frames->get_animation_list(&al);
for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
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() {
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/animated_sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class AnimatedSprite : public Node2D {
bool is_flipped_v() 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();
};
Expand Down
10 changes: 2 additions & 8 deletions scene/3d/sprite_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,21 +440,15 @@ SpatialMaterial::BillboardMode SpriteBase3D::get_billboard_mode() const {
return billboard_mode;
}

void AnimatedSprite3D::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

void AnimatedSprite3D::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
if (p_idx == 0 && p_function == "play" && frames.is_valid()) {
List<StringName> al;
frames->get_animation_list(&al);
for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
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() {
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/sprite_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class AnimatedSprite3D : public SpriteBase3D {
virtual Rect2 get_item_rect() 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();
};
Expand Down
10 changes: 2 additions & 8 deletions scene/animation/animation_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,13 +1630,7 @@ NodePath AnimationPlayer::get_root() const {
return root;
}

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_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif

void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
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")) {
List<StringName> al;
Expand All @@ -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);
}
}
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
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class AnimationPlayer : public Node {

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
Ref<AnimatedValuesBackup> backup_animated_values(Node *p_root_override = NULL);
Expand Down
10 changes: 2 additions & 8 deletions scene/main/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2659,14 +2659,8 @@ bool Control::is_visibility_clip_disabled() const {
return data.disable_visibility_clip;
}

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_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif

Node::get_argument_options(p_function, p_idx, r_options);
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
Node::get_argument_options(p_function, p_idx, r_options, quote_style);

if (p_idx == 0) {
List<StringName> sn;
Expand Down
2 changes: 1 addition & 1 deletion scene/main/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class Control : public CanvasItem {
void set_disable_visibility_clip(bool p_ignore);
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;

Control();
Expand Down
4 changes: 2 additions & 2 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
if ((pf == "has_node" || pf == "get_node") && p_idx == 0) {
_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() {
Expand Down
2 changes: 1 addition & 1 deletion scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class Node : public Object {

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();

Expand Down
2 changes: 1 addition & 1 deletion scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ bool SceneTree::is_using_font_oversampling() const {
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") {
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
List<String> directories;
Expand Down
2 changes: 1 addition & 1 deletion scene/main/scene_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class SceneTree : public MainLoop {

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 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

Expand Down
10 changes: 2 additions & 8 deletions scene/resources/material/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ void ShaderMaterial::_bind_methods() {
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 {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif

void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const {
String f = p_function.operator String();
if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
if (shader.is_valid()) {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/material/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ShaderMaterial : public Material {

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;

Expand Down

0 comments on commit 191e9e1

Please sign in to comment.