swc_estree_ast/
comment.rs1use serde::{Deserialize, Serialize};
2use swc_atoms::Atom;
3use swc_common::ast_serde;
4
5use crate::common::Loc;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8pub enum CommentType {
9 #[serde(rename = "CommentLine")]
10 Line,
11 #[serde(rename = "CommentBlock")]
12 Block,
13}
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15pub struct BaseComment {
16 #[serde(rename = "type")]
17 pub type_: CommentType,
18 pub value: Atom,
19 pub start: u32,
20 pub end: u32,
21 pub loc: Loc,
22}
23
24#[derive(Debug, Clone, PartialEq, Eq)]
25#[ast_serde]
26pub enum Comment {
27 #[tag("CommentBlock")]
28 Block(BaseComment),
29 #[tag("CommentLine")]
30 Line(BaseComment),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
34#[serde(rename_all = "lowercase")]
35pub enum CommentTypeShorthand {
36 Leading,
37 Inner,
38 Trailing,
39}