UNPKG

@abaplint/core

Version:
47 lines 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UpdateDatabase = void 0; const Expressions = require("../../2_statements/expressions"); const source_1 = require("../expressions/source"); const _scope_type_1 = require("../_scope_type"); const basic_1 = require("../../types/basic"); const _typed_identifier_1 = require("../../types/_typed_identifier"); const identifier_1 = require("../../1_lexer/tokens/identifier"); const database_table_1 = require("../expressions/database_table"); const dynamic_1 = require("../expressions/dynamic"); class UpdateDatabase { runSyntax(node, input) { const dbtab = node.findFirstExpression(Expressions.DatabaseTable); if (dbtab !== undefined) { database_table_1.DatabaseTable.runSyntax(dbtab, input); } const tableName = node.findDirectExpression(Expressions.DatabaseTable); const tokenName = tableName === null || tableName === void 0 ? void 0 : tableName.getFirstToken(); if (tableName && tokenName) { // todo, this also finds structures, it should only find transparent tables const found = input.scope.getDDIC().lookupTable(tokenName.getStr()); if (found instanceof basic_1.StructureType) { input.scope.push(_scope_type_1.ScopeType.OpenSQL, "UPDATE", tokenName.getStart(), input.filename); for (const field of found.getComponents()) { const fieldToken = new identifier_1.Identifier(node.getFirstToken().getStart(), field.name); const id = new _typed_identifier_1.TypedIdentifier(fieldToken, input.filename, field.type); input.scope.addIdentifier(id); } } } for (const s of node.findAllExpressions(Expressions.Source)) { source_1.Source.runSyntax(s, input); } for (const s of node.findAllExpressions(Expressions.SimpleSource3)) { source_1.Source.runSyntax(s, input); } for (const d of node.findAllExpressions(Expressions.Dynamic)) { dynamic_1.Dynamic.runSyntax(d, input); } if (input.scope.getType() === _scope_type_1.ScopeType.OpenSQL) { input.scope.pop(node.getLastToken().getEnd()); } } } exports.UpdateDatabase = UpdateDatabase; //# sourceMappingURL=update_database.js.map