@abaplint/core 2.120.19 → 2.120.21

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.
@@ -1263,6 +1263,8 @@ declare class ClassDefinition_3 extends Identifier implements IClassDefinition {
1263
1263
  private checkClassConstructorStatic;
1264
1264
  private checkInterfaceVisibility;
1265
1265
  private checkMethodsFromSuperClasses;
1266
+ private checkMethodNameConflicts;
1267
+ private checkEventNameConflicts;
1266
1268
  private findFriends;
1267
1269
  private addReference;
1268
1270
  private parse;
@@ -1645,6 +1647,7 @@ export declare class CurrentScope {
1645
1647
  push(stype: ScopeType, sname: string, start: Position, filename: string): void;
1646
1648
  isOO(): boolean;
1647
1649
  isAnyOO(): boolean;
1650
+ isInStaticMethod(): boolean;
1648
1651
  addLocalFriend(className: string, friendName: string): void;
1649
1652
  isLocalFriend(className: string, friendName: string): boolean;
1650
1653
  getEnclosingClassName(): string | undefined;
@@ -23,11 +23,12 @@ class ModifyEntities {
23
23
  const reported = (0, combi_1.seq)("REPORTED", expressions_1.Target);
24
24
  const end = (0, combi_1.optPrio)((0, combi_1.per)(failed, result, mapped, reported));
25
25
  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.NamespaceSimpleName, (0, combi_1.plus)(operation))));
26
+ const dynamic = (0, combi_1.seq)("ENTITIES", (0, combi_1.optPrio)((0, combi_1.altPrio)("IN LOCAL MODE", (0, combi_1.seq)((0, combi_1.opt)("FORWARDING"), "PRIVILEGED"))), "OPERATIONS", expressions_1.Source);
26
27
  const create2 = (0, combi_1.seq)("CREATE", fieldsWith, (0, combi_1.opt)((0, combi_1.seq)("CREATE BY", expressions_1.EMLEntityPath, fieldsWith)));
27
28
  const create3 = (0, combi_1.seq)("CREATE BY", expressions_1.EMLEntityPath, fieldsWith);
28
29
  const create4 = (0, combi_1.seq)("CREATE FROM", expressions_1.Source, (0, combi_1.plus)((0, combi_1.seq)("CREATE BY", expressions_1.EMLEntityPath, "FROM", expressions_1.Source)));
29
30
  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, updateFields, deleteFrom, updateSetFields, updateFrom, create2, create3, create4));
30
- return (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("MODIFY", (0, combi_1.alt)(entities, entity), end), { also: combi_1.AlsoIn.OpenABAP });
31
+ return (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("MODIFY", (0, combi_1.alt)(entities, dynamic, entity), end), { also: combi_1.AlsoIn.OpenABAP });
31
32
  }
32
33
  }
33
34
  exports.ModifyEntities = ModifyEntities;
@@ -462,6 +462,20 @@ class CurrentScope {
462
462
  }
463
463
  return false;
464
464
  }
465
+ isInStaticMethod() {
466
+ let curr = this.current;
467
+ while (curr !== undefined) {
468
+ const stype = curr.getIdentifier().stype;
469
+ if (stype === _scope_type_1.ScopeType.MethodInstance) {
470
+ return false;
471
+ }
472
+ else if (stype === _scope_type_1.ScopeType.ClassImplementation) {
473
+ return true;
474
+ }
475
+ curr = curr.getParent();
476
+ }
477
+ return false;
478
+ }
465
479
  addLocalFriend(className, friendName) {
466
480
  var _a;
467
481
  const key = className.toUpperCase();
@@ -510,7 +510,8 @@ class TypeUtils {
510
510
  }
511
511
  }
512
512
  else if (source instanceof basic_1.XStringType) {
513
- if (target instanceof basic_1.CLikeType
513
+ if (target instanceof basic_1.CharacterType
514
+ || target instanceof basic_1.CLikeType
514
515
  || target instanceof basic_1.IntegerType
515
516
  || target instanceof basic_1.StringType
516
517
  || target instanceof basic_1.ObjectReferenceType
@@ -1,17 +1,57 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.AttributeChain = void 0;
37
+ const nodes_1 = require("../../nodes");
38
+ const Expressions = __importStar(require("../../2_statements/expressions"));
4
39
  const void_type_1 = require("../../types/basic/void_type");
5
- const object_reference_type_1 = require("../../types/basic/object_reference_type");
40
+ const basic_1 = require("../../types/basic");
6
41
  const _object_oriented_1 = require("../_object_oriented");
7
42
  const expressions_1 = require("../../2_statements/expressions");
8
43
  const _syntax_input_1 = require("../_syntax_input");
44
+ const component_name_1 = require("./component_name");
45
+ const attribute_name_1 = require("./attribute_name");
46
+ const table_expression_1 = require("./table_expression");
47
+ const field_offset_1 = require("./field_offset");
48
+ const field_length_1 = require("./field_length");
9
49
  class AttributeChain {
10
50
  static runSyntax(inputContext, node, input, type) {
11
51
  if (inputContext instanceof void_type_1.VoidType) {
12
52
  return inputContext;
13
53
  }
14
- else if (!(inputContext instanceof object_reference_type_1.ObjectReferenceType)) {
54
+ else if (!(inputContext instanceof basic_1.ObjectReferenceType)) {
15
55
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), "Not an object reference(AttributeChain)"));
16
56
  return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
17
57
  }
@@ -41,8 +81,69 @@ class AttributeChain {
41
81
  for (const t of type) {
42
82
  input.scope.addReference(nameToken, context, t, input.filename);
43
83
  }
44
- // todo, loop, handle ArrowOrDash, ComponentName, TableExpression
45
- return context.getType();
84
+ let contextType = context.getType();
85
+ const children = node.getChildren();
86
+ for (let i = 1; i < children.length; i++) {
87
+ const child = children[i];
88
+ if (contextType instanceof void_type_1.VoidType || contextType instanceof basic_1.UnknownType) {
89
+ return contextType;
90
+ }
91
+ else if (child.get() instanceof Expressions.ArrowOrDash) {
92
+ const operator = child.getFirstToken().getStr();
93
+ if (operator === "-" && !(contextType instanceof basic_1.StructureType)) {
94
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "AttributeChain, not a structure"));
95
+ return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
96
+ }
97
+ else if ((operator === "->" || operator === "=>")
98
+ && !(contextType instanceof basic_1.ObjectReferenceType)
99
+ && !(contextType instanceof basic_1.DataReference)) {
100
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "AttributeChain, not a reference"));
101
+ return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
102
+ }
103
+ }
104
+ else if (child.get() instanceof Expressions.ComponentName) {
105
+ if (contextType instanceof basic_1.ObjectReferenceType || contextType instanceof basic_1.DataReference) {
106
+ contextType = attribute_name_1.AttributeName.runSyntax(contextType, child, input, type);
107
+ }
108
+ else {
109
+ contextType = component_name_1.ComponentName.runSyntax(contextType, child, input);
110
+ }
111
+ }
112
+ else if (child.getFirstToken().getStr() === "*" && contextType instanceof basic_1.DataReference) {
113
+ contextType = contextType.getType();
114
+ }
115
+ else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.TableExpression) {
116
+ if (!(contextType instanceof basic_1.TableType)) {
117
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "Table expression, expected table"));
118
+ return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
119
+ }
120
+ table_expression_1.TableExpression.runSyntax(child, input, contextType);
121
+ contextType = contextType.getRowType();
122
+ }
123
+ else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldOffset) {
124
+ const offset = field_offset_1.FieldOffset.runSyntax(child, input);
125
+ if (offset !== undefined) {
126
+ if (contextType instanceof basic_1.CharacterType) {
127
+ contextType = new basic_1.CharacterType(contextType.getLength() - offset);
128
+ }
129
+ else if (contextType instanceof basic_1.HexType) {
130
+ contextType = new basic_1.HexType(contextType.getLength() - offset);
131
+ }
132
+ }
133
+ }
134
+ else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldLength) {
135
+ const length = field_length_1.FieldLength.runSyntax(child, input);
136
+ if (length !== undefined) {
137
+ if (contextType instanceof basic_1.CharacterType) {
138
+ contextType = new basic_1.CharacterType(length);
139
+ }
140
+ else if (contextType instanceof basic_1.HexType) {
141
+ contextType = new basic_1.HexType(length);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ return contextType;
46
147
  }
47
148
  }
48
149
  exports.AttributeChain = AttributeChain;
@@ -90,6 +90,11 @@ class MethodCallChain {
90
90
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
91
91
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
92
92
  }
93
+ if (current === first && (method === null || method === void 0 ? void 0 : method.isStatic()) === false && input.scope.isInStaticMethod() === true) {
94
+ const message = "Method \"" + methodName + "\" not static";
95
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
96
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
97
+ }
93
98
  const voidedName = context instanceof basic_1.VoidType ? context.getVoided() : undefined;
94
99
  const extra = helper.methodReferenceExtras(foundDef, className || voidedName);
95
100
  input.scope.addReference(methodToken, method, _reference_1.ReferenceType.MethodReference, input.filename, extra);
@@ -59,9 +59,11 @@ class MethodSource {
59
59
  throw new assert_error_1.AssertError("MethodSource, first child expected");
60
60
  }
61
61
  let context = this.findTop(first, input, children);
62
+ let implicitMe = false;
62
63
  if (context === undefined) {
63
64
  context = (_a = input.scope.findVariable("me")) === null || _a === void 0 ? void 0 : _a.getType();
64
65
  children.unshift(first);
66
+ implicitMe = true;
65
67
  }
66
68
  if (input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
67
69
  && first.get() instanceof Expressions.Dynamic
@@ -121,6 +123,11 @@ class MethodSource {
121
123
  const def = input.scope.findObjectDefinition(className);
122
124
  // eslint-disable-next-line prefer-const
123
125
  let { method, def: foundDef } = helper.searchMethodName(def, methodName);
126
+ if (implicitMe && current === first && (method === null || method === void 0 ? void 0 : method.isStatic()) === false && input.scope.isInStaticMethod() === true) {
127
+ const message = "Method \"" + methodName + "\" not static";
128
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
129
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
130
+ }
124
131
  if (method === undefined && (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) === "CONSTRUCTOR") {
125
132
  context = basic_1.VoidType.get("CONSTRUCTOR"); // todo, this is a workaround, constructors always exists
126
133
  }
@@ -97,6 +97,8 @@ class ClassDefinition extends _identifier_1.Identifier {
97
97
  // perform checks after everything has been initialized
98
98
  this.checkInterfaceVisibility(input, node);
99
99
  this.checkMethodsFromSuperClasses(input);
100
+ this.checkMethodNameConflicts(input);
101
+ this.checkEventNameConflicts(input);
100
102
  this.checkClassNameLength(input);
101
103
  this.checkMethodNameLength(input);
102
104
  this.checkClassConstructorStatic(input);
@@ -228,6 +230,23 @@ class ClassDefinition extends _identifier_1.Identifier {
228
230
  }
229
231
  }
230
232
  }
233
+ checkMethodNameConflicts(input) {
234
+ for (const m of this.methodDefs.getAll()) {
235
+ if (this.attributes.findByName(m.getName()) !== undefined
236
+ || this.types.getByName(m.getName()) !== undefined) {
237
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), `"${m.getName()}" already defined`));
238
+ }
239
+ }
240
+ }
241
+ checkEventNameConflicts(input) {
242
+ for (const e of this.events) {
243
+ if (this.attributes.findByName(e.getName()) !== undefined
244
+ || this.types.getByName(e.getName()) !== undefined
245
+ || this.methodDefs.getByName(e.getName()) !== undefined) {
246
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getToken(), `"${e.getName()}" already defined`));
247
+ }
248
+ }
249
+ }
231
250
  findFriends(def, input) {
232
251
  var _a;
233
252
  const result = [];
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.19";
78
+ return "2.120.21";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.19",
3
+ "version": "2.120.21",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
10
10
  "lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" --fix",
11
- "clean": "rm -rf build",
11
+ "clean": "rimraf build",
12
12
  "compile": "npm run clean && tsc && node scripts/version.js",
13
13
  "watch": "tsc --watch",
14
14
  "test": "npm run compile && mocha --timeout 1000 && npm run lint && npm run schema && api-extractor run",
@@ -39,7 +39,7 @@
39
39
  "url": "git+https://github.com/abaplint/abaplint.git"
40
40
  },
41
41
  "engines": {
42
- "node": ">=18.0.0"
42
+ "node": ">=22.0.0"
43
43
  },
44
44
  "keywords": [
45
45
  "ABAP",
@@ -60,6 +60,7 @@
60
60
  "chai": "^4.5.0",
61
61
  "eslint": "^9.39.5",
62
62
  "mocha": "^11.7.6",
63
+ "rimraf": "^6.1.3",
63
64
  "source-map-support": "^0.5.21",
64
65
  "ts-json-schema-generator": "^2.9.0",
65
66
  "typescript": "^7.0.2"