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

100% Statements 43/43
100% Branches 11/11
100% Functions 1/1
100% Lines 43/43

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 37 38 39 40 41 42 43 441x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 21x 21x 3x 3x 3x 18x 21x 13x 13x 13x 13x 13x 13x 13x 1x 1x 1x 1x 13x 12x 12x 5x 21x 2x 2x 5x 5x 5x 5x 5x 1x 1x  
import * as Expressions from "../../2_statements/expressions";
import {ExpressionNode, StatementNode} from "../../nodes";
import {TableType, UnknownType, VoidType} from "../../types/basic";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
import {SQLSetOpGroup} from "./sql_set_op_group";
import {SQLSource} from "./sql_source";
 
export class SQLIn {
 
  public static runSyntax(node: ExpressionNode | StatementNode, input: SyntaxInput): void {
 
    const setop = node.findDirectExpression(Expressions.SQLSetOpGroup);
    if (setop) {
      SQLSetOpGroup.runSyntax(setop, input);
      return;
    }
 
    if (node.getChildren().length === 2) {
      const insource = node.findFirstExpression(Expressions.SQLSource);
      if (insource) {
        const intype = SQLSource.runSyntax(insource, input);
        if (intype &&
            !(intype instanceof VoidType) &&
            !(intype instanceof UnknownType) &&
            !(intype instanceof TableType)) {
          const message = "IN, not a table";
          input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
          return;
        }
      }
      return;
    }
 
    for (const s of node.findDirectExpressions(Expressions.SQLSource)) {
      SQLSource.runSyntax(s, input);
    }
    for (const s of node.findDirectExpressions(Expressions.SQLSourceNoSpace)) {
      SQLSource.runSyntax(s, input);
    }
 
  }
 
}