Add cpp_using_declaration
This commit is contained in:
parent
69f78d6abf
commit
9d60bd2992
3 changed files with 38 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ namespace cppast
|
||||||
namespace_t,
|
namespace_t,
|
||||||
namespace_alias_t,
|
namespace_alias_t,
|
||||||
using_directive_t,
|
using_directive_t,
|
||||||
|
using_declaration_t,
|
||||||
|
|
||||||
count,
|
count,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ namespace cppast
|
||||||
return std::unique_ptr<cpp_using_directive>(new cpp_using_directive(target));
|
return std::unique_ptr<cpp_using_directive>(new cpp_using_directive(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \returns The [cppast::cpp_namespace_ref]() that is exposed.
|
/// \returns The [cppast::cpp_namespace_ref]() that is being used.
|
||||||
/// \notes The name of the reference is the same as the name of this entity.
|
/// \notes The name of the reference is the same as the name of this entity.
|
||||||
cpp_namespace_ref target() const
|
cpp_namespace_ref target() const
|
||||||
{
|
{
|
||||||
|
|
@ -137,6 +137,41 @@ namespace cppast
|
||||||
|
|
||||||
cpp_entity_id target_;
|
cpp_entity_id target_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// A [cppast::cpp_entity]() modelling a using declaration.
|
||||||
|
///
|
||||||
|
/// A using declaration is `using std::vector`, for example.
|
||||||
|
class cpp_using_declaration final : public cpp_entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// \returns A newly created using declaration.
|
||||||
|
/// \notes It is not meant to be registered at the [cppast::cpp_entity_index](),
|
||||||
|
/// as nothing can refer to it.
|
||||||
|
static std::unique_ptr<cpp_using_declaration> build(const cpp_entity_ref& target)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<cpp_using_declaration>(new cpp_using_declaration(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \returns The [cppast::cpp_entity_ref]() that is being used.
|
||||||
|
/// \notes The name of the reference is the same as the name of this entity.
|
||||||
|
cpp_entity_ref target() const
|
||||||
|
{
|
||||||
|
return {target_, name()};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cpp_using_declaration(const cpp_entity_ref& target)
|
||||||
|
: cpp_entity(target.name()), target_(target.id())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
cpp_entity_type do_get_entity_type() const noexcept override
|
||||||
|
{
|
||||||
|
return cpp_entity_type::using_declaration_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpp_entity_id target_;
|
||||||
|
};
|
||||||
} // namespace cppast
|
} // namespace cppast
|
||||||
|
|
||||||
#endif // CPPAST_CPP_NAMESPACE_HPP_INCLUDED
|
#endif // CPPAST_CPP_NAMESPACE_HPP_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ bool cppast::is_scope(cpp_entity_type type) noexcept
|
||||||
case cpp_entity_type::file_t:
|
case cpp_entity_type::file_t:
|
||||||
case cpp_entity_type::namespace_alias_t:
|
case cpp_entity_type::namespace_alias_t:
|
||||||
case cpp_entity_type::using_directive_t:
|
case cpp_entity_type::using_directive_t:
|
||||||
|
case cpp_entity_type::using_declaration_t:
|
||||||
case cpp_entity_type::count:
|
case cpp_entity_type::count:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue