@abaplint/cli 2.80.5 → 2.80.6
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/bundle.js +3 -3
- package/package.json +2 -2
package/build/bundle.js
CHANGED
|
@@ -8409,7 +8409,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
8409
8409
|
/***/ ((__unused_webpack_module, exports) => {
|
|
8410
8410
|
|
|
8411
8411
|
"use strict";
|
|
8412
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FlowGraph = void 0;\r\nclass FlowGraph {\r\n constructor(counter) {\r\n this.label = \"undefined\";\r\n this.edges = {};\r\n this.start = \"start#\" + counter;\r\n this.end = \"end#\" + counter;\r\n }\r\n getStart() {\r\n return this.start;\r\n }\r\n getEnd() {\r\n return this.end;\r\n }\r\n addEdge(from, to) {\r\n if (this.edges[from] === undefined) {\r\n this.edges[from] = {};\r\n }\r\n this.edges[from][to] = true;\r\n }\r\n removeEdge(from, to) {\r\n if (this.edges[from] === undefined) {\r\n return;\r\n }\r\n delete this.edges[from][to];\r\n if (Object.keys(this.edges[from]).length === 0) {\r\n delete this.edges[from];\r\n }\r\n }\r\n listEdges() {\r\n const list = [];\r\n for (const from of Object.keys(this.edges)) {\r\n for (const to of Object.keys(this.edges[from])) {\r\n list.push({ from, to });\r\n }\r\n }\r\n return list;\r\n }\r\n listNodes() {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n set.add(l.from);\r\n set.add(l.to);\r\n }\r\n return Array.from(set.values());\r\n }\r\n hasEdges() {\r\n return Object.keys(this.edges).length > 0;\r\n }\r\n /** return value: end node of to graph */\r\n addGraph(from, to) {\r\n if (to.hasEdges() === false) {\r\n return from;\r\n }\r\n this.addEdge(from, to.getStart());\r\n to.listEdges().forEach(e => this.addEdge(e.from, e.to));\r\n return to.getEnd();\r\n }\r\n toJSON() {\r\n return JSON.stringify(this.edges);\r\n }\r\n toTextEdges() {\r\n let graph = \"\";\r\n for (const l of this.listEdges()) {\r\n graph += `\"${l.from}\" -> \"${l.to}\";\\n`;\r\n }\r\n return graph.trim();\r\n }\r\n setLabel(label) {\r\n this.label = label;\r\n }\r\n toDigraph() {\r\n return `digraph G {\r\nlabelloc=\"t\";\r\nlabel=\"${this.label}\";\r\ngraph [fontname = \"helvetica\"];\r\nnode [fontname = \"helvetica\"];\r\nedge [fontname = \"helvetica\"];\r\n${this.toTextEdges()}\r\n}`;\r\n }\r\n listSources(node) {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n if (node === l.to) {\r\n set.add(l.from);\r\n }\r\n }\r\n return Array.from(set.values());\r\n }\r\n listTargets(node) {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n if (node === l.from) {\r\n set.add(l.to);\r\n }\r\n }\r\n return Array.from(set.values());\r\n }\r\n /** removes all nodes containing \"#\" that have one ingoing and one outgoing edge */\r\n reduce() {\r\n for (const node of this.listNodes()) {\r\n if (node.includes(\"#\") === false) {\r\n continue;\r\n }\r\n const sources = this.listSources(node);\r\n const targets = this.listTargets(node);\r\n if (sources.length > 0 && targets.length > 0) {\r\n // hash node in the middle of the graph\r\n for (const s of sources) {\r\n this.removeEdge(s, node);\r\n }\r\n for (const t of targets) {\r\n this.removeEdge(node, t);\r\n }\r\n for (const s of sources) {\r\n for (const t of targets) {\r\n this.addEdge(s, t);\r\n }\r\n }\r\n }\r\n if (node.startsWith(\"end#\") && sources.length === 0) {\r\n for (const t of targets) {\r\n this.removeEdge(node, t);\r\n }\r\n }\r\n }\r\n return this;\r\n }\r\n}\r\nexports.FlowGraph = FlowGraph;\r\n//# sourceMappingURL=flow_graph.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/flow/flow_graph.js?");
|
|
8412
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FlowGraph = void 0;\r\nclass FlowGraph {\r\n constructor(counter) {\r\n this.label = \"undefined\";\r\n this.edges = {};\r\n this.start = \"start#\" + counter;\r\n this.end = \"end#\" + counter;\r\n }\r\n getStart() {\r\n return this.start;\r\n }\r\n getEnd() {\r\n return this.end;\r\n }\r\n addEdge(from, to) {\r\n if (this.edges[from] === undefined) {\r\n this.edges[from] = {};\r\n }\r\n this.edges[from][to] = true;\r\n }\r\n removeEdge(from, to) {\r\n if (this.edges[from] === undefined) {\r\n return;\r\n }\r\n delete this.edges[from][to];\r\n if (Object.keys(this.edges[from]).length === 0) {\r\n delete this.edges[from];\r\n }\r\n }\r\n listEdges() {\r\n const list = [];\r\n for (const from of Object.keys(this.edges)) {\r\n for (const to of Object.keys(this.edges[from])) {\r\n list.push({ from, to });\r\n }\r\n }\r\n return list;\r\n }\r\n listNodes() {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n set.add(l.from);\r\n set.add(l.to);\r\n }\r\n return Array.from(set.values());\r\n }\r\n hasEdges() {\r\n return Object.keys(this.edges).length > 0;\r\n }\r\n /** return value: end node of to graph */\r\n addGraph(from, to) {\r\n if (to.hasEdges() === false) {\r\n return from;\r\n }\r\n this.addEdge(from, to.getStart());\r\n to.listEdges().forEach(e => this.addEdge(e.from, e.to));\r\n return to.getEnd();\r\n }\r\n toJSON() {\r\n return JSON.stringify(this.edges);\r\n }\r\n toTextEdges() {\r\n let graph = \"\";\r\n for (const l of this.listEdges()) {\r\n graph += `\"${l.from}\" -> \"${l.to}\";\\n`;\r\n }\r\n return graph.trim();\r\n }\r\n setLabel(label) {\r\n this.label = label;\r\n }\r\n toDigraph() {\r\n return `digraph G {\r\nlabelloc=\"t\";\r\nlabel=\"${this.label}\";\r\ngraph [fontname = \"helvetica\"];\r\nnode [fontname = \"helvetica\", shape=\"box\"];\r\nedge [fontname = \"helvetica\"];\r\n${this.toTextEdges()}\r\n}`;\r\n }\r\n listSources(node) {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n if (node === l.to) {\r\n set.add(l.from);\r\n }\r\n }\r\n return Array.from(set.values());\r\n }\r\n listTargets(node) {\r\n const set = new Set();\r\n for (const l of this.listEdges()) {\r\n if (node === l.from) {\r\n set.add(l.to);\r\n }\r\n }\r\n return Array.from(set.values());\r\n }\r\n /** removes all nodes containing \"#\" that have one ingoing and one outgoing edge */\r\n reduce() {\r\n for (const node of this.listNodes()) {\r\n if (node.includes(\"#\") === false) {\r\n continue;\r\n }\r\n const sources = this.listSources(node);\r\n const targets = this.listTargets(node);\r\n if (sources.length > 0 && targets.length > 0) {\r\n // hash node in the middle of the graph\r\n for (const s of sources) {\r\n this.removeEdge(s, node);\r\n }\r\n for (const t of targets) {\r\n this.removeEdge(node, t);\r\n }\r\n for (const s of sources) {\r\n for (const t of targets) {\r\n this.addEdge(s, t);\r\n }\r\n }\r\n }\r\n if (node.startsWith(\"end#\") && sources.length === 0) {\r\n for (const t of targets) {\r\n this.removeEdge(node, t);\r\n }\r\n }\r\n }\r\n return this;\r\n }\r\n}\r\nexports.FlowGraph = FlowGraph;\r\n//# sourceMappingURL=flow_graph.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/flow/flow_graph.js?");
|
|
8413
8413
|
|
|
8414
8414
|
/***/ }),
|
|
8415
8415
|
|
|
@@ -8420,7 +8420,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
8420
8420
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
8421
8421
|
|
|
8422
8422
|
"use strict";
|
|
8423
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.StatementFlow = void 0;\r\nconst nodes_1 = __webpack_require__(/*! ../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst Structures = __webpack_require__(/*! ../3_structures/structures */ \"./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst flow_graph_1 = __webpack_require__(/*! ./flow_graph */ \"./node_modules/@abaplint/core/build/src/abap/flow/flow_graph.js\");\r\n// Levels: top, FORM, METHOD, FUNCTION-MODULE, (MODULE, AT, END-OF-*, GET, START-OF-SELECTION, TOP-OF-PAGE)\r\n//\r\n// Loop branching: LOOP, DO, WHILE,SELECT(loop), WITH, PROVIDE\r\n//\r\n// Branching: IF, CASE, CASE TYPE OF, TRY, ON, CATCH SYSTEM-EXCEPTIONS, AT\r\n//\r\n// Conditional exits: CHECK, ASSERT\r\n//\r\n// Exits: RETURN, EXIT, RAISE(not RESUMABLE), MESSAGE(type E and A?), CONTINUE, REJECT, RESUME, STOP\r\n//\r\n// Not handled? INCLUDE + malplaced macro calls\r\n/////////////////////////////////////\r\n// TODO: handling static exceptions(only static), refactor some logic from UncaughtException to common file\r\n// TODO: RAISE\r\nclass StatementFlow {\r\n constructor() {\r\n this.counter = 0;\r\n }\r\n build(stru) {\r\n var _a, _b;\r\n const ret = [];\r\n const forms = stru.findAllStructures(Structures.Form);\r\n for (const f of forms) {\r\n const formName = \"FORM \" + ((_a = f.findFirstExpression(Expressions.FormName)) === null || _a === void 0 ? void 0 : _a.concatTokens());\r\n this.counter = 1;\r\n const graph = this.traverseBody(this.findBody(f), \"end#1\", undefined);\r\n graph.setLabel(formName);\r\n ret.push(graph);\r\n }\r\n const methods = stru.findAllStructures(Structures.Method);\r\n for (const f of methods) {\r\n const methodName = \"METHOD \" + ((_b = f.findFirstExpression(Expressions.MethodName)) === null || _b === void 0 ? void 0 : _b.concatTokens());\r\n this.counter = 1;\r\n const graph = this.traverseBody(this.findBody(f), \"end#1\", undefined);\r\n graph.setLabel(methodName);\r\n ret.push(graph);\r\n }\r\n return ret.map(f => f.reduce());\r\n }\r\n findBody(f) {\r\n var _a;\r\n return ((_a = f.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || [];\r\n }\r\n buildName(statement) {\r\n // note: there might be multiple statements on the same line\r\n return statement.get().constructor.name +\r\n \":\" + statement.getFirstToken().getRow() +\r\n \",\" + statement.getFirstToken().getCol();\r\n }\r\n traverseBody(children, procedureEnd, loopStart) {\r\n const graph = new flow_graph_1.FlowGraph(this.counter++);\r\n if (children.length === 0) {\r\n graph.addEdge(graph.getStart(), graph.getEnd());\r\n return graph;\r\n }\r\n let current = graph.getStart();\r\n for (const c of children) {\r\n if (c.get() instanceof Structures.Normal) {\r\n const firstChild = c.getFirstChild(); // \"Normal\" only has one child\r\n if (firstChild instanceof nodes_1.StatementNode) {\r\n const name = this.buildName(firstChild);\r\n graph.addEdge(current, name);\r\n current = name;\r\n if (firstChild.get() instanceof Statements.Check) {\r\n if (loopStart) {\r\n graph.addEdge(name, loopStart);\r\n }\r\n else {\r\n graph.addEdge(name, procedureEnd);\r\n }\r\n }\r\n else if (firstChild.get() instanceof Statements.Assert) {\r\n graph.addEdge(name, procedureEnd);\r\n }\r\n else if (firstChild.get() instanceof Statements.Continue && loopStart) {\r\n graph.addEdge(name, loopStart);\r\n return graph;\r\n }\r\n else if (firstChild.get() instanceof Statements.Exit) {\r\n if (loopStart) {\r\n // hmm, perhaps this should hit loop end instead?\r\n graph.addEdge(name, loopStart);\r\n }\r\n else {\r\n graph.addEdge(name, procedureEnd);\r\n }\r\n return graph;\r\n }\r\n else if (firstChild.get() instanceof Statements.Return) {\r\n graph.addEdge(name, procedureEnd);\r\n return graph;\r\n }\r\n }\r\n else if (firstChild instanceof nodes_1.StructureNode) {\r\n const sub = this.traverseStructure(firstChild, procedureEnd, loopStart);\r\n current = graph.addGraph(current, sub);\r\n }\r\n }\r\n }\r\n graph.addEdge(current, graph.getEnd());\r\n return graph;\r\n }\r\n traverseStructure(n, procedureEnd, loopStart) {\r\n const graph = new flow_graph_1.FlowGraph(this.counter++);\r\n if (n === undefined) {\r\n return graph;\r\n }\r\n let current = graph.getStart();\r\n const type = n.get();\r\n if (type instanceof Structures.If) {\r\n const ifName = this.buildName(n.findDirectStatement(Statements.If));\r\n const sub = this.traverseBody(this.findBody(n), procedureEnd, loopStart);\r\n graph.addEdge(current, ifName);\r\n graph.addGraph(ifName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n current = ifName;\r\n for (const e of n.findDirectStructures(Structures.ElseIf)) {\r\n const elseifst = e.findDirectStatement(Statements.ElseIf);\r\n if (elseifst === undefined) {\r\n continue;\r\n }\r\n const elseIfName = this.buildName(elseifst);\r\n const sub = this.traverseBody(this.findBody(e), procedureEnd, loopStart);\r\n graph.addEdge(current, elseIfName);\r\n graph.addGraph(elseIfName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n current = elseIfName;\r\n }\r\n const els = n.findDirectStructure(Structures.Else);\r\n const elsest = els === null || els === void 0 ? void 0 : els.findDirectStatement(Statements.Else);\r\n if (els && elsest) {\r\n const elseName = this.buildName(elsest);\r\n const sub = this.traverseBody(this.findBody(els), procedureEnd, loopStart);\r\n graph.addEdge(current, elseName);\r\n graph.addGraph(elseName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n else {\r\n graph.addEdge(ifName, graph.getEnd());\r\n }\r\n }\r\n else if (type instanceof Structures.Loop\r\n || type instanceof Structures.While\r\n || type instanceof Structures.With\r\n || type instanceof Structures.Provide\r\n || type instanceof Structures.Select\r\n || type instanceof Structures.Do) {\r\n const loopName = this.buildName(n.getFirstStatement());\r\n const sub = this.traverseBody(this.findBody(n), procedureEnd, loopName);\r\n graph.addEdge(current, loopName);\r\n graph.addGraph(loopName, sub);\r\n graph.addEdge(sub.getEnd(), loopName);\r\n graph.addEdge(loopName, graph.getEnd());\r\n }\r\n else if (type instanceof Structures.Try) {\r\n const tryName = this.buildName(n.getFirstStatement());\r\n const body = this.traverseBody(this.findBody(n), procedureEnd, loopStart);\r\n graph.addEdge(current, tryName);\r\n graph.addGraph(tryName, body);\r\n graph.addEdge(body.getEnd(), graph.getEnd());\r\n for (const c of n.findDirectStructures(Structures.Catch)) {\r\n const catchName = this.buildName(c.getFirstStatement());\r\n const catchBody = this.traverseBody(this.findBody(c), procedureEnd, loopStart);\r\n // TODO: this does not take exceptions into account\r\n graph.addEdge(body.getEnd(), catchName);\r\n graph.addGraph(catchName, catchBody);\r\n graph.addEdge(catchBody.getEnd(), graph.getEnd());\r\n }\r\n // TODO, handle CLEANUP\r\n }\r\n else if (type instanceof Structures.Case) {\r\n const caseName = this.buildName(n.getFirstStatement());\r\n graph.addEdge(current, caseName);\r\n let othersFound = false;\r\n for (const w of n.findDirectStructures(Structures.When)) {\r\n const first = w.getFirstStatement();\r\n if (first === undefined) {\r\n continue;\r\n }\r\n if (first.get() instanceof Statements.WhenOthers) {\r\n othersFound = true;\r\n }\r\n const firstName = this.buildName(first);\r\n const sub = this.traverseBody(this.findBody(w), procedureEnd, loopStart);\r\n graph.addEdge(caseName, firstName);\r\n graph.addGraph(firstName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n if (othersFound === false) {\r\n graph.addEdge(caseName, graph.getEnd());\r\n }\r\n }\r\n else if (type instanceof Structures.CaseType) {\r\n const caseName = this.buildName(n.getFirstStatement());\r\n graph.addEdge(current, caseName);\r\n let othersFound = false;\r\n for (const w of n.findDirectStructures(Structures.WhenType)) {\r\n const first = w.getFirstStatement();\r\n if (first === undefined) {\r\n continue;\r\n }\r\n if (first.get() instanceof Statements.WhenOthers) {\r\n othersFound = true;\r\n }\r\n const firstName = this.buildName(first);\r\n const sub = this.traverseBody(this.findBody(w), procedureEnd, loopStart);\r\n graph.addEdge(caseName, firstName);\r\n graph.addGraph(firstName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n if (othersFound === false) {\r\n graph.addEdge(caseName, graph.getEnd());\r\n }\r\n }\r\n else {\r\n console.dir(\"todo, \" + n.get().constructor.name);\r\n }\r\n return graph;\r\n }\r\n}\r\nexports.StatementFlow = StatementFlow;\r\n//# sourceMappingURL=statement_flow.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/flow/statement_flow.js?");
|
|
8423
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.StatementFlow = void 0;\r\nconst nodes_1 = __webpack_require__(/*! ../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst Structures = __webpack_require__(/*! ../3_structures/structures */ \"./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst flow_graph_1 = __webpack_require__(/*! ./flow_graph */ \"./node_modules/@abaplint/core/build/src/abap/flow/flow_graph.js\");\r\nclass StatementFlow {\r\n constructor() {\r\n this.counter = 0;\r\n }\r\n build(stru) {\r\n var _a, _b;\r\n const ret = [];\r\n const forms = stru.findAllStructures(Structures.Form);\r\n for (const f of forms) {\r\n const formName = \"FORM \" + ((_a = f.findFirstExpression(Expressions.FormName)) === null || _a === void 0 ? void 0 : _a.concatTokens());\r\n this.counter = 1;\r\n const graph = this.traverseBody(this.findBody(f), { procedureEnd: \"end#1\" });\r\n graph.setLabel(formName);\r\n ret.push(graph);\r\n }\r\n const methods = stru.findAllStructures(Structures.Method);\r\n for (const f of methods) {\r\n const methodName = \"METHOD \" + ((_b = f.findFirstExpression(Expressions.MethodName)) === null || _b === void 0 ? void 0 : _b.concatTokens());\r\n this.counter = 1;\r\n const graph = this.traverseBody(this.findBody(f), { procedureEnd: \"end#1\" });\r\n graph.setLabel(methodName);\r\n ret.push(graph);\r\n }\r\n return ret.map(f => f.reduce());\r\n }\r\n findBody(f) {\r\n var _a;\r\n return ((_a = f.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || [];\r\n }\r\n buildName(statement) {\r\n let token = undefined;\r\n const colon = statement.getColon();\r\n if (colon === undefined) {\r\n token = statement.getFirstToken();\r\n }\r\n else {\r\n for (const t of statement.getTokens()) {\r\n if (t.getStart().isAfter(colon.getEnd())) {\r\n token = t;\r\n break;\r\n }\r\n }\r\n }\r\n if (token === undefined) {\r\n return \"tokenError\";\r\n }\r\n return statement.get().constructor.name +\r\n \":\" + token.getRow() +\r\n \",\" + token.getCol();\r\n }\r\n traverseBody(children, context) {\r\n const graph = new flow_graph_1.FlowGraph(this.counter++);\r\n if (children.length === 0) {\r\n graph.addEdge(graph.getStart(), graph.getEnd());\r\n return graph;\r\n }\r\n let current = graph.getStart();\r\n for (const c of children) {\r\n if (c.get() instanceof Structures.Normal) {\r\n const firstChild = c.getFirstChild(); // \"Normal\" only has one child\r\n if (firstChild instanceof nodes_1.StatementNode) {\r\n const name = this.buildName(firstChild);\r\n graph.addEdge(current, name);\r\n current = name;\r\n if (firstChild.get() instanceof Statements.Check) {\r\n if (context.loopStart) {\r\n graph.addEdge(name, context.loopStart);\r\n }\r\n else {\r\n graph.addEdge(name, context.procedureEnd);\r\n }\r\n }\r\n else if (firstChild.get() instanceof Statements.Assert) {\r\n graph.addEdge(name, context.procedureEnd);\r\n }\r\n else if (firstChild.get() instanceof Statements.Continue && context.loopStart) {\r\n graph.addEdge(name, context.loopStart);\r\n return graph;\r\n }\r\n else if (firstChild.get() instanceof Statements.Exit) {\r\n if (context.loopEnd) {\r\n graph.addEdge(name, context.loopEnd);\r\n }\r\n else {\r\n graph.addEdge(name, context.procedureEnd);\r\n }\r\n return graph;\r\n }\r\n else if (firstChild.get() instanceof Statements.Return) {\r\n graph.addEdge(name, context.procedureEnd);\r\n return graph;\r\n }\r\n }\r\n else if (firstChild instanceof nodes_1.StructureNode) {\r\n const sub = this.traverseStructure(firstChild, context);\r\n current = graph.addGraph(current, sub);\r\n }\r\n }\r\n }\r\n graph.addEdge(current, graph.getEnd());\r\n return graph;\r\n }\r\n traverseStructure(n, context) {\r\n const graph = new flow_graph_1.FlowGraph(this.counter++);\r\n if (n === undefined) {\r\n return graph;\r\n }\r\n let current = graph.getStart();\r\n const type = n.get();\r\n if (type instanceof Structures.If) {\r\n const ifName = this.buildName(n.findDirectStatement(Statements.If));\r\n const sub = this.traverseBody(this.findBody(n), context);\r\n graph.addEdge(current, ifName);\r\n graph.addGraph(ifName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n current = ifName;\r\n for (const e of n.findDirectStructures(Structures.ElseIf)) {\r\n const elseifst = e.findDirectStatement(Statements.ElseIf);\r\n if (elseifst === undefined) {\r\n continue;\r\n }\r\n const elseIfName = this.buildName(elseifst);\r\n const sub = this.traverseBody(this.findBody(e), context);\r\n graph.addEdge(current, elseIfName);\r\n graph.addGraph(elseIfName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n current = elseIfName;\r\n }\r\n const els = n.findDirectStructure(Structures.Else);\r\n const elsest = els === null || els === void 0 ? void 0 : els.findDirectStatement(Statements.Else);\r\n if (els && elsest) {\r\n const elseName = this.buildName(elsest);\r\n const sub = this.traverseBody(this.findBody(els), context);\r\n graph.addEdge(current, elseName);\r\n graph.addGraph(elseName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n else {\r\n graph.addEdge(ifName, graph.getEnd());\r\n }\r\n }\r\n else if (type instanceof Structures.Loop\r\n || type instanceof Structures.While\r\n || type instanceof Structures.With\r\n || type instanceof Structures.Provide\r\n || type instanceof Structures.Select\r\n || type instanceof Structures.Do) {\r\n const loopName = this.buildName(n.getFirstStatement());\r\n const sub = this.traverseBody(this.findBody(n), Object.assign(Object.assign({}, context), { loopStart: loopName, loopEnd: graph.getEnd() }));\r\n graph.addEdge(current, loopName);\r\n graph.addGraph(loopName, sub);\r\n graph.addEdge(sub.getEnd(), loopName);\r\n graph.addEdge(loopName, graph.getEnd());\r\n }\r\n else if (type instanceof Structures.Try) {\r\n const tryName = this.buildName(n.getFirstStatement());\r\n const body = this.traverseBody(this.findBody(n), context);\r\n graph.addEdge(current, tryName);\r\n graph.addGraph(tryName, body);\r\n graph.addEdge(body.getEnd(), graph.getEnd());\r\n for (const c of n.findDirectStructures(Structures.Catch)) {\r\n const catchName = this.buildName(c.getFirstStatement());\r\n const catchBody = this.traverseBody(this.findBody(c), context);\r\n // TODO: this does not take exceptions into account\r\n graph.addEdge(body.getEnd(), catchName);\r\n graph.addGraph(catchName, catchBody);\r\n graph.addEdge(catchBody.getEnd(), graph.getEnd());\r\n }\r\n // TODO, handle CLEANUP\r\n }\r\n else if (type instanceof Structures.Case) {\r\n const caseName = this.buildName(n.getFirstStatement());\r\n graph.addEdge(current, caseName);\r\n let othersFound = false;\r\n for (const w of n.findDirectStructures(Structures.When)) {\r\n const first = w.getFirstStatement();\r\n if (first === undefined) {\r\n continue;\r\n }\r\n if (first.get() instanceof Statements.WhenOthers) {\r\n othersFound = true;\r\n }\r\n const firstName = this.buildName(first);\r\n const sub = this.traverseBody(this.findBody(w), context);\r\n graph.addEdge(caseName, firstName);\r\n graph.addGraph(firstName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n if (othersFound === false) {\r\n graph.addEdge(caseName, graph.getEnd());\r\n }\r\n }\r\n else if (type instanceof Structures.CaseType) {\r\n const caseName = this.buildName(n.getFirstStatement());\r\n graph.addEdge(current, caseName);\r\n let othersFound = false;\r\n for (const w of n.findDirectStructures(Structures.WhenType)) {\r\n const first = w.getFirstStatement();\r\n if (first === undefined) {\r\n continue;\r\n }\r\n if (first.get() instanceof Statements.WhenOthers) {\r\n othersFound = true;\r\n }\r\n const firstName = this.buildName(first);\r\n const sub = this.traverseBody(this.findBody(w), context);\r\n graph.addEdge(caseName, firstName);\r\n graph.addGraph(firstName, sub);\r\n graph.addEdge(sub.getEnd(), graph.getEnd());\r\n }\r\n if (othersFound === false) {\r\n graph.addEdge(caseName, graph.getEnd());\r\n }\r\n }\r\n else {\r\n console.dir(\"StatementFlow,todo, \" + n.get().constructor.name);\r\n }\r\n return graph;\r\n }\r\n}\r\nexports.StatementFlow = StatementFlow;\r\n//# sourceMappingURL=statement_flow.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/flow/statement_flow.js?");
|
|
8424
8424
|
|
|
8425
8425
|
/***/ }),
|
|
8426
8426
|
|
|
@@ -10675,7 +10675,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
10675
10675
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10676
10676
|
|
|
10677
10677
|
"use strict";
|
|
10678
|
-
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 artifacts_rules_1 = __webpack_require__(/*! ./artifacts_rules */ \"./node_modules/@abaplint/core/build/src/artifacts_rules.js\");\nconst skip_logic_1 = __webpack_require__(/*! ./skip_logic */ \"./node_modules/@abaplint/core/build/src/skip_logic.js\");\nconst _abap_object_1 = __webpack_require__(/*! ./objects/_abap_object */ \"./node_modules/@abaplint/core/build/src/objects/_abap_object.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 syntax_1 = __webpack_require__(/*! ./abap/5_syntax/syntax */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.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\");\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 /** object containing filenames of dependencies */\n this.dependencies = {};\n this.issues = [];\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.80.5\";\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 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) {\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 const found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n found.addFile(f);\n }\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.dependencies[f.getFilename().toUpperCase()] = true;\n }\n return this.addFiles(files);\n }\n addDependency(file) {\n this.dependencies[file.getFilename().toUpperCase()] = true;\n this.addFile(file);\n return this;\n }\n isDependency(obj) {\n const filename = obj.getFiles()[0].getFilename().toUpperCase();\n return this.dependencies[filename] === true;\n }\n isFileDependency(filename) {\n return this.dependencies[filename.toUpperCase()] === 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 this.runRules(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 this.runRules(undefined, 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 this.issues = [];\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n this.issues.push(...o.getParsingIssues());\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 this.issues = [];\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 this.issues.push(...o.getParsingIssues());\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);\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 runRules(input, iobj) {\n var _a, _b, _c, _d, _e, _f;\n const rulePerformance = {};\n const issues = this.issues.slice(0);\n const objects = iobj ? [iobj] : this.getObjects();\n const rules = this.conf.getEnabledRules();\n const skipLogic = new skip_logic_1.SkipLogic(this);\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(iobj ? 1 : this.getObjectCount(false), \"Run Syntax\");\n const check = [];\n for (const obj of objects) {\n (_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Run Syntax - \" + obj.getName());\n if (skipLogic.skip(obj) || this.isDependency(obj)) {\n continue;\n }\n if (obj instanceof _abap_object_1.ABAPObject) {\n new syntax_1.SyntaxLogic(this, obj).run();\n }\n check.push(obj);\n }\n (_c = input === null || input === void 0 ? void 0 : input.progress) === null || _c === void 0 ? void 0 : _c.set(rules.length, \"Initialize Rules\");\n for (const rule of rules) {\n (_d = input === null || input === void 0 ? void 0 : input.progress) === null || _d === void 0 ? void 0 : _d.tick(\"Initialize Rules - \" + rule.getMetadata().key);\n if (rule.initialize === undefined) {\n throw new Error(rule.getMetadata().key + \" missing initialize method\");\n }\n rule.initialize(this);\n rulePerformance[rule.getMetadata().key] = 0;\n }\n (_e = input === null || input === void 0 ? void 0 : input.progress) === null || _e === void 0 ? void 0 : _e.set(check.length, \"Finding Issues\");\n for (const obj of check) {\n (_f = input === null || input === void 0 ? void 0 : input.progress) === null || _f === void 0 ? void 0 : _f.tick(\"Finding Issues - \" + obj.getType() + \" \" + obj.getName());\n for (const rule of rules) {\n const before = Date.now();\n issues.push(...rule.run(obj));\n const runtime = Date.now() - before;\n rulePerformance[rule.getMetadata().key] = rulePerformance[rule.getMetadata().key] + runtime;\n }\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n const perf = [];\n for (const p in rulePerformance) {\n if (rulePerformance[p] > 100) { // ignore rules if it takes less than 100ms\n perf.push({ name: p, time: rulePerformance[p] });\n }\n }\n perf.sort((a, b) => { return b.time - a.time; });\n for (const p of perf) {\n process.stderr.write(\"\\t\" + p.time + \"ms\\t\" + p.name + \"\\n\");\n }\n }\n return this.excludeIssues(issues);\n }\n excludeIssues(issues) {\n var _a;\n const ret = issues;\n // exclude issues, as now we know both the filename and issue key\n for (const rule of artifacts_rules_1.ArtifactsRules.getRules()) {\n const key = rule.getMetadata().key;\n const ruleExclude = ((_a = this.conf.readByKey(key, \"exclude\")) !== null && _a !== void 0 ? _a : []);\n const ruleExcludePatterns = ruleExclude.map(x => new RegExp(x, \"i\"));\n for (let i = ret.length - 1; i >= 0; i--) {\n if (ret[i].getKey() !== key) {\n continue;\n }\n const filename = ret[i].getFilename();\n if (excludeHelper_1.ExcludeHelper.isExcluded(filename, ruleExcludePatterns)) {\n ret.splice(i, 1);\n }\n }\n }\n return ret;\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?");
|
|
10678
|
+
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 artifacts_rules_1 = __webpack_require__(/*! ./artifacts_rules */ \"./node_modules/@abaplint/core/build/src/artifacts_rules.js\");\nconst skip_logic_1 = __webpack_require__(/*! ./skip_logic */ \"./node_modules/@abaplint/core/build/src/skip_logic.js\");\nconst _abap_object_1 = __webpack_require__(/*! ./objects/_abap_object */ \"./node_modules/@abaplint/core/build/src/objects/_abap_object.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 syntax_1 = __webpack_require__(/*! ./abap/5_syntax/syntax */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.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\");\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 /** object containing filenames of dependencies */\n this.dependencies = {};\n this.issues = [];\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.80.6\";\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 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) {\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 const found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n found.addFile(f);\n }\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.dependencies[f.getFilename().toUpperCase()] = true;\n }\n return this.addFiles(files);\n }\n addDependency(file) {\n this.dependencies[file.getFilename().toUpperCase()] = true;\n this.addFile(file);\n return this;\n }\n isDependency(obj) {\n const filename = obj.getFiles()[0].getFilename().toUpperCase();\n return this.dependencies[filename] === true;\n }\n isFileDependency(filename) {\n return this.dependencies[filename.toUpperCase()] === 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 this.runRules(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 this.runRules(undefined, 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 this.issues = [];\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n this.issues.push(...o.getParsingIssues());\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 this.issues = [];\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 this.issues.push(...o.getParsingIssues());\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);\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 runRules(input, iobj) {\n var _a, _b, _c, _d, _e, _f;\n const rulePerformance = {};\n const issues = this.issues.slice(0);\n const objects = iobj ? [iobj] : this.getObjects();\n const rules = this.conf.getEnabledRules();\n const skipLogic = new skip_logic_1.SkipLogic(this);\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(iobj ? 1 : this.getObjectCount(false), \"Run Syntax\");\n const check = [];\n for (const obj of objects) {\n (_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Run Syntax - \" + obj.getName());\n if (skipLogic.skip(obj) || this.isDependency(obj)) {\n continue;\n }\n if (obj instanceof _abap_object_1.ABAPObject) {\n new syntax_1.SyntaxLogic(this, obj).run();\n }\n check.push(obj);\n }\n (_c = input === null || input === void 0 ? void 0 : input.progress) === null || _c === void 0 ? void 0 : _c.set(rules.length, \"Initialize Rules\");\n for (const rule of rules) {\n (_d = input === null || input === void 0 ? void 0 : input.progress) === null || _d === void 0 ? void 0 : _d.tick(\"Initialize Rules - \" + rule.getMetadata().key);\n if (rule.initialize === undefined) {\n throw new Error(rule.getMetadata().key + \" missing initialize method\");\n }\n rule.initialize(this);\n rulePerformance[rule.getMetadata().key] = 0;\n }\n (_e = input === null || input === void 0 ? void 0 : input.progress) === null || _e === void 0 ? void 0 : _e.set(check.length, \"Finding Issues\");\n for (const obj of check) {\n (_f = input === null || input === void 0 ? void 0 : input.progress) === null || _f === void 0 ? void 0 : _f.tick(\"Finding Issues - \" + obj.getType() + \" \" + obj.getName());\n for (const rule of rules) {\n const before = Date.now();\n issues.push(...rule.run(obj));\n const runtime = Date.now() - before;\n rulePerformance[rule.getMetadata().key] = rulePerformance[rule.getMetadata().key] + runtime;\n }\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n const perf = [];\n for (const p in rulePerformance) {\n if (rulePerformance[p] > 100) { // ignore rules if it takes less than 100ms\n perf.push({ name: p, time: rulePerformance[p] });\n }\n }\n perf.sort((a, b) => { return b.time - a.time; });\n for (const p of perf) {\n process.stderr.write(\"\\t\" + p.time + \"ms\\t\" + p.name + \"\\n\");\n }\n }\n return this.excludeIssues(issues);\n }\n excludeIssues(issues) {\n var _a;\n const ret = issues;\n // exclude issues, as now we know both the filename and issue key\n for (const rule of artifacts_rules_1.ArtifactsRules.getRules()) {\n const key = rule.getMetadata().key;\n const ruleExclude = ((_a = this.conf.readByKey(key, \"exclude\")) !== null && _a !== void 0 ? _a : []);\n const ruleExcludePatterns = ruleExclude.map(x => new RegExp(x, \"i\"));\n for (let i = ret.length - 1; i >= 0; i--) {\n if (ret[i].getKey() !== key) {\n continue;\n }\n const filename = ret[i].getFilename();\n if (excludeHelper_1.ExcludeHelper.isExcluded(filename, ruleExcludePatterns)) {\n ret.splice(i, 1);\n }\n }\n }\n return ret;\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?");
|
|
10679
10679
|
|
|
10680
10680
|
/***/ }),
|
|
10681
10681
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.80.
|
|
3
|
+
"version": "2.80.6",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"abaplint": "./abaplint"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://abaplint.org",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@abaplint/core": "^2.80.
|
|
41
|
+
"@abaplint/core": "^2.80.6",
|
|
42
42
|
"@types/chai": "^4.2.22",
|
|
43
43
|
"@types/glob": "^7.2.0",
|
|
44
44
|
"@types/minimist": "^1.2.2",
|