mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user