parse

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CommentPrefix = "//"

Variables

This section is empty.

Functions

func AstDirFuncDecl

func AstDirFuncDecl(path string, fund func(filePath string, astFile *ast.File, funcDecl *ast.FuncDecl))

func AstDirTypeDecl

func AstDirTypeDecl(path string, fund func(filePath string, astFile *ast.File, genDecl *ast.GenDecl))

func AstFileGenDecl

func AstFileGenDecl(filePath string, fund func(genDecl *ast.GenDecl))

func BuildRoute

func BuildRoute(routePath string, routeComments []RouteComment)

BuildRoute 生成route.go文件

func CheckIsRoute

func CheckIsRoute(routePath string) (isRoute bool)

CheckIsRoute 检查route.go文件

func ExistsGoMod

func ExistsGoMod(rootPath string) bool

ExistsGoMod 判断go.mod文件是否存在

func GetModRequire

func GetModRequire(rootPath string) collections.List[string]

GetModRequire 得到依赖包

func GetRootPackage

func GetRootPackage(rootPath string) string

GetRootPackage 得到包名

Types

type Annotation

type Annotation struct {
	Cmd  string
	Args []string
}

func GetAnnotation

func GetAnnotation(comment string) *Annotation

func (*Annotation) IsApi

func (receiver *Annotation) IsApi() bool

func (*Annotation) IsArea

func (receiver *Annotation) IsArea() bool

func (*Annotation) IsCodeReview added in v0.13.2

func (receiver *Annotation) IsCodeReview() bool

func (*Annotation) IsDi

func (receiver *Annotation) IsDi() bool

func (*Annotation) IsFilter

func (receiver *Annotation) IsFilter() bool

func (*Annotation) IsMessage

func (receiver *Annotation) IsMessage() bool

type RouteComment

type RouteComment struct {
	Area   string // 区域 @area
	Url    string // 路由地址 @get {area}/order/{action}
	Method string // 路由method @get {area}/order/{action}

	IocNames      map[string]string // 注入别名 @di repository default
	StatusMessage string            // api返回message @message 成功
	PackagePath   string            // 包路径
	PackageName   string            // 包名
	FuncName      string            // handle名称

	ProjectPath    string // 项目根目录
	TopPackageName string // 顶级包名
	CodeReview     bool   // 是否做了CodeReview
	// contains filtered or unexported fields
}

RouteComment 路由注解、函数类型

func (*RouteComment) IsHaveComment

func (receiver *RouteComment) IsHaveComment(route map[string]string) bool

IsHaveComment 是否有解析到

func (*RouteComment) ParseFuncComment

func (receiver *RouteComment) ParseFuncComment(ant *Annotation, route map[string]string)

ParseFuncComment 解析函数注解

func (*RouteComment) ParseFuncType

func (receiver *RouteComment) ParseFuncType(astFile *ast.File, funcDecl *ast.FuncDecl)

ParseFuncType 解析函数名称、参数类型

func (*RouteComment) ParsePackageComment

func (receiver *RouteComment) ParsePackageComment(ant *Annotation)

ParsePackageComment 解析包注解

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL