-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.go
140 lines (118 loc) · 2.81 KB
/
ast.go
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package phpdoc
import "mibk.dev/phpdoc/phptype"
// A Block represents a PHPDoc comment block.
type Block struct {
Lines []Line
Indent string // … each line
PreferOneline bool
}
// A Line represents a line in a PHPDoc comment.
type Line interface{ aLine() }
type line struct{}
func (*line) aLine() {}
// A TextLine represents a regular, text-only line in a PHPDoc comment.
type TextLine struct {
line
Value string
}
// A Tag represents a tag line in a PHPDoc comment (e.g. @author).
type Tag interface {
Line
aTag()
desc() string
}
type tag struct{ line }
func (*tag) aTag() {}
// A ParamTag represents a @param tag.
type ParamTag struct {
tag
Param *phptype.Param
Desc string
}
// A ReturnTag represents a @return tag.
type ReturnTag struct {
tag
Type phptype.Type
Desc string
}
// A PropertyTag represents a @property tag, as well as its variants
// @property-read and @property-write.
type PropertyTag struct {
tag
ReadOnly, WriteOnly bool
Type phptype.Type
Var string
Desc string
}
// A MethodTag represents a @method tag.
type MethodTag struct {
tag
Static bool
Result phptype.Type // or nil
Name string
Params []*phptype.Param
Desc string
}
// A VarTag represents a @var tag.
type VarTag struct {
tag
Type phptype.Type
Var string
Desc string
}
// A ThrowsTag represents a @throws tag.
type ThrowsTag struct {
tag
Class phptype.Type
Desc string
}
// An ExtendsTag represents an @extends tag.
type ExtendsTag struct {
tag
Class phptype.Type
Desc string
}
// An ImplementsTag represents an @implements tag.
type ImplementsTag struct {
tag
Interface phptype.Type
Desc string
}
// A UsesTag represents a @uses tag.
type UsesTag struct {
tag
Trait phptype.Type
Desc string
}
// A TemplateTag represents a @template tag.
type TemplateTag struct {
tag
Param string
Bound phptype.Type // or nil
Desc string
}
// A TemplateTag represents a @phpstan-type tag.
type TypeDefTag struct {
tag
Name string
Type phptype.Type
Desc string
}
// A OtherTag represents an arbitrary tag without a special meaning.
type OtherTag struct {
tag
Name string
Desc string
}
func (t *ParamTag) desc() string { return t.Desc }
func (t *ReturnTag) desc() string { return t.Desc }
func (t *PropertyTag) desc() string { return t.Desc }
func (t *MethodTag) desc() string { return t.Desc }
func (t *VarTag) desc() string { return t.Desc }
func (t *ThrowsTag) desc() string { return t.Desc }
func (t *ExtendsTag) desc() string { return t.Desc }
func (t *ImplementsTag) desc() string { return t.Desc }
func (t *UsesTag) desc() string { return t.Desc }
func (t *TemplateTag) desc() string { return t.Desc }
func (t *TypeDefTag) desc() string { return t.Desc }
func (t *OtherTag) desc() string { return t.Desc }