Fixed clang-tidy warnings
This commit is contained in:
@@ -1981,18 +1981,21 @@ void translation_unit_visitor::
|
||||
bool translation_unit_visitor::find_relationships_in_unexposed_template_params(
|
||||
const template_parameter &ct, found_relationships_t &relationships)
|
||||
{
|
||||
assert(ct.type());
|
||||
const auto &type = ct.type();
|
||||
|
||||
if (!type)
|
||||
return false;
|
||||
|
||||
bool found{false};
|
||||
LOG_DBG("Finding relationships in user defined type: {}",
|
||||
ct.to_string(config().using_namespace(), false));
|
||||
|
||||
auto type_with_namespace =
|
||||
std::make_optional<common::model::namespace_>(ct.type().value());
|
||||
std::make_optional<common::model::namespace_>(type.value());
|
||||
|
||||
if (!type_with_namespace.has_value()) {
|
||||
// Couldn't find declaration of this type
|
||||
type_with_namespace = common::model::namespace_{ct.type().value()};
|
||||
type_with_namespace = common::model::namespace_{type.value()};
|
||||
}
|
||||
|
||||
auto element_opt = diagram().get(type_with_namespace.value().to_string());
|
||||
@@ -2007,6 +2010,7 @@ bool translation_unit_visitor::find_relationships_in_unexposed_template_params(
|
||||
nested_template_params, relationships) ||
|
||||
found;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ void to_json(nlohmann::json &j, const element &c)
|
||||
void to_json(nlohmann::json &j, const template_parameter &c)
|
||||
{
|
||||
j["kind"] = to_string(c.kind());
|
||||
if (c.type())
|
||||
j["type"] = c.type().value();
|
||||
if (c.name())
|
||||
j["name"] = c.name().value();
|
||||
if (c.default_value())
|
||||
j["default"] = c.default_value().value();
|
||||
if (const auto &t = c.type(); t)
|
||||
j["type"] = t.value();
|
||||
if (const auto &n = c.name(); n)
|
||||
j["name"] = n.value();
|
||||
if (const auto &d = c.default_value(); d)
|
||||
j["default"] = d.value();
|
||||
j["is_variadic"] = c.is_variadic();
|
||||
j["template_parameters"] = c.template_params();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ std::string to_string(message_t m);
|
||||
|
||||
std::string to_string(diagram_t r);
|
||||
|
||||
std::string to_string(message_scope_t);
|
||||
std::string to_string(message_scope_t t);
|
||||
|
||||
diagram_t from_string(const std::string &s);
|
||||
|
||||
|
||||
@@ -44,20 +44,21 @@ std::string to_string(template_parameter_kind_t k);
|
||||
/// nested templates
|
||||
class template_parameter {
|
||||
public:
|
||||
static template_parameter make_template_type(std::string name,
|
||||
static template_parameter make_template_type(const std::string &name,
|
||||
const std::optional<std::string> &default_value = {},
|
||||
bool is_variadic = false)
|
||||
{
|
||||
template_parameter p;
|
||||
p.set_kind(template_parameter_kind_t::template_type);
|
||||
p.set_name(std::move(name));
|
||||
p.set_name(name);
|
||||
p.is_variadic(is_variadic);
|
||||
if (default_value)
|
||||
p.set_default_value(default_value.value());
|
||||
return p;
|
||||
}
|
||||
|
||||
static template_parameter make_template_template_type(std::string name,
|
||||
static template_parameter make_template_template_type(
|
||||
const std::string &name,
|
||||
const std::optional<std::string> &default_value = {},
|
||||
bool is_variadic = false)
|
||||
{
|
||||
@@ -70,14 +71,14 @@ public:
|
||||
return p;
|
||||
}
|
||||
|
||||
static template_parameter make_non_type_template(std::string type,
|
||||
static template_parameter make_non_type_template(const std::string &type,
|
||||
const std::optional<std::string> &name,
|
||||
const std::optional<std::string> &default_value = {},
|
||||
bool is_variadic = false)
|
||||
{
|
||||
template_parameter p;
|
||||
p.set_kind(template_parameter_kind_t::non_type_template);
|
||||
p.set_type(std::move(type));
|
||||
p.set_type(type);
|
||||
if (name)
|
||||
p.set_name(name.value());
|
||||
if (default_value)
|
||||
@@ -86,21 +87,21 @@ public:
|
||||
return p;
|
||||
}
|
||||
|
||||
static template_parameter make_argument(
|
||||
std::string type, const std::optional<std::string> &default_value = {})
|
||||
static template_parameter make_argument(const std::string &type,
|
||||
const std::optional<std::string> &default_value = {})
|
||||
{
|
||||
template_parameter p;
|
||||
p.set_kind(template_parameter_kind_t::argument);
|
||||
p.set_type(std::move(type));
|
||||
p.set_type(type);
|
||||
if (default_value)
|
||||
p.set_default_value(default_value.value());
|
||||
return p;
|
||||
}
|
||||
|
||||
static template_parameter make_unexposed_argument(
|
||||
std::string type, const std::optional<std::string> &default_value = {})
|
||||
static template_parameter make_unexposed_argument(const std::string &type,
|
||||
const std::optional<std::string> &default_value = {})
|
||||
{
|
||||
template_parameter p = make_argument(std::move(type), default_value);
|
||||
template_parameter p = make_argument(type, default_value);
|
||||
p.set_unexposed(true);
|
||||
return p;
|
||||
}
|
||||
@@ -178,7 +179,7 @@ public:
|
||||
private:
|
||||
template_parameter() = default;
|
||||
|
||||
template_parameter_kind_t kind_;
|
||||
template_parameter_kind_t kind_{template_parameter_kind_t::template_type};
|
||||
|
||||
/// Represents the type of non-type template parameters
|
||||
/// e.g. 'int' or type of template arguments
|
||||
|
||||
@@ -32,8 +32,6 @@ void generator::generate_relationships(
|
||||
{
|
||||
LOG_DBG("Generating relationships for file {}", f.full_name(true));
|
||||
|
||||
namespace json_common = clanguml::common::generators::json;
|
||||
|
||||
if (f.type() == common::model::source_file_t::kDirectory) {
|
||||
util::for_each(f, [this, &parent](const auto &file) {
|
||||
generate_relationships(
|
||||
@@ -93,7 +91,7 @@ void generator::generate(std::ostream &ostr) const
|
||||
// Generate files and folders
|
||||
util::for_each_if(
|
||||
m_model, [](const auto & /*f*/) { return true; },
|
||||
[this, &ostr](const auto &f) {
|
||||
[this](const auto &f) {
|
||||
generate(dynamic_cast<source_file &>(*f), json_);
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void to_json(nlohmann::json &j, const activity &c)
|
||||
j["participant_id"] = std::to_string(c.from());
|
||||
}
|
||||
|
||||
} // namespace clanguml::class_diagram::model
|
||||
} // namespace clanguml::sequence_diagram::model
|
||||
|
||||
namespace clanguml::sequence_diagram::generators::json {
|
||||
|
||||
@@ -172,11 +172,8 @@ void generator::generate_call(const message &m, nlohmann::json &parent) const
|
||||
m.from(), to, m.to());
|
||||
}
|
||||
|
||||
void generator::generate_activity(
|
||||
common::model::diagram_element::id_t activity_id, const activity &a,
|
||||
nlohmann::json &unused,
|
||||
std::vector<common::model::diagram_element::id_t> &visited,
|
||||
std::optional<nlohmann::json> nested_block) const
|
||||
void generator::generate_activity(const activity &a,
|
||||
std::vector<common::model::diagram_element::id_t> &visited) const
|
||||
{
|
||||
// Generate calls from this activity to other activities
|
||||
for (const auto &m : a.messages()) {
|
||||
@@ -265,8 +262,7 @@ void generator::process_call_message(const model::message &m,
|
||||
LOG_DBG("Creating activity {} --> {} - missing sequence {}",
|
||||
m.from(), m.to(), m.to());
|
||||
|
||||
generate_activity(m.to(), m_model.get_activity(m.to()),
|
||||
current_block_statement(), visited, {});
|
||||
generate_activity(m_model.get_activity(m.to()), visited);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -644,8 +640,8 @@ void generator::generate(std::ostream &ostr) const
|
||||
|
||||
block_statements_stack_.push_back(std::ref(sequence));
|
||||
|
||||
generate_activity(start_from, m_model.get_activity(start_from),
|
||||
sequence, visited_participants, {});
|
||||
generate_activity(
|
||||
m_model.get_activity(start_from), visited_participants);
|
||||
|
||||
json_["sequences"].push_back(std::move(sequence));
|
||||
|
||||
@@ -666,4 +662,4 @@ void generator::generate(std::ostream &ostr) const
|
||||
|
||||
ostr << json_;
|
||||
}
|
||||
} // namespace clanguml::sequence_diagram::generators::plantuml
|
||||
} // namespace clanguml::sequence_diagram::generators::json
|
||||
|
||||
@@ -53,10 +53,8 @@ public:
|
||||
void generate_participant(
|
||||
nlohmann::json &parent, const std::string &name) const;
|
||||
|
||||
void generate_activity(common::model::diagram_element::id_t activity_id,
|
||||
const sequence_diagram::model::activity &a, nlohmann::json &parent,
|
||||
std::vector<common::model::diagram_element::id_t> &visited,
|
||||
std::optional<nlohmann::json> nested_block) const;
|
||||
void generate_activity(const sequence_diagram::model::activity &a,
|
||||
std::vector<common::model::diagram_element::id_t> &visited) const;
|
||||
|
||||
void generate(std::ostream &ostr) const override;
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ std::string method::message_name(message_render_mode mode) const
|
||||
{
|
||||
constexpr auto kAbbreviatedMethodArgumentsLength{15};
|
||||
|
||||
const std::string style = "";
|
||||
const std::string style{};
|
||||
|
||||
if (mode == message_render_mode::no_arguments) {
|
||||
return fmt::format("{}{}(){}{}", style, method_name(),
|
||||
|
||||
@@ -1606,8 +1606,13 @@ translation_unit_visitor::build_template_instantiation_process_type_argument(
|
||||
|
||||
// If this is a nested template type - add nested templates as
|
||||
// template arguments
|
||||
if (arg.getAsType()->getAs<clang::FunctionType>() != nullptr) {
|
||||
if (const auto *function_template_type =
|
||||
arg.getAsType()->getAs<clang::FunctionType>();
|
||||
function_template_type != nullptr) {
|
||||
// TODO
|
||||
argument = template_parameter::make_argument(
|
||||
common::to_string(function_template_type->getReturnType(),
|
||||
template_decl->getASTContext()));
|
||||
}
|
||||
else if (const auto *nested_template_type =
|
||||
arg.getAsType()->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
Reference in New Issue
Block a user