Remove full_name() function
Doesn't work for templates.
This commit is contained in:
parent
133d51b630
commit
6894a025ca
3 changed files with 19 additions and 24 deletions
|
|
@ -162,11 +162,6 @@ namespace cppast
|
|||
/// \returns Whether or not the given entity is "friended",
|
||||
/// that is, its declaration exists as part of a [cppast::cpp_friend]() declaration.
|
||||
bool is_friended(const cpp_entity& e) noexcept;
|
||||
|
||||
/// \returns The full name of the [cppast::cpp_entity](), with all scopes.
|
||||
/// \notes Enitites without a name ([cppast::cpp_using_declaration]() etc.) do not have a full name either.
|
||||
/// \notes For (template) parameters the full name is the name itself.
|
||||
std::string full_name(const cpp_entity& e);
|
||||
} // namespace cppast
|
||||
|
||||
#endif // CPPAST_CPP_ENTITY_HPP_INCLUDED
|
||||
|
|
|
|||
|
|
@ -42,21 +42,3 @@ bool cppast::is_templated(const cpp_entity& e) noexcept
|
|||
return false;
|
||||
return e.parent().value().name() == e.name();
|
||||
}
|
||||
|
||||
std::string cppast::full_name(const cpp_entity& e)
|
||||
{
|
||||
if (e.name().empty())
|
||||
return "";
|
||||
else if (is_parameter(e.kind()))
|
||||
// parameters don't have a full name
|
||||
return e.name();
|
||||
|
||||
std::string scopes;
|
||||
|
||||
for (auto cur = e.parent(); cur; cur = cur.value().parent())
|
||||
// prepend each scope, if there is any
|
||||
type_safe::with(cur.value().scope_name(),
|
||||
[&](const std::string& cur_scope) { scopes = cur_scope + "::" + scopes; });
|
||||
|
||||
return scopes + e.name();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,13 +140,31 @@ unsigned count_children(const Entity& cont)
|
|||
return std::distance(cont.begin(), cont.end());
|
||||
}
|
||||
|
||||
inline std::string full_name(const cppast::cpp_entity& e)
|
||||
{
|
||||
if (e.name().empty())
|
||||
return "";
|
||||
else if (cppast::is_parameter(e.kind()))
|
||||
// parameters don't have a full name
|
||||
return e.name();
|
||||
|
||||
std::string scopes;
|
||||
|
||||
for (auto cur = e.parent(); cur; cur = cur.value().parent())
|
||||
// prepend each scope, if there is any
|
||||
type_safe::with(cur.value().scope_name(),
|
||||
[&](const std::string& cur_scope) { scopes = cur_scope + "::" + scopes; });
|
||||
|
||||
return scopes + e.name();
|
||||
}
|
||||
|
||||
// checks the full name/parent
|
||||
inline void check_parent(const cppast::cpp_entity& e, const char* parent_name,
|
||||
const char* full_name)
|
||||
{
|
||||
REQUIRE(e.parent());
|
||||
REQUIRE(e.parent().value().name() == parent_name);
|
||||
REQUIRE(cppast::full_name(e) == full_name);
|
||||
REQUIRE(::full_name(e) == full_name);
|
||||
}
|
||||
|
||||
bool equal_types(const cppast::cpp_entity_index& idx, const cppast::cpp_type& parsed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue