Fixed formatting

This commit is contained in:
Bartek Kryza
2022-07-31 00:42:13 +02:00
parent 37757b2ccc
commit dd85cfc19b
23 changed files with 76 additions and 64 deletions

View File

@@ -107,8 +107,8 @@ private:
namespace std {
template <>
struct hash<std::reference_wrapper<
const clanguml::class_diagram::model::class_>> {
struct hash<
std::reference_wrapper<const clanguml::class_diagram::model::class_>> {
std::size_t operator()(const std::reference_wrapper<
const clanguml::class_diagram::model::class_> &key) const
{

View File

@@ -245,7 +245,7 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
// Check if the class was already processed within
// VisitClassTemplateDecl()
if (diagram_.has_element(cls->getID()))
return true;
return true;
// TODO: Add support for classes defined in function/method bodies
if (cls->isLocalClass())

View File

@@ -144,7 +144,8 @@ private:
const clang::TemplateSpecializationType &template_instantiation_type);
void process_unexposed_template_specialization_parameters(
const std::string &tspec, clanguml::class_diagram::model::template_parameter &tp,
const std::string &tspec,
clanguml::class_diagram::model::template_parameter &tp,
clanguml::class_diagram::model::class_ &c);
bool find_relationships_in_unexposed_template_params(

View File

@@ -67,7 +67,8 @@ public:
return false;
}
virtual bool should_include(const namespace_ &ns, const std::string &name) const;
virtual bool should_include(
const namespace_ &ns, const std::string &name) const;
private:
std::string name_;

View File

@@ -86,7 +86,7 @@ inja::json diagram_element::context() const
bool operator==(const diagram_element &l, const diagram_element &r)
{
return l.id() == r.id();
//return l.full_name(false) == r.full_name(false);
// return l.full_name(false) == r.full_name(false);
}
std::ostream &operator<<(std::ostream &out, const diagram_element &rhs)

View File

@@ -34,8 +34,6 @@ namespace clanguml::common::model {
class element : public diagram_element, public source_location {
public:
element(const namespace_ &using_namespace);
virtual ~element() = default;

View File

@@ -37,25 +37,26 @@ void generator::generate_relationships(
namespace plantuml_common = clanguml::common::generators::plantuml;
// if (f.type() == common::model::source_file_t::kDirectory) {
// util::for_each(f, [this, &ostr](const auto &file) {
// generate_relationships(
// dynamic_cast<const source_file &>(*file), ostr);
// });
// }
// else {
// util::for_each_if(
// f.relationships(),
// [this](const auto &r) {
// return m_model.should_include(r.type()) &&
// util::contains(m_generated_aliases, r.destination());
// },
// [&f, &ostr](const auto &r) {
// ostr << f.alias() << " "
// << plantuml_common::to_plantuml(r.type(), r.style()) << " "
// << r.destination() << '\n';
// });
// }
// if (f.type() == common::model::source_file_t::kDirectory) {
// util::for_each(f, [this, &ostr](const auto &file) {
// generate_relationships(
// dynamic_cast<const source_file &>(*file), ostr);
// });
// }
// else {
// util::for_each_if(
// f.relationships(),
// [this](const auto &r) {
// return m_model.should_include(r.type()) &&
// util::contains(m_generated_aliases, r.destination());
// },
// [&f, &ostr](const auto &r) {
// ostr << f.alias() << " "
// << plantuml_common::to_plantuml(r.type(), r.style())
// << " "
// << r.destination() << '\n';
// });
// }
}
void generator::generate(const source_file &f, std::ostream &ostr) const

View File

@@ -42,7 +42,8 @@ public:
void operator()(const cppast::cpp_entity &file);
void finalize() {}
void finalize() { }
private:
clang::SourceManager &source_manager_;

View File

@@ -106,9 +106,8 @@ int main(int argc, const char *argv[])
std::string err{};
auto db =
clang::tooling::CompilationDatabase::autoDetectFromDirectory(
config.compilation_database_dir(), err);
auto db = clang::tooling::CompilationDatabase::autoDetectFromDirectory(
config.compilation_database_dir(), err);
if (!err.empty()) {
LOG_ERROR("Failed to load compilation database from {}",

View File

@@ -32,15 +32,16 @@ void generator::generate_relationships(
{
LOG_DBG("Generating relationships for package {}", p.full_name(true));
// const auto &uns = m_config.using_namespace();
// const auto &uns = m_config.using_namespace();
// Generate this packages relationship
if (m_model.should_include(relationship_t::kDependency)) {
for (const auto &r : p.relationships()) {
std::stringstream relstr;
try {
relstr << p.alias() << " ..> "
//<< m_model.get_ to_alias(uns.relative(r.destination()))
relstr << p.alias()
<< " ..> "
//<< m_model.get_ to_alias(uns.relative(r.destination()))
<< '\n';
ostr << relstr.str();
}

View File

@@ -34,13 +34,14 @@
namespace clanguml::package_diagram::visitor {
class translation_unit_visitor
: public clang::RecursiveASTVisitor<translation_unit_visitor>{
: public clang::RecursiveASTVisitor<translation_unit_visitor> {
public:
translation_unit_visitor(clang::SourceManager &sm,
clanguml::package_diagram::model::diagram &diagram,
const clanguml::config::package_diagram &config);
void finalize() {}
void finalize() { }
private:
clang::SourceManager &source_manager_;

View File

@@ -22,7 +22,6 @@
#include "cx/util.h"
#include "translation_unit_context.h"
namespace clanguml::sequence_diagram::visitor {
translation_unit_visitor::translation_unit_visitor(clang::SourceManager &sm,
@@ -34,7 +33,6 @@ translation_unit_visitor::translation_unit_visitor(clang::SourceManager &sm,
{
}
/*
void translation_unit_visitor::process_activities(const cppast::cpp_function &e)
{

View File

@@ -33,7 +33,8 @@ public:
clanguml::sequence_diagram::model::diagram &diagram,
const clanguml::config::sequence_diagram &config);
void finalize() {}
void finalize() { }
private:
clang::SourceManager &source_manager_;

View File

@@ -46,7 +46,7 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsClassTemplate("A", "double,float"));
REQUIRE_THAT(puml, IsClassTemplate("A", "bool,std::string"));
REQUIRE_THAT(puml, IsClassTemplate("A", "std::string,std::string"));
// REQUIRE_THAT(puml, IsClassTemplate("A", "char,std::string"));
// REQUIRE_THAT(puml, IsClassTemplate("A", "char,std::string"));
REQUIRE_THAT(puml, IsClass(_A("B")));
REQUIRE_THAT(puml, IsField<Private>("bapair", "PairPairBA<bool>"));
@@ -83,10 +83,12 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsInstantiation(_A("A<T,P>"), _A("A<T,std::string>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("A<T,std::string>"), _A("A<bool,std::string>")));
// REQUIRE_THAT(puml,
// IsInstantiation(_A("A<T,std::string>"), _A("A<char,std::string>")));
// REQUIRE_THAT(puml,
// IsInstantiation(_A("A<T,std::string>"), _A("A<wchar_t,std::string>")));
// REQUIRE_THAT(puml,
// IsInstantiation(_A("A<T,std::string>"),
// _A("A<char,std::string>")));
// REQUIRE_THAT(puml,
// IsInstantiation(_A("A<T,std::string>"),
// _A("A<wchar_t,std::string>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("A<T,std::unique_ptr<std::string>>"),
@@ -108,8 +110,9 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml,
IsAggregation(_A("R"), _A("A<float,std::unique_ptr<std::string>>"),
"-floatstring"));
// REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A<char,std::string>")));
// REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A<wchar_t,std::string>")));
// REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A<char,std::string>")));
// REQUIRE_THAT(puml, IsDependency(_A("R"),
// _A("A<wchar_t,std::string>")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);

View File

@@ -46,8 +46,8 @@ TEST_CASE("t00016", "[test-case][class]")
puml, IsInstantiation(_A("is_numeric<>"), _A("is_numeric<bool>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("is_numeric<>"), _A("is_numeric<char>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("is_numeric<>"), _A("is_numeric<float>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("is_numeric<>"), _A("is_numeric<float>")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);

View File

@@ -48,7 +48,8 @@ TEST_CASE("t00017", "[test-case][class]")
REQUIRE_THAT(puml, (IsField<Private>("some_int", "int")));
REQUIRE_THAT(puml, (IsField<Private>("some_int_pointer", "int *")));
REQUIRE_THAT(puml, (IsField<Private>("some_int_pointer_pointer", "int **")));
REQUIRE_THAT(
puml, (IsField<Private>("some_int_pointer_pointer", "int **")));
// Relationship members should not be rendered as part of this testcase
REQUIRE_THAT(puml, !(IsField<Private>("a", _A("A"))));

View File

@@ -47,10 +47,8 @@ TEST_CASE("t00025", "[test-case][class]")
puml, !IsAggregation(_A("ProxyHolder"), _A("Target1"), "+proxy1"));
REQUIRE_THAT(
puml, !IsAggregation(_A("ProxyHolder"), _A("Target2"), "+proxy2"));
REQUIRE_THAT(
puml, IsDependency(_A("Proxy<Target1>"), _A("Target1")));
REQUIRE_THAT(
puml, IsDependency(_A("Proxy<Target2>"), _A("Target2")));
REQUIRE_THAT(puml, IsDependency(_A("Proxy<Target1>"), _A("Target1")));
REQUIRE_THAT(puml, IsDependency(_A("Proxy<Target2>"), _A("Target2")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);

View File

@@ -4,15 +4,20 @@
namespace clanguml {
namespace t00030 {
class A { };
class A {
};
class B { };
class B {
};
class C { };
class C {
};
class D { };
class D {
};
class E { };
class E {
};
struct R {
/// @uml{association[]}

View File

@@ -25,7 +25,8 @@ namespace ns2 {
namespace ns22 {
// TODO: Fix for incomplete struct C declaration "struct C;"
struct C {};
struct C {
};
}
}

View File

@@ -32,7 +32,8 @@ struct key_t {
std::string key;
};
template <typename T> struct map {};
template <typename T> struct map {
};
using namespace thirdparty::ns1;

View File

@@ -37,7 +37,7 @@ TEST_CASE("t00044", "[test-case][class]")
// TODO:
// Check dependants filter<void(int), bool>
//REQUIRE_THAT(puml, IsClassTemplate("signal_handler", "Ret,Args...,A"));
// REQUIRE_THAT(puml, IsClassTemplate("signal_handler", "Ret,Args...,A"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);

View File

@@ -41,7 +41,7 @@ load_config(const std::string &test_name)
clang::tooling::CompilationDatabase::autoDetectFromDirectory(
config.compilation_database_dir(), err);
if(!err.empty())
if (!err.empty())
throw std::runtime_error{err};
return std::make_pair(std::move(config), std::move(compilation_database));

View File

@@ -37,8 +37,8 @@
#include "catch.h"
#include <clang/Tooling/Tooling.h>
#include <clang/Tooling/CompilationDatabase.h>
#include <clang/Tooling/Tooling.h>
#include <algorithm>
#include <complex>
@@ -52,7 +52,8 @@ using Catch::Matchers::StartsWith;
using Catch::Matchers::VectorContains;
using namespace clanguml::util;
std::pair<clanguml::config::config, std::unique_ptr<clang::tooling::CompilationDatabase>>
std::pair<clanguml::config::config,
std::unique_ptr<clang::tooling::CompilationDatabase>>
load_config(const std::string &test_name);
std::string generate_sequence_puml(