WalkSets returns the expressions in order of evaluation.
(walk eval.SetWalker)
| 56 | |
| 57 | // WalkSets returns the expressions in order of evaluation. |
| 58 | func (r *RootExpr) WalkSets(walk eval.SetWalker) { |
| 59 | if r.API == nil { |
| 60 | name := "API" |
| 61 | if len(r.Services) > 0 { |
| 62 | name = r.Services[0].Name |
| 63 | } |
| 64 | r.API = NewAPIExpr(name, func() {}) |
| 65 | } |
| 66 | |
| 67 | // Top level API DSL |
| 68 | walk(eval.ExpressionSet{r.API}) |
| 69 | |
| 70 | // Servers |
| 71 | walk(eval.ToExpressionSet(r.API.Servers)) |
| 72 | |
| 73 | // User types |
| 74 | types := make(eval.ExpressionSet, len(r.Types)) |
| 75 | for i, t := range r.Types { |
| 76 | types[i] = t.Attribute() |
| 77 | } |
| 78 | walk(types) |
| 79 | |
| 80 | // Result types, note: initialized when the generated result types are |
| 81 | // walked so empty the first time around (in the first pass DSL |
| 82 | // execution). See ResultTypesRoot.WalkSets for details. |
| 83 | rtypes := make(eval.ExpressionSet, len(r.ResultTypes)) |
| 84 | for i, rt := range r.ResultTypes { |
| 85 | rtypes[i] = rt |
| 86 | } |
| 87 | walk(rtypes) |
| 88 | |
| 89 | // Services |
| 90 | walk(eval.ToExpressionSet(r.Services)) |
| 91 | |
| 92 | // Methods (must be done after services) |
| 93 | var methods eval.ExpressionSet |
| 94 | for _, s := range r.Services { |
| 95 | for _, m := range s.Methods { |
| 96 | methods = append(methods, m) |
| 97 | } |
| 98 | } |
| 99 | walk(methods) |
| 100 | |
| 101 | // HTTP services and endpoints |
| 102 | r.walkHTTPServices(r.API.HTTP.Services, walk) |
| 103 | |
| 104 | // JSON-RPC services and endpoints |
| 105 | r.walkHTTPServices(r.API.JSONRPC.Services, walk) |
| 106 | |
| 107 | // GRPC services and endpoints |
| 108 | grpcsvcs := make(eval.ExpressionSet, len(r.API.GRPC.Services)) |
| 109 | sort.SliceStable(r.API.GRPC.Services, func(i, j int) bool { |
| 110 | return r.API.GRPC.Services[j].ParentName == r.API.GRPC.Services[i].Name() |
| 111 | }) |
| 112 | var grpcepts eval.ExpressionSet |
| 113 | for i, svc := range r.API.GRPC.Services { |
| 114 | grpcsvcs[i] = svc |
| 115 | for _, e := range svc.GRPCEndpoints { |
nothing calls this directly
no test coverage detected