@abaplint/core 2.119.14 → 2.119.16

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.
@@ -4619,6 +4619,7 @@ declare class MethodDefinitions implements IMethodDefinitions {
4619
4619
  getByName(name: string | undefined): IMethodDefinition | undefined;
4620
4620
  private parseInterface;
4621
4621
  private parse;
4622
+ private add;
4622
4623
  }
4623
4624
 
4624
4625
  declare class MethodDefRaising extends Expression {
@@ -4684,6 +4685,7 @@ declare class MethodParameters_2 implements IMethodParameters {
4684
4685
  getExceptions(): string[];
4685
4686
  getParameterDefault(parameter: string): ExpressionNode;
4686
4687
  private parse;
4688
+ private checkDuplicateNames;
4687
4689
  private workaroundRAP;
4688
4690
  private add;
4689
4691
  }
@@ -41,7 +41,8 @@ class ClassDefinition extends _identifier_1.Identifier {
41
41
  for (const e of events) {
42
42
  const eventName = (_a = e.findDirectExpression(Expressions.EventName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
43
43
  if (this.events.find(ev => ev.getName().toUpperCase() === eventName) !== undefined) {
44
- throw new Error("Event " + eventName + " already defined");
44
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getFirstToken(), "Event " + eventName + " already defined"));
45
+ continue;
45
46
  }
46
47
  this.events.push(new event_definition_1.EventDefinition(e, visibility_1.Visibility.Public, input)); // todo, all these are not Public
47
48
  }
@@ -61,8 +62,8 @@ class ClassDefinition extends _identifier_1.Identifier {
61
62
  this.createVisibilityValue = visibility_1.Visibility.Public;
62
63
  }
63
64
  // perform checks after everything has been initialized
64
- this.checkMethodsFromSuperClasses(input.scope);
65
- this.checkMethodNameLength();
65
+ this.checkMethodsFromSuperClasses(input);
66
+ this.checkMethodNameLength(input);
66
67
  }
67
68
  getFriends() {
68
69
  return this.friends;
@@ -118,18 +119,20 @@ class ClassDefinition extends _identifier_1.Identifier {
118
119
  const name = token === null || token === void 0 ? void 0 : token.getStr();
119
120
  return name;
120
121
  }
121
- checkMethodNameLength() {
122
+ checkMethodNameLength(input) {
122
123
  for (const m of this.methodDefs.getAll()) {
123
124
  if (m.getName().length > 30 && m.getName().includes("~") === false) {
124
125
  const message = `Method name "${m.getName()}" is too long, maximum length is 30 characters`;
125
- throw new Error(message);
126
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), message));
126
127
  }
127
128
  }
128
129
  }
129
- checkMethodsFromSuperClasses(scope) {
130
+ checkMethodsFromSuperClasses(input) {
130
131
  var _a;
132
+ const scope = input.scope;
131
133
  let sup = this.getSuperClass();
132
134
  const names = new Set();
135
+ const methods = new Map();
133
136
  while (sup !== undefined) {
134
137
  const cdef = scope.findClassDefinition(sup);
135
138
  for (const m of ((_a = cdef === null || cdef === void 0 ? void 0 : cdef.getMethodDefinitions()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
@@ -143,6 +146,9 @@ class ClassDefinition extends _identifier_1.Identifier {
143
146
  continue;
144
147
  }
145
148
  names.add(name);
149
+ if (methods.has(name) === false) {
150
+ methods.set(name, m.getVisibility());
151
+ }
146
152
  }
147
153
  for (const a of (cdef === null || cdef === void 0 ? void 0 : cdef.getAliases()) || []) {
148
154
  names.add(a.getName().toUpperCase());
@@ -152,7 +158,13 @@ class ClassDefinition extends _identifier_1.Identifier {
152
158
  for (const m of this.getMethodDefinitions().getAll()) {
153
159
  if (names.has(m.getName().toUpperCase())
154
160
  && m.isRedefinition() === false) {
155
- throw new Error(`${m.getName().toUpperCase()} already declared in superclass`);
161
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), `${m.getName().toUpperCase()} already declared in superclass`));
162
+ }
163
+ const superVisibility = methods.get(m.getName().toUpperCase());
164
+ if (m.isRedefinition() === true
165
+ && superVisibility !== undefined
166
+ && m.getVisibility() !== superVisibility) {
167
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), `${m.getName().toUpperCase()} redefinition visibility cannot be changed`));
156
168
  }
157
169
  }
158
170
  }
@@ -11,6 +11,7 @@ const _scope_type_1 = require("../5_syntax/_scope_type");
11
11
  const event_definition_1 = require("./event_definition");
12
12
  const method_definitions_1 = require("./method_definitions");
13
13
  const _reference_1 = require("../5_syntax/_reference");
14
+ const _syntax_input_1 = require("../5_syntax/_syntax_input");
14
15
  const _object_oriented_1 = require("../5_syntax/_object_oriented");
15
16
  class InterfaceDefinition extends _identifier_1.Identifier {
16
17
  constructor(node, input) {
@@ -27,7 +28,7 @@ class InterfaceDefinition extends _identifier_1.Identifier {
27
28
  this.parse(input, node);
28
29
  input.scope.pop(node.getLastToken().getEnd());
29
30
  // perform checks after everything has been initialized
30
- this.checkMethodNameLength();
31
+ this.checkMethodNameLength(input);
31
32
  }
32
33
  getSuperClass() {
33
34
  return undefined;
@@ -57,11 +58,11 @@ class InterfaceDefinition extends _identifier_1.Identifier {
57
58
  return this.methodDefinitions;
58
59
  }
59
60
  /////////////////
60
- checkMethodNameLength() {
61
+ checkMethodNameLength(input) {
61
62
  for (const m of this.methodDefinitions.getAll()) {
62
63
  if (m.getName().length > 30) {
63
64
  const message = `Method name "${m.getName()}" is too long, maximum length is 30 characters`;
64
- throw new Error(message);
65
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), message));
65
66
  }
66
67
  }
67
68
  }
@@ -86,6 +87,7 @@ class InterfaceDefinition extends _identifier_1.Identifier {
86
87
  }
87
88
  }
88
89
  parse(input, node) {
90
+ var _a;
89
91
  this.checkInterfacesExists(input, node);
90
92
  const helper = new _object_oriented_1.ObjectOriented(input.scope);
91
93
  helper.fromInterfaces(this);
@@ -95,11 +97,17 @@ class InterfaceDefinition extends _identifier_1.Identifier {
95
97
  this.aliases = this.attributes.getAliases();
96
98
  const events = node.findAllStatements(Statements.Events);
97
99
  for (const e of events) {
100
+ const eventName = (_a = e.findDirectExpression(Expressions.EventName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
101
+ if (this.events.find(ev => ev.getName().toUpperCase() === eventName) !== undefined) {
102
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getFirstToken(), "Event " + eventName + " already defined"));
103
+ continue;
104
+ }
98
105
  this.events.push(new event_definition_1.EventDefinition(e, visibility_1.Visibility.Public, input));
99
106
  }
100
107
  this.methodDefinitions = new method_definitions_1.MethodDefinitions(node, input);
101
108
  if (this.methodDefinitions.getByName("CONSTRUCTOR") !== undefined) {
102
- throw new Error("Interfaces cannot have constructor methods");
109
+ const constructor = this.methodDefinitions.getByName("CONSTRUCTOR");
110
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, constructor.getToken(), "Interfaces cannot have constructor methods"));
103
111
  }
104
112
  }
105
113
  }
@@ -5,6 +5,7 @@ const method_definition_1 = require("./method_definition");
5
5
  const Structures = require("../3_structures/structures");
6
6
  const statements_1 = require("../2_statements/statements");
7
7
  const visibility_1 = require("../4_file_information/visibility");
8
+ const _syntax_input_1 = require("../5_syntax/_syntax_input");
8
9
  class MethodDefinitions {
9
10
  constructor(node, input) {
10
11
  this.all = {};
@@ -26,8 +27,7 @@ class MethodDefinitions {
26
27
  parseInterface(node, input) {
27
28
  const defs = node.findAllStatements(statements_1.MethodDef);
28
29
  for (const def of defs) {
29
- const m = new method_definition_1.MethodDefinition(def, visibility_1.Visibility.Public, input);
30
- this.all[m.getName().toUpperCase()] = m;
30
+ this.add(def, visibility_1.Visibility.Public, input);
31
31
  }
32
32
  }
33
33
  parse(node, input) {
@@ -41,19 +41,25 @@ class MethodDefinitions {
41
41
  }
42
42
  const pri = cdef.findDirectStructure(Structures.PrivateSection);
43
43
  for (const def of (pri === null || pri === void 0 ? void 0 : pri.findAllStatements(statements_1.MethodDef)) || []) {
44
- const m = new method_definition_1.MethodDefinition(def, visibility_1.Visibility.Private, input);
45
- this.all[m.getName().toUpperCase()] = m;
44
+ this.add(def, visibility_1.Visibility.Private, input);
46
45
  }
47
46
  const pro = node.findDirectStructure(Structures.ProtectedSection);
48
47
  for (const def of (pro === null || pro === void 0 ? void 0 : pro.findAllStatements(statements_1.MethodDef)) || []) {
49
- const m = new method_definition_1.MethodDefinition(def, visibility_1.Visibility.Protected, input);
50
- this.all[m.getName().toUpperCase()] = m;
48
+ this.add(def, visibility_1.Visibility.Protected, input);
51
49
  }
52
50
  const pub = node.findDirectStructure(Structures.PublicSection);
53
51
  for (const def of (pub === null || pub === void 0 ? void 0 : pub.findAllStatements(statements_1.MethodDef)) || []) {
54
- const m = new method_definition_1.MethodDefinition(def, visibility_1.Visibility.Public, input);
52
+ this.add(def, visibility_1.Visibility.Public, input);
53
+ }
54
+ }
55
+ add(def, visibility, input) {
56
+ try {
57
+ const m = new method_definition_1.MethodDefinition(def, visibility, input);
55
58
  this.all[m.getName().toUpperCase()] = m;
56
59
  }
60
+ catch (e) {
61
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, def.getFirstToken(), e.message));
62
+ }
57
63
  }
58
64
  }
59
65
  exports.MethodDefinitions = MethodDefinitions;
@@ -32,8 +32,13 @@ class MethodParameters {
32
32
  // need the scope for LIKE typing inside method parameters
33
33
  const parentName = input.scope.getName();
34
34
  input.scope.push(_scope_type_1.ScopeType.MethodDefinition, "method definition", node.getStart(), input.filename);
35
- this.parse(node, input, parentName, abstractMethod);
36
- input.scope.pop(node.getEnd());
35
+ try {
36
+ this.parse(node, input, parentName, abstractMethod);
37
+ this.checkDuplicateNames();
38
+ }
39
+ finally {
40
+ input.scope.pop(node.getEnd());
41
+ }
37
42
  }
38
43
  getFilename() {
39
44
  return this.filename;
@@ -170,6 +175,16 @@ class MethodParameters {
170
175
  }
171
176
  this.workaroundRAP(node, input, parentName);
172
177
  }
178
+ checkDuplicateNames() {
179
+ const names = new Set();
180
+ for (const parameter of this.getAll()) {
181
+ const name = parameter.getName().toUpperCase();
182
+ if (names.has(name)) {
183
+ throw new Error(`Method parameter "${name}" already defined`);
184
+ }
185
+ names.add(name);
186
+ }
187
+ }
173
188
  workaroundRAP(node, input, parentName) {
174
189
  const resultName = node.findExpressionAfterToken("RESULT");
175
190
  const isRap = node.findExpressionAfterToken("IMPORTING");
@@ -74,7 +74,7 @@ class Registry {
74
74
  }
75
75
  static abaplintVersion() {
76
76
  // magic, see build script "version.sh"
77
- return "2.119.14";
77
+ return "2.119.16";
78
78
  }
79
79
  getDDICReferences() {
80
80
  return this.ddicReferences;
@@ -44,10 +44,6 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
44
44
  || node.get() instanceof _statement_1.Empty) {
45
45
  continue;
46
46
  }
47
- else if (this.isExit(node)) {
48
- exit = true;
49
- continue;
50
- }
51
47
  else if (this.isStructure(node.get())) {
52
48
  exit = false;
53
49
  continue;
@@ -56,6 +52,11 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
56
52
  const issue = issue_1.Issue.atStatement(file, node, this.getMessage(), this.getMetadata().key, this.conf.severity);
57
53
  output.push(issue);
58
54
  exit = false;
55
+ continue;
56
+ }
57
+ else if (this.isExit(node)) {
58
+ exit = true;
59
+ continue;
59
60
  }
60
61
  }
61
62
  return output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.119.14",
3
+ "version": "2.119.16",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
- "@microsoft/api-extractor": "^7.58.5",
53
+ "@microsoft/api-extractor": "^7.58.7",
54
54
  "@types/chai": "^4.3.20",
55
55
  "@types/mocha": "^10.0.10",
56
56
  "@types/node": "^24.12.2",
@@ -63,7 +63,7 @@
63
63
  "typescript": "^5.9.3"
64
64
  },
65
65
  "dependencies": {
66
- "fast-xml-parser": "^5.7.1",
66
+ "fast-xml-parser": "^5.8.0",
67
67
  "json5": "^2.2.3",
68
68
  "vscode-languageserver-types": "^3.17.5"
69
69
  }