swc_ecma_usage_analyzer/marks.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
#![allow(dead_code)]
use swc_common::Mark;
#[derive(Debug, Clone, Copy)]
pub struct Marks {
/// [Mark] applied to non-top level variables which is injected while
/// inlining.
///
/// In other words, AST nodes marked with this mark will not be treated as a
/// top level item, even if it's in the top level scope.
pub non_top_level: Mark,
/// Indicates that a sequence expression is generated by the minifier.
///
/// This is required because `sequences` option is ignored for synthesized
/// sequences.
pub synthesized_seq: Mark,
/// Treat this function as a top level module.
///
/// If this mark is applied, the function will be treated as a black box. It
/// will not be analyzed by usage analyzer.
///
/// # Note
///
/// Standalone functions should not depend on any other declarations in the
/// outer scope.
///
/// This is only applied to [swc_ecma_ast::Function] and it should not be
/// nested.
pub standalone: Mark,
//// Applied to [swc_ecma_ast::Module].
pub bundle_of_standalone: Mark,
/// `/** @const */`.
pub const_ann: Mark,
/// Check for `/*#__NOINLINE__*/`
pub noinline: Mark,
/// Check for `/*#__PURE__*/`
pub pure: Mark,
/// This is applied to [swc_ecma_ast::BlockStmt] which is injected to
/// preserve the side effects.
pub fake_block: Mark,
pub unresolved_mark: Mark,
}
impl Marks {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
fn m() -> Mark {
Mark::new()
}
Marks {
non_top_level: m(),
synthesized_seq: m(),
standalone: m(),
bundle_of_standalone: m(),
const_ann: m(),
noinline: m(),
pure: m(),
fake_block: m(),
unresolved_mark: m(),
}
}
}