use std::path::PathBuf;
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub enum LegalComment {
#[default]
None,
Inline,
Eof,
Linked(String),
External,
}
impl LegalComment {
pub fn is_none(&self) -> bool {
*self == Self::None
}
pub fn is_inline(&self) -> bool {
*self == Self::Inline
}
pub fn is_eof(&self) -> bool {
*self == Self::Eof
}
}
#[derive(Debug, Clone)]
pub struct CodegenOptions {
pub single_quote: bool,
pub minify: bool,
pub comments: bool,
pub annotation_comments: bool,
pub legal_comments: LegalComment,
pub source_map_path: Option<PathBuf>,
}
impl Default for CodegenOptions {
fn default() -> Self {
Self {
single_quote: false,
minify: false,
comments: true,
annotation_comments: false,
legal_comments: LegalComment::default(),
source_map_path: None,
}
}
}
impl CodegenOptions {
pub(crate) fn print_comments(&self) -> bool {
!self.minify
&& (self.comments || self.annotation_comments || self.legal_comments.is_inline())
}
pub(crate) fn print_annotation_comments(&self) -> bool {
!self.minify && (self.comments || self.annotation_comments)
}
}