@abaplint/cli 2.101.11 → 2.101.13

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 +181 -24
  2. package/package.json +5 -5
package/build/cli.js CHANGED
@@ -14704,7 +14704,7 @@ class ReadTable {
14704
14704
  const from = (0, combi_1.seq)("FROM", expressions_1.Source);
14705
14705
  const fields = (0, combi_1.plus)((0, combi_1.alt)((0, combi_1.seq)("INTO", (0, combi_1.failStar)()), expressions_1.FieldSub));
14706
14706
  const perm = (0, combi_1.per)((0, combi_1.alt)(index, key, from), expressions_1.ReadTableTarget, using, comparing, "CASTING", "TRANSPORTING ALL FIELDS", (0, combi_1.seq)("TRANSPORTING", (0, combi_1.altPrio)(expressions_1.Dynamic, fields)), "BINARY SEARCH");
14707
- return (0, combi_1.seq)("READ TABLE", (0, combi_1.alt)((0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source), expressions_1.SimpleSource2), (0, combi_1.opt)(perm));
14707
+ return (0, combi_1.seq)("READ TABLE", (0, combi_1.alt)(expressions_1.SimpleSource2, (0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source)), (0, combi_1.opt)(perm));
14708
14708
  }
14709
14709
  }
14710
14710
  exports.ReadTable = ReadTable;
@@ -20405,7 +20405,7 @@ BuiltIn.methods = [
20405
20405
  {
20406
20406
  name: "XSTRLEN",
20407
20407
  mandatory: {
20408
- "val": new basic_1.XStringType(),
20408
+ "val": new basic_1.XSequenceType(),
20409
20409
  },
20410
20410
  return: new basic_1.IntegerType(),
20411
20411
  },
@@ -21624,7 +21624,7 @@ class TypeUtils {
21624
21624
  return false;
21625
21625
  }
21626
21626
  isAssignableStrict(source, target) {
21627
- var _a, _b, _c, _d, _e;
21627
+ var _a, _b, _c, _d, _e, _f;
21628
21628
  /*
21629
21629
  console.dir(source);
21630
21630
  console.dir(target);
@@ -21663,8 +21663,14 @@ class TypeUtils {
21663
21663
  return false;
21664
21664
  }
21665
21665
  }
21666
- else if (source instanceof basic_1.StringType && target instanceof basic_1.StructureType) {
21667
- if (this.structureContainsString(target)) {
21666
+ else if (source instanceof basic_1.StringType) {
21667
+ if (target instanceof basic_1.StructureType && this.structureContainsString(target)) {
21668
+ return false;
21669
+ }
21670
+ else if (target instanceof basic_1.XSequenceType) {
21671
+ if (((_f = source.getAbstractTypeData()) === null || _f === void 0 ? void 0 : _f.derivedFromConstant) === true) {
21672
+ return true;
21673
+ }
21668
21674
  return false;
21669
21675
  }
21670
21676
  return true;
@@ -21687,6 +21693,11 @@ class TypeUtils {
21687
21693
  return false;
21688
21694
  }
21689
21695
  }
21696
+ else if (source instanceof basic_1.XStringType) {
21697
+ if (target instanceof basic_1.CLikeType) {
21698
+ return false;
21699
+ }
21700
+ }
21690
21701
  return this.isAssignable(source, target);
21691
21702
  }
21692
21703
  isAssignable(source, target) {
@@ -23315,6 +23326,9 @@ class Constant {
23315
23326
  }
23316
23327
  return new basic_1.CharacterType(len, { derivedFromConstant: true });
23317
23328
  }
23329
+ else if (node.getFirstToken().getStr().startsWith("`")) {
23330
+ return new basic_1.StringType({ qualifiedName: "STRING", derivedFromConstant: true });
23331
+ }
23318
23332
  else {
23319
23333
  return new basic_1.StringType({ qualifiedName: "STRING" });
23320
23334
  }
@@ -25515,27 +25529,36 @@ class Source {
25515
25529
  {
25516
25530
  const foundType = this.determineType(node, scope, filename, targetType);
25517
25531
  const bodyType = new reduce_body_1.ReduceBody().runSyntax(node.findDirectExpression(Expressions.ReduceBody), scope, filename, foundType);
25518
- if (foundType === undefined || foundType.isGeneric() === true) {
25532
+ if (foundType === undefined || foundType.isGeneric()) {
25519
25533
  this.addIfInferred(node, scope, filename, bodyType);
25520
25534
  }
25535
+ else {
25536
+ this.addIfInferred(node, scope, filename, foundType);
25537
+ }
25521
25538
  return foundType ? foundType : bodyType;
25522
25539
  }
25523
25540
  case "SWITCH":
25524
25541
  {
25525
25542
  const foundType = this.determineType(node, scope, filename, targetType);
25526
25543
  const bodyType = new switch_body_1.SwitchBody().runSyntax(node.findDirectExpression(Expressions.SwitchBody), scope, filename);
25527
- if (foundType === undefined || foundType.isGeneric() === true) {
25544
+ if (foundType === undefined || foundType.isGeneric()) {
25528
25545
  this.addIfInferred(node, scope, filename, bodyType);
25529
25546
  }
25547
+ else {
25548
+ this.addIfInferred(node, scope, filename, foundType);
25549
+ }
25530
25550
  return foundType ? foundType : bodyType;
25531
25551
  }
25532
25552
  case "COND":
25533
25553
  {
25534
25554
  const foundType = this.determineType(node, scope, filename, targetType);
25535
25555
  const bodyType = new cond_body_1.CondBody().runSyntax(node.findDirectExpression(Expressions.CondBody), scope, filename);
25536
- if (foundType === undefined || foundType.isGeneric() === true) {
25556
+ if (foundType === undefined || foundType.isGeneric()) {
25537
25557
  this.addIfInferred(node, scope, filename, bodyType);
25538
25558
  }
25559
+ else {
25560
+ this.addIfInferred(node, scope, filename, foundType);
25561
+ }
25539
25562
  return foundType ? foundType : bodyType;
25540
25563
  }
25541
25564
  case "CONV":
@@ -25672,10 +25695,12 @@ class Source {
25672
25695
  throw new Error("determineType, child TypeNameOrInfer not found");
25673
25696
  }
25674
25697
  else if (typeName === "#" && targetType) {
25675
- const found = basic.lookupQualifiedName(targetType.getQualifiedName());
25698
+ // const found = basic.lookupQualifiedName(targetType.getQualifiedName());
25699
+ /*
25676
25700
  if (found) {
25677
- scope.addReference(typeToken, found, _reference_1.ReferenceType.InferredType, filename);
25701
+ scope.addReference(typeToken, found, ReferenceType.InferredType, filename);
25678
25702
  }
25703
+ */
25679
25704
  return targetType;
25680
25705
  }
25681
25706
  if (typeName !== "#" && typeToken) {
@@ -28610,10 +28635,15 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
28610
28635
  const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
28611
28636
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
28612
28637
  const inline_data_1 = __webpack_require__(/*! ../expressions/inline_data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/inline_data.js");
28638
+ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
28613
28639
  class GetBit {
28614
28640
  runSyntax(node, scope, filename) {
28641
+ let lastType = undefined;
28615
28642
  for (const s of node.findDirectExpressions(Expressions.Source)) {
28616
- new source_1.Source().runSyntax(s, scope, filename);
28643
+ lastType = new source_1.Source().runSyntax(s, scope, filename);
28644
+ }
28645
+ if (lastType && new _type_utils_1.TypeUtils(scope).isHexLike(lastType) === false) {
28646
+ throw new Error("Input must be byte-like");
28617
28647
  }
28618
28648
  for (const t of node.findDirectExpressions(Expressions.Target)) {
28619
28649
  const inline = t === null || t === void 0 ? void 0 : t.findDirectExpression(Expressions.InlineData);
@@ -30488,13 +30518,17 @@ exports.SetBit = void 0;
30488
30518
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
30489
30519
  const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
30490
30520
  const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
30521
+ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
30491
30522
  class SetBit {
30492
30523
  runSyntax(node, scope, filename) {
30493
30524
  for (const s of node.findDirectExpressions(Expressions.Source)) {
30494
30525
  new source_1.Source().runSyntax(s, scope, filename);
30495
30526
  }
30496
30527
  for (const t of node.findDirectExpressions(Expressions.Target)) {
30497
- new target_1.Target().runSyntax(t, scope, filename);
30528
+ const typ = new target_1.Target().runSyntax(t, scope, filename);
30529
+ if (typ && new _type_utils_1.TypeUtils(scope).isHexLike(typ) === false) {
30530
+ throw new Error("Input must be byte-like");
30531
+ }
30498
30532
  }
30499
30533
  }
30500
30534
  }
@@ -39984,6 +40018,9 @@ class LSPUtils {
39984
40018
  static tokenToRange(token) {
39985
40019
  return LServer.Range.create(token.getStart().getRow() - 1, token.getStart().getCol() - 1, token.getEnd().getRow() - 1, token.getEnd().getCol() - 1);
39986
40020
  }
40021
+ static positionToLS(pos) {
40022
+ return LServer.Position.create(pos.getRow() - 1, pos.getCol() - 1);
40023
+ }
39987
40024
  static identiferToLocation(identifier) {
39988
40025
  return {
39989
40026
  uri: identifier.getFilename(),
@@ -40143,7 +40180,7 @@ class CodeLens {
40143
40180
  constructor(reg) {
40144
40181
  this.reg = reg;
40145
40182
  }
40146
- list(textDocument) {
40183
+ list(textDocument, settings = { messageText: true }) {
40147
40184
  var _a;
40148
40185
  const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri);
40149
40186
  if (file === undefined) {
@@ -40155,14 +40192,22 @@ class CodeLens {
40155
40192
  }
40156
40193
  new syntax_1.SyntaxLogic(this.reg, obj).run();
40157
40194
  const ret = [];
40158
- const list = this.reg.getMSAGReferences().listByFilename(file.getFilename());
40159
- for (const l of list) {
40160
- const msag = this.reg.getObject("MSAG", l.messageClass);
40161
- if (msag === undefined) {
40162
- continue;
40195
+ if (settings.messageText === true) {
40196
+ const list = this.reg.getMSAGReferences().listByFilename(file.getFilename());
40197
+ for (const l of list) {
40198
+ const msag = this.reg.getObject("MSAG", l.messageClass);
40199
+ if (msag === undefined) {
40200
+ continue;
40201
+ }
40202
+ const text = (_a = msag.getByNumber(l.number)) === null || _a === void 0 ? void 0 : _a.getMessage();
40203
+ if (text === undefined) {
40204
+ continue;
40205
+ }
40206
+ ret.push({
40207
+ range: _lsp_utils_1.LSPUtils.tokenToRange(l.token),
40208
+ command: LServer.Command.create(text, ""),
40209
+ });
40163
40210
  }
40164
- const text = (_a = msag.getByNumber(l.number)) === null || _a === void 0 ? void 0 : _a.getMessage();
40165
- ret.push(LServer.CodeLens.create(_lsp_utils_1.LSPUtils.tokenToRange(l.token), text));
40166
40211
  }
40167
40212
  return ret;
40168
40213
  }
@@ -40844,6 +40889,81 @@ exports.Implementation = Implementation;
40844
40889
 
40845
40890
  /***/ }),
40846
40891
 
40892
+ /***/ "./node_modules/@abaplint/core/build/src/lsp/inlay_hints.js":
40893
+ /*!******************************************************************!*\
40894
+ !*** ./node_modules/@abaplint/core/build/src/lsp/inlay_hints.js ***!
40895
+ \******************************************************************/
40896
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
40897
+
40898
+ "use strict";
40899
+
40900
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
40901
+ exports.InlayHints = void 0;
40902
+ const LServer = __webpack_require__(/*! vscode-languageserver-types */ "./node_modules/vscode-languageserver-types/lib/esm/main.js");
40903
+ const _lsp_utils_1 = __webpack_require__(/*! ./_lsp_utils */ "./node_modules/@abaplint/core/build/src/lsp/_lsp_utils.js");
40904
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
40905
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
40906
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
40907
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
40908
+ const types_1 = __webpack_require__(/*! ../abap/types */ "./node_modules/@abaplint/core/build/src/abap/types/index.js");
40909
+ class InlayHints {
40910
+ constructor(reg) {
40911
+ this.reg = reg;
40912
+ }
40913
+ list(textDocument, settings = { inferredTypes: true }) {
40914
+ const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri);
40915
+ if (file === undefined) {
40916
+ return [];
40917
+ }
40918
+ const obj = this.reg.findObjectForFile(file);
40919
+ if (obj === undefined || !(obj instanceof _abap_object_1.ABAPObject)) {
40920
+ return [];
40921
+ }
40922
+ const top = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop();
40923
+ const ret = [];
40924
+ if (settings.inferredTypes === true) {
40925
+ const implicit = this.findImplicitReferences(top);
40926
+ for (const i of implicit) {
40927
+ let label = undefined;
40928
+ if (i.resolved instanceof _typed_identifier_1.TypedIdentifier) {
40929
+ label = "TYPE " + i.resolved.getType().toABAP();
40930
+ }
40931
+ else if (i.resolved instanceof types_1.ClassDefinition) {
40932
+ label = "TYPE REF TO " + i.resolved.getName();
40933
+ }
40934
+ if (label === undefined) {
40935
+ continue;
40936
+ }
40937
+ ret.push({
40938
+ label: label,
40939
+ tooltip: "Inferred type",
40940
+ kind: LServer.InlayHintKind.Type,
40941
+ paddingLeft: true,
40942
+ paddingRight: true,
40943
+ position: _lsp_utils_1.LSPUtils.positionToLS(i.position.getEnd()),
40944
+ });
40945
+ }
40946
+ }
40947
+ return ret;
40948
+ }
40949
+ findImplicitReferences(node) {
40950
+ const ret = [];
40951
+ for (const r of node.getData().references) {
40952
+ if (r.referenceType === _reference_1.ReferenceType.InferredType) {
40953
+ ret.push(r);
40954
+ }
40955
+ }
40956
+ for (const c of node.getChildren()) {
40957
+ ret.push(...this.findImplicitReferences(c));
40958
+ }
40959
+ return ret;
40960
+ }
40961
+ }
40962
+ exports.InlayHints = InlayHints;
40963
+ //# sourceMappingURL=inlay_hints.js.map
40964
+
40965
+ /***/ }),
40966
+
40847
40967
  /***/ "./node_modules/@abaplint/core/build/src/lsp/language_server.js":
40848
40968
  /*!**********************************************************************!*\
40849
40969
  !*** ./node_modules/@abaplint/core/build/src/lsp/language_server.js ***!
@@ -40870,6 +40990,7 @@ const implementation_1 = __webpack_require__(/*! ./implementation */ "./node_mod
40870
40990
  const semantic_1 = __webpack_require__(/*! ./semantic */ "./node_modules/@abaplint/core/build/src/lsp/semantic.js");
40871
40991
  const statement_flow_1 = __webpack_require__(/*! ../abap/flow/statement_flow */ "./node_modules/@abaplint/core/build/src/abap/flow/statement_flow.js");
40872
40992
  const code_lens_1 = __webpack_require__(/*! ./code_lens */ "./node_modules/@abaplint/core/build/src/lsp/code_lens.js");
40993
+ const inlay_hints_1 = __webpack_require__(/*! ./inlay_hints */ "./node_modules/@abaplint/core/build/src/lsp/inlay_hints.js");
40873
40994
  // note Ranges are zero based in LSP,
40874
40995
  // https://github.com/microsoft/language-server-protocol/blob/main/versions/protocol-2-x.md#range
40875
40996
  // but 1 based in abaplint
@@ -40951,8 +41072,12 @@ class LanguageServer {
40951
41072
  return new semantic_1.SemanticHighlighting(this.reg).semanticTokensRange(range);
40952
41073
  }
40953
41074
  // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens
40954
- codeLens(textDocument) {
40955
- return new code_lens_1.CodeLens(this.reg).list(textDocument);
41075
+ codeLens(textDocument, settings) {
41076
+ return new code_lens_1.CodeLens(this.reg).list(textDocument, settings);
41077
+ }
41078
+ // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint
41079
+ inlayHints(textDocument, settings) {
41080
+ return new inlay_hints_1.InlayHints(this.reg).list(textDocument, settings);
40956
41081
  }
40957
41082
  ////////////////////////////////////////
40958
41083
  // ______ _
@@ -48161,7 +48286,7 @@ class Registry {
48161
48286
  }
48162
48287
  static abaplintVersion() {
48163
48288
  // magic, see build script "version.sh"
48164
- return "2.101.11";
48289
+ return "2.101.13";
48165
48290
  }
48166
48291
  getDDICReferences() {
48167
48292
  return this.ddicReferences;
@@ -53250,6 +53375,10 @@ Make sure to test the downported code, it might not always be completely correct
53250
53375
  if (found) {
53251
53376
  return found;
53252
53377
  }
53378
+ found = this.downportReadTable(high, lowFile, highSyntax);
53379
+ if (found) {
53380
+ return found;
53381
+ }
53253
53382
  return undefined;
53254
53383
  }
53255
53384
  //////////////////////////////////////////
@@ -53545,6 +53674,22 @@ ${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
53545
53674
  }
53546
53675
  return undefined;
53547
53676
  }
53677
+ downportReadTable(high, lowFile, highSyntax) {
53678
+ if (!(high.get() instanceof Statements.ReadTable)) {
53679
+ return undefined;
53680
+ }
53681
+ const source = high.findExpressionAfterToken("TABLE");
53682
+ if ((source === null || source === void 0 ? void 0 : source.get()) instanceof Expressions.Source) {
53683
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
53684
+ const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
53685
+ const firstToken = high.getFirstToken();
53686
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA(${uniqueName}) = ${source.concatTokens()}.\n` + indentation);
53687
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
53688
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
53689
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline table source", this.getMetadata().key, this.conf.severity, fix);
53690
+ }
53691
+ return undefined;
53692
+ }
53548
53693
  replaceInsertExpression(high, lowFile, highSyntax) {
53549
53694
  if (!(high.get() instanceof Statements.InsertInternal)) {
53550
53695
  return undefined;
@@ -70647,7 +70792,7 @@ function readDocType(xmlData, i){
70647
70792
  i += 7;
70648
70793
  [entityName, val,i] = readEntityExp(xmlData,i+1);
70649
70794
  if(val.indexOf("&") === -1) //Parameter entities are not supported
70650
- entities[ entityName ] = {
70795
+ entities[ validateEntityName(entityName) ] = {
70651
70796
  regx : RegExp( `&${entityName};`,"g"),
70652
70797
  val: val
70653
70798
  };
@@ -70768,6 +70913,18 @@ function isNotation(xmlData, i){
70768
70913
  return false
70769
70914
  }
70770
70915
 
70916
+ //an entity name should not contains special characters that may be used in regex
70917
+ //Eg !?\\\/[]$%{}^&*()<>
70918
+ const specialChar = "!?\\\/[]$%{}^&*()<>";
70919
+
70920
+ function validateEntityName(name){
70921
+ for (let i = 0; i < specialChar.length; i++) {
70922
+ const ch = specialChar[i];
70923
+ if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
70924
+ }
70925
+ return name;
70926
+ }
70927
+
70771
70928
  module.exports = readDocType;
70772
70929
 
70773
70930
  /***/ }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.101.11",
3
+ "version": "2.101.13",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.101.11",
41
+ "@abaplint/core": "^2.101.13",
42
42
  "@types/chai": "^4.3.5",
43
43
  "@types/glob": "^7.2.0",
44
44
  "@types/minimist": "^1.2.2",
@@ -47,16 +47,16 @@
47
47
  "@types/progress": "^2.0.5",
48
48
  "chai": "^4.3.7",
49
49
  "chalk": "^5.2.0",
50
- "eslint": "^8.41.0",
50
+ "eslint": "^8.42.0",
51
51
  "glob": "^7.2.3",
52
52
  "json5": "^2.2.3",
53
- "memfs": "^3.5.1",
53
+ "memfs": "^3.5.2",
54
54
  "minimist": "^1.2.8",
55
55
  "mocha": "^10.2.0",
56
56
  "progress": "^2.0.3",
57
57
  "typescript": "^5.1.3",
58
58
  "webpack": "^5.85.0",
59
- "webpack-cli": "^5.1.1",
59
+ "webpack-cli": "^5.1.3",
60
60
  "xml-js": "^1.6.11"
61
61
  },
62
62
  "dependencies": {}