Added is_system header file property to JSON include diagram generator
This commit is contained in:
@@ -117,6 +117,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
source_file_t type() const { return type_; }
|
source_file_t type() const { return type_; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the file is a system header
|
||||||
|
*
|
||||||
|
* @param is_system Whether the file is a system header
|
||||||
|
*/
|
||||||
|
void set_system_header(bool is_system) { is_system_header_ = is_system; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the file a system header?
|
||||||
|
*
|
||||||
|
* @return True, if the source file is a system header
|
||||||
|
*/
|
||||||
|
bool is_system_header() const { return is_system_header_; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the source file's parent path.
|
* Get the source file's parent path.
|
||||||
*
|
*
|
||||||
@@ -185,6 +199,7 @@ private:
|
|||||||
filesystem_path path_{path_type::kFilesystem};
|
filesystem_path path_{path_type::kFilesystem};
|
||||||
source_file_t type_{source_file_t::kDirectory};
|
source_file_t type_{source_file_t::kDirectory};
|
||||||
bool is_absolute_{false};
|
bool is_absolute_{false};
|
||||||
|
bool is_system_header_{false};
|
||||||
};
|
};
|
||||||
} // namespace clanguml::common::model
|
} // namespace clanguml::common::model
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ void generator::generate(const source_file &f, nlohmann::json &parent) const
|
|||||||
|
|
||||||
j["type"] = "file";
|
j["type"] = "file";
|
||||||
j["file_kind"] = to_string(f.type());
|
j["file_kind"] = to_string(f.type());
|
||||||
|
if (f.type() == common::model::source_file_t::kHeader) {
|
||||||
|
j["is_system"] = f.is_system_header();
|
||||||
|
}
|
||||||
|
|
||||||
parent["elements"].push_back(std::move(j));
|
parent["elements"].push_back(std::move(j));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ void translation_unit_visitor::include_visitor::process_internal_header(
|
|||||||
include_file.set_file(
|
include_file.set_file(
|
||||||
std::filesystem::absolute(include_path).lexically_normal().string());
|
std::filesystem::absolute(include_path).lexically_normal().string());
|
||||||
include_file.set_line(0);
|
include_file.set_line(0);
|
||||||
|
include_file.set_system_header(is_system);
|
||||||
|
|
||||||
// Add relationship from the currently parsed source file to this
|
// Add relationship from the currently parsed source file to this
|
||||||
// include file
|
// include file
|
||||||
@@ -174,6 +175,7 @@ void translation_unit_visitor::include_visitor::process_external_system_header(
|
|||||||
f->set_name(include_path.string());
|
f->set_name(include_path.string());
|
||||||
f->set_type(common::model::source_file_t::kHeader);
|
f->set_type(common::model::source_file_t::kHeader);
|
||||||
f->set_id(common::to_id(include_path));
|
f->set_id(common::to_id(include_path));
|
||||||
|
f->set_system_header(true);
|
||||||
|
|
||||||
const auto f_id = f->id();
|
const auto f_id = f->id();
|
||||||
|
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ TEST_CASE("t40001", "[test-case][include]")
|
|||||||
REQUIRE(IsFolder(j, "include/lib1"));
|
REQUIRE(IsFolder(j, "include/lib1"));
|
||||||
REQUIRE(IsFolder(j, "src"));
|
REQUIRE(IsFolder(j, "src"));
|
||||||
|
|
||||||
REQUIRE(IsFile(j, "include/lib1/lib1.h"));
|
REQUIRE(IsHeader(j, "include/lib1/lib1.h"));
|
||||||
REQUIRE(IsFile(j, "include/t40001_include1.h"));
|
REQUIRE(IsHeader(j, "include/t40001_include1.h"));
|
||||||
REQUIRE(IsFile(j, "src/t40001.cc"));
|
REQUIRE(IsFile(j, "src/t40001.cc"));
|
||||||
REQUIRE(IsFile(j, "yaml-cpp/yaml.h"));
|
REQUIRE(IsSystemHeader(j, "yaml-cpp/yaml.h"));
|
||||||
|
|
||||||
REQUIRE(IsFile(j, "string"));
|
REQUIRE(IsFile(j, "string"));
|
||||||
|
|
||||||
|
|||||||
@@ -1391,6 +1391,20 @@ bool IsFile(const nlohmann::json &j, const std::string &name)
|
|||||||
return e && e->at("type") == "file";
|
return e && e->at("type") == "file";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSystemHeader(const nlohmann::json &j, const std::string &name)
|
||||||
|
{
|
||||||
|
auto e = get_element(j, name);
|
||||||
|
return e && e->at("type") == "file" && e->at("file_kind") == "header" &&
|
||||||
|
e->at("is_system");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsHeader(const nlohmann::json &j, const std::string &name)
|
||||||
|
{
|
||||||
|
auto e = get_element(j, name);
|
||||||
|
return e && e->at("type") == "file" && e->at("file_kind") == "header" &&
|
||||||
|
!e->at("is_system");
|
||||||
|
}
|
||||||
|
|
||||||
bool IsDeprecated(const nlohmann::json &j, const std::string &name)
|
bool IsDeprecated(const nlohmann::json &j, const std::string &name)
|
||||||
{
|
{
|
||||||
auto e = get_element(j, expand_name(j, name));
|
auto e = get_element(j, expand_name(j, name));
|
||||||
|
|||||||
Reference in New Issue
Block a user