(declareContext map[string]placeholder.Type, tp ast.DataType)
| 200 | } |
| 201 | |
| 202 | func (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 | |
| 234 | func (api *API) getAtServerValue(atServer *ast.AtServerStmt, key string) string { |
| 235 | if atServer == nil { |
no test coverage detected