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

100% Statements 29/29
100% Branches 8/8
100% Functions 1/1
100% Lines 29/29

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 291x 1x 1x 1x 1x 1x 1x 1x 1x 131x 131x 131x 8x 8x 8x 123x 123x 131x 14x 131x 90x 109x 19x 19x 19x 109x 109x 109x 1x
import {DataDefinition, Table, View} from "../../../objects";
import {ExpressionNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {ReferenceType} from "../_reference";
 
export type DatabaseTableSource = Table | DataDefinition | View | undefined;
 
export class DatabaseTable {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string): DatabaseTableSource {
    const token = node.getFirstToken();
    const name = token.getStr();
    if (name === "(") {
      // dynamic
      return undefined;
    }
 
    const found = scope.getDDIC().lookupTableOrView2(name);
    if (found === undefined && scope.getDDIC().inErrorNamespace(name) === true) {
      throw new Error("Database table or view \"" + name + "\" not found");
    } else if (found === undefined) {
      scope.addReference(token, undefined, ReferenceType.TableVoidReference, filename);
    } else {
      scope.addReference(token, found.getIdentifier(), ReferenceType.TableReference, filename);
      scope.getDDICReferences().addUsing(scope.getParentObj(), {object: found, token: token, filename: filename});
    }
 
    return found;
  }
}