@abaplint/core 2.113.205 → 2.113.206

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.
@@ -4239,7 +4239,6 @@ export declare class LanguageServer {
4239
4239
  listDefinitionPositions(textDocument: LServer.TextDocumentIdentifier): LServer.Range[];
4240
4240
  listReadPositions(textDocument: LServer.TextDocumentIdentifier): LServer.Range[];
4241
4241
  listWritePositions(textDocument: LServer.TextDocumentIdentifier): LServer.Range[];
4242
- dumpStatementFlows(textDocument: LServer.TextDocumentIdentifier): string;
4243
4242
  }
4244
4243
 
4245
4244
  declare namespace LanguageServerTypes {
@@ -19,7 +19,7 @@ class TypeTable extends combi_1.Expression {
19
19
  // "WITH" is not allowed as a field name in keys
20
20
  const typetable = (0, combi_1.alt)(generic, (0, combi_1.seq)(normal1, (0, combi_1.alt)((0, combi_1.opt)((0, combi_1.per)(header, initial, (0, combi_1.plusPrio)(type_table_key_1.TypeTableKey))), (0, combi_1.seq)((0, combi_1.plus)(type_table_key_1.TypeTableKey), (0, combi_1.optPrio)(initial))), (0, combi_1.optPrio)("VALUE IS INITIAL")));
21
21
  const occurs = (0, combi_1.seq)("OCCURS", (0, combi_1.altPrio)(_1.Integer, field_chain_1.FieldChain));
22
- const derived = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("TABLE FOR", (0, combi_1.altPrio)("ACTION IMPORT", "ACTION RESULT", "CREATE", "EVENT", "REPORTED EARLY", "FAILED EARLY", "FAILED", "LOCK", "DETERMINATION", "READ RESULT", "UPDATE", "DELETE"), (0, combi_1.alt)(_1.TypeName, _1.EntityAssociation)));
22
+ const derived = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("TABLE FOR", (0, combi_1.altPrio)("ACTION IMPORT", "ACTION RESULT", "CREATE", "EVENT", "REPORTED EARLY", "READ IMPORT", "FAILED EARLY", "FAILED", "LOCK", "DETERMINATION", "READ RESULT", "UPDATE", "DELETE"), (0, combi_1.alt)(_1.TypeName, _1.EntityAssociation)));
23
23
  const oldType = (0, combi_1.seq)((0, combi_1.opt)("REF TO"), _1.TypeName, (0, combi_1.alt)((0, combi_1.seq)(occurs, (0, combi_1.opt)(header)), header));
24
24
  const oldLike = (0, combi_1.seq)((0, combi_1.opt)("REF TO"), field_chain_1.FieldChain, (0, combi_1.alt)((0, combi_1.seq)(occurs, (0, combi_1.opt)(header)), header));
25
25
  const typeLine = (0, combi_1.seq)("LINE OF", _1.TypeName, occurs, header);
@@ -17,9 +17,9 @@ class MethodDef {
17
17
  const forfunction = (0, combi_1.seq)("FOR FUNCTION", expressions_1.TypeName, result);
18
18
  const behavior = (0, combi_1.altPrio)("DDL OBJECT OPTIONS CDS SESSION CLIENT REQUIRED", // todo, this is only from version something
19
19
  (0, combi_1.seq)("TABLE FUNCTION", expressions_1.NamespaceSimpleName), // todo, this is only from version something
20
- (0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY IMPORTING", (0, combi_1.plus)((0, combi_1.seq)(expressions_1.MethodParamName, modify))), (0, combi_1.seq)("PRECHECK IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("DETERMINATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("VALIDATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("NUMBERING IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, (0, combi_1.altPrio)(forRead, forfunction)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("GLOBAL AUTHORIZATION IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("GLOBAL FEATURES IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.seq)((0, combi_1.opt)("INSTANCE"), "AUTHORIZATION IMPORTING"), expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("INSTANCE FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result));
20
+ (0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY IMPORTING", (0, combi_1.plus)((0, combi_1.seq)(expressions_1.MethodParamName, modify))), (0, combi_1.seq)("PRECHECK IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("DETERMINATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("VALIDATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("NUMBERING IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, (0, combi_1.altPrio)(forRead, forfunction)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("GLOBAL AUTHORIZATION IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("GLOBAL FEATURES IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.seq)((0, combi_1.opt)("INSTANCE"), "AUTHORIZATION IMPORTING"), expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("INSTANCE FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result));
21
21
  // todo, this is only from version something
22
- const amdp = (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.optPrio)("READ-ONLY"), "CDS SESSION CLIENT CURRENT", (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising));
22
+ const amdp = (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.optPrio)("READ-ONLY"), "CDS SESSION CLIENT", (0, combi_1.alt)("CURRENT", "DEPENDENT"), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising));
23
23
  const ret = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), (0, combi_1.optPrio)(def), expressions_1.EventHandler), parameters, testing, (0, combi_1.seq)("FOR", behavior), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
24
24
  return ret;
25
25
  }
@@ -12,14 +12,16 @@ class ModifyEntities {
12
12
  const relating = (0, combi_1.seq)("RELATING TO", expressions_1.NamespaceSimpleName, "BY", expressions_1.NamespaceSimpleName);
13
13
  const execute = (0, combi_1.seq)("EXECUTE", expressions_1.NamespaceSimpleName, "FROM", expressions_1.Source);
14
14
  const create = (0, combi_1.seq)("CREATE", (0, combi_1.opt)(by), "FROM", expressions_1.Source, (0, combi_1.opt)(relating));
15
- const operation = (0, combi_1.alt)((0, combi_1.seq)("UPDATE SET FIELDS WITH", expressions_1.Source), (0, combi_1.seq)("CREATE SET FIELDS WITH", expressions_1.Source), (0, combi_1.seq)("UPDATE", fieldsWith), (0, combi_1.seq)("DELETE FROM", expressions_1.Source), (0, combi_1.seq)("UPDATE FROM", expressions_1.Source, (0, combi_1.opt)(relating)), create, execute, (0, combi_1.seq)("CREATE", (0, combi_1.opt)(by), (0, combi_1.optPrio)("AUTO FILL CID"), (0, combi_1.altPrio)(withh, fieldsWith)));
15
+ const updateFrom = (0, combi_1.seq)("UPDATE FROM", expressions_1.Source, (0, combi_1.opt)(relating));
16
+ const deleteFrom = (0, combi_1.seq)("DELETE FROM", expressions_1.Source);
17
+ const operation = (0, combi_1.alt)((0, combi_1.seq)("UPDATE SET FIELDS WITH", expressions_1.Source), (0, combi_1.seq)("CREATE SET FIELDS WITH", expressions_1.Source), (0, combi_1.seq)("UPDATE", fieldsWith), deleteFrom, updateFrom, create, execute, (0, combi_1.seq)("CREATE", (0, combi_1.opt)(by), (0, combi_1.optPrio)("AUTO FILL CID"), (0, combi_1.altPrio)(withh, fieldsWith)));
16
18
  const failed = (0, combi_1.seq)("FAILED", expressions_1.Target);
17
19
  const result = (0, combi_1.seq)("RESULT", expressions_1.Target);
18
20
  const mapped = (0, combi_1.seq)("MAPPED", expressions_1.Target);
19
21
  const reported = (0, combi_1.seq)("REPORTED", expressions_1.Target);
20
22
  const end = (0, combi_1.optPrio)((0, combi_1.per)(failed, result, mapped, reported));
21
23
  const entities = (0, combi_1.seq)((0, combi_1.optPrio)("AUGMENTING"), "ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.plusPrio)((0, combi_1.seq)("ENTITY", expressions_1.SimpleName, (0, combi_1.plus)(operation))));
22
- const entity = (0, combi_1.seq)("ENTITY", (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.alt)(expressions_1.NamespaceSimpleName, expressions_1.EntityAssociation), (0, combi_1.alt)(execute, create));
24
+ const entity = (0, combi_1.seq)("ENTITY", (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.alt)(expressions_1.NamespaceSimpleName, expressions_1.EntityAssociation), (0, combi_1.alt)(execute, create, deleteFrom, updateFrom));
23
25
  return (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("MODIFY", (0, combi_1.alt)(entities, entity), end));
24
26
  }
25
27
  }
@@ -11,9 +11,10 @@ class ReadEntities {
11
11
  const fields = (0, combi_1.seq)("FIELDS", (0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(expressions_1.SimpleName), (0, combi_1.tok)(tokens_1.WParenRightW), "WITH", expressions_1.Source);
12
12
  const all = (0, combi_1.seq)("ALL FIELDS WITH", expressions_1.Source);
13
13
  const result = (0, combi_1.seq)("RESULT", expressions_1.Target);
14
+ const failed = (0, combi_1.seq)("FAILED", expressions_1.Target);
14
15
  const entity = (0, combi_1.seq)("ENTITY", expressions_1.NamespaceSimpleName, (0, combi_1.opt)((0, combi_1.seq)("BY", expressions_1.AssociationName)), (0, combi_1.alt)(fields, from, all), (0, combi_1.optPrio)(result));
15
- const s = (0, combi_1.seq)("ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.plus)(entity), (0, combi_1.optPrio)((0, combi_1.seq)("LINK", expressions_1.Target)), (0, combi_1.optPrio)((0, combi_1.seq)("FAILED", expressions_1.Target)), (0, combi_1.optPrio)((0, combi_1.seq)("REPORTED", expressions_1.Target)));
16
- const single = (0, combi_1.seq)("ENTITY", (0, combi_1.alt)(expressions_1.NamespaceSimpleName, expressions_1.EntityAssociation), from, result);
16
+ const s = (0, combi_1.seq)("ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.plus)(entity), (0, combi_1.optPrio)((0, combi_1.seq)("LINK", expressions_1.Target)), (0, combi_1.optPrio)(failed), (0, combi_1.optPrio)((0, combi_1.seq)("REPORTED", expressions_1.Target)));
17
+ const single = (0, combi_1.seq)("ENTITY", (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.alt)(expressions_1.NamespaceSimpleName, expressions_1.EntityAssociation), (0, combi_1.alt)(all, fields, from), result, (0, combi_1.optPrio)(failed));
17
18
  return (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("READ", (0, combi_1.alt)(s, single)));
18
19
  }
19
20
  }
@@ -15,7 +15,6 @@ const code_actions_1 = require("./code_actions");
15
15
  const references_1 = require("./references");
16
16
  const implementation_1 = require("./implementation");
17
17
  const semantic_1 = require("./semantic");
18
- const statement_flow_1 = require("../abap/flow/statement_flow");
19
18
  const code_lens_1 = require("./code_lens");
20
19
  const inlay_hints_1 = require("./inlay_hints");
21
20
  // note Ranges are zero based in LSP,
@@ -127,23 +126,6 @@ class LanguageServer {
127
126
  listWritePositions(textDocument) {
128
127
  return new highlight_1.Highlight(this.reg).listWritePositions(textDocument);
129
128
  }
130
- dumpStatementFlows(textDocument) {
131
- const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri);
132
- if (file === undefined) {
133
- return "file not found";
134
- }
135
- const obj = this.reg.findObjectForFile(file);
136
- if (obj === undefined) {
137
- return "obj not found";
138
- }
139
- const stru = file.getStructure();
140
- if (stru === undefined) {
141
- return "empty structure";
142
- }
143
- const graphs = new statement_flow_1.StatementFlow().build(stru, obj);
144
- const wiz = graphs.map(g => g.toDigraph());
145
- return JSON.stringify(wiz);
146
- }
147
129
  }
148
130
  exports.LanguageServer = LanguageServer;
149
131
  //# sourceMappingURL=language_server.js.map
@@ -67,7 +67,7 @@ class Registry {
67
67
  }
68
68
  static abaplintVersion() {
69
69
  // magic, see build script "version.sh"
70
- return "2.113.205";
70
+ return "2.113.206";
71
71
  }
72
72
  getDDICReferences() {
73
73
  return this.ddicReferences;
@@ -7,7 +7,7 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
7
7
  const Structures = require("../abap/3_structures/structures");
8
8
  const _irule_1 = require("./_irule");
9
9
  const objects_1 = require("../objects");
10
- const selection_events_1 = require("../abap/flow/selection_events");
10
+ const stuff_1 = require("../stuff");
11
11
  class EmptyEventConf extends _basic_rule_config_1.BasicRuleConfig {
12
12
  }
13
13
  exports.EmptyEventConf = EmptyEventConf;
@@ -51,7 +51,7 @@ START-OF-SELECTION.
51
51
  let currentEvent = undefined;
52
52
  let children = [];
53
53
  for (const s of stru.getChildren() || []) {
54
- if (selection_events_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
54
+ if (stuff_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
55
55
  if (currentEvent !== undefined && children.length === 0) {
56
56
  issues.push(issue_1.Issue.atStatement(file, currentEvent, "Empty event", this.getMetadata().key, this.getConfig().severity));
57
57
  }
@@ -61,7 +61,7 @@ START-OF-SELECTION.
61
61
  else if (s.get() instanceof Structures.Normal) {
62
62
  const stru = s;
63
63
  // ignore declaration stuff
64
- if (selection_events_1.DECLARATION_STUFF.some(d => { var _a; return ((_a = stru.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.get()) instanceof d; })) {
64
+ if (stuff_1.DECLARATION_STUFF.some(d => { var _a; return ((_a = stru.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.get()) instanceof d; })) {
65
65
  continue;
66
66
  }
67
67
  children.push(s);
@@ -8,7 +8,7 @@ const Structures = require("../abap/3_structures/structures");
8
8
  const _irule_1 = require("./_irule");
9
9
  const objects_1 = require("../objects");
10
10
  const nodes_1 = require("../abap/nodes");
11
- const selection_events_1 = require("../abap/flow/selection_events");
11
+ const stuff_1 = require("../stuff");
12
12
  class ImplicitStartOfSelectionConf extends _basic_rule_config_1.BasicRuleConfig {
13
13
  }
14
14
  exports.ImplicitStartOfSelectionConf = ImplicitStartOfSelectionConf;
@@ -51,7 +51,7 @@ START-OF-SELECTION.
51
51
  let inEvent = false;
52
52
  let collected = [];
53
53
  for (const s of stru.getChildren() || []) {
54
- if (selection_events_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
54
+ if (stuff_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
55
55
  if (inEvent === false && collected.length > 0) {
56
56
  // implicit START-OF-SELECTION
57
57
  let first = collected[0];
@@ -66,7 +66,7 @@ START-OF-SELECTION.
66
66
  else if (s.get() instanceof Structures.Normal) {
67
67
  const stru = s;
68
68
  // ignore declaration stuff
69
- if (selection_events_1.DECLARATION_STUFF.some(d => { var _a; return ((_a = stru.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.get()) instanceof d; })) {
69
+ if (stuff_1.DECLARATION_STUFF.some(d => { var _a; return ((_a = stru.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.get()) instanceof d; })) {
70
70
  continue;
71
71
  }
72
72
  collected.push(s);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DECLARATION_STUFF = exports.SELECTION_EVENTS = void 0;
4
- const Statements = require("../2_statements/statements");
4
+ const Statements = require("./abap/2_statements/statements");
5
5
  exports.SELECTION_EVENTS = [
6
6
  Statements.StartOfSelection,
7
7
  Statements.AtSelectionScreen,
@@ -29,4 +29,4 @@ exports.DECLARATION_STUFF = [
29
29
  Statements.SelectionScreen,
30
30
  Statements.Define,
31
31
  ];
32
- //# sourceMappingURL=selection_events.js.map
32
+ //# sourceMappingURL=stuff.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.113.205",
3
+ "version": "2.113.206",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -1,154 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowGraph = exports.FLOW_EDGE_TYPE = void 0;
4
- var FLOW_EDGE_TYPE;
5
- (function (FLOW_EDGE_TYPE) {
6
- FLOW_EDGE_TYPE["true"] = "true";
7
- FLOW_EDGE_TYPE["false"] = "false";
8
- FLOW_EDGE_TYPE["undefined"] = "undefined";
9
- })(FLOW_EDGE_TYPE || (exports.FLOW_EDGE_TYPE = FLOW_EDGE_TYPE = {}));
10
- class FlowGraph {
11
- constructor(counter) {
12
- this.edges = {};
13
- this.label = "undefined";
14
- this.startNode = "start#" + counter;
15
- this.endNode = "end#" + counter;
16
- }
17
- getStart() {
18
- return this.startNode;
19
- }
20
- getLabel() {
21
- return this.label;
22
- }
23
- getEnd() {
24
- return this.endNode;
25
- }
26
- addEdge(from, to, type) {
27
- if (this.edges[from] === undefined) {
28
- this.edges[from] = {};
29
- }
30
- this.edges[from][to] = type;
31
- }
32
- removeEdge(from, to) {
33
- if (this.edges[from] === undefined) {
34
- return;
35
- }
36
- delete this.edges[from][to];
37
- if (Object.keys(this.edges[from]).length === 0) {
38
- delete this.edges[from];
39
- }
40
- }
41
- listEdges() {
42
- const list = [];
43
- for (const from of Object.keys(this.edges)) {
44
- for (const to of Object.keys(this.edges[from])) {
45
- list.push({ from, to, type: this.edges[from][to] });
46
- }
47
- }
48
- return list;
49
- }
50
- listNodes() {
51
- const set = new Set();
52
- for (const l of this.listEdges()) {
53
- set.add(l.from);
54
- set.add(l.to);
55
- }
56
- return Array.from(set.values());
57
- }
58
- hasEdges() {
59
- return Object.keys(this.edges).length > 0;
60
- }
61
- /** return value: end node of to graph */
62
- addGraph(from, to, type) {
63
- if (to.hasEdges() === false) {
64
- return from;
65
- }
66
- this.addEdge(from, to.getStart(), type);
67
- to.listEdges().forEach(e => this.addEdge(e.from, e.to, e.type));
68
- return to.getEnd();
69
- }
70
- toJSON() {
71
- return JSON.stringify(this.edges);
72
- }
73
- toTextEdges() {
74
- let graph = "";
75
- for (const l of this.listEdges()) {
76
- const label = l.type === FLOW_EDGE_TYPE.undefined ? "" : ` [label="${l.type}"]`;
77
- graph += `"${l.from}" -> "${l.to}"${label};\n`;
78
- }
79
- return graph.trim();
80
- }
81
- setLabel(label) {
82
- this.label = label;
83
- }
84
- toDigraph() {
85
- return `digraph G {
86
- labelloc="t";
87
- label="${this.label}";
88
- graph [fontname = "helvetica"];
89
- node [fontname = "helvetica", shape="box"];
90
- edge [fontname = "helvetica"];
91
- ${this.toTextEdges()}
92
- }`;
93
- }
94
- listSources(node) {
95
- const set = [];
96
- for (const l of this.listEdges()) {
97
- if (node === l.to) {
98
- set.push({ name: l.from, type: l.type });
99
- }
100
- }
101
- return set;
102
- }
103
- listTargets(node) {
104
- const set = [];
105
- for (const l of this.listEdges()) {
106
- if (node === l.from) {
107
- set.push({ name: l.to, type: l.type });
108
- }
109
- }
110
- return set;
111
- }
112
- /** removes all nodes containing "#" that have one in-going and one out-going edge */
113
- reduce() {
114
- for (const node of this.listNodes()) {
115
- if (node.includes("#") === false) {
116
- continue;
117
- }
118
- const sources = this.listSources(node);
119
- const targets = this.listTargets(node);
120
- if (sources.length > 0 && targets.length > 0) {
121
- // hash node in the middle of the graph
122
- for (const s of sources) {
123
- this.removeEdge(s.name, node);
124
- }
125
- for (const t of targets) {
126
- this.removeEdge(node, t.name);
127
- }
128
- for (const s of sources) {
129
- for (const t of targets) {
130
- let type = FLOW_EDGE_TYPE.undefined;
131
- if (s.type !== FLOW_EDGE_TYPE.undefined) {
132
- type = s.type;
133
- }
134
- if (t.type !== FLOW_EDGE_TYPE.undefined) {
135
- if (type !== FLOW_EDGE_TYPE.undefined) {
136
- throw new Error("reduce: cannot merge, different edge types");
137
- }
138
- type = t.type;
139
- }
140
- this.addEdge(s.name, t.name, type);
141
- }
142
- }
143
- }
144
- if (node.startsWith("end#") && sources.length === 0) {
145
- for (const t of targets) {
146
- this.removeEdge(node, t.name);
147
- }
148
- }
149
- }
150
- return this;
151
- }
152
- }
153
- exports.FlowGraph = FlowGraph;
154
- //# sourceMappingURL=flow_graph.js.map
@@ -1,342 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatementFlow = void 0;
4
- const nodes_1 = require("../nodes");
5
- const Structures = require("../3_structures/structures");
6
- const Statements = require("../2_statements/statements");
7
- const Expressions = require("../2_statements/expressions");
8
- const flow_graph_1 = require("./flow_graph");
9
- const objects_1 = require("../../objects");
10
- const selection_events_1 = require("./selection_events");
11
- const virtual_position_1 = require("../../virtual_position");
12
- class StatementFlow {
13
- constructor() {
14
- this.counter = 0;
15
- }
16
- build(stru, obj) {
17
- var _a, _b, _c, _d;
18
- const ret = [];
19
- let name = "";
20
- const structures = stru.findAllStructuresMulti([
21
- Structures.Form, Structures.ClassImplementation, Structures.FunctionModule, Structures.Module
22
- ]);
23
- for (const s of structures) {
24
- if (s.get() instanceof Structures.Form) {
25
- name = "FORM " + ((_a = s.findFirstExpression(Expressions.FormName)) === null || _a === void 0 ? void 0 : _a.concatTokens());
26
- ret.push(this.run(s, name));
27
- }
28
- else if (s.get() instanceof Structures.ClassImplementation) {
29
- const className = (_b = s.findFirstExpression(Expressions.ClassName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
30
- for (const method of s.findDirectStructures(Structures.Method)) {
31
- const methodName = (_c = method.findFirstExpression(Expressions.MethodName)) === null || _c === void 0 ? void 0 : _c.concatTokens();
32
- name = "METHOD " + methodName + ", CLASS " + className;
33
- ret.push(this.run(method, name));
34
- }
35
- }
36
- else if (s.get() instanceof Structures.FunctionModule) {
37
- name = "FUNCTION " + ((_d = s.findFirstExpression(Expressions.Field)) === null || _d === void 0 ? void 0 : _d.concatTokens());
38
- ret.push(this.run(s, name));
39
- }
40
- else if (s.get() instanceof Structures.Module) {
41
- name = s.getFirstStatement().concatTokens().toUpperCase();
42
- ret.push(this.run(s, name));
43
- }
44
- else {
45
- throw new Error("StatementFlow, unknown structure");
46
- }
47
- }
48
- if (obj instanceof objects_1.Program || obj instanceof objects_1.FunctionGroup) {
49
- // find the top level events
50
- let inEvent = false;
51
- let collected = [];
52
- for (const s of stru.getChildren() || []) {
53
- if (selection_events_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
54
- if (inEvent === true) {
55
- ret.push(this.runEvent(collected, name));
56
- }
57
- collected = [];
58
- inEvent = true;
59
- name = s.concatTokens();
60
- }
61
- else if (s.get() instanceof Structures.Normal) {
62
- collected.push(s);
63
- }
64
- else {
65
- if (inEvent === true) {
66
- ret.push(this.runEvent(collected, name));
67
- inEvent = false;
68
- }
69
- collected = [];
70
- }
71
- }
72
- if (inEvent === true) {
73
- ret.push(this.runEvent(collected, name));
74
- }
75
- else if (collected.length > 0
76
- && !(obj instanceof objects_1.FunctionGroup)) {
77
- // implicit START-OF-SELECTION
78
- ret.push(this.runEvent(collected, "START-OF-SELECTION."));
79
- }
80
- }
81
- return ret.map(f => f.reduce());
82
- }
83
- ////////////////////
84
- runEvent(s, name) {
85
- this.counter = 1;
86
- const graph = this.traverseBody(s, { procedureEnd: "end#1" });
87
- graph.setLabel(name);
88
- return graph;
89
- }
90
- run(s, name) {
91
- this.counter = 1;
92
- const graph = this.traverseBody(this.findBody(s), { procedureEnd: "end#1" });
93
- graph.setLabel(name);
94
- return graph;
95
- }
96
- findBody(f) {
97
- var _a;
98
- return ((_a = f.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || [];
99
- }
100
- // note: it must handle macros and chained statements
101
- static buildName(statement) {
102
- let token = undefined;
103
- const colon = statement.getColon();
104
- if (colon === undefined) {
105
- token = statement.getFirstToken();
106
- }
107
- else {
108
- for (const t of statement.getTokens()) {
109
- if (t.getStart().isAfter(colon.getEnd())) {
110
- token = t;
111
- break;
112
- }
113
- }
114
- }
115
- let extra = "";
116
- const tStart = token === null || token === void 0 ? void 0 : token.getStart();
117
- if (tStart instanceof virtual_position_1.VirtualPosition) {
118
- extra += "$" + tStart.vrow;
119
- extra += "," + tStart.vcol;
120
- }
121
- if (token === undefined) {
122
- return "tokenError";
123
- }
124
- return statement.get().constructor.name +
125
- ":" + token.getRow() +
126
- "," + token.getCol() + extra;
127
- }
128
- traverseBody(children, context) {
129
- const graph = new flow_graph_1.FlowGraph(this.counter++);
130
- if (children.length === 0) {
131
- graph.addEdge(graph.getStart(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
132
- return graph;
133
- }
134
- let current = graph.getStart();
135
- for (const c of children) {
136
- if (c.get() instanceof Structures.Normal) {
137
- const firstChild = c.getFirstChild(); // "Normal" only has one child
138
- if (firstChild instanceof nodes_1.StatementNode) {
139
- const name = StatementFlow.buildName(firstChild);
140
- graph.addEdge(current, name, flow_graph_1.FLOW_EDGE_TYPE.undefined);
141
- current = name;
142
- if (firstChild.get() instanceof Statements.Check) {
143
- if (context.loopStart) {
144
- graph.addEdge(name, context.loopStart, flow_graph_1.FLOW_EDGE_TYPE.false);
145
- }
146
- else {
147
- graph.addEdge(name, context.procedureEnd, flow_graph_1.FLOW_EDGE_TYPE.false);
148
- }
149
- }
150
- else if (firstChild.get() instanceof Statements.Assert) {
151
- graph.addEdge(name, context.procedureEnd, flow_graph_1.FLOW_EDGE_TYPE.false);
152
- }
153
- else if (firstChild.get() instanceof Statements.Continue && context.loopStart) {
154
- graph.addEdge(name, context.loopStart, flow_graph_1.FLOW_EDGE_TYPE.undefined);
155
- return graph;
156
- }
157
- else if (firstChild.get() instanceof Statements.Exit) {
158
- if (context.loopEnd) {
159
- graph.addEdge(name, context.loopEnd, flow_graph_1.FLOW_EDGE_TYPE.undefined);
160
- }
161
- else {
162
- graph.addEdge(name, context.procedureEnd, flow_graph_1.FLOW_EDGE_TYPE.undefined);
163
- }
164
- return graph;
165
- }
166
- else if (firstChild.get() instanceof Statements.Return) {
167
- graph.addEdge(name, context.procedureEnd, flow_graph_1.FLOW_EDGE_TYPE.undefined);
168
- return graph;
169
- }
170
- }
171
- else if (firstChild instanceof nodes_1.StructureNode) {
172
- const sub = this.traverseStructure(firstChild, context);
173
- current = graph.addGraph(current, sub, flow_graph_1.FLOW_EDGE_TYPE.undefined);
174
- }
175
- }
176
- }
177
- graph.addEdge(current, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
178
- return graph;
179
- }
180
- traverseStructure(n, context) {
181
- const graph = new flow_graph_1.FlowGraph(this.counter++);
182
- if (n === undefined) {
183
- return graph;
184
- }
185
- let current = graph.getStart();
186
- const type = n.get();
187
- if (type instanceof Structures.If) {
188
- const ifName = StatementFlow.buildName(n.findDirectStatement(Statements.If));
189
- const sub = this.traverseBody(this.findBody(n), context);
190
- graph.addEdge(current, ifName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
191
- graph.addGraph(ifName, sub, flow_graph_1.FLOW_EDGE_TYPE.true);
192
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
193
- current = ifName;
194
- for (const e of n.findDirectStructures(Structures.ElseIf)) {
195
- const elseifst = e.findDirectStatement(Statements.ElseIf);
196
- if (elseifst === undefined) {
197
- continue;
198
- }
199
- const elseIfName = StatementFlow.buildName(elseifst);
200
- const sub = this.traverseBody(this.findBody(e), context);
201
- graph.addEdge(current, elseIfName, flow_graph_1.FLOW_EDGE_TYPE.false);
202
- graph.addGraph(elseIfName, sub, flow_graph_1.FLOW_EDGE_TYPE.true);
203
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
204
- current = elseIfName;
205
- }
206
- const els = n.findDirectStructure(Structures.Else);
207
- const elsest = els === null || els === void 0 ? void 0 : els.findDirectStatement(Statements.Else);
208
- if (els && elsest) {
209
- const elseName = StatementFlow.buildName(elsest);
210
- const sub = this.traverseBody(this.findBody(els), context);
211
- graph.addEdge(current, elseName, flow_graph_1.FLOW_EDGE_TYPE.false);
212
- graph.addGraph(elseName, sub, flow_graph_1.FLOW_EDGE_TYPE.undefined);
213
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
214
- }
215
- else {
216
- graph.addEdge(ifName, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.false);
217
- }
218
- }
219
- else if (type instanceof Structures.Loop
220
- || type instanceof Structures.While
221
- || type instanceof Structures.With
222
- || type instanceof Structures.Provide
223
- || type instanceof Structures.Select
224
- || type instanceof Structures.EnhancementSection
225
- || type instanceof Structures.LoopAtScreen
226
- || type instanceof Structures.Do) {
227
- const loopName = StatementFlow.buildName(n.getFirstStatement());
228
- const sub = this.traverseBody(this.findBody(n), Object.assign(Object.assign({}, context), { loopStart: loopName, loopEnd: graph.getEnd() }));
229
- graph.addEdge(current, loopName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
230
- graph.addGraph(loopName, sub, flow_graph_1.FLOW_EDGE_TYPE.true);
231
- graph.addEdge(sub.getEnd(), loopName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
232
- graph.addEdge(loopName, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.false);
233
- }
234
- else if (type instanceof Structures.Data
235
- || type instanceof Structures.Constants
236
- || type instanceof Structures.Statics
237
- || type instanceof Structures.ExecSQL
238
- || type instanceof Structures.Types) {
239
- // these doesnt affect control flow, so just take the first statement
240
- const statement = n.getFirstStatement();
241
- const name = StatementFlow.buildName(statement);
242
- graph.addEdge(current, name, flow_graph_1.FLOW_EDGE_TYPE.undefined);
243
- graph.addEdge(name, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
244
- }
245
- else if (type instanceof Structures.TestSeam) {
246
- const name = StatementFlow.buildName(n.getFirstStatement());
247
- const sub = this.traverseBody(this.findBody(n), context);
248
- graph.addEdge(current, name, flow_graph_1.FLOW_EDGE_TYPE.undefined);
249
- graph.addGraph(name, sub, flow_graph_1.FLOW_EDGE_TYPE.undefined);
250
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
251
- }
252
- else if (type instanceof Structures.AtFirst
253
- || type instanceof Structures.AtLast
254
- || type instanceof Structures.At
255
- || type instanceof Structures.OnChange) {
256
- const name = StatementFlow.buildName(n.getFirstStatement());
257
- const body = this.traverseBody(this.findBody(n), context);
258
- graph.addEdge(current, name, flow_graph_1.FLOW_EDGE_TYPE.undefined);
259
- graph.addGraph(name, body, flow_graph_1.FLOW_EDGE_TYPE.undefined);
260
- graph.addEdge(body.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
261
- graph.addEdge(current, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
262
- }
263
- else if (type instanceof Structures.Try) {
264
- const tryName = StatementFlow.buildName(n.getFirstStatement());
265
- const body = this.traverseBody(this.findBody(n), context);
266
- graph.addEdge(current, tryName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
267
- graph.addGraph(tryName, body, flow_graph_1.FLOW_EDGE_TYPE.undefined);
268
- graph.addEdge(body.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
269
- for (const c of n.findDirectStructures(Structures.Catch)) {
270
- const catchName = StatementFlow.buildName(c.getFirstStatement());
271
- const catchBody = this.traverseBody(this.findBody(c), context);
272
- // TODO: this does not take exceptions into account
273
- graph.addEdge(body.getEnd(), catchName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
274
- graph.addGraph(catchName, catchBody, flow_graph_1.FLOW_EDGE_TYPE.undefined);
275
- graph.addEdge(catchBody.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
276
- }
277
- // TODO, handle CLEANUP
278
- }
279
- else if (type instanceof Structures.CatchSystemExceptions) {
280
- // TODO: this is not completely correct
281
- const catchName = StatementFlow.buildName(n.getFirstStatement());
282
- const body = this.traverseBody(this.findBody(n), context);
283
- graph.addEdge(current, catchName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
284
- graph.addGraph(catchName, body, flow_graph_1.FLOW_EDGE_TYPE.undefined);
285
- graph.addEdge(body.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
286
- }
287
- else if (type instanceof Structures.Case) {
288
- const caseName = StatementFlow.buildName(n.getFirstStatement());
289
- graph.addEdge(current, caseName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
290
- let othersFound = false;
291
- for (const w of n.findDirectStructures(Structures.When)) {
292
- const first = w.getFirstStatement();
293
- if (first === undefined) {
294
- continue;
295
- }
296
- if (first.get() instanceof Statements.WhenOthers) {
297
- othersFound = true;
298
- }
299
- const firstName = StatementFlow.buildName(first);
300
- const sub = this.traverseBody(this.findBody(w), context);
301
- graph.addEdge(caseName, firstName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
302
- graph.addGraph(firstName, sub, flow_graph_1.FLOW_EDGE_TYPE.undefined);
303
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
304
- }
305
- if (othersFound === false) {
306
- graph.addEdge(caseName, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
307
- }
308
- }
309
- else if (type instanceof Structures.CaseType) {
310
- const caseName = StatementFlow.buildName(n.getFirstStatement());
311
- graph.addEdge(current, caseName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
312
- let othersFound = false;
313
- for (const w of n.findDirectStructures(Structures.WhenType)) {
314
- const first = w.getFirstStatement();
315
- if (first === undefined) {
316
- continue;
317
- }
318
- if (first.get() instanceof Statements.WhenOthers) {
319
- othersFound = true;
320
- }
321
- const firstName = StatementFlow.buildName(first);
322
- const sub = this.traverseBody(this.findBody(w), context);
323
- graph.addEdge(caseName, firstName, flow_graph_1.FLOW_EDGE_TYPE.undefined);
324
- graph.addGraph(firstName, sub, flow_graph_1.FLOW_EDGE_TYPE.undefined);
325
- graph.addEdge(sub.getEnd(), graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
326
- }
327
- if (othersFound === false) {
328
- graph.addEdge(caseName, graph.getEnd(), flow_graph_1.FLOW_EDGE_TYPE.undefined);
329
- }
330
- }
331
- else if (type instanceof Structures.Define
332
- || type instanceof Structures.TestInjection) {
333
- // do nothing
334
- }
335
- else {
336
- console.dir("StatementFlow,todo, " + n.get().constructor.name);
337
- }
338
- return graph;
339
- }
340
- }
341
- exports.StatementFlow = StatementFlow;
342
- //# sourceMappingURL=statement_flow.js.map