@abaplint/transpiler-cli 2.14.38 → 2.14.39

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/bundle.js +335 -30
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -4526,7 +4526,7 @@ function dynComp(...inside) {
4526
4526
  return (0, combi_1.ver)(version_1.Release.v757, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), dynIdent, dynInside, ...inside, dynClose));
4527
4527
  }
4528
4528
  function dynAttr() {
4529
- return (0, combi_1.ver)(version_1.Release.v757, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.InstanceArrow), dynIdent, dynInside, dynClose));
4529
+ return (0, combi_1.ver)(version_1.Release.v756, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.InstanceArrow), dynIdent, dynInside, dynClose));
4530
4530
  }
4531
4531
  //# sourceMappingURL=_dynamic_access.js.map
4532
4532
 
@@ -30033,12 +30033,25 @@ exports.SuperConstructorCall = SuperConstructorCall;
30033
30033
  Object.defineProperty(exports, "__esModule", ({ value: true }));
30034
30034
  exports.CheckSyntaxKey = void 0;
30035
30035
  exports.syntaxIssue = syntaxIssue;
30036
+ exports.dataObjectBeforeStaticArrow = dataObjectBeforeStaticArrow;
30036
30037
  const issue_1 = __webpack_require__(/*! ../../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
30037
30038
  const severity_1 = __webpack_require__(/*! ../../severity */ "./node_modules/@abaplint/core/build/src/severity.js");
30038
30039
  exports.CheckSyntaxKey = "check_syntax";
30039
30040
  function syntaxIssue(input, token, message, fix) {
30040
30041
  return issue_1.Issue.atTokenFilename(input.filename, token, message, exports.CheckSyntaxKey, severity_1.Severity.Error, fix);
30041
30042
  }
30043
+ /** the name in front of "=>" is looked up as a class or interface only, data objects are not considered.
30044
+ * Call when no class or interface of the name was found: if a data object of the name is visible,
30045
+ * it is not an unknown global class, so report it. Returns true if an issue was added */
30046
+ function dataObjectBeforeStaticArrow(input, token) {
30047
+ const name = token.getStr();
30048
+ if (input.scope.findVariable(name) === undefined) {
30049
+ return false;
30050
+ }
30051
+ const message = `"${name}" is not a class or interface, => cannot be used with a data object`;
30052
+ input.issues.push(syntaxIssue(input, token, message));
30053
+ return true;
30054
+ }
30042
30055
  //# sourceMappingURL=_syntax_input.js.map
30043
30056
 
30044
30057
  /***/ },
@@ -34836,7 +34849,7 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modu
34836
34849
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
34837
34850
  class FieldChain {
34838
34851
  static runSyntax(node, input, refType, allowGenericDeference = false) {
34839
- var _a, _b, _c;
34852
+ var _a, _b, _c, _d;
34840
34853
  if (((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SourceField
34841
34854
  && node.findDirectExpression(Expressions.ComponentName)) {
34842
34855
  // workaround for names with dashes, eg. "sy-repid"
@@ -34907,7 +34920,11 @@ class FieldChain {
34907
34920
  if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
34908
34921
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
34909
34922
  }
34910
- if (!(context instanceof basic_1.ObjectReferenceType)
34923
+ if (context instanceof basic_1.GenericObjectReferenceType && ((_d = children[i + 1]) === null || _d === void 0 ? void 0 : _d.get()) instanceof tokens_1.ParenLeft) {
34924
+ // dynamic attribute, oref->(name), the attribute is resolved at runtime
34925
+ context = basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
34926
+ }
34927
+ else if (!(context instanceof basic_1.ObjectReferenceType)
34911
34928
  && !(context instanceof basic_1.DataReference)
34912
34929
  && !(context instanceof basic_1.VoidType)) {
34913
34930
  const message = "Not an object reference, field chain";
@@ -34991,6 +35008,9 @@ class FieldChain {
34991
35008
  input.scope.addReference(classTok, found.id, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
34992
35009
  return new basic_1.ObjectReferenceType(found.id);
34993
35010
  }
35011
+ else if ((0, _syntax_input_1.dataObjectBeforeStaticArrow)(input, classTok)) {
35012
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
35013
+ }
34994
35014
  else if (input.scope.getDDIC().inErrorNamespace(classNam) === false) {
34995
35015
  input.scope.addReference(classTok, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename, { ooName: classNam.toUpperCase() });
34996
35016
  return basic_1.VoidType.get(classNam);
@@ -36648,7 +36668,10 @@ class MethodCallChain {
36648
36668
  const token = first.getFirstToken();
36649
36669
  const className = token.getStr();
36650
36670
  const classDefinition = input.scope.findObjectDefinition(className);
36651
- if (classDefinition === undefined && input.scope.getDDIC().inErrorNamespace(className) === false) {
36671
+ if (classDefinition === undefined && (0, _syntax_input_1.dataObjectBeforeStaticArrow)(input, token)) {
36672
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
36673
+ }
36674
+ else if (classDefinition === undefined && input.scope.getDDIC().inErrorNamespace(className) === false) {
36652
36675
  const extra = { ooName: className, ooType: "Void" };
36653
36676
  input.scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename, extra);
36654
36677
  return basic_1.VoidType.get(className);
@@ -37559,7 +37582,10 @@ class MethodSource {
37559
37582
  const token = first.getFirstToken();
37560
37583
  const className = token.getStr();
37561
37584
  const classDefinition = input.scope.findObjectDefinition(className);
37562
- if (classDefinition === undefined && input.scope.getDDIC().inErrorNamespace(className) === false) {
37585
+ if (classDefinition === undefined && (0, _syntax_input_1.dataObjectBeforeStaticArrow)(input, token)) {
37586
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
37587
+ }
37588
+ else if (classDefinition === undefined && input.scope.getDDIC().inErrorNamespace(className) === false) {
37563
37589
  const extra = { ooName: className, ooType: "Void" };
37564
37590
  input.scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename, extra);
37565
37591
  return basic_1.VoidType.get(className);
@@ -40379,6 +40405,7 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modu
40379
40405
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
40380
40406
  class Target {
40381
40407
  static runSyntax(node, input) {
40408
+ var _a;
40382
40409
  const concat = node.concatTokens();
40383
40410
  if (concat.includes("-")) {
40384
40411
  // workaround for names with dashes
@@ -40429,7 +40456,11 @@ class Target {
40429
40456
  if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
40430
40457
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
40431
40458
  }
40432
- if (!(context instanceof basic_1.ObjectReferenceType)
40459
+ if (context instanceof basic_1.GenericObjectReferenceType && ((_a = children[currentIndex]) === null || _a === void 0 ? void 0 : _a.get()) instanceof tokens_1.ParenLeft) {
40460
+ // dynamic attribute, oref->(name), the attribute is resolved at runtime
40461
+ context = basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
40462
+ }
40463
+ else if (!(context instanceof basic_1.ObjectReferenceType)
40433
40464
  && !(context instanceof basic_1.DataReference)
40434
40465
  && !(context instanceof basic_1.VoidType)) {
40435
40466
  const message = "Not an object reference, target";
@@ -40548,6 +40579,9 @@ class Target {
40548
40579
  input.scope.addReference(token, found, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
40549
40580
  return new basic_1.ObjectReferenceType(found);
40550
40581
  }
40582
+ else if ((0, _syntax_input_1.dataObjectBeforeStaticArrow)(input, token)) {
40583
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
40584
+ }
40551
40585
  else if (input.scope.getDDIC().inErrorNamespace(name) === false) {
40552
40586
  input.scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename, { ooName: name, ooType: "CLAS" });
40553
40587
  return basic_1.VoidType.get(name);
@@ -41711,6 +41745,7 @@ var __importStar = (this && this.__importStar) || (function () {
41711
41745
  Object.defineProperty(exports, "__esModule", ({ value: true }));
41712
41746
  exports.Append = void 0;
41713
41747
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
41748
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
41714
41749
  const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
41715
41750
  const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
41716
41751
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
@@ -41781,9 +41816,17 @@ class Append {
41781
41816
  let sourceType = source_1.Source.runSyntax(source, input, rowType);
41782
41817
  if (node.findDirectTokenByText("LINES")) {
41783
41818
  // hmm, checking only the row types are compatible will not check the table type, e.g. sorted or hashed
41819
+ // a generically typed dref->* is checked at runtime, except FROM idx1 TO idx2, which expect an index table
41820
+ const genericLines = sourceType instanceof basic_1.DataType
41821
+ && source.concatTokens().replace(/\s/g, "").endsWith("->*")
41822
+ && node.findDirectTokenByText("FROM") === undefined
41823
+ && node.getChildren().filter(c => c instanceof nodes_1.TokenNode && c.getFirstToken().getStr().toUpperCase() === "TO").length === 1;
41784
41824
  if (sourceType instanceof basic_1.TableType) {
41785
41825
  sourceType = sourceType.getRowType();
41786
41826
  }
41827
+ else if (genericLines) {
41828
+ sourceType = basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
41829
+ }
41787
41830
  else if (!(sourceType instanceof basic_1.VoidType) && !(sourceType instanceof basic_1.UnknownType)) {
41788
41831
  const message = "LINES OF must be a table type";
41789
41832
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -46921,16 +46964,21 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/
46921
46964
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
46922
46965
  class InsertInternal {
46923
46966
  runSyntax(node, input) {
46924
- var _a, _b;
46967
+ var _a, _b, _c;
46925
46968
  let targetType;
46926
46969
  const t = node.findDirectExpression(Expressions.Target);
46927
46970
  if (t) {
46928
46971
  targetType = target_1.Target.runSyntax(t, input);
46929
46972
  }
46973
+ // a generically typed dref->* is checked at runtime, except where an index table is expected
46974
+ const genericByKey = targetType instanceof basic_1.DataType
46975
+ && ((_a = t === null || t === void 0 ? void 0 : t.getLastChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dereference
46976
+ && node.findDirectTokenByText("TABLE") !== undefined;
46930
46977
  if (!(targetType instanceof basic_1.TableType)
46931
46978
  && !(targetType instanceof basic_1.VoidType)
46932
46979
  && !(targetType instanceof basic_1.AnyType)
46933
46980
  && !(targetType instanceof basic_1.UnknownType)
46981
+ && genericByKey === false
46934
46982
  && targetType !== undefined) {
46935
46983
  const message = "INSERT target must be a table";
46936
46984
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -46985,7 +47033,7 @@ class InsertInternal {
46985
47033
  error = true;
46986
47034
  }
46987
47035
  else if ((sourceType instanceof basic_1.StringType || sourceType instanceof basic_1.CharacterType)
46988
- && ((_a = sourceType.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) !== true
47036
+ && ((_b = sourceType.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) !== true
46989
47037
  && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.Constant)) === undefined
46990
47038
  && (targetType instanceof basic_1.IntegerType
46991
47039
  || targetType instanceof basic_1.Integer8Type
@@ -46998,7 +47046,7 @@ class InsertInternal {
46998
47046
  }
46999
47047
  else if (sourceType instanceof basic_1.CharacterType
47000
47048
  && targetType instanceof basic_1.CharacterType
47001
- && ((_b = sourceType.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true
47049
+ && ((_c = sourceType.getAbstractTypeData()) === null || _c === void 0 ? void 0 : _c.derivedFromConstant) === true
47002
47050
  && sourceType.getLength() !== targetType.getLength()) {
47003
47051
  // character literal of different length than the row type
47004
47052
  error = true;
@@ -52466,6 +52514,7 @@ const field_chain_1 = __webpack_require__(/*! ../expressions/field_chain */ "./n
52466
52514
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
52467
52515
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
52468
52516
  const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin_call.js");
52517
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
52469
52518
  class Write {
52470
52519
  runSyntax(node, input) {
52471
52520
  // todo, more
@@ -52485,7 +52534,9 @@ class Write {
52485
52534
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
52486
52535
  return;
52487
52536
  }
52537
+ // a utclong is written as a time stamp, although it is not character-like elsewhere
52488
52538
  if (s === second
52539
+ && !(type instanceof basic_1.UTCLongType)
52489
52540
  && new _type_utils_1.TypeUtils(input.scope).isCharLike(type) === false
52490
52541
  && new _type_utils_1.TypeUtils(input.scope).isHexLike(type) === false) {
52491
52542
  const message = "Source not character like";
@@ -69752,6 +69803,10 @@ const domain_1 = __webpack_require__(/*! ./domain */ "./node_modules/@abaplint/c
69752
69803
  const _identifier_1 = __webpack_require__(/*! ../abap/4_file_information/_identifier */ "./node_modules/@abaplint/core/build/src/abap/4_file_information/_identifier.js");
69753
69804
  const identifier_1 = __webpack_require__(/*! ../abap/1_lexer/tokens/identifier */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js");
69754
69805
  const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
69806
+ function toNumber(value) {
69807
+ const parsed = parseInt(value !== null && value !== void 0 ? value : "", 10);
69808
+ return isNaN(parsed) ? undefined : parsed;
69809
+ }
69755
69810
  class DataElement extends _abstract_object_1.AbstractObject {
69756
69811
  constructor() {
69757
69812
  super(...arguments);
@@ -69801,10 +69856,33 @@ class DataElement extends _abstract_object_1.AbstractObject {
69801
69856
  if ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.datatype) {
69802
69857
  return this.parsedXML.datatype;
69803
69858
  }
69804
- if (reg && ((_b = this.parsedXML) === null || _b === void 0 ? void 0 : _b.refkind) === "D" && this.parsedXML.domname) {
69859
+ return (_b = this.findDomain(reg)) === null || _b === void 0 ? void 0 : _b.getDataType();
69860
+ }
69861
+ /** DDIC length, eg. number of digits for DEC, which parseType() cannot give.
69862
+ * Taken from the same place as getDataType(), ie. the data element or its domain. */
69863
+ getLength(reg) {
69864
+ var _a, _b;
69865
+ this.parse();
69866
+ if ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.datatype) {
69867
+ return toNumber(this.parsedXML.leng);
69868
+ }
69869
+ return (_b = this.findDomain(reg)) === null || _b === void 0 ? void 0 : _b.getLength();
69870
+ }
69871
+ /** DDIC decimals, taken from the same place as getDataType(), ie. the data element or its domain. */
69872
+ getDecimals(reg) {
69873
+ var _a, _b;
69874
+ this.parse();
69875
+ if ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.datatype) {
69876
+ return toNumber(this.parsedXML.decimals);
69877
+ }
69878
+ return (_b = this.findDomain(reg)) === null || _b === void 0 ? void 0 : _b.getDecimals();
69879
+ }
69880
+ findDomain(reg) {
69881
+ var _a;
69882
+ if (reg && ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.refkind) === "D" && this.parsedXML.domname) {
69805
69883
  const domain = reg.getObject("DOMA", this.parsedXML.domname);
69806
69884
  if (domain instanceof domain_1.Domain) {
69807
- return domain.getDataType();
69885
+ return domain;
69808
69886
  }
69809
69887
  }
69810
69888
  return undefined;
@@ -70140,6 +70218,10 @@ const xml_utils_1 = __webpack_require__(/*! ../xml_utils */ "./node_modules/@aba
70140
70218
  const _identifier_1 = __webpack_require__(/*! ../abap/4_file_information/_identifier */ "./node_modules/@abaplint/core/build/src/abap/4_file_information/_identifier.js");
70141
70219
  const identifier_1 = __webpack_require__(/*! ../abap/1_lexer/tokens/identifier */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js");
70142
70220
  const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
70221
+ function toNumber(value) {
70222
+ const parsed = parseInt(value !== null && value !== void 0 ? value : "", 10);
70223
+ return isNaN(parsed) ? undefined : parsed;
70224
+ }
70143
70225
  class Domain extends _abstract_object_1.AbstractObject {
70144
70226
  getType() {
70145
70227
  return "DOMA";
@@ -70159,6 +70241,16 @@ class Domain extends _abstract_object_1.AbstractObject {
70159
70241
  this.parse();
70160
70242
  return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.datatype;
70161
70243
  }
70244
+ getLength() {
70245
+ var _a;
70246
+ this.parse();
70247
+ return toNumber((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.length);
70248
+ }
70249
+ getDecimals() {
70250
+ var _a;
70251
+ this.parse();
70252
+ return toNumber((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.decimals);
70253
+ }
70162
70254
  getAllowedNaming() {
70163
70255
  return {
70164
70256
  maxLength: 30,
@@ -76824,7 +76916,7 @@ class Registry {
76824
76916
  }
76825
76917
  static abaplintVersion() {
76826
76918
  // magic, see build script "version.js"
76827
- return "2.120.118";
76919
+ return "2.120.119";
76828
76920
  }
76829
76921
  getDDICReferences() {
76830
76922
  return this.ddicReferences;
@@ -115591,12 +115683,21 @@ ENDWHILE.`,
115591
115683
  }
115592
115684
  const reads = this.reads(procedure, move.source);
115593
115685
  if (reads === undefined
115594
- || reads.locals.some(l => l.writes().some(w => w.index > from && w.index < to))
115686
+ || reads.locals.some(l => this.changedIn(procedure, l, from, to))
115595
115687
  || reads.others.some(o => this.writtenIn(procedure, o, from, to))) {
115596
115688
  return false;
115597
115689
  }
115598
115690
  return reads.others.length === 0 || this.mayChangeOtherData(procedure, from, to, reads.receivers) === false;
115599
115691
  }
115692
+ /** written in the loop body, or declared inline in it: the inline declaration is not one of the writes(),
115693
+ * but sets the variable in every iteration, possibly from data the loop changes */
115694
+ changedIn(procedure, local, from, to) {
115695
+ if (local.writes().some(w => w.index > from && w.index < to)) {
115696
+ return true;
115697
+ }
115698
+ const index = local.inline && local.declaration !== undefined ? procedure.index(local.declaration) : -1;
115699
+ return index > from && index < to;
115700
+ }
115600
115701
  writtenIn(procedure, identifier, from, to) {
115601
115702
  for (const reference of procedure.analysis.referencesTo(identifier)) {
115602
115703
  if (reference.referenceType !== _reference_1.ReferenceType.DataWriteReference || !procedure.contains(reference.position)) {
@@ -118628,14 +118729,22 @@ var __importStar = (this && this.__importStar) || (function () {
118628
118729
  Object.defineProperty(exports, "__esModule", ({ value: true }));
118629
118730
  exports.UnsecureFAE = exports.UnsecureFAEConf = void 0;
118630
118731
  const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
118732
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
118733
+ const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js"));
118631
118734
  const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
118632
118735
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
118633
118736
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
118634
118737
  const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
118635
118738
  const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
118739
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
118740
+ const _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
118636
118741
  class UnsecureFAEConf extends _basic_rule_config_1.BasicRuleConfig {
118637
118742
  }
118638
118743
  exports.UnsecureFAEConf = UnsecureFAEConf;
118744
+ const PROCEDURES = [Structures.Method, Structures.Form, Structures.FunctionModule];
118745
+ const LOOPS = [Structures.Loop, Structures.Do, Structures.While, Structures.Select, Structures.LoopAtScreen];
118746
+ const CALLS = [Statements.Call, Statements.CallFunction, Statements.Perform, Statements.Submit,
118747
+ Statements.RaiseEvent, Statements.CallTransaction];
118639
118748
  class UnsecureFAE {
118640
118749
  constructor() {
118641
118750
  this.conf = new UnsecureFAEConf();
@@ -118645,8 +118754,24 @@ class UnsecureFAE {
118645
118754
  key: "unsecure_fae",
118646
118755
  title: "Unsecure FAE",
118647
118756
  shortDescription: `Checks for unsecure FAE`,
118648
- extendedInformation: `Issues from rule check_syntax must be fixed before this rule takes effect`,
118757
+ extendedInformation: `Issues from rule check_syntax must be fixed before this rule takes effect
118758
+
118759
+ The driver table of FOR ALL ENTRIES is considered checked, and no issue is reported, if
118760
+ * the SELECT is in the IF or ELSEIF branch of a condition "itab IS NOT INITIAL", "NOT itab IS INITIAL"
118761
+ or "lines( itab ) > 0", also combined with AND, or
118762
+ * "IF itab IS INITIAL. RETURN. ENDIF." or "CHECK itab IS NOT INITIAL." precedes the SELECT in the same method,
118763
+ form or function module, at the same or an outer block level, not inside a loop,
118764
+
118765
+ and the driver table is not changed between the check and the SELECT, or in a loop around the SELECT inside the
118766
+ checked region. If the driver table is not a local variable or parameter, a method, function or form call in
118767
+ between also invalidates the check.`,
118649
118768
  tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Performance],
118769
+ badExample: `SELECT * FROM t000 FOR ALL ENTRIES IN @lt_list
118770
+ WHERE mandt = @lt_list-table_line INTO TABLE @DATA(lt_t000).`,
118771
+ goodExample: `IF lt_list IS NOT INITIAL.
118772
+ SELECT * FROM t000 FOR ALL ENTRIES IN @lt_list
118773
+ WHERE mandt = @lt_list-table_line INTO TABLE @DATA(lt_t000).
118774
+ ENDIF.`,
118650
118775
  };
118651
118776
  }
118652
118777
  getConfig() {
@@ -118660,7 +118785,6 @@ class UnsecureFAE {
118660
118785
  this.conf = conf;
118661
118786
  }
118662
118787
  run(obj) {
118663
- var _a;
118664
118788
  const issues = [];
118665
118789
  if (!(obj instanceof _abap_object_1.ABAPObject)) {
118666
118790
  return issues;
@@ -118670,15 +118794,193 @@ class UnsecureFAE {
118670
118794
  return issues;
118671
118795
  }
118672
118796
  for (const f of obj.getABAPFiles()) {
118673
- // todo
118674
- for (const e of ((_a = f.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(Expressions.SQLForAllEntries)) || []) {
118675
- const token = e.getFirstToken();
118676
- const message = "Unsecure FAE";
118677
- issues.push(issue_1.Issue.atToken(f, token, message, this.getMetadata().key, this.getConfig().severity));
118797
+ const structure = f.getStructure();
118798
+ if (structure === undefined) {
118799
+ continue;
118800
+ }
118801
+ for (const statement of structure.findAllStatementNodes()) {
118802
+ for (const e of statement.findAllExpressions(Expressions.SQLForAllEntries)) {
118803
+ if (this.isChecked(f, structure, statement, e, syntaxResult.spaghetti)) {
118804
+ continue;
118805
+ }
118806
+ const token = e.getFirstToken();
118807
+ const message = "Unsecure FAE";
118808
+ issues.push(issue_1.Issue.atToken(f, token, message, this.getMetadata().key, this.getConfig().severity));
118809
+ }
118678
118810
  }
118679
118811
  }
118680
118812
  return issues;
118681
118813
  }
118814
+ ////////////////
118815
+ isChecked(file, root, statement, fae, spaghetti) {
118816
+ var _a;
118817
+ const source = fae.findDirectExpression(Expressions.SQLSource);
118818
+ const name = source === null || source === void 0 ? void 0 : source.concatTokens().replace(/^@/, "").replace(/\s/g, "").toUpperCase();
118819
+ if (name === undefined || /^[\w/<>~]+((->|=>)[\w/~]+)?$/.test(name) === false) {
118820
+ return false;
118821
+ }
118822
+ const path = this.findPath(root, statement, []);
118823
+ if (path === undefined) {
118824
+ return false;
118825
+ }
118826
+ const local = this.isLocal(file, name, statement.getStart(), spaghetti);
118827
+ for (let i = path.length - 1; i >= 0; i--) {
118828
+ const node = path[i];
118829
+ const type = node.get();
118830
+ if (PROCEDURES.some(p => type instanceof p)) {
118831
+ break;
118832
+ }
118833
+ const child = (_a = path[i + 1]) !== null && _a !== void 0 ? _a : statement;
118834
+ const inner = path.slice(i + 1);
118835
+ // IF itab IS NOT INITIAL. SELECT ... ENDIF.
118836
+ if ((type instanceof Structures.If || type instanceof Structures.ElseIf) && child.get() instanceof Structures.Body) {
118837
+ const header = node.findDirectStatement(type instanceof Structures.If ? Statements.If : Statements.ElseIf);
118838
+ const cond = header === null || header === void 0 ? void 0 : header.findDirectExpression(Expressions.Cond);
118839
+ if (header && cond && this.notInitial(cond, name)
118840
+ && this.unchanged(file, inner, statement, header.getEnd(), name, local)) {
118841
+ return true;
118842
+ }
118843
+ }
118844
+ // IF itab IS INITIAL. RETURN. ENDIF. or CHECK itab IS NOT INITIAL. before the SELECT
118845
+ const outer = path.slice(0, i + 1);
118846
+ if (type instanceof Structures.Body
118847
+ && outer.some(n => PROCEDURES.some(p => n.get() instanceof p))
118848
+ && outer.some(n => LOOPS.some(l => n.get() instanceof l)) === false) {
118849
+ for (const sibling of node.getChildren()) {
118850
+ if (sibling === child) {
118851
+ break;
118852
+ }
118853
+ const content = sibling instanceof nodes_1.StructureNode && sibling.get() instanceof Structures.Normal
118854
+ ? sibling.getFirstChild() : sibling;
118855
+ if ((content instanceof nodes_1.StructureNode || content instanceof nodes_1.StatementNode)
118856
+ && this.leavesIfInitial(content, name)
118857
+ && this.unchanged(file, inner, statement, sibling.getLastToken().getEnd(), name, local)) {
118858
+ return true;
118859
+ }
118860
+ }
118861
+ }
118862
+ }
118863
+ return false;
118864
+ }
118865
+ findPath(node, target, path) {
118866
+ for (const child of node.getChildren()) {
118867
+ if (child === target) {
118868
+ return [...path, node];
118869
+ }
118870
+ else if (child instanceof nodes_1.StructureNode) {
118871
+ const found = this.findPath(child, target, [...path, node]);
118872
+ if (found) {
118873
+ return found;
118874
+ }
118875
+ }
118876
+ }
118877
+ return undefined;
118878
+ }
118879
+ /** local variable or parameter of the procedure, calls cannot change it */
118880
+ isLocal(file, name, position, spaghetti) {
118881
+ if (name.includes("->") || name.includes("=>") || name.startsWith("<")) {
118882
+ return false;
118883
+ }
118884
+ let scope = spaghetti.lookupPosition(position, file.getFilename());
118885
+ while ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === _scope_type_1.ScopeType.OpenSQL) {
118886
+ scope = scope.getParent();
118887
+ }
118888
+ const stype = scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype;
118889
+ if (stype !== _scope_type_1.ScopeType.Method && stype !== _scope_type_1.ScopeType.Form && stype !== _scope_type_1.ScopeType.FunctionModule) {
118890
+ return false;
118891
+ }
118892
+ return (scope === null || scope === void 0 ? void 0 : scope.getData().vars[name]) !== undefined;
118893
+ }
118894
+ /** "itab IS NOT INITIAL" or "lines( itab ) > 0", possibly combined with AND */
118895
+ notInitial(cond, name) {
118896
+ const children = cond.getChildren();
118897
+ if (children.some(c => ["OR", "EQUIV"].includes(c.concatTokens().toUpperCase()))) {
118898
+ return false;
118899
+ }
118900
+ for (const child of children) {
118901
+ if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Compare) {
118902
+ const text = this.normalize(child);
118903
+ if ([`${name} IS NOT INITIAL`, `NOT ${name} IS INITIAL`,
118904
+ `LINES( ${name} ) > 0`, `LINES( ${name} ) GT 0`, `LINES( ${name} ) <> 0`, `LINES( ${name} ) NE 0`,
118905
+ `LINES( ${name} ) >= 1`, `LINES( ${name} ) GE 1`].includes(text)) {
118906
+ return true;
118907
+ }
118908
+ }
118909
+ else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.CondSub
118910
+ && child.getFirstToken().getStr().toUpperCase() !== "NOT") {
118911
+ const sub = child.findDirectExpression(Expressions.Cond);
118912
+ if (sub && this.notInitial(sub, name)) {
118913
+ return true;
118914
+ }
118915
+ }
118916
+ }
118917
+ return false;
118918
+ }
118919
+ /** "itab IS INITIAL" or "lines( itab ) = 0", possibly combined with OR */
118920
+ initial(cond, name) {
118921
+ const children = cond.getChildren();
118922
+ if (children.some(c => ["AND", "EQUIV"].includes(c.concatTokens().toUpperCase()))) {
118923
+ return false;
118924
+ }
118925
+ return children.some(c => c instanceof nodes_1.ExpressionNode && c.get() instanceof Expressions.Compare
118926
+ && [`${name} IS INITIAL`, `NOT ${name} IS NOT INITIAL`,
118927
+ `LINES( ${name} ) = 0`, `LINES( ${name} ) EQ 0`, `LINES( ${name} ) < 1`, `LINES( ${name} ) LT 1`]
118928
+ .includes(this.normalize(c)));
118929
+ }
118930
+ /** "IF itab IS INITIAL. RETURN. ENDIF." or "CHECK itab IS NOT INITIAL." */
118931
+ leavesIfInitial(node, name) {
118932
+ var _a, _b;
118933
+ var _c;
118934
+ if (node instanceof nodes_1.StatementNode) {
118935
+ const cond = node.get() instanceof Statements.Check ? node.findDirectExpression(Expressions.Cond) : undefined;
118936
+ return cond !== undefined && this.notInitial(cond, name);
118937
+ }
118938
+ if (!(node.get() instanceof Structures.If)
118939
+ || node.findDirectStructure(Structures.Else) !== undefined
118940
+ || node.findDirectStructure(Structures.ElseIf) !== undefined) {
118941
+ return false;
118942
+ }
118943
+ const statements = (_c = (_a = node.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.findAllStatementNodes()) !== null && _c !== void 0 ? _c : [];
118944
+ if (statements.length !== 1 || !(statements[0].get() instanceof Statements.Return)) {
118945
+ return false;
118946
+ }
118947
+ const cond = (_b = node.findDirectStatement(Statements.If)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.Cond);
118948
+ return cond !== undefined && this.initial(cond, name);
118949
+ }
118950
+ normalize(node) {
118951
+ return node.concatTokens().toUpperCase().replace(/\s+/g, " ");
118952
+ }
118953
+ /** the driver table is not changed after the check and before the SELECT, nor in a loop around the SELECT
118954
+ * inside the checked region */
118955
+ unchanged(file, inner, statement, from, name, local) {
118956
+ const loop = inner.find(n => LOOPS.some(l => n.get() instanceof l));
118957
+ const to = loop === undefined ? statement.getStart() : loop.getLastToken().getEnd();
118958
+ for (const s of file.getStatements()) {
118959
+ if (s === statement || !s.getStart().isAfter(from) || !s.getStart().isBefore(to)) {
118960
+ continue;
118961
+ }
118962
+ if (this.writes(s, name) || (local === false && this.calls(s))) {
118963
+ return false;
118964
+ }
118965
+ }
118966
+ return true;
118967
+ }
118968
+ writes(statement, name) {
118969
+ for (const target of [...statement.findAllExpressions(Expressions.Target),
118970
+ ...statement.findAllExpressions(Expressions.FSTarget)]) {
118971
+ const text = target.concatTokens().replace(/\s/g, "").toUpperCase();
118972
+ if (text === name || (text.startsWith(name) && /^[^\w/]/.test(text.substring(name.length)))) {
118973
+ return true;
118974
+ }
118975
+ }
118976
+ return false;
118977
+ }
118978
+ calls(statement) {
118979
+ const type = statement.get();
118980
+ return CALLS.some(c => type instanceof c)
118981
+ || statement.findFirstExpression(Expressions.MethodCall) !== undefined
118982
+ || statement.findFirstExpression(Expressions.MethodSource) !== undefined;
118983
+ }
118682
118984
  }
118683
118985
  exports.UnsecureFAE = UnsecureFAE;
118684
118986
  //# sourceMappingURL=unsecure_fae.js.map
@@ -131653,13 +131955,13 @@ class HandleDataDefinition {
131653
131955
  const cds = this.metadata.build(obj);
131654
131956
  const type = this.withoutAssociations(obj.parseType(reg), cds);
131655
131957
  const typeFactory = new type_factory_registry_1.TypeFactoryRegistry(filename);
131656
- const body = `abap.DDIC["${obj.getName().toUpperCase()}"] = {
131657
- "objectType": "DDLS",
131658
- "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type, typeFactory)},
131659
- "keyFields": ${JSON.stringify(cds?.fields.filter(f => f.key).map(f => f.name.toUpperCase()) ?? [])},
131660
- "description": ${JSON.stringify(obj.getDescription())},
131661
- "sqlViewName": ${JSON.stringify(obj.getSQLViewName())},
131662
- "cds": ${JSON.stringify(cds)},
131958
+ const body = `abap.DDIC["${obj.getName().toUpperCase()}"] = {
131959
+ "objectType": "DDLS",
131960
+ "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type, typeFactory)},
131961
+ "keyFields": ${JSON.stringify(cds?.fields.filter(f => f.key).map(f => f.name.toUpperCase()) ?? [])},
131962
+ "description": ${JSON.stringify(obj.getDescription())},
131963
+ "sqlViewName": ${JSON.stringify(obj.getSQLViewName())},
131964
+ "cds": ${JSON.stringify(cds)},
131663
131965
  };`;
131664
131966
  const chunk = new chunk_1.Chunk(body);
131665
131967
  const helpers = typeFactory.finalize(chunk);
@@ -131726,6 +132028,9 @@ class HandleDataElement {
131726
132028
  "objectType": "DTEL",
131727
132029
  "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type, typeFactory)},
131728
132030
  "domain": ${JSON.stringify(obj.getDomainName())},
132031
+ "datatype": ${JSON.stringify(obj.getDataType(reg))},
132032
+ "length": ${JSON.stringify(obj.getLength(reg))},
132033
+ "decimals": ${JSON.stringify(obj.getDecimals(reg))},
131729
132034
  "fixedValues": ${JSON.stringify(fixedValues)},
131730
132035
  "description": ${JSON.stringify(obj.getDescription())},
131731
132036
  };`;
@@ -132656,12 +132961,12 @@ class Initialization {
132656
132961
  script(reg, dbSetup, options, useImport) {
132657
132962
  let ret = "";
132658
132963
  if (useImport === true) {
132659
- ret = `/* eslint-disable import/newline-after-import */
132964
+ ret = `/* eslint-disable import/newline-after-import */
132660
132965
  import "./_top.mjs";\n`;
132661
132966
  }
132662
132967
  else {
132663
- ret = `/* eslint-disable import/newline-after-import */
132664
- import runtime from "@abaplint/runtime";
132968
+ ret = `/* eslint-disable import/newline-after-import */
132969
+ import runtime from "@abaplint/runtime";
132665
132970
  globalThis.abap = new runtime.ABAP();\n`;
132666
132971
  }
132667
132972
  if (options?.setup?.filename === undefined || options?.setup?.filename === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.14.38",
3
+ "version": "2.14.39",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@abaplint/core": "^2.120.118",
31
- "@abaplint/transpiler": "^2.14.38",
30
+ "@abaplint/core": "^2.120.119",
31
+ "@abaplint/transpiler": "^2.14.39",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.6",
34
34
  "@types/progress": "^2.0.7",