-
Notifications
You must be signed in to change notification settings - Fork 1
/
expr.go
141 lines (117 loc) · 3.99 KB
/
expr.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
141
package astp
import "go/ast"
// IsExpr reports whether a given ast.Node is an expression(ast.Expr).
func IsExpr(node ast.Node) bool {
_, ok := node.(ast.Expr)
return ok
}
// IsBadExpr reports whether a given ast.Node is a bad expression (*ast.IsBadExpr).
func IsBadExpr(node ast.Node) bool {
_, ok := node.(*ast.BadExpr)
return ok
}
// IsIdent reports whether a given ast.Node is an identifier (*ast.IsIdent).
func IsIdent(node ast.Node) bool {
_, ok := node.(*ast.Ident)
return ok
}
// IsEllipsis reports whether a given ast.Node is an `...` (ellipsis) (*ast.IsEllipsis).
func IsEllipsis(node ast.Node) bool {
_, ok := node.(*ast.Ellipsis)
return ok
}
// IsBasicLit reports whether a given ast.Node is a literal of basic type (*ast.IsBasicLit).
func IsBasicLit(node ast.Node) bool {
_, ok := node.(*ast.BasicLit)
return ok
}
// IsFuncLit reports whether a given ast.Node is a function literal (*ast.IsFuncLit).
func IsFuncLit(node ast.Node) bool {
_, ok := node.(*ast.FuncLit)
return ok
}
// IsCompositeLit reports whether a given ast.Node is a composite literal (*ast.IsCompositeLit).
func IsCompositeLit(node ast.Node) bool {
_, ok := node.(*ast.CompositeLit)
return ok
}
// IsParenExpr reports whether a given ast.Node is a parenthesized expression (*ast.IsParenExpr).
func IsParenExpr(node ast.Node) bool {
_, ok := node.(*ast.ParenExpr)
return ok
}
// IsSelectorExpr reports whether a given ast.Node is a selector expression (*ast.IsSelectorExpr).
func IsSelectorExpr(node ast.Node) bool {
_, ok := node.(*ast.SelectorExpr)
return ok
}
// IsIndexExpr reports whether a given ast.Node is an index expression (*ast.IsIndexExpr).
func IsIndexExpr(node ast.Node) bool {
_, ok := node.(*ast.IndexExpr)
return ok
}
// IsSliceExpr reports whether a given ast.Node is a slice expression (*ast.IsSliceExpr).
func IsSliceExpr(node ast.Node) bool {
_, ok := node.(*ast.SliceExpr)
return ok
}
// IsTypeAssertExpr reports whether a given ast.Node is a type assert expression (*ast.IsTypeAssertExpr).
func IsTypeAssertExpr(node ast.Node) bool {
_, ok := node.(*ast.TypeAssertExpr)
return ok
}
// IsCallExpr reports whether a given ast.Node is an expression followed by an argument list (*ast.IsCallExpr).
func IsCallExpr(node ast.Node) bool {
_, ok := node.(*ast.CallExpr)
return ok
}
// IsStarExpr reports whether a given ast.Node is a star expression(unary "*" or apointer) (*ast.IsStarExpr)
func IsStarExpr(node ast.Node) bool {
_, ok := node.(*ast.StarExpr)
return ok
}
// IsUnaryExpr reports whether a given ast.Node is a unary expression (*ast.IsUnaryExpr).
func IsUnaryExpr(node ast.Node) bool {
_, ok := node.(*ast.UnaryExpr)
return ok
}
// IsBinaryExpr reports whether a given ast.Node is a binary expression (*ast.IsBinaryExpr).
func IsBinaryExpr(node ast.Node) bool {
_, ok := node.(*ast.BinaryExpr)
return ok
}
// IsKeyValueExpr reports whether a given ast.Node is a (key:value) pair (*ast.IsKeyValueExpr).
func IsKeyValueExpr(node ast.Node) bool {
_, ok := node.(*ast.KeyValueExpr)
return ok
}
// IsArrayType reports whether a given ast.Node is an array or slice type (*ast.IsArrayType).
func IsArrayType(node ast.Node) bool {
_, ok := node.(*ast.ArrayType)
return ok
}
// IsStructType reports whether a given ast.Node is a struct type (*ast.IsStructType).
func IsStructType(node ast.Node) bool {
_, ok := node.(*ast.StructType)
return ok
}
// IsFuncType reports whether a given ast.Node is a function type (*ast.IsFuncType).
func IsFuncType(node ast.Node) bool {
_, ok := node.(*ast.FuncType)
return ok
}
// IsInterfaceType reports whether a given ast.Node is an interface type (*ast.IsInterfaceType).
func IsInterfaceType(node ast.Node) bool {
_, ok := node.(*ast.InterfaceType)
return ok
}
// IsMapType reports whether a given ast.Node is a map type (*ast.IsMapType).
func IsMapType(node ast.Node) bool {
_, ok := node.(*ast.MapType)
return ok
}
// IsChanType reports whether a given ast.Node is a channel type (*ast.IsChanType).
func IsChanType(node ast.Node) bool {
_, ok := node.(*ast.ChanType)
return ok
}