From 1c7edea9ad24fd0420491208ad23a329f38cee61 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 10 Apr 2022 16:18:04 +0200 Subject: [PATCH] Added alias resolution in include diagrams --- src/include_diagram/model/diagram.cc | 14 +++++++++++++- tests/t40001/.clang-uml | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/include_diagram/model/diagram.cc b/src/include_diagram/model/diagram.cc index 77513703..5f1bcf7d 100644 --- a/src/include_diagram/model/diagram.cc +++ b/src/include_diagram/model/diagram.cc @@ -61,7 +61,19 @@ std::string diagram::to_alias(const std::string &full_name) const { LOG_DBG("Looking for alias for {}", full_name); - return full_name; + auto path = common::model::filesystem_path{full_name}; + + if (path.is_empty()) + throw error::uml_alias_missing( + fmt::format("Missing alias for '{}'", path.to_string())); + + auto source_file = get_element(path); + + if (!source_file) + throw error::uml_alias_missing( + fmt::format("Missing alias for '{}'", path.to_string())); + + return source_file.value().alias(); } } diff --git a/tests/t40001/.clang-uml b/tests/t40001/.clang-uml index 6d55f301..660a1e13 100644 --- a/tests/t40001/.clang-uml +++ b/tests/t40001/.clang-uml @@ -16,4 +16,7 @@ diagrams: - ../../tests/t40001 plantuml: before: - - "' t40001 test include diagram" \ No newline at end of file + - "' t40001 test include diagram" + after: + - 'note right of {{ alias("include/lib1") }}: This is a lib1 include dir' + - 'note right of {{ alias("include/t40001_include1.h") }}: This is a t40001_include1.h include file' \ No newline at end of file