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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use crate::ast::{Decorator, Expression, FunctionParam, Statement, TypeAnnotation, TypeParameter};
use core::range::Range;
/// Represents the visibility of a class member.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Visibility {
/// Public visibility.
Public,
/// Private visibility.
Private,
/// Protected visibility.
Protected,
}
/// Represents a member of a class.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ClassMember {
/// A property member.
Property {
/// Decorators associated with the property.
decorators: Vec<Decorator>,
/// Name of the property.
name: String,
/// Type annotation of the property.
ty: Option<TypeAnnotation>,
/// Initializer expression of the property.
initializer: Option<Expression>,
/// Visibility of the property.
visibility: Option<Visibility>,
/// Whether the property is static.
is_static: bool,
/// Whether the property is readonly.
is_readonly: bool,
/// Whether the property is abstract.
is_abstract: bool,
/// Whether the property is optional.
is_optional: bool,
/// Source span of the property.
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
span: Range<usize>,
},
/// A method member.
Method {
/// Decorators associated with the method.
decorators: Vec<Decorator>,
/// Name of the method.
name: String,
/// Type parameters of the method.
type_params: Vec<TypeParameter>,
/// Parameters of the method.
params: Vec<FunctionParam>,
/// Return type of the method.
return_type: Option<TypeAnnotation>,
/// Body of the method.
body: Vec<Statement>,
/// Visibility of the method.
visibility: Option<Visibility>,
/// Whether the method is static.
is_static: bool,
/// Whether the method is abstract.
is_abstract: bool,
/// Whether the method is a getter.
is_getter: bool,
/// Whether the method is a setter.
is_setter: bool,
/// Whether the method is optional.
is_optional: bool,
/// Source span of the method.
#[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
span: Range<usize>,
},
}