Fixed class and include diagrams tests in Windows
This commit is contained in:
@@ -80,6 +80,7 @@ message(STATUS "LLVM library dir: ${LLVM_LIBRARY_DIR}")
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
# LLVM_BUILD_LLVM_DYLIB is not available on Windows
|
# LLVM_BUILD_LLVM_DYLIB is not available on Windows
|
||||||
set(LINK_LLVM_SHARED NO)
|
set(LINK_LLVM_SHARED NO)
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(LINK_LLVM_SHARED)
|
if(LINK_LLVM_SHARED)
|
||||||
|
|||||||
@@ -763,11 +763,10 @@ void translation_unit_visitor::process_class_children(
|
|||||||
|
|
||||||
// Static fields have to be processed by iterating over variable
|
// Static fields have to be processed by iterating over variable
|
||||||
// declarations
|
// declarations
|
||||||
#ifndef _MSC_VER
|
|
||||||
for (const auto *decl : cls->decls()) {
|
for (const auto *decl : cls->decls()) {
|
||||||
if (decl->getKind() == clang::Decl::Var) {
|
if (decl->getKind() == clang::Decl::Var) {
|
||||||
const clang::VarDecl *variable_declaration{
|
const clang::VarDecl *variable_declaration{
|
||||||
dynamic_cast<const clang::VarDecl *>(decl)};
|
clang::dyn_cast_or_null<clang::VarDecl>(decl)};
|
||||||
if ((variable_declaration != nullptr) &&
|
if ((variable_declaration != nullptr) &&
|
||||||
variable_declaration->isStaticDataMember()) {
|
variable_declaration->isStaticDataMember()) {
|
||||||
process_static_field(*variable_declaration, c);
|
process_static_field(*variable_declaration, c);
|
||||||
@@ -789,7 +788,7 @@ void translation_unit_visitor::process_class_children(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (cls->isCompleteDefinition())
|
if (cls->isCompleteDefinition())
|
||||||
for (const auto *friend_declaration : cls->friends()) {
|
for (const auto *friend_declaration : cls->friends()) {
|
||||||
if (friend_declaration != nullptr)
|
if (friend_declaration != nullptr)
|
||||||
|
|||||||
@@ -569,6 +569,7 @@ template <typename C, typename D> void generator<C, D>::init_env()
|
|||||||
auto element_opt = m_model.get_with_namespace(
|
auto element_opt = m_model.get_with_namespace(
|
||||||
args[0]->get<std::string>(), m_config.using_namespace());
|
args[0]->get<std::string>(), m_config.using_namespace());
|
||||||
|
|
||||||
|
|
||||||
if (!element_opt.has_value())
|
if (!element_opt.has_value())
|
||||||
throw clanguml::error::uml_alias_missing(
|
throw clanguml::error::uml_alias_missing(
|
||||||
args[0]->get<std::string>());
|
args[0]->get<std::string>());
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
/// \brief Find element in diagram which can have full name or be
|
/// \brief Find element in diagram which can have full name or be
|
||||||
/// relative to ns
|
/// relative to ns
|
||||||
common::optional_ref<clanguml::common::model::diagram_element>
|
virtual common::optional_ref<clanguml::common::model::diagram_element>
|
||||||
get_with_namespace(const std::string &name, const namespace_ &ns) const;
|
get_with_namespace(const std::string &name, const namespace_ &ns) const;
|
||||||
|
|
||||||
diagram(const diagram &) = delete;
|
diagram(const diagram &) = delete;
|
||||||
|
|||||||
@@ -374,6 +374,8 @@ paths_filter::paths_filter(filter_t type, const std::filesystem::path &root,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absolute_path.make_preferred();
|
||||||
|
|
||||||
paths_.emplace_back(std::move(absolute_path));
|
paths_.emplace_back(std::move(absolute_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,13 +388,15 @@ tvl::value_t paths_filter::match(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Matching source paths doesn't make sens if they are not absolute
|
// Matching source paths doesn't make sens if they are not absolute
|
||||||
if (!p.is_absolute())
|
if (!p.is_absolute()) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
auto pp = p.fs_path(root_);
|
auto pp = p.fs_path(root_);
|
||||||
for (const auto &path : paths_) {
|
for (const auto &path : paths_) {
|
||||||
if (pp.root_name().string() == path.root_name().string() &&
|
if (pp.root_name().string() == path.root_name().string() &&
|
||||||
util::starts_with(pp, path)) {
|
util::starts_with(pp.relative_path(), path.relative_path())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ public:
|
|||||||
|
|
||||||
explicit source_file(const std::filesystem::path &p)
|
explicit source_file(const std::filesystem::path &p)
|
||||||
{
|
{
|
||||||
set_path({p.parent_path().string()});
|
auto preferred = p;
|
||||||
set_name(p.filename().string());
|
preferred.make_preferred();
|
||||||
is_absolute_ = p.is_absolute();
|
set_path({preferred.parent_path().string()});
|
||||||
set_id(common::to_id(p));
|
set_name(preferred.filename().string());
|
||||||
|
is_absolute_ = preferred.is_absolute();
|
||||||
|
set_id(common::to_id(preferred));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_path(const filesystem_path &p) { path_ = p; }
|
void set_path(const filesystem_path &p) { path_ = p; }
|
||||||
@@ -118,6 +120,17 @@ public:
|
|||||||
return res.lexically_normal();
|
return res.lexically_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inja::json context() const override
|
||||||
|
{
|
||||||
|
inja::json ctx = diagram_element::context();
|
||||||
|
|
||||||
|
std::filesystem::path fullNamePath{ctx["full_name"].get<std::string>()};
|
||||||
|
fullNamePath.make_preferred();
|
||||||
|
ctx["full_name"] = fullNamePath.string();
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
filesystem_path path_;
|
filesystem_path path_;
|
||||||
source_file_t type_{source_file_t::kDirectory};
|
source_file_t type_{source_file_t::kDirectory};
|
||||||
|
|||||||
@@ -89,8 +89,12 @@ void diagram::add_file(std::unique_ptr<common::model::source_file> &&f)
|
|||||||
common::optional_ref<common::model::source_file> diagram::get_file(
|
common::optional_ref<common::model::source_file> diagram::get_file(
|
||||||
const std::string &name) const
|
const std::string &name) const
|
||||||
{
|
{
|
||||||
|
// Convert the name to the OS preferred path
|
||||||
|
std::filesystem::path namePath{name};
|
||||||
|
namePath.make_preferred();
|
||||||
|
|
||||||
for (const auto &p : files_) {
|
for (const auto &p : files_) {
|
||||||
if (p.get().full_name(false) == name) {
|
if (p.get().full_name(false) == namePath.string()) {
|
||||||
return {p};
|
return {p};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,6 +139,25 @@ diagram::files() const
|
|||||||
return files_;
|
return files_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common::optional_ref<clanguml::common::model::diagram_element>
|
||||||
|
diagram::get_with_namespace(const std::string &name, const common::model::namespace_ &ns) const
|
||||||
|
{
|
||||||
|
// Convert to preferred OS path
|
||||||
|
std::filesystem::path namePath{name};
|
||||||
|
auto namePreferred = namePath.make_preferred().string();
|
||||||
|
|
||||||
|
auto element_opt = get(namePreferred);
|
||||||
|
|
||||||
|
if (!element_opt) {
|
||||||
|
// If no element matches, try to prepend the 'using_namespace'
|
||||||
|
// value to the element and search again
|
||||||
|
auto fully_qualified_name = ns | namePreferred;
|
||||||
|
element_opt = get(fully_qualified_name.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
return element_opt;
|
||||||
|
}
|
||||||
|
|
||||||
inja::json diagram::context() const
|
inja::json diagram::context() const
|
||||||
{
|
{
|
||||||
inja::json ctx;
|
inja::json ctx;
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public:
|
|||||||
|
|
||||||
const common::reference_vector<common::model::source_file> &files() const;
|
const common::reference_vector<common::model::source_file> &files() const;
|
||||||
|
|
||||||
|
common::optional_ref<clanguml::common::model::diagram_element>
|
||||||
|
get_with_namespace(const std::string &name, const common::model::namespace_ &ns) const override;
|
||||||
|
|
||||||
inja::json context() const override;
|
inja::json context() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -220,18 +220,16 @@ void translation_unit_visitor::process_class_children(
|
|||||||
|
|
||||||
// Static fields have to be processed by iterating over variable
|
// Static fields have to be processed by iterating over variable
|
||||||
// declarations
|
// declarations
|
||||||
#ifndef _MSC_VER
|
|
||||||
for (const auto *decl : cls.decls()) {
|
for (const auto *decl : cls.decls()) {
|
||||||
if (decl->getKind() == clang::Decl::Var) {
|
if (decl->getKind() == clang::Decl::Var) {
|
||||||
const clang::VarDecl *variable_declaration{
|
const clang::VarDecl *variable_declaration{
|
||||||
dynamic_cast<const clang::VarDecl *>(decl)};
|
clang::dyn_cast_or_null<clang::VarDecl>(decl)};
|
||||||
if ((variable_declaration != nullptr) &&
|
if ((variable_declaration != nullptr) &&
|
||||||
variable_declaration->isStaticDataMember()) {
|
variable_declaration->isStaticDataMember()) {
|
||||||
process_static_field(*variable_declaration, relationships);
|
process_static_field(*variable_declaration, relationships);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cls.isCompleteDefinition())
|
if (cls.isCompleteDefinition())
|
||||||
for (const auto *friend_declaration : cls.friends()) {
|
for (const auto *friend_declaration : cls.friends()) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test_cases.h"
|
#include "test_cases.h"
|
||||||
#include "common/generators/plantuml/generator.h"
|
#include "common/generators/plantuml/generator.h"
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "common/model/namespace.h"
|
#include "common/model/namespace.h"
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Test namespace_", "[unit-test]")
|
TEST_CASE("Test namespace_", "[unit-test]")
|
||||||
{
|
{
|
||||||
using clanguml::common::model::namespace_;
|
using clanguml::common::model::namespace_;
|
||||||
|
|||||||
Reference in New Issue
Block a user