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

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

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 1201x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x  
import {IStatement} from "./_statement";
import {verNot, str, seq, altPrio, optPrio, alt, opt, per, regex as reg, tok} from "../combi";
import {ParenLeft, WParenLeft, ParenRightW, ParenRight} from "../../1_lexer/tokens";
import {Integer, Source, Field, Modif, Constant, InlineField, TextElement, BlockName} from "../expressions";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
 
export class SelectionScreen implements IStatement {
 
  public getMatcher(): IStatementRunnable {
    const beginBlock = seq("BEGIN OF BLOCK",
                           BlockName,
                           optPrio("WITH FRAME"),
                           optPrio(seq("TITLE", alt(InlineField, TextElement))),
                           optPrio("NO INTERVALS"));
    const endBlock = seq("END OF BLOCK", BlockName);
 
    const nesting = seq("NESTING LEVEL", Source);
 
    const scrOptions = per(seq("AS", alt("WINDOW", "SUBSCREEN")),
                           seq("TITLE", alt(InlineField, TextElement)),
                           "NO INTERVALS",
                           nesting);
 
    const beginScreen = seq("BEGIN OF SCREEN",
                            Integer,
                            opt(scrOptions));
 
    const endScreen = seq("END OF SCREEN", Integer);
 
    const beginLine = str("BEGIN OF LINE");
    const endLine = str("END OF LINE");
 
    const modif = seq("MODIF ID", Modif);
 
    const visible = seq("VISIBLE LENGTH", reg(/^\d+$/));
 
    const commentOpt = per(seq("FOR FIELD", Field), modif, visible);
 
    const position = seq(opt(reg(/^\/?[\d\w]+$/)),
                         altPrio(tok(ParenLeft), tok(WParenLeft)),
                         Integer,
                         altPrio(tok(ParenRightW), tok(ParenRight)));
 
    const comment = seq("COMMENT",
                        position,
                        opt(alt(InlineField, TextElement)),
                        opt(commentOpt));
 
    const command = seq("USER-COMMAND", alt(Field, Constant));
 
    const push = seq("PUSHBUTTON",
                     position,
                     alt(InlineField, TextElement),
                     command,
                     opt(modif),
                     opt(visible));
 
    const prog = seq("PROGRAM", Field);
    const def = seq("DEFAULT", opt(prog), "SCREEN", Integer);
 
    const tab = seq("TAB",
                    tok(WParenLeft),
                    Integer,
                    tok(ParenRightW),
                    alt(InlineField, TextElement),
                    command,
                    opt(def),
                    opt(modif));
 
    const func = seq("FUNCTION KEY", Integer);
 
    const skip = seq("SKIP", opt(Integer));
 
    const posSymbols = altPrio("POS_LOW", "POS_HIGH");
 
    // number between 1 and 83
    const posIntegers = reg(/^(0?[1-9]|[1234567][0-9]|8[0-3])$/);
 
    const pos = seq("POSITION",
                    altPrio(posIntegers, posSymbols));
 
    const incl = seq("INCLUDE BLOCKS", BlockName);
 
    const tabbed = seq("BEGIN OF TABBED BLOCK",
                       InlineField,
                       "FOR",
                       Integer,
                       "LINES",
                       optPrio("NO INTERVALS"));
 
    const uline = seq("ULINE", opt(position));
 
    const param = seq("INCLUDE PARAMETERS", Field);
    const iso = seq("INCLUDE SELECT-OPTIONS", Field);
 
    const ret = seq("SELECTION-SCREEN",
                    altPrio(comment,
                            func,
                            skip,
                            pos,
                            incl,
                            iso,
                            push,
                            tab,
                            uline,
                            beginBlock,
                            tabbed,
                            endBlock,
                            beginLine,
                            endLine,
                            param,
                            beginScreen,
                            endScreen));
 
    return verNot(Version.Cloud, ret);
  }
 
}