All files / src/cds/expressions cds_function.ts

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

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 40 41 42 431x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
import {CDSArithmetics, CDSCase, CDSCast, CDSName, CDSParameters, CDSString} from ".";
import {altPrio, Expression, opt, regex, seq, starPrio} from "../../abap/2_statements/combi";
import {IStatementRunnable} from "../../abap/2_statements/statement_runnable";
 
export class CDSFunction extends Expression {
  public getRunnable(): IStatementRunnable {
    const qualified = seq(CDSName, opt(CDSParameters), starPrio(seq(".", CDSName, opt(CDSParameters))));
    const input = altPrio(CDSCast, CDSFunction, CDSArithmetics, CDSCase, CDSString, qualified, regex(/^\d+$/), );
 
    const coalesce = seq("COALESCE", "(", input, ",", input, ")");
    const concat = seq("CONCAT", "(", input, ",", input, ")");
    const concat_with_space = seq("CONCAT_WITH_SPACE", "(", input, ",", input, ",", input, ")");
    const dats_add_days = seq("DATS_ADD_DAYS", "(", input, ",", input, ",", input, ")");
    const dats_add_months = seq("DATS_ADD_MONTHS", "(", input, ",", input, ",", input, ")");
    const dats_days_between = seq("DATS_DAYS_BETWEEN", "(", input, ",", input, ")");
    const dats_is_valid = seq("DATS_IS_VALID", "(", input, ")");
    const substring = seq("SUBSTRING", "(", input, ",", input, ",", input, ")");
 
    const bintohex = seq("BINTOHEX", "(", input, ")");
    const hextobin = seq("HEXTOBIN", "(", input, ")");
 
    const tstmp_to_dats = seq("TSTMP_TO_DATS", "(", input, ",", input, ",", input, ",", input, ")");
    const tstmp_to_tims = seq("TSTMP_TO_TIMS", "(", input, ",", input, ",", input, ",", input, ")");
    const tstmp_to_dst = seq("TSTMP_TO_DST", "(", input, ",", input, ",", input, ",", input, ")");
    const dats_tims_to_tstmp = seq("DATS_TIMS_TO_TSTMP", "(", input, ",", input, ",", input, ",", input, ",", input, ")");
 
    const tstmp_is_valid = seq("TSTMP_IS_VALID", "(", input, ")");
    const tstmp_current_utctimestamp = seq("TSTMP_CURRENT_UTCTIMESTAMP", "(", ")");
    const tstmp_seconds_between = seq("TSTMP_SECONDS_BETWEEN", "(", input, ",", input, ",", input, ")");
    const tstmp_add_seconds = seq("TSTMP_ADD_SECONDS", "(", input, ",", input, ",", input, ")");
 
    const abap_system_timezone = seq("ABAP_SYSTEM_TIMEZONE", "(", input, ",", input, ")");
    const abap_user_timezone = seq("ABAP_USER_TIMEZONE", "(", input, ",", input, ",", input, ")");
 
    const mod = seq("MOD", "(", input, ",", input, ")");
 
    return altPrio(substring, coalesce, tstmp_to_dats, concat, tstmp_to_tims,
                   concat_with_space, dats_is_valid, dats_days_between, tstmp_add_seconds,
                   tstmp_seconds_between, tstmp_current_utctimestamp, tstmp_is_valid,
                   abap_system_timezone, abap_user_timezone, bintohex, hextobin,
                   dats_add_days, dats_add_months, tstmp_to_dst, dats_tims_to_tstmp, mod);
  }
}