Skip to content

Commit

Permalink
Release 0.11.1 (#91)
Browse files Browse the repository at this point in the history
* fix parsing of invalid uris

* include fix

* prepare for release 0.11.1
  • Loading branch information
michalbali256 authored Nov 9, 2020
1 parent a67b811 commit 4f5aa98
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
5 changes: 5 additions & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clients/vscode-hlasmplugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 16 additions & 2 deletions language_server/src/lsp/feature_workspace_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@

#include <filesystem>

#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<std::string, method>& methods)
{
Expand Down Expand Up @@ -120,7 +124,17 @@ void feature_workspace_folders::did_change_watched_files(const json&, const json
std::vector<json> changes = params["changes"];
std::vector<std::string> paths;
for (auto& change : changes)
paths.push_back(uri_to_path(change["uri"].get<std::string>()));
{
try
{
paths.push_back(uri_to_path(change["uri"].get<std::string>()));
}
catch (const std::system_error& e)
{
LOG_ERROR(
std::string("An exception caught while parsing didChangeWatchedFiles notification uri: ") + e.what());
}
}
std::vector<const char*> 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());
Expand Down
20 changes: 14 additions & 6 deletions language_server/src/lsp/lsp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(), "", params_found.value());
if (id_found == message.end())
{
// notification
call_method(method_found.value().get<std::string>(), "", params_found.value());
}
else
{
// method
call_method(method_found.value().get<std::string>(), id_found.value(), params_found.value());
}
}
else
catch (const std::exception& e)
{
// method
call_method(method_found.value().get<std::string>(), id_found.value(), params_found.value());
LOG_ERROR(e.what());
return;
}
}

Expand Down
12 changes: 12 additions & 0 deletions language_server/test/lsp/workspace_folders_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, method> 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;
Expand Down
11 changes: 11 additions & 0 deletions language_server/test/server_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4f5aa98

Please sign in to comment.