Fixed test case with template class sequence diagram
This commit is contained in:
@@ -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);
|
||||
@@ -169,7 +167,7 @@ void generator::generate(std::ostream &ostr) const
|
||||
if (sf.location_type == source_location::location_t::function) {
|
||||
std::int64_t start_from;
|
||||
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);
|
||||
if (vfrom == sf.location) {
|
||||
LOG_DBG("Found sequence diagram start point: {}", k);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user