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; ostr << "activate " << to.value().alias() << std::endl;
if (m_model.sequences.find(m.to) != m_model.sequences.end()) { if (m_model.sequences.find(m.to) != m_model.sequences.end()) {
LOG_DBG("Creating activity {} --> {} - missing sequence {}", LOG_DBG("Creating activity {} --> {} - missing sequence {}", m.from,
m.from, m.to, m.to); m.to, m.to);
generate_activity(m_model.sequences[m.to], ostr); generate_activity(m_model.sequences[m.to], ostr);
} }
else else
LOG_DBG("Skipping activity {} --> {} - missing sequence {}", LOG_DBG("Skipping activity {} --> {} - missing sequence {}", m.from,
m.from, m.to, m.to); m.to, m.to);
generate_return(m, ostr); generate_return(m, ostr);
@@ -159,8 +159,6 @@ void generator::generate(std::ostream &ostr) const
{ {
m_model.print(); m_model.print();
ostr << "@startuml" << std::endl; ostr << "@startuml" << std::endl;
generate_plantuml_directives(ostr, m_config.puml().before); generate_plantuml_directives(ostr, m_config.puml().before);
@@ -169,7 +167,7 @@ void generator::generate(std::ostream &ostr) const
if (sf.location_type == source_location::location_t::function) { if (sf.location_type == source_location::location_t::function) {
std::int64_t start_from; std::int64_t start_from;
for (const auto &[k, v] : m_model.sequences) { for (const auto &[k, v] : m_model.sequences) {
const auto& caller = *m_model.participants.at(v.from); const auto &caller = *m_model.participants.at(v.from);
std::string vfrom = caller.full_name(false); std::string vfrom = caller.full_name(false);
if (vfrom == sf.location) { if (vfrom == sf.location) {
LOG_DBG("Found sequence diagram start point: {}", k); LOG_DBG("Found sequence diagram start point: {}", k);

View File

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

View File

@@ -28,10 +28,7 @@ namespace clanguml::sequence_diagram::model {
struct message { struct message {
message() message()
: from{} : from{}
// , from_method_name{}
// , from_name{}
, to{} , to{}
// , to_name{}
, message_name{} , message_name{}
, return_type{} , return_type{}
, line{} , line{}
@@ -41,19 +38,6 @@ struct message {
common::model::message_t type; common::model::message_t type;
common::model::diagram_element::id_t from; common::model::diagram_element::id_t from;
common::model::diagram_element::id_t to; 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; 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() + diagram().participants.at(m_ptr->class_id())->full_name_no_ns() +
"::" + m->getNameAsString()); "::" + m->getNameAsString());
m_ptr->set_id( m_ptr->set_id(common::to_id(
common::to_id(m_ptr->full_name(false) + "::" + m->getNameAsString())); 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); 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) m.return_type = method_call_expr->getCallReturnType(current_ast_context)
.getAsString(); .getAsString();
LOG_DBG("Set callee method id {} for method name {}", m.to,
method_decl->getQualifiedNameAsString());
if (get_ast_local_id(callee_decl->getID())) if (get_ast_local_id(callee_decl->getID()))
diagram().add_active_participant( diagram().add_active_participant(
get_ast_local_id(callee_decl->getID()).value()); 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, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n")); REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist // Check if all calls exist
REQUIRE_THAT(puml, HasCall(_A("C<T>"), _A("B<T>"), "b")); REQUIRE_THAT(puml, HasCall(_A("C<T>"), _A("B<T>"), "b"));
REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a")); REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a"));
save_puml( save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml); "./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
} }