Fixed test case with template class sequence diagram

This commit is contained in:
Bartek Kryza
2022-11-13 14:29:32 +01:00
parent a1e447966d
commit f3aec40b2a
5 changed files with 15 additions and 30 deletions

View File

@@ -90,13 +90,13 @@ void generator::generate_activity(const activity &a, std::ostream &ostr) const
ostr << "activate " << to.value().alias() << std::endl;
if (m_model.sequences.find(m.to) != m_model.sequences.end()) {
LOG_DBG("Creating activity {} --> {} - missing sequence {}",
m.from, m.to, m.to);
LOG_DBG("Creating activity {} --> {} - missing sequence {}", m.from,
m.to, m.to);
generate_activity(m_model.sequences[m.to], ostr);
}
else
LOG_DBG("Skipping activity {} --> {} - missing sequence {}",
m.from, m.to, m.to);
LOG_DBG("Skipping activity {} --> {} - missing sequence {}", m.from,
m.to, m.to);
generate_return(m, ostr);
@@ -159,8 +159,6 @@ void generator::generate(std::ostream &ostr) const
{
m_model.print();
ostr << "@startuml" << std::endl;
generate_plantuml_directives(ostr, m_config.puml().before);

View File

@@ -26,9 +26,6 @@
namespace clanguml::sequence_diagram::model {
struct activity {
// std::uint_least64_t from_id;
// std::string from_name;
// std::string from_method_name;
common::model::diagram_element::id_t from;
std::vector<message> messages;
};

View File

@@ -28,10 +28,7 @@ namespace clanguml::sequence_diagram::model {
struct message {
message()
: from{}
// , from_method_name{}
// , from_name{}
, to{}
// , to_name{}
, message_name{}
, return_type{}
, line{}
@@ -41,19 +38,6 @@ struct message {
common::model::message_t type;
common::model::diagram_element::id_t from;
common::model::diagram_element::id_t to;
//
// /// Source participant id
// std::uint_least64_t from;
// std::string from_method_name;
//
// std::string from_name;
// // std::uint_least64_t from_usr{};
//
// /// Target participant id
// std::uint_least64_t to;
// std::string to_name;
//
// // std::int64_t to_usr{};
std::string message_name;

View File

@@ -223,8 +223,13 @@ bool translation_unit_visitor::VisitCXXMethodDecl(clang::CXXMethodDecl *m)
diagram().participants.at(m_ptr->class_id())->full_name_no_ns() +
"::" + m->getNameAsString());
m_ptr->set_id(
common::to_id(m_ptr->full_name(false) + "::" + m->getNameAsString()));
m_ptr->set_id(common::to_id(
diagram().participants.at(m_ptr->class_id())->full_name(false) +
"::" + m->getNameAsString()));
LOG_DBG("Set id {} for method name {}", m_ptr->id(),
diagram().participants.at(m_ptr->class_id())->full_name(false) +
"::" + m->getNameAsString());
call_expression_context_.update(m);
@@ -396,6 +401,9 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
m.return_type = method_call_expr->getCallReturnType(current_ast_context)
.getAsString();
LOG_DBG("Set callee method id {} for method name {}", m.to,
method_decl->getQualifiedNameAsString());
if (get_ast_local_id(callee_decl->getID()))
diagram().add_active_participant(
get_ast_local_id(callee_decl->getID()).value());

View File

@@ -34,12 +34,10 @@ TEST_CASE("t20005", "[test-case][sequence]")
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist
REQUIRE_THAT(puml, HasCall(_A("C<T>"), _A("B<T>"), "b"));
REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
}