From 76c9e4ceb73b02bd95ab0512e27229516208dc60 Mon Sep 17 00:00:00 2001 From: Geequlim Date: Mon, 24 Jun 2019 18:25:12 +0800 Subject: Improved performance for completion and symbol resolvation. Improved uri and workspace path translatation on windows platform. The smart resolvation is much faster than builtin's in the server side. The smart resolve mode is still disabled as default as the clients might be slow with a planty of completion items. --- .../language_server/gdscript_language_protocol.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'modules/gdscript/language_server/gdscript_language_protocol.cpp') diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 7c24efe450..7fb336cc58 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -91,7 +91,27 @@ void GDScriptLanguageProtocol::_bind_methods() { Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { lsp::InitializeResult ret; - workspace.initialize(); + + String root_uri = p_params["rootUri"]; + String root = p_params["rootPath"]; + bool is_same_workspace = root == workspace.root; + is_same_workspace = root.to_lower() == workspace.root.to_lower(); +#ifdef WINDOWS_ENABLED + is_same_workspace = root.replace("\\", "/").to_lower() == workspace.root.to_lower(); +#endif + + if (root_uri.length() && is_same_workspace) { + workspace.root_uri = root_uri; + } else { + workspace.root_uri = "file://" + workspace.root; + } + + if (!_initialized) { + workspace.initialize(); + text_document.initialize(); + _initialized = true; + } + return ret.to_json(); } @@ -167,6 +187,7 @@ bool GDScriptLanguageProtocol::is_smart_resolve_enabled() const { GDScriptLanguageProtocol::GDScriptLanguageProtocol() { server = NULL; singleton = this; + _initialized = false; set_scope("textDocument", &text_document); set_scope("completionItem", &text_document); set_scope("workspace", &workspace); -- cgit v1.2.3