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 171x 171x 171x 10x 10x 10x 161x 161x 171x 14x 14x 171x 123x 147x 24x 24x 24x 161x 161x 161x 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 static 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;
  }
}