Skip to content

Commit

Permalink
fix: Bridge for Git configuration files may be ignored by the macro t…
Browse files Browse the repository at this point in the history
…racer
  • Loading branch information
slavek-kucera authored Jun 1, 2023
1 parent f051e7f commit 98da01d
Show file tree
Hide file tree
Showing 46 changed files with 1,617 additions and 1,443 deletions.
16 changes: 8 additions & 8 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class bench

struct parse_parameters
{
parser_library::workspace_manager ws;
std::unique_ptr<parser_library::workspace_manager> ws = parser_library::create_workspace_manager();
benchmark::diagnostic_counter diag_counter;
parsing_metadata_collector collector;
const std::string& source_file;
Expand All @@ -395,10 +395,10 @@ class bench
, source_path(bc.ws_folder + "/" + source_file)
{
annotation = get_file_message(current_iteration, bc);
ws.register_diagnostics_consumer(&diag_counter);
ws.register_parsing_metadata_consumer(&collector);
ws.add_workspace(bc.ws_folder.c_str(), bc.ws_folder.c_str());
ws.idle_handler();
ws->register_diagnostics_consumer(&diag_counter);
ws->register_parsing_metadata_consumer(&collector);
ws->add_workspace(bc.ws_folder.c_str(), bc.ws_folder.c_str());
ws->idle_handler();
}

private:
Expand Down Expand Up @@ -599,10 +599,10 @@ class bench
// open file/parse
try
{
reparse ? ws.did_change_file(source_path_c_str, 1, &dummy_change, 1)
: ws.did_open_file(source_path_c_str, 1, content.c_str(), content.length());
reparse ? ws->did_change_file(source_path_c_str, 1, &dummy_change, 1)
: ws->did_open_file(source_path_c_str, 1, content.c_str(), content.length());

ws.idle_handler();
ws->idle_handler();
}
catch (const std::exception& e)
{
Expand Down
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 @@

## ****Unreleased****

#### Added

#### Fixed
- Bridge for Git configuration files may be ignored by the macro tracer

## [1.8.0](https://github.com/eclipse-che4z/che-che4z-lsp-for-hlasm/compare/1.7.0...1.8.0) (2023-05-24)

#### Added
Expand Down
8 changes: 4 additions & 4 deletions language_server/src/dap/dap_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ void dap_feature::initialize_feature(const nlohmann::json&)
{ /* nothing to do */
}

dap_feature::dap_feature(parser_library::workspace_manager& ws_mngr,
dap_feature::dap_feature(parser_library::debugger_configuration_provider& dc_provider,
response_provider& response_provider,
dap_disconnect_listener* disconnect_listener)
: feature(ws_mngr, response_provider)
: feature(response_provider)
, dc_provider(dc_provider)
, disconnect_listener_(disconnect_listener)
{}

Expand Down Expand Up @@ -150,7 +151,6 @@ void dap_feature::on_launch(const request_id& request_seq, const nlohmann::json&
// wait for configurationDone?
std::string program_path = server_conformant_path(args["program"].get<std::string_view>(), client_path_format_);
bool stop_on_entry = args["stopOnEntry"].get<bool>();
auto workspace_id = ws_mngr_.find_workspace(program_path.c_str());
debugger->set_event_consumer(this);

struct launch_handler
Expand All @@ -174,7 +174,7 @@ void dap_feature::on_launch(const request_id& request_seq, const nlohmann::json&
};

debugger->launch(program_path.c_str(),
*workspace_id,
dc_provider,
stop_on_entry,
parser_library::make_workspace_manager_response(launch_handler { request_seq, response_ }).first);
}
Expand Down
3 changes: 2 additions & 1 deletion language_server/src/dap/dap_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class dap_feature : public feature, public hlasm_plugin::parser_library::debuggi
public:
void initialize_feature(const nlohmann::json& client_capabilities) override;

dap_feature(parser_library::workspace_manager& ws_mngr,
dap_feature(parser_library::debugger_configuration_provider& dc_provider,
response_provider& response_provider,
dap_disconnect_listener* disconnect_listener);

Expand Down Expand Up @@ -77,6 +77,7 @@ class dap_feature : public feature, public hlasm_plugin::parser_library::debuggi
hlasm_plugin::parser_library::sequence<char> addtl_info) override;
void exited(int exit_code) override;

parser_library::debugger_configuration_provider& dc_provider;
std::optional<hlasm_plugin::parser_library::debugging::debugger> debugger;

int column_1_based_ = 0;
Expand Down
6 changes: 3 additions & 3 deletions language_server/src/dap/dap_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

namespace hlasm_plugin::language_server::dap {

server::server(parser_library::workspace_manager& ws_mngr, telemetry_sink* telemetry_reporter)
: language_server::server(ws_mngr, telemetry_reporter)
server::server(parser_library::debugger_configuration_provider& dc_provider, telemetry_sink* telemetry_reporter)
: language_server::server(telemetry_reporter)
{
auto dap_f = std::make_unique<dap_feature>(ws_mngr_, *this, this);
auto dap_f = std::make_unique<dap_feature>(dc_provider, *this, this);
m_dap_feature = dap_f.get();
features_.push_back(std::move(dap_f));
register_feature_methods();
Expand Down
3 changes: 2 additions & 1 deletion language_server/src/dap/dap_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace hlasm_plugin::language_server::dap {
class server final : public hlasm_plugin::language_server::server, public dap_disconnect_listener
{
public:
explicit server(parser_library::workspace_manager& ws_mngr, telemetry_sink* telemetry_reporter = nullptr);
explicit server(
parser_library::debugger_configuration_provider& dc_provider, telemetry_sink* telemetry_reporter = nullptr);

void request(const std::string& requested_method,
const nlohmann::json& args,
Expand Down
39 changes: 35 additions & 4 deletions language_server/src/dap/dap_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ void session::thread_routine()
{
const auto ext = [this]() {
if (ext_files)
return ext_files->register_thread([this]() { queue.write(nlohmann::json::value_t::discarded); });
return ext_files->register_thread([this]() noexcept {
// terminates on failure
queue.write(nlohmann::json::value_t::discarded);
});
else
return external_file_reader::thread_registration();
}();
Expand All @@ -44,7 +47,7 @@ void session::thread_routine()

utils::scope_exit indicate_end([this]() noexcept { running = false; });

dap::server server(*ws_mngr, telemetry_reporter);
dap::server server(*this, telemetry_reporter);
server.set_send_message_provider(&smp);

while (!server.is_exit_notification_received())
Expand All @@ -71,13 +74,41 @@ void session::thread_routine()
LOG_ERROR("DAP Thread encountered an unknown exception.");
}
}
void session::provide_debugger_configuration(parser_library::sequence<char> document_uri,
parser_library::workspace_manager_response<parser_library::debugging::debugger_configuration> conf)
{
struct proxy
{
parser_library::workspace_manager_response<parser_library::debugging::debugger_configuration> conf;
json_queue_channel& queue;

void wakeup() const noexcept
{
// terminates on failure
queue.write(nlohmann::json::value_t::discarded);
}

void provide(parser_library::debugging::debugger_configuration&& r) const
{
conf.provide(std::move(r));
wakeup();
}
void error(int err, const char* errmsg) const noexcept
{
conf.error(err, errmsg);
wakeup();
}
};
dc_provider->provide_debugger_configuration(
document_uri, parser_library::make_workspace_manager_response(proxy { std::move(conf), queue }).first);
}
session::session(size_t s_id,
hlasm_plugin::parser_library::workspace_manager& ws,
parser_library::debugger_configuration_provider& dc_provider,
json_sink& out,
telemetry_sink* telem_reporter,
external_file_reader* ext_files)
: session_id(message_wrapper::generate_method_name(s_id))
, ws_mngr(&ws)
, dc_provider(&dc_provider)
, msg_wrapper(out, s_id)
, msg_unwrapper(queue)
, telemetry_reporter(telem_reporter)
Expand Down
9 changes: 6 additions & 3 deletions language_server/src/dap/dap_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class external_file_reader;

namespace hlasm_plugin::language_server::dap {

class session final : public json_sink
class session final : public json_sink, parser_library::debugger_configuration_provider
{
std::string session_id;
hlasm_plugin::parser_library::workspace_manager* ws_mngr;
parser_library::debugger_configuration_provider* dc_provider;
json_queue_channel queue;
dap::message_wrapper msg_wrapper;
dap::message_unwrapper msg_unwrapper;
Expand All @@ -44,9 +44,12 @@ class session final : public json_sink

void thread_routine();

void provide_debugger_configuration(parser_library::sequence<char> document_uri,
parser_library::workspace_manager_response<parser_library::debugging::debugger_configuration> conf) override;

public:
session(size_t session_id,
hlasm_plugin::parser_library::workspace_manager& ws,
parser_library::debugger_configuration_provider& dc_provider,
json_sink& out,
telemetry_sink* telemetry_reporter = nullptr,
external_file_reader* ext_files = nullptr);
Expand Down
6 changes: 3 additions & 3 deletions language_server/src/dap/dap_session_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ void session_manager::handle_registration_request(size_t new_id)
cleanup_sessions();

// currently only one debug session is supported
auto new_session = std::make_unique<dap::session>(new_id, *ws_mngr, *out_stream, telemetry_reporter, ext_files);
auto new_session = std::make_unique<dap::session>(new_id, *dc_provider, *out_stream, telemetry_reporter, ext_files);
sessions.try_emplace(new_session->get_session_id(), std::move(new_session));
}
session_manager::session_manager(hlasm_plugin::parser_library::workspace_manager& ws,
session_manager::session_manager(parser_library::debugger_configuration_provider& dc_provider,
json_sink& out,
telemetry_sink* telem_reporter,
external_file_reader* ext_files)
: ws_mngr(&ws)
: dc_provider(&dc_provider)
, out_stream(&out)
, telemetry_reporter(telem_reporter)
, ext_files(ext_files)
Expand Down
4 changes: 2 additions & 2 deletions language_server/src/dap/dap_session_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace hlasm_plugin::language_server::dap {
class session;
class session_manager final : public json_sink
{
hlasm_plugin::parser_library::workspace_manager* ws_mngr;
parser_library::debugger_configuration_provider* dc_provider;
json_sink* out_stream;
std::map<std::string, std::unique_ptr<dap::session>, std::less<>> sessions;
telemetry_sink* telemetry_reporter;
Expand All @@ -41,7 +41,7 @@ class session_manager final : public json_sink
void handle_registration_request(size_t new_id);

public:
session_manager(hlasm_plugin::parser_library::workspace_manager& ws,
session_manager(parser_library::debugger_configuration_provider& dc_provider,
json_sink& out,
telemetry_sink* telemetry_reporter = nullptr,
external_file_reader* ext_files = nullptr);
Expand Down
14 changes: 4 additions & 10 deletions language_server/src/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,10 @@ class response_provider
class feature
{
public:
// Constructs the feature with workspace_manager.
// All the requests and notification are passed to the workspace manager
explicit feature(parser_library::workspace_manager& ws_mngr)
: ws_mngr_(ws_mngr)
{}
// Constructs the feature with workspace_manager and response_provider through which the feature can send messages.
feature(parser_library::workspace_manager& ws_mngr, response_provider& response_provider)
: ws_mngr_(ws_mngr)
, response_(&response_provider)
explicit feature() = default;
// Constructs the feature with response_provider through which the feature can send messages.
explicit feature(response_provider& response_provider)
: response_(&response_provider)
{}

// Implement to add methods to server.
Expand All @@ -180,7 +175,6 @@ class feature
virtual ~feature() = default;

protected:
parser_library::workspace_manager& ws_mngr_;
bool callbacks_registered_ = false;
response_provider* response_ = nullptr;
};
Expand Down
3 changes: 2 additions & 1 deletion language_server/src/lsp/feature_language_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ auto make_response(const request_id& id, response_provider* response, U handler)

feature_language_features::feature_language_features(
parser_library::workspace_manager& ws_mngr, response_provider& response_provider)
: feature(ws_mngr, response_provider)
: feature(response_provider)
, ws_mngr_(ws_mngr)
{}

void feature_language_features::register_methods(std::map<std::string, method>& methods)
Expand Down
2 changes: 2 additions & 0 deletions language_server/src/lsp/feature_language_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class feature_language_features : public feature

nlohmann::json document_symbol_item_json(hlasm_plugin::parser_library::document_symbol_item symbol);
nlohmann::json document_symbol_list_json(hlasm_plugin::parser_library::document_symbol_list symbol_list);

parser_library::workspace_manager& ws_mngr_;
};

} // namespace hlasm_plugin::language_server::lsp
Expand Down
3 changes: 2 additions & 1 deletion language_server/src/lsp/feature_text_synchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace hlasm_plugin::language_server::lsp {

feature_text_synchronization::feature_text_synchronization(
parser_library::workspace_manager& ws_mngr, response_provider& response_provider)
: feature(ws_mngr, response_provider)
: feature(response_provider)
, ws_mngr_(ws_mngr)
{}

void feature_text_synchronization::register_methods(std::map<std::string, method>& methods)
Expand Down
2 changes: 2 additions & 0 deletions language_server/src/lsp/feature_text_synchronization.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class feature_text_synchronization : public feature
void on_did_change(const nlohmann::json& params);
// Handles textDocument/didClose notification.
void on_did_close(const nlohmann::json& params);

parser_library::workspace_manager& ws_mngr_;
};

} // namespace hlasm_plugin::language_server::lsp
Expand Down
3 changes: 2 additions & 1 deletion language_server/src/lsp/feature_workspace_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace hlasm_plugin::language_server::lsp {

feature_workspace_folders::feature_workspace_folders(
parser_library::workspace_manager& ws_mngr, response_provider& response_provider)
: feature(ws_mngr, response_provider)
: feature(response_provider)
, ws_mngr_(ws_mngr)
{}

void feature_workspace_folders::register_methods(std::map<std::string, method>& methods)
Expand Down
1 change: 1 addition & 0 deletions language_server/src/lsp/feature_workspace_folders.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class feature_workspace_folders : public feature

void send_configuration_request();

parser_library::workspace_manager& ws_mngr_;
std::vector<std::pair<std::string, std::string>> m_initial_workspaces;
};

Expand Down
16 changes: 8 additions & 8 deletions language_server/src/lsp/lsp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
namespace hlasm_plugin::language_server::lsp {

server::server(parser_library::workspace_manager& ws_mngr)
: language_server::server(ws_mngr, this)
: language_server::server(this)
{
features_.push_back(std::make_unique<feature_workspace_folders>(ws_mngr_, *this));
features_.push_back(std::make_unique<feature_text_synchronization>(ws_mngr_, *this));
features_.push_back(std::make_unique<feature_language_features>(ws_mngr_, *this));
features_.push_back(std::make_unique<feature_workspace_folders>(ws_mngr, *this));
features_.push_back(std::make_unique<feature_text_synchronization>(ws_mngr, *this));
features_.push_back(std::make_unique<feature_language_features>(ws_mngr, *this));
register_feature_methods();
register_methods();

ws_mngr_.register_diagnostics_consumer(this);
ws_mngr_.set_message_consumer(this);
ws_mngr_.set_request_interface(this);
ws_mngr.register_diagnostics_consumer(this);
ws_mngr.set_message_consumer(this);
ws_mngr.set_request_interface(this);

ws_mngr_.register_parsing_metadata_consumer(this);
ws_mngr.register_parsing_metadata_consumer(this);
}

void server::consume_parsing_metadata(
Expand Down
Loading

0 comments on commit 98da01d

Please sign in to comment.