Merge pull request #228 from bkryza/add-coroutine-testcase
Add coroutine testcase
This commit is contained in:
@@ -27,7 +27,7 @@ target_compile_options(clang-umllib PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Werror -Wall -Wextra -Wno-unused-parameter
|
||||
-Wno-deprecated-declarations ${CUSTOM_COMPILE_OPTIONS}>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>)
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/MP /MD /W1 /bigobj /wd4291 /wd4624 /wd4244>)
|
||||
target_compile_definitions(clang-umllib PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
-DLLVM_FORCE_USE_OLD_TOOLCHAIN
|
||||
@@ -44,7 +44,7 @@ target_compile_options(clang-uml PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Werror -Wall -Wextra -Wno-unused-parameter
|
||||
-Wno-deprecated-declarations ${CUSTOM_COMPILE_OPTIONS}>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>)
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/MP /MD /W1 /bigobj /wd4291 /wd4624 /wd4244>)
|
||||
target_compile_definitions(clang-uml PRIVATE
|
||||
${ENABLE_BACKWARD_CPP})
|
||||
target_link_libraries(clang-uml
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file rc/class_diagram/generators/json/class_diagram_generator.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,14 @@
|
||||
namespace clanguml::class_diagram::model {
|
||||
using nlohmann::json;
|
||||
|
||||
void set_module(nlohmann::json &j, const common::model::element &e)
|
||||
{
|
||||
if (e.module()) {
|
||||
j["module"]["name"] = e.module().value();
|
||||
j["module"]["is_private"] = e.module_private();
|
||||
}
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &j, const class_element &c)
|
||||
{
|
||||
j["name"] = c.name();
|
||||
@@ -63,6 +71,7 @@ void to_json(nlohmann::json &j, const class_method &c)
|
||||
j["is_noexcept"] = c.is_noexcept();
|
||||
j["is_constexpr"] = c.is_constexpr();
|
||||
j["is_consteval"] = c.is_consteval();
|
||||
j["is_coroutine"] = c.is_coroutine();
|
||||
j["is_constructor"] = c.is_constructor();
|
||||
j["is_move_assignment"] = c.is_move_assignment();
|
||||
j["is_copy_assignment"] = c.is_copy_assignment();
|
||||
@@ -93,6 +102,8 @@ void to_json(nlohmann::json &j, const class_ &c)
|
||||
j["methods"] = c.methods();
|
||||
j["bases"] = c.parents();
|
||||
|
||||
set_module(j, c);
|
||||
|
||||
j["template_parameters"] = c.template_params();
|
||||
}
|
||||
|
||||
@@ -101,6 +112,8 @@ void to_json(nlohmann::json &j, const enum_ &c)
|
||||
j = dynamic_cast<const common::model::element &>(c);
|
||||
j["is_nested"] = c.is_nested();
|
||||
j["constants"] = c.constants();
|
||||
|
||||
set_module(j, c);
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &j, const concept_ &c)
|
||||
@@ -108,6 +121,8 @@ void to_json(nlohmann::json &j, const concept_ &c)
|
||||
j = dynamic_cast<const common::model::element &>(c);
|
||||
j["parameters"] = c.requires_parameters();
|
||||
j["statements"] = c.requires_statements();
|
||||
|
||||
set_module(j, c);
|
||||
}
|
||||
|
||||
} // namespace clanguml::class_diagram::model
|
||||
@@ -124,6 +139,11 @@ void generator::generate_diagram(nlohmann::json &parent) const
|
||||
if (config().using_namespace)
|
||||
parent["using_namespace"] = config().using_namespace().to_string();
|
||||
|
||||
if (config().using_module)
|
||||
parent["using_module"] = config().using_module();
|
||||
|
||||
if (config().generate_packages.has_value)
|
||||
parent["package_type"] = to_string(config().package_type());
|
||||
parent["elements"] = std::vector<nlohmann::json>{};
|
||||
parent["relationships"] = std::vector<nlohmann::json>{};
|
||||
|
||||
@@ -169,13 +189,9 @@ void generator::generate(const package &p, nlohmann::json &parent) const
|
||||
if (!uns.starts_with({p.full_name(false)})) {
|
||||
LOG_DBG("Generating package {}", p.name());
|
||||
|
||||
if (config().package_type() == config::package_type_t::kDirectory)
|
||||
package_object["type"] = "directory";
|
||||
else
|
||||
package_object["type"] = "namespace";
|
||||
|
||||
package_object["type"] = to_string(config().package_type());
|
||||
package_object["name"] = p.name();
|
||||
package_object["display_name"] = p.full_name(false);
|
||||
package_object["display_name"] = p.name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/generators/json/class_diagram_generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/generators/mermaid/class_diagram_generator.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -251,6 +251,9 @@ void generator::generate_method(
|
||||
if (m.is_consteval()) {
|
||||
method_mods.emplace_back("consteval");
|
||||
}
|
||||
if (m.is_coroutine()) {
|
||||
method_mods.emplace_back("coroutine");
|
||||
}
|
||||
|
||||
if (!method_mods.empty()) {
|
||||
ostr << fmt::format("[{}] ", fmt::join(method_mods, ","));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/generators/mermaid/class_diagram_generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/generators/plantuml/class_diagram_generator.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
||||
class_type = "abstract";
|
||||
|
||||
std::string full_name;
|
||||
if (config().generate_packages())
|
||||
if (config().generate_fully_qualified_name())
|
||||
full_name = c.full_name_no_ns();
|
||||
else
|
||||
full_name = c.full_name();
|
||||
@@ -89,7 +89,7 @@ void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
|
||||
{
|
||||
print_debug(e, ostr);
|
||||
|
||||
if (config().generate_packages())
|
||||
if (config().generate_fully_qualified_name())
|
||||
ostr << "enum"
|
||||
<< " \"" << e.name();
|
||||
else
|
||||
@@ -106,7 +106,7 @@ void generator::generate_alias(const concept_ &c, std::ostream &ostr) const
|
||||
{
|
||||
print_debug(c, ostr);
|
||||
|
||||
if (config().generate_packages())
|
||||
if (config().generate_fully_qualified_name())
|
||||
ostr << "class"
|
||||
<< " \"" << c.name();
|
||||
else
|
||||
@@ -338,6 +338,9 @@ void generator::generate_method(
|
||||
else if (m.is_deleted())
|
||||
ostr << " = deleted";
|
||||
|
||||
if (m.is_coroutine())
|
||||
ostr << " [coroutine]";
|
||||
|
||||
ostr << " : " << type;
|
||||
|
||||
if (config().generate_links) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/generators/plantuml/class_diagram_generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_member.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_member.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_method.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,6 +70,13 @@ void class_method::is_consteval(bool is_consteval)
|
||||
is_consteval_ = is_consteval;
|
||||
}
|
||||
|
||||
bool class_method::is_coroutine() const { return is_coroutine_; }
|
||||
|
||||
void class_method::is_coroutine(bool is_coroutine)
|
||||
{
|
||||
is_coroutine_ = is_coroutine;
|
||||
}
|
||||
|
||||
bool class_method::is_noexcept() const { return is_noexcept_; }
|
||||
|
||||
void class_method::is_noexcept(bool is_noexcept) { is_noexcept_ = is_noexcept; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_method.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -152,6 +152,20 @@ public:
|
||||
*/
|
||||
void is_consteval(bool is_consteval);
|
||||
|
||||
/**
|
||||
* @brief Whether the method is a C++20 coroutine.
|
||||
*
|
||||
* @return True, if the method is a coroutine
|
||||
*/
|
||||
bool is_coroutine() const;
|
||||
|
||||
/**
|
||||
* @brief Set whether the method is a C++20 coroutine.
|
||||
*
|
||||
* @param is_coroutine True, if the method is a coroutine
|
||||
*/
|
||||
void is_coroutine(bool is_coroutine);
|
||||
|
||||
/**
|
||||
* @brief Whether the method is noexcept.
|
||||
*
|
||||
@@ -262,6 +276,7 @@ private:
|
||||
bool is_noexcept_{false};
|
||||
bool is_constexpr_{false};
|
||||
bool is_consteval_{false};
|
||||
bool is_coroutine_{false};
|
||||
bool is_constructor_{false};
|
||||
bool is_destructor_{false};
|
||||
bool is_move_assignment_{false};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_parent.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/class_parent.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/concept.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/concept.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/diagram.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,7 +74,7 @@ common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
|
||||
}
|
||||
|
||||
common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
|
||||
const clanguml::common::model::diagram_element::id_t id) const
|
||||
const clanguml::common::id_t id) const
|
||||
{
|
||||
common::optional_ref<clanguml::common::model::diagram_element> res;
|
||||
|
||||
@@ -116,6 +116,18 @@ bool diagram::add_with_filesystem_path<common::model::package>(
|
||||
return add_element(ns, std::move(p));
|
||||
}
|
||||
|
||||
template <>
|
||||
bool diagram::add_with_module_path<common::model::package>(
|
||||
const common::model::path & /*parent_path*/,
|
||||
std::unique_ptr<common::model::package> &&p)
|
||||
{
|
||||
LOG_DBG("Adding module package: {}, {}", p->name(), p->full_name(true));
|
||||
|
||||
auto ns = p->get_relative_namespace();
|
||||
|
||||
return add_element(ns, std::move(p));
|
||||
}
|
||||
|
||||
void diagram::get_parents(
|
||||
clanguml::common::reference_set<class_> &parents) const
|
||||
{
|
||||
@@ -137,8 +149,7 @@ void diagram::get_parents(
|
||||
}
|
||||
}
|
||||
|
||||
bool diagram::has_element(
|
||||
clanguml::common::model::diagram_element::id_t id) const
|
||||
bool diagram::has_element(clanguml::common::id_t id) const
|
||||
{
|
||||
const auto has_class = std::any_of(classes().begin(), classes().end(),
|
||||
[id](const auto &c) { return c.get().id() == id; });
|
||||
@@ -156,8 +167,7 @@ bool diagram::has_element(
|
||||
[id](const auto &c) { return c.get().id() == id; });
|
||||
}
|
||||
|
||||
std::string diagram::to_alias(
|
||||
clanguml::common::model::diagram_element::id_t id) const
|
||||
std::string diagram::to_alias(clanguml::common::id_t id) const
|
||||
{
|
||||
LOG_DBG("Looking for alias for {}", id);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/diagram.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
* @param id Element id.
|
||||
* @return Optional reference to a diagram element.
|
||||
*/
|
||||
opt_ref<diagram_element> get(diagram_element::id_t id) const override;
|
||||
opt_ref<diagram_element> get(common::id_t id) const override;
|
||||
|
||||
/**
|
||||
* @brief Get list of references to classes in the diagram model.
|
||||
@@ -172,8 +172,7 @@ public:
|
||||
* @param id Id of the element
|
||||
* @return Optional reference to a diagram element
|
||||
*/
|
||||
template <typename ElementT>
|
||||
opt_ref<ElementT> find(diagram_element::id_t id) const;
|
||||
template <typename ElementT> opt_ref<ElementT> find(common::id_t id) const;
|
||||
|
||||
/**
|
||||
* @brief Get reference to vector of elements of specific type
|
||||
@@ -203,6 +202,10 @@ public:
|
||||
return add_with_namespace_path(std::move(e));
|
||||
}
|
||||
|
||||
if (parent_path.type() == common::model::path_type::kModule) {
|
||||
return add_with_module_path(parent_path, std::move(e));
|
||||
}
|
||||
|
||||
return add_with_filesystem_path(parent_path, std::move(e));
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ public:
|
||||
* @param id Id of the diagram element.
|
||||
* @return PlantUML alias.
|
||||
*/
|
||||
std::string to_alias(diagram_element::id_t id) const;
|
||||
std::string to_alias(common::id_t id) const;
|
||||
|
||||
/**
|
||||
* @brief Given an initial set of classes, add all their parents to the
|
||||
@@ -224,8 +227,6 @@ public:
|
||||
*/
|
||||
void get_parents(clanguml::common::reference_set<class_> &parents) const;
|
||||
|
||||
friend void print_diagram_tree(const diagram &d, int level);
|
||||
|
||||
/**
|
||||
* @brief Check if diagram contains element by id.
|
||||
*
|
||||
@@ -234,7 +235,7 @@ public:
|
||||
* @param id Id of the element.
|
||||
* @return True, if diagram contains an element with a specific id.
|
||||
*/
|
||||
bool has_element(diagram_element::id_t id) const override;
|
||||
bool has_element(common::id_t id) const override;
|
||||
|
||||
/**
|
||||
* @brief Remove redundant dependency relationships
|
||||
@@ -252,6 +253,10 @@ private:
|
||||
template <typename ElementT>
|
||||
bool add_with_namespace_path(std::unique_ptr<ElementT> &&e);
|
||||
|
||||
template <typename ElementT>
|
||||
bool add_with_module_path(
|
||||
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e);
|
||||
|
||||
template <typename ElementT>
|
||||
bool add_with_filesystem_path(
|
||||
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e);
|
||||
@@ -317,19 +322,53 @@ bool diagram::add_with_namespace_path(std::unique_ptr<ElementT> &&e)
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename ElementT>
|
||||
bool diagram::add_with_module_path(
|
||||
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e)
|
||||
{
|
||||
const auto element_type = e->type_name();
|
||||
|
||||
// Make sure all parent modules are already packages in the
|
||||
// model
|
||||
for (auto it = parent_path.begin(); it != parent_path.end(); it++) {
|
||||
auto pkg = std::make_unique<common::model::package>(
|
||||
e->using_namespace(), parent_path.type());
|
||||
pkg->set_name(*it);
|
||||
auto ns =
|
||||
common::model::path(parent_path.begin(), it, parent_path.type());
|
||||
// ns.pop_back();
|
||||
pkg->set_namespace(ns);
|
||||
pkg->set_id(common::to_id(pkg->full_name(false)));
|
||||
|
||||
add(ns, std::move(pkg));
|
||||
}
|
||||
|
||||
const auto base_name = e->name();
|
||||
const auto full_name = e->full_name(false);
|
||||
auto &e_ref = *e;
|
||||
|
||||
if (add_element(parent_path, std::move(e))) {
|
||||
element_view<ElementT>::add(std::ref(e_ref));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename ElementT>
|
||||
bool diagram::add_with_filesystem_path(
|
||||
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e)
|
||||
{
|
||||
const auto element_type = e->type_name();
|
||||
|
||||
// Make sure all parent directories are already packages in the
|
||||
// Make sure all parent modules are already packages in the
|
||||
// model
|
||||
for (auto it = parent_path.begin(); it != parent_path.end(); it++) {
|
||||
auto pkg =
|
||||
std::make_unique<common::model::package>(e->using_namespace());
|
||||
auto pkg = std::make_unique<common::model::package>(
|
||||
e->using_namespace(), parent_path.type());
|
||||
pkg->set_name(*it);
|
||||
auto ns = common::model::path(parent_path.begin(), it);
|
||||
auto ns =
|
||||
common::model::path(parent_path.begin(), it, parent_path.type());
|
||||
// ns.pop_back();
|
||||
pkg->set_namespace(ns);
|
||||
pkg->set_id(common::to_id(pkg->full_name(false)));
|
||||
@@ -381,7 +420,7 @@ std::vector<opt_ref<ElementT>> diagram::find(
|
||||
}
|
||||
|
||||
template <typename ElementT>
|
||||
opt_ref<ElementT> diagram::find(diagram_element::id_t id) const
|
||||
opt_ref<ElementT> diagram::find(common::id_t id) const
|
||||
{
|
||||
for (const auto &element : element_view<ElementT>::view()) {
|
||||
if (element.get().id() == id) {
|
||||
@@ -405,6 +444,11 @@ template <>
|
||||
bool diagram::add_with_namespace_path<common::model::package>(
|
||||
std::unique_ptr<common::model::package> &&p);
|
||||
|
||||
template <>
|
||||
bool diagram::add_with_module_path<common::model::package>(
|
||||
const common::model::path &parent_path,
|
||||
std::unique_ptr<common::model::package> &&p);
|
||||
|
||||
template <>
|
||||
bool diagram::add_with_filesystem_path<common::model::package>(
|
||||
const common::model::path &parent_path,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/enum.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/enum.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/method_parameter.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/model/method_parameter.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/visitor/template_builder.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -216,7 +216,7 @@ std::unique_ptr<class_> template_builder::build(const clang::NamedDecl *cls,
|
||||
std::string best_match_full_name{};
|
||||
auto full_template_name = template_instantiation.full_name(false);
|
||||
int best_match{};
|
||||
common::model::diagram_element::id_t best_match_id{0};
|
||||
common::id_t best_match_id{0};
|
||||
|
||||
for (const auto templ : diagram().classes()) {
|
||||
if (templ.get() == template_instantiation)
|
||||
@@ -318,7 +318,7 @@ template_builder::build_from_class_template_specialization(
|
||||
std::string best_match_full_name{};
|
||||
auto full_template_name = template_instantiation.full_name(false);
|
||||
int best_match{};
|
||||
common::model::diagram_element::id_t best_match_id{0};
|
||||
common::id_t best_match_id{0};
|
||||
|
||||
for (const auto templ : diagram().classes()) {
|
||||
if (templ.get() == template_instantiation)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/visitor/template_builder.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,9 +30,8 @@ using common::model::namespace_;
|
||||
using common::model::relationship_t;
|
||||
using common::model::template_parameter;
|
||||
|
||||
using found_relationships_t =
|
||||
std::vector<std::pair<clanguml::common::model::diagram_element::id_t,
|
||||
common::model::relationship_t>>;
|
||||
using found_relationships_t = std::vector<
|
||||
std::pair<clanguml::common::id_t, common::model::relationship_t>>;
|
||||
|
||||
class translation_unit_visitor;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/visitor/translation_unit_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -116,7 +116,7 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
||||
|
||||
const auto *parent = enm->getParent();
|
||||
|
||||
std::optional<common::model::diagram_element::id_t> id_opt;
|
||||
std::optional<common::id_t> id_opt;
|
||||
|
||||
if (parent != nullptr) {
|
||||
const auto *parent_record_decl =
|
||||
@@ -159,6 +159,7 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
||||
|
||||
process_comment(*enm, e);
|
||||
set_source_location(*enm, e);
|
||||
set_owning_module(*enm, e);
|
||||
|
||||
if (e.skip())
|
||||
return true;
|
||||
@@ -212,7 +213,7 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
|
||||
}
|
||||
|
||||
if (!template_specialization.template_specialization_found()) {
|
||||
// Only do this if we haven't found a bettern specialization during
|
||||
// Only do this if we haven't found a better specialization during
|
||||
// construction of the template specialization
|
||||
const auto maybe_id =
|
||||
id_mapper().get_global_id(cls->getSpecializedTemplate()->getID());
|
||||
@@ -265,6 +266,7 @@ bool translation_unit_visitor::VisitTypeAliasTemplateDecl(
|
||||
LOG_DBG("Adding class {} with id {}", name, id);
|
||||
|
||||
set_source_location(*cls, *template_specialization_ptr);
|
||||
set_owning_module(*cls, *template_specialization_ptr);
|
||||
|
||||
add_class(std::move(template_specialization_ptr));
|
||||
}
|
||||
@@ -677,6 +679,9 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
|
||||
LOG_DBG(
|
||||
"== getQualifiedNameAsString() = {}", cls->getQualifiedNameAsString());
|
||||
if (cls->getOwningModule() != nullptr)
|
||||
LOG_DBG(
|
||||
"== getOwningModule()->Name = {}", cls->getOwningModule()->Name);
|
||||
LOG_DBG("== getID() = {}", cls->getID());
|
||||
LOG_DBG("== isTemplateDecl() = {}", cls->isTemplateDecl());
|
||||
LOG_DBG("== isTemplated() = {}", cls->isTemplated());
|
||||
@@ -762,6 +767,7 @@ translation_unit_visitor::create_concept_declaration(clang::ConceptDecl *cpt)
|
||||
|
||||
process_comment(*cpt, concept_model);
|
||||
set_source_location(*cpt, concept_model);
|
||||
set_owning_module(*cpt, concept_model);
|
||||
|
||||
if (concept_model.skip())
|
||||
return {};
|
||||
@@ -802,6 +808,7 @@ std::unique_ptr<class_> translation_unit_visitor::create_record_declaration(
|
||||
|
||||
process_comment(*rec, record);
|
||||
set_source_location(*rec, record);
|
||||
set_owning_module(*rec, record);
|
||||
|
||||
const auto record_full_name = record_ptr->full_name(false);
|
||||
|
||||
@@ -841,6 +848,7 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
||||
|
||||
process_comment(*cls, c);
|
||||
set_source_location(*cls, c);
|
||||
set_owning_module(*cls, c);
|
||||
|
||||
if (c.skip())
|
||||
return {};
|
||||
@@ -855,7 +863,7 @@ void translation_unit_visitor::process_record_parent(
|
||||
{
|
||||
const auto *parent = cls->getParent();
|
||||
|
||||
std::optional<common::model::diagram_element::id_t> id_opt;
|
||||
std::optional<common::id_t> id_opt;
|
||||
|
||||
auto parent_ns = ns;
|
||||
if (parent != nullptr) {
|
||||
@@ -1369,6 +1377,7 @@ void translation_unit_visitor::process_method_properties(
|
||||
method.is_move_assignment(mf.isMoveAssignmentOperator());
|
||||
method.is_copy_assignment(mf.isCopyAssignmentOperator());
|
||||
method.is_noexcept(isNoexceptExceptionSpec(mf.getExceptionSpecType()));
|
||||
method.is_coroutine(common::is_coroutine(mf));
|
||||
}
|
||||
|
||||
void translation_unit_visitor::
|
||||
@@ -1834,6 +1843,7 @@ translation_unit_visitor::process_template_specialization(
|
||||
|
||||
process_comment(*cls, template_instantiation);
|
||||
set_source_location(*cls, template_instantiation);
|
||||
set_owning_module(*cls, template_instantiation);
|
||||
|
||||
if (template_instantiation.skip())
|
||||
return {};
|
||||
@@ -2140,6 +2150,15 @@ void translation_unit_visitor::add_class(std::unique_ptr<class_> &&c)
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
}
|
||||
else if ((config().generate_packages() &&
|
||||
config().package_type() == config::package_type_t::kModule)) {
|
||||
|
||||
const auto module_path = config().make_module_relative(c->module());
|
||||
|
||||
common::model::path p{module_path, common::model::path_type::kModule};
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
}
|
||||
else {
|
||||
diagram().add(c->path(), std::move(c));
|
||||
}
|
||||
@@ -2159,6 +2178,15 @@ void translation_unit_visitor::add_enum(std::unique_ptr<enum_> &&e)
|
||||
|
||||
diagram().add(p, std::move(e));
|
||||
}
|
||||
else if ((config().generate_packages() &&
|
||||
config().package_type() == config::package_type_t::kModule)) {
|
||||
|
||||
const auto module_path = config().make_module_relative(e->module());
|
||||
|
||||
common::model::path p{module_path, common::model::path_type::kModule};
|
||||
|
||||
diagram().add(p, std::move(e));
|
||||
}
|
||||
else {
|
||||
diagram().add(e->path(), std::move(e));
|
||||
}
|
||||
@@ -2178,6 +2206,15 @@ void translation_unit_visitor::add_concept(std::unique_ptr<concept_> &&c)
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
}
|
||||
else if ((config().generate_packages() &&
|
||||
config().package_type() == config::package_type_t::kModule)) {
|
||||
|
||||
const auto module_path = config().make_module_relative(c->module());
|
||||
|
||||
common::model::path p{module_path, common::model::path_type::kModule};
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
}
|
||||
else {
|
||||
diagram().add(c->path(), std::move(c));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/class_diagram/visitor/translation_unit_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -477,7 +477,7 @@ private:
|
||||
|
||||
template_builder template_builder_;
|
||||
|
||||
std::map<common::model::diagram_element::id_t,
|
||||
std::map<common::id_t,
|
||||
std::unique_ptr<clanguml::class_diagram::model::class_>>
|
||||
forward_declarations_;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/options/cli_handler.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -384,14 +384,13 @@ runtime_config cli_handler::get_runtime_config() const
|
||||
|
||||
cli_flow_t cli_handler::print_version()
|
||||
{
|
||||
ostr_ << "clang-uml " << clanguml::version::CLANG_UML_VERSION << std::endl;
|
||||
ostr_ << "Copyright (C) 2021-2023 Bartek Kryza <bkryza@gmail.com>"
|
||||
<< std::endl;
|
||||
ostr_ << util::get_os_name() << std::endl;
|
||||
ostr_ << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n';
|
||||
ostr_ << "Copyright (C) 2021-2024 Bartek Kryza <bkryza@gmail.com>" << '\n';
|
||||
ostr_ << util::get_os_name() << '\n';
|
||||
ostr_ << "Built against LLVM/Clang libraries version: "
|
||||
<< LLVM_VERSION_STRING << std::endl;
|
||||
<< LLVM_VERSION_STRING << '\n';
|
||||
ostr_ << "Using LLVM/Clang libraries version: "
|
||||
<< clang::getClangFullVersion() << std::endl;
|
||||
<< clang::getClangFullVersion() << '\n';
|
||||
|
||||
return cli_flow_t::kExit;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/options/cli_handler.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/clang_utils.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -887,4 +887,10 @@ clang::RawComment *get_expression_raw_comment(const clang::SourceManager &sm,
|
||||
return {};
|
||||
}
|
||||
|
||||
bool is_coroutine(const clang::FunctionDecl &decl)
|
||||
{
|
||||
const auto *body = decl.getBody();
|
||||
return clang::isa_and_nonnull<clang::CoroutineBodyStmt>(body);
|
||||
}
|
||||
|
||||
} // namespace clanguml::common
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/clang_utils.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -295,4 +295,12 @@ consume_type_context(clang::QualType type);
|
||||
clang::RawComment *get_expression_raw_comment(const clang::SourceManager &sm,
|
||||
const clang::ASTContext &context, const clang::Stmt *stmt);
|
||||
|
||||
/**
|
||||
* Check if function or method declaration is a C++20 coroutine.
|
||||
*
|
||||
* @param decl Function declaration
|
||||
* @return True, if the function is a C++20 coroutine.
|
||||
*/
|
||||
bool is_coroutine(const clang::FunctionDecl &decl);
|
||||
|
||||
} // namespace clanguml::common
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/compilation_database.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/compilation_database.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/generators.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -127,7 +127,7 @@ void generate_diagram_impl(const std::string &name,
|
||||
auto from_values = model->list_from_values();
|
||||
|
||||
for (const auto &from : from_values) {
|
||||
std::cout << from << std::endl;
|
||||
std::cout << from << '\n';
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ void generate_diagram_impl(const std::string &name,
|
||||
auto to_values = model->list_to_values();
|
||||
|
||||
for (const auto &to : to_values) {
|
||||
std::cout << "|" << to << "|" << std::endl;
|
||||
std::cout << "|" << to << "|" << '\n';
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/generators.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/json/generator.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ void to_json(nlohmann::json &j, const element &c)
|
||||
j = json{{"id", std::to_string(c.id())},
|
||||
{"name", detail::render_name(c.name())},
|
||||
{"namespace", c.get_namespace().to_string()}, {"type", c.type_name()},
|
||||
{"display_name", detail::render_name(c.full_name(false))}};
|
||||
{"display_name", detail::render_name(c.full_name(true))}};
|
||||
|
||||
if (const auto &comment = c.comment(); comment)
|
||||
j["comment"] = comment.value();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/json/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,13 +35,13 @@
|
||||
namespace clanguml::common::model {
|
||||
using nlohmann::json;
|
||||
|
||||
void to_json(nlohmann::json &j, const source_location &sl);
|
||||
void to_json(json &j, const source_location &sl);
|
||||
|
||||
void to_json(nlohmann::json &j, const element &c);
|
||||
void to_json(json &j, const element &c);
|
||||
|
||||
void to_json(nlohmann::json &j, const template_parameter &c);
|
||||
void to_json(json &j, const template_parameter &c);
|
||||
|
||||
void to_json(nlohmann::json &j, const relationship &c);
|
||||
void to_json(json &j, const relationship &c);
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
namespace clanguml::common::generators::json {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/mermaid/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/mermaid/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/nested_element_stack.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/plantuml/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/plantuml/generator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/progress_indicator.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/generators/progress_indicator.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/decorated_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/decorated_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/diagram.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/diagram.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
* @return Optional reference to a diagram element.
|
||||
*/
|
||||
virtual common::optional_ref<clanguml::common::model::diagram_element> get(
|
||||
diagram_element::id_t id) const = 0;
|
||||
common::id_t id) const = 0;
|
||||
|
||||
/**
|
||||
* Return optional reference to a diagram_element by name and namespace.
|
||||
@@ -152,10 +152,7 @@ public:
|
||||
// Disallow std::string overload
|
||||
bool should_include(const std::string &s) const = delete;
|
||||
|
||||
virtual bool has_element(const diagram_element::id_t /*id*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool has_element(const common::id_t /*id*/) const { return false; }
|
||||
|
||||
virtual bool should_include(
|
||||
const namespace_ &ns, const std::string &name) const;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/diagram_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,16 +26,16 @@ namespace clanguml::common::model {
|
||||
|
||||
diagram_element::diagram_element() = default;
|
||||
|
||||
diagram_element::id_t diagram_element::id() const { return id_; }
|
||||
common::id_t diagram_element::id() const { return id_; }
|
||||
|
||||
void diagram_element::set_id(diagram_element::id_t id) { id_ = id; }
|
||||
void diagram_element::set_id(common::id_t id) { id_ = id; }
|
||||
|
||||
std::optional<id_t> diagram_element::parent_element_id() const
|
||||
{
|
||||
return parent_element_id_;
|
||||
}
|
||||
|
||||
void diagram_element::set_parent_element_id(diagram_element::id_t id)
|
||||
void diagram_element::set_parent_element_id(common::id_t id)
|
||||
{
|
||||
parent_element_id_ = id;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/common/model/diagram_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,6 @@ namespace clanguml::common::model {
|
||||
*/
|
||||
class diagram_element : public decorated_element, public source_location {
|
||||
public:
|
||||
using id_t = int64_t;
|
||||
|
||||
diagram_element();
|
||||
|
||||
~diagram_element() override = default;
|
||||
@@ -55,14 +53,14 @@ public:
|
||||
*
|
||||
* @return Elements id.
|
||||
*/
|
||||
id_t id() const;
|
||||
common::id_t id() const;
|
||||
|
||||
/**
|
||||
* Set elements id.
|
||||
*
|
||||
* @param id Elements id.
|
||||
*/
|
||||
void set_id(id_t id);
|
||||
void set_id(common::id_t id);
|
||||
|
||||
/**
|
||||
* Get elements parent package id.
|
||||
@@ -76,7 +74,7 @@ public:
|
||||
*
|
||||
* @param id Id of parent package.
|
||||
*/
|
||||
void set_parent_element_id(diagram_element::id_t id);
|
||||
void set_parent_element_id(id_t id);
|
||||
|
||||
/**
|
||||
* @brief Return elements' diagram alias.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/diagram_filter.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -285,6 +285,47 @@ tvl::value_t namespace_filter::match(const diagram &d, const element &e) const
|
||||
return result;
|
||||
}
|
||||
|
||||
modules_filter::modules_filter(
|
||||
filter_t type, std::vector<common::string_or_regex> modules)
|
||||
: filter_visitor{type}
|
||||
, modules_{std::move(modules)}
|
||||
{
|
||||
}
|
||||
|
||||
tvl::value_t modules_filter::match(
|
||||
const diagram & /*d*/, const element &e) const
|
||||
{
|
||||
if (modules_.empty())
|
||||
return {};
|
||||
|
||||
if (!e.module().has_value())
|
||||
return {false};
|
||||
|
||||
auto module_toks =
|
||||
path::split(e.module().value(), path_type::kModule); // NOLINT
|
||||
|
||||
if (dynamic_cast<const package *>(&e) != nullptr &&
|
||||
e.get_namespace().type() == path_type::kModule) {
|
||||
module_toks.push_back(e.name());
|
||||
}
|
||||
|
||||
auto result = tvl::any_of(modules_.begin(), modules_.end(),
|
||||
[&e, &module_toks](const auto &modit) {
|
||||
if (std::holds_alternative<std::string>(modit.value())) {
|
||||
const auto &modit_str = std::get<std::string>(modit.value());
|
||||
const auto modit_toks =
|
||||
path::split(modit_str, path_type::kModule);
|
||||
|
||||
return e.module() == modit_str ||
|
||||
util::starts_with(module_toks, modit_toks);
|
||||
}
|
||||
|
||||
return std::get<common::regex>(modit.value()) %= e.module().value();
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
element_filter::element_filter(
|
||||
filter_t type, std::vector<common::string_or_regex> elements)
|
||||
: filter_visitor{type}
|
||||
@@ -534,6 +575,31 @@ tvl::value_t access_filter::match(
|
||||
[&a](const auto &access) { return a == access; });
|
||||
}
|
||||
|
||||
module_access_filter::module_access_filter(
|
||||
filter_t type, std::vector<module_access_t> access)
|
||||
: filter_visitor{type}
|
||||
, access_{std::move(access)}
|
||||
{
|
||||
}
|
||||
|
||||
tvl::value_t module_access_filter::match(
|
||||
const diagram & /*d*/, const element &e) const
|
||||
{
|
||||
if (!e.module().has_value())
|
||||
return {};
|
||||
|
||||
if (access_.empty())
|
||||
return {};
|
||||
|
||||
return tvl::any_of(
|
||||
access_.begin(), access_.end(), [&e](const auto &access) {
|
||||
if (access == module_access_t::kPublic)
|
||||
return !e.module_private();
|
||||
|
||||
return e.module_private();
|
||||
});
|
||||
}
|
||||
|
||||
context_filter::context_filter(
|
||||
filter_t type, std::vector<config::context_config> context)
|
||||
: filter_visitor{type}
|
||||
@@ -887,6 +953,12 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
add_inclusive_filter(std::make_unique<namespace_filter>(
|
||||
filter_t::kInclusive, c.include().namespaces));
|
||||
|
||||
add_inclusive_filter(std::make_unique<modules_filter>(
|
||||
filter_t::kInclusive, c.include().modules));
|
||||
|
||||
add_inclusive_filter(std::make_unique<module_access_filter>(
|
||||
filter_t::kInclusive, c.include().module_access));
|
||||
|
||||
add_inclusive_filter(std::make_unique<relationship_filter>(
|
||||
filter_t::kInclusive, c.include().relationships));
|
||||
|
||||
@@ -997,6 +1069,12 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
add_exclusive_filter(std::make_unique<namespace_filter>(
|
||||
filter_t::kExclusive, c.exclude().namespaces));
|
||||
|
||||
add_exclusive_filter(std::make_unique<modules_filter>(
|
||||
filter_t::kExclusive, c.exclude().modules));
|
||||
|
||||
add_exclusive_filter(std::make_unique<module_access_filter>(
|
||||
filter_t::kExclusive, c.exclude().module_access));
|
||||
|
||||
add_exclusive_filter(std::make_unique<paths_filter>(
|
||||
filter_t::kExclusive, c.root_directory(), c.exclude().paths));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/diagram_filter.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -154,6 +154,21 @@ private:
|
||||
std::vector<common::namespace_or_regex> namespaces_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Match diagram elements to a set of specified modules or
|
||||
* module regex patterns.
|
||||
*/
|
||||
struct modules_filter : public filter_visitor {
|
||||
modules_filter(filter_t type, std::vector<common::string_or_regex> modules);
|
||||
|
||||
~modules_filter() override = default;
|
||||
|
||||
tvl::value_t match(const diagram &d, const element &e) const override;
|
||||
|
||||
private:
|
||||
std::vector<common::string_or_regex> modules_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Match element's name to a set of names or regex patterns.
|
||||
*/
|
||||
@@ -442,6 +457,20 @@ private:
|
||||
std::vector<access_t> access_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Match diagram elements based on module access (public or private).
|
||||
*/
|
||||
struct module_access_filter : public filter_visitor {
|
||||
module_access_filter(filter_t type, std::vector<module_access_t> access);
|
||||
|
||||
~module_access_filter() override = default;
|
||||
|
||||
tvl::value_t match(const diagram &d, const element &a) const override;
|
||||
|
||||
private:
|
||||
std::vector<module_access_t> access_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Match diagram elements which are in within a 'radius' distance relationship
|
||||
* to any of the elements specified in context.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,9 @@
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
element::element(namespace_ using_namespace)
|
||||
: using_namespace_{std::move(using_namespace)}
|
||||
element::element(namespace_ using_namespace, path_type pt)
|
||||
: ns_{pt}
|
||||
, using_namespace_{std::move(using_namespace)}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/element.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ namespace clanguml::common::model {
|
||||
*/
|
||||
class element : public diagram_element {
|
||||
public:
|
||||
element(namespace_ using_namespace);
|
||||
element(namespace_ using_namespace, path_type pt = path_type::kNamespace);
|
||||
|
||||
~element() override = default;
|
||||
|
||||
@@ -87,13 +87,47 @@ public:
|
||||
*/
|
||||
const namespace_ &path() const { return ns_; }
|
||||
|
||||
/**
|
||||
* Set elements owning module.
|
||||
*
|
||||
* @param module C++20 module.
|
||||
*/
|
||||
void set_module(const std::string &module) { module_ = module; }
|
||||
|
||||
/**
|
||||
* Return elements owning module, if any.
|
||||
*
|
||||
* @return C++20 module.
|
||||
*/
|
||||
std::optional<std::string> module() const { return module_; }
|
||||
|
||||
/**
|
||||
* Set whether the element is in a private module
|
||||
*
|
||||
* @param module C++20 module.
|
||||
*/
|
||||
void set_module_private(const bool module_private)
|
||||
{
|
||||
module_private_ = module_private;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the element is in a private module.
|
||||
*
|
||||
* @return C++20 module.
|
||||
*/
|
||||
bool module_private() const { return module_private_; }
|
||||
|
||||
/**
|
||||
* Return elements full name.
|
||||
*
|
||||
* @return Fully qualified elements name.
|
||||
*/
|
||||
std::string full_name(bool /*relative*/) const override
|
||||
std::string full_name(bool relative) const override
|
||||
{
|
||||
if (relative)
|
||||
return name();
|
||||
|
||||
return name_and_ns();
|
||||
}
|
||||
|
||||
@@ -120,5 +154,7 @@ public:
|
||||
private:
|
||||
namespace_ ns_;
|
||||
namespace_ using_namespace_;
|
||||
std::optional<std::string> module_;
|
||||
bool module_private_{false};
|
||||
};
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/element_view.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,8 +58,7 @@ public:
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
common::optional_ref<T> get(
|
||||
clanguml::common::model::diagram_element::id_t id) const
|
||||
common::optional_ref<T> get(clanguml::common::id_t id) const
|
||||
{
|
||||
for (const auto &e : elements_) {
|
||||
if (e.get().id() == id) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/enums.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,6 +70,19 @@ std::string to_string(access_t a)
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(module_access_t a)
|
||||
{
|
||||
switch (a) {
|
||||
case module_access_t::kPublic:
|
||||
return "public";
|
||||
case module_access_t::kPrivate:
|
||||
return "private";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(message_t r)
|
||||
{
|
||||
switch (r) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/enums.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ namespace clanguml::common::model {
|
||||
|
||||
enum class diagram_t { kClass, kSequence, kPackage, kInclude };
|
||||
|
||||
enum class module_access_t { kPublic, kPrivate };
|
||||
enum class access_t { kPublic, kProtected, kPrivate, kNone };
|
||||
|
||||
enum class relationship_t {
|
||||
@@ -77,6 +78,8 @@ std::string to_string(relationship_t r);
|
||||
|
||||
std::string to_string(access_t r);
|
||||
|
||||
std::string to_string(module_access_t r);
|
||||
|
||||
std::string to_string(message_t m);
|
||||
|
||||
std::string to_string(diagram_t r);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/namespace.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/namespace.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/nested_trait.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/package.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <sstream>
|
||||
|
||||
namespace clanguml::common::model {
|
||||
package::package(const common::model::namespace_ &using_namespace)
|
||||
: element{using_namespace}
|
||||
package::package(const common::model::namespace_ &using_namespace, path_type pt)
|
||||
: element{using_namespace, pt}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/package.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,8 @@ class package : public element,
|
||||
public stylable_element,
|
||||
public nested_trait<element, path> {
|
||||
public:
|
||||
package(const common::model::path &using_namespace);
|
||||
package(const common::model::path &using_namespace,
|
||||
path_type pt = path_type::kNamespace);
|
||||
|
||||
package(const package &) = delete;
|
||||
package(package &&) = default;
|
||||
|
||||
38
src/common/model/path.cc
Normal file
38
src/common/model/path.cc
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file src/common/model/path.cc
|
||||
*
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "path.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
std::string to_string(const path_type pt)
|
||||
{
|
||||
switch (pt) {
|
||||
case path_type::kModule:
|
||||
return "module";
|
||||
case path_type::kNamespace:
|
||||
return "namespace";
|
||||
case path_type::kFilesystem:
|
||||
return "directory";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace clanguml::common::model
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/path.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,13 @@ namespace clanguml::common::model {
|
||||
* a nested set of namespaces or nested set of directories.
|
||||
*/
|
||||
enum class path_type {
|
||||
kNamespace, /*!< Namespace path */
|
||||
kFilesystem /*!< Filesystem path */
|
||||
kNamespace, /*!< Namespace path */
|
||||
kFilesystem, /*!< Filesystem path */
|
||||
kModule /*!< Module path */
|
||||
};
|
||||
|
||||
std::string to_string(path_type pt);
|
||||
|
||||
/**
|
||||
* @brief Diagram path
|
||||
*
|
||||
@@ -49,11 +52,13 @@ class path {
|
||||
*
|
||||
* @return Path separator
|
||||
*/
|
||||
const char *separator() const
|
||||
static const char *separator(path_type pt)
|
||||
{
|
||||
switch (path_type_) {
|
||||
switch (pt) {
|
||||
case path_type::kNamespace:
|
||||
return "::";
|
||||
case path_type::kModule:
|
||||
return ".";
|
||||
case path_type::kFilesystem:
|
||||
#ifdef _WIN32
|
||||
return "\\";
|
||||
@@ -65,9 +70,38 @@ class path {
|
||||
return "::";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path separator based on the type of the instance path.
|
||||
*
|
||||
* @return Path separator
|
||||
*/
|
||||
const char *separator() const { return separator(path_type_); }
|
||||
|
||||
public:
|
||||
using container_type = std::vector<std::string>;
|
||||
|
||||
static container_type split(
|
||||
const std::string &ns, path_type pt = path_type::kNamespace)
|
||||
{
|
||||
container_type result;
|
||||
if (pt == path_type::kModule) {
|
||||
auto path_toks = util::split(ns, separator(pt));
|
||||
for (const auto &pt : path_toks) {
|
||||
const auto subtoks = util::split(pt, ":");
|
||||
if (subtoks.size() == 2) {
|
||||
result.push_back(subtoks.at(0));
|
||||
result.push_back(fmt::format(":{}", subtoks.at(1)));
|
||||
}
|
||||
else
|
||||
result.push_back(subtoks.at(0));
|
||||
}
|
||||
}
|
||||
else
|
||||
result = util::split(ns, separator(pt));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
path(path_type pt = path_type::kNamespace)
|
||||
: path_type_{pt}
|
||||
{
|
||||
@@ -79,7 +113,7 @@ public:
|
||||
if (ns.empty())
|
||||
return;
|
||||
|
||||
path_ = util::split(ns, separator());
|
||||
path_ = split(ns, pt);
|
||||
}
|
||||
|
||||
virtual ~path() = default;
|
||||
@@ -103,7 +137,8 @@ public:
|
||||
return *this;
|
||||
|
||||
if (path_type_ != right.path_type_)
|
||||
throw std::runtime_error("");
|
||||
throw std::runtime_error(
|
||||
"Cannot assign a path to a path with another path type.");
|
||||
|
||||
path_type_ = right.path_type_;
|
||||
path_ = right.path_;
|
||||
@@ -160,7 +195,14 @@ public:
|
||||
*/
|
||||
std::string to_string() const
|
||||
{
|
||||
return fmt::format("{}", fmt::join(path_, std::string{separator()}));
|
||||
auto result =
|
||||
fmt::format("{}", fmt::join(path_, std::string{separator()}));
|
||||
|
||||
if (path_type_ == path_type::kModule) {
|
||||
util::replace_all(result, ".:", ":");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +228,7 @@ public:
|
||||
path operator|(const path &right) const
|
||||
{
|
||||
path res{*this};
|
||||
res.path_type_ = right.path_type_;
|
||||
res.append(right);
|
||||
return res;
|
||||
}
|
||||
@@ -383,6 +426,8 @@ public:
|
||||
*/
|
||||
path_type type() const { return path_type_; }
|
||||
|
||||
const container_type &tokens() const { return path_; }
|
||||
|
||||
private:
|
||||
path_type path_type_;
|
||||
container_type path_;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/relationship.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/relationship.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/source_file.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/source_file.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -117,6 +117,20 @@ public:
|
||||
*/
|
||||
source_file_t type() const { return type_; }
|
||||
|
||||
/**
|
||||
* Set whether the file is a system header
|
||||
*
|
||||
* @param is_system Whether the file is a system header
|
||||
*/
|
||||
void set_system_header(bool is_system) { is_system_header_ = is_system; }
|
||||
|
||||
/**
|
||||
* Is the file a system header?
|
||||
*
|
||||
* @return True, if the source file is a system header
|
||||
*/
|
||||
bool is_system_header() const { return is_system_header_; }
|
||||
|
||||
/**
|
||||
* Get the source file's parent path.
|
||||
*
|
||||
@@ -185,6 +199,7 @@ private:
|
||||
filesystem_path path_{path_type::kFilesystem};
|
||||
source_file_t type_{source_file_t::kDirectory};
|
||||
bool is_absolute_{false};
|
||||
bool is_system_header_{false};
|
||||
};
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/source_location.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/source_location.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/stylable_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/stylable_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/template_parameter.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/template_parameter.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/template_trait.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/template_trait.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/model/tvl.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/types.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/types.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/ast_id_mapper.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/ast_id_mapper.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ namespace clanguml::common::visitor {
|
||||
*/
|
||||
class ast_id_mapper {
|
||||
public:
|
||||
using id_t = common::model::diagram_element::id_t;
|
||||
using id_t = common::id_t;
|
||||
|
||||
ast_id_mapper() = default;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/clang_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/clang_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/comment_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/comment_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/plain_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/comment/plain_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/translation_unit_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
#include "comment/clang_visitor.h"
|
||||
#include "comment/plain_visitor.h"
|
||||
#include "common/clang_utils.h"
|
||||
|
||||
#include <clang/AST/Expr.h>
|
||||
#include <clang/Basic/Module.h>
|
||||
|
||||
namespace clanguml::common::visitor {
|
||||
|
||||
@@ -161,4 +165,25 @@ void translation_unit_visitor::set_source_location(
|
||||
element.set_location_id(location.getHashValue());
|
||||
}
|
||||
|
||||
void translation_unit_visitor::set_owning_module(
|
||||
const clang::Decl &decl, clanguml::common::model::element &element)
|
||||
{
|
||||
if (const clang::Module *module = decl.getOwningModule();
|
||||
module != nullptr) {
|
||||
std::string module_name = module->Name;
|
||||
bool is_private{false};
|
||||
#if LLVM_VERSION_MAJOR < 15
|
||||
is_private =
|
||||
module->Kind == clang::Module::ModuleKind::PrivateModuleFragment;
|
||||
#else
|
||||
is_private = module->isPrivateModule();
|
||||
#endif
|
||||
if (is_private) {
|
||||
// Clang just maps private modules names to "<private>"
|
||||
module_name = module->getTopLevelModule()->Name;
|
||||
}
|
||||
element.set_module(module_name);
|
||||
element.set_module_private(is_private);
|
||||
}
|
||||
}
|
||||
} // namespace clanguml::common::visitor
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/common/visitor/translation_unit_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,9 +18,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "comment/comment_visitor.h"
|
||||
#include "common/model/element.h"
|
||||
#include "common/model/source_location.h"
|
||||
#include "config/config.h"
|
||||
|
||||
#include <clang/AST/Comment.h>
|
||||
#include <clang/AST/RawCommentList.h>
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
|
||||
#include <deque>
|
||||
@@ -31,9 +34,8 @@
|
||||
|
||||
namespace clanguml::common::visitor {
|
||||
|
||||
using found_relationships_t =
|
||||
std::vector<std::pair<clanguml::common::model::diagram_element::id_t,
|
||||
common::model::relationship_t>>;
|
||||
using found_relationships_t = std::vector<
|
||||
std::pair<clanguml::common::id_t, common::model::relationship_t>>;
|
||||
|
||||
/**
|
||||
* @brief Diagram translation unit visitor base class
|
||||
@@ -100,6 +102,9 @@ public:
|
||||
void set_source_location(const clang::SourceLocation &location,
|
||||
clanguml::common::model::source_location &element);
|
||||
|
||||
void set_owning_module(
|
||||
const clang::Decl &decl, clanguml::common::model::element &element);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Process comment directives in comment attached to a declaration
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/config.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -147,6 +147,8 @@ std::string to_string(package_type_t pt)
|
||||
return "namespace";
|
||||
case package_type_t::kDirectory:
|
||||
return "directory";
|
||||
case package_type_t::kModule:
|
||||
return "module";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
@@ -187,6 +189,7 @@ void inheritable_diagram_options::inherit(
|
||||
{
|
||||
glob.override(parent.glob);
|
||||
using_namespace.override(parent.using_namespace);
|
||||
using_module.override(parent.using_module);
|
||||
include_relations_also_as_members.override(
|
||||
parent.include_relations_also_as_members);
|
||||
include.override(parent.include);
|
||||
@@ -214,6 +217,7 @@ void inheritable_diagram_options::inherit(
|
||||
parent.generate_condition_statements);
|
||||
debug_mode.override(parent.debug_mode);
|
||||
generate_metadata.override(parent.generate_metadata);
|
||||
type_aliases.override(parent.type_aliases);
|
||||
}
|
||||
|
||||
std::string inheritable_diagram_options::simplify_template_type(
|
||||
@@ -229,6 +233,12 @@ std::string inheritable_diagram_options::simplify_template_type(
|
||||
return full_name;
|
||||
}
|
||||
|
||||
bool inheritable_diagram_options::generate_fully_qualified_name() const
|
||||
{
|
||||
return generate_packages() &&
|
||||
(package_type() == package_type_t::kNamespace);
|
||||
}
|
||||
|
||||
std::vector<std::string> diagram::get_translation_units() const
|
||||
{
|
||||
std::vector<std::string> translation_units{};
|
||||
@@ -264,6 +274,29 @@ std::filesystem::path diagram::make_path_relative(
|
||||
return relative(p, root_directory()).lexically_normal().string();
|
||||
}
|
||||
|
||||
std::vector<std::string> diagram::make_module_relative(
|
||||
const std::optional<std::string> &maybe_module) const
|
||||
{
|
||||
if (!maybe_module)
|
||||
return {};
|
||||
|
||||
auto module_path = common::model::path(
|
||||
maybe_module.value(), common::model::path_type::kModule)
|
||||
.tokens();
|
||||
|
||||
if (using_module.has_value) {
|
||||
auto using_module_path = common::model::path(
|
||||
using_module(), common::model::path_type::kModule)
|
||||
.tokens();
|
||||
|
||||
if (util::starts_with(module_path, using_module_path)) {
|
||||
util::remove_prefix(module_path, using_module_path);
|
||||
}
|
||||
}
|
||||
|
||||
return module_path;
|
||||
}
|
||||
|
||||
std::optional<std::string> diagram::get_together_group(
|
||||
const std::string &full_name) const
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/config.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "class_diagram/model/diagram.h"
|
||||
#include "common/model/enums.h"
|
||||
#include "common/types.h"
|
||||
#include "option.h"
|
||||
@@ -87,7 +86,8 @@ std::string to_string(callee_type mt);
|
||||
/*! How packages in diagrams should be generated */
|
||||
enum class package_type_t {
|
||||
kNamespace, /*!< From namespaces */
|
||||
kDirectory /*!< From directories */
|
||||
kDirectory, /*!< From directories */
|
||||
kModule /*!< From modules */
|
||||
};
|
||||
|
||||
std::string to_string(package_type_t mt);
|
||||
@@ -180,6 +180,35 @@ struct filter {
|
||||
*/
|
||||
std::vector<common::namespace_or_regex> namespaces;
|
||||
|
||||
/*! @brief Modules filter
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```yaml
|
||||
* include
|
||||
* modules:
|
||||
* - app.module1
|
||||
* - r: ".*internal.*"
|
||||
* ```
|
||||
*/
|
||||
std::vector<common::string_or_regex> modules;
|
||||
|
||||
/*! @brief Access type filter
|
||||
*
|
||||
* This filter allows to filter class members methods based on their access:
|
||||
* - public
|
||||
* - private
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```yaml
|
||||
* include:
|
||||
* module_access:
|
||||
* - public
|
||||
* ```
|
||||
*/
|
||||
std::vector<common::model::module_access_t> module_access;
|
||||
|
||||
/*! @brief Elements filter
|
||||
*
|
||||
* Example:
|
||||
@@ -231,8 +260,8 @@ struct filter {
|
||||
*
|
||||
* ```yaml
|
||||
* include:
|
||||
* relationships:
|
||||
* - inheritance
|
||||
* access:
|
||||
* - public
|
||||
* ```
|
||||
*/
|
||||
std::vector<common::model::access_t> access;
|
||||
@@ -456,6 +485,18 @@ struct inheritable_diagram_options {
|
||||
|
||||
std::string simplify_template_type(std::string full_name) const;
|
||||
|
||||
/**
|
||||
* @brief Whether the diagram element should be fully qualified in diagram
|
||||
*
|
||||
* This method determines whether an elements' name should include
|
||||
* fully qualified namespace name (however relative to using_namespace), or
|
||||
* whether it should just contain it's name. This depends on whether the
|
||||
* diagram has packages and if they are based on namespaces or sth else.
|
||||
*
|
||||
* @return True, if element should include it's namespace
|
||||
*/
|
||||
bool generate_fully_qualified_name() const;
|
||||
|
||||
/**
|
||||
* @brief Get reference to `relative_to` diagram config option
|
||||
*
|
||||
@@ -470,6 +511,7 @@ struct inheritable_diagram_options {
|
||||
|
||||
option<std::vector<std::string>> glob{"glob"};
|
||||
option<common::model::namespace_> using_namespace{"using_namespace"};
|
||||
option<std::string> using_module{"using_module"};
|
||||
option<bool> include_relations_also_as_members{
|
||||
"include_relations_also_as_members", true};
|
||||
option<filter> include{"include"};
|
||||
@@ -496,7 +538,8 @@ struct inheritable_diagram_options {
|
||||
option<std::filesystem::path> base_directory{"__parent_path"};
|
||||
option<bool> generate_system_headers{"generate_system_headers", false};
|
||||
option<relationship_hints_t> relationship_hints{"relationship_hints"};
|
||||
option<type_aliases_t> type_aliases{"type_aliases"};
|
||||
option<type_aliases_t> type_aliases{
|
||||
"type_aliases", option_inherit_mode::kAppend};
|
||||
option<comment_parser_t> comment_parser{
|
||||
"comment_parser", comment_parser_t::plain};
|
||||
option<bool> combine_free_functions_into_file_participants{
|
||||
@@ -553,6 +596,15 @@ struct diagram : public inheritable_diagram_options {
|
||||
std::filesystem::path make_path_relative(
|
||||
const std::filesystem::path &p) const;
|
||||
|
||||
/**
|
||||
* @brief Make module path relative to `using_module` configuration option
|
||||
*
|
||||
* @param p Input path
|
||||
* @return Relative path
|
||||
*/
|
||||
std::vector<std::string> make_module_relative(
|
||||
const std::optional<std::string> &maybe_module) const;
|
||||
|
||||
/**
|
||||
* @brief Returns absolute path of the `relative_to` option
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/diagram_templates.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/diagram_templates.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/option.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,14 +17,28 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml {
|
||||
namespace config {
|
||||
|
||||
template <typename T> void append_value(T &l, const T &r) { l = r; }
|
||||
|
||||
template <typename T>
|
||||
void append_value(std::vector<T> &l, const std::vector<T> &r)
|
||||
{
|
||||
l.insert(std::end(l), r.begin(), r.end());
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
void append_value(std::map<K, V> &l, const std::map<K, V> &r)
|
||||
{
|
||||
l.insert(r.begin(), r.end());
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible option inheritance methods from top level to diagram level.
|
||||
*/
|
||||
@@ -102,9 +116,7 @@ template <typename T> struct option {
|
||||
has_value = true;
|
||||
}
|
||||
else if (!is_declared && o.is_declared) {
|
||||
value = o.value;
|
||||
is_declared = true;
|
||||
has_value = true;
|
||||
set(o.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/schema.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,16 +58,13 @@ types:
|
||||
package_type_t: !variant
|
||||
- namespace
|
||||
- directory
|
||||
- module
|
||||
member_order_t: !variant
|
||||
- lexical
|
||||
- as_is
|
||||
regex_t:
|
||||
r: string
|
||||
regex_or_string_t: [string, regex_t]
|
||||
namespaces_filter_t:
|
||||
namespaces: [regex_or_string_t]
|
||||
elements_filter_t:
|
||||
elements: [regex_or_string_t]
|
||||
element_types_filter_t: !variant
|
||||
- class
|
||||
- enum
|
||||
@@ -94,6 +91,9 @@ types:
|
||||
- public
|
||||
- protected
|
||||
- private
|
||||
module_access_filter_t: !variant
|
||||
- public
|
||||
- private
|
||||
method_type_filter_t: !variant
|
||||
- constructor
|
||||
- destructor
|
||||
@@ -121,10 +121,12 @@ types:
|
||||
- context_filter_match_t
|
||||
filter_t:
|
||||
namespaces: !optional [regex_or_string_t]
|
||||
modules: !optional [regex_or_string_t]
|
||||
elements: !optional [regex_or_string_t]
|
||||
element_types: !optional [element_types_filter_t]
|
||||
relationships: !optional [relationship_filter_t]
|
||||
access: !optional [access_filter_t]
|
||||
module_access: !optional [module_access_filter_t]
|
||||
subclasses: !optional [regex_or_string_t]
|
||||
parents: !optional [regex_or_string_t]
|
||||
specializations: !optional [regex_or_string_t]
|
||||
@@ -164,6 +166,7 @@ types:
|
||||
cmd: !optional string
|
||||
relative_to: !optional string
|
||||
using_namespace: !optional [string, [string]]
|
||||
using_module: !optional string
|
||||
generate_metadata: !optional bool
|
||||
title: !optional string
|
||||
#
|
||||
@@ -202,6 +205,7 @@ types:
|
||||
after: !optional [string]
|
||||
cmd: !optional string
|
||||
relative_to: !optional string
|
||||
type_aliases: !optional map_t<string;string>
|
||||
using_namespace: !optional [string, [string]]
|
||||
generate_metadata: !optional bool
|
||||
title: !optional string
|
||||
@@ -242,6 +246,7 @@ types:
|
||||
cmd: !optional string
|
||||
relative_to: !optional string
|
||||
using_namespace: !optional [string, [string]]
|
||||
using_module: !optional string
|
||||
generate_metadata: !optional bool
|
||||
title: !optional string
|
||||
#
|
||||
@@ -321,6 +326,7 @@ root:
|
||||
cmd: !optional string
|
||||
relative_to: !optional string
|
||||
using_namespace: !optional [string, [string]]
|
||||
using_module: !optional string
|
||||
generate_metadata: !optional bool
|
||||
#
|
||||
# Inheritable custom options
|
||||
@@ -337,6 +343,7 @@ root:
|
||||
package_type: !optional package_type_t
|
||||
generate_template_argument_dependencies: !optional bool
|
||||
skip_redundant_dependencies: !optional bool
|
||||
type_aliases: !optional map_t<string;string>
|
||||
)";
|
||||
|
||||
} // namespace clanguml::config
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/yaml_decoders.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ namespace YAML {
|
||||
using clanguml::common::namespace_or_regex;
|
||||
using clanguml::common::string_or_regex;
|
||||
using clanguml::common::model::access_t;
|
||||
using clanguml::common::model::module_access_t;
|
||||
using clanguml::common::model::relationship_t;
|
||||
using clanguml::config::callee_type;
|
||||
using clanguml::config::class_diagram;
|
||||
@@ -133,6 +134,8 @@ void get_option<package_type_t>(
|
||||
option.set(package_type_t::kNamespace);
|
||||
else if (val == "directory")
|
||||
option.set(package_type_t::kDirectory);
|
||||
else if (val == "module")
|
||||
option.set(package_type_t::kModule);
|
||||
else
|
||||
throw std::runtime_error(
|
||||
"Invalid generate_method_arguments value: " + val);
|
||||
@@ -239,6 +242,23 @@ template <> struct convert<access_t> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config module_access_t decoder
|
||||
//
|
||||
template <> struct convert<module_access_t> {
|
||||
static bool decode(const Node &node, module_access_t &rhs)
|
||||
{
|
||||
if (node.as<std::string>() == "public")
|
||||
rhs = module_access_t::kPublic;
|
||||
else if (node.as<std::string>() == "private")
|
||||
rhs = module_access_t::kPrivate;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config method_type decoder
|
||||
//
|
||||
@@ -475,6 +495,16 @@ template <> struct convert<filter> {
|
||||
rhs.namespaces.push_back({ns});
|
||||
}
|
||||
|
||||
if (node["modules"]) {
|
||||
auto module_list = node["modules"].as<decltype(rhs.modules)>();
|
||||
for (const auto &ns : module_list)
|
||||
rhs.modules.push_back({ns});
|
||||
}
|
||||
|
||||
if (node["module_access"])
|
||||
rhs.module_access =
|
||||
node["module_access"].as<decltype(rhs.module_access)>();
|
||||
|
||||
if (node["relationships"])
|
||||
rhs.relationships =
|
||||
node["relationships"].as<decltype(rhs.relationships)>();
|
||||
@@ -567,6 +597,7 @@ template <typename T> bool decode_diagram(const Node &node, T &rhs)
|
||||
// Decode options common for all diagrams
|
||||
get_option(node, rhs.glob);
|
||||
get_option(node, rhs.using_namespace);
|
||||
get_option(node, rhs.using_module);
|
||||
get_option(node, rhs.include);
|
||||
get_option(node, rhs.exclude);
|
||||
get_option(node, rhs.puml);
|
||||
@@ -632,6 +663,7 @@ template <> struct convert<sequence_diagram> {
|
||||
get_option(node, rhs.generate_method_arguments);
|
||||
get_option(node, rhs.generate_message_comments);
|
||||
get_option(node, rhs.message_comment_width);
|
||||
get_option(node, rhs.type_aliases);
|
||||
|
||||
get_option(node, rhs.get_relative_to());
|
||||
|
||||
@@ -781,6 +813,7 @@ template <> struct convert<config> {
|
||||
{
|
||||
get_option(node, rhs.glob);
|
||||
get_option(node, rhs.using_namespace);
|
||||
get_option(node, rhs.using_module);
|
||||
get_option(node, rhs.output_directory);
|
||||
get_option(node, rhs.compilation_database_dir);
|
||||
get_option(node, rhs.add_compile_flags);
|
||||
@@ -804,6 +837,7 @@ template <> struct convert<config> {
|
||||
get_option(node, rhs.generate_condition_statements);
|
||||
get_option(node, rhs.generate_message_comments);
|
||||
get_option(node, rhs.message_comment_width);
|
||||
get_option(node, rhs.type_aliases);
|
||||
|
||||
rhs.base_directory.set(node["__parent_path"].as<std::string>());
|
||||
get_option(node, rhs.get_relative_to());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/config/yaml_emitters.cc
|
||||
*
|
||||
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,6 +69,12 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const access_t &a)
|
||||
return out;
|
||||
}
|
||||
|
||||
YAML::Emitter &operator<<(YAML::Emitter &out, const module_access_t &a)
|
||||
{
|
||||
out << to_string(a);
|
||||
return out;
|
||||
}
|
||||
|
||||
YAML::Emitter &operator<<(YAML::Emitter &out, const diagram_t &d)
|
||||
{
|
||||
out << to_string(d);
|
||||
@@ -122,6 +128,10 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const filter &f)
|
||||
out << YAML::BeginMap;
|
||||
if (!f.namespaces.empty())
|
||||
out << YAML::Key << "namespaces" << YAML::Value << f.namespaces;
|
||||
if (!f.modules.empty())
|
||||
out << YAML::Key << "modules" << YAML::Value << f.modules;
|
||||
if (!f.module_access.empty())
|
||||
out << YAML::Key << "module_access" << YAML::Value << f.module_access;
|
||||
if (!f.access.empty())
|
||||
out << YAML::Key << "access" << YAML::Value << f.access;
|
||||
if (!f.context.empty())
|
||||
@@ -308,6 +318,7 @@ YAML::Emitter &operator<<(
|
||||
out << c.puml;
|
||||
out << c.relative_to;
|
||||
out << c.using_namespace;
|
||||
out << c.using_module;
|
||||
out << c.generate_metadata;
|
||||
|
||||
if (const auto *cd = dynamic_cast<const class_diagram *>(&c);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user