Merge pull request #64396 from qarmin/add_line_length_options
This commit is contained in:
commit
992104bc12
3 changed files with 1114 additions and 914 deletions
File diff suppressed because it is too large
Load diff
|
@ -35,37 +35,43 @@
|
|||
#include "core/io/file_access.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
|
||||
class RegEx;
|
||||
|
||||
class ProjectConverter3To4 {
|
||||
public:
|
||||
class RegExContainer;
|
||||
|
||||
private:
|
||||
void rename_enums(String &file_content);
|
||||
Vector<String> check_for_rename_enums(Vector<String> &file_content);
|
||||
uint64_t maximum_file_size;
|
||||
uint64_t maximum_line_length;
|
||||
|
||||
void rename_classes(String &file_content);
|
||||
Vector<String> check_for_rename_classes(Vector<String> &file_content);
|
||||
void rename_colors(Vector<String> &lines, const RegExContainer ®_container);
|
||||
Vector<String> check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container);
|
||||
|
||||
void rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin);
|
||||
Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin);
|
||||
void rename_classes(Vector<String> &lines, const RegExContainer ®_container);
|
||||
Vector<String> check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container);
|
||||
|
||||
void rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin);
|
||||
Vector<String> check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin);
|
||||
void process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin);
|
||||
|
||||
void rename_csharp_functions(String &file_content);
|
||||
Vector<String> check_for_rename_csharp_functions(Vector<String> &file_content);
|
||||
void process_csharp_line(String &line);
|
||||
void rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container);
|
||||
Vector<String> check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container);
|
||||
void process_csharp_line(String &line, const RegExContainer ®_container);
|
||||
|
||||
void rename_csharp_attributes(String &file_content);
|
||||
Vector<String> check_for_rename_csharp_attributes(Vector<String> &file_content);
|
||||
void rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container);
|
||||
Vector<String> check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container);
|
||||
|
||||
void rename_gdscript_keywords(String &file_content);
|
||||
Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content);
|
||||
void rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container);
|
||||
Vector<String> check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container);
|
||||
|
||||
void custom_rename(String &file_content, String from, String to);
|
||||
Vector<String> check_for_custom_rename(Vector<String> &file_content, String from, String to);
|
||||
void custom_rename(Vector<String> &lines, String from, String to);
|
||||
Vector<String> check_for_custom_rename(Vector<String> &lines, String from, String to);
|
||||
|
||||
void rename_common(const char *array[][2], String &file_content);
|
||||
Vector<String> check_for_rename_common(const char *array[][2], Vector<String> &file_content);
|
||||
void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines);
|
||||
Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines);
|
||||
|
||||
Vector<String> check_for_files();
|
||||
|
||||
|
@ -77,15 +83,17 @@ private:
|
|||
|
||||
String line_formatter(int current_line, String from, String to, String line);
|
||||
String simple_line_formatter(int current_line, String old_line, String line);
|
||||
String collect_string_from_vector(Vector<String> &vector);
|
||||
|
||||
bool test_single_array(const char *array[][2], bool ignore_second_check = false);
|
||||
bool test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what);
|
||||
bool test_conversion_single_additional_builtin(String name, String expected, void (ProjectConverter3To4::*func)(String &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin);
|
||||
bool test_conversion_single_normal(String name, String expected, const char *array[][2], String what);
|
||||
bool test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin);
|
||||
bool test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container);
|
||||
bool test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what);
|
||||
bool test_array_names();
|
||||
bool test_conversion(const RegExContainer ®_container);
|
||||
bool test_conversion(RegExContainer ®_container);
|
||||
|
||||
public:
|
||||
ProjectConverter3To4(int, int);
|
||||
int validate_conversion();
|
||||
int convert();
|
||||
};
|
||||
|
|
|
@ -156,6 +156,8 @@ static OS::ProcessID editor_pid = 0;
|
|||
#ifdef TOOLS_ENABLED
|
||||
static bool auto_build_solutions = false;
|
||||
static String debug_server_uri;
|
||||
static int converter_max_kb_file = 4 * 1024; // 4MB
|
||||
static int converter_max_line_length = 100000;
|
||||
|
||||
HashMap<Main::CLIScope, Vector<String>> forwardable_cli_arguments;
|
||||
#endif
|
||||
|
@ -403,8 +405,8 @@ void Main::print_help(const char *p_binary) {
|
|||
OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n");
|
||||
OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n");
|
||||
OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n");
|
||||
OS::get_singleton()->print(" --convert-3to4 Converts project from Godot 3.x to Godot 4.x.\n");
|
||||
OS::get_singleton()->print(" --validate-conversion-3to4 Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n");
|
||||
OS::get_singleton()->print(" --convert-3to4 [<max_file_kb>] [<max_line_size>] Converts project from Godot 3.x to Godot 4.x.\n");
|
||||
OS::get_singleton()->print(" --validate-conversion-3to4 [<max_file_kb>] [<max_line_size>] Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n");
|
||||
OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n");
|
||||
OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
|
||||
OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n");
|
||||
|
@ -1086,10 +1088,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
|
||||
if (I->next() && !I->next()->get().begins_with("-")) {
|
||||
if (itos(I->next()->get().to_int()) == I->next()->get()) {
|
||||
converter_max_kb_file = I->next()->get().to_int();
|
||||
}
|
||||
if (I->next()->next() && !I->next()->next()->get().begins_with("-")) {
|
||||
if (itos(I->next()->next()->get().to_int()) == I->next()->next()->get()) {
|
||||
converter_max_line_length = I->next()->next()->get().to_int();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (I->get() == "--validate-conversion-3to4") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
|
||||
if (I->next() && !I->next()->get().begins_with("-")) {
|
||||
if (itos(I->next()->get().to_int()) == I->next()->get()) {
|
||||
converter_max_kb_file = I->next()->get().to_int();
|
||||
}
|
||||
if (I->next()->next() && !I->next()->next()->get().begins_with("-")) {
|
||||
if (itos(I->next()->next()->get().to_int()) == I->next()->next()->get()) {
|
||||
converter_max_line_length = I->next()->next()->get().to_int();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (I->get() == "--doctool") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
|
@ -2394,12 +2418,12 @@ bool Main::start() {
|
|||
}
|
||||
|
||||
if (converting_project) {
|
||||
int exit_code = ProjectConverter3To4().convert();
|
||||
int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
if (validating_converting_project) {
|
||||
int exit_code = ProjectConverter3To4().validate_conversion();
|
||||
int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).validate_conversion();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue