use super::{CallArgs, FormalArgs, Name, SassString, Selectors, Value};
use crate::parser::SourcePos;
use std::collections::BTreeSet;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub enum Item {
Import(Vec<SassString>, Value, SourcePos),
VariableDeclaration {
name: String,
val: Value,
default: bool,
global: bool,
},
AtRoot(Selectors, Vec<Item>),
AtRule {
name: SassString,
args: Value,
body: Option<Vec<Item>>,
},
Debug(Value),
Warn(Value),
Error(Value, SourcePos),
MixinDeclaration(String, FormalArgs, Vec<Item>, SourcePos),
MixinCall(String, CallArgs, Option<Vec<Item>>, SourcePos),
Content(SourcePos),
FunctionDeclaration(String, FormalArgs, SourcePos, Vec<Item>),
Return(Value),
IfStatement(Value, Vec<Item>, Vec<Item>),
Each(Vec<Name>, Value, Vec<Item>),
For {
name: Name,
from: Box<Value>,
to: Box<Value>,
inclusive: bool,
body: Vec<Item>,
},
While(Value, Vec<Item>),
Use(SassString, UseAs, Vec<(Name, Value, bool)>, SourcePos),
Forward(
SassString,
UseAs,
Expose,
Vec<(Name, Value, bool)>,
SourcePos,
),
Rule(Selectors, Vec<Item>),
NamespaceRule(SassString, Value, Vec<Item>),
Property(SassString, Value),
CustomProperty(SassString, SassString),
Comment(SassString),
None,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub enum Expose {
All,
Show(BTreeSet<Name>, BTreeSet<Name>),
Hide(BTreeSet<Name>, BTreeSet<Name>),
}
impl Expose {
pub fn allow_fun(&self, name: &Name) -> bool {
match self {
Expose::All => true,
Expose::Show(show, _) => show.contains(name),
Expose::Hide(hide, _) => !hide.contains(name),
}
}
pub fn allow_var(&self, name: &Name) -> bool {
match self {
Expose::All => true,
Expose::Show(_, show) => show.contains(name),
Expose::Hide(_, hide) => !hide.contains(name),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub enum UseAs {
KeepName,
Star,
Name(String),
Prefix(String),
}