-
Notifications
You must be signed in to change notification settings - Fork 1
/
decl.go
39 lines (32 loc) · 1016 Bytes
/
decl.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
package astp
import "go/ast"
// IsDecl reports whether a node is a ast.Decl.
func IsDecl(node ast.Node) bool {
_, ok := node.(ast.Decl)
return ok
}
// IsFuncDecl reports whether a given ast.Node is a function declaration (*ast.FuncDecl).
func IsFuncDecl(node ast.Node) bool {
_, ok := node.(*ast.FuncDecl)
return ok
}
// IsGenDecl reports whether a given ast.Node is a generic declaration (*ast.GenDecl).
func IsGenDecl(node ast.Node) bool {
_, ok := node.(*ast.GenDecl)
return ok
}
// IsImportSpec reports whether a given ast.Node is an import declaration (*ast.ImportSpec).
func IsImportSpec(node ast.Node) bool {
_, ok := node.(*ast.ImportSpec)
return ok
}
// IsValueSpec reports whether a given ast.Node is a value declaration (*ast.ValueSpec).
func IsValueSpec(node ast.Node) bool {
_, ok := node.(*ast.ValueSpec)
return ok
}
// IsTypeSpec reports whether a given ast.Node is a type declaration (*ast.TypeSpec).
func IsTypeSpec(node ast.Node) bool {
_, ok := node.(*ast.TypeSpec)
return ok
}