All files / src/abap/types event_definition.ts

90.24% Statements 37/41
66.66% Branches 4/6
100% Functions 3/3
90.24% Lines 37/41

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 411x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x     12x 12x     12x 12x 12x 12x 12x 1x 1x 17x 17x 1x 1x 1x 1x 12x 7x 7x 12x 1x 1x
import {Identifier} from "../4_file_information/_identifier";
import {IEventDefinition} from "./_event_definition";
import * as Expressions from "../2_statements/expressions";
import {Visibility} from "../4_file_information/visibility";
import {StatementNode} from "../nodes/statement_node";
import {Events} from "../2_statements/statements/events";
import {TypedIdentifier} from "./_typed_identifier";
import {MethodParam as MethodParamExpression} from "../2_statements/expressions";
import {MethodParam} from "../5_syntax/expressions/method_param";
import {SyntaxInput} from "../5_syntax/_syntax_input";
 
export class EventDefinition extends Identifier implements IEventDefinition {
  private readonly parameters: TypedIdentifier[];
 
  public constructor(node: StatementNode, _visibility: Visibility, input: SyntaxInput) {
    if (!(node.get() instanceof Events)) {
      throw new Error("MethodDefinition, expected MethodDef as part of input node");
    }
    const found = node.findFirstExpression(Expressions.EventName);
    if (found === undefined) {
      throw new Error("MethodDefinition, expected MethodDef as part of input node");
    }
    super(found.getFirstToken(), input.filename);
 
    this.parameters = [];
    this.parse(node, input);
  }
 
  public getParameters(): readonly TypedIdentifier[] {
    return this.parameters;
  }
 
///////////////
 
  private parse(node: StatementNode, input: SyntaxInput) {
    for (const e of node.findAllExpressions(MethodParamExpression)) {
      this.parameters.push(new MethodParam().runSyntax(e, input, []));
    }
  }
 
}