All files / src/abap/5_syntax/expressions field_assignment.ts

85.71% Statements 12/14
70% Branches 7/10
100% Functions 1/1
85.71% Lines 12/14

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               13x 13x       13x 13x       13x 13x 9x     13x      
import * as Expressions from "../../2_statements/expressions";
import {ExpressionNode, StatementNode} from "../../nodes";
import {StructureType} from "../../types/basic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {CurrentScope} from "../_current_scope";
import {Source} from "./source";
 
export class FieldAssignment {
 
  public runSyntax(
    node: ExpressionNode | StatementNode,
    scope: CurrentScope,
    filename: string,
    targetType: AbstractType | undefined): void {
 
    const name = node.findDirectExpression(Expressions.FieldSub)?.concatTokens();
    Iif (name === undefined) {
      throw new Error("FieldAssignment, FieldSub node not found");
    }
 
    const s = node.findDirectExpression(Expressions.Source);
    Iif (s === undefined) {
      throw new Error("FieldAssignment, Source node not found");
    }
 
    let type: AbstractType | undefined = undefined;
    if (targetType instanceof StructureType) {
      type = targetType.getComponentByName(name);
    }
 
    new Source().runSyntax(s, scope, filename, type);
  }
 
}