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

84.61% Statements 22/26
66.66% Branches 2/3
100% Functions 1/1
84.61% Lines 22/26

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 261x 1x 1x 1x 1x 1x 1x 1x 1x 19x 19x 19x 1x 1x         1x 1x 1x 1x 1x 19x 19x 1x
import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {ReferenceType} from "../_reference";
import {StatementSyntax} from "../_statement_syntax";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
import {Source} from "../expressions/source";
 
export class Return implements StatementSyntax {
  public runSyntax(node: StatementNode, input: SyntaxInput): void {
 
    const source = node.findDirectExpression(Expressions.Source);
    if (source) {
      const ret = input.scope.findReturningParameter();
      if (ret === undefined) {
        const message = "Method does not have a RETURNING parameter to assign to";
        input.issues.push(syntaxIssue(input, source.getFirstToken(), message));
        return;
      }
 
      input.scope.addReference(source.getFirstToken(), ret, ReferenceType.DataReadReference, input.filename);
 
      Source.runSyntax(source, input, ret.getType());
    }
 
  }
}