All files / src/abap/5_syntax/statements call.ts

93.54% Statements 29/31
71.42% Branches 5/7
100% Functions 1/1
93.54% Lines 29/31

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 311x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 211x 211x 185x 185x 185x 26x 26x 211x     26x 26x 26x 211x 12x 12x 12x 211x 211x 1x
import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {MethodCallChain} from "../expressions/method_call_chain";
import {MethodSource} from "../expressions/method_source";
import {MethodCallBody} from "../expressions/method_call_body";
import {VoidType} from "../../types/basic/void_type";
import {StatementSyntax} from "../_statement_syntax";
 
export class Call implements StatementSyntax {
  public runSyntax(node: StatementNode, scope: CurrentScope, filename: string): void {
    const chain = node.findDirectExpression(Expressions.MethodCallChain);
    if (chain) {
      new MethodCallChain().runSyntax(chain, scope, filename);
      return;
    }
 
    const methodSource = node.findDirectExpression(Expressions.MethodSource);
    if (methodSource === undefined) {
      throw new Error("Call, child MethodSource not found");
    }
    const methodDef = new MethodSource().runSyntax(methodSource, scope, filename);
 
    const body = node.findDirectExpression(Expressions.MethodCallBody);
    if (body) {
      // todo, resolve the method definition above and pass, if possible, in case of dynamic pass void
      new MethodCallBody().runSyntax(body, scope, filename, methodDef || new VoidType("CallTODO"));
    }
 
  }
}