mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
[ty] Lightly expose FileModule
and NamespacePackage
fields
This will make it easier to emit this info into snapshots for testing.
This commit is contained in:
parent
79b2754215
commit
ec7c2efef9
1 changed files with 9 additions and 6 deletions
|
@ -72,6 +72,9 @@ impl<'db> Module<'db> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The search path from which the module was resolved.
|
/// The search path from which the module was resolved.
|
||||||
|
///
|
||||||
|
/// It is guaranteed that if `None` is returned, then this is a namespace
|
||||||
|
/// package. Otherwise, this is a regular package or file module.
|
||||||
pub(crate) fn search_path(self, db: &'db dyn Database) -> Option<&'db SearchPath> {
|
pub(crate) fn search_path(self, db: &'db dyn Database) -> Option<&'db SearchPath> {
|
||||||
match self {
|
match self {
|
||||||
Module::File(module) => Some(module.search_path(db)),
|
Module::File(module) => Some(module.search_path(db)),
|
||||||
|
@ -214,12 +217,12 @@ fn all_submodule_names_for_package(db: &dyn Db, file: File) -> Option<Vec<Name>>
|
||||||
#[salsa::tracked(debug, heap_size=ruff_memory_usage::heap_size)]
|
#[salsa::tracked(debug, heap_size=ruff_memory_usage::heap_size)]
|
||||||
pub struct FileModule<'db> {
|
pub struct FileModule<'db> {
|
||||||
#[returns(ref)]
|
#[returns(ref)]
|
||||||
name: ModuleName,
|
pub(super) name: ModuleName,
|
||||||
kind: ModuleKind,
|
pub(super) kind: ModuleKind,
|
||||||
#[returns(ref)]
|
#[returns(ref)]
|
||||||
search_path: SearchPath,
|
pub(super) search_path: SearchPath,
|
||||||
file: File,
|
pub(super) file: File,
|
||||||
known: Option<KnownModule>,
|
pub(super) known: Option<KnownModule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A namespace package.
|
/// A namespace package.
|
||||||
|
@ -229,7 +232,7 @@ pub struct FileModule<'db> {
|
||||||
#[salsa::tracked(debug, heap_size=ruff_memory_usage::heap_size)]
|
#[salsa::tracked(debug, heap_size=ruff_memory_usage::heap_size)]
|
||||||
pub struct NamespacePackage<'db> {
|
pub struct NamespacePackage<'db> {
|
||||||
#[returns(ref)]
|
#[returns(ref)]
|
||||||
name: ModuleName,
|
pub(super) name: ModuleName,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, get_size2::GetSize)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, get_size2::GetSize)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue