Added highlight of calls within condition statements of if/else blocks
This commit is contained in:
@@ -79,14 +79,25 @@ void generator::generate_call(const message &m, std::ostream &ostr) const
|
||||
const std::string to_alias = generate_alias(to.value());
|
||||
|
||||
ostr << from_alias << " "
|
||||
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " "
|
||||
<< to_alias;
|
||||
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " ";
|
||||
|
||||
ostr << to_alias;
|
||||
|
||||
if (m_config.generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(ostr, m);
|
||||
}
|
||||
|
||||
ostr << " : " << message << std::endl;
|
||||
ostr << " : ";
|
||||
|
||||
if (m.message_scope() == common::model::message_scope_t::kCondition)
|
||||
ostr << "**[**";
|
||||
|
||||
ostr << message;
|
||||
|
||||
if (m.message_scope() == common::model::message_scope_t::kCondition)
|
||||
ostr << "**]**";
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
LOG_DBG("Generated call '{}' from {} [{}] to {} [{}]", message, from,
|
||||
m.from(), to, m.to());
|
||||
|
||||
@@ -50,4 +50,11 @@ void message::set_return_type(std::string t) { return_type_ = std::move(t); }
|
||||
|
||||
const std::string &message::return_type() const { return return_type_; }
|
||||
|
||||
void message::set_message_scope(common::model::message_scope_t scope)
|
||||
{
|
||||
scope_ = scope;
|
||||
}
|
||||
|
||||
common::model::message_scope_t message::message_scope() const { return scope_; }
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
void set_return_type(std::string t);
|
||||
const std::string &return_type() const;
|
||||
|
||||
void set_message_scope(common::model::message_scope_t scope);
|
||||
common::model::message_scope_t message_scope() const;
|
||||
|
||||
private:
|
||||
common::model::message_t type_{common::model::message_t::kNone};
|
||||
|
||||
@@ -54,6 +57,9 @@ private:
|
||||
|
||||
common::model::diagram_element::id_t to_{};
|
||||
|
||||
common::model::message_scope_t scope_{
|
||||
common::model::message_scope_t::kNormal};
|
||||
|
||||
// This is only for better verbose messages, we cannot rely on this
|
||||
// always
|
||||
std::string message_name_{};
|
||||
|
||||
@@ -732,6 +732,7 @@ bool translation_unit_visitor::TraverseCXXForRangeStmt(
|
||||
|
||||
bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
||||
{
|
||||
using clanguml::common::model::message_scope_t;
|
||||
using clanguml::common::model::message_t;
|
||||
using clanguml::common::model::namespace_;
|
||||
using clanguml::sequence_diagram::model::activity;
|
||||
@@ -774,6 +775,20 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
||||
}
|
||||
}
|
||||
|
||||
if (context().current_ifstmt()) {
|
||||
if (common::is_subexpr_of(
|
||||
context().current_ifstmt()->getCond(), expr)) {
|
||||
m.set_message_scope(common::model::message_scope_t::kCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (context().current_elseifstmt()) {
|
||||
if (common::is_subexpr_of(
|
||||
context().current_elseifstmt()->getCond(), expr)) {
|
||||
m.set_message_scope(common::model::message_scope_t::kCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto *operator_call_expr =
|
||||
clang::dyn_cast_or_null<clang::CXXOperatorCallExpr>(expr);
|
||||
operator_call_expr != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user