@abaplint/core 2.112.0 → 2.112.2

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.
@@ -36,7 +36,7 @@ class AttributeChain {
36
36
  }
37
37
  if (context === undefined) {
38
38
  const message = "Attribute or constant \"" + name + "\" not found in \"" + def.getName() + "\"";
39
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
39
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
40
40
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
41
41
  }
42
42
  for (const t of type) {
@@ -55,7 +55,7 @@ class Cast {
55
55
  else if (tt === undefined) {
56
56
  // todo, this should be an UnknownType instead?
57
57
  const message = "Type \"" + typeName + "\" not found in scope, Cast";
58
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
58
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, typeExpression.getFirstToken(), message));
59
59
  return new basic_1.VoidType(_syntax_input_1.CheckSyntaxKey);
60
60
  }
61
61
  }
@@ -28,21 +28,21 @@ class ComponentChain {
28
28
  if (concat === "-") {
29
29
  if (!(context instanceof structure_type_1.StructureType)) {
30
30
  const message = "ComponentChain, not a structure";
31
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
31
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
32
32
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
33
33
  }
34
34
  }
35
35
  else if (concat === "=>") {
36
36
  if (!(context instanceof basic_1.ObjectReferenceType)) {
37
37
  const message = "ComponentChain, not a reference";
38
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
38
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
39
39
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
40
40
  }
41
41
  }
42
42
  else if (concat === "->") {
43
43
  if (!(context instanceof basic_1.ObjectReferenceType) && !(context instanceof basic_1.DataReference)) {
44
44
  const message = "ComponentChain, not a reference";
45
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
45
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
46
46
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
47
47
  }
48
48
  }
@@ -59,7 +59,7 @@ class ComponentChain {
59
59
  context = context.getComponentByName(name);
60
60
  if (context === undefined) {
61
61
  const message = "Component \"" + name + "\" not found in structure";
62
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
62
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
63
63
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
64
64
  }
65
65
  }
@@ -68,7 +68,7 @@ class ComponentChain {
68
68
  const def = input.scope.findObjectDefinition(id.getName());
69
69
  if (def === undefined) {
70
70
  const message = id.getName() + " not found in scope";
71
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
71
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
72
72
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
73
73
  }
74
74
  const helper = new _object_oriented_1.ObjectOriented(input.scope);
@@ -76,7 +76,7 @@ class ComponentChain {
76
76
  context = found === null || found === void 0 ? void 0 : found.getType();
77
77
  if (context === undefined) {
78
78
  const message = "Attribute \"" + name + "\" not found";
79
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
79
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
80
80
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
81
81
  }
82
82
  else {
@@ -89,7 +89,7 @@ class ComponentChain {
89
89
  }
90
90
  else {
91
91
  const message = "ComponentChain, not a structure, " + (context === null || context === void 0 ? void 0 : context.constructor.name);
92
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
92
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
93
93
  return new void_type_1.VoidType(_syntax_input_1.CheckSyntaxKey);
94
94
  }
95
95
  }
@@ -53,7 +53,7 @@ class MethodCallChain {
53
53
  else {
54
54
  if (previous && previous.getFirstToken().getStr() === "=>" && (method === null || method === void 0 ? void 0 : method.isStatic()) === false) {
55
55
  const message = "Method \"" + methodName + "\" not static";
56
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
56
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
57
57
  return new basic_1.VoidType(_syntax_input_1.CheckSyntaxKey);
58
58
  }
59
59
  const extra = {
@@ -74,7 +74,7 @@ class MethodCallChain {
74
74
  }
75
75
  else if (method === undefined && !(context instanceof basic_1.VoidType)) {
76
76
  const message = "Method \"" + methodName + "\" not found, methodCallChain";
77
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
77
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
78
78
  return new basic_1.VoidType(_syntax_input_1.CheckSyntaxKey);
79
79
  }
80
80
  else if (method) {
@@ -74,7 +74,7 @@ class Data {
74
74
  }
75
75
  if (!(found instanceof Basic.StructureType)) {
76
76
  const message = "not structured, " + typeName;
77
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
77
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, typeToken, message));
78
78
  return new _typed_identifier_1.TypedIdentifier(name, input.filename, new Basic.VoidType(_syntax_input_1.CheckSyntaxKey));
79
79
  }
80
80
  for (const c of found.getComponents()) {
@@ -65,6 +65,7 @@ class InterfaceDefinition extends _identifier_1.Identifier {
65
65
  this.typeDefinitions = this.attributes.getTypes();
66
66
  this.aliases = new aliases_1.Aliases(node, this.filename, input.scope);
67
67
  // todo, cleanup aliases, vs "object_oriented.ts" vs "class_implementation.ts"
68
+ // this adds the aliased types to scope?
68
69
  for (const a of this.aliases.getAll()) {
69
70
  const [objName, fieldName] = a.getComponent().split("~");
70
71
  const idef = input.scope.findInterfaceDefinition(objName);
@@ -84,10 +85,6 @@ class InterfaceDefinition extends _identifier_1.Identifier {
84
85
  }
85
86
  }
86
87
  }
87
- this.methodDefinitions = new method_definitions_1.MethodDefinitions(node, input);
88
- if (this.methodDefinitions.getByName("CONSTRUCTOR") !== undefined) {
89
- throw new Error("Interfaces cannot have constructor methods");
90
- }
91
88
  const events = node.findAllStatements(Statements.Events);
92
89
  for (const e of events) {
93
90
  this.events.push(new event_definition_1.EventDefinition(e, visibility_1.Visibility.Public, input));
@@ -109,6 +106,10 @@ class InterfaceDefinition extends _identifier_1.Identifier {
109
106
  }
110
107
  }
111
108
  }
109
+ this.methodDefinitions = new method_definitions_1.MethodDefinitions(node, input);
110
+ if (this.methodDefinitions.getByName("CONSTRUCTOR") !== undefined) {
111
+ throw new Error("Interfaces cannot have constructor methods");
112
+ }
112
113
  }
113
114
  }
114
115
  exports.InterfaceDefinition = InterfaceDefinition;
@@ -89,6 +89,10 @@ class Config {
89
89
  if (this.config.syntax.globalConstants === undefined) {
90
90
  this.config.syntax.globalConstants = [];
91
91
  }
92
+ else {
93
+ // remove duplicates,
94
+ this.config.syntax.globalConstants = [...new Set(this.config.syntax.globalConstants)];
95
+ }
92
96
  if (this.config.global.skipIncludesWithoutMain === undefined) {
93
97
  this.config.global.skipIncludesWithoutMain = false;
94
98
  }
@@ -67,7 +67,7 @@ class Registry {
67
67
  }
68
68
  static abaplintVersion() {
69
69
  // magic, see build script "version.sh"
70
- return "2.112.0";
70
+ return "2.112.2";
71
71
  }
72
72
  getDDICReferences() {
73
73
  return this.ddicReferences;
@@ -16,6 +16,8 @@ class DoubleSpaceConf extends _basic_rule_config_1.BasicRuleConfig {
16
16
  super(...arguments);
17
17
  /** Check for double space after keywords */
18
18
  this.keywords = true;
19
+ /** list of keywords to skip, case insensitive */
20
+ this.skipKeywords = ["CHANGING", "EXPORTING", "OTHERS"];
19
21
  /** Check for double space after start parenthesis */
20
22
  this.startParen = true;
21
23
  /** Check for double space before end parenthesis */
@@ -48,6 +50,9 @@ class DoubleSpace extends _abap_rule_1.ABAPRule {
48
50
  }
49
51
  setConfig(conf) {
50
52
  this.conf = conf;
53
+ if (this.conf.skipKeywords === undefined) {
54
+ this.conf.skipKeywords = new DoubleSpaceConf().skipKeywords;
55
+ }
51
56
  }
52
57
  runParsed(file) {
53
58
  let issues = [];
@@ -159,9 +164,7 @@ class DoubleSpace extends _abap_rule_1.ABAPRule {
159
164
  if (prev instanceof nodes_1.TokenNodeRegex
160
165
  || upper === "("
161
166
  || upper === ")"
162
- || upper === "CHANGING"
163
- || upper === "EXPORTING"
164
- || upper === "OTHERS") {
167
+ || this.getConfig().skipKeywords.some(e => e.toUpperCase() === upper)) {
165
168
  // not a keyword, continue
166
169
  prev = n;
167
170
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.112.0",
3
+ "version": "2.112.2",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- const lexer_1 = require("../src/abap/1_lexer/lexer");
5
- const fs = require("fs");
6
- console.log("========================");
7
- const file = new src_1.MemoryFile("abapgit.abap", fs.readFileSync("./lexer_performance.abap", "utf-8"));
8
- let total = 0;
9
- for (let i = 0; i < 10; i++) {
10
- const before = Date.now();
11
- const result = new lexer_1.Lexer().run(file);
12
- const runtime = Date.now() - before;
13
- console.log("Runtime: " + runtime + "ms, Tokens: " + result.tokens.length);
14
- total += runtime;
15
- }
16
- console.log("Total: " + total + "ms");
17
- //# sourceMappingURL=lexer_performance.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- const lexer_1 = require("../src/abap/1_lexer/lexer");
5
- const fs = require("fs");
6
- const statement_parser_1 = require("../src/abap/2_statements/statement_parser");
7
- console.log("========================");
8
- const file = new src_1.MemoryFile("abapgit.abap", fs.readFileSync("./lexer_performance.abap", "utf-8"));
9
- const lexerResult = new lexer_1.Lexer().run(file);
10
- let total = 0;
11
- for (let i = 0; i < 4; i++) {
12
- const before = Date.now();
13
- new statement_parser_1.StatementParser(src_1.Version.v702).run([lexerResult], []);
14
- const runtime = Date.now() - before;
15
- total += runtime;
16
- }
17
- console.log("Total: " + total + "ms");
18
- //# sourceMappingURL=parser_performance.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,185 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- const fs = require("fs");
5
- console.log("========================");
6
- const file1 = new src_1.MemoryFile("abapgit.prog.abap", fs.readFileSync("./lexer_performance.abap", "utf-8"));
7
- const reg = new src_1.Registry().addFile(file1);
8
- reg.addFile(new src_1.MemoryFile("cx_root.clas.abap", `
9
- CLASS cx_root DEFINITION ABSTRACT PUBLIC.
10
- PUBLIC SECTION.
11
- DATA previous TYPE REF TO cx_root.
12
- DATA textid TYPE c LENGTH 32.
13
-
14
- METHODS constructor
15
- IMPORTING
16
- textid LIKE textid OPTIONAL
17
- previous TYPE REF TO cx_root OPTIONAL.
18
-
19
- METHODS get_source_position
20
- EXPORTING
21
- program_name TYPE string
22
- include_name TYPE string
23
- source_line TYPE i.
24
-
25
- INTERFACES if_message.
26
- ALIASES get_longtext FOR if_message~get_longtext.
27
- ALIASES get_text FOR if_message~get_text.
28
-
29
- ENDCLASS.
30
-
31
- CLASS cx_root IMPLEMENTATION.
32
-
33
- METHOD constructor.
34
- ENDMETHOD.
35
-
36
- METHOD get_source_position.
37
- ENDMETHOD.
38
-
39
- METHOD if_message~get_longtext.
40
- ENDMETHOD.
41
-
42
- METHOD if_message~get_text.
43
- ENDMETHOD.
44
-
45
- ENDCLASS.`));
46
- reg.addFile(new src_1.MemoryFile("cx_static_check.clas.abap", `
47
- CLASS cx_static_check DEFINITION PUBLIC INHERITING FROM cx_root.
48
- PUBLIC SECTION.
49
- METHODS constructor
50
- IMPORTING
51
- textid LIKE textid OPTIONAL
52
- previous TYPE REF TO cx_root OPTIONAL.
53
- ENDCLASS.
54
-
55
- CLASS cx_static_check IMPLEMENTATION.
56
- METHOD constructor.
57
- ENDMETHOD.
58
- ENDCLASS.`));
59
- reg.addFile(new src_1.MemoryFile("if_message.intf.abap", `
60
- INTERFACE if_message PUBLIC.
61
- METHODS get_text RETURNING VALUE(result) TYPE string.
62
-
63
- METHODS get_longtext
64
- IMPORTING preserve_newlines TYPE abap_bool OPTIONAL
65
- RETURNING VALUE(result) TYPE string.
66
- ENDINTERFACE.`));
67
- reg.addFile(new src_1.MemoryFile("if_t100_message.intf.abap", `
68
- INTERFACE if_t100_message PUBLIC.
69
-
70
- DATA t100key TYPE scx_t100key.
71
-
72
- CONSTANTS:
73
- BEGIN OF default_textid,
74
- msgid TYPE symsgid VALUE 'AB',
75
- msgno TYPE symsgno VALUE '123',
76
- attr1 TYPE scx_attrname VALUE '',
77
- attr2 TYPE scx_attrname VALUE '',
78
- attr3 TYPE scx_attrname VALUE '',
79
- attr4 TYPE scx_attrname VALUE '',
80
- END OF default_textid.
81
-
82
- ENDINTERFACE.`));
83
- reg.setConfig(new src_1.Config(`
84
- {
85
- "global": {
86
- "files": "/src/**/*.*"
87
- },
88
- "dependencies": [],
89
- "syntax": {
90
- "version": "v702",
91
- "errorNamespace": "^(Z|Y|LCL_|TY_|LIF_)",
92
- "globalConstants": [
93
- "abap_func_exporting",
94
- "abap_func_tables",
95
- "cssf_formtype_text",
96
- "icon_abap",
97
- "icon_adopt",
98
- "icon_change",
99
- "icon_create",
100
- "icon_delete",
101
- "icon_display_text",
102
- "icon_folder",
103
- "icon_led_green",
104
- "icon_led_inactive",
105
- "icon_led_red",
106
- "icon_led_yellow",
107
- "icon_message_information",
108
- "icon_okay",
109
- "icon_set_state",
110
- "icon_stack",
111
- "icon_system_help",
112
- "icon_workflow_fork",
113
- "seoc_category_exception",
114
- "seoc_category_webdynpro_class",
115
- "seoc_exposure_private",
116
- "seoc_exposure_protected",
117
- "seoc_exposure_public",
118
- "seoc_state_implemented",
119
- "seoc_version_active",
120
- "seoc_version_deleted",
121
- "seoc_version_inactive",
122
- "seok_access_free",
123
- "seok_access_modify",
124
- "seox_false",
125
- "seok_pgmid_r3tr",
126
- "seoo_cmptype_type",
127
- "seoo_cmptype_event",
128
- "seoo_cmptype_method",
129
- "seoo_cmptype_attribute",
130
- "seop_ext_class_locals_def",
131
- "seop_ext_class_locals_imp",
132
- "seop_ext_class_macros",
133
- "seop_ext_class_testclasses",
134
- "seop_incextapp_definition",
135
- "seop_incextapp_implementation",
136
- "seop_incextapp_macros",
137
- "seop_incextapp_testclasses",
138
- "seos_scotype_exception",
139
- "seos_scotype_parameter",
140
- "seox_true",
141
- "sews_c_vif_version",
142
- "skwfc_obtype_folder",
143
- "skwfc_obtype_loio",
144
- "so2_controller",
145
- "icon_no_status",
146
- "icon_package_standard",
147
- "srext_ext_class_pool",
148
- "srext_ext_interface_pool",
149
- "ststc_c_type_dialog",
150
- "ststc_c_type_object",
151
- "ststc_c_type_parameters",
152
- "ststc_c_type_report",
153
- "swbm_c_op_delete_no_dialog",
154
- "swbm_c_type_ddic_db_tabxinx",
155
- "swbm_c_type_wdy_application",
156
- "swbm_version_active",
157
- "swbm_version_inactive",
158
- "wbmr_c_skwf_folder_class",
159
- "wdyn_limu_component_controller",
160
- "wdyn_limu_component_definition",
161
- "wdyn_limu_component_view"
162
- ]
163
- },
164
- "rules": {
165
- "begin_end_names": true,
166
- "check_ddic": true,
167
- "check_include": true,
168
- "check_syntax": true,
169
- "global_class": true,
170
- "implement_methods": true,
171
- "method_implemented_twice": true,
172
- "parser_error": true,
173
- "superclass_final": true,
174
- "unknown_types": true,
175
- "xml_consistency": true
176
- }
177
- }`));
178
- reg.parse();
179
- console.log("run syntax logic,");
180
- const before = Date.now();
181
- const issues = reg.findIssues();
182
- console.dir(issues);
183
- const runtime = Date.now() - before;
184
- console.log("Total: " + runtime + "ms");
185
- //# sourceMappingURL=syntax_performance.js.map
@@ -1,20 +0,0 @@
1
- declare class Token {
2
- private readonly col;
3
- private readonly row;
4
- private readonly type;
5
- private readonly str;
6
- constructor(col: number, row: number, type: number, str: string);
7
- get(): {
8
- a: number;
9
- b: number;
10
- c: number;
11
- d: string;
12
- };
13
- }
14
- declare class TokensMemory {
15
- private readonly strings;
16
- private readonly memory;
17
- private length;
18
- add(col: number, row: number, type: number, str: string): void;
19
- }
20
- declare const count = 5000000;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- class Token {
3
- constructor(col, row, type, str) {
4
- this.col = col;
5
- this.row = row;
6
- this.type = type;
7
- this.str = str;
8
- }
9
- get() {
10
- return { a: this.col, b: this.row, c: this.type, d: this.str };
11
- }
12
- }
13
- class TokensMemory {
14
- constructor() {
15
- this.strings = [];
16
- this.memory = new Int32Array();
17
- this.length = 0;
18
- }
19
- add(col, row, type, str) {
20
- this.memory[0 + this.length] = col;
21
- this.memory[1 + this.length] = row;
22
- this.memory[2 + this.length] = type;
23
- this.memory[3 + this.length] = this.strings.length;
24
- this.strings.push(str);
25
- this.length++;
26
- }
27
- }
28
- const count = 5000000;
29
- {
30
- const start = Date.now();
31
- const mem = new TokensMemory();
32
- for (let i = 0; i < count; i++) {
33
- mem.add(i, i, i, "dfs" + i);
34
- }
35
- const runtime = Date.now() - start;
36
- console.log("Typed Array: " + runtime + "ms");
37
- }
38
- {
39
- const start = Date.now();
40
- const tokens = [];
41
- for (let i = 0; i < count; i++) {
42
- tokens.push(new Token(i, i, i, "dfs" + i));
43
- }
44
- const runtime = Date.now() - start;
45
- console.log("Objects: " + runtime + "ms");
46
- }
47
- //# sourceMappingURL=typed_array.js.map