-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
59 lines (46 loc) · 1.32 KB
/
types.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
package swag
import (
"github.com/go-openapi/spec"
"go/ast"
)
//Schema parsed schema
type Schema struct {
PkgPath string //package import path used to rename Name of a definition int case of conflict
Name string //Name in definitions
*spec.Schema //
}
//TypeSpecDef the whole information of a typeSpec
type TypeSpecDef struct {
//path of package starting from under ${GOPATH}/src or from module path in go.mod
PkgPath string
//ast file where TypeSpec is
File *ast.File
//the TypeSpec of this type definition
TypeSpec *ast.TypeSpec
}
//Name name of the typeSpec
func (t *TypeSpecDef) Name() string {
return t.TypeSpec.Name.Name
}
//FullName full name of the typeSpec
func (t *TypeSpecDef) FullName() string {
return fullTypeName(t.File.Name.Name, t.TypeSpec.Name.Name)
}
//AstFileInfo information of a ast.File
type AstFileInfo struct {
//File ast.File
File *ast.File
//Path path of the ast.File
Path string
//PackagePath package import path of the ast.File
PackagePath string
}
//PackageDefinitions files and definition in a package
type PackageDefinitions struct {
//package name
Name string
//files in this package, map key is file's relative path starting package path
Files map[string]*ast.File
//definitions in this package, map key is typeName
TypeDefinitions map[string]*TypeSpecDef
}