diff --git a/src/class_diagram/visitor/translation_unit_visitor.cc b/src/class_diagram/visitor/translation_unit_visitor.cc index 198f4b97..7aa8ee10 100644 --- a/src/class_diagram/visitor/translation_unit_visitor.cc +++ b/src/class_diagram/visitor/translation_unit_visitor.cc @@ -1852,8 +1852,11 @@ void translation_unit_visitor::process_field( if (template_field_type != nullptr && !field_type_is_template_template_parameter) { // Build the template instantiation for the field type - auto template_specialization_ptr = - tbuilder().build(&field_declaration, *template_field_type, {&c}); + auto template_specialization_ptr = tbuilder().build( + field_type->getAs() + ->getTemplateName() + .getAsTemplateDecl(), + *template_field_type, {&c}); if (!field.skip_relationship() && template_specialization_ptr) { const auto &template_specialization = *template_specialization_ptr; @@ -1862,14 +1865,14 @@ void translation_unit_visitor::process_field( // current diagram. Even if the top level template type for // this instantiation should not be part of the diagram, e.g. // it's a std::vector<>, it's nested types might be added - bool add_template_instantiation_to_diargam{false}; + bool add_template_instantiation_to_diagram{false}; if (diagram().should_include( template_specialization.full_name(false))) { found_relationships_t::value_type r{ template_specialization.id(), relationship_hint}; - add_template_instantiation_to_diargam = true; + add_template_instantiation_to_diagram = true; // If the template instantiation for the build type has been // added as aggregation, skip its nested templates @@ -1910,7 +1913,7 @@ void translation_unit_visitor::process_field( // Add the template instantiation object to the diagram if it // matches the include pattern - if (add_template_instantiation_to_diargam) + if (add_template_instantiation_to_diagram) diagram().add_class(std::move(template_specialization_ptr)); } } diff --git a/tests/t00014/t00014.cc b/tests/t00014/t00014.cc index 8b01e1c1..4a2e6f09 100644 --- a/tests/t00014/t00014.cc +++ b/tests/t00014/t00014.cc @@ -36,6 +36,7 @@ using PairPairBA = std::pair>, long>; template using VectorPtr = std::unique_ptr>; template using APtr = std::unique_ptr>; template using ASharedPtr = std::shared_ptr>; + template using AAPtr = std::unique_ptr, A>>; @@ -52,7 +53,7 @@ using ACharString = AString; using AStringString = AString; using BStringString = AStringString; -class R { +template class R { using AWCharString = AString; PairPairBA bapair; @@ -65,6 +66,7 @@ class R { AIntString intstring; AStringString stringstring; BStringString bstringstring; + AAPtr atfloat; protected: BVector bs; diff --git a/tests/t00014/test_case.h b/tests/t00014/test_case.h index 78bcd34b..65125aa9 100644 --- a/tests/t00014/test_case.h +++ b/tests/t00014/test_case.h @@ -53,6 +53,7 @@ TEST_CASE("t00014", "[test-case][class]") REQUIRE_THAT(puml, IsClassTemplate("A", "std::string,std::string")); REQUIRE_THAT(puml, IsClassTemplate("A", "char,std::string")); REQUIRE_THAT(puml, IsClass(_A("B"))); + REQUIRE_THAT(puml, IsClassTemplate("R", "T")); REQUIRE_THAT(puml, IsField("bapair", "PairPairBA")); REQUIRE_THAT(puml, IsField("abool", "APtr")); @@ -62,6 +63,8 @@ TEST_CASE("t00014", "[test-case][class]") puml, IsField("boolstring", "A")); REQUIRE_THAT( puml, IsField("floatstring", "AStringPtr")); + REQUIRE_THAT(puml, IsField("atfloat", "AAPtr")); + REQUIRE_THAT(puml, IsField("intstring", "AIntString")); REQUIRE_THAT(puml, IsField("stringstring", "AStringString")); REQUIRE_THAT(puml, IsField("bstringstring", "BStringString")); @@ -114,23 +117,29 @@ TEST_CASE("t00014", "[test-case][class]") IsInstantiation( _A("A"), _A("A>"))); - REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+vps")); - REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "-bapair")); - REQUIRE_THAT( - puml, IsAggregation(_A("R"), _A("A"), "-aboolfloat")); - REQUIRE_THAT( - puml, IsAggregation(_A("R"), _A("A"), "-bapair")); - REQUIRE_THAT( - puml, IsAggregation(_A("R"), _A("A"), "-aboolfloat")); - REQUIRE_THAT( - puml, IsAssociation(_A("R"), _A("A"), "-afloat")); + REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+vps")); + REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "-bapair")); REQUIRE_THAT(puml, - IsAggregation(_A("R"), _A("A"), "-boolstring")); + IsAggregation(_A("R"), _A("A"), "-aboolfloat")); + REQUIRE_THAT( + puml, IsAggregation(_A("R"), _A("A"), "-bapair")); REQUIRE_THAT(puml, - IsAggregation(_A("R"), _A("A>"), - "-floatstring")); - REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A"))); - REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A"))); + IsAggregation(_A("R"), _A("A"), "-aboolfloat")); + REQUIRE_THAT( + puml, IsAggregation(_A("R"), _A("A"), "-atfloat")); + REQUIRE_THAT( + puml, IsAggregation(_A("R"), _A("A"), "-atfloat")); + REQUIRE_THAT( + puml, IsAssociation(_A("R"), _A("A"), "-afloat")); + REQUIRE_THAT(puml, + IsAggregation( + _A("R"), _A("A"), "-boolstring")); + REQUIRE_THAT(puml, + IsAggregation(_A("R"), + _A("A>"), "-floatstring")); + REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A"))); + REQUIRE_THAT( + puml, IsDependency(_A("R"), _A("A"))); save_puml( config.output_directory() + "/" + diagram->name + ".puml", puml);