mxmlextrema_as3parser/tree/
asdoc.rs

1use crate::ns::*;
2use serde::{Serialize, Deserialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Asdoc {
6    pub location: Location,
7    pub main_body: Option<(String, Location)>,
8    pub tags: Vec<(AsdocTag, Location)>,
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub enum AsdocTag {
13    Author(String),
14    Copy(Rc<AsdocReference>),
15    Created(String),
16    Default(String),
17    Deprecated {
18        message: Option<String>,
19    },
20    EventType(Rc<Expression>),
21    Example(String),
22    InheritDoc,
23    Internal(String),
24    Langversion(String),
25    Param {
26        name: String,
27        description: String,
28    },
29    Playerversion(String),
30    Private,
31    Productversion(String),
32    Return(String),
33    See {
34        reference: Rc<AsdocReference>,
35        display_text: Option<String>,
36    },
37    Throws {
38        class_reference: Rc<Expression>,
39        description: Option<String>,
40    },
41    Version(String),
42}
43
44/// An ASDoc reference consisting of an optional base and
45/// an optional instance property fragment (`#x`).
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct AsdocReference {
48    /// Base expression.
49    pub base: Option<Rc<Expression>>,
50    /// Instance property fragment following the hash character.
51    pub instance_property: Option<Rc<QualifiedIdentifier>>,
52}
53
54impl AsdocReference {
55    pub fn location(&self) -> Location {
56        if let Some(base) = self.base.as_ref() {
57            if let Some(iprop) = self.instance_property.as_ref() {
58                base.location().combine_with(iprop.location.clone())
59            } else {
60                base.location()
61            }
62        } else {
63            self.instance_property.as_ref().unwrap().location.clone()
64        }
65    }
66}