All files / src/abap/2_statements/statements method_def.ts

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

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 43 44 45 46 47 48 49 50 51 52 531x 1x 1x 1x 1x 1x 1x 1x 1x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 621x 1x 1x
import {Version} from "../../../version";
import {IStatement} from "./_statement";
import {seq, alt, altPrio, ver, regex as reg, optPrio} from "../combi";
import {MethodDefChanging, MethodDefReturning, Redefinition, MethodName, MethodDefExporting, MethodDefImporting, EventHandler, Abstract, MethodDefRaising, MethodDefExceptions, MethodParamName, NamespaceSimpleName, TypeName} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
 
export class MethodDef implements IStatement {
 
  public getMatcher(): IStatementRunnable {
 
    const def = ver(Version.v740sp08, seq("DEFAULT", altPrio("FAIL", "IGNORE")));
 
    const parameters = seq(optPrio(altPrio("FINAL", def, Abstract)),
                           optPrio(MethodDefImporting),
                           optPrio(MethodDefExporting),
                           optPrio(MethodDefChanging),
                           optPrio(MethodDefReturning),
                           optPrio(altPrio(MethodDefRaising, MethodDefExceptions)));
 
    const testing = seq(optPrio(Abstract), "FOR TESTING", optPrio(altPrio(MethodDefRaising, MethodDefExceptions)));
 
// todo, this is only from version something
    const tableFunction = seq("TABLE FUNCTION", reg(/^\w+?$/));
// todo, this is only from version something
    const ddl = "DDL OBJECT OPTIONS CDS SESSION CLIENT REQUIRED";
 
    const behavior = altPrio(
      seq("VALIDATE ON SAVE IMPORTING", MethodParamName, "FOR", TypeName),
      seq("MODIFY IMPORTING", MethodParamName, "FOR ACTION", TypeName, "RESULT", MethodParamName),
      seq("FEATURES IMPORTING", MethodParamName, "REQUEST", NamespaceSimpleName, "FOR", NamespaceSimpleName, "RESULT", MethodParamName),
      seq("DETERMINE ON MODIFY IMPORTING", MethodParamName, "FOR", TypeName));
 
// todo, this is only from version something
    const amdp = seq(
      "AMDP OPTIONS CDS SESSION CLIENT CURRENT",
      optPrio(MethodDefImporting),
      optPrio(MethodDefExporting),
      optPrio(MethodDefRaising));
 
    const ret = seq(altPrio("CLASS-METHODS", "METHODS"),
                    MethodName,
                    alt(seq(optPrio(Abstract), EventHandler),
                        parameters,
                        testing,
                        seq("FOR", alt(tableFunction, ddl, behavior)),
                        amdp,
                        "NOT AT END OF MODE",
                        optPrio(Redefinition)));
 
    return ret;
  }
 
}