All files / src/cds/expressions cds_condition.ts

100% Statements 16/16
100% Branches 1/1
100% Functions 1/1
100% Lines 16/16

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 161x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
import {CDSFunction, CDSName, CDSString} from ".";
import {alt, altPrio, Expression, opt, optPrio, seq, star} from "../../abap/2_statements/combi";
import {IStatementRunnable} from "../../abap/2_statements/statement_runnable";
import {CDSInteger} from "./cds_integer";
 
export class CDSCondition extends Expression {
  public getRunnable(): IStatementRunnable {
    const name = seq(CDSName, opt(seq(".", alt(CDSName, CDSString))));
    const left = alt(name, CDSFunction);
    const compare = seq(left, alt("=", seq("!", "="), seq("<", ">"), "<", ">", seq(">", "="), seq("<", "="), "LIKE", "NOT LIKE"), alt(left, CDSInteger, CDSFunction, CDSString));
    const is = seq(left, "IS", optPrio("NOT"), altPrio("INITIAL", "NULL"));
    const condition = alt(compare, is);
    const paren = seq("(", CDSCondition, ")");
    return seq(alt(condition, paren), star(seq(alt("AND", "OR"), alt(condition, paren))));
  }
}