Added JSON test case stubs for all class diagram test cases
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
using nlohmann::json;
|
||||
|
||||
void to_json(nlohmann::json &j, const class_element &c)
|
||||
{
|
||||
j["name"] = c.name();
|
||||
@@ -113,6 +114,11 @@ generator::generator(diagram_config &config, diagram_model &model)
|
||||
|
||||
void generator::generate(std::ostream &ostr) const
|
||||
{
|
||||
if (m_config.using_namespace)
|
||||
json_["using_namespace"] = m_config.using_namespace().to_string();
|
||||
json_["name"] = m_model.name();
|
||||
json_["diagram_type"] = "class";
|
||||
|
||||
json_["elements"] = std::vector<nlohmann::json>{};
|
||||
json_["relationships"] = std::vector<nlohmann::json>{};
|
||||
|
||||
@@ -120,9 +126,6 @@ void generator::generate(std::ostream &ostr) const
|
||||
|
||||
generate_relationships(json_);
|
||||
|
||||
json_["name"] = m_model.name();
|
||||
json_["diagram_type"] = "class";
|
||||
|
||||
ostr << json_;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
void generate_relationships(const package &p, nlohmann::json &parent) const;
|
||||
|
||||
private:
|
||||
std::string render_name(std::string name) const;
|
||||
|
||||
mutable nlohmann::json json_;
|
||||
};
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ bool translation_unit_visitor::VisitClassTemplateDecl(
|
||||
const auto id = common::to_id(cls_full_name);
|
||||
|
||||
c_ptr->set_id(id);
|
||||
c_ptr->is_template(true);
|
||||
|
||||
set_ast_local_id(cls->getID(), id);
|
||||
|
||||
|
||||
@@ -21,6 +21,15 @@
|
||||
namespace clanguml::common::model {
|
||||
using nlohmann::json;
|
||||
|
||||
namespace detail {
|
||||
std::string render_name(std::string name)
|
||||
{
|
||||
util::replace_all(name, "##", "::");
|
||||
|
||||
return name;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
void to_json(nlohmann::json &j, const source_location &sl)
|
||||
{
|
||||
j = json{{"file", sl.file_relative()}, {"line", sl.line()}};
|
||||
@@ -28,9 +37,10 @@ void to_json(nlohmann::json &j, const source_location &sl)
|
||||
|
||||
void to_json(nlohmann::json &j, const element &c)
|
||||
{
|
||||
j = json{{"id", std::to_string(c.id())}, {"name", c.name()},
|
||||
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", c.full_name(false)}};
|
||||
{"display_name", detail::render_name(c.full_name(false))}};
|
||||
|
||||
if (const auto &comment = c.comment(); comment)
|
||||
j["comment"] = comment.value();
|
||||
|
||||
Reference in New Issue
Block a user