diff --git a/clients/vscode-hlasmplugin/CHANGELOG.md b/clients/vscode-hlasmplugin/CHANGELOG.md index 51166aef6..d641f1d66 100644 --- a/clients/vscode-hlasmplugin/CHANGELOG.md +++ b/clients/vscode-hlasmplugin/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the HLASM Language Support extension are documented in this file. +## [0.11.1] - 2020-11-09 + +#### Fixed +- Plugin crashing when used on che-theia 7.21. + ## [0.11.0] - 2020-05-07 #### Added diff --git a/clients/vscode-hlasmplugin/package.json b/clients/vscode-hlasmplugin/package.json index 1b7710db6..3765e806d 100644 --- a/clients/vscode-hlasmplugin/package.json +++ b/clients/vscode-hlasmplugin/package.json @@ -2,7 +2,7 @@ "name": "hlasm-language-support", "displayName": "HLASM Language Support", "description": "Code completion, highlighting, browsing and validation for High Level Assembler.", - "version": "0.11.0", + "version": "0.11.1", "license": "EPL-2.0", "author": "Broadcom", "publisher": "BroadcomMFD", diff --git a/language_server/src/lsp/feature_workspace_folders.cpp b/language_server/src/lsp/feature_workspace_folders.cpp index ff3d9989f..027455f52 100644 --- a/language_server/src/lsp/feature_workspace_folders.cpp +++ b/language_server/src/lsp/feature_workspace_folders.cpp @@ -16,11 +16,15 @@ #include +#include "network/uri/uri.hpp" + +#include "../logger.h" + namespace hlasm_plugin::language_server::lsp { feature_workspace_folders::feature_workspace_folders(parser_library::workspace_manager& ws_mngr) : feature(ws_mngr) -{} +{ } void feature_workspace_folders::register_methods(std::map& methods) { @@ -120,7 +124,17 @@ void feature_workspace_folders::did_change_watched_files(const json&, const json std::vector changes = params["changes"]; std::vector paths; for (auto& change : changes) - paths.push_back(uri_to_path(change["uri"].get())); + { + try + { + paths.push_back(uri_to_path(change["uri"].get())); + } + catch (const std::system_error& e) + { + LOG_ERROR( + std::string("An exception caught while parsing didChangeWatchedFiles notification uri: ") + e.what()); + } + } std::vector c_uris; std::transform(paths.begin(), paths.end(), std::back_inserter(c_uris), [](std::string& s) { return s.c_str(); }); ws_mngr_.did_change_watched_files(c_uris.data(), c_uris.size()); diff --git a/language_server/src/lsp/lsp_server.cpp b/language_server/src/lsp/lsp_server.cpp index 4f4ca3de7..1559e9136 100644 --- a/language_server/src/lsp/lsp_server.cpp +++ b/language_server/src/lsp/lsp_server.cpp @@ -50,15 +50,23 @@ void server::message_received(const json& message) return; } - if (id_found == message.end()) + try { - // notification - call_method(method_found.value().get(), "", params_found.value()); + if (id_found == message.end()) + { + // notification + call_method(method_found.value().get(), "", params_found.value()); + } + else + { + // method + call_method(method_found.value().get(), id_found.value(), params_found.value()); + } } - else + catch (const std::exception& e) { - // method - call_method(method_found.value().get(), id_found.value(), params_found.value()); + LOG_ERROR(e.what()); + return; } } diff --git a/language_server/test/lsp/workspace_folders_test.cpp b/language_server/test/lsp/workspace_folders_test.cpp index e82708354..41c0fcf99 100644 --- a/language_server/test/lsp/workspace_folders_test.cpp +++ b/language_server/test/lsp/workspace_folders_test.cpp @@ -76,6 +76,18 @@ TEST(workspace_folders, did_change_workspace_folders) notifs["workspace/didChangeWorkspaceFolders"]("", params3); } +TEST(workspace_folders, did_change_watchedfiles_invalid_uri) +{ + ws_mngr_mock ws_mngr; + lsp::feature_workspace_folders f(ws_mngr); + + std::map notifs; + + f.register_methods(notifs); + notifs["workspace/didChangeWatchedFiles"]( + "", R"({"changes":[{"uri":"user_storage:/user/storage/layout","type":2}, {"uri":"file:///file_name"}]})"_json); +} + TEST(workspace_folders, initialize_folders) { using namespace ::testing; diff --git a/language_server/test/server_test.cpp b/language_server/test/server_test.cpp index 49f06b30b..77160a2b6 100644 --- a/language_server/test/server_test.cpp +++ b/language_server/test/server_test.cpp @@ -66,4 +66,15 @@ TEST(lsp_server_test, initialize) EXPECT_NE(server_capab["result"].find("capabilities"), server_capab["result"].end()); } +TEST(lsp_server_test, wrong_message_received) +{ + ws_mngr_mock ws_mngr; + send_message_provider_mock smpm; + lsp::server s(ws_mngr); + s.set_send_message_provider(&smpm); + + s.message_received( + R"({"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"user_storage:/user/storage/layout","languageId":"plaintext","version":4,"text":"sad"}}})"_json); +} + #endif // !HLASMPLUGIN_LANGUAGESERVER_TEST_SERVER_TEST_H