UNPKG

@abaplint/core

Version:
81 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArtifactsABAP = void 0; const Statements = require("./2_statements/statements"); const Expressions = require("./2_statements/expressions"); const combi_1 = require("./2_statements/combi"); const Structures = require("./3_structures/structures"); class List { constructor() { this.words = []; } add(keywords, source) { for (const w of keywords) { const index = this.find(w); if (index >= 0) { this.words[index].source.push(source); } else { this.words.push({ word: w, source: [source] }); } } } get() { return this.words; } find(keyword) { for (let i = 0; i < this.words.length; i++) { if (this.words[i].word === keyword) { return i; } } return -1; } } function className(cla) { return cla.constructor.name; } class ArtifactsABAP { static getStructures() { const ret = []; const list = Structures; for (const key in Structures) { if (typeof list[key] === "function") { ret.push(new list[key]()); } } return ret; } static getExpressions() { const ret = []; const list = Expressions; for (const key in Expressions) { if (typeof list[key] === "function") { ret.push(list[key]); } } return ret; } static getStatements() { const ret = []; const list = Statements; for (const key in Statements) { if (typeof list[key] === "function") { ret.push(new list[key]()); } } return ret; } static getKeywords() { const list = new List(); for (const stat of this.getStatements()) { list.add(combi_1.Combi.listKeywords(stat.getMatcher()), "statement_" + className(stat)); } for (const expr of this.getExpressions()) { list.add(combi_1.Combi.listKeywords(new expr().getRunnable()), "expression_" + className(expr)); } return list.get(); } } exports.ArtifactsABAP = ArtifactsABAP; //# sourceMappingURL=artifacts.js.map