All files / src/abap/2_statements/expressions sql_path_segment.ts

100% Statements 39/39
100% Branches 4/4
100% Functions 2/2
100% Lines 39/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 401x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x  
import {seq, tok, optPrio, altPrio, regex as reg, Expression, ver} from "../combi";
import {BracketLeftW, WBracketRight, WBracketRightW, AssociationName} from "../../1_lexer/tokens";
import {IStatementRunnable} from "../statement_runnable";
import {SQLCDSParameters} from "./sql_cds_parameters";
import {SQLCond} from "./sql_cond";
import {SQLPathCardinality} from "./sql_path_cardinality";
import {SQLPathJoinType} from "./sql_path_join_type";
import {Release} from "../../../version";
 
export class SQLPathSegment extends Expression {
  private readonly nws: boolean;
 
  public constructor(nws: boolean = false) {
    super();
    this.nws = nws;
  }
 
  public getRunnable(): IStatementRunnable {
    const joinTag = optPrio(ver(Release.v795, reg(/^#[A-Z][A-Z0-9_]*$/i)));
    const filter = ver(Release.v751, seq(
      tok(BracketLeftW),
      joinTag,
      optPrio(SQLPathCardinality),
      optPrio(SQLPathJoinType),
      optPrio(seq(optPrio("WHERE"), SQLCond)),
      altPrio(tok(WBracketRightW), tok(WBracketRight)),
    ));
    const params = ver(Release.v751, SQLCDSParameters);
 
    const name = this.nws
      ? tok(AssociationName)
      : altPrio(tok(AssociationName), reg(/^\\[\w]+$/));
 
    return ver(Release.v740sp05, seq(name, optPrio(altPrio(
      seq(params, optPrio(filter)),
      filter,
    ))));
  }
}