Added missing --lsp-port command line setting.

This commit is contained in:
Relintai 2023-10-02 19:30:35 +02:00
parent 84768b8f0c
commit 19d2c42c46

View File

@ -87,10 +87,17 @@
#endif #endif
#include "modules/modules_enabled.gen.h" #include "modules/modules_enabled.gen.h"
#ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED #ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED
#include "editor_code_editor/editor_script_editor.h" #include "editor_code_editor/editor_script_editor.h"
#endif #endif
#ifdef MODULE_GDSCRIPT_ENABLED
#if defined(TOOLS_ENABLED) && !defined(GDSCRIPT_NO_LSP)
#include "modules/gdscript/language_server/gdscript_language_server.h"
#endif // TOOLS_ENABLED && !GDSCRIPT_NO_LSP
#endif // MODULE_GDSCRIPT_ENABLED
/* Static members */ /* Static members */
// Singletons // Singletons
@ -328,6 +335,9 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n"); OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n");
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n"); OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
OS::get_singleton()->print(" --debug-server <address> Start the editor debug server (<IP>:<port>, e.g. 127.0.0.1:6007)\n"); OS::get_singleton()->print(" --debug-server <address> Start the editor debug server (<IP>:<port>, e.g. 127.0.0.1:6007)\n");
#if defined(MODULE_GDSCRIPT_ENABLED) && !defined(GDSCRIPT_NO_LSP)
OS::get_singleton()->print(" --lsp-port <port> Use the specified port for the language server protocol. The port must be between 0 to 65535.\n");
#endif // MODULE_GDSCRIPT_ENABLED && !GDSCRIPT_NO_LSP
#endif #endif
OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n"); OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n"); OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
@ -984,7 +994,21 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing <path> argument for --benchmark-file <path>.\n"); OS::get_singleton()->print("Missing <path> argument for --benchmark-file <path>.\n");
goto error; goto error;
} }
#if defined(TOOLS_ENABLED) && !defined(GDSCRIPT_NO_LSP)
} else if (I->get() == "--lsp-port") {
if (I->next()) {
int port_override = I->next()->get().to_int();
if (port_override < 0 || port_override > 65535) {
OS::get_singleton()->print("<port> argument for --lsp-port <port> must be between 0 and 65535.\n");
goto error;
}
GDScriptLanguageServer::port_override = port_override;
N = I->next()->next();
} else {
OS::get_singleton()->print("Missing <port> argument for --lsp-port <port>.\n");
goto error;
}
#endif // TOOLS_ENABLED && !GDSCRIPT_NO_LSP
} else { } else {
main_args.push_back(I->get()); main_args.push_back(I->get());
} }