Added namespace deprecated attribute test case

This commit is contained in:
Bartek Kryza
2022-01-26 00:30:46 +01:00
parent a7dcd708a7
commit ed965c544e
9 changed files with 135 additions and 1 deletions

View File

@@ -114,7 +114,11 @@ void generator::generate(const package &p, std::ostream &ostr) const
{
const auto uns = m_config.using_namespace;
ostr << "package [" << p.name() << "] as " << p.alias();
ostr << "package [" << p.name() << "] ";
ostr << "as " << p.alias();
if (p.is_deprecated())
ostr << " <<deprecated>>";
if (!p.style().empty())
ostr << " " << p.style();

View File

@@ -47,4 +47,8 @@ bool operator==(const package &l, const package &r)
{
return l.full_name(false) == r.full_name(false);
}
bool package::is_deprecated() const { return is_deprecated_; }
void package::set_deprecated(bool deprecated) { is_deprecated_ = deprecated; }
}

View File

@@ -118,5 +118,11 @@ public:
std::string full_name(bool relative) const override;
friend bool operator==(const package &l, const package &r);
bool is_deprecated() const;
void set_deprecated(bool deprecated);
private:
bool is_deprecated_{false};
};
}

View File

@@ -106,6 +106,15 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
p->set_name(e.name());
p->set_namespace(package_parent);
for (const auto &attr :
ns_declaration.attributes()) {
if (attr.kind() ==
cppast::cpp_attribute_kind::deprecated) {
p->set_deprecated(true);
break;
}
}
ctx.diagram().add_package(
package_parent, std::move(p));
ctx.set_current_package(