summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/language_server/gdscript_language_protocol.cpp
diff options
context:
space:
mode:
authorGeequlim <geequlim@gmail.com>2019-06-24 18:25:12 +0800
committergeequlim <geequlim@gmail.com>2019-08-11 13:30:15 +0800
commit76c9e4ceb73b02bd95ab0512e27229516208dc60 (patch)
treeb145ae3a4a837a109943f654bf433e704b7eac74 /modules/gdscript/language_server/gdscript_language_protocol.cpp
parentfa6d6a329c93224b5454b17603284913da0472a3 (diff)
downloadredot-engine-76c9e4ceb73b02bd95ab0512e27229516208dc60.tar.gz
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.
Diffstat (limited to 'modules/gdscript/language_server/gdscript_language_protocol.cpp')
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp23
1 files changed, 22 insertions, 1 deletions
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);