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 {CurrentScope} from "../5_syntax/_current_scope";
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";
 
export class EventDefinition extends Identifier implements IEventDefinition {
  private readonly parameters: TypedIdentifier[];
 
  public constructor(node: StatementNode, _visibility: Visibility, filename: string, scope: CurrentScope) {
    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(), filename);
 
    this.parameters = [];
    this.parse(node, filename, scope);
  }
 
  public getParameters(): readonly TypedIdentifier[] {
    return this.parameters;
  }
 
///////////////
 
  private parse(node: StatementNode, filename: string, scope: CurrentScope) {
    for (const e of node.findAllExpressions(MethodParamExpression)) {
      this.parameters.push(new MethodParam().runSyntax(e, scope, filename, []));
    }
  }
 
}