Fixed handling of elements filter in sequence diagrams (#248)
This commit is contained in:
@@ -280,10 +280,12 @@ void generator<C, D>::generate(std::ostream &ostr) const
|
||||
|
||||
generate_title(ostr);
|
||||
|
||||
// Generate PlantUML directives before auto generated content
|
||||
generate_plantuml_directives(ostr, config.puml().before);
|
||||
|
||||
generate_diagram(ostr);
|
||||
|
||||
// Generate PlantUML directives after auto generated content
|
||||
generate_plantuml_directives(ostr, config.puml().after);
|
||||
|
||||
generate_metadata(ostr);
|
||||
|
||||
@@ -346,6 +346,35 @@ tvl::value_t element_filter::match(const diagram &d, const element &e) const
|
||||
});
|
||||
}
|
||||
|
||||
tvl::value_t element_filter::match(
|
||||
const diagram &d, const sequence_diagram::model::participant &p) const
|
||||
{
|
||||
using sequence_diagram::model::method;
|
||||
using sequence_diagram::model::participant;
|
||||
|
||||
if (d.type() != diagram_t::kSequence)
|
||||
return {};
|
||||
|
||||
const auto &sequence_model =
|
||||
dynamic_cast<const sequence_diagram::model::diagram &>(d);
|
||||
return tvl::any_of(elements_.begin(), elements_.end(),
|
||||
[&sequence_model, &p](const auto &el) {
|
||||
if (p.type_name() == "method") {
|
||||
|
||||
const auto &m = dynamic_cast<const method &>(p);
|
||||
const auto class_id = m.class_id();
|
||||
const auto &class_participant =
|
||||
sequence_model.get_participant<participant>(class_id)
|
||||
.value();
|
||||
|
||||
return el == p.full_name(false) ||
|
||||
el == class_participant.full_name(false);
|
||||
}
|
||||
|
||||
return el == p.full_name(false);
|
||||
});
|
||||
}
|
||||
|
||||
element_type_filter::element_type_filter(
|
||||
filter_t type, std::vector<std::string> element_types)
|
||||
: filter_visitor{type}
|
||||
|
||||
@@ -180,6 +180,9 @@ struct element_filter : public filter_visitor {
|
||||
|
||||
tvl::value_t match(const diagram &d, const element &e) const override;
|
||||
|
||||
tvl::value_t match(const diagram &d,
|
||||
const sequence_diagram::model::participant &p) const override;
|
||||
|
||||
private:
|
||||
std::vector<common::string_or_regex> elements_;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ std::string render_participant_name(std::string name)
|
||||
|
||||
std::string render_message_text(std::string text)
|
||||
{
|
||||
util::replace_all(text, ";", "#59;");
|
||||
util::replace_all(text, ";", ";");
|
||||
|
||||
return text;
|
||||
}
|
||||
@@ -481,6 +481,12 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
if (from_activity_id == 0 || to_activity_id == 0)
|
||||
continue;
|
||||
|
||||
if (model().participants().count(from_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
if (model().participants().count(to_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
auto message_chains_unique = model().get_all_from_to_message_chains(
|
||||
from_activity_id, to_activity_id);
|
||||
|
||||
@@ -522,6 +528,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
for (const auto &mc : message_chains_unique) {
|
||||
const auto from_activity_id = mc.front().from();
|
||||
|
||||
if (model().participants().count(from_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
const auto &from =
|
||||
model().get_participant<model::function>(from_activity_id);
|
||||
|
||||
@@ -547,6 +556,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
if (sf.location_type == location_t::function) {
|
||||
common::id_t start_from{0};
|
||||
for (const auto &[k, v] : model().sequences()) {
|
||||
if (model().participants().count(v.from()) == 0)
|
||||
continue;
|
||||
|
||||
const auto &caller = *model().participants().at(v.from());
|
||||
std::string vfrom = caller.full_name(false);
|
||||
if (vfrom == sf.location) {
|
||||
@@ -566,6 +578,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
// Use this to break out of recurrent loops
|
||||
std::vector<common::id_t> visited_participants;
|
||||
|
||||
if (model().participants().count(start_from) == 0)
|
||||
continue;
|
||||
|
||||
const auto &from =
|
||||
model().get_participant<model::function>(start_from);
|
||||
|
||||
|
||||
@@ -483,6 +483,12 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
if (from_activity_id == 0 || to_activity_id == 0)
|
||||
continue;
|
||||
|
||||
if (model().participants().count(from_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
if (model().participants().count(to_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
auto message_chains_unique = model().get_all_from_to_message_chains(
|
||||
from_activity_id, to_activity_id);
|
||||
|
||||
@@ -530,6 +536,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
|
||||
const auto from_activity_id = mc.front().from();
|
||||
|
||||
if (model().participants().count(from_activity_id) == 0)
|
||||
continue;
|
||||
|
||||
const auto &from =
|
||||
model().get_participant<model::function>(from_activity_id);
|
||||
|
||||
@@ -553,6 +562,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
if (sf.location_type == location_t::function) {
|
||||
common::id_t start_from{0};
|
||||
for (const auto &[k, v] : model().sequences()) {
|
||||
if (model().participants().count(v.from()) == 0)
|
||||
continue;
|
||||
|
||||
const auto &caller = *model().participants().at(v.from());
|
||||
std::string vfrom = caller.full_name(false);
|
||||
if (vfrom == sf.location) {
|
||||
@@ -569,6 +581,9 @@ void generator::generate_diagram(std::ostream &ostr) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (model().participants().count(start_from) == 0)
|
||||
continue;
|
||||
|
||||
// Use this to break out of recurrent loops
|
||||
std::vector<common::id_t> visited_participants;
|
||||
|
||||
|
||||
@@ -413,6 +413,8 @@ void diagram::print() const
|
||||
|
||||
LOG_TRACE(" --- Activities ---");
|
||||
for (const auto &[from_id, act] : sequences_) {
|
||||
if (participants_.count(from_id) == 0)
|
||||
continue;
|
||||
|
||||
LOG_TRACE("Sequence id={}:", from_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user