Added hyperlink generation in sequence diagrams
This commit is contained in:
@@ -66,11 +66,23 @@ void translation_unit_visitor::process_comment(
|
||||
void translation_unit_visitor::set_source_location(
|
||||
const clang::Decl &decl, clanguml::common::model::source_location &element)
|
||||
{
|
||||
if (decl.getLocation().isValid()) {
|
||||
element.set_file(source_manager_.getFilename(decl.getLocation()).str());
|
||||
element.set_line(
|
||||
source_manager_.getSpellingLineNumber(decl.getLocation()));
|
||||
element.set_location_id(decl.getLocation().getHashValue());
|
||||
set_source_location(decl.getLocation(), element);
|
||||
}
|
||||
|
||||
void translation_unit_visitor::set_source_location(
|
||||
const clang::Expr &expr, clanguml::common::model::source_location &element)
|
||||
{
|
||||
set_source_location(expr.getBeginLoc(), element);
|
||||
}
|
||||
|
||||
void translation_unit_visitor::set_source_location(
|
||||
const clang::SourceLocation &location,
|
||||
clanguml::common::model::source_location &element)
|
||||
{
|
||||
if (location.isValid()) {
|
||||
element.set_file(source_manager_.getFilename(location).str());
|
||||
element.set_line(source_manager_.getSpellingLineNumber(location));
|
||||
element.set_location_id(location.getHashValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ protected:
|
||||
void set_source_location(const clang::Decl &decl,
|
||||
clanguml::common::model::source_location &element);
|
||||
|
||||
void set_source_location(const clang::Expr &expr,
|
||||
clanguml::common::model::source_location &element);
|
||||
|
||||
void set_source_location(const clang::SourceLocation &location,
|
||||
clanguml::common::model::source_location &element);
|
||||
|
||||
void process_comment(const clang::NamedDecl &decl,
|
||||
clanguml::common::model::decorated_element &e);
|
||||
|
||||
|
||||
@@ -80,7 +80,13 @@ void generator::generate_call(const message &m, std::ostream &ostr) const
|
||||
|
||||
ostr << from_alias << " "
|
||||
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " "
|
||||
<< to_alias << " : " << message << std::endl;
|
||||
<< to_alias;
|
||||
|
||||
if (m_config.generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(ostr, m);
|
||||
}
|
||||
|
||||
ostr << " : " << message << std::endl;
|
||||
|
||||
LOG_DBG("Generated call '{}' from {} [{}] to {} [{}]", message, from,
|
||||
m.from, to, m.to);
|
||||
@@ -168,7 +174,14 @@ void generator::generate_participant(std::ostream &ostr, common::id_t id) const
|
||||
ostr << "participant \""
|
||||
<< render_name(m_config.using_namespace().relative(
|
||||
class_participant.full_name(false)))
|
||||
<< "\" as " << class_participant.alias() << '\n';
|
||||
<< "\" as " << class_participant.alias();
|
||||
|
||||
if (m_config.generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(
|
||||
ostr, class_participant);
|
||||
}
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
generated_participants_.emplace(class_id);
|
||||
}
|
||||
@@ -197,7 +210,9 @@ void generator::generate_participant(std::ostream &ostr, common::id_t id) const
|
||||
.string();
|
||||
|
||||
ostr << "participant \"" << render_name(participant_name)
|
||||
<< "\" as " << fmt::format("C_{:022}", file_id) << '\n';
|
||||
<< "\" as " << fmt::format("C_{:022}", file_id);
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
generated_participants_.emplace(file_id);
|
||||
}
|
||||
@@ -205,7 +220,14 @@ void generator::generate_participant(std::ostream &ostr, common::id_t id) const
|
||||
ostr << "participant \""
|
||||
<< m_config.using_namespace().relative(
|
||||
participant.full_name(false))
|
||||
<< "\" as " << participant.alias() << '\n';
|
||||
<< "\" as " << participant.alias();
|
||||
|
||||
if (m_config.generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(
|
||||
ostr, participant);
|
||||
}
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
generated_participants_.emplace(participant_id);
|
||||
}
|
||||
@@ -309,4 +331,5 @@ std::string generator::generate_alias(
|
||||
|
||||
return participant.alias();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,13 +25,12 @@
|
||||
|
||||
namespace clanguml::sequence_diagram::model {
|
||||
|
||||
struct message {
|
||||
struct message : public common::model::diagram_element {
|
||||
message()
|
||||
: from{}
|
||||
, to{}
|
||||
, message_name{}
|
||||
, return_type{}
|
||||
, line{}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,8 +41,6 @@ struct message {
|
||||
std::string message_name;
|
||||
|
||||
std::string return_type;
|
||||
|
||||
unsigned int line;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -570,6 +570,8 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
||||
m.type = message_t::kCall;
|
||||
m.from = context().caller_id();
|
||||
|
||||
set_source_location(*expr, m);
|
||||
|
||||
// If we're currently inside a lambda expression, set it's id as
|
||||
// message source rather then enclosing context
|
||||
// Unless the lambda is declared in a function or method call
|
||||
|
||||
Reference in New Issue
Block a user