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
use super::*;

/// `A⦓T⦔, A⟨T⟩, A::<T>`
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct GenericCallNode {
    /// `this?::<T>`
    pub monadic: bool,
    /// `Base::<T>, ::<T as Trait>`
    pub base: ExpressionKind,
    /// `A::<T>::Associated::<T as Trait>`
    pub term: GenericCallTerm,
    /// The range of the node
    pub span: Range<u32>,
}

/// Call with static method
#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum GenericCallTerm {
    /// `T::Associated`
    Associated(IdentifierNode),
    /// `f::<T, U>`
    Generic(ArgumentsList),
}

impl ValkyrieNode for GenericCallNode {
    fn get_range(&self) -> Range<usize> {
        Range { start: self.span.start as usize, end: self.span.end as usize }
    }
}

impl GenericCallNode {
    /// Replace placeholder with actual expression
    pub fn with_base(self, base: ExpressionKind) -> Self {
        Self { base, ..self }
    }
}