@abaplint/cli 2.120.105 → 2.120.107

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.
Files changed (2) hide show
  1. package/build/cli.js +260 -11
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -28348,6 +28348,236 @@ exports.SortedKeyWrite = SortedKeyWrite;
28348
28348
 
28349
28349
  /***/ },
28350
28350
 
28351
+ /***/ "../core/build/src/abap/5_syntax/_super_constructor_call.js"
28352
+ /*!******************************************************************!*\
28353
+ !*** ../core/build/src/abap/5_syntax/_super_constructor_call.js ***!
28354
+ \******************************************************************/
28355
+ (__unused_webpack_module, exports, __webpack_require__) {
28356
+
28357
+ "use strict";
28358
+
28359
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28360
+ if (k2 === undefined) k2 = k;
28361
+ var desc = Object.getOwnPropertyDescriptor(m, k);
28362
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28363
+ desc = { enumerable: true, get: function() { return m[k]; } };
28364
+ }
28365
+ Object.defineProperty(o, k2, desc);
28366
+ }) : (function(o, m, k, k2) {
28367
+ if (k2 === undefined) k2 = k;
28368
+ o[k2] = m[k];
28369
+ }));
28370
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28371
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28372
+ }) : function(o, v) {
28373
+ o["default"] = v;
28374
+ });
28375
+ var __importStar = (this && this.__importStar) || (function () {
28376
+ var ownKeys = function(o) {
28377
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28378
+ var ar = [];
28379
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28380
+ return ar;
28381
+ };
28382
+ return ownKeys(o);
28383
+ };
28384
+ return function (mod) {
28385
+ if (mod && mod.__esModule) return mod;
28386
+ var result = {};
28387
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
28388
+ __setModuleDefault(result, mod);
28389
+ return result;
28390
+ };
28391
+ })();
28392
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
28393
+ exports.SuperConstructorCall = void 0;
28394
+ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
28395
+ const Statements = __importStar(__webpack_require__(/*! ../2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
28396
+ const _statement_1 = __webpack_require__(/*! ../2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
28397
+ const dash_1 = __webpack_require__(/*! ../1_lexer/tokens/dash */ "../core/build/src/abap/1_lexer/tokens/dash.js");
28398
+ const identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ "../core/build/src/abap/1_lexer/tokens/identifier.js");
28399
+ const virtual_position_1 = __webpack_require__(/*! ../../virtual_position */ "../core/build/src/virtual_position.js");
28400
+ const _syntax_input_1 = __webpack_require__(/*! ./_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
28401
+ /** The constructor of a subclass must call SUPER->CONSTRUCTOR, and before the call instance
28402
+ * attributes, instance methods and ME cannot be used. Runs when the method has been traversed,
28403
+ * scopeNode is the outermost scope of the method, holding the references of its body. */
28404
+ class SuperConstructorCall {
28405
+ static check(method, scopeNode, input) {
28406
+ var _a;
28407
+ const methodStatement = method.findDirectStatement(Statements.MethodImplementation);
28408
+ const methodName = (_a = methodStatement === null || methodStatement === void 0 ? void 0 : methodStatement.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
28409
+ if (methodStatement === undefined || (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) !== "CONSTRUCTOR") {
28410
+ return;
28411
+ }
28412
+ const classDefinition = input.scope.findClassDefinition(input.scope.getName());
28413
+ const superName = classDefinition === null || classDefinition === void 0 ? void 0 : classDefinition.getSuperClass();
28414
+ if (classDefinition === undefined || superName === undefined || superName.toUpperCase() === "OBJECT") {
28415
+ return;
28416
+ }
28417
+ const statements = method.findAllStatementNodes();
28418
+ for (const s of statements) {
28419
+ const type = s.get();
28420
+ if (type instanceof _statement_1.Unknown || type instanceof _statement_1.MacroCall
28421
+ || s.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition) {
28422
+ return;
28423
+ }
28424
+ }
28425
+ const callIndex = statements.findIndex(s => SuperConstructorCall.isSuperConstructorCall(s));
28426
+ // at most one issue is reported per constructor
28427
+ if (callIndex < 0) {
28428
+ const message = "The constructor of a subclass must call SUPER->CONSTRUCTOR";
28429
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodStatement.getFirstToken(), message));
28430
+ return;
28431
+ }
28432
+ // the statements before the call, the call itself can pass instance attributes, eg. previous = previous,
28433
+ // declarations can refer to instance attributes for typing, eg. DATA ls_row LIKE LINE OF mt_table
28434
+ const before = statements.slice(1, callIndex)
28435
+ .filter(s => !(s.get() instanceof _statement_1.NativeSQL) && !SuperConstructorCall.isDeclaration(s));
28436
+ const offending = SuperConstructorCall.findInstanceAccess(before, classDefinition, scopeNode, input);
28437
+ if (offending !== undefined) {
28438
+ const message = "Instance attributes, instance methods and ME can only be accessed after SUPER->CONSTRUCTOR is called";
28439
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, offending, message));
28440
+ }
28441
+ }
28442
+ static isDeclaration(statement) {
28443
+ const type = statement.get();
28444
+ return type instanceof Statements.Data
28445
+ || type instanceof Statements.DataBegin
28446
+ || type instanceof Statements.DataEnd
28447
+ || type instanceof Statements.Constant
28448
+ || type instanceof Statements.ConstantBegin
28449
+ || type instanceof Statements.ConstantEnd
28450
+ || type instanceof Statements.Type
28451
+ || type instanceof Statements.TypeBegin
28452
+ || type instanceof Statements.TypeEnd
28453
+ || type instanceof Statements.Static
28454
+ || type instanceof Statements.StaticBegin
28455
+ || type instanceof Statements.StaticEnd
28456
+ || type instanceof Statements.IncludeType
28457
+ || type instanceof Statements.FieldSymbol;
28458
+ }
28459
+ static isSuperConstructorCall(statement) {
28460
+ const tokens = statement.getTokens();
28461
+ for (let i = 0; i < tokens.length - 2; i++) {
28462
+ if (tokens[i].getStr().toUpperCase() === "SUPER"
28463
+ && tokens[i + 1].getStr() === "->"
28464
+ && tokens[i + 2].getStr().toUpperCase() === "CONSTRUCTOR") {
28465
+ return true;
28466
+ }
28467
+ }
28468
+ return false;
28469
+ }
28470
+ /** returns the first offending token */
28471
+ static findInstanceAccess(statements, classDefinition, scopeNode, input) {
28472
+ const instance = SuperConstructorCall.listInstanceMembers(classDefinition, input);
28473
+ const references = SuperConstructorCall.listReferences(scopeNode, input.filename);
28474
+ for (const statement of statements) {
28475
+ const tokens = statement.getTokens();
28476
+ for (let i = 0; i < tokens.length; i++) {
28477
+ const token = tokens[i];
28478
+ if (SuperConstructorCall.isMe(tokens, i)) {
28479
+ return token;
28480
+ }
28481
+ const resolved = references.get(SuperConstructorCall.key(token));
28482
+ if (resolved !== undefined
28483
+ && resolved.some(r => instance.has(r))
28484
+ && SuperConstructorCall.isOwnAccess(tokens, i)) {
28485
+ return token;
28486
+ }
28487
+ }
28488
+ }
28489
+ return undefined;
28490
+ }
28491
+ /** ME used as a value, me->component is allowed for constants and static components,
28492
+ * instance components are found via the references */
28493
+ static isMe(tokens, index) {
28494
+ var _a;
28495
+ const token = tokens[index];
28496
+ if (!(token instanceof identifier_1.Identifier) || token.getStr().toUpperCase() !== "ME") {
28497
+ return false;
28498
+ }
28499
+ const prev = tokens[index - 1];
28500
+ if (prev !== undefined && (prev instanceof dash_1.Dash || ["->", "=>", "~"].includes(prev.getStr()))) {
28501
+ return false;
28502
+ }
28503
+ return ((_a = tokens[index + 1]) === null || _a === void 0 ? void 0 : _a.getStr()) !== "->";
28504
+ }
28505
+ /** the member is accessed via the implicit or explicit self reference, not via another object or class */
28506
+ static isOwnAccess(tokens, index) {
28507
+ var _a;
28508
+ const prev = tokens[index - 1];
28509
+ if (prev === undefined) {
28510
+ return true;
28511
+ }
28512
+ else if (prev.getStr() === "->") {
28513
+ return ((_a = tokens[index - 2]) === null || _a === void 0 ? void 0 : _a.getStr().toUpperCase()) === "ME";
28514
+ }
28515
+ return !(prev instanceof dash_1.Dash || ["=>", "~"].includes(prev.getStr()));
28516
+ }
28517
+ /** instance attributes and methods of the class, its super classes and implemented interfaces */
28518
+ static listInstanceMembers(classDefinition, input) {
28519
+ const ret = new Set();
28520
+ const visited = new Set();
28521
+ const stack = [classDefinition];
28522
+ while (stack.length > 0) {
28523
+ const current = stack.pop();
28524
+ const name = current.getName().toUpperCase();
28525
+ if (visited.has(name)) {
28526
+ continue;
28527
+ }
28528
+ visited.add(name);
28529
+ for (const a of current.getAttributes().getInstance()) {
28530
+ ret.add(a);
28531
+ }
28532
+ for (const m of current.getMethodDefinitions().getAll()) {
28533
+ if (m.isStatic() === false) {
28534
+ ret.add(m);
28535
+ }
28536
+ }
28537
+ for (const i of current.getImplementing()) {
28538
+ const intf = input.scope.findInterfaceDefinition(i.name);
28539
+ if (intf !== undefined) {
28540
+ stack.push(intf);
28541
+ }
28542
+ }
28543
+ if ("getSuperClass" in current) {
28544
+ const sup = input.scope.findClassDefinition(current.getSuperClass());
28545
+ if (sup !== undefined) {
28546
+ stack.push(sup);
28547
+ }
28548
+ }
28549
+ }
28550
+ return ret;
28551
+ }
28552
+ /** resolved references of the method body by token position */
28553
+ static listReferences(node, filename) {
28554
+ var _a;
28555
+ const ret = new Map();
28556
+ const stack = node ? [node] : [];
28557
+ while (stack.length > 0) {
28558
+ const current = stack.pop();
28559
+ stack.push(...current.getChildren());
28560
+ for (const r of current.getData().references) {
28561
+ if (r.resolved === undefined || r.position.getFilename() !== filename) {
28562
+ continue;
28563
+ }
28564
+ const key = SuperConstructorCall.key(r.position.getToken());
28565
+ const list = (_a = ret.get(key)) !== null && _a !== void 0 ? _a : [];
28566
+ list.push(r.resolved);
28567
+ ret.set(key, list);
28568
+ }
28569
+ }
28570
+ return ret;
28571
+ }
28572
+ static key(token) {
28573
+ return token.getRow() + ":" + token.getCol();
28574
+ }
28575
+ }
28576
+ exports.SuperConstructorCall = SuperConstructorCall;
28577
+ //# sourceMappingURL=_super_constructor_call.js.map
28578
+
28579
+ /***/ },
28580
+
28351
28581
  /***/ "../core/build/src/abap/5_syntax/_syntax_input.js"
28352
28582
  /*!********************************************************!*\
28353
28583
  !*** ../core/build/src/abap/5_syntax/_syntax_input.js ***!
@@ -38260,8 +38490,8 @@ class ValueBody {
38260
38490
  }
38261
38491
  for (const s of foo.findDirectExpressions(Expressions.Source)) {
38262
38492
  const sourceType = source_1.Source.runSyntax(s, input, rowType);
38263
- if (rowType instanceof basic_1.StringType && sourceType instanceof basic_1.CharacterType) {
38264
- const message = "VALUE, source type CharacterType not compatible with StringType";
38493
+ if ((rowType instanceof basic_1.StringType || rowType instanceof basic_1.XStringType) && sourceType instanceof basic_1.CharacterType) {
38494
+ const message = "VALUE, source type CharacterType not compatible with " + rowType.constructor.name;
38265
38495
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
38266
38496
  }
38267
38497
  else if (this.insertsUsingTableKey(targetType)) {
@@ -39058,6 +39288,11 @@ class Append {
39058
39288
  let targetType = undefined;
39059
39289
  const target = node.findDirectExpression(Expressions.Target);
39060
39290
  if (target) {
39291
+ if (target.findDirectExpression(Expressions.TableExpression) !== undefined) {
39292
+ const message = "APPEND, table expression not allowed in target";
39293
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, target.getFirstToken(), message));
39294
+ return;
39295
+ }
39061
39296
  targetType = target_1.Target.runSyntax(target, input);
39062
39297
  }
39063
39298
  // a hashed table has no index, APPEND adds at the end
@@ -46108,7 +46343,7 @@ const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/b
46108
46343
  class Raise {
46109
46344
  runSyntax(node, input) {
46110
46345
  // todo
46111
- var _a, _b, _c, _d, _e, _f;
46346
+ var _a, _b, _c, _d, _e, _f, _g;
46112
46347
  const helper = new _object_oriented_1.ObjectOriented(input.scope);
46113
46348
  let method;
46114
46349
  const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
@@ -46124,7 +46359,12 @@ class Raise {
46124
46359
  if (found === null || found === void 0 ? void 0 : found.id) {
46125
46360
  input.scope.addReference(classTok, found.id, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
46126
46361
  const def = input.scope.findObjectDefinition(className);
46127
- method = (_b = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _b === void 0 ? void 0 : _b.method;
46362
+ if (((_b = input.scope.findClassDefinition(className)) === null || _b === void 0 ? void 0 : _b.isAbstract()) === true) {
46363
+ const message = className + " is abstract, cannot be instantiated";
46364
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, classTok, message));
46365
+ return;
46366
+ }
46367
+ method = (_c = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _c === void 0 ? void 0 : _c.method;
46128
46368
  }
46129
46369
  else if (input.scope.getDDIC().inErrorNamespace(className) === false) {
46130
46370
  const extra = { ooName: className, ooType: "Void" };
@@ -46148,7 +46388,7 @@ class Raise {
46148
46388
  }
46149
46389
  else if (type instanceof basic_1.ObjectReferenceType) {
46150
46390
  const def = input.scope.findObjectDefinition(type.getIdentifierName());
46151
- method = (_c = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _c === void 0 ? void 0 : _c.method;
46391
+ method = (_d = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _d === void 0 ? void 0 : _d.method;
46152
46392
  }
46153
46393
  else if (type !== undefined) {
46154
46394
  const message = "RAISE EXCEPTION, must be object reference, got " + type.constructor.name;
@@ -46177,10 +46417,10 @@ class Raise {
46177
46417
  for (const s of node.findDirectExpressions(Expressions.MessageSource)) {
46178
46418
  message_source_1.MessageSource.runSyntax(s, input);
46179
46419
  }
46180
- const id = (_d = node.findExpressionAfterToken("ID")) === null || _d === void 0 ? void 0 : _d.concatTokens();
46181
- let number = (_e = node.findDirectExpression(Expressions.MessageNumber)) === null || _e === void 0 ? void 0 : _e.concatTokens();
46420
+ const id = (_e = node.findExpressionAfterToken("ID")) === null || _e === void 0 ? void 0 : _e.concatTokens();
46421
+ let number = (_f = node.findDirectExpression(Expressions.MessageNumber)) === null || _f === void 0 ? void 0 : _f.concatTokens();
46182
46422
  if (number === undefined) {
46183
- const num = (_f = node.findExpressionAfterToken("NUMBER")) === null || _f === void 0 ? void 0 : _f.concatTokens();
46423
+ const num = (_g = node.findExpressionAfterToken("NUMBER")) === null || _g === void 0 ? void 0 : _g.concatTokens();
46184
46424
  if (num === null || num === void 0 ? void 0 : num.startsWith("'")) {
46185
46425
  number = num.substring(1, num.length - 1).toUpperCase();
46186
46426
  }
@@ -50804,6 +51044,7 @@ const field_group_1 = __webpack_require__(/*! ./statements/field_group */ "../co
50804
51044
  const stuff_1 = __webpack_require__(/*! ../../stuff */ "../core/build/src/stuff.js");
50805
51045
  const _loop_table_change_1 = __webpack_require__(/*! ./_loop_table_change */ "../core/build/src/abap/5_syntax/_loop_table_change.js");
50806
51046
  const _sorted_key_write_1 = __webpack_require__(/*! ./_sorted_key_write */ "../core/build/src/abap/5_syntax/_sorted_key_write.js");
51047
+ const _super_constructor_call_1 = __webpack_require__(/*! ./_super_constructor_call */ "../core/build/src/abap/5_syntax/_super_constructor_call.js");
50807
51048
  // -----------------------------------
50808
51049
  const map = {};
50809
51050
  function addToMap(handler) {
@@ -51150,6 +51391,9 @@ class SyntaxLogic {
51150
51391
  else if (stru instanceof Structures.Try) {
51151
51392
  try_1.Try.runSyntax(node, input);
51152
51393
  }
51394
+ else if (stru instanceof Structures.Method) {
51395
+ this.currentMethod = node;
51396
+ }
51153
51397
  return false;
51154
51398
  }
51155
51399
  updateScopeStatement(node) {
@@ -51197,12 +51441,17 @@ class SyntaxLogic {
51197
51441
  this.scope.pop(node.getLastToken().getEnd());
51198
51442
  }
51199
51443
  else if (s instanceof Statements.EndMethod) {
51444
+ let popped = undefined;
51200
51445
  if (this.scope.getType() === _scope_type_1.ScopeType.Method) {
51201
- this.scope.pop(node.getLastToken().getEnd());
51446
+ popped = this.scope.pop(node.getLastToken().getEnd());
51202
51447
  }
51203
51448
  if (this.scope.getType() === _scope_type_1.ScopeType.MethodInstance) {
51204
- this.scope.pop(node.getLastToken().getEnd());
51449
+ popped = this.scope.pop(node.getLastToken().getEnd());
51450
+ }
51451
+ if (this.currentMethod !== undefined && popped !== undefined) {
51452
+ _super_constructor_call_1.SuperConstructorCall.check(this.currentMethod, popped.getTop(), input);
51205
51453
  }
51454
+ this.currentMethod = undefined;
51206
51455
  }
51207
51456
  }
51208
51457
  updateSelectionEventScope(node) {
@@ -73639,7 +73888,7 @@ class Registry {
73639
73888
  }
73640
73889
  static abaplintVersion() {
73641
73890
  // magic, see build script "version.js"
73642
- return "2.120.105";
73891
+ return "2.120.107";
73643
73892
  }
73644
73893
  getDDICReferences() {
73645
73894
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.105",
3
+ "version": "2.120.107",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.105",
42
+ "@abaplint/core": "^2.120.107",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",