VisitWith visits the node
(ctx *antlrgen.WithContext)
| 252 | |
| 253 | // VisitWith visits the node |
| 254 | func (v *ASTBuilder) VisitWith(ctx *antlrgen.WithContext) interface{} { |
| 255 | v.Logger.Debugf("VisitWith: %s", ctx.GetText()) |
| 256 | |
| 257 | location := v.getLocation(ctx) |
| 258 | level, levelWith, levelQuery := v.getCtxLevels(v.SQL2AqlCtx) |
| 259 | mapKey := v.SQL2AqlCtx.mapKey |
| 260 | levelWith++ |
| 261 | levelQuery++ |
| 262 | |
| 263 | if levelWith > maxlevelWith { |
| 264 | panic(fmt.Errorf("only support %v level with query at (line:%d, col:%d)", |
| 265 | maxlevelWith, location.Line, location.CharPosition)) |
| 266 | } |
| 267 | |
| 268 | if ctx.RECURSIVE() != nil { |
| 269 | panic(fmt.Errorf("RECURSIVE not yet supported at (line:%d, col:%d)", |
| 270 | location.Line, location.CharPosition)) |
| 271 | } |
| 272 | |
| 273 | ctxArr := ctx.AllNamedQuery() |
| 274 | arrWithQuery := make([]*tree.WithQuery, len(ctxArr)) |
| 275 | for i, c := range ctxArr { |
| 276 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 277 | v.SQL2AqlCtx.mapKey = v.generateKey(levelQuery, typeWithQuery, i) |
| 278 | v.SQL2AqlCtx.MapMeasures[v.SQL2AqlCtx.mapKey] = make([]queryCom.Measure, 0, defaultSliceCap) |
| 279 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] = make([]queryCom.Dimension, 0, defaultSliceCap) |
| 280 | v.SQL2AqlCtx.MapJoinTables[v.SQL2AqlCtx.mapKey] = make([]queryCom.Join, 0, defaultSliceCap) |
| 281 | v.SQL2AqlCtx.MapRowFilters[v.SQL2AqlCtx.mapKey] = make([]string, 0, defaultSliceCap) |
| 282 | v.SQL2AqlCtx.MapOrderBy[v.SQL2AqlCtx.mapKey] = make([]queryCom.SortField, 0, defaultSliceCap) |
| 283 | |
| 284 | arrWithQuery[i], _ = v.VisitNamedQuery(c.(*antlrgen.NamedQueryContext)).(*tree.WithQuery) |
| 285 | } |
| 286 | with := tree.NewWith(v.getLocation(ctx), false, arrWithQuery) |
| 287 | with.SetValue(fmt.Sprintf("With: (%s)", v.getText(ctx.BaseParserRuleContext))) |
| 288 | |
| 289 | v.setCtxLevels(v.SQL2AqlCtx, level-1, levelWith-1, levelQuery-1) |
| 290 | v.SQL2AqlCtx.mapKey = mapKey |
| 291 | return with |
| 292 | } |
| 293 | |
| 294 | // VisitNamedQuery visits the node |
| 295 | func (v *ASTBuilder) VisitNamedQuery(ctx *antlrgen.NamedQueryContext) interface{} { |
nothing calls this directly
no test coverage detected