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

94.59% Statements 35/37
87.5% Branches 7/8
100% Functions 1/1
94.59% Lines 35/37

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 371x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 3x 3x 9x 9x 3x 3x 9x 9x 9x 9x 9x 8x 9x 6x 6x 6x     8x 8x 1x
import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {Source} from "../expressions/source";
import {FSTarget} from "../expressions/fstarget";
import {Dynamic} from "../expressions/dynamic";
import {VoidType} from "../../types/basic";
import {StatementSyntax} from "../_statement_syntax";
 
export class Assign implements StatementSyntax {
  public runSyntax(node: StatementNode, scope: CurrentScope, filename: string): void {
    const sources = node.findDirectExpressions(Expressions.Source);
    const firstSource = sources[0];
    let sourceType = new Source().runSyntax(firstSource, scope, filename);
 
    if (sourceType === undefined || node.findDirectExpression(Expressions.Dynamic)) {
      sourceType = new VoidType("DynamicAssign");
    }
 
    for (const d of node.findAllExpressions(Expressions.Dynamic)) {
      new Dynamic().runSyntax(d, scope, filename);
    }
 
    const target = node.findDirectExpression(Expressions.FSTarget);
    if (target) {
      new FSTarget().runSyntax(target, scope, filename, sourceType);
    }
 
    for (const s of sources) {
      if (s === firstSource) {
        continue;
      }
      new Source().runSyntax(s, scope, filename);
    }
 
  }
}