Skip to content

Commit

Permalink
fix: Implicit *NOPROC* processor group
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimosinger authored Apr 18, 2023
1 parent d57895e commit 2aa82d1
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 219 deletions.
4 changes: 4 additions & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- Configuration request sent before initialization is done
- VSCode enters an infinite loop of opening and closing files
- "pgm_conf.json not found" prompt shows up even when `.bridge.json` exists
- `.bridge.json` is not reparsed when changed

#### Changed
- Programs assigned to "\*NOPROC\*" processor group no longer need its definition in pgm_conf.json

## [1.7.0](https://github.com/eclipse-che4z/che-che4z-lsp-for-hlasm/compare/1.6.0...1.7.0) (2023-03-08)

Expand Down
19 changes: 13 additions & 6 deletions parser_library/src/diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2547,6 +2547,17 @@ diagnostic_op diagnostic_op::error_S0012(const range& range)
return diagnostic_op(diagnostic_severity::error, "S0012", "Right parenthesis has no left match", range);
}

namespace {
std::string get_not_defined_proc_group_msg(std::string_view config_file, std::string_view pgroup)
{
return concat("The ",
config_file,
" file refers to a processor group \"",
pgroup,
"\", that is not defined in proc_grps.json");
}
} // namespace

diagnostic_s diagnostic_s::error_W0001(const utils::resource::resource_location& file_name)
{
return diagnostic_s(file_name.get_uri(),
Expand Down Expand Up @@ -2586,9 +2597,7 @@ diagnostic_s diagnostic_s::error_W0004(const utils::resource::resource_location&
{},
diagnostic_severity::warning,
"W0004",
concat("The configuration file pgm_conf refers to a processor group (",
pgroup,
"), that is not defined in proc_grps"),
get_not_defined_proc_group_msg("pgm_conf.json", pgroup),
{},
diagnostic_tag::none);
}
Expand Down Expand Up @@ -2653,9 +2662,7 @@ diagnostic_s diagnostic_s::error_B4G002(const utils::resource::resource_location
{},
diagnostic_severity::warning,
"B4G002",
concat("The .bridge.json file refers to a processor group \"",
grp_name,
"\", that is not defined in proc_grps.json"),
get_not_defined_proc_group_msg(".bridge.json", grp_name),
{},
diagnostic_tag::none);
}
Expand Down
52 changes: 26 additions & 26 deletions parser_library/src/workspaces/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct workspace_parse_lib_provider final : public parse_lib_provider

workspace_parse_lib_provider(workspace& ws, workspace::processor_file_compoments& pfc)
: ws(ws)
, libraries(ws.get_proc_grp_by_program(pfc.m_file->get_location()).libraries())
, libraries(ws.get_proc_grp(pfc.m_file->get_location()).libraries())
, pfc(pfc)
{}

Expand Down Expand Up @@ -464,7 +464,7 @@ void workspace::retrieve_fade_messages(std::vector<fade_message_s>& fms) const

bool take_also_opencode_hc = true;
if (const auto& pf_rl = proc_file_component.m_file->get_location();
&get_proc_grp_by_program(pf_rl) == &implicit_proc_grp && is_dependency(pf_rl))
&get_proc_grp(pf_rl) == &implicit_proc_grp && is_dependency(pf_rl))
take_also_opencode_hc = false;

for (const auto& [__, opened_file_rl] : opened_files_uris)
Expand Down Expand Up @@ -637,7 +637,7 @@ workspace_file_info workspace::parse_successful(processor_file_compoments& comp,
comp.m_collect_perf_metrics = false; // only on open/first parsing
m_parsing_pending.erase(comp.m_file->get_location());

const processor_group& grp = get_proc_grp_by_program(comp.m_file->get_location());
const processor_group& grp = get_proc_grp(comp.m_file->get_location());
ws_file_info.processor_group_found = &grp != &implicit_proc_grp;
if (&grp == &implicit_proc_grp
&& (int64_t)comp.m_last_results->opencode_diagnostics.size() > get_config().diag_supress_limit)
Expand Down Expand Up @@ -845,12 +845,15 @@ bool workspace::settings_updated()
return updated;
}

const processor_group& workspace::get_proc_grp_by_program(const resource_location& file) const
const processor_group& workspace::get_proc_grp(const resource_location& file) const
{
if (const auto* pgm = m_configuration.get_program(file); pgm)
return m_configuration.get_proc_grp_by_program(*pgm);
else
return implicit_proc_grp;
{
if (auto proc_grp = m_configuration.get_proc_grp_by_program(*pgm); proc_grp)
return *proc_grp;
}

return implicit_proc_grp;
}

const processor_group& workspace::get_proc_grp(const proc_grp_id& id) const { return m_configuration.get_proc_grp(id); }
Expand Down Expand Up @@ -934,7 +937,6 @@ std::vector<std::pair<std::string, size_t>> generate_instruction_suggestions(
return process(suggestion);
}
}

} // namespace

std::vector<std::pair<std::string, size_t>> workspace::make_opcode_suggestion(
Expand All @@ -945,19 +947,18 @@ std::vector<std::pair<std::string, size_t>> workspace::make_opcode_suggestion(
c = static_cast<char>(std::toupper((unsigned char)c));

std::vector<std::pair<std::string, size_t>> result;

asm_option opts;
if (const auto* pgm = m_configuration.get_program(file); pgm)
{
auto& proc_grp = m_configuration.get_proc_grp_by_program(*pgm);
proc_grp.apply_options_to(opts);
pgm->asm_opts.apply_options_to(opts);

result = proc_grp.suggest(opcode, extended);
}
if (auto pgm = m_configuration.get_program(file); !pgm)
implicit_proc_grp.apply_options_to(opts);
else
{
implicit_proc_grp.apply_options_to(opts);
if (auto proc_grp = m_configuration.get_proc_grp_by_program(*pgm); proc_grp)
{
proc_grp->apply_options_to(opts);
result = proc_grp->suggest(opcode, extended);
}
pgm->asm_opts.apply_options_to(opts);
}

for (auto&& s : generate_instruction_suggestions(opcode, opts.instr_set, extended))
Expand Down Expand Up @@ -1026,22 +1027,21 @@ bool workspace::is_dependency(const resource_location& file_location) const

std::vector<std::shared_ptr<library>> workspace::get_libraries(const resource_location& file_location) const
{
return get_proc_grp_by_program(file_location).libraries();
return get_proc_grp(file_location).libraries();
}

asm_option workspace::get_asm_options(const resource_location& file_location) const
{
asm_option result;

const auto* pgm = m_configuration.get_program(file_location);
if (pgm)
{
m_configuration.get_proc_grp_by_program(*pgm).apply_options_to(result);
pgm->asm_opts.apply_options_to(result);
}
auto pgm = m_configuration.get_program(file_location);
if (!pgm)
implicit_proc_grp.apply_options_to(result);
else
{
implicit_proc_grp.apply_options_to(result);
if (auto proc_grp = m_configuration.get_proc_grp_by_program(*pgm); proc_grp)
proc_grp->apply_options_to(result);
pgm->asm_opts.apply_options_to(result);
}

resource_location relative_to_location(file_location.lexically_relative(location_).lexically_normal());
Expand All @@ -1057,7 +1057,7 @@ asm_option workspace::get_asm_options(const resource_location& file_location) co

std::vector<preprocessor_options> workspace::get_preprocessor_options(const resource_location& file_location) const
{
return get_proc_grp_by_program(file_location).preprocessors();
return get_proc_grp(file_location).preprocessors();
}

workspace::processor_file_compoments::processor_file_compoments(std::shared_ptr<file> file)
Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/workspaces/workspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class workspace : public diagnosable_impl

bool settings_updated();

const processor_group& get_proc_grp_by_program(const resource_location& file) const;
const processor_group& get_proc_grp(const resource_location& file) const;
const processor_group& get_proc_grp(const proc_grp_id& id) const; // test only

std::vector<std::pair<std::string, size_t>> make_opcode_suggestion(
Expand Down
Loading

0 comments on commit 2aa82d1

Please sign in to comment.