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

93.75% Statements 30/32
71.42% Branches 5/7
100% Functions 1/1
93.75% Lines 30/32

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 321x 1x 1x 1x 1x 1x 1x 1x 1x 1x 221x 221x 221x 195x 195x 195x 195x 26x 26x 221x     26x 26x 26x 221x 12x 12x 12x 221x 221x 1x
import {ExpressionNode, 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 children = node.getChildren();
 
    if (children.length === 2) {
      const first = children[0] as ExpressionNode;
      new MethodCallChain().runSyntax(first, scope, filename);
      return;
    }
 
    const methodSource = children[2] as ExpressionNode;
    if (methodSource === undefined) {
      throw new Error("Call, child MethodSource not found");
    }
    const methodDef = new MethodSource().runSyntax(methodSource, scope, filename);
 
    const body = children[3];
    if (body instanceof ExpressionNode) {
      // 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"));
    }
 
  }
}