From 745f8e112fcf5d61e0fc377bdbc2539dd6b16ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 29 Jan 2024 21:00:26 +0100 Subject: [PATCH] Revert "Add UID support to GDScript files" This reverts commit c7f68a27ec4b825302998eeb5a400f869cd21cf7. We still think GDScript files need UIDs to allow safe refactoring, but we're still debating what form those should take exactly. So far there seems to be agreement that it shouldn't be done via an annotation as implemented here, so we're reverting this one for now, to revisit the feature in a future PR. --- editor/plugins/script_text_editor.cpp | 1 - modules/gdscript/doc_classes/@GDScript.xml | 10 +- modules/gdscript/gdscript.cpp | 122 ++---------------- modules/gdscript/gdscript.h | 6 - modules/gdscript/gdscript_parser.cpp | 38 +----- modules/gdscript/gdscript_parser.h | 4 - .../scripts/parser/errors/uid_duplicate.gd | 5 - .../scripts/parser/errors/uid_duplicate.out | 2 - .../scripts/parser/errors/uid_invalid.gd | 4 - .../scripts/parser/errors/uid_invalid.out | 2 - .../scripts/parser/errors/uid_too_late.gd | 5 - .../scripts/parser/errors/uid_too_late.out | 2 - .../tests/scripts/parser/features/uid.gd | 5 - .../tests/scripts/parser/features/uid.out | 1 - modules/gdscript/tests/test_gdscript_uid.h | 115 ----------------- 15 files changed, 15 insertions(+), 307 deletions(-) delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_duplicate.gd delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_duplicate.out delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_invalid.gd delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_invalid.out delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_too_late.gd delete mode 100644 modules/gdscript/tests/scripts/parser/errors/uid_too_late.out delete mode 100644 modules/gdscript/tests/scripts/parser/features/uid.gd delete mode 100644 modules/gdscript/tests/scripts/parser/features/uid.out delete mode 100644 modules/gdscript/tests/test_gdscript_uid.h diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index d8fb55ca543..c48cbd8c208 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -146,7 +146,6 @@ void ScriptTextEditor::set_edited_resource(const Ref &p_res) { ERR_FAIL_COND(p_res.is_null()); script = p_res; - script->connect_changed(callable_mp((ScriptEditorBase *)this, &ScriptEditorBase::reload_text)); code_editor->get_text_editor()->set_text(script->get_source_code()); code_editor->get_text_editor()->clear_undo_history(); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index b335bf8faec..933bfba5bad 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -627,7 +627,7 @@ [/codeblock] [b]Note:[/b] Only the script can have a custom icon. Inner classes are not supported. [b]Note:[/b] As annotations describe their subject, the [annotation @icon] annotation must be placed before the class definition and inheritance. - [b]Note:[/b] Unlike most other annotations, the argument of the [annotation @icon] annotation must be a string literal (constant expressions are not supported). + [b]Note:[/b] Unlike other annotations, the argument of the [annotation @icon] annotation must be a string literal (constant expressions are not supported). @@ -681,14 +681,6 @@ [b]Note:[/b] As annotations describe their subject, the [annotation @tool] annotation must be placed before the class definition and inheritance. - - - - - Stores information about UID of this script. This annotation is auto-generated when saving the script and must not be modified manually. Only applies to scripts saved as separate files (i.e. not built-in). - [b]Note:[/b] Unlike most other annotations, the argument of the [annotation @uid] annotation must be a string literal (constant expressions are not supported). - - diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 02c21618f07..0da77529405 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -55,7 +55,6 @@ #ifdef TOOLS_ENABLED #include "editor/editor_paths.h" -#include "editor/editor_settings.h" #endif #include @@ -1077,36 +1076,6 @@ Ref GDScript::get_base() const { return base; } -String GDScript::get_raw_source_code(const String &p_path, bool *r_error) { - Ref f = FileAccess::open(p_path, FileAccess::READ); - if (f.is_null()) { - if (r_error) { - *r_error = true; - } - return String(); - } - return f->get_as_utf8_string(); -} - -Vector2i GDScript::get_uid_lines(const String &p_source) { - GDScriptParser parser; - parser.parse(p_source, "", false); - const GDScriptParser::ClassNode *c = parser.get_tree(); - if (!c) { - return Vector2i(-1, -1); - } - return c->uid_lines; -} - -String GDScript::create_uid_line(const String &p_uid_str) { -#ifdef TOOLS_ENABLED - if (EDITOR_GET("text_editor/completion/use_single_quotes")) { - return vformat(R"(@uid('%s') # %s)", p_uid_str, RTR("Generated automatically, do not modify.")); - } -#endif - return vformat(R"(@uid("%s") # %s)", p_uid_str, RTR("Generated automatically, do not modify.")); -} - bool GDScript::inherits_script(const Ref