MCPcopy
hub / github.com/zeromicro/go-zero / checkServiceStmt

Method checkServiceStmt

tools/goctl/pkg/parser/api/parser/api.go:120–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118}
119
120func (api *API) checkServiceStmt() error {
121 f := newFilter()
122 serviceNameChecker := f.addCheckItem(api.Filename, "service name expression")
123 handlerChecker := f.addCheckItem(api.Filename, "handler expression")
124 pathChecker := f.addCheckItem(api.Filename, "path expression")
125 var serviceName = map[string]string{}
126 for _, v := range api.ServiceStmts {
127 name := strings.TrimSuffix(v.Name.Format(""), "-api")
128 if sn, ok := serviceName[name]; ok {
129 if sn != name {
130 serviceNameChecker.errorManager.add(ast.SyntaxError(v.Name.Pos(), "multiple service name"))
131 }
132 } else {
133 serviceName[name] = name
134 }
135 var (
136 prefix = api.getAtServerValue(v.AtServerStmt, atServerPrefixKey)
137 group = api.getAtServerValue(v.AtServerStmt, atServerGroupKey)
138 )
139 for _, item := range v.Routes {
140 handlerChecker.checkNodeWithPrefix(group, item.AtHandler.Name)
141 path := fmt.Sprintf("[%s]:%s", prefix, item.Route.Format(""))
142 pathChecker.check(
143 ast.NewTokenNode(
144 token.Token{
145 Text: path,
146 Position: item.Route.Pos(),
147 },
148 ),
149 )
150 }
151 }
152 return f.error()
153}
154
155func (api *API) checkTypeStmt() error {
156 f := newFilter()

Callers 1

SelfCheckMethod · 0.95

Calls 11

getAtServerValueMethod · 0.95
SyntaxErrorFunction · 0.92
NewTokenNodeFunction · 0.92
newFilterFunction · 0.85
addCheckItemMethod · 0.80
checkNodeWithPrefixMethod · 0.80
FormatMethod · 0.65
addMethod · 0.65
PosMethod · 0.65
checkMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected