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.
This commit is contained in:
Geequlim 2019-06-24 18:25:12 +08:00 committed by geequlim
parent fa6d6a329c
commit 76c9e4ceb7
9 changed files with 496 additions and 442 deletions

View file

@ -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);