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

100% Statements 30/30
100% Branches 9/9
100% Functions 1/1
100% Lines 30/30

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 301x 1x 1x 1x 1x 1x 1x 1x 1x 159x 159x 159x 10x 10x 10x 149x 149x 159x 14x 14x 159x 116x 135x 19x 19x 19x 149x 149x 149x 1x
import {DataDefinition, Table, View} from "../../../objects";
import {ExpressionNode} from "../../nodes";
import {ReferenceType} from "../_reference";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
 
export type DatabaseTableSource = Table | DataDefinition | View | undefined;
 
export class DatabaseTable {
  public runSyntax(node: ExpressionNode, input: SyntaxInput): DatabaseTableSource {
    const token = node.getFirstToken();
    const name = token.getStr();
    if (name === "(") {
      // dynamic
      return undefined;
    }
 
    const found = input.scope.getDDIC().lookupTableOrView2(name);
    if (found === undefined && input.scope.getDDIC().inErrorNamespace(name) === true) {
      const message = "Database table or view \"" + name + "\" not found";
      input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
    } else if (found === undefined) {
      input.scope.addReference(token, undefined, ReferenceType.TableVoidReference, input.filename);
    } else {
      input.scope.addReference(token, found.getIdentifier(), ReferenceType.TableReference, input.filename);
      input.scope.getDDICReferences().addUsing(input.scope.getParentObj(), {object: found, token: token, filename: input.filename});
    }
 
    return found;
  }
}