use super::prose::Prose;
pub struct Import {
pub offset: usize,
pub spec: String,
}
pub trait Dialect: Sync {
fn name(&self) -> &'static str;
fn extensions(&self) -> &'static [&'static str];
fn manifests(&self) -> &'static [&'static str];
fn vendored(&self, _manifest: &str) -> Vec<String> {
Vec::new()
}
fn declared(&self, _manifest: &str) -> Option<String> {
None
}
fn ambient(&self) -> &'static [&'static str];
fn prose(&self) -> &Prose;
fn imports(
&self,
path: &str,
roots: &[&str],
own: &str,
source: &str,
code: &[u8],
) -> Vec<Import>;
fn is_local(&self, spec: &str) -> bool;
fn escape_remedy(&self) -> &'static str;
}
#[must_use]
pub fn all() -> &'static [&'static dyn Dialect] {
&[&super::zig::Zig, &super::python::Python]
}
#[must_use]
pub fn by_name(name: &str) -> Option<&'static dyn Dialect> {
all().iter().copied().find(|d| d.name() == name)
}