Added scope symbol in front of relationships
This commit is contained in:
@@ -258,7 +258,7 @@ public:
|
||||
<< m_model.to_alias(uns, ns_relative(uns, destination));
|
||||
|
||||
if (!r.label.empty())
|
||||
relstr << " : " << r.label;
|
||||
relstr << " : " << to_string(r.scope) << r.label;
|
||||
|
||||
relstr << std::endl;
|
||||
ostr << relstr.str();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace clanguml {
|
||||
namespace model {
|
||||
namespace class_diagram {
|
||||
|
||||
enum class scope_t { kPublic, kProtected, kPrivate };
|
||||
enum class scope_t { kPublic, kProtected, kPrivate, kNone };
|
||||
|
||||
enum class relationship_t {
|
||||
kNone,
|
||||
@@ -121,6 +121,7 @@ struct class_relationship {
|
||||
std::string cardinality_source;
|
||||
std::string cardinality_destination;
|
||||
std::string label;
|
||||
scope_t scope{scope_t::kNone};
|
||||
|
||||
friend bool operator==(
|
||||
const class_relationship &l, const class_relationship &r)
|
||||
|
||||
@@ -171,6 +171,7 @@ void tu_visitor::operator()(const cppast::cpp_entity &file)
|
||||
r.destination = tinst.base_template_usr;
|
||||
r.type = relationship_t::kInstantiation;
|
||||
r.label = "";
|
||||
r.scope = scope_t::kNone;
|
||||
tinst.add_relationship(std::move(r));
|
||||
|
||||
LOG_DBG("Created template instantiation: {}, {}, {}",
|
||||
@@ -206,6 +207,7 @@ void tu_visitor::process_enum_declaration(const cppast::cpp_enum &enm)
|
||||
containment.type = relationship_t::kContainment;
|
||||
containment.destination =
|
||||
cx::util::full_name(ctx.namespace_, cur.value());
|
||||
containment.scope = scope_t::kNone;
|
||||
e.relationships.emplace_back(std::move(containment));
|
||||
|
||||
LOG_DBG("Added relationship {} +-- {}", e.name,
|
||||
@@ -398,6 +400,7 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
|
||||
r.type = relationship_t::kInstantiation;
|
||||
r.label = "";
|
||||
r.destination = base_template_usr;
|
||||
r.scope = scope_t::kNone;
|
||||
c.add_relationship(std::move(r));
|
||||
}
|
||||
else {
|
||||
@@ -484,7 +487,7 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
|
||||
|
||||
void tu_visitor::process_field_with_template_instantiation(
|
||||
const cppast::cpp_member_variable &mv, const cppast::cpp_type &tr,
|
||||
class_ &c)
|
||||
class_ &c, cppast::cpp_access_specifier_kind as)
|
||||
{
|
||||
LOG_DBG("Processing field with template instatiation type {}",
|
||||
cppast::to_string(tr));
|
||||
@@ -527,6 +530,7 @@ void tu_visitor::process_field_with_template_instantiation(
|
||||
}
|
||||
r.type = relationship_t::kInstantiation;
|
||||
r.label = "";
|
||||
r.scope = scope_t::kNone;
|
||||
tinst.add_relationship(std::move(r));
|
||||
|
||||
class_relationship rr;
|
||||
@@ -537,9 +541,12 @@ void tu_visitor::process_field_with_template_instantiation(
|
||||
else
|
||||
rr.type = relationship_t::kAggregation;
|
||||
rr.label = mv.name();
|
||||
rr.scope = detail::cpp_access_specifier_to_scope(as);
|
||||
|
||||
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
||||
rr.destination, model::class_diagram::to_string(rr.type), c.usr,
|
||||
rr.label);
|
||||
|
||||
c.add_relationship(std::move(rr));
|
||||
|
||||
LOG_DBG("Created template instantiation: {}, {}", tinst.name,
|
||||
@@ -572,7 +579,7 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c,
|
||||
cppast::to_string(tr), mv.name());
|
||||
}
|
||||
else if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) {
|
||||
process_field_with_template_instantiation(mv, resolve_alias(tr), c);
|
||||
process_field_with_template_instantiation(mv, resolve_alias(tr), c, as);
|
||||
}
|
||||
else if (tr.kind() == cppast::cpp_type_kind::unexposed_t) {
|
||||
LOG_DBG(
|
||||
@@ -592,6 +599,7 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c,
|
||||
r.destination = type;
|
||||
r.type = relationship_type;
|
||||
r.label = m.name;
|
||||
r.scope = m.scope;
|
||||
|
||||
LOG_DBG("Adding field relationship {} {} {} : {}",
|
||||
r.destination, model::class_diagram::to_string(r.type),
|
||||
|
||||
@@ -165,7 +165,8 @@ public:
|
||||
|
||||
void process_field_with_template_instantiation(
|
||||
const cppast::cpp_member_variable &mv, const cppast::cpp_type &tr,
|
||||
clanguml::model::class_diagram::class_ &c);
|
||||
clanguml::model::class_diagram::class_ &c,
|
||||
cppast::cpp_access_specifier_kind as);
|
||||
|
||||
void process_static_field(const cppast::cpp_variable &mv,
|
||||
clanguml::model::class_diagram::class_ &c,
|
||||
|
||||
@@ -53,7 +53,7 @@ TEST_CASE("t00002", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, (IsMethod<Public, Abstract>("foo_a")));
|
||||
REQUIRE_THAT(puml, (IsMethod<Public, Abstract>("foo_c")));
|
||||
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("D"), _A("A"), "as"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("D"), _A("A"), "-as"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -61,17 +61,17 @@ TEST_CASE("t00005", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, (IsField<Public>("some_int_pointer", "int*")));
|
||||
REQUIRE_THAT(puml, (IsField<Public>("some_int_pointer_pointer", "int**")));
|
||||
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "d"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("E"), "e"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "g"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("H"), "h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "i"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("J"), "j"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("K"), "k"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "+a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "+b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "+c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "+d"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("E"), "+e"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "+f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "+g"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("H"), "+h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "+i"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("J"), "+j"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("K"), "+k"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -65,22 +65,22 @@ TEST_CASE("t00006", "[test-case][class]")
|
||||
REQUIRE_THAT(puml,
|
||||
IsInstantiation(_A("custom_container<T>"), _A("custom_container<E>")));
|
||||
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "d"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("custom_container<E>"), "e"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "g"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("H"), "h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "i"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("J"), "j"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("K"), "k"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("L"), "lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("M"), "lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("N"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NN"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NNN"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "+a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "+b"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("C"), "+c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "+d"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("custom_container<E>"), "+e"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "+f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "+g"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("H"), "+h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "+i"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("J"), "+j"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("K"), "+k"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("L"), "+lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("M"), "+lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("N"), "+ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NN"), "+ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NNN"), "+ns"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -50,9 +50,9 @@ TEST_CASE("t00007", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsClass(_A("C")));
|
||||
REQUIRE_THAT(puml, IsClass(_A("R")));
|
||||
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "+a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "+b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "+c"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -54,10 +54,11 @@ TEST_CASE("t00009", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<std::string>")));
|
||||
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("B"), _A("A<int>"), "aint"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("B"), _A("A<std::string>"), "astring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("B"), _A("A<int>"), "+aint"));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAssociation(_A("B"), _A("A<std::string>"), "+astring"));
|
||||
REQUIRE_THAT(puml,
|
||||
IsAssociation(_A("B"), _A("A<std::vector<std::string>>"), "avector"));
|
||||
IsAssociation(_A("B"), _A("A<std::vector<std::string>>"), "+avector"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -52,8 +52,8 @@ TEST_CASE("t00010", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("B<T>"), _A("B<int>")));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("B<T>"), _A("A<T,std::string>"), "astring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("C"), _A("B<int>"), "aintstring"));
|
||||
puml, IsAggregation(_A("B<T>"), _A("A<T,std::string>"), "+astring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("C"), _A("B<int>"), "+aintstring"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -56,7 +56,8 @@ TEST_CASE("t00013", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("E<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("E<T>"), _A("E<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("E<T>"), _A("E<std::string>")));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("E<std::string>"), "estring"));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("R"), _A("E<std::string>"), "-estring"));
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("ABCD::F<T>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("ABCD::F<T>"), _A("ABCD::F<int>")));
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("ABCD::F<int>")));
|
||||
|
||||
@@ -48,7 +48,11 @@ class R {
|
||||
AString<float> floatstring;
|
||||
AIntString intstring;
|
||||
AStringString stringstring;
|
||||
|
||||
protected:
|
||||
BVector bs;
|
||||
|
||||
public:
|
||||
BVector2 bs2;
|
||||
GeneralCallback<AIntString> cb;
|
||||
VoidCallback vcb;
|
||||
|
||||
@@ -49,11 +49,11 @@ TEST_CASE("t00014", "[test-case][class]")
|
||||
REQUIRE_THAT(
|
||||
puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<float>")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "boolstring"));
|
||||
puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "-boolstring"));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("R"), _A("AString<float>"), "floatstring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "bs"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "bs2"));
|
||||
puml, IsAggregation(_A("R"), _A("AString<float>"), "-floatstring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "#bs"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+bs2"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
Reference in New Issue
Block a user