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

89.18% Statements 33/37
83.33% Branches 10/12
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 84x     84x 84x 84x 68x 68x 84x 84x 36x 36x 84x     48x 48x 48x 260x 54x 260x 54x 54x 260x 48x 84x 1x
import {ExpressionNode} from "../../nodes";
import * as Expressions from "../../2_statements/expressions";
import {Source} from "./source";
import {SyntaxInput} from "../_syntax_input";
import {AbstractType} from "../../..";
import {TableType} from "../../types/basic";
import {ComponentChain} from "./component_chain";
 
export class TableExpression {
  public static runSyntax(node: ExpressionNode | undefined, input: SyntaxInput, rowType: AbstractType | undefined) {
    if (node === undefined) {
      return;
    }
 
    let context = rowType;
    if (context instanceof TableType) {
      context = context.getRowType();
    }
 
    if (node.getChildren().length === 3) {
      const s = node.findDirectExpression(Expressions.Source);
      Source.runSyntax(s, input, context);
    } else if (node.findDirectTokenByText("INDEX")) {
      const s = node.findDirectExpression(Expressions.Source);
      Source.runSyntax(s, input);
    } else {
      let fieldType: AbstractType | undefined = undefined;
      for (const c of node.getChildren()) {
        if (c instanceof ExpressionNode && c.get() instanceof Expressions.ComponentChainSimple) {
          fieldType = ComponentChain.runSyntax(context, c, input);
        } else if (c instanceof ExpressionNode && c.get() instanceof Expressions.Source) {
          Source.runSyntax(c, input, fieldType);
        }
      }
    }
  }
}