|
| 1 | +use crate::ast::annotation::Annotation; |
| 2 | +use crate::ast::comment::Comment; |
| 3 | +use crate::ast::location::{ |
| 4 | + AliasDeclarationLocation, ClassDeclarationLocation, ClassSuperLocation, |
| 5 | + ConstantDeclarationLocation, GlobalDeclarationLocation, InterfaceDeclarationLocation, |
| 6 | + ModuleDeclarationLocation, ModuleSelfLocation, TypeAliasDeclarationLocation, |
| 7 | +}; |
| 8 | +use crate::ast::members::Member; |
| 9 | +use crate::ast::type_param::TypeParam; |
| 10 | +use crate::ast::types::Type; |
| 11 | +use crate::ids::{SymbolId, TypeName}; |
| 12 | + |
| 13 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 14 | +pub enum Declaration { |
| 15 | + Class(ClassDeclaration), |
| 16 | + Module(ModuleDeclaration), |
| 17 | + Interface(InterfaceDeclaration), |
| 18 | + Constant(ConstantDeclaration), |
| 19 | + Global(GlobalDeclaration), |
| 20 | + TypeAlias(TypeAliasDeclaration), |
| 21 | + ClassAlias(ClassAliasDeclaration), |
| 22 | + ModuleAlias(ModuleAliasDeclaration), |
| 23 | +} |
| 24 | + |
| 25 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 26 | +pub enum ClassMember { |
| 27 | + Member(Member), |
| 28 | + Declaration(Declaration), |
| 29 | +} |
| 30 | + |
| 31 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 32 | +pub enum ModuleMember { |
| 33 | + Member(Member), |
| 34 | + Declaration(Declaration), |
| 35 | +} |
| 36 | + |
| 37 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 38 | +pub struct ClassSuper { |
| 39 | + pub name: TypeName, |
| 40 | + pub args: Vec<Type>, |
| 41 | + pub location: Option<ClassSuperLocation>, |
| 42 | +} |
| 43 | + |
| 44 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 45 | +pub struct ClassDeclaration { |
| 46 | + pub name: TypeName, |
| 47 | + pub type_params: Vec<TypeParam>, |
| 48 | + pub members: Vec<ClassMember>, |
| 49 | + pub super_class: Option<ClassSuper>, |
| 50 | + pub annotations: Vec<Annotation>, |
| 51 | + pub location: Option<ClassDeclarationLocation>, |
| 52 | + pub comment: Option<Comment>, |
| 53 | +} |
| 54 | + |
| 55 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 56 | +pub struct ModuleSelf { |
| 57 | + pub name: TypeName, |
| 58 | + pub args: Vec<Type>, |
| 59 | + pub location: Option<ModuleSelfLocation>, |
| 60 | +} |
| 61 | + |
| 62 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 63 | +pub struct ModuleDeclaration { |
| 64 | + pub name: TypeName, |
| 65 | + pub type_params: Vec<TypeParam>, |
| 66 | + pub members: Vec<ModuleMember>, |
| 67 | + pub location: Option<ModuleDeclarationLocation>, |
| 68 | + pub annotations: Vec<Annotation>, |
| 69 | + pub self_types: Vec<ModuleSelf>, |
| 70 | + pub comment: Option<Comment>, |
| 71 | +} |
| 72 | + |
| 73 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 74 | +pub struct InterfaceDeclaration { |
| 75 | + pub name: TypeName, |
| 76 | + pub type_params: Vec<TypeParam>, |
| 77 | + pub members: Vec<Member>, |
| 78 | + pub annotations: Vec<Annotation>, |
| 79 | + pub location: Option<InterfaceDeclarationLocation>, |
| 80 | + pub comment: Option<Comment>, |
| 81 | +} |
| 82 | + |
| 83 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 84 | +pub struct TypeAliasDeclaration { |
| 85 | + pub name: TypeName, |
| 86 | + pub type_params: Vec<TypeParam>, |
| 87 | + pub ty: Type, |
| 88 | + pub annotations: Vec<Annotation>, |
| 89 | + pub location: Option<TypeAliasDeclarationLocation>, |
| 90 | + pub comment: Option<Comment>, |
| 91 | +} |
| 92 | + |
| 93 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 94 | +pub struct ConstantDeclaration { |
| 95 | + pub name: TypeName, |
| 96 | + pub ty: Type, |
| 97 | + pub location: Option<ConstantDeclarationLocation>, |
| 98 | + pub comment: Option<Comment>, |
| 99 | + pub annotations: Vec<Annotation>, |
| 100 | +} |
| 101 | + |
| 102 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 103 | +pub struct GlobalDeclaration { |
| 104 | + pub name: SymbolId, |
| 105 | + pub ty: Type, |
| 106 | + pub location: Option<GlobalDeclarationLocation>, |
| 107 | + pub comment: Option<Comment>, |
| 108 | + pub annotations: Vec<Annotation>, |
| 109 | +} |
| 110 | + |
| 111 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 112 | +pub struct ClassAliasDeclaration { |
| 113 | + pub new_name: TypeName, |
| 114 | + pub old_name: TypeName, |
| 115 | + pub location: Option<AliasDeclarationLocation>, |
| 116 | + pub comment: Option<Comment>, |
| 117 | + pub annotations: Vec<Annotation>, |
| 118 | +} |
| 119 | + |
| 120 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 121 | +pub struct ModuleAliasDeclaration { |
| 122 | + pub new_name: TypeName, |
| 123 | + pub old_name: TypeName, |
| 124 | + pub location: Option<AliasDeclarationLocation>, |
| 125 | + pub comment: Option<Comment>, |
| 126 | + pub annotations: Vec<Annotation>, |
| 127 | +} |
0 commit comments