#![doc = include_str!("readme.md")]
use core::range::Range;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Identifier {
pub name: String,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct ActionScriptRoot {
pub items: Vec<ActionScriptItem>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub enum ActionScriptItem {
Package(PackageDeclaration),
Class(ClassDeclaration),
Interface(InterfaceDeclaration),
Function(FunctionDeclaration),
Variable(VariableDeclaration),
Import(ImportDeclaration),
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct PackageDeclaration {
pub name: Option<Identifier>,
pub items: Vec<ActionScriptItem>,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct ClassDeclaration {
pub name: Identifier,
pub modifiers: Vec<String>,
pub extends: Option<Identifier>,
pub implements: Vec<Identifier>,
pub items: Vec<ActionScriptItem>,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct InterfaceDeclaration {
pub name: Identifier,
pub extends: Vec<Identifier>,
pub items: Vec<ActionScriptItem>,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct FunctionDeclaration {
pub name: Identifier,
pub parameters: Vec<Parameter>,
pub return_type: Option<Identifier>,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct Parameter {
pub name: Identifier,
pub type_annotation: Option<Identifier>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct VariableDeclaration {
pub name: Identifier,
pub type_annotation: Option<Identifier>,
pub is_const: bool,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct ImportDeclaration {
pub path: String,
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
pub span: Range<usize>,
}
impl Default for ActionScriptRoot {
fn default() -> Self {
Self { items: Vec::new() }
}
}