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

Method checkTypeExprContext

tools/goctl/pkg/parser/api/parser/api.go:202–232  ·  view source on GitHub ↗
(declareContext map[string]placeholder.Type, tp ast.DataType)

Source from the content-addressed store, hash-verified

200}
201
202func (api *API) checkTypeExprContext(declareContext map[string]placeholder.Type, tp ast.DataType) error {
203 switch val := tp.(type) {
204 case *ast.ArrayDataType:
205 return api.checkTypeExprContext(declareContext, val.DataType)
206 case *ast.BaseDataType:
207 if IsBaseType(val.Base.Token.Text) {
208 return nil
209 }
210 _, ok := declareContext[val.Base.Token.Text]
211 if !ok {
212 return ast.SyntaxError(val.Base.Pos(), "unresolved type <%s>", val.Base.Token.Text)
213 }
214 return nil
215 case *ast.MapDataType:
216 var manager = newErrorManager()
217 manager.add(api.checkTypeExprContext(declareContext, val.Key))
218 manager.add(api.checkTypeExprContext(declareContext, val.Value))
219 return manager.error()
220 case *ast.PointerDataType:
221 return api.checkTypeExprContext(declareContext, val.DataType)
222 case *ast.SliceDataType:
223 return api.checkTypeExprContext(declareContext, val.DataType)
224 case *ast.StructDataType:
225 var manager = newErrorManager()
226 for _, e := range val.Elements {
227 manager.add(api.checkTypeExprContext(declareContext, e.DataType))
228 }
229 return manager.error()
230 }
231 return nil
232}
233
234func (api *API) getAtServerValue(atServer *ast.AtServerStmt, key string) string {
235 if atServer == nil {

Callers 1

checkTypeContextMethod · 0.95

Calls 6

SyntaxErrorFunction · 0.92
IsBaseTypeFunction · 0.85
newErrorManagerFunction · 0.85
PosMethod · 0.65
addMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected