use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq)]
pub struct TypeImportSpec {
pub check_name: String,
pub import_statement: String,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum FixtureScope {
#[default]
Function = 0,
Class = 1,
Module = 2,
Package = 3,
Session = 4,
}
impl FixtureScope {
pub fn parse(s: &str) -> Option<Self> {
match s.to_lowercase().as_str() {
"function" => Some(Self::Function),
"class" => Some(Self::Class),
"module" => Some(Self::Module),
"package" => Some(Self::Package),
"session" => Some(Self::Session),
_ => None,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Self::Function => "function",
Self::Class => "class",
Self::Module => "module",
Self::Package => "package",
Self::Session => "session",
}
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct FixtureDefinition {
pub name: String,
pub file_path: PathBuf,
pub line: usize,
pub end_line: usize, pub start_char: usize, pub end_char: usize, pub docstring: Option<String>,
pub return_type: Option<String>, pub return_type_imports: Vec<TypeImportSpec>, pub is_third_party: bool, pub is_plugin: bool, pub dependencies: Vec<String>, pub scope: FixtureScope, pub yield_line: Option<usize>, pub autouse: bool, }
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct FixtureUsage {
pub name: String,
pub file_path: PathBuf,
pub line: usize,
pub start_char: usize, pub end_char: usize, pub is_parameter: bool,
}
#[derive(Debug, Clone)]
#[allow(dead_code)] pub struct UndeclaredFixture {
pub name: String,
pub file_path: PathBuf,
pub line: usize,
pub start_char: usize,
pub end_char: usize,
pub function_name: String, pub function_line: usize, }
#[derive(Debug, Clone)]
pub struct FixtureCycle {
pub cycle_path: Vec<String>,
pub fixture: FixtureDefinition,
}
#[derive(Debug, Clone)]
pub struct ScopeMismatch {
pub fixture: FixtureDefinition,
pub dependency: FixtureDefinition,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CompletionContext {
FunctionSignature {
function_name: String,
function_line: usize,
is_fixture: bool,
declared_params: Vec<String>,
fixture_scope: Option<FixtureScope>,
},
FunctionBody {
function_name: String,
function_line: usize,
is_fixture: bool,
declared_params: Vec<String>,
fixture_scope: Option<FixtureScope>,
},
UsefixturesDecorator,
ParametrizeIndirect,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ParamInsertionInfo {
pub line: usize,
pub char_pos: usize,
pub needs_comma: bool,
pub multiline_indent: Option<String>,
}