Changed JSON generator paths to relative

This commit is contained in:
Bartek Kryza
2023-03-17 00:39:52 +01:00
parent f13ce56840
commit 4e404a362e
9 changed files with 172 additions and 260 deletions

View File

@@ -26,6 +26,7 @@ namespace clanguml::common::visitor {
translation_unit_visitor::translation_unit_visitor(
clang::SourceManager &sm, const clanguml::config::diagram &config)
: source_manager_{sm}
, relative_to_path_{config.relative_to()}
{
if (config.comment_parser() == config::comment_parser_t::plain) {
comment_visitor_ =
@@ -86,6 +87,9 @@ void translation_unit_visitor::set_source_location(
{
if (location.isValid()) {
element.set_file(source_manager_.getFilename(location).str());
element.set_file_relative(util::path_to_url(
std::filesystem::relative(element.file(), relative_to_path_)
.string()));
element.set_line(source_manager_.getSpellingLineNumber(location));
element.set_location_id(location.getHashValue());
}

View File

@@ -106,5 +106,7 @@ private:
clang::SourceManager &source_manager_;
std::unique_ptr<comment::comment_visitor> comment_visitor_;
std::filesystem::path relative_to_path_;
};
} // namespace clanguml::common::visitor