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

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

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 321x 1x 1x 1x 1x 1x 1x 1x 1x 223x 223x 223x 223x 223x 15x 15x 15x 208x 208x 223x 15x 15x 223x 152x 193x 41x 41x 41x 208x 208x 208x 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 rawName = token.getStr();
    const starPrefixed = rawName.startsWith("*");
    const name = starPrefixed ? rawName.substring(1) : rawName;
    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;
  }
}