diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-01 14:56:12 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-01 14:56:12 +0100 |
commit | 0618bff3940a596114cc4fc1bdc302f0b218bfea (patch) | |
tree | 1b6a834132df5bba1de33fe710fade246381c296 /core | |
parent | c1377920cdf919e7316e43f5039c46ac91fd96e0 (diff) | |
parent | 920dff34452a1beec08e0d9bc7f0343d21154c62 (diff) | |
download | redot-engine-0618bff3940a596114cc4fc1bdc302f0b218bfea.tar.gz |
Merge pull request #86777 from Mickeon/autocomplete-classdb
Add autocompletion for ClassDB & AudioServer
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 24 | ||||
-rw-r--r-- | core/core_bind.h | 4 |
2 files changed, 28 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index b5098fc4d2..a0df1b6240 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1519,6 +1519,30 @@ bool ClassDB::is_class_enabled(const StringName &p_class) const { return ::ClassDB::is_class_enabled(p_class); } +#ifdef TOOLS_ENABLED +void ClassDB::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + const String pf = p_function; + bool first_argument_is_class = false; + if (p_idx == 0) { + first_argument_is_class = (pf == "get_inheriters_from_class" || pf == "get_parent_class" || + pf == "class_exists" || pf == "can_instantiate" || pf == "instantiate" || + pf == "class_has_signal" || pf == "class_get_signal" || pf == "class_get_signal_list" || + pf == "class_get_property_list" || pf == "class_get_property" || pf == "class_set_property" || + pf == "class_has_method" || pf == "class_get_method_list" || + pf == "class_get_integer_constant_list" || pf == "class_has_integer_constant" || pf == "class_get_integer_constant" || + pf == "class_has_enum" || pf == "class_get_enum_list" || pf == "class_get_enum_constants" || pf == "class_get_integer_constant_enum" || + pf == "is_class_enabled"); + } + if (first_argument_is_class || pf == "is_parent_class") { + for (const String &E : get_class_list()) { + r_options->push_back(E.quote()); + } + } + + Object::get_argument_options(p_function, p_idx, r_options); +} +#endif + void ClassDB::_bind_methods() { ::ClassDB::bind_method(D_METHOD("get_class_list"), &ClassDB::get_class_list); ::ClassDB::bind_method(D_METHOD("get_inheriters_from_class", "class"), &ClassDB::get_inheriters_from_class); diff --git a/core/core_bind.h b/core/core_bind.h index d5b8151f1e..64ab4dd7e2 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -460,6 +460,10 @@ public: bool is_class_enabled(const StringName &p_class) const; +#ifdef TOOLS_ENABLED + virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif + ClassDB() {} ~ClassDB() {} }; |