@abaplint/cli 2.93.4 → 2.93.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +4 -4
- package/package.json +2 -2
- package/build/src/apack_dependency_provider.js +0 -30
- package/build/src/compressed_file.js +0 -22
- package/build/src/file_operations.js +0 -48
- package/build/src/fixes.js +0 -110
- package/build/src/formatters/_format.js +0 -23
- package/build/src/formatters/_iformatter.js +0 -3
- package/build/src/formatters/codeframe.js +0 -74
- package/build/src/formatters/index.js +0 -22
- package/build/src/formatters/json.js +0 -28
- package/build/src/formatters/junit.js +0 -91
- package/build/src/formatters/standard.js +0 -61
- package/build/src/formatters/total.js +0 -10
- package/build/src/index.d.ts +0 -20
- package/build/src/index.js +0 -207
- package/build/src/rename.js +0 -98
package/build/cli.js
CHANGED
|
@@ -60,7 +60,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
60
60
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
61
61
|
|
|
62
62
|
"use strict";
|
|
63
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ApplyFixes = void 0;\r\n/* eslint-disable max-len */\r\nconst core_1 = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass ApplyFixes {\r\n constructor() {\r\n this.changedFiles = new Set();\r\n }\r\n // Strategy:\r\n // Execute one rule at a time and apply fixes for that rule\r\n // Some rules are quite expensive to initialize(like downport),\r\n // so running all rules every time is expensive.\r\n async applyFixes(reg, fs, quiet) {\r\n let iteration =
|
|
63
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ApplyFixes = void 0;\r\n/* eslint-disable max-len */\r\nconst core_1 = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass ApplyFixes {\r\n constructor() {\r\n this.changedFiles = new Set();\r\n }\r\n // Strategy:\r\n // Execute one rule at a time and apply fixes for that rule\r\n // Some rules are quite expensive to initialize(like downport),\r\n // so running all rules every time is expensive.\r\n async applyFixes(reg, fs, quiet) {\r\n let iteration = 0;\r\n this.changedFiles.clear();\r\n const MAX_ITERATIONS = 50000;\r\n const objects = new core_1.RulesRunner(reg).objectsToCheck(reg.getObjects());\r\n const rules = reg.getConfig().getEnabledRules();\r\n while (iteration <= MAX_ITERATIONS) {\r\n let changed = 0;\r\n for (const rule of rules) {\r\n while (iteration <= MAX_ITERATIONS) {\r\n const before = Date.now();\r\n rule.initialize(reg);\r\n const issues = [];\r\n for (const obj of objects) {\r\n issues.push(...rule.run(obj));\r\n }\r\n iteration++;\r\n const appliedCount = this.applyList(issues, reg).length;\r\n const runtime = Date.now() - before;\r\n if (quiet !== true) {\r\n process.stderr.write(`\\tIteration ${iteration}, ${appliedCount} fixes applied, ${runtime}ms, \\trule ${rule.getMetadata().key}\\n`);\r\n }\r\n if (appliedCount > 0) {\r\n changed += appliedCount;\r\n const before = Date.now();\r\n reg.parse();\r\n const runtime = Date.now() - before;\r\n if (quiet !== true) {\r\n process.stderr.write(`\\tParse, ${runtime}ms\\n`);\r\n }\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n if (changed === 0) {\r\n break;\r\n }\r\n }\r\n this.writeChangesToFS(fs, reg);\r\n }\r\n ///////////////////////////////////////////////////\r\n writeChangesToFS(fs, reg) {\r\n for (const filename of this.changedFiles.values()) {\r\n const file = reg.getFileByName(filename);\r\n if (file === undefined) {\r\n continue;\r\n }\r\n fs.writeFileSync(file.getFilename(), file.getRaw());\r\n }\r\n }\r\n possibleOverlap(edit, list) {\r\n // only checks if the edits have changes in the same rows\r\n for (const e of list) {\r\n for (const file1 of Object.keys(e)) {\r\n for (const file2 of Object.keys(edit)) {\r\n if (file1 === file2) {\r\n for (const list1 of e[file1]) {\r\n for (const list2 of edit[file2]) {\r\n if (list2.range.start.getRow() <= list1.range.start.getRow()\r\n && list2.range.end.getRow() >= list1.range.start.getRow()) {\r\n return true;\r\n }\r\n if (list2.range.start.getRow() <= list1.range.start.getRow()\r\n && list2.range.end.getRow() >= list1.range.end.getRow()) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n applyList(issues, reg) {\r\n const edits = [];\r\n for (const i of issues) {\r\n const edit = i.getFix();\r\n if (edit === undefined) {\r\n continue;\r\n }\r\n else if (this.possibleOverlap(edit, edits) === true) {\r\n continue;\r\n }\r\n edits.push(edit);\r\n }\r\n const changed = (0, core_1.applyEditList)(reg, edits);\r\n for (const filename of changed) {\r\n this.changedFiles.add(filename);\r\n }\r\n return changed;\r\n }\r\n}\r\nexports.ApplyFixes = ApplyFixes;\r\n//# sourceMappingURL=fixes.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./build/src/fixes.js?");
|
|
64
64
|
|
|
65
65
|
/***/ }),
|
|
66
66
|
|
|
@@ -148,7 +148,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
148
148
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
149
149
|
|
|
150
150
|
"use strict";
|
|
151
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.run = exports.GENERIC_ERROR = void 0;\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst os = __webpack_require__(/*! os */ \"os\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst ProgressBar = __webpack_require__(/*! progress */ \"./node_modules/progress/index.js\");\r\nconst childProcess = __webpack_require__(/*! child_process */ \"child_process\");\r\nconst JSON5 = __webpack_require__(/*! json5 */ \"./node_modules/json5/dist/index.mjs\");\r\nconst core_1 = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst _format_1 = __webpack_require__(/*! ./formatters/_format */ \"./build/src/formatters/_format.js\");\r\nconst file_operations_1 = __webpack_require__(/*! ./file_operations */ \"./build/src/file_operations.js\");\r\nconst apack_dependency_provider_1 = __webpack_require__(/*! ./apack_dependency_provider */ \"./build/src/apack_dependency_provider.js\");\r\nconst fixes_1 = __webpack_require__(/*! ./fixes */ \"./build/src/fixes.js\");\r\nconst rename_1 = __webpack_require__(/*! ./rename */ \"./build/src/rename.js\");\r\nexports.GENERIC_ERROR = \"generic_error\";\r\nclass Progress {\r\n set(total, _text) {\r\n this.bar = new ProgressBar(\":percent - :elapseds - :text\", { total, renderThrottle: 100 });\r\n }\r\n async tick(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n tickSync(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n}\r\nfunction loadConfig(filename) {\r\n // possible cases:\r\n // a) nothing specified, using abaplint.json from cwd\r\n // b) nothing specified, no abaplint.json in cwd\r\n // c) specified and found\r\n // d) specified and not found => use default\r\n // e) supplied but a directory => use default\r\n let f = \"\";\r\n if (filename === undefined) {\r\n f = process.cwd() + path.sep + \"abaplint.json\";\r\n if (fs.existsSync(f) === false) {\r\n f = process.cwd() + path.sep + \"abaplint.jsonc\";\r\n }\r\n if (fs.existsSync(f) === false) {\r\n f = process.cwd() + path.sep + \"abaplint.json5\";\r\n }\r\n if (fs.existsSync(f) === false) {\r\n process.stderr.write(\"Using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n }\r\n else {\r\n if (fs.existsSync(filename) === false) {\r\n process.stderr.write(\"ERROR: Specified abaplint configuration file does not exist, using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n else if (fs.statSync(filename).isDirectory() === true) {\r\n process.stderr.write(\"Supply filename, not directory, using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n f = filename;\r\n }\r\n // evil hack to get JSON5 working\r\n if (JSON5.parse === undefined) {\r\n // @ts-ignore\r\n JSON5.parse = JSON5.default.parse;\r\n }\r\n process.stderr.write(\"Using config: \" + f + \"\\n\");\r\n const json = fs.readFileSync(f, \"utf8\");\r\n const parsed = JSON5.parse(json);\r\n const vers = core_1.Version;\r\n if (Object.keys(core_1.Version).some(v => vers[v] === parsed.syntax.version) === false) {\r\n throw \"Error: Unknown version in abaplint.json\";\r\n }\r\n return {\r\n config: new core_1.Config(json),\r\n base: path.dirname(f) === process.cwd() ? \".\" : path.dirname(f),\r\n };\r\n}\r\nasync function loadDependencies(config, compress, bar, base) {\r\n let files = [];\r\n const deps = config.get().dependencies || [];\r\n const useApack = config.get().global.useApackDependencies;\r\n if (useApack) {\r\n const apackPath = path.join(base, \".apack-manifest.xml\");\r\n if (fs.existsSync(apackPath)) {\r\n const apackManifest = fs.readFileSync(apackPath, \"utf8\");\r\n deps.push(...apack_dependency_provider_1.ApackDependencyProvider.fromManifest(apackManifest));\r\n }\r\n }\r\n if (!deps) {\r\n return [];\r\n }\r\n for (const d of deps) {\r\n if (d.folder) {\r\n const g = base + d.folder + d.files;\r\n const names = file_operations_1.FileOperations.loadFileNames(g, false);\r\n if (names.length > 0) {\r\n process.stderr.write(\"Using dependency from: \" + g + \"\\n\");\r\n files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));\r\n continue;\r\n }\r\n }\r\n if (d.url) {\r\n process.stderr.write(\"Clone: \" + d.url + \"\\n\");\r\n const dir = fs.mkdtempSync(path.join(os.tmpdir(), \"abaplint-\"));\r\n childProcess.execSync(\"git clone --quiet --depth 1 \" + d.url + \" .\", { cwd: dir, stdio: \"inherit\" });\r\n const names = file_operations_1.FileOperations.loadFileNames(dir + d.files);\r\n files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));\r\n file_operations_1.FileOperations.deleteFolderRecursive(dir);\r\n }\r\n }\r\n return files;\r\n}\r\nfunction displayHelp() {\r\n // follow https://docopt.org conventions,\r\n return \"Usage:\\n\" +\r\n \" abaplint [<abaplint.json> -f <format> -c --outformat <format> --outfile <file> --fix] \\n\" +\r\n \" abaplint -h | --help show this help\\n\" +\r\n \" abaplint -v | --version show version\\n\" +\r\n \" abaplint -d | --default show default configuration\\n\" +\r\n \"\\n\" +\r\n \"Options:\\n\" +\r\n \" -f, --format <format> output format (standard, total, json, summary, junit, codeframe)\\n\" +\r\n \" --outformat <format> output format, use in combination with outfile\\n\" +\r\n \" --outfile <file> output issues to file in format\\n\" +\r\n \" --fix apply quick fixes to files\\n\" +\r\n \" --rename rename object according to rules in abaplint.json\\n\" +\r\n \" -p output performance information\\n\" +\r\n \" -c compress files in memory\\n\";\r\n}\r\nfunction out(issues, length, arg) {\r\n const output = _format_1.Formatter.format(issues, arg.format, length);\r\n if (arg.outFormat && arg.outFile) {\r\n const fileContents = _format_1.Formatter.format(issues, arg.outFormat, length);\r\n fs.writeFileSync(arg.outFile, fileContents, \"utf-8\");\r\n }\r\n return output;\r\n}\r\nasync function run(arg) {\r\n var _a, _b;\r\n // evil hack to get JSON5 working\r\n if (JSON5.parse === undefined) {\r\n // @ts-ignore\r\n JSON5.parse = JSON5.default.parse;\r\n }\r\n if (JSON5.stringify === undefined) {\r\n // @ts-ignore\r\n JSON5.stringify = JSON5.default.stringify;\r\n }\r\n let output = \"\";\r\n let issues = [];\r\n let reg = undefined;\r\n const progress = new Progress();\r\n if (arg.showHelp === true) {\r\n output = output + displayHelp();\r\n }\r\n else if (arg.showVersion === true) {\r\n output = output + core_1.Registry.abaplintVersion() + \"\\n\";\r\n }\r\n else if (arg.outputDefaultConfig === true) {\r\n output = output + JSON.stringify(core_1.Config.getDefault().get(), undefined, 2) + \"\\n\";\r\n }\r\n else {\r\n process.stderr.write(\"abaplint \" + core_1.Registry.abaplintVersion() + \"\\n\");\r\n let loaded = [];\r\n let deps = [];\r\n const { config, base } = loadConfig(arg.configFilename);\r\n try {\r\n if (config.get().global.files === undefined) {\r\n throw \"Error: Update abaplint configuration file to latest format\";\r\n }\r\n const files = file_operations_1.FileOperations.loadFileNames(base + config.get().global.files);\r\n loaded = await file_operations_1.FileOperations.loadFiles(arg.compress, files, progress);\r\n deps = await loadDependencies(config, arg.compress, progress, base);\r\n reg = new core_1.Registry(config);\r\n reg.addDependencies(deps);\r\n reg.addFiles(loaded); // if the object exists in repo, it should take precedence over deps\r\n await reg.parseAsync({ progress, outputPerformance: arg.parsingPerformance });\r\n issues = issues.concat(reg.findIssues({ progress, outputPerformance: arg.parsingPerformance }));\r\n }\r\n catch (error) {\r\n const file = new core_1.MemoryFile(\"generic\", \"dummy\");\r\n const message = error.toString() + \" \" + ((_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(\"\\n\")[1]) === null || _b === void 0 ? void 0 : _b.trim());\r\n const issue = core_1.Issue.atPosition(file, new core_1.Position(1, 1), message, exports.GENERIC_ERROR);\r\n issues = [issue];\r\n }\r\n let extra = \"\";\r\n if (arg.runFix === true && reg) {\r\n issues = [];\r\n await new fixes_1.ApplyFixes().applyFixes(reg, fs);\r\n extra = \"Fixes applied\";\r\n }\r\n else if (arg.runRename === true && reg) {\r\n if (issues.length === 0) {\r\n new rename_1.Rename(reg).run(config, base);\r\n extra = \"Renames applied\";\r\n }\r\n else {\r\n extra = \"Renames NOT applied, issues found\";\r\n }\r\n }\r\n output = out(issues, loaded.length, arg) + extra;\r\n }\r\n return { output, issues, reg };\r\n}\r\nexports.run = run;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./build/src/index.js?");
|
|
151
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.run = exports.GENERIC_ERROR = void 0;\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst os = __webpack_require__(/*! os */ \"os\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst ProgressBar = __webpack_require__(/*! progress */ \"./node_modules/progress/index.js\");\r\nconst childProcess = __webpack_require__(/*! child_process */ \"child_process\");\r\nconst JSON5 = __webpack_require__(/*! json5 */ \"./node_modules/json5/dist/index.mjs\");\r\nconst core_1 = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst _format_1 = __webpack_require__(/*! ./formatters/_format */ \"./build/src/formatters/_format.js\");\r\nconst file_operations_1 = __webpack_require__(/*! ./file_operations */ \"./build/src/file_operations.js\");\r\nconst apack_dependency_provider_1 = __webpack_require__(/*! ./apack_dependency_provider */ \"./build/src/apack_dependency_provider.js\");\r\nconst fixes_1 = __webpack_require__(/*! ./fixes */ \"./build/src/fixes.js\");\r\nconst rename_1 = __webpack_require__(/*! ./rename */ \"./build/src/rename.js\");\r\nexports.GENERIC_ERROR = \"generic_error\";\r\nclass Progress {\r\n set(total, _text) {\r\n this.bar = new ProgressBar(\":percent - :elapseds - :text\", { total, renderThrottle: 100 });\r\n }\r\n async tick(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n tickSync(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n}\r\nfunction loadConfig(filename) {\r\n // possible cases:\r\n // a) nothing specified, using abaplint.json from cwd\r\n // b) nothing specified, no abaplint.json in cwd\r\n // c) specified and found\r\n // d) specified and not found => use default\r\n // e) supplied but a directory => use default\r\n let f = \"\";\r\n if (filename === undefined) {\r\n f = process.cwd() + path.sep + \"abaplint.json\";\r\n if (fs.existsSync(f) === false) {\r\n f = process.cwd() + path.sep + \"abaplint.jsonc\";\r\n }\r\n if (fs.existsSync(f) === false) {\r\n f = process.cwd() + path.sep + \"abaplint.json5\";\r\n }\r\n if (fs.existsSync(f) === false) {\r\n process.stderr.write(\"Using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n }\r\n else {\r\n if (fs.existsSync(filename) === false) {\r\n process.stderr.write(\"ERROR: Specified abaplint configuration file does not exist, using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n else if (fs.statSync(filename).isDirectory() === true) {\r\n process.stderr.write(\"Supply filename, not directory, using default config\\n\");\r\n return { config: core_1.Config.getDefault(), base: \".\" };\r\n }\r\n f = filename;\r\n }\r\n // evil hack to get JSON5 working\r\n if (JSON5.parse === undefined) {\r\n // @ts-ignore\r\n JSON5.parse = JSON5.default.parse;\r\n }\r\n process.stderr.write(\"Using config: \" + f + \"\\n\");\r\n const json = fs.readFileSync(f, \"utf8\");\r\n const parsed = JSON5.parse(json);\r\n const vers = core_1.Version;\r\n if (Object.keys(core_1.Version).some(v => vers[v] === parsed.syntax.version) === false) {\r\n throw \"Error: Unknown version in abaplint.json\";\r\n }\r\n return {\r\n config: new core_1.Config(json),\r\n base: path.dirname(f) === process.cwd() ? \".\" : path.dirname(f),\r\n };\r\n}\r\nasync function loadDependencies(config, compress, bar, base) {\r\n let files = [];\r\n const deps = config.get().dependencies || [];\r\n const useApack = config.get().global.useApackDependencies;\r\n if (useApack) {\r\n const apackPath = path.join(base, \".apack-manifest.xml\");\r\n if (fs.existsSync(apackPath)) {\r\n const apackManifest = fs.readFileSync(apackPath, \"utf8\");\r\n deps.push(...apack_dependency_provider_1.ApackDependencyProvider.fromManifest(apackManifest));\r\n }\r\n }\r\n if (!deps) {\r\n return [];\r\n }\r\n for (const d of deps) {\r\n if (d.folder) {\r\n const g = base + d.folder + d.files;\r\n const names = file_operations_1.FileOperations.loadFileNames(g, false);\r\n if (names.length > 0) {\r\n process.stderr.write(\"Using dependency from: \" + g + \"\\n\");\r\n files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));\r\n continue;\r\n }\r\n }\r\n if (d.url) {\r\n process.stderr.write(\"Clone: \" + d.url + \"\\n\");\r\n const dir = fs.mkdtempSync(path.join(os.tmpdir(), \"abaplint-\"));\r\n childProcess.execSync(\"git clone --quiet --depth 1 \" + d.url + \" .\", { cwd: dir, stdio: \"inherit\" });\r\n const names = file_operations_1.FileOperations.loadFileNames(dir + d.files);\r\n files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));\r\n file_operations_1.FileOperations.deleteFolderRecursive(dir);\r\n }\r\n }\r\n return files;\r\n}\r\nfunction displayHelp() {\r\n // follow https://docopt.org conventions,\r\n return \"Usage:\\n\" +\r\n \" abaplint [<abaplint.json> -f <format> -c --outformat <format> --outfile <file> --fix] \\n\" +\r\n \" abaplint -h | --help show this help\\n\" +\r\n \" abaplint -v | --version show version\\n\" +\r\n \" abaplint -d | --default show default configuration\\n\" +\r\n \"\\n\" +\r\n \"Options:\\n\" +\r\n \" -f, --format <format> output format (standard, total, json, summary, junit, codeframe)\\n\" +\r\n \" --outformat <format> output format, use in combination with outfile\\n\" +\r\n \" --outfile <file> output issues to file in format\\n\" +\r\n \" --fix apply quick fixes to files\\n\" +\r\n \" --rename rename object according to rules in abaplint.json\\n\" +\r\n \" -p output performance information\\n\" +\r\n \" -c compress files in memory\\n\";\r\n}\r\nfunction out(issues, length, arg) {\r\n const output = _format_1.Formatter.format(issues, arg.format, length);\r\n if (arg.outFormat && arg.outFile) {\r\n const fileContents = _format_1.Formatter.format(issues, arg.outFormat, length);\r\n fs.writeFileSync(arg.outFile, fileContents, \"utf-8\");\r\n }\r\n return output;\r\n}\r\nasync function run(arg) {\r\n var _a, _b;\r\n // evil hack to get JSON5 working\r\n if (JSON5.parse === undefined) {\r\n // @ts-ignore\r\n JSON5.parse = JSON5.default.parse;\r\n }\r\n if (JSON5.stringify === undefined) {\r\n // @ts-ignore\r\n JSON5.stringify = JSON5.default.stringify;\r\n }\r\n let output = \"\";\r\n let issues = [];\r\n let reg = undefined;\r\n const progress = new Progress();\r\n if (arg.showHelp === true) {\r\n output = output + displayHelp();\r\n }\r\n else if (arg.showVersion === true) {\r\n output = output + core_1.Registry.abaplintVersion() + \"\\n\";\r\n }\r\n else if (arg.outputDefaultConfig === true) {\r\n output = output + JSON.stringify(core_1.Config.getDefault().get(), undefined, 2) + \"\\n\";\r\n }\r\n else {\r\n process.stderr.write(\"abaplint \" + core_1.Registry.abaplintVersion() + \"\\n\");\r\n let loaded = [];\r\n let deps = [];\r\n const { config, base } = loadConfig(arg.configFilename);\r\n try {\r\n if (config.get().global.files === undefined) {\r\n throw \"Error: Update abaplint configuration file to latest format\";\r\n }\r\n const files = file_operations_1.FileOperations.loadFileNames(base + config.get().global.files);\r\n loaded = await file_operations_1.FileOperations.loadFiles(arg.compress, files, progress);\r\n deps = await loadDependencies(config, arg.compress, progress, base);\r\n reg = new core_1.Registry(config);\r\n reg.addDependencies(deps);\r\n reg.addFiles(loaded); // if the object exists in repo, it should take precedence over deps\r\n await reg.parseAsync({ progress, outputPerformance: arg.parsingPerformance });\r\n if (arg.runFix !== true) {\r\n issues = issues.concat(reg.findIssues({ progress, outputPerformance: arg.parsingPerformance }));\r\n }\r\n }\r\n catch (error) {\r\n const file = new core_1.MemoryFile(\"generic\", \"dummy\");\r\n const message = error.toString() + \" \" + ((_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(\"\\n\")[1]) === null || _b === void 0 ? void 0 : _b.trim());\r\n const issue = core_1.Issue.atPosition(file, new core_1.Position(1, 1), message, exports.GENERIC_ERROR);\r\n issues = [issue];\r\n }\r\n let extra = \"\";\r\n if (arg.runFix === true && reg) {\r\n await new fixes_1.ApplyFixes().applyFixes(reg, fs);\r\n issues = [...reg.findIssues()]; // used in exercism ABAP test runner\r\n extra = \"Fixes applied\";\r\n }\r\n else if (arg.runRename === true && reg) {\r\n if (issues.length === 0) {\r\n new rename_1.Rename(reg).run(config, base);\r\n extra = \"Renames applied\";\r\n }\r\n else {\r\n extra = \"Renames NOT applied, issues found\";\r\n }\r\n }\r\n output = out(issues, loaded.length, arg) + extra;\r\n }\r\n return { output, issues, reg };\r\n}\r\nexports.run = run;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./build/src/index.js?");
|
|
152
152
|
|
|
153
153
|
/***/ }),
|
|
154
154
|
|
|
@@ -6649,7 +6649,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
6649
6649
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6650
6650
|
|
|
6651
6651
|
"use strict";
|
|
6652
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BasicTypes = void 0;\r\n/* eslint-disable default-case */\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\r\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\r\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\r\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\r\nclass BasicTypes {\r\n constructor(filename, scope) {\r\n this.filename = filename;\r\n this.scope = scope;\r\n }\r\n lookupQualifiedName(name) {\r\n var _a;\r\n // argh, todo, rewrite this entire method\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n const found = this.scope.findType(name);\r\n if (found) {\r\n return found;\r\n }\r\n if (name.includes(\"=>\")) {\r\n const split = name.split(\"=>\");\r\n const ooName = split[0];\r\n const typeName = split[1];\r\n const oo = this.scope.findObjectDefinition(ooName);\r\n if (oo) {\r\n const f = oo.getTypeDefinitions().getByName(typeName);\r\n if (f) {\r\n return f;\r\n }\r\n }\r\n }\r\n else if (name.includes(\"-\")) {\r\n const split = name.split(\"-\");\r\n const typeName = split[0];\r\n const fieldName = split[1];\r\n const type = this.scope.findType(typeName);\r\n if (type) {\r\n const stru = type.getType();\r\n if (stru instanceof basic_1.StructureType) {\r\n const f = stru.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\r\n }\r\n }\r\n }\r\n }\r\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\r\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\r\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\r\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\r\n }\r\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\r\n if (builtin) {\r\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\r\n }\r\n const type = this.scope.findTypePoolType(name);\r\n if (type) {\r\n return type;\r\n }\r\n return undefined;\r\n }\r\n resolveLikeName(node, headerLogic = true) {\r\n var _a;\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n let chain = node.findFirstExpression(Expressions.FieldChain);\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.TypeName);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.FieldSub);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n }\r\n if (chain === undefined) {\r\n throw new Error(\"resolveLikeName, chain undefined\");\r\n }\r\n const fullName = chain.concatTokens();\r\n const children = [...chain.getChildren()];\r\n if (children.length === 0) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\r\n }\r\n let type = undefined;\r\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\r\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\r\n }\r\n else {\r\n const name = children.shift().getFirstToken().getStr();\r\n let found = this.scope.findVariable(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n if (found === undefined) {\r\n found = this.scope.findExtraLikeType(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n }\r\n if (found) {\r\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (type === undefined) {\r\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\r\n }\r\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\r\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n while (children.length > 0) {\r\n const child = children.shift();\r\n if (child.getFirstToken().getStr() === \"-\") {\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n }\r\n else if (child.concatTokens() === \"[]\") {\r\n if (type instanceof Types.TableType) {\r\n type = new basic_1.TableType(type.getRowType(), { withHeader: false });\r\n }\r\n }\r\n else { // field name\r\n let sub = undefined;\r\n if (type instanceof Types.TableType) {\r\n type = type.getRowType();\r\n }\r\n if (type instanceof Types.StructureType) {\r\n sub = type.getComponentByName(child.getFirstToken().getStr());\r\n }\r\n if (sub === undefined) {\r\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\r\n }\r\n type = sub;\r\n }\r\n }\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else if (type instanceof basic_1.TableType\r\n && type.isWithHeader()\r\n && headerLogic === true) {\r\n type = type.getRowType();\r\n }\r\n else if (type instanceof Types.TableType\r\n && type.isWithHeader() === true\r\n && type.getRowType() instanceof Types.VoidType) {\r\n return type.getRowType();\r\n }\r\n }\r\n if (!type) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\r\n }\r\n return type;\r\n }\r\n resolveTypeName(typeName, length, decimals, qualifiedName) {\r\n var _a;\r\n if (typeName === undefined) {\r\n return undefined;\r\n }\r\n let chain = this.resolveTypeChain(typeName);\r\n if (chain) {\r\n if (chain instanceof basic_1.CharacterType && qualifiedName) {\r\n chain = chain.cloneType(qualifiedName);\r\n }\r\n return chain;\r\n }\r\n const chainText = typeName.concatTokens().toUpperCase();\r\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\r\n if (f !== undefined) {\r\n return f;\r\n }\r\n const typ = this.scope.findType(chainText);\r\n if (typ) {\r\n const token = typeName.getFirstToken();\r\n if (chainText.includes(\"~\")) {\r\n const name = chainText.split(\"~\")[0];\r\n const idef = this.scope.findInterfaceDefinition(name);\r\n if (idef) {\r\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\r\n }\r\n }\r\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\r\n return typ.getType();\r\n }\r\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (type) {\r\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\r\n return type;\r\n }\r\n const ddic = this.scope.getDDIC().lookup(chainText);\r\n if (ddic) {\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\r\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else if (ddic.type instanceof basic_1.VoidType) {\r\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n }\r\n return ddic.type;\r\n }\r\n return undefined;\r\n }\r\n simpleType(node, qualifiedNamePrefix) {\r\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\r\n if (nameExpr === undefined) {\r\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\r\n }\r\n if (nameExpr === undefined) {\r\n return undefined;\r\n }\r\n let name = nameExpr.getFirstToken();\r\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\r\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\r\n }\r\n let qualifiedName = undefined;\r\n if (node.get() instanceof Statements.Type) {\r\n if (this.scope.isTypePool() === true) {\r\n qualifiedName = name.getStr();\r\n }\r\n else {\r\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\r\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\r\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\r\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\r\n }\r\n }\r\n }\r\n else if (qualifiedNamePrefix) {\r\n qualifiedName = qualifiedNamePrefix + qualifiedName;\r\n }\r\n const found = this.parseType(node, qualifiedName);\r\n if (found) {\r\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\r\n }\r\n return undefined;\r\n }\r\n parseTable(node, name) {\r\n var _a;\r\n const typename = node.findFirstExpression(Expressions.TypeName);\r\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n let type = undefined;\r\n if (text.includes(\" STANDARD TABLE \")) {\r\n type = basic_1.TableAccessType.standard;\r\n }\r\n else if (text.includes(\" SORTED TABLE \")) {\r\n type = basic_1.TableAccessType.sorted;\r\n }\r\n else if (text.includes(\" HASHED TABLE \")) {\r\n type = basic_1.TableAccessType.hashed;\r\n }\r\n const keyFields = [];\r\n if (type) {\r\n const keys = node.findFirstExpression(expressions_1.TypeTableKey);\r\n for (const k of (keys === null || keys === void 0 ? void 0 : keys.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n }\r\n const options = {\r\n withHeader: text.includes(\" WITH HEADER LINE\"),\r\n type: type,\r\n isUnique: text.includes(\" WITH UNIQUE\"),\r\n keyFields: keyFields,\r\n };\r\n let found = undefined;\r\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\r\n found = this.resolveTypeRef(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE TABLE OF \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\r\n found = this.resolveTypeName(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE TABLE OF \")\r\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\r\n || text.startsWith(\"LIKE SORTED TABLE OF \")\r\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\r\n found = this.resolveLikeName(node);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), options);\r\n }\r\n else if (text.startsWith(\"TYPE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ], name);\r\n return new Types.TableType(structure, options);\r\n }\r\n else if (text.startsWith(\"LIKE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n found = this.resolveLikeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ], name);\r\n return new Types.TableType(structure, options);\r\n }\r\n // fallback to old style syntax, OCCURS etc\r\n return this.parseType(node, name);\r\n }\r\n parseType(node, qualifiedName) {\r\n var _a, _b, _c, _d, _e, _f;\r\n const typeName = node.findFirstExpression(Expressions.TypeName);\r\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\r\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\r\n text = \"TYPE\";\r\n }\r\n }\r\n if (text === undefined) {\r\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = \"TYPE\";\r\n }\r\n let found = undefined;\r\n if (text.startsWith(\"LIKE LINE OF \")) {\r\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\r\n let e = node.findFirstExpression(Expressions.Type);\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n const type = this.resolveLikeName(e, false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n else if (type instanceof Types.TableType) {\r\n return type.getRowType();\r\n }\r\n else if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else {\r\n return new Types.UnknownType(\"Type error, not a table type \" + name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE REF TO \")) {\r\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\r\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n return new Types.DataReference(type, name);\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\") });\r\n }\r\n else if (text.startsWith(\"LIKE \")) {\r\n let sub = node.findFirstExpression(Expressions.Type);\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.TypeParam);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n found = this.resolveLikeName(sub);\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE LINE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\r\n found = found.getType();\r\n }\r\n if (found instanceof Types.TableType) {\r\n return found.getRowType();\r\n }\r\n else if (found instanceof Types.VoidType) {\r\n return found;\r\n }\r\n else if (found instanceof Types.UnknownType) {\r\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\r\n }\r\n else {\r\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE REF TO \")) {\r\n found = this.resolveTypeRef(typeName);\r\n }\r\n else if (text.startsWith(\"TYPE\")) {\r\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\r\n const concat = node.concatTokens().toUpperCase();\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\r\n if (found instanceof Types.VoidType) {\r\n found = new Types.TableType(found, { withHeader: true });\r\n }\r\n else if (!(found instanceof Types.TableType)) {\r\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\r\n }\r\n else {\r\n found = new Types.TableType(found.getRowType(), { withHeader: true });\r\n }\r\n }\r\n if (found === undefined && typeName === undefined) {\r\n let length = 1;\r\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\r\n if (len) {\r\n const int = len.findDirectExpression(Expressions.Integer);\r\n if (int) {\r\n length = parseInt(int.concatTokens(), 10);\r\n }\r\n }\r\n found = new Types.CharacterType(length, qualifiedName); // fallback\r\n if (this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n }\r\n return found;\r\n }\r\n /////////////////////\r\n isOccurs(node) {\r\n var _a;\r\n if (node.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n // todo, rewrite this method\r\n resolveTypeChain(expr) {\r\n var _a;\r\n const chainText = expr.concatTokens().toUpperCase();\r\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\r\n return undefined;\r\n }\r\n let className;\r\n let rest = chainText;\r\n if (chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n const subs = rest.split(\"-\");\r\n let foundType = undefined;\r\n if (className) {\r\n const split = chainText.split(\"=>\");\r\n const className = split[0];\r\n // the prefix might be itself\r\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\r\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\r\n const foundId = this.scope.findType(subs[0]);\r\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\r\n if (foundType === undefined) {\r\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\r\n }\r\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n // lookup in local and global scope\r\n const obj = this.scope.findObjectDefinition(className);\r\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\r\n return new Types.VoidType(className);\r\n }\r\n else if (obj === undefined) {\r\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\r\n }\r\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n }\r\n else {\r\n const found = this.scope.findType(subs[0]);\r\n foundType = found === null || found === void 0 ? void 0 : found.getType();\r\n if (foundType === undefined) {\r\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (typePoolType) {\r\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\r\n foundType = typePoolType;\r\n }\r\n if (foundType === undefined) {\r\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\r\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n foundType = f.type.getType();\r\n }\r\n else {\r\n foundType = f.type;\r\n }\r\n }\r\n }\r\n else {\r\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(subs[0]);\r\n }\r\n else if (foundType instanceof Types.VoidType) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return foundType;\r\n }\r\n else if (foundType === undefined) {\r\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\r\n }\r\n }\r\n subs.shift();\r\n while (subs.length > 0) {\r\n if (foundType instanceof Types.UnknownType\r\n || foundType instanceof Types.VoidType) {\r\n return foundType;\r\n }\r\n else if (!(foundType instanceof Types.StructureType)) {\r\n return new Types.UnknownType(\"Not a structured type\");\r\n }\r\n foundType = foundType.getComponentByName(subs[0]);\r\n subs.shift();\r\n }\r\n return foundType;\r\n }\r\n resolveConstantValue(expr) {\r\n var _a, _b;\r\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\r\n throw new Error(\"resolveConstantValue\");\r\n }\r\n const firstNode = expr.getFirstChild();\r\n const firstToken = firstNode.getFirstToken();\r\n const firstName = firstToken.getStr();\r\n if (firstNode.get() instanceof Expressions.Field) {\r\n const found = this.scope.findVariable(firstName);\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName\r\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\r\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\r\n const children = expr.getChildren();\r\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const found = this.scope.findVariable(token.getStr());\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName) {\r\n const obj = this.scope.findObjectDefinition(firstName);\r\n if (obj === undefined) {\r\n if (this.scope.existsObject(firstName).found === true) {\r\n return undefined;\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\r\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\r\n }\r\n else {\r\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\r\n return undefined;\r\n }\r\n }\r\n const children = expr.getChildren();\r\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\r\n const attr = token.getStr();\r\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\r\n if (c instanceof class_constant_1.ClassConstant) {\r\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n const val = c.getValue();\r\n if (typeof val === \"string\") {\r\n return val;\r\n }\r\n else if (typeof val === \"object\" && children[4]) {\r\n const name = children[4].getFirstToken().getStr();\r\n if (val[name] !== undefined) {\r\n return val[name];\r\n }\r\n }\r\n return undefined;\r\n }\r\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\r\n }\r\n else {\r\n throw new Error(\"resolveConstantValue, unexpected structure\");\r\n }\r\n }\r\n resolveTypeRef(chain) {\r\n var _a;\r\n if (chain === undefined) {\r\n return undefined;\r\n }\r\n const name = chain.getFirstToken().getStr();\r\n if (chain.getAllTokens().length === 1) {\r\n if (name.toUpperCase() === \"OBJECT\") {\r\n return new Types.GenericObjectReferenceType();\r\n }\r\n const search = this.scope.existsObject(name);\r\n if (search.found === true && search.id) {\r\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\r\n return new Types.ObjectReferenceType(search.id, name);\r\n }\r\n }\r\n const found = this.resolveTypeName(chain);\r\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\r\n return new Types.DataReference(found);\r\n }\r\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\r\n return new Types.DataReference(new Types.AnyType());\r\n }\r\n if (this.scope.isBadiDef(name) === true) {\r\n return new Types.VoidType(name);\r\n }\r\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\r\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\r\n }\r\n findValue(node) {\r\n const val = node.findFirstExpression(Expressions.Value);\r\n if (val === undefined) {\r\n throw new Error(\"VALUE missing in expression\");\r\n }\r\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\r\n return undefined;\r\n }\r\n const constant = val.findFirstExpression(Expressions.Constant);\r\n if (constant) {\r\n return constant.concatTokens();\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n return this.resolveConstantValue(chain);\r\n }\r\n throw new Error(\"findValue, unexpected\");\r\n }\r\n findDecimals(node) {\r\n var _a, _b;\r\n const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (dec) {\r\n return parseInt(dec, 10);\r\n }\r\n return undefined;\r\n }\r\n findLength(node) {\r\n const val = node.findFirstExpression(Expressions.Length);\r\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\r\n if (val && flen) {\r\n throw new Error(\"Only specify length once\");\r\n }\r\n if (flen) {\r\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\r\n if (cintExpr) {\r\n return this.parseInt(cintExpr.concatTokens());\r\n }\r\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (cchain) {\r\n const val = this.resolveConstantValue(cchain);\r\n return this.parseInt(val);\r\n }\r\n }\r\n if (val === undefined) {\r\n return 1;\r\n }\r\n const intExpr = val.findFirstExpression(Expressions.Integer);\r\n if (intExpr) {\r\n return this.parseInt(intExpr.concatTokens());\r\n }\r\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\r\n if (strExpr) {\r\n return this.parseInt(strExpr.concatTokens());\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n const val = this.resolveConstantValue(chain);\r\n return this.parseInt(val);\r\n }\r\n throw new Error(\"Unexpected, findLength\");\r\n }\r\n parseInt(text) {\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n if (text.startsWith(\"'\")) {\r\n text = text.split(\"'\")[1];\r\n }\r\n else if (text.startsWith(\"`\")) {\r\n text = text.split(\"`\")[1];\r\n }\r\n return parseInt(text, 10);\r\n }\r\n}\r\nexports.BasicTypes = BasicTypes;\r\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6652
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BasicTypes = void 0;\r\n/* eslint-disable default-case */\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\r\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\r\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\r\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\r\nclass BasicTypes {\r\n constructor(filename, scope) {\r\n this.filename = filename;\r\n this.scope = scope;\r\n }\r\n lookupQualifiedName(name) {\r\n var _a;\r\n // argh, todo, rewrite this entire method\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n const found = this.scope.findType(name);\r\n if (found) {\r\n return found;\r\n }\r\n if (name.includes(\"=>\")) {\r\n const split = name.split(\"=>\");\r\n const ooName = split[0];\r\n const typeName = split[1];\r\n const oo = this.scope.findObjectDefinition(ooName);\r\n if (oo) {\r\n const f = oo.getTypeDefinitions().getByName(typeName);\r\n if (f) {\r\n return f;\r\n }\r\n }\r\n }\r\n else if (name.includes(\"-\")) {\r\n const split = name.split(\"-\");\r\n const typeName = split[0];\r\n const fieldName = split[1];\r\n const type = this.scope.findType(typeName);\r\n if (type) {\r\n const stru = type.getType();\r\n if (stru instanceof basic_1.StructureType) {\r\n const f = stru.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\r\n }\r\n }\r\n }\r\n }\r\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\r\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\r\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\r\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\r\n }\r\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\r\n if (builtin) {\r\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\r\n }\r\n const type = this.scope.findTypePoolType(name);\r\n if (type) {\r\n return type;\r\n }\r\n return undefined;\r\n }\r\n resolveLikeName(node, headerLogic = true) {\r\n var _a;\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n let chain = node.findFirstExpression(Expressions.FieldChain);\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.TypeName);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.FieldSub);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n }\r\n if (chain === undefined) {\r\n throw new Error(\"resolveLikeName, chain undefined\");\r\n }\r\n const fullName = chain.concatTokens();\r\n const children = [...chain.getChildren()];\r\n if (children.length === 0) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\r\n }\r\n let type = undefined;\r\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\r\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\r\n }\r\n else {\r\n const name = children.shift().getFirstToken().getStr();\r\n let found = this.scope.findVariable(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n if (found === undefined) {\r\n found = this.scope.findExtraLikeType(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n }\r\n if (found) {\r\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (type === undefined) {\r\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\r\n }\r\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\r\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n while (children.length > 0) {\r\n const child = children.shift();\r\n if (child.getFirstToken().getStr() === \"-\") {\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n }\r\n else if (child.concatTokens() === \"[]\") {\r\n if (type instanceof Types.TableType) {\r\n type = new basic_1.TableType(type.getRowType(), { withHeader: false });\r\n }\r\n }\r\n else { // field name\r\n let sub = undefined;\r\n if (type instanceof Types.TableType) {\r\n type = type.getRowType();\r\n }\r\n if (type instanceof Types.StructureType) {\r\n sub = type.getComponentByName(child.getFirstToken().getStr());\r\n }\r\n if (sub === undefined) {\r\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\r\n }\r\n type = sub;\r\n }\r\n }\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else if (type instanceof basic_1.TableType\r\n && type.isWithHeader()\r\n && headerLogic === true) {\r\n type = type.getRowType();\r\n }\r\n else if (type instanceof Types.TableType\r\n && type.isWithHeader() === true\r\n && type.getRowType() instanceof Types.VoidType) {\r\n return type.getRowType();\r\n }\r\n }\r\n if (!type) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\r\n }\r\n return type;\r\n }\r\n resolveTypeName(typeName, length, decimals, qualifiedName) {\r\n var _a;\r\n if (typeName === undefined) {\r\n return undefined;\r\n }\r\n let chain = this.resolveTypeChain(typeName);\r\n if (chain) {\r\n if (chain instanceof basic_1.CharacterType && qualifiedName) {\r\n chain = chain.cloneType(qualifiedName);\r\n }\r\n return chain;\r\n }\r\n const chainText = typeName.concatTokens().toUpperCase();\r\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\r\n if (f !== undefined) {\r\n return f;\r\n }\r\n const typ = this.scope.findType(chainText);\r\n if (typ) {\r\n const token = typeName.getFirstToken();\r\n if (chainText.includes(\"~\")) {\r\n const name = chainText.split(\"~\")[0];\r\n const idef = this.scope.findInterfaceDefinition(name);\r\n if (idef) {\r\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\r\n }\r\n }\r\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\r\n return typ.getType();\r\n }\r\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (type) {\r\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\r\n return type;\r\n }\r\n const ddic = this.scope.getDDIC().lookup(chainText);\r\n if (ddic) {\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\r\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else if (ddic.type instanceof basic_1.VoidType) {\r\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n }\r\n return ddic.type;\r\n }\r\n return undefined;\r\n }\r\n simpleType(node, qualifiedNamePrefix) {\r\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\r\n if (nameExpr === undefined) {\r\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\r\n }\r\n if (nameExpr === undefined) {\r\n return undefined;\r\n }\r\n let name = nameExpr.getFirstToken();\r\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\r\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\r\n }\r\n let qualifiedName = undefined;\r\n if (node.get() instanceof Statements.Type) {\r\n if (this.scope.isTypePool() === true) {\r\n qualifiedName = name.getStr();\r\n }\r\n else {\r\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\r\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\r\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\r\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\r\n }\r\n }\r\n }\r\n else if (qualifiedNamePrefix) {\r\n qualifiedName = qualifiedNamePrefix + qualifiedName;\r\n }\r\n const found = this.parseType(node, qualifiedName);\r\n if (found) {\r\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\r\n }\r\n return undefined;\r\n }\r\n parseTable(node, name) {\r\n var _a;\r\n const typename = node.findFirstExpression(Expressions.TypeName);\r\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n let type = undefined;\r\n if (text.includes(\" STANDARD TABLE \")) {\r\n type = basic_1.TableAccessType.standard;\r\n }\r\n else if (text.includes(\" SORTED TABLE \")) {\r\n type = basic_1.TableAccessType.sorted;\r\n }\r\n else if (text.includes(\" HASHED TABLE \")) {\r\n type = basic_1.TableAccessType.hashed;\r\n }\r\n const keyFields = [];\r\n if (type) {\r\n const keys = node.findFirstExpression(expressions_1.TypeTableKey);\r\n for (const k of (keys === null || keys === void 0 ? void 0 : keys.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n }\r\n const options = {\r\n withHeader: text.includes(\" WITH HEADER LINE\"),\r\n type: type,\r\n isUnique: text.includes(\" WITH UNIQUE\"),\r\n keyFields: keyFields,\r\n };\r\n let found = undefined;\r\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\r\n found = this.resolveTypeRef(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE TABLE OF \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\r\n found = this.resolveTypeName(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE TABLE OF \")\r\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\r\n || text.startsWith(\"LIKE SORTED TABLE OF \")\r\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\r\n found = this.resolveLikeName(node);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), options);\r\n }\r\n else if (text.startsWith(\"TYPE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ]);\r\n return new Types.TableType(structure, options, name);\r\n }\r\n else if (text.startsWith(\"LIKE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n found = this.resolveLikeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ], name);\r\n return new Types.TableType(structure, options);\r\n }\r\n // fallback to old style syntax, OCCURS etc\r\n return this.parseType(node, name);\r\n }\r\n parseType(node, qualifiedName) {\r\n var _a, _b, _c, _d, _e, _f;\r\n const typeName = node.findFirstExpression(Expressions.TypeName);\r\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\r\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\r\n text = \"TYPE\";\r\n }\r\n }\r\n if (text === undefined) {\r\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = \"TYPE\";\r\n }\r\n let found = undefined;\r\n if (text.startsWith(\"LIKE LINE OF \")) {\r\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\r\n let e = node.findFirstExpression(Expressions.Type);\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n const type = this.resolveLikeName(e, false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n else if (type instanceof Types.TableType) {\r\n return type.getRowType();\r\n }\r\n else if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else {\r\n return new Types.UnknownType(\"Type error, not a table type \" + name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE REF TO \")) {\r\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\r\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n return new Types.DataReference(type, name);\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\") });\r\n }\r\n else if (text.startsWith(\"LIKE \")) {\r\n let sub = node.findFirstExpression(Expressions.Type);\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.TypeParam);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n found = this.resolveLikeName(sub);\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE LINE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\r\n found = found.getType();\r\n }\r\n if (found instanceof Types.TableType) {\r\n return found.getRowType();\r\n }\r\n else if (found instanceof Types.VoidType) {\r\n return found;\r\n }\r\n else if (found instanceof Types.UnknownType) {\r\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\r\n }\r\n else {\r\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE REF TO \")) {\r\n found = this.resolveTypeRef(typeName);\r\n }\r\n else if (text.startsWith(\"TYPE\")) {\r\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\r\n const concat = node.concatTokens().toUpperCase();\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\r\n if (found instanceof Types.VoidType) {\r\n found = new Types.TableType(found, { withHeader: true });\r\n }\r\n else if (!(found instanceof Types.TableType)) {\r\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\r\n }\r\n else {\r\n found = new Types.TableType(found.getRowType(), { withHeader: true });\r\n }\r\n }\r\n if (found === undefined && typeName === undefined) {\r\n let length = 1;\r\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\r\n if (len) {\r\n const int = len.findDirectExpression(Expressions.Integer);\r\n if (int) {\r\n length = parseInt(int.concatTokens(), 10);\r\n }\r\n }\r\n found = new Types.CharacterType(length, qualifiedName); // fallback\r\n if (this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n }\r\n return found;\r\n }\r\n /////////////////////\r\n isOccurs(node) {\r\n var _a;\r\n if (node.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n // todo, rewrite this method\r\n resolveTypeChain(expr) {\r\n var _a;\r\n const chainText = expr.concatTokens().toUpperCase();\r\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\r\n return undefined;\r\n }\r\n let className;\r\n let rest = chainText;\r\n if (chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n const subs = rest.split(\"-\");\r\n let foundType = undefined;\r\n if (className) {\r\n const split = chainText.split(\"=>\");\r\n const className = split[0];\r\n // the prefix might be itself\r\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\r\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\r\n const foundId = this.scope.findType(subs[0]);\r\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\r\n if (foundType === undefined) {\r\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\r\n }\r\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n // lookup in local and global scope\r\n const obj = this.scope.findObjectDefinition(className);\r\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\r\n return new Types.VoidType(className);\r\n }\r\n else if (obj === undefined) {\r\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\r\n }\r\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n }\r\n else {\r\n const found = this.scope.findType(subs[0]);\r\n foundType = found === null || found === void 0 ? void 0 : found.getType();\r\n if (foundType === undefined) {\r\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (typePoolType) {\r\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\r\n foundType = typePoolType;\r\n }\r\n if (foundType === undefined) {\r\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\r\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n foundType = f.type.getType();\r\n }\r\n else {\r\n foundType = f.type;\r\n }\r\n }\r\n }\r\n else {\r\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(subs[0]);\r\n }\r\n else if (foundType instanceof Types.VoidType) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return foundType;\r\n }\r\n else if (foundType === undefined) {\r\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\r\n }\r\n }\r\n subs.shift();\r\n while (subs.length > 0) {\r\n if (foundType instanceof Types.UnknownType\r\n || foundType instanceof Types.VoidType) {\r\n return foundType;\r\n }\r\n else if (!(foundType instanceof Types.StructureType)) {\r\n return new Types.UnknownType(\"Not a structured type\");\r\n }\r\n foundType = foundType.getComponentByName(subs[0]);\r\n subs.shift();\r\n }\r\n return foundType;\r\n }\r\n resolveConstantValue(expr) {\r\n var _a, _b;\r\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\r\n throw new Error(\"resolveConstantValue\");\r\n }\r\n const firstNode = expr.getFirstChild();\r\n const firstToken = firstNode.getFirstToken();\r\n const firstName = firstToken.getStr();\r\n if (firstNode.get() instanceof Expressions.Field) {\r\n const found = this.scope.findVariable(firstName);\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName\r\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\r\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\r\n const children = expr.getChildren();\r\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const found = this.scope.findVariable(token.getStr());\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName) {\r\n const obj = this.scope.findObjectDefinition(firstName);\r\n if (obj === undefined) {\r\n if (this.scope.existsObject(firstName).found === true) {\r\n return undefined;\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\r\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\r\n }\r\n else {\r\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\r\n return undefined;\r\n }\r\n }\r\n const children = expr.getChildren();\r\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\r\n const attr = token.getStr();\r\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\r\n if (c instanceof class_constant_1.ClassConstant) {\r\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n const val = c.getValue();\r\n if (typeof val === \"string\") {\r\n return val;\r\n }\r\n else if (typeof val === \"object\" && children[4]) {\r\n const name = children[4].getFirstToken().getStr();\r\n if (val[name] !== undefined) {\r\n return val[name];\r\n }\r\n }\r\n return undefined;\r\n }\r\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\r\n }\r\n else {\r\n throw new Error(\"resolveConstantValue, unexpected structure\");\r\n }\r\n }\r\n resolveTypeRef(chain) {\r\n var _a;\r\n if (chain === undefined) {\r\n return undefined;\r\n }\r\n const name = chain.getFirstToken().getStr();\r\n if (chain.getAllTokens().length === 1) {\r\n if (name.toUpperCase() === \"OBJECT\") {\r\n return new Types.GenericObjectReferenceType();\r\n }\r\n const search = this.scope.existsObject(name);\r\n if (search.found === true && search.id) {\r\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\r\n return new Types.ObjectReferenceType(search.id, name);\r\n }\r\n }\r\n const found = this.resolveTypeName(chain);\r\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\r\n return new Types.DataReference(found);\r\n }\r\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\r\n return new Types.DataReference(new Types.AnyType());\r\n }\r\n if (this.scope.isBadiDef(name) === true) {\r\n return new Types.VoidType(name);\r\n }\r\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\r\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\r\n }\r\n findValue(node) {\r\n const val = node.findFirstExpression(Expressions.Value);\r\n if (val === undefined) {\r\n throw new Error(\"VALUE missing in expression\");\r\n }\r\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\r\n return undefined;\r\n }\r\n const constant = val.findFirstExpression(Expressions.Constant);\r\n if (constant) {\r\n return constant.concatTokens();\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n return this.resolveConstantValue(chain);\r\n }\r\n throw new Error(\"findValue, unexpected\");\r\n }\r\n findDecimals(node) {\r\n var _a, _b;\r\n const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (dec) {\r\n return parseInt(dec, 10);\r\n }\r\n return undefined;\r\n }\r\n findLength(node) {\r\n const val = node.findFirstExpression(Expressions.Length);\r\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\r\n if (val && flen) {\r\n throw new Error(\"Only specify length once\");\r\n }\r\n if (flen) {\r\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\r\n if (cintExpr) {\r\n return this.parseInt(cintExpr.concatTokens());\r\n }\r\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (cchain) {\r\n const val = this.resolveConstantValue(cchain);\r\n return this.parseInt(val);\r\n }\r\n }\r\n if (val === undefined) {\r\n return 1;\r\n }\r\n const intExpr = val.findFirstExpression(Expressions.Integer);\r\n if (intExpr) {\r\n return this.parseInt(intExpr.concatTokens());\r\n }\r\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\r\n if (strExpr) {\r\n return this.parseInt(strExpr.concatTokens());\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n const val = this.resolveConstantValue(chain);\r\n return this.parseInt(val);\r\n }\r\n throw new Error(\"Unexpected, findLength\");\r\n }\r\n parseInt(text) {\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n if (text.startsWith(\"'\")) {\r\n text = text.split(\"'\")[1];\r\n }\r\n else if (text.startsWith(\"`\")) {\r\n text = text.split(\"`\")[1];\r\n }\r\n return parseInt(text, 10);\r\n }\r\n}\r\nexports.BasicTypes = BasicTypes;\r\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6653
6653
|
|
|
6654
6654
|
/***/ }),
|
|
6655
6655
|
|
|
@@ -11456,7 +11456,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
11456
11456
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11457
11457
|
|
|
11458
11458
|
"use strict";
|
|
11459
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Registry = void 0;\nconst config_1 = __webpack_require__(/*! ./config */ \"./node_modules/@abaplint/core/build/src/config.js\");\nconst artifacts_objects_1 = __webpack_require__(/*! ./artifacts_objects */ \"./node_modules/@abaplint/core/build/src/artifacts_objects.js\");\nconst find_global_definitions_1 = __webpack_require__(/*! ./abap/5_syntax/global_definitions/find_global_definitions */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/global_definitions/find_global_definitions.js\");\nconst excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ \"./node_modules/@abaplint/core/build/src/utils/excludeHelper.js\");\nconst ddic_references_1 = __webpack_require__(/*! ./ddic_references */ \"./node_modules/@abaplint/core/build/src/ddic_references.js\");\nconst rules_runner_1 = __webpack_require__(/*! ./rules_runner */ \"./node_modules/@abaplint/core/build/src/rules_runner.js\");\n// todo, this should really be an instance in case there are multiple Registry'ies\nclass ParsingPerformance {\n static clear() {\n this.results = [];\n this.lexing = 0;\n this.statements = 0;\n this.structure = 0;\n }\n static push(obj, result) {\n if (result.runtimeExtra) {\n this.lexing += result.runtimeExtra.lexing;\n this.statements += result.runtimeExtra.statements;\n this.structure += result.runtimeExtra.structure;\n }\n if (result.runtime < 100) {\n return;\n }\n if (this.results === undefined) {\n this.results = [];\n }\n let extra = \"\";\n if (result.runtimeExtra) {\n extra = `\\t(lexing: ${result.runtimeExtra.lexing}ms, statements: ${result.runtimeExtra.statements}ms, structure: ${result.runtimeExtra.structure}ms)`;\n }\n this.results.push({\n runtime: result.runtime,\n extra,\n name: obj.getType() + \" \" + obj.getName(),\n });\n }\n static output() {\n const MAX = 10;\n this.results.sort((a, b) => { return b.runtime - a.runtime; });\n for (let i = 0; i < MAX; i++) {\n const row = this.results[i];\n if (row === undefined) {\n break;\n }\n process.stderr.write(`\\t${row.runtime}ms\\t${row.name} ${row.extra}\\n`);\n }\n process.stderr.write(`\\tTotal lexing: ${this.lexing}ms\\n`);\n process.stderr.write(`\\tTotal statements: ${this.statements}ms\\n`);\n process.stderr.write(`\\tTotal structure: ${this.structure}ms\\n`);\n }\n}\n///////////////////////////////////////////////////////////////////////////////////////////////\nclass Registry {\n constructor(conf) {\n this.objects = {};\n this.objectsByType = {};\n this.dependencies = {};\n this.conf = conf ? conf : config_1.Config.getDefault();\n this.references = new ddic_references_1.DDICReferences();\n }\n static abaplintVersion() {\n // magic, see build script \"version.sh\"\n return \"2.93.4\";\n }\n getDDICReferences() {\n return this.references;\n }\n *getObjects() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n yield this.objects[name][type];\n }\n }\n }\n *getObjectsByType(type) {\n for (const name in this.objectsByType[type] || []) {\n yield this.objectsByType[type][name];\n }\n }\n *getFiles() {\n for (const obj of this.getObjects()) {\n for (const file of obj.getFiles()) {\n yield file;\n }\n }\n }\n getFirstObject() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n return this.objects[name][type];\n }\n }\n return undefined;\n }\n getObjectCount(skipDependencies = true) {\n let res = 0;\n for (const o of this.getObjects()) {\n if (skipDependencies === true && this.isDependency(o)) {\n continue;\n }\n res = res + 1;\n }\n return res;\n }\n getFileByName(filename) {\n const upper = filename.toUpperCase();\n for (const o of this.getObjects()) {\n for (const f of o.getFiles()) {\n if (f.getFilename().toUpperCase() === upper) {\n return f;\n }\n }\n }\n return undefined;\n }\n getObject(type, name) {\n if (type === undefined || name === undefined) {\n return undefined;\n }\n const searchName = name.toUpperCase();\n if (this.objects[searchName]) {\n return this.objects[searchName][type];\n }\n return undefined;\n }\n getConfig() {\n return this.conf;\n }\n // assumption: Config is immutable, and can only be changed via this method\n setConfig(conf) {\n for (const obj of this.getObjects()) {\n obj.setDirty();\n }\n this.conf = conf;\n return this;\n }\n inErrorNamespace(name) {\n // todo: performance? cache regexp?\n const reg = new RegExp(this.getConfig().getSyntaxSetttings().errorNamespace, \"i\");\n return reg.test(name);\n }\n addFile(file) {\n return this.addFiles([file]);\n }\n updateFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.updateFile(file);\n return this;\n }\n removeFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.removeFile(file);\n if (obj.getFiles().length === 0) {\n this.references.clear(obj);\n this.removeObject(obj);\n }\n return this;\n }\n _addFiles(files, dependency) {\n var _a;\n const globalExclude = ((_a = this.conf.getGlobal().exclude) !== null && _a !== void 0 ? _a : [])\n .map(pattern => new RegExp(pattern, \"i\"));\n for (const f of files) {\n const filename = f.getFilename();\n const isNotAbapgitFile = filename.split(\".\").length <= 2;\n if (isNotAbapgitFile || excludeHelper_1.ExcludeHelper.isExcluded(filename, globalExclude)) {\n continue;\n }\n let found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n if (dependency === false && found && this.isDependency(found)) {\n this.removeDependency(found);\n found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n }\n found.addFile(f);\n }\n return this;\n }\n addFiles(files) {\n this._addFiles(files, false);\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.addDependency(f);\n }\n return this;\n }\n addDependency(file) {\n var _a;\n const type = (_a = file.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return this;\n }\n const name = file.getObjectName().toUpperCase();\n if (this.dependencies[type] === undefined) {\n this.dependencies[type] = {};\n }\n this.dependencies[type][name] = true;\n this._addFiles([file], true);\n return this;\n }\n removeDependency(obj) {\n var _a;\n (_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? true : delete _a[obj.getName()];\n this.removeObject(obj);\n }\n isDependency(obj) {\n var _a;\n return ((_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? void 0 : _a[obj.getName()]) === true;\n }\n isFileDependency(filename) {\n var _a, _b;\n const f = this.getFileByName(filename);\n if (f === undefined) {\n return false;\n }\n const type = (_a = f.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return false;\n }\n const name = f.getObjectName().toUpperCase();\n return ((_b = this.dependencies[type]) === null || _b === void 0 ? void 0 : _b[name]) === true;\n }\n // assumption: the file is already in the registry\n findObjectForFile(file) {\n const filename = file.getFilename();\n for (const obj of this.getObjects()) {\n for (const ofile of obj.getFiles()) {\n if (ofile.getFilename() === filename) {\n return obj;\n }\n }\n }\n return undefined;\n }\n // todo, this will be changed to async sometime\n findIssues(input) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules(this.getObjects(), input);\n }\n // todo, this will be changed to async sometime\n findIssuesObject(iobj) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules([iobj]);\n }\n // todo, this will be changed to async sometime\n parse() {\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run();\n return this;\n }\n async parseAsync(input) {\n var _a, _b;\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount(false), \"Lexing and parsing\");\n for (const o of this.getObjects()) {\n await ((_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Lexing and parsing(\" + this.conf.getVersion() + \") - \" + o.getType() + \" \" + o.getName()));\n this.parsePrivate(o);\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n ParsingPerformance.output();\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run(input === null || input === void 0 ? void 0 : input.progress);\n return this;\n }\n //////////////////////////////////////////\n // todo, refactor, this is a mess, see where-used, a lot of the code should be in this method instead\n parsePrivate(input) {\n const config = this.getConfig();\n const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros, this);\n ParsingPerformance.push(input, result);\n }\n isDirty() {\n for (const o of this.getObjects()) {\n const dirty = o.isDirty();\n if (dirty === true) {\n return true;\n }\n }\n return false;\n }\n findOrCreate(name, type) {\n try {\n return this.find(name, type);\n }\n catch (_a) {\n const newName = name.toUpperCase();\n const newType = type ? type : \"UNKNOWN\";\n const add = artifacts_objects_1.ArtifactsObjects.newObject(newName, newType);\n if (this.objects[newName] === undefined) {\n this.objects[newName] = {};\n }\n this.objects[newName][newType] = add;\n if (this.objectsByType[newType] === undefined) {\n this.objectsByType[newType] = {};\n }\n this.objectsByType[newType][newName] = add;\n return add;\n }\n }\n removeObject(remove) {\n if (remove === undefined) {\n return;\n }\n if (this.objects[remove.getName()][remove.getType()] === undefined) {\n throw new Error(\"removeObject: object not found\");\n }\n if (Object.keys(this.objects[remove.getName()]).length === 1) {\n delete this.objects[remove.getName()];\n }\n else {\n delete this.objects[remove.getName()][remove.getType()];\n }\n if (Object.keys(this.objectsByType[remove.getType()]).length === 1) {\n delete this.objectsByType[remove.getType()];\n }\n else {\n delete this.objectsByType[remove.getType()][remove.getName()];\n }\n }\n find(name, type) {\n const searchType = type ? type : \"UNKNOWN\";\n const searchName = name.toUpperCase();\n if (this.objects[searchName] !== undefined\n && this.objects[searchName][searchType]) {\n return this.objects[searchName][searchType];\n }\n throw new Error(\"find: object not found, \" + type + \" \" + name);\n }\n}\nexports.Registry = Registry;\n//# sourceMappingURL=registry.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/registry.js?");
|
|
11459
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Registry = void 0;\nconst config_1 = __webpack_require__(/*! ./config */ \"./node_modules/@abaplint/core/build/src/config.js\");\nconst artifacts_objects_1 = __webpack_require__(/*! ./artifacts_objects */ \"./node_modules/@abaplint/core/build/src/artifacts_objects.js\");\nconst find_global_definitions_1 = __webpack_require__(/*! ./abap/5_syntax/global_definitions/find_global_definitions */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/global_definitions/find_global_definitions.js\");\nconst excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ \"./node_modules/@abaplint/core/build/src/utils/excludeHelper.js\");\nconst ddic_references_1 = __webpack_require__(/*! ./ddic_references */ \"./node_modules/@abaplint/core/build/src/ddic_references.js\");\nconst rules_runner_1 = __webpack_require__(/*! ./rules_runner */ \"./node_modules/@abaplint/core/build/src/rules_runner.js\");\n// todo, this should really be an instance in case there are multiple Registry'ies\nclass ParsingPerformance {\n static clear() {\n this.results = [];\n this.lexing = 0;\n this.statements = 0;\n this.structure = 0;\n }\n static push(obj, result) {\n if (result.runtimeExtra) {\n this.lexing += result.runtimeExtra.lexing;\n this.statements += result.runtimeExtra.statements;\n this.structure += result.runtimeExtra.structure;\n }\n if (result.runtime < 100) {\n return;\n }\n if (this.results === undefined) {\n this.results = [];\n }\n let extra = \"\";\n if (result.runtimeExtra) {\n extra = `\\t(lexing: ${result.runtimeExtra.lexing}ms, statements: ${result.runtimeExtra.statements}ms, structure: ${result.runtimeExtra.structure}ms)`;\n }\n this.results.push({\n runtime: result.runtime,\n extra,\n name: obj.getType() + \" \" + obj.getName(),\n });\n }\n static output() {\n const MAX = 10;\n this.results.sort((a, b) => { return b.runtime - a.runtime; });\n for (let i = 0; i < MAX; i++) {\n const row = this.results[i];\n if (row === undefined) {\n break;\n }\n process.stderr.write(`\\t${row.runtime}ms\\t${row.name} ${row.extra}\\n`);\n }\n process.stderr.write(`\\tTotal lexing: ${this.lexing}ms\\n`);\n process.stderr.write(`\\tTotal statements: ${this.statements}ms\\n`);\n process.stderr.write(`\\tTotal structure: ${this.structure}ms\\n`);\n }\n}\n///////////////////////////////////////////////////////////////////////////////////////////////\nclass Registry {\n constructor(conf) {\n this.objects = {};\n this.objectsByType = {};\n this.dependencies = {};\n this.conf = conf ? conf : config_1.Config.getDefault();\n this.references = new ddic_references_1.DDICReferences();\n }\n static abaplintVersion() {\n // magic, see build script \"version.sh\"\n return \"2.93.7\";\n }\n getDDICReferences() {\n return this.references;\n }\n *getObjects() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n yield this.objects[name][type];\n }\n }\n }\n *getObjectsByType(type) {\n for (const name in this.objectsByType[type] || []) {\n yield this.objectsByType[type][name];\n }\n }\n *getFiles() {\n for (const obj of this.getObjects()) {\n for (const file of obj.getFiles()) {\n yield file;\n }\n }\n }\n getFirstObject() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n return this.objects[name][type];\n }\n }\n return undefined;\n }\n getObjectCount(skipDependencies = true) {\n let res = 0;\n for (const o of this.getObjects()) {\n if (skipDependencies === true && this.isDependency(o)) {\n continue;\n }\n res = res + 1;\n }\n return res;\n }\n getFileByName(filename) {\n const upper = filename.toUpperCase();\n for (const o of this.getObjects()) {\n for (const f of o.getFiles()) {\n if (f.getFilename().toUpperCase() === upper) {\n return f;\n }\n }\n }\n return undefined;\n }\n getObject(type, name) {\n if (type === undefined || name === undefined) {\n return undefined;\n }\n const searchName = name.toUpperCase();\n if (this.objects[searchName]) {\n return this.objects[searchName][type];\n }\n return undefined;\n }\n getConfig() {\n return this.conf;\n }\n // assumption: Config is immutable, and can only be changed via this method\n setConfig(conf) {\n for (const obj of this.getObjects()) {\n obj.setDirty();\n }\n this.conf = conf;\n return this;\n }\n inErrorNamespace(name) {\n // todo: performance? cache regexp?\n const reg = new RegExp(this.getConfig().getSyntaxSetttings().errorNamespace, \"i\");\n return reg.test(name);\n }\n addFile(file) {\n return this.addFiles([file]);\n }\n updateFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.updateFile(file);\n return this;\n }\n removeFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.removeFile(file);\n if (obj.getFiles().length === 0) {\n this.references.clear(obj);\n this.removeObject(obj);\n }\n return this;\n }\n _addFiles(files, dependency) {\n var _a;\n const globalExclude = ((_a = this.conf.getGlobal().exclude) !== null && _a !== void 0 ? _a : [])\n .map(pattern => new RegExp(pattern, \"i\"));\n for (const f of files) {\n const filename = f.getFilename();\n const isNotAbapgitFile = filename.split(\".\").length <= 2;\n if (isNotAbapgitFile || excludeHelper_1.ExcludeHelper.isExcluded(filename, globalExclude)) {\n continue;\n }\n let found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n if (dependency === false && found && this.isDependency(found)) {\n this.removeDependency(found);\n found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n }\n found.addFile(f);\n }\n return this;\n }\n addFiles(files) {\n this._addFiles(files, false);\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.addDependency(f);\n }\n return this;\n }\n addDependency(file) {\n var _a;\n const type = (_a = file.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return this;\n }\n const name = file.getObjectName().toUpperCase();\n if (this.dependencies[type] === undefined) {\n this.dependencies[type] = {};\n }\n this.dependencies[type][name] = true;\n this._addFiles([file], true);\n return this;\n }\n removeDependency(obj) {\n var _a;\n (_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? true : delete _a[obj.getName()];\n this.removeObject(obj);\n }\n isDependency(obj) {\n var _a;\n return ((_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? void 0 : _a[obj.getName()]) === true;\n }\n isFileDependency(filename) {\n var _a, _b;\n const f = this.getFileByName(filename);\n if (f === undefined) {\n return false;\n }\n const type = (_a = f.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return false;\n }\n const name = f.getObjectName().toUpperCase();\n return ((_b = this.dependencies[type]) === null || _b === void 0 ? void 0 : _b[name]) === true;\n }\n // assumption: the file is already in the registry\n findObjectForFile(file) {\n const filename = file.getFilename();\n for (const obj of this.getObjects()) {\n for (const ofile of obj.getFiles()) {\n if (ofile.getFilename() === filename) {\n return obj;\n }\n }\n }\n return undefined;\n }\n // todo, this will be changed to async sometime\n findIssues(input) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules(this.getObjects(), input);\n }\n // todo, this will be changed to async sometime\n findIssuesObject(iobj) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules([iobj]);\n }\n // todo, this will be changed to async sometime\n parse() {\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run();\n return this;\n }\n async parseAsync(input) {\n var _a, _b;\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount(false), \"Lexing and parsing\");\n for (const o of this.getObjects()) {\n await ((_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Lexing and parsing(\" + this.conf.getVersion() + \") - \" + o.getType() + \" \" + o.getName()));\n this.parsePrivate(o);\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n ParsingPerformance.output();\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run(input === null || input === void 0 ? void 0 : input.progress);\n return this;\n }\n //////////////////////////////////////////\n // todo, refactor, this is a mess, see where-used, a lot of the code should be in this method instead\n parsePrivate(input) {\n const config = this.getConfig();\n const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros, this);\n ParsingPerformance.push(input, result);\n }\n isDirty() {\n for (const o of this.getObjects()) {\n const dirty = o.isDirty();\n if (dirty === true) {\n return true;\n }\n }\n return false;\n }\n findOrCreate(name, type) {\n try {\n return this.find(name, type);\n }\n catch (_a) {\n const newName = name.toUpperCase();\n const newType = type ? type : \"UNKNOWN\";\n const add = artifacts_objects_1.ArtifactsObjects.newObject(newName, newType);\n if (this.objects[newName] === undefined) {\n this.objects[newName] = {};\n }\n this.objects[newName][newType] = add;\n if (this.objectsByType[newType] === undefined) {\n this.objectsByType[newType] = {};\n }\n this.objectsByType[newType][newName] = add;\n return add;\n }\n }\n removeObject(remove) {\n if (remove === undefined) {\n return;\n }\n if (this.objects[remove.getName()][remove.getType()] === undefined) {\n throw new Error(\"removeObject: object not found\");\n }\n if (Object.keys(this.objects[remove.getName()]).length === 1) {\n delete this.objects[remove.getName()];\n }\n else {\n delete this.objects[remove.getName()][remove.getType()];\n }\n if (Object.keys(this.objectsByType[remove.getType()]).length === 1) {\n delete this.objectsByType[remove.getType()];\n }\n else {\n delete this.objectsByType[remove.getType()][remove.getName()];\n }\n }\n find(name, type) {\n const searchType = type ? type : \"UNKNOWN\";\n const searchName = name.toUpperCase();\n if (this.objects[searchName] !== undefined\n && this.objects[searchName][searchType]) {\n return this.objects[searchName][searchType];\n }\n throw new Error(\"find: object not found, \" + type + \" \" + name);\n }\n}\nexports.Registry = Registry;\n//# sourceMappingURL=registry.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/registry.js?");
|
|
11460
11460
|
|
|
11461
11461
|
/***/ }),
|
|
11462
11462
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.93.
|
|
3
|
+
"version": "2.93.7",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"abaplint": "./abaplint"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.93.
|
|
42
|
+
"@abaplint/core": "^2.93.7",
|
|
43
43
|
"@types/chai": "^4.3.3",
|
|
44
44
|
"@types/glob": "^7.2.0",
|
|
45
45
|
"@types/minimist": "^1.2.2",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApackDependencyProvider = void 0;
|
|
4
|
-
const xml_js_1 = require("xml-js");
|
|
5
|
-
class ApackDependencyProvider {
|
|
6
|
-
static fromManifest(manifestContents) {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
if (!manifestContents || !manifestContents.length) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const result = [];
|
|
12
|
-
const manifest = (0, xml_js_1.xml2js)(manifestContents, { compact: true });
|
|
13
|
-
let apackDependencies = (_b = (_a = manifest["asx:abap"]["asx:values"]["DATA"]) === null || _a === void 0 ? void 0 : _a["DEPENDENCIES"]) === null || _b === void 0 ? void 0 : _b.item;
|
|
14
|
-
if (!apackDependencies) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
else if (!apackDependencies.length) {
|
|
18
|
-
apackDependencies = [apackDependencies];
|
|
19
|
-
}
|
|
20
|
-
for (const dependency of apackDependencies) {
|
|
21
|
-
result.push({
|
|
22
|
-
files: "/src/**/*.*",
|
|
23
|
-
url: dependency["GIT_URL"]["_text"],
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.ApackDependencyProvider = ApackDependencyProvider;
|
|
30
|
-
//# sourceMappingURL=apack_dependency_provider.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompressedFile = void 0;
|
|
4
|
-
const core_1 = require("@abaplint/core");
|
|
5
|
-
const zlib = require("zlib");
|
|
6
|
-
class CompressedFile extends core_1.AbstractFile {
|
|
7
|
-
constructor(filename, compressed) {
|
|
8
|
-
super(filename);
|
|
9
|
-
this.compressed = compressed;
|
|
10
|
-
}
|
|
11
|
-
getRaw() {
|
|
12
|
-
return this.decompress(this.compressed);
|
|
13
|
-
}
|
|
14
|
-
getRawRows() {
|
|
15
|
-
return this.decompress(this.compressed).split("\n");
|
|
16
|
-
}
|
|
17
|
-
decompress(compressed) {
|
|
18
|
-
return zlib.inflateSync(Buffer.from(compressed, "base64")).toString("utf8");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.CompressedFile = CompressedFile;
|
|
22
|
-
//# sourceMappingURL=compressed_file.js.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileOperations = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const zlib = require("zlib");
|
|
7
|
-
const glob = require("glob");
|
|
8
|
-
const core_1 = require("@abaplint/core");
|
|
9
|
-
const compressed_file_1 = require("./compressed_file");
|
|
10
|
-
class FileOperations {
|
|
11
|
-
static deleteFolderRecursive(dir) {
|
|
12
|
-
if (fs.existsSync(dir) === false) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
fs.rmSync(dir, { recursive: true });
|
|
16
|
-
}
|
|
17
|
-
static loadFileNames(arg, error = true) {
|
|
18
|
-
const files = glob.sync(arg, { nosort: true, nodir: true });
|
|
19
|
-
if (files.length === 0 && error) {
|
|
20
|
-
throw "Error: No files found";
|
|
21
|
-
}
|
|
22
|
-
return files;
|
|
23
|
-
}
|
|
24
|
-
static async loadFiles(compress, input, bar) {
|
|
25
|
-
const files = [];
|
|
26
|
-
bar.set(input.length, "Reading files");
|
|
27
|
-
for (const filename of input) {
|
|
28
|
-
bar.tick("Reading files - " + path.basename(filename));
|
|
29
|
-
const base = filename.split("/").reverse()[0];
|
|
30
|
-
if (base.split(".").length <= 2) {
|
|
31
|
-
continue; // not a abapGit file
|
|
32
|
-
}
|
|
33
|
-
// note that readFileSync is typically faster than async readFile,
|
|
34
|
-
// https://medium.com/@adamhooper/node-synchronous-code-runs-faster-than-asynchronous-code-b0553d5cf54e
|
|
35
|
-
const raw = fs.readFileSync(filename, "utf8");
|
|
36
|
-
if (compress === true) {
|
|
37
|
-
// todo, util.promisify(zlib.deflate) does not seem to work?
|
|
38
|
-
files.push(new compressed_file_1.CompressedFile(filename, zlib.deflateSync(raw).toString("base64")));
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
files.push(new core_1.MemoryFile(filename, raw));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return files;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.FileOperations = FileOperations;
|
|
48
|
-
//# sourceMappingURL=file_operations.js.map
|
package/build/src/fixes.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplyFixes = void 0;
|
|
4
|
-
/* eslint-disable max-len */
|
|
5
|
-
const core_1 = require("@abaplint/core");
|
|
6
|
-
class ApplyFixes {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.changedFiles = new Set();
|
|
9
|
-
}
|
|
10
|
-
// Strategy:
|
|
11
|
-
// Execute one rule at a time and apply fixes for that rule
|
|
12
|
-
// Some rules are quite expensive to initialize(like downport),
|
|
13
|
-
// so running all rules every time is expensive.
|
|
14
|
-
async applyFixes(reg, fs, quiet) {
|
|
15
|
-
let iteration = 1;
|
|
16
|
-
this.changedFiles.clear();
|
|
17
|
-
const MAX_ITERATIONS = 50000;
|
|
18
|
-
const objects = new core_1.RulesRunner(reg).objectsToCheck(reg.getObjects());
|
|
19
|
-
const rules = reg.getConfig().getEnabledRules();
|
|
20
|
-
while (iteration <= MAX_ITERATIONS) {
|
|
21
|
-
let changed = 0;
|
|
22
|
-
for (const rule of rules) {
|
|
23
|
-
while (iteration <= MAX_ITERATIONS) {
|
|
24
|
-
const before = Date.now();
|
|
25
|
-
rule.initialize(reg);
|
|
26
|
-
const issues = [];
|
|
27
|
-
for (const obj of objects) {
|
|
28
|
-
issues.push(...rule.run(obj));
|
|
29
|
-
}
|
|
30
|
-
iteration++;
|
|
31
|
-
const appliedCount = this.applyList(issues, reg).length;
|
|
32
|
-
const runtime = Date.now() - before;
|
|
33
|
-
if (quiet !== true) {
|
|
34
|
-
process.stderr.write(`\tIteration ${iteration.toString().padEnd(3, " ")}, ${appliedCount} fixes applied, ${runtime}ms, rule ${rule.getMetadata().key}\n`);
|
|
35
|
-
}
|
|
36
|
-
if (appliedCount > 0) {
|
|
37
|
-
changed += appliedCount;
|
|
38
|
-
const before = Date.now();
|
|
39
|
-
reg.parse();
|
|
40
|
-
const runtime = Date.now() - before;
|
|
41
|
-
if (quiet !== true) {
|
|
42
|
-
process.stderr.write(`\tParse, ${runtime}ms\n`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (changed === 0) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
this.writeChangesToFS(fs, reg);
|
|
55
|
-
}
|
|
56
|
-
///////////////////////////////////////////////////
|
|
57
|
-
writeChangesToFS(fs, reg) {
|
|
58
|
-
for (const filename of this.changedFiles.values()) {
|
|
59
|
-
const file = reg.getFileByName(filename);
|
|
60
|
-
if (file === undefined) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
fs.writeFileSync(file.getFilename(), file.getRaw());
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
possibleOverlap(edit, list) {
|
|
67
|
-
// only checks if the edits have changes in the same rows
|
|
68
|
-
for (const e of list) {
|
|
69
|
-
for (const file1 of Object.keys(e)) {
|
|
70
|
-
for (const file2 of Object.keys(edit)) {
|
|
71
|
-
if (file1 === file2) {
|
|
72
|
-
for (const list1 of e[file1]) {
|
|
73
|
-
for (const list2 of edit[file2]) {
|
|
74
|
-
if (list2.range.start.getRow() <= list1.range.start.getRow()
|
|
75
|
-
&& list2.range.end.getRow() >= list1.range.start.getRow()) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
if (list2.range.start.getRow() <= list1.range.start.getRow()
|
|
79
|
-
&& list2.range.end.getRow() >= list1.range.end.getRow()) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
applyList(issues, reg) {
|
|
91
|
-
const edits = [];
|
|
92
|
-
for (const i of issues) {
|
|
93
|
-
const edit = i.getFix();
|
|
94
|
-
if (edit === undefined) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
else if (this.possibleOverlap(edit, edits) === true) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
edits.push(edit);
|
|
101
|
-
}
|
|
102
|
-
const changed = (0, core_1.applyEditList)(reg, edits);
|
|
103
|
-
for (const filename of changed) {
|
|
104
|
-
this.changedFiles.add(filename);
|
|
105
|
-
}
|
|
106
|
-
return changed;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.ApplyFixes = ApplyFixes;
|
|
110
|
-
//# sourceMappingURL=fixes.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Formatter = void 0;
|
|
4
|
-
const Formatters = require(".");
|
|
5
|
-
class Formatter {
|
|
6
|
-
static format(issues, format, fileCount) {
|
|
7
|
-
// todo, this can be done more generic, move to artifacts.ts?
|
|
8
|
-
switch (format) {
|
|
9
|
-
case "total":
|
|
10
|
-
return new Formatters.Total().output(issues, fileCount);
|
|
11
|
-
case "json":
|
|
12
|
-
return new Formatters.Json().output(issues, fileCount);
|
|
13
|
-
case "junit":
|
|
14
|
-
return new Formatters.Junit().output(issues, fileCount);
|
|
15
|
-
case "codeframe":
|
|
16
|
-
return new Formatters.CodeFrame().output(issues, fileCount);
|
|
17
|
-
default:
|
|
18
|
-
return new Formatters.Standard().output(issues, fileCount);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.Formatter = Formatter;
|
|
23
|
-
//# sourceMappingURL=_format.js.map
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CodeFrame = void 0;
|
|
4
|
-
const total_1 = require("./total");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const chalk_1 = require("chalk");
|
|
7
|
-
function issueSort(a, b) {
|
|
8
|
-
return a.filename.localeCompare(b.filename)
|
|
9
|
-
|| (a.row - b.row)
|
|
10
|
-
|| (a.col - b.col);
|
|
11
|
-
}
|
|
12
|
-
class CodeFrame {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.currentFilename = "";
|
|
15
|
-
this.currentFileLinesCount = 0;
|
|
16
|
-
this.fileContent = [];
|
|
17
|
-
}
|
|
18
|
-
output(issues, fileCount) {
|
|
19
|
-
const builtIssues = this.convertAllIssues(issues).sort(issueSort); // Make sure it is sorted by filename for caching to work
|
|
20
|
-
return [
|
|
21
|
-
...builtIssues.map(i => this.renderIssue(i)),
|
|
22
|
-
(issues.length > 0 ? chalk_1.default.red(new total_1.Total().output(issues, fileCount)) : chalk_1.default.green(new total_1.Total().output(issues, fileCount))),
|
|
23
|
-
].join("\n");
|
|
24
|
-
}
|
|
25
|
-
convertAllIssues(issues) {
|
|
26
|
-
return issues.map(i => this.convertIssue(i));
|
|
27
|
-
}
|
|
28
|
-
cacheFile(filename) {
|
|
29
|
-
if (filename !== this.currentFilename) {
|
|
30
|
-
this.currentFilename = filename;
|
|
31
|
-
this.fileContent = fs.readFileSync(filename, "utf8").split(/\r?\n/);
|
|
32
|
-
this.currentFileLinesCount = this.fileContent.length;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
renderIssue(issue) {
|
|
36
|
-
this.cacheFile(issue.filename);
|
|
37
|
-
const frameSize = 1;
|
|
38
|
-
const lineFrom = Math.max(issue.row - frameSize, 1);
|
|
39
|
-
const lineTo = Math.min(issue.row + frameSize, this.currentFileLinesCount);
|
|
40
|
-
const issueLineIndex = issue.row - 1;
|
|
41
|
-
const padSize = Math.ceil(Math.log10(lineTo)) + 4;
|
|
42
|
-
const code = [];
|
|
43
|
-
for (let lineIndex = lineFrom - 1; lineIndex < lineTo; lineIndex++) {
|
|
44
|
-
const prefix = `${ /*(lineIndex === issueLineIndex) ? ">" :*/" "}${lineIndex + 1} |`.padStart(padSize);
|
|
45
|
-
code.push(prefix + this.fileContent[lineIndex]);
|
|
46
|
-
if (lineIndex === issueLineIndex) {
|
|
47
|
-
code.push("|".padStart(padSize) + " ".repeat(issue.col - 1) + "^");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const severityStr = issue.severity === "E"
|
|
51
|
-
? chalk_1.default.red(issue.severity)
|
|
52
|
-
: chalk_1.default.yellow(issue.severity);
|
|
53
|
-
return `[${severityStr}] ${issue.description} (${issue.issueKey}) @ ${issue.location}`
|
|
54
|
-
+ "\n"
|
|
55
|
-
+ code.map(str => chalk_1.default.grey(str)).join("\n")
|
|
56
|
-
+ "\n";
|
|
57
|
-
}
|
|
58
|
-
renderLocation(issue) {
|
|
59
|
-
return issue.getFilename() + "[" + issue.getStart().getRow() + ", " + issue.getStart().getCol() + "]";
|
|
60
|
-
}
|
|
61
|
-
convertIssue(issue) {
|
|
62
|
-
return {
|
|
63
|
-
location: this.renderLocation(issue),
|
|
64
|
-
description: issue.getMessage(),
|
|
65
|
-
issueKey: issue.getKey(),
|
|
66
|
-
filename: issue.getFilename(),
|
|
67
|
-
severity: issue.getSeverity().toString().charAt(0),
|
|
68
|
-
row: issue.getStart().getRow(),
|
|
69
|
-
col: issue.getStart().getCol(),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.CodeFrame = CodeFrame;
|
|
74
|
-
//# sourceMappingURL=codeframe.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./json"), exports);
|
|
18
|
-
__exportStar(require("./junit"), exports);
|
|
19
|
-
__exportStar(require("./standard"), exports);
|
|
20
|
-
__exportStar(require("./total"), exports);
|
|
21
|
-
__exportStar(require("./codeframe"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Json = void 0;
|
|
4
|
-
class Json {
|
|
5
|
-
output(issues, _fileCount) {
|
|
6
|
-
const out = [];
|
|
7
|
-
for (const issue of issues) {
|
|
8
|
-
const single = {
|
|
9
|
-
description: issue.getMessage(),
|
|
10
|
-
key: issue.getKey(),
|
|
11
|
-
file: issue.getFilename(),
|
|
12
|
-
start: {
|
|
13
|
-
row: issue.getStart().getRow(),
|
|
14
|
-
col: issue.getStart().getCol(),
|
|
15
|
-
},
|
|
16
|
-
end: {
|
|
17
|
-
row: issue.getEnd().getRow(),
|
|
18
|
-
col: issue.getEnd().getCol(),
|
|
19
|
-
},
|
|
20
|
-
severity: issue.getSeverity(),
|
|
21
|
-
};
|
|
22
|
-
out.push(single);
|
|
23
|
-
}
|
|
24
|
-
return JSON.stringify(out) + "\n";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.Json = Json;
|
|
28
|
-
//# sourceMappingURL=json.js.map
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Junit = void 0;
|
|
4
|
-
const xml_js_1 = require("xml-js");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
class Junit {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.currentFilename = "";
|
|
9
|
-
this.currentFileLinesCount = 0;
|
|
10
|
-
this.fileContent = [];
|
|
11
|
-
}
|
|
12
|
-
output(issues, _fileCount) {
|
|
13
|
-
const outputObj = {
|
|
14
|
-
_declaration: {
|
|
15
|
-
_attributes: {
|
|
16
|
-
version: "1.0",
|
|
17
|
-
encoding: "UTF-8",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
testsuites: {
|
|
21
|
-
testsuite: {
|
|
22
|
-
_attributes: {
|
|
23
|
-
name: "abaplint",
|
|
24
|
-
tests: issues.length || 1,
|
|
25
|
-
failures: issues.length,
|
|
26
|
-
errors: 0,
|
|
27
|
-
skipped: 0,
|
|
28
|
-
},
|
|
29
|
-
testcase: [],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
if (issues.length > 0) {
|
|
34
|
-
for (const issue of issues) {
|
|
35
|
-
outputObj.testsuites.testsuite.testcase.push({
|
|
36
|
-
_attributes: {
|
|
37
|
-
classname: issue.getFilename().split(".")[0],
|
|
38
|
-
file: issue.getFilename(),
|
|
39
|
-
name: `${issue.getFilename()}: [${issue.getStart().getRow()}, ${issue.getStart().getCol()}] - ${issue.getKey()}`,
|
|
40
|
-
},
|
|
41
|
-
failure: {
|
|
42
|
-
_attributes: {
|
|
43
|
-
message: this.formatFailureMessage(issue.getMessage()),
|
|
44
|
-
type: issue.getSeverity().toString(),
|
|
45
|
-
},
|
|
46
|
-
_cdata: `${this.renderIssue(issue)}`,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
outputObj.testsuites.testsuite.testcase.push({
|
|
53
|
-
_attributes: {
|
|
54
|
-
classname: "none",
|
|
55
|
-
name: "OK",
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const xml = (0, xml_js_1.js2xml)(outputObj, { compact: true, spaces: 2 });
|
|
60
|
-
return xml;
|
|
61
|
-
}
|
|
62
|
-
cacheFile(filename) {
|
|
63
|
-
if (filename !== this.currentFilename) {
|
|
64
|
-
this.currentFilename = filename;
|
|
65
|
-
this.fileContent = fs.readFileSync(filename, "utf8").split(/\r?\n/);
|
|
66
|
-
this.currentFileLinesCount = this.fileContent.length;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
renderIssue(issue) {
|
|
70
|
-
this.cacheFile(issue.getFilename());
|
|
71
|
-
const frameSize = 1;
|
|
72
|
-
const lineFrom = Math.max(issue.getStart().getRow() - frameSize, 1);
|
|
73
|
-
const lineTo = Math.min(issue.getStart().getRow() + frameSize, this.currentFileLinesCount);
|
|
74
|
-
const issueLineIndex = issue.getStart().getRow() - 1;
|
|
75
|
-
const padSize = Math.ceil(Math.log10(lineTo)) + 4;
|
|
76
|
-
const code = [];
|
|
77
|
-
for (let lineIndex = lineFrom - 1; lineIndex < lineTo; lineIndex++) {
|
|
78
|
-
const prefix = `${lineIndex + 1} | `.padStart(padSize, "0");
|
|
79
|
-
code.push(prefix + this.fileContent[lineIndex]);
|
|
80
|
-
if (lineIndex === issueLineIndex) {
|
|
81
|
-
code.push("| ".padStart(padSize) + " ".repeat(issue.getStart().getCol() - 1) + "^");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return code.map(str => str).join("\n");
|
|
85
|
-
}
|
|
86
|
-
formatFailureMessage(message) {
|
|
87
|
-
return message.replace("<", "").replace(">", "");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.Junit = Junit;
|
|
91
|
-
//# sourceMappingURL=junit.js.map
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Standard = void 0;
|
|
4
|
-
const total_1 = require("./total");
|
|
5
|
-
class Standard {
|
|
6
|
-
output(issues, fileCount) {
|
|
7
|
-
const tuples = [];
|
|
8
|
-
for (const issue of issues) {
|
|
9
|
-
tuples.push(this.build(issue));
|
|
10
|
-
}
|
|
11
|
-
tuples.sort((a, b) => {
|
|
12
|
-
const nameCompare = a.rawFilename.localeCompare(b.rawFilename);
|
|
13
|
-
if (nameCompare === 0) {
|
|
14
|
-
const rowCompare = a.startPos.getRow() - b.startPos.getRow();
|
|
15
|
-
if (rowCompare === 0) {
|
|
16
|
-
return a.startPos.getCol() - b.startPos.getCol();
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return rowCompare;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return nameCompare;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const result = this.columns(tuples);
|
|
27
|
-
return result + new total_1.Total().output(issues, fileCount);
|
|
28
|
-
}
|
|
29
|
-
columns(issues) {
|
|
30
|
-
let max = 0;
|
|
31
|
-
issues.forEach((tuple) => { if (max < tuple.filename.length) {
|
|
32
|
-
max = tuple.filename.length;
|
|
33
|
-
} });
|
|
34
|
-
let result = "";
|
|
35
|
-
issues.forEach((issue) => {
|
|
36
|
-
result = result +
|
|
37
|
-
this.pad(issue.filename, max - issue.filename.length) +
|
|
38
|
-
issue.description +
|
|
39
|
-
` [${issue.severity.charAt(0)}]\n`; //E/W/I
|
|
40
|
-
});
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
pad(input, length) {
|
|
44
|
-
let output = input;
|
|
45
|
-
for (let i = 0; i < length; i++) {
|
|
46
|
-
output = output + " ";
|
|
47
|
-
}
|
|
48
|
-
return output + " - ";
|
|
49
|
-
}
|
|
50
|
-
build(issue) {
|
|
51
|
-
return {
|
|
52
|
-
filename: issue.getFilename() + "[" + issue.getStart().getRow() + ", " + issue.getStart().getCol() + "]",
|
|
53
|
-
description: issue.getMessage() + " (" + issue.getKey() + ")",
|
|
54
|
-
startPos: issue.getStart(),
|
|
55
|
-
rawFilename: issue.getFilename(),
|
|
56
|
-
severity: issue.getSeverity().toString(),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.Standard = Standard;
|
|
61
|
-
//# sourceMappingURL=standard.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Total = void 0;
|
|
4
|
-
class Total {
|
|
5
|
-
output(issues, fileCount) {
|
|
6
|
-
return "abaplint: " + issues.length + " issue(s) found, " + fileCount + " file(s) analyzed\n";
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.Total = Total;
|
|
10
|
-
//# sourceMappingURL=total.js.map
|
package/build/src/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Issue, IRegistry } from "@abaplint/core";
|
|
2
|
-
export declare const GENERIC_ERROR = "generic_error";
|
|
3
|
-
export declare type Arguments = {
|
|
4
|
-
configFilename?: string;
|
|
5
|
-
format: string;
|
|
6
|
-
compress?: boolean;
|
|
7
|
-
parsingPerformance?: boolean;
|
|
8
|
-
showHelp?: boolean;
|
|
9
|
-
showVersion?: boolean;
|
|
10
|
-
outputDefaultConfig?: boolean;
|
|
11
|
-
runFix?: boolean;
|
|
12
|
-
runRename?: boolean;
|
|
13
|
-
outFormat?: string;
|
|
14
|
-
outFile?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare function run(arg: Arguments): Promise<{
|
|
17
|
-
output: string;
|
|
18
|
-
issues: Issue[];
|
|
19
|
-
reg: IRegistry | undefined;
|
|
20
|
-
}>;
|
package/build/src/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = exports.GENERIC_ERROR = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const ProgressBar = require("progress");
|
|
8
|
-
const childProcess = require("child_process");
|
|
9
|
-
const JSON5 = require("json5");
|
|
10
|
-
const core_1 = require("@abaplint/core");
|
|
11
|
-
const _format_1 = require("./formatters/_format");
|
|
12
|
-
const file_operations_1 = require("./file_operations");
|
|
13
|
-
const apack_dependency_provider_1 = require("./apack_dependency_provider");
|
|
14
|
-
const fixes_1 = require("./fixes");
|
|
15
|
-
const rename_1 = require("./rename");
|
|
16
|
-
exports.GENERIC_ERROR = "generic_error";
|
|
17
|
-
class Progress {
|
|
18
|
-
set(total, _text) {
|
|
19
|
-
this.bar = new ProgressBar(":percent - :elapseds - :text", { total, renderThrottle: 100 });
|
|
20
|
-
}
|
|
21
|
-
async tick(text) {
|
|
22
|
-
this.bar.tick({ text });
|
|
23
|
-
this.bar.render();
|
|
24
|
-
}
|
|
25
|
-
tickSync(text) {
|
|
26
|
-
this.bar.tick({ text });
|
|
27
|
-
this.bar.render();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function loadConfig(filename) {
|
|
31
|
-
// possible cases:
|
|
32
|
-
// a) nothing specified, using abaplint.json from cwd
|
|
33
|
-
// b) nothing specified, no abaplint.json in cwd
|
|
34
|
-
// c) specified and found
|
|
35
|
-
// d) specified and not found => use default
|
|
36
|
-
// e) supplied but a directory => use default
|
|
37
|
-
let f = "";
|
|
38
|
-
if (filename === undefined) {
|
|
39
|
-
f = process.cwd() + path.sep + "abaplint.json";
|
|
40
|
-
if (fs.existsSync(f) === false) {
|
|
41
|
-
f = process.cwd() + path.sep + "abaplint.jsonc";
|
|
42
|
-
}
|
|
43
|
-
if (fs.existsSync(f) === false) {
|
|
44
|
-
f = process.cwd() + path.sep + "abaplint.json5";
|
|
45
|
-
}
|
|
46
|
-
if (fs.existsSync(f) === false) {
|
|
47
|
-
process.stderr.write("Using default config\n");
|
|
48
|
-
return { config: core_1.Config.getDefault(), base: "." };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (fs.existsSync(filename) === false) {
|
|
53
|
-
process.stderr.write("ERROR: Specified abaplint configuration file does not exist, using default config\n");
|
|
54
|
-
return { config: core_1.Config.getDefault(), base: "." };
|
|
55
|
-
}
|
|
56
|
-
else if (fs.statSync(filename).isDirectory() === true) {
|
|
57
|
-
process.stderr.write("Supply filename, not directory, using default config\n");
|
|
58
|
-
return { config: core_1.Config.getDefault(), base: "." };
|
|
59
|
-
}
|
|
60
|
-
f = filename;
|
|
61
|
-
}
|
|
62
|
-
// evil hack to get JSON5 working
|
|
63
|
-
if (JSON5.parse === undefined) {
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
JSON5.parse = JSON5.default.parse;
|
|
66
|
-
}
|
|
67
|
-
process.stderr.write("Using config: " + f + "\n");
|
|
68
|
-
const json = fs.readFileSync(f, "utf8");
|
|
69
|
-
const parsed = JSON5.parse(json);
|
|
70
|
-
const vers = core_1.Version;
|
|
71
|
-
if (Object.keys(core_1.Version).some(v => vers[v] === parsed.syntax.version) === false) {
|
|
72
|
-
throw "Error: Unknown version in abaplint.json";
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
config: new core_1.Config(json),
|
|
76
|
-
base: path.dirname(f) === process.cwd() ? "." : path.dirname(f),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async function loadDependencies(config, compress, bar, base) {
|
|
80
|
-
let files = [];
|
|
81
|
-
const deps = config.get().dependencies || [];
|
|
82
|
-
const useApack = config.get().global.useApackDependencies;
|
|
83
|
-
if (useApack) {
|
|
84
|
-
const apackPath = path.join(base, ".apack-manifest.xml");
|
|
85
|
-
if (fs.existsSync(apackPath)) {
|
|
86
|
-
const apackManifest = fs.readFileSync(apackPath, "utf8");
|
|
87
|
-
deps.push(...apack_dependency_provider_1.ApackDependencyProvider.fromManifest(apackManifest));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (!deps) {
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
for (const d of deps) {
|
|
94
|
-
if (d.folder) {
|
|
95
|
-
const g = base + d.folder + d.files;
|
|
96
|
-
const names = file_operations_1.FileOperations.loadFileNames(g, false);
|
|
97
|
-
if (names.length > 0) {
|
|
98
|
-
process.stderr.write("Using dependency from: " + g + "\n");
|
|
99
|
-
files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (d.url) {
|
|
104
|
-
process.stderr.write("Clone: " + d.url + "\n");
|
|
105
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "abaplint-"));
|
|
106
|
-
childProcess.execSync("git clone --quiet --depth 1 " + d.url + " .", { cwd: dir, stdio: "inherit" });
|
|
107
|
-
const names = file_operations_1.FileOperations.loadFileNames(dir + d.files);
|
|
108
|
-
files = files.concat(await file_operations_1.FileOperations.loadFiles(compress, names, bar));
|
|
109
|
-
file_operations_1.FileOperations.deleteFolderRecursive(dir);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return files;
|
|
113
|
-
}
|
|
114
|
-
function displayHelp() {
|
|
115
|
-
// follow https://docopt.org conventions,
|
|
116
|
-
return "Usage:\n" +
|
|
117
|
-
" abaplint [<abaplint.json> -f <format> -c --outformat <format> --outfile <file> --fix] \n" +
|
|
118
|
-
" abaplint -h | --help show this help\n" +
|
|
119
|
-
" abaplint -v | --version show version\n" +
|
|
120
|
-
" abaplint -d | --default show default configuration\n" +
|
|
121
|
-
"\n" +
|
|
122
|
-
"Options:\n" +
|
|
123
|
-
" -f, --format <format> output format (standard, total, json, summary, junit, codeframe)\n" +
|
|
124
|
-
" --outformat <format> output format, use in combination with outfile\n" +
|
|
125
|
-
" --outfile <file> output issues to file in format\n" +
|
|
126
|
-
" --fix apply quick fixes to files\n" +
|
|
127
|
-
" --rename rename object according to rules in abaplint.json\n" +
|
|
128
|
-
" -p output performance information\n" +
|
|
129
|
-
" -c compress files in memory\n";
|
|
130
|
-
}
|
|
131
|
-
function out(issues, length, arg) {
|
|
132
|
-
const output = _format_1.Formatter.format(issues, arg.format, length);
|
|
133
|
-
if (arg.outFormat && arg.outFile) {
|
|
134
|
-
const fileContents = _format_1.Formatter.format(issues, arg.outFormat, length);
|
|
135
|
-
fs.writeFileSync(arg.outFile, fileContents, "utf-8");
|
|
136
|
-
}
|
|
137
|
-
return output;
|
|
138
|
-
}
|
|
139
|
-
async function run(arg) {
|
|
140
|
-
var _a, _b;
|
|
141
|
-
// evil hack to get JSON5 working
|
|
142
|
-
if (JSON5.parse === undefined) {
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
JSON5.parse = JSON5.default.parse;
|
|
145
|
-
}
|
|
146
|
-
if (JSON5.stringify === undefined) {
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
JSON5.stringify = JSON5.default.stringify;
|
|
149
|
-
}
|
|
150
|
-
let output = "";
|
|
151
|
-
let issues = [];
|
|
152
|
-
let reg = undefined;
|
|
153
|
-
const progress = new Progress();
|
|
154
|
-
if (arg.showHelp === true) {
|
|
155
|
-
output = output + displayHelp();
|
|
156
|
-
}
|
|
157
|
-
else if (arg.showVersion === true) {
|
|
158
|
-
output = output + core_1.Registry.abaplintVersion() + "\n";
|
|
159
|
-
}
|
|
160
|
-
else if (arg.outputDefaultConfig === true) {
|
|
161
|
-
output = output + JSON.stringify(core_1.Config.getDefault().get(), undefined, 2) + "\n";
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
process.stderr.write("abaplint " + core_1.Registry.abaplintVersion() + "\n");
|
|
165
|
-
let loaded = [];
|
|
166
|
-
let deps = [];
|
|
167
|
-
const { config, base } = loadConfig(arg.configFilename);
|
|
168
|
-
try {
|
|
169
|
-
if (config.get().global.files === undefined) {
|
|
170
|
-
throw "Error: Update abaplint configuration file to latest format";
|
|
171
|
-
}
|
|
172
|
-
const files = file_operations_1.FileOperations.loadFileNames(base + config.get().global.files);
|
|
173
|
-
loaded = await file_operations_1.FileOperations.loadFiles(arg.compress, files, progress);
|
|
174
|
-
deps = await loadDependencies(config, arg.compress, progress, base);
|
|
175
|
-
reg = new core_1.Registry(config);
|
|
176
|
-
reg.addDependencies(deps);
|
|
177
|
-
reg.addFiles(loaded); // if the object exists in repo, it should take precedence over deps
|
|
178
|
-
await reg.parseAsync({ progress, outputPerformance: arg.parsingPerformance });
|
|
179
|
-
issues = issues.concat(reg.findIssues({ progress, outputPerformance: arg.parsingPerformance }));
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
const file = new core_1.MemoryFile("generic", "dummy");
|
|
183
|
-
const message = error.toString() + " " + ((_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split("\n")[1]) === null || _b === void 0 ? void 0 : _b.trim());
|
|
184
|
-
const issue = core_1.Issue.atPosition(file, new core_1.Position(1, 1), message, exports.GENERIC_ERROR);
|
|
185
|
-
issues = [issue];
|
|
186
|
-
}
|
|
187
|
-
let extra = "";
|
|
188
|
-
if (arg.runFix === true && reg) {
|
|
189
|
-
issues = [];
|
|
190
|
-
await new fixes_1.ApplyFixes().applyFixes(reg, fs);
|
|
191
|
-
extra = "Fixes applied";
|
|
192
|
-
}
|
|
193
|
-
else if (arg.runRename === true && reg) {
|
|
194
|
-
if (issues.length === 0) {
|
|
195
|
-
new rename_1.Rename(reg).run(config, base);
|
|
196
|
-
extra = "Renames applied";
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
extra = "Renames NOT applied, issues found";
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
output = out(issues, loaded.length, arg) + extra;
|
|
203
|
-
}
|
|
204
|
-
return { output, issues, reg };
|
|
205
|
-
}
|
|
206
|
-
exports.run = run;
|
|
207
|
-
//# sourceMappingURL=index.js.map
|
package/build/src/rename.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Rename = void 0;
|
|
4
|
-
const abaplint = require("@abaplint/core");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const file_operations_1 = require("./file_operations");
|
|
8
|
-
class Rename {
|
|
9
|
-
constructor(reg) {
|
|
10
|
-
this.deletedFiles = [];
|
|
11
|
-
this.addedFiles = [];
|
|
12
|
-
this.reg = reg;
|
|
13
|
-
}
|
|
14
|
-
run(config, base) {
|
|
15
|
-
const rconfig = config.get().rename;
|
|
16
|
-
if (rconfig === undefined) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
this.skip(rconfig);
|
|
20
|
-
this.rename(rconfig);
|
|
21
|
-
if (rconfig.output === undefined || rconfig.output === "") {
|
|
22
|
-
// write changes inline
|
|
23
|
-
this.deletedFiles.forEach(f => {
|
|
24
|
-
console.log("rm " + f);
|
|
25
|
-
fs.rmSync(f);
|
|
26
|
-
});
|
|
27
|
-
this.addedFiles.forEach(f => {
|
|
28
|
-
console.log("write " + f.getFilename());
|
|
29
|
-
fs.writeFileSync(f.getFilename(), f.getRaw());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// output full registry contents to output folder
|
|
34
|
-
this.write(rconfig, base);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
////////////////////////
|
|
38
|
-
write(rconfig, base) {
|
|
39
|
-
const outputFolder = base + path.sep + rconfig.output;
|
|
40
|
-
console.log("Base: " + base);
|
|
41
|
-
console.log("Output folder: " + outputFolder);
|
|
42
|
-
file_operations_1.FileOperations.deleteFolderRecursive(outputFolder);
|
|
43
|
-
for (const o of this.reg.getObjects()) {
|
|
44
|
-
if (this.reg.isDependency(o) === true) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
for (const f of o.getFiles()) {
|
|
48
|
-
const n = outputFolder + f.getFilename().replace(base, "");
|
|
49
|
-
console.log("Write " + n);
|
|
50
|
-
fs.mkdirSync(path.dirname(n), { recursive: true });
|
|
51
|
-
fs.writeFileSync(n, f.getRaw());
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
rename(rconfig) {
|
|
56
|
-
const renamer = new abaplint.Rename(this.reg);
|
|
57
|
-
for (const o of this.reg.getObjects()) {
|
|
58
|
-
if (this.reg.isDependency(o) === true) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
for (const p of rconfig.patterns || []) {
|
|
62
|
-
if (!(o.getType().match(p.type))) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const regex = new RegExp(p.oldName, "i");
|
|
66
|
-
const match = regex.exec(o.getName());
|
|
67
|
-
if (!match) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
o.getFiles().forEach(f => this.deletedFiles.push(f.getFilename()));
|
|
71
|
-
const newStr = o.getName().replace(regex, p.newName);
|
|
72
|
-
console.log("Renaming " + o.getName().padEnd(30, " ") + " -> " + newStr);
|
|
73
|
-
renamer.rename(o.getType(), o.getName(), newStr);
|
|
74
|
-
const newObject = this.reg.getObject(o.getType(), newStr);
|
|
75
|
-
newObject === null || newObject === void 0 ? void 0 : newObject.getFiles().forEach(f => this.addedFiles.push(f));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
skip(rconfig) {
|
|
80
|
-
if (rconfig.skip) {
|
|
81
|
-
for (const s of rconfig.skip) {
|
|
82
|
-
const all = [];
|
|
83
|
-
for (const f of this.reg.getFiles()) {
|
|
84
|
-
all.push(f);
|
|
85
|
-
}
|
|
86
|
-
for (const n of all) {
|
|
87
|
-
if (n.getFilename().match(s)) {
|
|
88
|
-
console.log(n.getFilename() + " skipped");
|
|
89
|
-
this.reg.removeFile(n);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
this.reg.parse();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.Rename = Rename;
|
|
98
|
-
//# sourceMappingURL=rename.js.map
|