Skip to main content

elm_ast/
exposing.rs

1use crate::comment::Comment;
2use crate::node::Spanned;
3use crate::span::Span;
4
5/// An exposing list on a module declaration or import.
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub enum Exposing {
9    /// `exposing (..)` — expose everything.
10    All(Span),
11
12    /// `exposing (foo, Bar, Baz(..))` — expose specific items.
13    ///
14    /// `trailing_comments` captures any comments appearing after the last
15    /// item but before the closing `)`. elm-format preserves them on their
16    /// own lines just before the closing paren.
17    Explicit {
18        items: Vec<Spanned<ExposedItem>>,
19        #[cfg_attr(
20            feature = "serde",
21            serde(default, skip_serializing_if = "Vec::is_empty")
22        )]
23        trailing_comments: Vec<Spanned<Comment>>,
24    },
25}
26
27/// A single item in an explicit exposing list.
28#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
29#[derive(Clone, Debug, PartialEq, Eq)]
30pub enum ExposedItem {
31    /// An exposed value or function: `foo`
32    Function(String),
33
34    /// An exposed type with no constructors: `Foo`
35    TypeOrAlias(String),
36
37    /// An exposed type with specified constructor visibility:
38    /// `Foo(..)` (all constructors exposed).
39    TypeExpose {
40        name: String,
41        /// `Some(span)` if `(..)` is present; `None` if constructors are not exposed.
42        open: Option<Span>,
43    },
44
45    /// An exposed infix operator: `(+)`
46    Infix(String),
47}