@abaplint/core 2.94.25 → 2.95.0

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.
@@ -6398,7 +6398,6 @@ declare class VirtualEndPoint extends AbstractObject {
6398
6398
 
6399
6399
  /** used for macro calls */
6400
6400
  export declare class VirtualPosition extends Position {
6401
- private readonly virtual;
6402
6401
  readonly vrow: number;
6403
6402
  readonly vcol: number;
6404
6403
  constructor(virtual: Position, row: number, col: number);
@@ -9,10 +9,10 @@ class MethodSource extends combi_1.Expression {
9
9
  // note: AttributeName can be both an attribute and a method name, the syntax check will tell
10
10
  // note: its allowed to end with MethodCall, however if this is done it will give a syntax error via syntax check
11
11
  const afterArrow = (0, combi_1.alt)(_1.AttributeName, _1.MethodCall, _1.Dynamic);
12
- const arrow = (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));
12
+ const arrow = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));
13
13
  const attr = (0, combi_1.seq)(arrow, afterArrow);
14
14
  const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), _1.ComponentName);
15
- const attrOrComp = (0, combi_1.alt)(attr, comp);
15
+ const attrOrComp = (0, combi_1.altPrio)(attr, comp);
16
16
  const staticClass = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow));
17
17
  const clas = (0, combi_1.seq)(staticClass, afterArrow);
18
18
  const start = (0, combi_1.seq)((0, combi_1.altPrio)(clas, _1.SourceField, _1.SourceFieldSymbol, _1.Dynamic), (0, combi_1.star)(attrOrComp));
@@ -31,7 +31,7 @@ exports.Position = Position;
31
31
  class VirtualPosition extends Position {
32
32
  constructor(virtual, row, col) {
33
33
  super(virtual.getRow(), virtual.getCol());
34
- this.virtual = virtual;
34
+ // this.virtual = virtual;
35
35
  this.vrow = row;
36
36
  this.vcol = col;
37
37
  }
@@ -39,8 +39,7 @@ class VirtualPosition extends Position {
39
39
  if (!(p instanceof VirtualPosition)) {
40
40
  return false;
41
41
  }
42
- const bar = p; // widening cast for ABAP translation
43
- return super.equals(this.virtual) && this.vrow === bar.vrow && this.vcol === bar.vcol;
42
+ return super.equals(this) && this.vrow === p.vrow && this.vcol === p.vcol;
44
43
  }
45
44
  }
46
45
  exports.VirtualPosition = VirtualPosition;
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.94.25";
66
+ return "2.95.0";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpandMacros = exports.ExpandMacrosConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const _abap_rule_1 = require("./_abap_rule");
6
+ const _basic_rule_config_1 = require("./_basic_rule_config");
7
+ const _irule_1 = require("./_irule");
8
+ const edit_helper_1 = require("../edit_helper");
9
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
10
+ const position_1 = require("../position");
11
+ class ExpandMacrosConf extends _basic_rule_config_1.BasicRuleConfig {
12
+ }
13
+ exports.ExpandMacrosConf = ExpandMacrosConf;
14
+ class ExpandMacros extends _abap_rule_1.ABAPRule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.conf = new ExpandMacrosConf();
18
+ }
19
+ getMetadata() {
20
+ return {
21
+ key: "expand_macros",
22
+ title: "Expand Macros",
23
+ shortDescription: `Allows expanding macro calls with quick fixes`,
24
+ extendedInformation: `Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
25
+
26
+ Note that macros/DEFINE cannot be used in the ABAP Cloud programming model`,
27
+ badExample: `DEFINE _hello.
28
+ WRITE 'hello'.
29
+ END-OF-DEFINITION.
30
+ _hello.`,
31
+ goodExample: `WRITE 'hello'.`,
32
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.Upport],
33
+ };
34
+ }
35
+ getConfig() {
36
+ return this.conf;
37
+ }
38
+ setConfig(conf) {
39
+ this.conf = conf;
40
+ }
41
+ runParsed(file) {
42
+ const issues = [];
43
+ const message = "Expand macro call";
44
+ const statements = file.getStatements();
45
+ for (let i = 0; i < statements.length; i++) {
46
+ const statementNode = statements[i];
47
+ const statement = statementNode.get();
48
+ if (!(statement instanceof _statement_1.MacroCall)) {
49
+ continue;
50
+ }
51
+ let replace = "";
52
+ for (let j = i + 1; j < statements.length; j++) {
53
+ const sub = statements[j];
54
+ if (sub.getFirstToken().getStart() instanceof position_1.VirtualPosition) {
55
+ replace += sub.concatTokens();
56
+ }
57
+ else {
58
+ break;
59
+ }
60
+ }
61
+ const fix = edit_helper_1.EditHelper.replaceRange(file, statementNode.getStart(), statementNode.getEnd(), replace);
62
+ issues.push(issue_1.Issue.atStatement(file, statementNode, message, this.getMetadata().key, this.conf.severity, fix));
63
+ }
64
+ return issues;
65
+ }
66
+ }
67
+ exports.ExpandMacros = ExpandMacros;
68
+ //# sourceMappingURL=expand_macros.js.map
@@ -57,6 +57,7 @@ __exportStar(require("./empty_line_in_statement"), exports);
57
57
  __exportStar(require("./empty_statement"), exports);
58
58
  __exportStar(require("./empty_structure"), exports);
59
59
  __exportStar(require("./exit_or_check"), exports);
60
+ __exportStar(require("./expand_macros"), exports);
60
61
  __exportStar(require("./exporting"), exports);
61
62
  __exportStar(require("./forbidden_identifier"), exports);
62
63
  __exportStar(require("./forbidden_pseudo_and_pragma"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.94.25",
3
+ "version": "2.95.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",