Skip to content

Commit

Permalink
refactor: Cleanup headers
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Aug 14, 2023
1 parent ad1c27c commit c9af94a
Show file tree
Hide file tree
Showing 129 changed files with 1,700 additions and 1,555 deletions.
23 changes: 15 additions & 8 deletions language_server/test/response_provider_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ namespace hlasm_plugin::language_server {
class response_provider_mock : public response_provider
{
public:
MOCK_METHOD4(request,
void(const std::string& requested_method,
MOCK_METHOD(void,
request,
(const std::string& requested_method,
const nlohmann::json& args,
std::function<void(const nlohmann::json& params)> handler,
std::function<void(int, const char*)> error_handler));
MOCK_METHOD3(respond, void(const request_id& id, const std::string& requested_method, const nlohmann::json& args));
MOCK_METHOD2(notify, void(const std::string& method, const nlohmann::json& args));
MOCK_METHOD5(respond_error,
void(const request_id& id,
std::function<void(int, const char*)> error_handler),
(override));
MOCK_METHOD(void,
respond,
(const request_id& id, const std::string& requested_method, const nlohmann::json& args),
(override));
MOCK_METHOD(void, notify, (const std::string& method, const nlohmann::json& args), (override));
MOCK_METHOD(void,
respond_error,
(const request_id& id,
const std::string& requested_method,
int err_code,
const std::string& err_message,
const nlohmann::json& error));
const nlohmann::json& error),
(override));
MOCK_METHOD(void, register_cancellable_request, (const request_id&, request_invalidator), (override));
};

Expand Down
22 changes: 13 additions & 9 deletions language_server/test/ws_mngr_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ using namespace parser_library;
class ws_mngr_mock : public workspace_manager
{
public:
MOCK_METHOD2(add_workspace, void(const char* name, const char* uri));
MOCK_METHOD1(remove_workspace, void(const char* uri));

MOCK_METHOD4(
did_open_file, void(const char* document_uri, version_t version, const char* text, size_t text_length));
MOCK_METHOD4(did_change_file,
void(const char* document_uri, version_t version, const document_change* changes, size_t ch_size));
MOCK_METHOD1(did_close_file, void(const char* document_uri));
MOCK_METHOD(void, add_workspace, (const char* name, const char* uri), (override));
MOCK_METHOD(void, remove_workspace, (const char* uri), (override));

MOCK_METHOD(void,
did_open_file,
(const char* document_uri, version_t version, const char* text, size_t text_length),
(override));
MOCK_METHOD(void,
did_change_file,
(const char* document_uri, version_t version, const document_change* changes, size_t ch_size),
(override));
MOCK_METHOD(void, did_close_file, (const char* document_uri), (override));
MOCK_METHOD(void, did_change_watched_files, (sequence<fs_change> changes), (override));

MOCK_METHOD(void,
Expand Down Expand Up @@ -73,7 +77,7 @@ class ws_mngr_mock : public workspace_manager
MOCK_METHOD(void, set_message_consumer, (message_consumer * consumer), (override));
MOCK_METHOD(void, set_request_interface, (workspace_manager_requests * requests), (override));

MOCK_METHOD(continuous_sequence<char>, get_virtual_file_content, (unsigned long long id), (const override));
MOCK_METHOD(continuous_sequence<char>, get_virtual_file_content, (unsigned long long id), (const, override));
MOCK_METHOD(void, toggle_advisory_configuration_diagnostics, (), (override));


Expand Down
4 changes: 3 additions & 1 deletion parser_library/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ target_sources(parser_library PRIVATE
diagnosable_impl.h
diagnostic.cpp
diagnostic.h
diagnostic_consumer.h
diagnostic_adder.h
diagnostic_consumer.h
diagnostic_tools.h
diagnostic_tools.cpp
document.cpp
document.h
ebcdic_encoding.cpp
Expand Down
98 changes: 61 additions & 37 deletions parser_library/src/analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

#include "analyzer.h"

#include "hlasmparser_multiline.h"
#include "lsp/lsp_context.h"
#include "processing/opencode_provider.h"
#include "processing/preprocessor.h"
#include "processing/processing_manager.h"
#include "semantics/source_info_processor.h"
#include "utils/task.h"

using namespace hlasm_plugin::parser_library;
using namespace hlasm_plugin::parser_library::lexing;
using namespace hlasm_plugin::parser_library::parsing;
using namespace hlasm_plugin::parser_library::workspaces;

using namespace hlasm_plugin::utils::resource;

analyzing_context& analyzer_options::get_context()
{
Expand Down Expand Up @@ -104,61 +105,84 @@ std::unique_ptr<processing::preprocessor> analyzer_options::get_preprocessor(pro
return std::make_unique<combined_preprocessor>(std::move(tmp));
}

struct analyzer::impl
{
impl(std::string_view text, analyzer_options&& opts, diagnosable_ctx& diag_consumer)
: ctx(std::move(opts.get_context()))
, src_proc(opts.collect_hl_info == collect_highlighting_info::yes)
, field_parser(ctx.hlasm_ctx.get())
, mngr(std::make_unique<processing::opencode_provider>(text,
ctx,
opts.get_lib_provider(),
mngr,
mngr,
src_proc,
diag_consumer,
opts.get_preprocessor(std::bind_front(&parse_lib_provider::get_library, &opts.get_lib_provider()),
diag_consumer,
src_proc),
opts.parsing_opencode == file_is_opencode::yes ? processing::opencode_provider_options { true, 10 }
: processing::opencode_provider_options {},
opts.vf_monitor,
vf_handles),
ctx,
opts.library_data,
opts.file_loc,
text,
opts.get_lib_provider(),
field_parser,
std::move(opts.fade_messages))
{}

analyzing_context ctx;

semantics::source_info_processor src_proc;

processing::statement_fields_parser field_parser;

std::vector<std::pair<virtual_file_handle, utils::resource::resource_location>> vf_handles;

processing::processing_manager mngr;
};

analyzer::analyzer(std::string_view text, analyzer_options opts)
: diagnosable_ctx(opts.get_hlasm_context())
, ctx_(std::move(opts.get_context()))
, src_proc_(opts.collect_hl_info == collect_highlighting_info::yes)
, field_parser_(ctx_.hlasm_ctx.get())
, mngr_(std::make_unique<processing::opencode_provider>(text,
ctx_,
opts.get_lib_provider(),
mngr_,
mngr_,
src_proc_,
*this,
opts.get_preprocessor(
std::bind_front(&parse_lib_provider::get_library, &opts.get_lib_provider()), *this, src_proc_),
opts.parsing_opencode == file_is_opencode::yes ? processing::opencode_provider_options { true, 10 }
: processing::opencode_provider_options {},
opts.vf_monitor,
vf_handles_),
ctx_,
opts.library_data,
opts.file_loc,
text,
opts.get_lib_provider(),
field_parser_,
std::move(opts.fade_messages))
, m_impl(std::make_unique<impl>(text, std::move(opts), *this))
{}

analyzing_context analyzer::context() const { return ctx_; }
analyzer::~analyzer() = default;

std::vector<std::pair<virtual_file_handle, resource_location>> analyzer::take_vf_handles()
{
return std::move(m_impl->vf_handles);
}

context::hlasm_context& analyzer::hlasm_ctx() { return *ctx_.hlasm_ctx; }
analyzing_context analyzer::context() const { return m_impl->ctx; }

parsing::hlasmparser_multiline& analyzer::parser() { return mngr_.opencode_parser(); }
context::hlasm_context& analyzer::hlasm_ctx() { return *m_impl->ctx.hlasm_ctx; }

size_t analyzer::debug_syntax_errors() { return mngr_.opencode_parser().getNumberOfSyntaxErrors(); }
parsing::hlasmparser_multiline& analyzer::parser() { return m_impl->mngr.opencode_parser(); }

lines_info analyzer::take_semantic_tokens() { return src_proc_.take_semantic_tokens(); }
semantics::lines_info analyzer::take_semantic_tokens() { return m_impl->src_proc.take_semantic_tokens(); }

void analyzer::analyze() { co_analyze().run(); }

hlasm_plugin::utils::task analyzer::co_analyze() &
{
co_await mngr_.co_step();
co_await m_impl->mngr.co_step();

src_proc_.finish();
m_impl->src_proc.finish();
}

void analyzer::collect_diags() const
{
collect_diags_from_child(mngr_);
collect_diags_from_child(field_parser_);
collect_diags_from_child(m_impl->mngr);
collect_diags_from_child(m_impl->field_parser);
}

const performance_metrics& analyzer::get_metrics() const { return ctx_.hlasm_ctx->metrics; }
const performance_metrics& analyzer::get_metrics() const { return m_impl->ctx.hlasm_ctx->metrics; }

void analyzer::register_stmt_analyzer(statement_analyzer* stmt_analyzer)
void analyzer::register_stmt_analyzer(processing::statement_analyzer* stmt_analyzer)
{
mngr_.register_stmt_analyzer(stmt_analyzer);
m_impl->mngr.register_stmt_analyzer(stmt_analyzer);
}
42 changes: 22 additions & 20 deletions parser_library/src/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,37 @@

#include "analyzing_context.h"
#include "compiler_options.h"
#include "context/hlasm_context.h"
#include "context/id_storage.h"
#include "diagnosable_ctx.h"
#include "fade_messages.h"
#include "preprocessor_options.h"
#include "processing/processing_format.h"
#include "processing/processing_manager.h"
#include "processing/statement_fields_parser.h"
#include "processing/preprocessor.h"
#include "protocol.h"
#include "semantics/source_info_processor.h"
#include "utils/resource_location.h"
#include "virtual_file_monitor.h"
#include "workspaces/parse_lib_provider.h"


namespace hlasm_plugin::utils {
class task;
} // namespace hlasm_plugin::utils

namespace hlasm_plugin::parser_library::context {
class hlasm_context;
} // namespace hlasm_plugin::parser_library::context

namespace hlasm_plugin::parser_library::parsing {
class hlasmparser_multiline;
} // namespace hlasm_plugin::parser_library::parsing

namespace hlasm_plugin::parser_library::processing {
class statement_analyzer;
} // namespace hlasm_plugin::parser_library::processing

namespace hlasm_plugin::parser_library::semantics {
class source_info_processor;
} // namespace hlasm_plugin::parser_library::semantics

namespace hlasm_plugin::parser_library {
struct fade_message_s;
class virtual_file_monitor;
class virtual_file_handle;

enum class collect_highlighting_info : bool
{
Expand Down Expand Up @@ -142,23 +149,19 @@ class analyzer_options
// this class analyzes provided text and produces diagnostics and highlighting info with respect to provided context
class analyzer : public diagnosable_ctx
{
analyzing_context ctx_;
struct impl;

semantics::source_info_processor src_proc_;

processing::statement_fields_parser field_parser_;

std::vector<std::pair<virtual_file_handle, utils::resource::resource_location>> vf_handles_;

processing::processing_manager mngr_;
std::unique_ptr<impl> m_impl;

public:
analyzer(std::string_view text, analyzer_options opts = {});
auto take_vf_handles() { return std::move(vf_handles_); }
~analyzer();

std::vector<std::pair<virtual_file_handle, utils::resource::resource_location>> take_vf_handles();
analyzing_context context() const;

context::hlasm_context& hlasm_ctx();
semantics::lines_info take_semantic_tokens();
std::vector<token_info> take_semantic_tokens();

void analyze();
[[nodiscard]] utils::task co_analyze() &;
Expand All @@ -169,7 +172,6 @@ class analyzer : public diagnosable_ctx
void register_stmt_analyzer(processing::statement_analyzer* stmt_analyzer);

parsing::hlasmparser_multiline& parser(); // for testing only
size_t debug_syntax_errors(); // for testing only
};

} // namespace hlasm_plugin::parser_library
Expand Down
2 changes: 2 additions & 0 deletions parser_library/src/checking/diagnostic_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#include "diagnostic_collector.h"

#include "context/hlasm_context.h"
#include "diagnosable_ctx.h"
#include "diagnostic_tools.h"

namespace hlasm_plugin::parser_library {

Expand Down
1 change: 1 addition & 0 deletions parser_library/src/context/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target_sources(parser_library PRIVATE
hlasm_context.h
hlasm_statement.cpp
hlasm_statement.h
id_index.h
id_storage.cpp
id_storage.h
instruction.cpp
Expand Down
1 change: 1 addition & 0 deletions parser_library/src/context/hlasm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "instruction.h"
#include "lexing/lexer.h"
#include "lexing/tools.h"
#include "ordinary_assembly/location_counter.h"
#include "using.h"
#include "utils/time.h"

Expand Down
Loading

0 comments on commit c9af94a

Please sign in to comment.