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

88.23% Statements 30/34
71.42% Branches 5/7
100% Functions 1/1
88.23% Lines 30/34

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 341x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1023x 1023x 1023x 976x 976x 976x 976x 47x 47x 1023x         47x 47x 47x 1023x 23x 23x 23x 1023x 1023x 1x
import {ExpressionNode, StatementNode} from "../../nodes";
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";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
 
export class Call implements StatementSyntax {
  public runSyntax(node: StatementNode, input: SyntaxInput): void {
    const children = node.getChildren();
 
    if (children.length === 2) {
      const first = children[0] as ExpressionNode;
      MethodCallChain.runSyntax(first, input);
      return;
    }
 
    const methodSource = children[2] as ExpressionNode;
    if (methodSource === undefined) {
      const message = "Call, child MethodSource not found";
      input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
      return;
    }
    const methodDef = MethodSource.runSyntax(methodSource, input);
 
    const body = children[3];
    if (body instanceof ExpressionNode) {
      // todo, resolve the method definition above and pass, if possible, in case of dynamic pass void
      MethodCallBody.runSyntax(body, input, methodDef || VoidType.get("CallTODO"));
    }
 
  }
}