Added initial support for skip decorator in sequence diagrams
This commit is contained in:
@@ -127,7 +127,7 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
|
|||||||
if (m.type() == message_t::kCall) {
|
if (m.type() == message_t::kCall) {
|
||||||
const auto &to =
|
const auto &to =
|
||||||
m_model.get_participant<model::participant>(m.to());
|
m_model.get_participant<model::participant>(m.to());
|
||||||
if (!to)
|
if (!to || to.value().skip())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
visited.push_back(m.from());
|
visited.push_back(m.from());
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ bool translation_unit_visitor::VisitCXXMethodDecl(clang::CXXMethodDecl *m)
|
|||||||
param->getType(), m->getASTContext(), false))));
|
param->getType(), m->getASTContext(), false))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process_comment(*m, *m_ptr);
|
||||||
|
|
||||||
set_source_location(*m, *m_ptr);
|
set_source_location(*m, *m_ptr);
|
||||||
|
|
||||||
const auto method_full_name = m_ptr->full_name(false);
|
const auto method_full_name = m_ptr->full_name(false);
|
||||||
@@ -368,6 +370,8 @@ bool translation_unit_visitor::VisitFunctionDecl(clang::FunctionDecl *f)
|
|||||||
}
|
}
|
||||||
set_unique_id(f->getID(), f_ptr->id());
|
set_unique_id(f->getID(), f_ptr->id());
|
||||||
|
|
||||||
|
process_comment(*f, *f_ptr);
|
||||||
|
|
||||||
set_source_location(*f, *f_ptr);
|
set_source_location(*f, *f_ptr);
|
||||||
|
|
||||||
// TODO: Handle overloaded functions with different arguments
|
// TODO: Handle overloaded functions with different arguments
|
||||||
@@ -400,6 +404,8 @@ bool translation_unit_visitor::VisitFunctionDecl(clang::FunctionDecl *f)
|
|||||||
}
|
}
|
||||||
set_unique_id(f->getID(), f_ptr->id());
|
set_unique_id(f->getID(), f_ptr->id());
|
||||||
|
|
||||||
|
process_comment(*f, *f_ptr);
|
||||||
|
|
||||||
set_source_location(*f, *f_ptr);
|
set_source_location(*f, *f_ptr);
|
||||||
|
|
||||||
// TODO: Handle overloaded functions with different arguments
|
// TODO: Handle overloaded functions with different arguments
|
||||||
@@ -441,6 +447,8 @@ bool translation_unit_visitor::VisitFunctionTemplateDecl(
|
|||||||
f_ptr->is_void(
|
f_ptr->is_void(
|
||||||
function_template->getAsFunction()->getReturnType()->isVoidType());
|
function_template->getAsFunction()->getReturnType()->isVoidType());
|
||||||
|
|
||||||
|
process_comment(*function_template, *f_ptr);
|
||||||
|
|
||||||
set_source_location(*function_template, *f_ptr);
|
set_source_location(*function_template, *f_ptr);
|
||||||
|
|
||||||
context().update(function_template);
|
context().update(function_template);
|
||||||
@@ -811,8 +819,7 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Skip casts, moves and such
|
// Skip casts, moves and such
|
||||||
if (expr->isCallToStdMove())
|
if (expr->isCallToStdMove()) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
if (expr->isImplicitCXXThis())
|
if (expr->isImplicitCXXThis())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
14
tests/t20025/.clang-uml
Normal file
14
tests/t20025/.clang-uml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
compilation_database_dir: ..
|
||||||
|
output_directory: puml
|
||||||
|
diagrams:
|
||||||
|
t20025_sequence:
|
||||||
|
type: sequence
|
||||||
|
glob:
|
||||||
|
- ../../tests/t20025/t20025.cc
|
||||||
|
include:
|
||||||
|
namespaces:
|
||||||
|
- clanguml::t20025
|
||||||
|
using_namespace:
|
||||||
|
- clanguml::t20025
|
||||||
|
start_from:
|
||||||
|
- function: "clanguml::t20025::tmain()"
|
||||||
45
tests/t20025/t20025.cc
Normal file
45
tests/t20025/t20025.cc
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
namespace clanguml {
|
||||||
|
namespace t20025 {
|
||||||
|
|
||||||
|
int add(int x, int y) { return x + y; }
|
||||||
|
|
||||||
|
/// Add 2 numbers
|
||||||
|
///
|
||||||
|
/// \param x
|
||||||
|
/// \param y
|
||||||
|
/// \return
|
||||||
|
/// \uml{skip}
|
||||||
|
int add2(int x, int y) { return x + x + y + y; }
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int a()
|
||||||
|
{
|
||||||
|
/// TODO: this doesn't work yet...
|
||||||
|
/// \uml{skip}
|
||||||
|
a2();
|
||||||
|
|
||||||
|
return a1();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \uml{skip}
|
||||||
|
int a1() { return 1; }
|
||||||
|
|
||||||
|
void a2() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
int tmain()
|
||||||
|
{
|
||||||
|
A a;
|
||||||
|
|
||||||
|
int result{};
|
||||||
|
|
||||||
|
result = a.a();
|
||||||
|
|
||||||
|
result += add(1, 2);
|
||||||
|
|
||||||
|
result += add2(2, 4);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
tests/t20025/test_case.h
Normal file
46
tests/t20025/test_case.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* tests/t20025/test_case.h
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021-2022 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TEST_CASE("t20025", "[test-case][sequence]")
|
||||||
|
{
|
||||||
|
auto [config, db] = load_config("t20025");
|
||||||
|
|
||||||
|
auto diagram = config.diagrams["t20025_sequence"];
|
||||||
|
|
||||||
|
REQUIRE(diagram->name == "t20025_sequence");
|
||||||
|
|
||||||
|
auto model = generate_sequence_diagram(*db, diagram);
|
||||||
|
|
||||||
|
REQUIRE(model->name() == "t20025_sequence");
|
||||||
|
|
||||||
|
auto puml = generate_sequence_puml(diagram, *model);
|
||||||
|
AliasMatcher _A(puml);
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||||
|
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||||
|
|
||||||
|
// Check if all calls exist
|
||||||
|
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("A"), "a()"));
|
||||||
|
REQUIRE_THAT(puml, !HasCall(_A("A"), _A("A"), "a1()"));
|
||||||
|
// REQUIRE_THAT(puml, !HasCall(_A("A"), _A("A"), "a2()"));
|
||||||
|
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("add(int,int)"), ""));
|
||||||
|
REQUIRE_THAT(puml, !HasCall(_A("tmain()"), _A("add2(int,int)"), ""));
|
||||||
|
|
||||||
|
save_puml(
|
||||||
|
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
|
}
|
||||||
@@ -271,6 +271,7 @@ using namespace clanguml::test::matchers;
|
|||||||
#include "t20022/test_case.h"
|
#include "t20022/test_case.h"
|
||||||
#include "t20023/test_case.h"
|
#include "t20023/test_case.h"
|
||||||
#include "t20024/test_case.h"
|
#include "t20024/test_case.h"
|
||||||
|
#include "t20025/test_case.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Package diagram tests
|
/// Package diagram tests
|
||||||
|
|||||||
@@ -220,6 +220,9 @@ test_cases:
|
|||||||
- name: t20024
|
- name: t20024
|
||||||
title: Switch statement sequence diagram test case
|
title: Switch statement sequence diagram test case
|
||||||
description:
|
description:
|
||||||
|
- name: t20025
|
||||||
|
title: Skip decorator sequence diagram test case
|
||||||
|
description:
|
||||||
Package diagrams:
|
Package diagrams:
|
||||||
- name: t30001
|
- name: t30001
|
||||||
title: Basic package diagram test case
|
title: Basic package diagram test case
|
||||||
|
|||||||
Reference in New Issue
Block a user