Initial refactor of namespace handling

This commit is contained in:
Bartek Kryza
2022-03-04 23:38:37 +01:00
parent bee20e7f26
commit a67b459437
40 changed files with 620 additions and 201 deletions
@@ -44,8 +44,8 @@ generator::generator(
void generator::generate_call(const message &m, std::ostream &ostr) const
{
const auto from = ns_relative(m_config.using_namespace(), m.from);
const auto to = ns_relative(m_config.using_namespace(), m.to);
const auto from = m_config.using_namespace().relative(m.from);
const auto to = m_config.using_namespace().relative(m.to);
ostr << '"' << from << "\" "
<< common::generators::plantuml::to_plantuml(message_t::kCall) << " \""
@@ -57,8 +57,8 @@ void generator::generate_return(const message &m, std::ostream &ostr) const
// Add return activity only for messages between different actors and
// only if the return type is different than void
if ((m.from != m.to) && (m.return_type != "void")) {
const auto from = ns_relative(m_config.using_namespace(), m.from);
const auto to = ns_relative(m_config.using_namespace(), m.to);
const auto from = m_config.using_namespace().relative(m.from);
const auto to = m_config.using_namespace().relative(m.to);
ostr << '"' << to << "\" "
<< common::generators::plantuml::to_plantuml(message_t::kReturn)
@@ -69,7 +69,7 @@ void generator::generate_return(const message &m, std::ostream &ostr) const
void generator::generate_activity(const activity &a, std::ostream &ostr) const
{
for (const auto &m : a.messages) {
const auto to = ns_relative(m_config.using_namespace(), m.to);
const auto to = m_config.using_namespace().relative(m.to);
generate_call(m, ostr);
ostr << "activate " << '"' << to << '"' << std::endl;
if (m_model.sequences.find(m.to_usr) != m_model.sequences.end())
@@ -18,6 +18,7 @@
#include "translation_unit_visitor.h"
#include "common/model/namespace.h"
#include "translation_unit_context.h"
#include <cppast/cpp_function.hpp>
@@ -81,7 +82,7 @@ void translation_unit_visitor::process_activities(const cppast::cpp_function &e)
m.from = cx::util::ns(caller) + "::" + caller.name();
if (!ctx.config().should_include(
util::split(cx::util::ns(caller), "::"), caller.name()))
common::model::namespace_{cx::util::ns(caller)}, caller.name()))
continue;
if (caller.kind() == cpp_entity_kind::function_t)
@@ -98,7 +99,7 @@ void translation_unit_visitor::process_activities(const cppast::cpp_function &e)
m.to += "()";
if (!ctx.config().should_include(
util::split(cx::util::ns(callee), "::"), callee.name()))
common::model::namespace_{cx::util::ns(callee)}, callee.name()))
continue;
m.to_usr = type_safe::get(function_call.get_callee_method_id());