[ty] Export some stuff from ty_python_semantic

We're going to want to use this outside of `ty_python_semantic`.
Specifically, in `ty_ide`.
This commit is contained in:
Andrew Gallant
2025-09-16 12:46:42 -04:00
committed by Andrew Gallant
parent 61a49c89eb
commit cf16fc4aa4
6 changed files with 25 additions and 16 deletions

View File

@@ -273,7 +273,14 @@ impl ModuleName {
std::iter::successors(Some(self.clone()), Self::parent)
}
pub(crate) fn from_import_statement<'db>(
/// Extracts a module name from the AST of a `from <module> import ...`
/// statement.
///
/// `importing_file` must be the [`File`] that contains the import
/// statement.
///
/// This handles relative import statements.
pub fn from_import_statement<'db>(
db: &'db dyn Db,
importing_file: File,
node: &'db ast::StmtImportFrom,
@@ -372,7 +379,7 @@ fn relative_module_name(
/// Various ways in which resolving a [`ModuleName`]
/// from an [`ast::StmtImport`] or [`ast::StmtImportFrom`] node might fail
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub(crate) enum ModuleNameResolutionError {
pub enum ModuleNameResolutionError {
/// The import statement has invalid syntax
InvalidSyntax,