Added sequence diagram model cleanup step to remove empty block statements

This commit is contained in:
Bartek Kryza
2023-07-02 17:56:15 +02:00
parent 9ada158828
commit ed88fcd39d
15 changed files with 160 additions and 46 deletions

View File

@@ -212,6 +212,15 @@ public:
*/
bool should_include(const sequence_diagram::model::participant &p) const;
/**
* @brief Once the diagram is complete, run any final processing.
*
* This method should be overriden by specific diagram models to do some
* final tasks like cleaning up the model (e.g. some filters only work
* on completed diagrams).
*/
void finalize() override;
private:
/**
* This method checks the last messages in sequence (current_messages),
@@ -233,6 +242,27 @@ private:
common::model::message_t statement_begin,
std::vector<message> &current_messages) const;
bool is_begin_block_message(common::model::message_t mt)
{
using common::model::message_t;
static std::set<message_t> block_begin_types{message_t::kIf,
message_t::kWhile, message_t::kDo, message_t::kFor, message_t::kTry,
message_t::kSwitch, message_t::kConditional};
return block_begin_types.count(mt) > 0;
};
bool is_end_block_message(common::model::message_t mt)
{
using common::model::message_t;
static std::set<message_t> block_end_types{message_t::kIfEnd,
message_t::kWhileEnd, message_t::kDoEnd, message_t::kForEnd,
message_t::kTryEnd, message_t::kSwitchEnd,
message_t::kConditionalEnd};
return block_end_types.count(mt) > 0;
};
bool started_{false};
std::map<common::model::diagram_element::id_t, activity> sequences_;