use crate::ast::{FnSig, GenericParam, Type, Visibility};
use crate::location::Span;
use std::collections::HashMap;
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct TraitInfo {
pub visibility: Visibility,
pub span: Span,
pub generics: Vec<GenericParam>,
pub fields: Vec<FieldInfo>,
pub composed_traits: Vec<String>,
pub methods: Vec<FnSig>,
pub doc: Option<String>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct LetInfo {
pub visibility: Visibility,
pub span: Span,
pub inferred_type: Option<String>,
pub doc: Option<String>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct StructInfo {
pub visibility: Visibility,
pub span: Span,
pub generics: Vec<GenericParam>,
pub fields: Vec<FieldInfo>,
pub has_impl: bool,
pub doc: Option<String>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct FieldInfo {
pub name: String,
pub ty: Type,
pub doc: Option<String>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct ImplInfo {
pub struct_name: String,
pub generics: Vec<GenericParam>,
pub span: Span,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct TraitImplInfo {
pub trait_name: String,
pub struct_name: String,
pub generics: Vec<GenericParam>,
pub span: Span,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct EnumInfo {
pub visibility: Visibility,
pub span: Span,
pub generics: Vec<GenericParam>,
pub variants: HashMap<String, (usize, Span)>,
pub variant_fields: HashMap<String, Vec<FieldInfo>>,
pub traits: Vec<String>,
pub doc: Option<String>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct ModuleInfo {
pub visibility: Visibility,
pub span: Span,
pub symbols: super::SymbolTable,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct ParamInfo {
pub convention: crate::ast::ParamConvention,
pub external_label: Option<crate::ast::Ident>,
pub name: crate::ast::Ident,
pub ty: Option<Type>,
pub default: Option<crate::ast::Expr>,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct FunctionInfo {
pub visibility: Visibility,
pub span: Span,
pub params: Vec<ParamInfo>,
pub return_type: Option<Type>,
pub generics: Vec<GenericParam>,
pub doc: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SymbolKind {
Trait,
Struct,
Impl,
Enum,
Let,
Module,
Function,
}
impl SymbolKind {
#[must_use]
pub const fn as_str(&self) -> &str {
match self {
Self::Trait => "trait",
Self::Struct => "struct",
Self::Impl => "impl",
Self::Enum => "enum",
Self::Let => "let binding",
Self::Function => "fn",
Self::Module => "mod",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ImportError {
PrivateItem { name: String, kind: SymbolKind },
ItemNotFound {
name: String,
available: Vec<String>,
},
}