Introduce EditorLanguage and move ScriptLanguage::complete_code into it.

This commit is contained in:
HolonProduction
2026-03-28 21:49:43 +01:00
parent a0375dde96
commit 623809d89e
12 changed files with 199 additions and 16 deletions
+11 -9
View File
@@ -36,6 +36,7 @@
#ifdef TOOLS_ENABLED
#include "editor/gdscript_docgen.h"
#include "editor/gdscript_editor_language.h"
#include "editor/script_templates/templates.gen.h"
#endif
@@ -55,6 +56,14 @@
#include "editor/settings/editor_settings.h"
#endif
#ifdef TOOLS_ENABLED
GDScriptEditorLanguage *GDScriptEditorLanguage::singleton = nullptr;
EditorLanguage *GDScriptLanguage::get_editor_language() {
return GDScriptEditorLanguage::get_singleton();
}
#endif // TOOLS_ENABLED
Vector<String> GDScriptLanguage::get_comment_delimiters() const {
static const Vector<String> delimiters = { "#" };
return delimiters;
@@ -3432,7 +3441,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_forced = r_result.size() > 0;
}
::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
::Error GDScriptEditorLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
GDScriptParser parser;
@@ -3623,7 +3632,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
HashMap<String, ScriptLanguage::CodeCompletionOption> opt;
_find_identifiers_in_base(base, false, false, false, opt, 0);
for (const KeyValue<String, CodeCompletionOption> &E : opt) {
for (const KeyValue<String, ScriptLanguage::CodeCompletionOption> &E : opt) {
ScriptLanguage::CodeCompletionOption option = _calculate_string_insertion(existing_index, E.value.insert_text);
option.kind = E.value.kind;
option.location = E.value.location;
@@ -3858,13 +3867,6 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
return OK;
}
#else // !TOOLS_ENABLED
Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
return OK;
}
#endif // TOOLS_ENABLED
//////// END COMPLETION //////////