Added debug_mode config option
This commit is contained in:
@@ -73,6 +73,8 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
|||||||
|
|
||||||
assert(!full_name.empty());
|
assert(!full_name.empty());
|
||||||
|
|
||||||
|
print_debug(c, ostr);
|
||||||
|
|
||||||
ostr << class_type << " \""
|
ostr << class_type << " \""
|
||||||
<< m_config.simplify_template_type(render_name(full_name));
|
<< m_config.simplify_template_type(render_name(full_name));
|
||||||
|
|
||||||
@@ -84,6 +86,8 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
|||||||
|
|
||||||
void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
|
void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
|
||||||
{
|
{
|
||||||
|
print_debug(e, ostr);
|
||||||
|
|
||||||
if (m_config.generate_packages())
|
if (m_config.generate_packages())
|
||||||
ostr << "enum"
|
ostr << "enum"
|
||||||
<< " \"" << e.name();
|
<< " \"" << e.name();
|
||||||
@@ -127,6 +131,8 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
|||||||
if (!m_model.should_include(m.access()))
|
if (!m_model.should_include(m.access()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
print_debug(m, ostr);
|
||||||
|
|
||||||
if (m.is_pure_virtual())
|
if (m.is_pure_virtual())
|
||||||
ostr << "{abstract} ";
|
ostr << "{abstract} ";
|
||||||
|
|
||||||
@@ -237,6 +243,8 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
|||||||
rendered_relations.find(m.name()) != rendered_relations.end())
|
rendered_relations.find(m.name()) != rendered_relations.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
print_debug(m, ostr);
|
||||||
|
|
||||||
if (m.is_static())
|
if (m.is_static())
|
||||||
ostr << "{static} ";
|
ostr << "{static} ";
|
||||||
|
|
||||||
@@ -424,6 +432,7 @@ void generator::generate(const package &p, std::ostream &ostr) const
|
|||||||
// Don't generate packages from namespaces filtered out by
|
// Don't generate packages from namespaces filtered out by
|
||||||
// using_namespace
|
// using_namespace
|
||||||
if (!uns.starts_with({p.full_name(false)})) {
|
if (!uns.starts_with({p.full_name(false)})) {
|
||||||
|
print_debug(p, ostr);
|
||||||
ostr << "package [" << p.name() << "] ";
|
ostr << "package [" << p.name() << "] ";
|
||||||
ostr << "as " << p.alias();
|
ostr << "as " << p.alias();
|
||||||
|
|
||||||
|
|||||||
@@ -140,12 +140,14 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
|||||||
|
|
||||||
// If not, check if the parent template declaration is in the model
|
// If not, check if the parent template declaration is in the model
|
||||||
if (!id_opt) {
|
if (!id_opt) {
|
||||||
local_id = parent_record_decl->getDescribedTemplate()->getID();
|
if (parent_record_decl->getDescribedTemplate() != nullptr) {
|
||||||
if (parent_record_decl->getDescribedTemplate() != nullptr)
|
local_id =
|
||||||
|
parent_record_decl->getDescribedTemplate()->getID();
|
||||||
id_opt = get_ast_local_id(local_id);
|
id_opt = get_ast_local_id(local_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (id_opt) {
|
if (id_opt) {
|
||||||
auto parent_class = diagram_.get_class(*id_opt);
|
auto parent_class = diagram_.get_class(*id_opt);
|
||||||
@@ -429,12 +431,14 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
|||||||
|
|
||||||
// If not, check if the parent template declaration is in the model
|
// If not, check if the parent template declaration is in the model
|
||||||
if (!id_opt) {
|
if (!id_opt) {
|
||||||
local_id = parent_record_decl->getDescribedTemplate()->getID();
|
if (parent_record_decl->getDescribedTemplate() != nullptr) {
|
||||||
if (parent_record_decl->getDescribedTemplate() != nullptr)
|
local_id =
|
||||||
|
parent_record_decl->getDescribedTemplate()->getID();
|
||||||
id_opt = get_ast_local_id(local_id);
|
id_opt = get_ast_local_id(local_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (id_opt) {
|
if (id_opt) {
|
||||||
// Here we have 2 options, either:
|
// Here we have 2 options, either:
|
||||||
|
|||||||
@@ -124,6 +124,14 @@ public:
|
|||||||
template <typename E>
|
template <typename E>
|
||||||
void generate_link(std::ostream &ostr, const E &e) const;
|
void generate_link(std::ostream &ostr, const E &e) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Print debug information in diagram comments
|
||||||
|
*
|
||||||
|
* @param m Diagram element to describe
|
||||||
|
* @param ostr Output stream
|
||||||
|
*/
|
||||||
|
void print_debug(
|
||||||
|
const common::model::source_location &e, std::ostream &ostr) const;
|
||||||
/**
|
/**
|
||||||
* @brief Update diagram Jinja context
|
* @brief Update diagram Jinja context
|
||||||
*
|
*
|
||||||
@@ -345,6 +353,14 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
|
|||||||
ostr << "]]";
|
ostr << "]]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename C, typename D>
|
||||||
|
void generator<C, D>::print_debug(
|
||||||
|
const common::model::source_location &e, std::ostream &ostr) const
|
||||||
|
{
|
||||||
|
if (m_config.debug_mode())
|
||||||
|
ostr << "' " << e.file() << ":" << e.line() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
template <typename DiagramModel, typename DiagramConfig,
|
template <typename DiagramModel, typename DiagramConfig,
|
||||||
typename TranslationUnitVisitor>
|
typename TranslationUnitVisitor>
|
||||||
class diagram_ast_consumer : public clang::ASTConsumer {
|
class diagram_ast_consumer : public clang::ASTConsumer {
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ void translation_unit_visitor::set_source_location(
|
|||||||
set_source_location(expr.getBeginLoc(), element);
|
set_source_location(expr.getBeginLoc(), element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void translation_unit_visitor::set_source_location(
|
||||||
|
const clang::Stmt &stmt, clanguml::common::model::source_location &element)
|
||||||
|
{
|
||||||
|
set_source_location(stmt.getBeginLoc(), element);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void translation_unit_visitor::set_source_location(
|
void translation_unit_visitor::set_source_location(
|
||||||
const clang::SourceLocation &location,
|
const clang::SourceLocation &location,
|
||||||
clanguml::common::model::source_location &element)
|
clanguml::common::model::source_location &element)
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ protected:
|
|||||||
void set_source_location(const clang::Expr &expr,
|
void set_source_location(const clang::Expr &expr,
|
||||||
clanguml::common::model::source_location &element);
|
clanguml::common::model::source_location &element);
|
||||||
|
|
||||||
|
void set_source_location(const clang::Stmt &stmt,
|
||||||
|
clanguml::common::model::source_location &element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set source location in diagram element
|
* @brief Set source location in diagram element
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ void inheritable_diagram_options::inherit(
|
|||||||
comment_parser.override(parent.comment_parser);
|
comment_parser.override(parent.comment_parser);
|
||||||
combine_free_functions_into_file_participants.override(
|
combine_free_functions_into_file_participants.override(
|
||||||
combine_free_functions_into_file_participants);
|
combine_free_functions_into_file_participants);
|
||||||
|
debug_mode.override(parent.debug_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string inheritable_diagram_options::simplify_template_type(
|
std::string inheritable_diagram_options::simplify_template_type(
|
||||||
@@ -551,6 +552,7 @@ template <typename T> bool decode_diagram(const Node &node, T &rhs)
|
|||||||
get_option(node, rhs.generate_links);
|
get_option(node, rhs.generate_links);
|
||||||
get_option(node, rhs.type_aliases);
|
get_option(node, rhs.type_aliases);
|
||||||
get_option(node, rhs.comment_parser);
|
get_option(node, rhs.comment_parser);
|
||||||
|
get_option(node, rhs.debug_mode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -734,6 +736,7 @@ template <> struct convert<config> {
|
|||||||
get_option(node, rhs.generate_links);
|
get_option(node, rhs.generate_links);
|
||||||
get_option(node, rhs.generate_system_headers);
|
get_option(node, rhs.generate_system_headers);
|
||||||
get_option(node, rhs.git);
|
get_option(node, rhs.git);
|
||||||
|
get_option(node, rhs.debug_mode);
|
||||||
rhs.base_directory.set(node["__parent_path"].as<std::string>());
|
rhs.base_directory.set(node["__parent_path"].as<std::string>());
|
||||||
get_option(node, rhs.relative_to);
|
get_option(node, rhs.relative_to);
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ struct inheritable_diagram_options {
|
|||||||
option<bool> combine_free_functions_into_file_participants{
|
option<bool> combine_free_functions_into_file_participants{
|
||||||
"combine_free_functions_into_file_participants", false};
|
"combine_free_functions_into_file_participants", false};
|
||||||
option<std::vector<std::string>> participants_order{"participants_order"};
|
option<std::vector<std::string>> participants_order{"participants_order"};
|
||||||
|
option<bool> debug_mode{"debug_mode", false};
|
||||||
|
|
||||||
void inherit(const inheritable_diagram_options &parent);
|
void inherit(const inheritable_diagram_options &parent);
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ void generator::generate_call(const message &m, std::ostream &ostr) const
|
|||||||
const std::string from_alias = generate_alias(from.value());
|
const std::string from_alias = generate_alias(from.value());
|
||||||
const std::string to_alias = generate_alias(to.value());
|
const std::string to_alias = generate_alias(to.value());
|
||||||
|
|
||||||
|
print_debug(m, ostr);
|
||||||
|
|
||||||
ostr << from_alias << " "
|
ostr << from_alias << " "
|
||||||
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " ";
|
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " ";
|
||||||
|
|
||||||
@@ -169,57 +171,70 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
|
|||||||
visited.pop_back();
|
visited.pop_back();
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kIf) {
|
else if (m.type() == message_t::kIf) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "alt\n";
|
ostr << "alt\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kElseIf) {
|
else if (m.type() == message_t::kElseIf) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "else\n";
|
ostr << "else\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kElse) {
|
else if (m.type() == message_t::kElse) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "else\n";
|
ostr << "else\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kIfEnd) {
|
else if (m.type() == message_t::kIfEnd) {
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kWhile) {
|
else if (m.type() == message_t::kWhile) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "loop\n";
|
ostr << "loop\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kWhileEnd) {
|
else if (m.type() == message_t::kWhileEnd) {
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kFor) {
|
else if (m.type() == message_t::kFor) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "loop\n";
|
ostr << "loop\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kForEnd) {
|
else if (m.type() == message_t::kForEnd) {
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kDo) {
|
else if (m.type() == message_t::kDo) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "loop\n";
|
ostr << "loop\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kDoEnd) {
|
else if (m.type() == message_t::kDoEnd) {
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kTry) {
|
else if (m.type() == message_t::kTry) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "group try\n";
|
ostr << "group try\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kCatch) {
|
else if (m.type() == message_t::kCatch) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "else " << m.message_name() << '\n';
|
ostr << "else " << m.message_name() << '\n';
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kTryEnd) {
|
else if (m.type() == message_t::kTryEnd) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kSwitch) {
|
else if (m.type() == message_t::kSwitch) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "group switch\n";
|
ostr << "group switch\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kCase) {
|
else if (m.type() == message_t::kCase) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "else " << m.message_name() << '\n';
|
ostr << "else " << m.message_name() << '\n';
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kSwitchEnd) {
|
else if (m.type() == message_t::kSwitchEnd) {
|
||||||
ostr << "end\n";
|
ostr << "end\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kConditional) {
|
else if (m.type() == message_t::kConditional) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "alt\n";
|
ostr << "alt\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kElse) {
|
else if (m.type() == message_t::kElse) {
|
||||||
|
print_debug(m, ostr);
|
||||||
ostr << "else\n";
|
ostr << "else\n";
|
||||||
}
|
}
|
||||||
else if (m.type() == message_t::kConditionalEnd) {
|
else if (m.type() == message_t::kConditionalEnd) {
|
||||||
@@ -279,6 +294,8 @@ void generator::generate_participant(
|
|||||||
const auto &class_participant =
|
const auto &class_participant =
|
||||||
m_model.get_participant<model::participant>(class_id).value();
|
m_model.get_participant<model::participant>(class_id).value();
|
||||||
|
|
||||||
|
print_debug(class_participant, ostr);
|
||||||
|
|
||||||
ostr << "participant \""
|
ostr << "participant \""
|
||||||
<< render_name(m_config.using_namespace().relative(
|
<< render_name(m_config.using_namespace().relative(
|
||||||
class_participant.full_name(false)))
|
class_participant.full_name(false)))
|
||||||
@@ -325,6 +342,8 @@ void generator::generate_participant(
|
|||||||
generated_participants_.emplace(file_id);
|
generated_participants_.emplace(file_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
print_debug(participant, ostr);
|
||||||
|
|
||||||
ostr << "participant \""
|
ostr << "participant \""
|
||||||
<< m_config.using_namespace().relative(
|
<< m_config.using_namespace().relative(
|
||||||
participant.full_name(false))
|
participant.full_name(false))
|
||||||
|
|||||||
Reference in New Issue
Block a user