diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-03 12:34:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-03 12:34:00 +0200 |
commit | c630c2001dbe2e25e0d372bd22ce85cdc2822eb0 (patch) | |
tree | ef0a55219c9b682c491194f42083780ede1a39ec /core/object | |
parent | 7bb963efe9083662baa356f56a2d5c368b96a9a0 (diff) | |
parent | 4ab605d14d0c18aeeded545e3cc453734df7abd7 (diff) |
Merge pull request #59633 from EricEzaM/better-code-complete-update
Improve sorting of Code Completion options.
Diffstat (limited to 'core/object')
-rw-r--r-- | core/object/script_language.h | 11 | ||||
-rw-r--r-- | core/object/script_language_extension.cpp | 5 | ||||
-rw-r--r-- | core/object/script_language_extension.h | 3 |
3 files changed, 18 insertions, 1 deletions
diff --git a/core/object/script_language.h b/core/object/script_language.h index 6161a0fc0f..af4f276825 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -311,6 +311,13 @@ public: CODE_COMPLETION_KIND_MAX }; + enum CodeCompletionLocation { + LOCATION_LOCAL = 0, + LOCATION_PARENT_MASK = 1 << 8, + LOCATION_OTHER_USER_CODE = 1 << 9, + LOCATION_OTHER = 1 << 10, + }; + struct CodeCompletionOption { CodeCompletionKind kind = CODE_COMPLETION_KIND_PLAIN_TEXT; String display; @@ -319,13 +326,15 @@ public: RES icon; Variant default_value; Vector<Pair<int, int>> matches; + int location = LOCATION_OTHER; CodeCompletionOption() {} - CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind) { + CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind, int p_location = LOCATION_OTHER) { display = p_text; insert_text = p_text; kind = p_kind; + location = p_location; } }; diff --git a/core/object/script_language_extension.cpp b/core/object/script_language_extension.cpp index bf0966c803..21d7685674 100644 --- a/core/object/script_language_extension.cpp +++ b/core/object/script_language_extension.cpp @@ -161,6 +161,11 @@ void ScriptLanguageExtension::_bind_methods() { BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE); BIND_ENUM_CONSTANT(LOOKUP_RESULT_MAX); + BIND_ENUM_CONSTANT(LOCATION_LOCAL); + BIND_ENUM_CONSTANT(LOCATION_PARENT_MASK); + BIND_ENUM_CONSTANT(LOCATION_OTHER_USER_CODE); + BIND_ENUM_CONSTANT(LOCATION_OTHER); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_CLASS); BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_FUNCTION); BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_SIGNAL); diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index b9ec79da26..40f18ab30d 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -387,6 +387,8 @@ public: option.icon = op["icon"]; ERR_CONTINUE(!op.has("default_value")); option.default_value = op["default_value"]; + ERR_CONTINUE(!op.has("location")); + option.location = op["location"]; if (op.has("matches")) { PackedInt32Array matches = op["matches"]; ERR_CONTINUE(matches.size() & 1); @@ -639,6 +641,7 @@ public: VARIANT_ENUM_CAST(ScriptLanguageExtension::LookupResultType) VARIANT_ENUM_CAST(ScriptLanguageExtension::CodeCompletionKind) +VARIANT_ENUM_CAST(ScriptLanguageExtension::CodeCompletionLocation) class ScriptInstanceExtension : public ScriptInstance { public: |