[Sema] Intro set of import filters for general use

Calling getImportedModules requires to list the desired kind of imports.
With the new kind of imports this has become cumbersome. Let's simplify
it by offering common sets of imports. Advanced call sites can still
list the desired imports explicitly.
This commit is contained in:
Alexis Laferrière
2023-03-09 15:20:52 -08:00
parent 2bc92a6a59
commit 205a2edf38
11 changed files with 41 additions and 60 deletions

View File

@@ -871,6 +871,28 @@ public:
/// \sa getImportedModules
using ImportFilter = OptionSet<ImportFilterKind>;
/// Returns an \c ImportFilter with all elements of \c ImportFilterKind.
constexpr static ImportFilter getImportFilterAll() {
return {ImportFilterKind::Exported,
ImportFilterKind::Default,
ImportFilterKind::ImplementationOnly,
ImportFilterKind::PackageOnly,
ImportFilterKind::SPIOnly,
ImportFilterKind::ShadowedByCrossImportOverlay};
}
/// Import kinds visible to the module declaring them.
///
/// This leaves out \c ShadowedByCrossImportOverlay as even if present in
/// the sources it's superseded by the cross-overlay as the local import.
constexpr static ImportFilter getImportFilterLocal() {
return {ImportFilterKind::Exported,
ImportFilterKind::Default,
ImportFilterKind::ImplementationOnly,
ImportFilterKind::PackageOnly,
ImportFilterKind::SPIOnly};
}
/// Looks up which modules are imported by this module.
///
/// \p filter controls whether public, private, or any imports are included