@abaplint/transpiler-cli 2.5.29 → 2.5.31

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 +61 -38
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -444,7 +444,10 @@ class Lexer {
444
444
  const ahead = this.stream.nextChar();
445
445
  const aahead = this.stream.nextNextChar();
446
446
  if (this.m === this.ModeNormal) {
447
- if (ahead === "'") {
447
+ if (splits[ahead]) {
448
+ this.add();
449
+ }
450
+ else if (ahead === "'") {
448
451
  // start string
449
452
  this.add();
450
453
  this.m = this.ModeStr;
@@ -470,9 +473,6 @@ class Lexer {
470
473
  this.add();
471
474
  this.m = this.ModeComment;
472
475
  }
473
- else if (splits[ahead]) {
474
- this.add();
475
- }
476
476
  else if (ahead === "@" && buf.trim().length === 0) {
477
477
  this.add();
478
478
  }
@@ -21642,6 +21642,9 @@ const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@a
21642
21642
  const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js");
21643
21643
  class ComponentChain {
21644
21644
  runSyntax(context, node, scope, filename) {
21645
+ if (context === undefined) {
21646
+ return undefined;
21647
+ }
21645
21648
  const children = node.getChildren();
21646
21649
  for (let i = 0; i < children.length; i++) {
21647
21650
  if (context instanceof void_type_1.VoidType || context instanceof basic_1.UnknownType) {
@@ -21704,7 +21707,7 @@ class ComponentChain {
21704
21707
  }
21705
21708
  }
21706
21709
  else {
21707
- throw new Error("ComponentChain, not a structure");
21710
+ throw new Error("ComponentChain, not a structure, " + (context === null || context === void 0 ? void 0 : context.constructor.name));
21708
21711
  }
21709
21712
  }
21710
21713
  }
@@ -21727,7 +21730,7 @@ exports.ComponentChain = ComponentChain;
21727
21730
  Object.defineProperty(exports, "__esModule", ({ value: true }));
21728
21731
  exports.ComponentCompare = void 0;
21729
21732
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
21730
- const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
21733
+ const component_chain_1 = __webpack_require__(/*! ./component_chain */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_chain.js");
21731
21734
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
21732
21735
  class ComponentCompare {
21733
21736
  runSyntax(node, scope, filename, type) {
@@ -21735,23 +21738,7 @@ class ComponentCompare {
21735
21738
  if (chain === undefined) {
21736
21739
  throw new Error("ComponentCompare, chain not found");
21737
21740
  }
21738
- // todo, handle deep chain
21739
- if (chain.getChildren().length === 1
21740
- && type !== undefined
21741
- && !(type instanceof basic_1.VoidType)
21742
- && !(type instanceof basic_1.UnknownType)
21743
- && !(type instanceof basic_1.AnyType)) {
21744
- const fieldName = chain.concatTokens();
21745
- if (fieldName.toLowerCase() !== "table_line") {
21746
- if (!(type instanceof basic_1.StructureType)) {
21747
- throw new Error("ComponentCompare, source not structured");
21748
- }
21749
- if (type.getComponentByName(fieldName) === undefined) {
21750
- throw new Error("Component \"" + fieldName + "\" not part of structure");
21751
- }
21752
- // todo, check type compatibility
21753
- }
21754
- }
21741
+ new component_chain_1.ComponentChain().runSyntax(type, chain, scope, filename);
21755
21742
  for (const s of node.findDirectExpressions(Expressions.Source)) {
21756
21743
  new source_1.Source().runSyntax(s, scope, filename);
21757
21744
  }
@@ -26571,12 +26558,14 @@ const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_module
26571
26558
  const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
26572
26559
  const component_compare_1 = __webpack_require__(/*! ../expressions/component_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_compare.js");
26573
26560
  const component_cond_1 = __webpack_require__(/*! ../expressions/component_cond */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_cond.js");
26561
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
26574
26562
  class DeleteInternal {
26575
26563
  runSyntax(node, scope, filename) {
26576
26564
  var _a;
26577
26565
  for (const s of node.findDirectExpressions(Expressions.Source)) {
26578
26566
  new source_1.Source().runSyntax(s, scope, filename);
26579
26567
  }
26568
+ let targetType = undefined;
26580
26569
  const target = node.findDirectExpression(Expressions.Target);
26581
26570
  if (target) {
26582
26571
  let tabl = undefined;
@@ -26588,14 +26577,17 @@ class DeleteInternal {
26588
26577
  }
26589
26578
  }
26590
26579
  if (tabl === undefined) {
26591
- new target_1.Target().runSyntax(target, scope, filename);
26580
+ targetType = new target_1.Target().runSyntax(target, scope, filename);
26581
+ if (targetType instanceof basic_1.TableType) {
26582
+ targetType = targetType.getRowType();
26583
+ }
26592
26584
  }
26593
26585
  }
26594
26586
  for (const t of node.findDirectExpressions(Expressions.ComponentCompare)) {
26595
- new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
26587
+ new component_compare_1.ComponentCompare().runSyntax(t, scope, filename, targetType);
26596
26588
  }
26597
26589
  for (const t of node.findDirectExpressions(Expressions.ComponentCond)) {
26598
- new component_cond_1.ComponentCond().runSyntax(t, scope, filename);
26590
+ new component_cond_1.ComponentCond().runSyntax(t, scope, filename, targetType);
26599
26591
  }
26600
26592
  }
26601
26593
  }
@@ -33372,8 +33364,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
33372
33364
  exports.StructureType = void 0;
33373
33365
  const _abstract_type_1 = __webpack_require__(/*! ./_abstract_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/_abstract_type.js");
33374
33366
  class StructureType extends _abstract_type_1.AbstractType {
33375
- constructor(components, qualifiedName) {
33376
- super({ qualifiedName: qualifiedName });
33367
+ constructor(components, qualifiedName, ddicName) {
33368
+ super({
33369
+ qualifiedName: qualifiedName,
33370
+ ddicName: ddicName,
33371
+ });
33377
33372
  if (components.length === 0) {
33378
33373
  throw new Error("Structure does not contain any components");
33379
33374
  }
@@ -37593,7 +37588,8 @@ exports.MemoryFile = MemoryFile;
37593
37588
  "use strict";
37594
37589
 
37595
37590
  Object.defineProperty(exports, "__esModule", ({ value: true }));
37596
- exports.RuleTag = exports.Severity = exports.Visibility = exports.Info = exports.Rename = exports.PrettyPrinter = exports.Position = exports.CurrentScope = exports.ABAPFile = exports.RulesRunner = exports.SpaghettiScope = exports.SyntaxLogic = exports.ABAPObject = exports.Tokens = exports.ExpressionsCDS = exports.CDSParser = exports.LanguageServerTypes = exports.DDLParser = exports.applyEditList = exports.applyEditSingle = exports.SpaghettiScopeNode = exports.AbstractFile = exports.Token = exports.ScopeType = exports.BasicTypes = exports.TypedIdentifier = exports.AbstractType = exports.VirtualPosition = exports.Comment = exports.Unknown = exports.Empty = exports.Identifier = exports.Nodes = exports.Types = exports.Expressions = exports.Statements = exports.Structures = exports.Objects = exports.ArtifactsRules = exports.ArtifactsObjects = exports.ArtifactsABAP = exports.BuiltIn = exports.MethodLengthStats = exports.LanguageServer = exports.Registry = exports.ReferenceType = exports.Version = exports.Config = exports.Issue = exports.MemoryFile = void 0;
37591
+ exports.Severity = exports.Visibility = exports.Info = exports.Rename = exports.PrettyPrinter = exports.Position = exports.CurrentScope = exports.ABAPFile = exports.RulesRunner = exports.SpaghettiScope = exports.SyntaxLogic = exports.ABAPObject = exports.Tokens = exports.ExpressionsCDS = exports.CDSParser = exports.LanguageServerTypes = exports.DDLParser = exports.applyEditList = exports.applyEditSingle = exports.SpaghettiScopeNode = exports.AbstractFile = exports.Token = exports.ScopeType = exports.BasicTypes = exports.TypedIdentifier = exports.AbstractType = exports.VirtualPosition = exports.Comment = exports.Unknown = exports.Empty = exports.Identifier = exports.Nodes = exports.Types = exports.Expressions = exports.Statements = exports.Structures = exports.Objects = exports.ArtifactsRules = exports.ArtifactsObjects = exports.ArtifactsABAP = exports.BuiltIn = exports.MethodLengthStats = exports.LanguageServer = exports.Registry = exports.CyclomaticComplexityStats = exports.ReferenceType = exports.Version = exports.Config = exports.Issue = exports.MemoryFile = void 0;
37592
+ exports.RuleTag = void 0;
37597
37593
  const issue_1 = __webpack_require__(/*! ./issue */ "./node_modules/@abaplint/core/build/src/issue.js");
37598
37594
  Object.defineProperty(exports, "Issue", ({ enumerable: true, get: function () { return issue_1.Issue; } }));
37599
37595
  const config_1 = __webpack_require__(/*! ./config */ "./node_modules/@abaplint/core/build/src/config.js");
@@ -37689,6 +37685,8 @@ const rules_runner_1 = __webpack_require__(/*! ./rules_runner */ "./node_modules
37689
37685
  Object.defineProperty(exports, "RulesRunner", ({ enumerable: true, get: function () { return rules_runner_1.RulesRunner; } }));
37690
37686
  const _irule_1 = __webpack_require__(/*! ./rules/_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
37691
37687
  Object.defineProperty(exports, "RuleTag", ({ enumerable: true, get: function () { return _irule_1.RuleTag; } }));
37688
+ const cyclomatic_complexity_stats_1 = __webpack_require__(/*! ./utils/cyclomatic_complexity_stats */ "./node_modules/@abaplint/core/build/src/utils/cyclomatic_complexity_stats.js");
37689
+ Object.defineProperty(exports, "CyclomaticComplexityStats", ({ enumerable: true, get: function () { return cyclomatic_complexity_stats_1.CyclomaticComplexityStats; } }));
37692
37690
  //# sourceMappingURL=index.js.map
37693
37691
 
37694
37692
  /***/ }),
@@ -44897,7 +44895,7 @@ class Table extends _abstract_object_1.AbstractObject {
44897
44895
  return new Types.UnknownType("Table/Structure " + this.getName() + " does not contain any components");
44898
44896
  }
44899
44897
  reg.getDDICReferences().setUsing(this, references);
44900
- return new Types.StructureType(components, this.getName());
44898
+ return new Types.StructureType(components, this.getName(), this.getName());
44901
44899
  }
44902
44900
  getTableCategory() {
44903
44901
  var _a;
@@ -45703,7 +45701,6 @@ exports.Position = Position;
45703
45701
  class VirtualPosition extends Position {
45704
45702
  constructor(virtual, row, col) {
45705
45703
  super(virtual.getRow(), virtual.getCol());
45706
- // this.virtual = virtual;
45707
45704
  this.vrow = row;
45708
45705
  this.vcol = col;
45709
45706
  }
@@ -45711,7 +45708,8 @@ class VirtualPosition extends Position {
45711
45708
  if (!(p instanceof VirtualPosition)) {
45712
45709
  return false;
45713
45710
  }
45714
- return super.equals(this) && this.vrow === p.vrow && this.vcol === p.vcol;
45711
+ const casted = p;
45712
+ return super.equals(this) && this.vrow === casted.vrow && this.vcol === casted.vcol;
45715
45713
  }
45716
45714
  }
45717
45715
  exports.VirtualPosition = VirtualPosition;
@@ -46210,7 +46208,7 @@ class Registry {
46210
46208
  }
46211
46209
  static abaplintVersion() {
46212
46210
  // magic, see build script "version.sh"
46213
- return "2.95.38";
46211
+ return "2.95.41";
46214
46212
  }
46215
46213
  getDDICReferences() {
46216
46214
  return this.references;
@@ -50772,6 +50770,7 @@ const include_graph_1 = __webpack_require__(/*! ../utils/include_graph */ "./nod
50772
50770
  const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
50773
50771
  const _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
50774
50772
  const _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
50773
+ const statements_1 = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
50775
50774
  // todo: refactor each sub-rule to new classes?
50776
50775
  // todo: add configuration
50777
50776
  class DownportConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -51177,7 +51176,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
51177
51176
  if (found) {
51178
51177
  return found;
51179
51178
  }
51180
- found = this.replaceLineFunctions(high, lowFile, highSyntax);
51179
+ found = this.replaceLineFunctions(high, lowFile, highSyntax, highFile);
51181
51180
  if (found) {
51182
51181
  return found;
51183
51182
  }
@@ -53218,7 +53217,7 @@ ${indentation} output = ${topTarget}.`;
53218
53217
  }
53219
53218
  return undefined;
53220
53219
  }
53221
- replaceLineFunctions(node, lowFile, highSyntax) {
53220
+ replaceLineFunctions(node, lowFile, highSyntax, highFile) {
53222
53221
  var _a, _b;
53223
53222
  const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
53224
53223
  for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
@@ -53253,12 +53252,30 @@ ${indentation} output = ${topTarget}.`;
53253
53252
  indentation + `READ TABLE ${tableName} ${condition}TRANSPORTING NO FIELDS.\n` +
53254
53253
  indentation + uniqueName + ` = ${sy}.\n` +
53255
53254
  indentation;
53256
- const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
53255
+ let insertAt = node.getFirstToken().getStart();
53256
+ if (node.get() instanceof statements_1.ElseIf) {
53257
+ // assumption: no side effects in IF conditions
53258
+ insertAt = this.findStartOfIf(node, highFile);
53259
+ if (insertAt === undefined) {
53260
+ continue;
53261
+ }
53262
+ }
53263
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, insertAt, code);
53257
53264
  const start = expression.getFirstToken().getStart();
53258
53265
  const end = expression.getLastToken().getEnd();
53259
53266
  const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, uniqueName + (func === "LINE_EXISTS" ? " = 0" : ""));
53260
53267
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
53261
- return issue_1.Issue.atToken(lowFile, token, "Use BOOLC", this.getMetadata().key, this.conf.severity, fix);
53268
+ return issue_1.Issue.atToken(lowFile, token, "Replace line function", this.getMetadata().key, this.conf.severity, fix);
53269
+ }
53270
+ }
53271
+ return undefined;
53272
+ }
53273
+ findStartOfIf(node, highFile) {
53274
+ var _a;
53275
+ const structure = highFile.getStructure();
53276
+ for (const c of (structure === null || structure === void 0 ? void 0 : structure.findAllStructuresRecursive(Structures.If)) || []) {
53277
+ if (((_a = c.findDirectStructure(Structures.ElseIf)) === null || _a === void 0 ? void 0 : _a.getFirstStatement()) === node) {
53278
+ return c.getFirstToken().getStart();
53262
53279
  }
53263
53280
  }
53264
53281
  return undefined;
@@ -73994,7 +74011,7 @@ class PerformTranspiler {
73994
74011
  return new chunk_1.Chunk(`throw new Error("PerformTranspiler FormName not found");`);
73995
74012
  }
73996
74013
  // todo, parameters
73997
- if (node.concatTokens().includes(" IN PROGRAM ")) {
74014
+ if (node.concatTokens().toUpperCase().includes(" IN PROGRAM ")) {
73998
74015
  return new chunk_1.Chunk(`throw new Error("PerformTranspiler IN PROGRAM, transpiler todo");`);
73999
74016
  }
74000
74017
  return new chunk_1.Chunk("await " + formName.concatTokens() + "();");
@@ -76748,6 +76765,12 @@ class TranspileTypes {
76748
76765
  if (type.getQualifiedName() !== undefined) {
76749
76766
  extra += ", \"" + type.getQualifiedName() + "\"";
76750
76767
  }
76768
+ else {
76769
+ extra += ", undefined";
76770
+ }
76771
+ if (type.getDDICName() !== undefined) {
76772
+ extra += ", \"" + type.getQualifiedName() + "\"";
76773
+ }
76751
76774
  }
76752
76775
  else if (type instanceof abaplint.BasicTypes.CLikeType
76753
76776
  || type instanceof abaplint.BasicTypes.CSequenceType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.5.29",
3
+ "version": "2.5.31",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,13 +25,13 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.5.29",
28
+ "@abaplint/transpiler": "^2.5.31",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
- "@abaplint/core": "^2.95.38",
32
+ "@abaplint/core": "^2.95.41",
33
33
  "progress": "^2.0.3",
34
- "webpack": "^5.76.0",
34
+ "webpack": "^5.76.1",
35
35
  "webpack-cli": "^5.0.1",
36
36
  "typescript": "=4.8.4"
37
37
  }