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
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;

use crate::lexer::token::Span;
use crate::parser::ast::comments::CommentGroup;
use crate::parser::ast::identifiers::SimpleIdentifier;
use crate::parser::ast::Expression;

#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "type", content = "value")]
pub enum Argument {
    Positional {
        comments: CommentGroup,
        ellipsis: Option<Span>, // `...`
        value: Expression,      // `$var`
    },
    Named {
        comments: CommentGroup,
        name: SimpleIdentifier, // `foo`
        colon: Span,            // `:`
        ellipsis: Option<Span>, // `...`
        value: Expression,      // `$var`
    },
}

#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ArgumentList {
    pub comments: CommentGroup,
    pub left_parenthesis: Span,   // `(`
    pub arguments: Vec<Argument>, // `$var`, `...$var`, `foo: $var`, `foo: ...$var`
    pub right_parenthesis: Span,  // `)`
}

#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct SingleArgument {
    pub comments: CommentGroup,
    pub left_parenthesis: Span,  // `(`
    pub argument: Argument,      // `$var`
    pub right_parenthesis: Span, // `)`
}

#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ArgumentPlaceholder {
    pub comments: CommentGroup,
    pub left_parenthesis: Span,  // `(`
    pub ellipsis: Span,          // `...`
    pub right_parenthesis: Span, // `)`
}