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

94.44% Statements 34/36
63.63% Branches 7/11
100% Functions 1/1
94.44% Lines 34/36

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 361x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 16x 16x 16x 3x 3x 16x 3x 3x 16x 16x 16x 16x 16x 15x 16x 13x 13x 13x     15x 15x 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.findAllExpressions(Expressions.Source);
    const firstSource = sources[0];
    let sourceType = new Source().runSyntax(firstSource, scope, filename);
 
    if (sourceType === undefined || node.findDirectExpression(Expressions.AssignSource)?.findDirectExpression(Expressions.Dynamic)) {
      sourceType = new VoidType("DynamicAssign");
    }
    for (const d of node.findDirectExpression(Expressions.AssignSource)?.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);
    }
 
  }
}