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

89.18% Statements 33/37
84.61% Branches 11/13
100% Functions 1/1
89.18% Lines 33/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 74x 74x 243x 162x 79x 162x 2x 83x 81x 81x 81x 81x 1x 1x 1x 1x 81x         162x 243x 73x 1x 1x
import * as Expressions from "../../2_statements/expressions";
import {ExpressionNode} from "../../nodes";
import {AbstractType} from "../../types/basic/_abstract_type";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
import {TypeUtils} from "../_type_utils";
import {ComponentChain} from "./component_chain";
import {Source} from "./source";
 
export class ComponentCompareSimple {
 
  public static runSyntax(node: ExpressionNode, input: SyntaxInput, rowType: AbstractType): void {
    let targetType: AbstractType | undefined = undefined;
    for (const c of node.getChildren()) {
      if (c instanceof ExpressionNode) {
        if (c.get() instanceof Expressions.ComponentChainSimple) {
          targetType = ComponentChain.runSyntax(rowType, c, input);
        } else if (c.get() instanceof Expressions.Dynamic) {
          targetType = undefined;
        } else if (c.get() instanceof Expressions.Source
            || c.get() instanceof Expressions.SimpleSource4
            || c.get() instanceof Expressions.SimpleSource2) {
          const sourceType = Source.runSyntax(c, input, targetType);
          if (targetType && new TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) {
            const message = "ComponentCompareSimple, incompatible types";
            input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
            return;
          }
        } else {
          const message = "ComponentCompareSimple, unexpected node";
          input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
          return;
        }
      }
    }
  }
 
}