@abaplint/cli 2.93.24 → 2.93.25
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/cli.js
CHANGED
|
@@ -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 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?");
|
|
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.get(), base, fs);\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
|
|
|
@@ -159,7 +159,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
159
159
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
160
160
|
|
|
161
161
|
"use strict";
|
|
162
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Rename = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst
|
|
162
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Rename = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst file_operations_1 = __webpack_require__(/*! ./file_operations */ \"./build/src/file_operations.js\");\r\nclass Rename {\r\n constructor(reg) {\r\n this.reg = reg;\r\n this.deletedFiles = new Set();\r\n this.addedFiles = new Set();\r\n this.updatedFiles = new Set();\r\n }\r\n run(config, base, fs, quiet) {\r\n const rconfig = config.rename;\r\n if (rconfig === undefined) {\r\n return;\r\n }\r\n this.skip(rconfig);\r\n this.rename(rconfig, quiet);\r\n if (rconfig.output === undefined || rconfig.output === \"\") {\r\n // write changes inline\r\n this.deletedFiles.forEach(f => {\r\n if (quiet !== true) {\r\n console.log(\"rm \" + f);\r\n }\r\n fs.rmSync(f);\r\n });\r\n this.addedFiles.forEach(f => {\r\n if (quiet !== true) {\r\n console.log(\"write \" + f);\r\n }\r\n const file = this.reg.getFileByName(f);\r\n if (file !== undefined) {\r\n fs.writeFileSync(file.getFilename(), file.getRaw());\r\n }\r\n });\r\n this.updatedFiles.forEach(f => {\r\n if (quiet !== true) {\r\n console.log(\"update \" + f);\r\n }\r\n const file = this.reg.getFileByName(f);\r\n if (file !== undefined) {\r\n fs.writeFileSync(file.getFilename(), file.getRaw());\r\n }\r\n });\r\n }\r\n else {\r\n // output full registry contents to output folder\r\n this.write(rconfig, base, fs);\r\n }\r\n }\r\n ////////////////////////\r\n write(rconfig, base, fs) {\r\n const outputFolder = base + path.sep + rconfig.output;\r\n console.log(\"Base: \" + base);\r\n console.log(\"Output folder: \" + outputFolder);\r\n file_operations_1.FileOperations.deleteFolderRecursive(outputFolder);\r\n for (const o of this.reg.getObjects()) {\r\n if (this.reg.isDependency(o) === true) {\r\n continue;\r\n }\r\n for (const f of o.getFiles()) {\r\n const n = outputFolder + f.getFilename().replace(base, \"\");\r\n console.log(\"Write \" + n);\r\n fs.mkdirSync(path.dirname(n), { recursive: true });\r\n fs.writeFileSync(n, f.getRaw());\r\n }\r\n }\r\n }\r\n rename(rconfig, quiet) {\r\n const renamer = new abaplint.Rename(this.reg);\r\n for (const o of this.reg.getObjects()) {\r\n if (this.reg.isDependency(o) === true) {\r\n continue;\r\n }\r\n for (const p of rconfig.patterns || []) {\r\n if (!(o.getType().match(p.type))) {\r\n continue;\r\n }\r\n const regex = new RegExp(p.oldName, \"i\");\r\n const match = regex.exec(o.getName());\r\n if (!match) {\r\n continue;\r\n }\r\n const newStr = o.getName().replace(regex, p.newName);\r\n if (quiet !== true) {\r\n console.log(\"Renaming \" + o.getName().padEnd(30, \" \") + \" -> \" + newStr);\r\n }\r\n const result = renamer.rename(o.getType(), o.getName(), newStr);\r\n result.updatedFiles.forEach(f => { this.updatedFiles.add(f); });\r\n result.deletedFiles.forEach(f => { this.deletedFiles.add(f); });\r\n result.addedFiles.forEach(f => { this.addedFiles.add(f); });\r\n }\r\n }\r\n }\r\n skip(rconfig) {\r\n if (rconfig.skip) {\r\n for (const s of rconfig.skip) {\r\n const all = [];\r\n for (const f of this.reg.getFiles()) {\r\n all.push(f);\r\n }\r\n for (const n of all) {\r\n if (n.getFilename().match(s)) {\r\n console.log(n.getFilename() + \" skipped\");\r\n this.reg.removeFile(n);\r\n }\r\n }\r\n }\r\n this.reg.parse();\r\n }\r\n }\r\n}\r\nexports.Rename = Rename;\r\n//# sourceMappingURL=rename.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./build/src/rename.js?");
|
|
163
163
|
|
|
164
164
|
/***/ }),
|
|
165
165
|
|
|
@@ -11093,7 +11093,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
11093
11093
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11094
11094
|
|
|
11095
11095
|
"use strict";
|
|
11096
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Renamer = void 0;\r\nconst vscode_languageserver_types_1 = __webpack_require__(/*! vscode-languageserver-types */ \"./node_modules/vscode-languageserver-types/lib/esm/main.js\");\r\nconst memory_file_1 = __webpack_require__(/*! ../../files/memory_file */ \"./node_modules/@abaplint/core/build/src/files/memory_file.js\");\r\nconst rename_data_element_1 = __webpack_require__(/*! ./rename_data_element */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_data_element.js\");\r\nconst rename_domain_1 = __webpack_require__(/*! ./rename_domain */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_domain.js\");\r\nconst rename_global_class_1 = __webpack_require__(/*! ./rename_global_class */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_global_class.js\");\r\nconst rename_global_interface_1 = __webpack_require__(/*! ./rename_global_interface */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_global_interface.js\");\r\nconst rename_table_1 = __webpack_require__(/*! ./rename_table */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_table.js\");\r\nconst rename_table_type_1 = __webpack_require__(/*! ./rename_table_type */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_table_type.js\");\r\nclass Renamer {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n /** Applies the renaming to the objects and files in the registry,\r\n * after renaming the registry is not parsed */\r\n rename(type, oldName, newName) {\r\n const edits = this.buildEdits(type, oldName, newName);\r\n if (edits === undefined) {\r\n throw new Error(\"no changes could be determined\");\r\n }\r\n else if (edits.changes) {\r\n throw new Error(\"only documentChanges expected\");\r\n }\r\n this.apply(edits);\r\n this.reg.findIssues(); // hmm, this builds the ddic references\r\n }\r\n /** Builds edits, but does not apply to registry, used by LSP */\r\n buildEdits(type, oldName, newName) {\r\n this.reg.parse(); // the registry must be parsed to dermine references\r\n const obj = this.reg.getObject(type, oldName);\r\n if (obj === undefined) {\r\n throw new Error(\"rename, object not found\");\r\n }\r\n else if (newName.length > obj.getAllowedNaming().maxLength) {\r\n // todo, also do not allow strange characters and spaces\r\n throw new Error(\"Name not allowed\");\r\n }\r\n const r = this.factory(type);\r\n return r.buildEdits(obj, oldName.toUpperCase(), newName);\r\n }\r\n //////////////////\r\n factory(type) {\r\n switch (type) {\r\n case \"CLAS\":\r\n return new rename_global_class_1.RenameGlobalClass(this.reg);\r\n case \"DTEL\":\r\n return new rename_data_element_1.RenameDataElement(this.reg);\r\n case \"DOMA\":\r\n return new rename_domain_1.RenameDomain(this.reg);\r\n case \"TABL\":\r\n return new rename_table_1.RenameTable(this.reg);\r\n case \"TTYP\":\r\n return new rename_table_type_1.RenameTableType(this.reg);\r\n case \"INTF\":\r\n return new rename_global_interface_1.RenameGlobalInterface(this.reg);\r\n default:\r\n throw new Error(\"Renaming of \" + type + \" not yet supported\");\r\n }\r\n }\r\n apply(edits) {\r\n const renames = [];\r\n // assumption: only renames or text changes, no deletes or creates\r\n for (const dc of edits.documentChanges || []) {\r\n if (vscode_languageserver_types_1.TextDocumentEdit.is(dc)) {\r\n this.applyEdit(dc);\r\n }\r\n else if (vscode_languageserver_types_1.RenameFile.is(dc)) {\r\n renames.push(dc);\r\n }\r\n else {\r\n throw new Error(\"unexpected documentChange type\");\r\n }\r\n }\r\n this.applyRenames(renames);\r\n }\r\n applyEdit(dc) {\r\n const file = this.reg.getFileByName(dc.textDocument.uri);\r\n if (file === undefined) {\r\n throw new Error(\"file \" + dc.textDocument.uri + \" not found\");\r\n }\r\n const rows = file.getRawRows();\r\n for (const e of dc.edits) {\r\n if (e.range.start.line !== e.range.end.line) {\r\n throw new Error(\"applyEdit, start and end line differ\");\r\n }\r\n const before = rows[e.range.start.line];\r\n rows[e.range.start.line] = before.substring(0, e.range.start.character) +\r\n e.newText +\r\n before.substring(e.range.end.character);\r\n }\r\n const newFile = new memory_file_1.MemoryFile(dc.textDocument.uri, rows.join(\"\\n\"));\r\n this.reg.updateFile(newFile);\r\n }\r\n applyRenames(renames) {\r\n for (const r of renames) {\r\n const old = this.reg.getFileByName(r.oldUri);\r\n if (old === undefined) {\r\n throw new Error(\"applyRenames, old not found\");\r\n }\r\n const newFile = new memory_file_1.MemoryFile(r.newUri, old.getRaw());\r\n this.reg.removeFile(old);\r\n this.reg.addFile(newFile);\r\n }\r\n }\r\n}\r\nexports.Renamer = Renamer;\r\n//# sourceMappingURL=renamer.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/objects/rename/renamer.js?");
|
|
11096
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Renamer = void 0;\r\nconst vscode_languageserver_types_1 = __webpack_require__(/*! vscode-languageserver-types */ \"./node_modules/vscode-languageserver-types/lib/esm/main.js\");\r\nconst memory_file_1 = __webpack_require__(/*! ../../files/memory_file */ \"./node_modules/@abaplint/core/build/src/files/memory_file.js\");\r\nconst rename_data_element_1 = __webpack_require__(/*! ./rename_data_element */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_data_element.js\");\r\nconst rename_domain_1 = __webpack_require__(/*! ./rename_domain */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_domain.js\");\r\nconst rename_global_class_1 = __webpack_require__(/*! ./rename_global_class */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_global_class.js\");\r\nconst rename_global_interface_1 = __webpack_require__(/*! ./rename_global_interface */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_global_interface.js\");\r\nconst rename_table_1 = __webpack_require__(/*! ./rename_table */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_table.js\");\r\nconst rename_table_type_1 = __webpack_require__(/*! ./rename_table_type */ \"./node_modules/@abaplint/core/build/src/objects/rename/rename_table_type.js\");\r\nclass Renamer {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n /** Applies the renaming to the objects and files in the registry,\r\n * after renaming the registry is not parsed */\r\n rename(type, oldName, newName) {\r\n const edits = this.buildEdits(type, oldName, newName);\r\n if (edits === undefined) {\r\n throw new Error(\"no changes could be determined\");\r\n }\r\n else if (edits.changes) {\r\n throw new Error(\"only documentChanges expected\");\r\n }\r\n const result = this.apply(edits);\r\n this.reg.findIssues(); // hmm, this builds the ddic references\r\n return result;\r\n }\r\n /** Builds edits, but does not apply to registry, used by LSP */\r\n buildEdits(type, oldName, newName) {\r\n this.reg.parse(); // the registry must be parsed to dermine references\r\n const obj = this.reg.getObject(type, oldName);\r\n if (obj === undefined) {\r\n throw new Error(\"rename, object not found\");\r\n }\r\n else if (newName.length > obj.getAllowedNaming().maxLength) {\r\n // todo, also do not allow strange characters and spaces\r\n throw new Error(\"Name not allowed\");\r\n }\r\n const r = this.factory(type);\r\n return r.buildEdits(obj, oldName.toUpperCase(), newName);\r\n }\r\n //////////////////\r\n factory(type) {\r\n switch (type) {\r\n case \"CLAS\":\r\n return new rename_global_class_1.RenameGlobalClass(this.reg);\r\n case \"DTEL\":\r\n return new rename_data_element_1.RenameDataElement(this.reg);\r\n case \"DOMA\":\r\n return new rename_domain_1.RenameDomain(this.reg);\r\n case \"TABL\":\r\n return new rename_table_1.RenameTable(this.reg);\r\n case \"TTYP\":\r\n return new rename_table_type_1.RenameTableType(this.reg);\r\n case \"INTF\":\r\n return new rename_global_interface_1.RenameGlobalInterface(this.reg);\r\n default:\r\n throw new Error(\"Renaming of \" + type + \" not yet supported\");\r\n }\r\n }\r\n apply(edits) {\r\n const renames = [];\r\n const result = {\r\n addedFiles: new Set(),\r\n deletedFiles: new Set(),\r\n updatedFiles: new Set(),\r\n };\r\n // assumption: only renames or text changes, no deletes or creates\r\n for (const dc of edits.documentChanges || []) {\r\n if (vscode_languageserver_types_1.TextDocumentEdit.is(dc)) {\r\n this.applyEdit(dc);\r\n result.updatedFiles.add(dc.textDocument.uri);\r\n }\r\n else if (vscode_languageserver_types_1.RenameFile.is(dc)) {\r\n renames.push(dc);\r\n }\r\n else {\r\n throw new Error(\"unexpected documentChange type\");\r\n }\r\n }\r\n for (const rename of renames) {\r\n result.updatedFiles.delete(rename.oldUri);\r\n result.deletedFiles.add(rename.oldUri);\r\n result.addedFiles.add(rename.newUri);\r\n }\r\n this.applyRenames(renames);\r\n return result;\r\n }\r\n applyEdit(dc) {\r\n const file = this.reg.getFileByName(dc.textDocument.uri);\r\n if (file === undefined) {\r\n throw new Error(\"file \" + dc.textDocument.uri + \" not found\");\r\n }\r\n const rows = file.getRawRows();\r\n for (const e of dc.edits) {\r\n if (e.range.start.line !== e.range.end.line) {\r\n throw new Error(\"applyEdit, start and end line differ\");\r\n }\r\n const before = rows[e.range.start.line];\r\n rows[e.range.start.line] = before.substring(0, e.range.start.character) +\r\n e.newText +\r\n before.substring(e.range.end.character);\r\n }\r\n const newFile = new memory_file_1.MemoryFile(dc.textDocument.uri, rows.join(\"\\n\"));\r\n this.reg.updateFile(newFile);\r\n }\r\n applyRenames(renames) {\r\n for (const r of renames) {\r\n const old = this.reg.getFileByName(r.oldUri);\r\n if (old === undefined) {\r\n throw new Error(\"applyRenames, old not found\");\r\n }\r\n const newFile = new memory_file_1.MemoryFile(r.newUri, old.getRaw());\r\n this.reg.removeFile(old);\r\n this.reg.addFile(newFile);\r\n }\r\n }\r\n}\r\nexports.Renamer = Renamer;\r\n//# sourceMappingURL=renamer.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/objects/rename/renamer.js?");
|
|
11097
11097
|
|
|
11098
11098
|
/***/ }),
|
|
11099
11099
|
|
|
@@ -11467,7 +11467,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
11467
11467
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11468
11468
|
|
|
11469
11469
|
"use strict";
|
|
11470
|
-
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.24\";\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?");
|
|
11470
|
+
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.25\";\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?");
|
|
11471
11471
|
|
|
11472
11472
|
/***/ }),
|
|
11473
11473
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.93.
|
|
3
|
+
"version": "2.93.25",
|
|
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.25",
|
|
43
43
|
"@types/chai": "^4.3.3",
|
|
44
44
|
"@types/glob": "^7.2.0",
|
|
45
45
|
"@types/minimist": "^1.2.2",
|