From 9618b0c63e3330865350bd8bbc6a9d2faf9dd26c Mon Sep 17 00:00:00 2001 From: Geequlim Date: Tue, 25 Jun 2019 18:09:42 +0800 Subject: [PATCH] Check client workspace directory is valid Drop test initialize message sent to client Remove unused code property for the parser class --- .../gdscript_extend_parser.cpp | 1 - .../language_server/gdscript_extend_parser.h | 2 -- .../gdscript_language_protocol.cpp | 23 +++++++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index 16f4324da82..4d90c4eec38 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -557,7 +557,6 @@ const Array &ExtendGDScriptParser::get_member_completions() { Error ExtendGDScriptParser::parse(const String &p_code, const String &p_path) { path = p_path; - code = p_code; lines = p_code.split("\n"); Error err = GDScriptParser::parse(p_code, p_path.get_base_dir(), false, p_path, false, NULL, false); diff --git a/modules/gdscript/language_server/gdscript_extend_parser.h b/modules/gdscript/language_server/gdscript_extend_parser.h index 3710b92993c..e2da500d0db 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.h +++ b/modules/gdscript/language_server/gdscript_extend_parser.h @@ -52,7 +52,6 @@ typedef HashMap ClassMembers; class ExtendGDScriptParser : public GDScriptParser { String path; - String code; Vector lines; lsp::DocumentSymbol class_symbol; @@ -73,7 +72,6 @@ class ExtendGDScriptParser : public GDScriptParser { public: _FORCE_INLINE_ const String &get_path() const { return path; } - _FORCE_INLINE_ const String &get_code() const { return code; } _FORCE_INLINE_ const Vector &get_lines() const { return lines; } _FORCE_INLINE_ const lsp::DocumentSymbol &get_symbols() const { return class_symbol; } _FORCE_INLINE_ const Vector &get_diagnostics() const { return diagnostics; } diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 7fb336cc588..9ebabc276e8 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -103,7 +103,18 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { if (root_uri.length() && is_same_workspace) { workspace.root_uri = root_uri; } else { + workspace.root_uri = "file://" + workspace.root; + + Dictionary params; + params["path"] = workspace.root; + Dictionary request = make_notification("gdscrip_client/changeWorkspace", params); + if (Ref *peer = clients.getptr(lastest_client_id)) { + String msg = JSON::print(request); + msg = format_output(msg); + CharString charstr = msg.utf8(); + (*peer)->put_packet((const uint8_t *)charstr.ptr(), charstr.length()); + } } if (!_initialized) { @@ -116,18 +127,6 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { } void GDScriptLanguageProtocol::initialized(const Variant &p_params) { - - Dictionary params; - params["type"] = 3; - params["message"] = "GDScript Language Server initialized!"; - Dictionary test_message = make_notification("window/showMessage", params); - - if (Ref *peer = clients.getptr(lastest_client_id)) { - String msg = JSON::print(test_message); - msg = format_output(msg); - CharString charstr = msg.utf8(); - (*peer)->put_packet((const uint8_t *)charstr.ptr(), charstr.length()); - } } void GDScriptLanguageProtocol::poll() {