@abaplint/core 2.107.1 → 2.107.3

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.
@@ -1709,6 +1709,15 @@ declare class Detail implements IStatement {
1709
1709
  getMatcher(): IStatementRunnable;
1710
1710
  }
1711
1711
 
1712
+ export declare class Diagnostics {
1713
+ private readonly reg;
1714
+ constructor(reg: IRegistry);
1715
+ findIssues(textDocument: LServer.TextDocumentIdentifier): readonly Issue[];
1716
+ static mapDiagnostic(issue: Issue): LServer.Diagnostic;
1717
+ find(textDocument: LServer.TextDocumentIdentifier): LServer.Diagnostic[];
1718
+ private static mapSeverity;
1719
+ }
1720
+
1712
1721
  declare class DialogModule extends AbstractObject {
1713
1722
  getType(): string;
1714
1723
  getAllowedNaming(): {
@@ -3165,7 +3174,12 @@ declare interface IIssueData {
3165
3174
  start: Position;
3166
3175
  end: Position;
3167
3176
  severity: Severity;
3168
- fix?: IEdit;
3177
+ /** The default fix for the issue, it always makes sense to apply this fix
3178
+ * These are applied by "abaplint --fix" and in the document formatter in vscode extension
3179
+ */
3180
+ defaultFix?: IEdit;
3181
+ /** Alternative quick fixes, the developer must choose which to apply */
3182
+ alternativeFixes?: IEdit[];
3169
3183
  }
3170
3184
 
3171
3185
  declare interface IKeyword {
@@ -3798,7 +3812,8 @@ export declare class Issue {
3798
3812
  getStart(): Position;
3799
3813
  getEnd(): Position;
3800
3814
  getFilename(): string;
3801
- getFix(): IEdit | undefined;
3815
+ getDefaultFix(): IEdit | undefined;
3816
+ getAlternativeFixes(): IEdit[] | undefined;
3802
3817
  getSeverity(): Severity;
3803
3818
  }
3804
3819
 
@@ -4019,6 +4034,12 @@ declare class LoopTarget extends Expression {
4019
4034
  getRunnable(): IStatementRunnable;
4020
4035
  }
4021
4036
 
4037
+ export declare class LSPEdit {
4038
+ static mapEdits(edits: IEdit[]): LServer.WorkspaceEdit;
4039
+ static mapEdit(edit: IEdit): LServer.WorkspaceEdit;
4040
+ private static mapText;
4041
+ }
4042
+
4022
4043
  declare class MacroName extends Expression {
4023
4044
  getRunnable(): IStatementRunnable;
4024
4045
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.SkipLogic = 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;
4
- exports.RuleTag = exports.Severity = void 0;
3
+ exports.Info = exports.Diagnostics = 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.SkipLogic = 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;
4
+ exports.LSPEdit = exports.RuleTag = exports.Severity = exports.Visibility = void 0;
5
5
  const issue_1 = require("./issue");
6
6
  Object.defineProperty(exports, "Issue", { enumerable: true, get: function () { return issue_1.Issue; } });
7
7
  const config_1 = require("./config");
@@ -102,4 +102,8 @@ const cyclomatic_complexity_stats_1 = require("./utils/cyclomatic_complexity_sta
102
102
  Object.defineProperty(exports, "CyclomaticComplexityStats", { enumerable: true, get: function () { return cyclomatic_complexity_stats_1.CyclomaticComplexityStats; } });
103
103
  const skip_logic_1 = require("./skip_logic");
104
104
  Object.defineProperty(exports, "SkipLogic", { enumerable: true, get: function () { return skip_logic_1.SkipLogic; } });
105
+ const diagnostics_1 = require("./lsp/diagnostics");
106
+ Object.defineProperty(exports, "Diagnostics", { enumerable: true, get: function () { return diagnostics_1.Diagnostics; } });
107
+ const _edit_1 = require("./lsp/_edit");
108
+ Object.defineProperty(exports, "LSPEdit", { enumerable: true, get: function () { return _edit_1.LSPEdit; } });
105
109
  //# sourceMappingURL=index.js.map
@@ -32,7 +32,7 @@ class Issue {
32
32
  key,
33
33
  start,
34
34
  end,
35
- fix,
35
+ defaultFix: fix,
36
36
  severity,
37
37
  });
38
38
  }
@@ -46,7 +46,7 @@ class Issue {
46
46
  key,
47
47
  start,
48
48
  end,
49
- fix,
49
+ defaultFix: fix,
50
50
  severity,
51
51
  });
52
52
  }
@@ -58,7 +58,7 @@ class Issue {
58
58
  key,
59
59
  start,
60
60
  end,
61
- fix,
61
+ defaultFix: fix,
62
62
  severity,
63
63
  });
64
64
  }
@@ -71,7 +71,7 @@ class Issue {
71
71
  start: token.getStart(),
72
72
  end: token.getEnd(),
73
73
  severity,
74
- fix,
74
+ defaultFix: fix,
75
75
  });
76
76
  }
77
77
  static atIdentifier(identifier, message, key, severity, fix) {
@@ -83,14 +83,14 @@ class Issue {
83
83
  start: identifier.getStart(),
84
84
  end: identifier.getEnd(),
85
85
  severity,
86
- fix,
86
+ defaultFix: fix,
87
87
  });
88
88
  }
89
89
  constructor(data) {
90
90
  this.data = data;
91
91
  if (this.data.start instanceof virtual_position_1.VirtualPosition) {
92
92
  // no quick fixes inside macros
93
- this.data.fix = undefined;
93
+ this.data.defaultFix = undefined;
94
94
  }
95
95
  if (this.data.start.getCol() < 1) {
96
96
  throw new Error("issue, start col < 1");
@@ -117,8 +117,11 @@ class Issue {
117
117
  getFilename() {
118
118
  return this.data.filename;
119
119
  }
120
- getFix() {
121
- return this.data.fix;
120
+ getDefaultFix() {
121
+ return this.data.defaultFix;
122
+ }
123
+ getAlternativeFixes() {
124
+ return this.data.alternativeFixes;
122
125
  }
123
126
  getSeverity() {
124
127
  return this.data.severity;
@@ -15,22 +15,6 @@ class LSPEdit {
15
15
  }
16
16
  return workspace;
17
17
  }
18
- /*
19
- public static mapEditsDocument(edit: IEdit): LServer.WorkspaceEdit {
20
- const workspace: LServer.WorkspaceEdit = {documentChanges: []};
21
- for (const filename in edit) {
22
- const doc: LServer.VersionedTextDocumentIdentifier = {uri: filename, version: 1};
23
-
24
- const e = LServer.TextDocumentEdit.create(doc, this.mapText(edit[filename]));
25
- workspace.documentChanges?.push(e);
26
- }
27
- // @ts-ignore
28
- console.dir(workspace.documentChanges![0].edits[0]);
29
- // @ts-ignore
30
- console.dir(workspace.documentChanges![0].edits[1]);
31
- return workspace;
32
- }
33
- */
34
18
  static mapEdit(edit) {
35
19
  const workspace = { changes: {} };
36
20
  for (const filename in edit) {
@@ -16,7 +16,7 @@ class CodeActions {
16
16
  const shown = new Set();
17
17
  const ret = [];
18
18
  for (const i of issues) {
19
- const fix = i.getFix();
19
+ const fix = i.getDefaultFix();
20
20
  if (fix === undefined) {
21
21
  continue;
22
22
  }
@@ -51,7 +51,7 @@ class CodeActions {
51
51
  const diagnostics = [];
52
52
  const fixes = [];
53
53
  for (const i of issues) {
54
- const fix = i.getFix();
54
+ const fix = i.getDefaultFix();
55
55
  if (fix === undefined) {
56
56
  continue;
57
57
  }
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.107.1";
68
+ return "2.107.3";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -33,7 +33,8 @@ STATICS BEGIN OF bar.
33
33
  INCLUDE STRUCTURE syst.
34
34
  STATICS END OF bar.`,
35
35
  goodExample: `DATA BEGIN OF foo.
36
- INCLUDE STRUCTURE dselc.
36
+ DATA field TYPE i.
37
+ INCLUDE STRUCTURE dselc.
37
38
  DATA END OF foo.`,
38
39
  };
39
40
  }
@@ -141,7 +141,7 @@ https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statement
141
141
  }
142
142
  let prevFix;
143
143
  if (previousRow === colon.getStart().getRow()) {
144
- prevFix = (_a = issues.pop()) === null || _a === void 0 ? void 0 : _a.getFix();
144
+ prevFix = (_a = issues.pop()) === null || _a === void 0 ? void 0 : _a.getDefaultFix();
145
145
  }
146
146
  const fix = this.getFix(file, statement, statementNode, prevFix);
147
147
  const message = "Chain mainly declarations";
@@ -33,6 +33,7 @@ class CommentedCode extends _abap_rule_1.ABAPRule {
33
33
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#delete-code-instead-of-commenting-it
34
34
  https://docs.abapopenchecks.org/checks/14/`,
35
35
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
36
+ badExample: `* WRITE 'hello world'.`,
36
37
  };
37
38
  }
38
39
  getMessage() {
@@ -29,6 +29,8 @@ class ContainsTab extends _abap_rule_1.ABAPRule {
29
29
  https://docs.abapopenchecks.org/checks/09/
30
30
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#indent-and-snap-to-tab`,
31
31
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
32
+ badExample: `\tWRITE 'hello world'.`,
33
+ goodExample: ` WRITE 'hello world'.`,
32
34
  };
33
35
  }
34
36
  getMessage() {
@@ -22,6 +22,8 @@ class EmptyStatement extends _abap_rule_1.ABAPRule {
22
22
  title: "Remove empty statement",
23
23
  shortDescription: `Checks for empty statements (an empty statement is a single dot)`,
24
24
  tags: [_irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
25
+ badExample: `WRITE 'hello world'..`,
26
+ goodExample: `WRITE 'hello world'.`,
25
27
  };
26
28
  }
27
29
  getConfig() {
@@ -39,6 +39,24 @@ class Indentation extends _abap_rule_1.ABAPRule {
39
39
  title: "Indentation",
40
40
  shortDescription: `Checks indentation`,
41
41
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
42
+ badExample: `CLASS lcl DEFINITION.
43
+ PRIVATE SECTION.
44
+ METHODS constructor.
45
+ ENDCLASS.
46
+
47
+ CLASS lcl IMPLEMENTATION.
48
+ METHOD constructor.
49
+ ENDMETHOD.
50
+ ENDCLASS.`,
51
+ goodExample: `CLASS lcl DEFINITION.
52
+ PRIVATE SECTION.
53
+ METHODS constructor.
54
+ ENDCLASS.
55
+
56
+ CLASS lcl IMPLEMENTATION.
57
+ METHOD constructor.
58
+ ENDMETHOD.
59
+ ENDCLASS.`,
42
60
  };
43
61
  }
44
62
  getConfig() {
@@ -113,6 +113,8 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
113
113
  shortDescription: `Checks that keywords have the same case. Non-keywords must be lower case.`,
114
114
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-your-pretty-printer-team-settings`,
115
115
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
116
+ badExample: `write 'hello world'.`,
117
+ goodExample: `WRITE 'hello world'.`,
116
118
  };
117
119
  }
118
120
  getConfig() {
@@ -34,6 +34,12 @@ class LocalVariableNames extends _abap_rule_1.ABAPRule {
34
34
  Allows you to enforce a pattern, such as a prefix, for local variables, constants and field symbols.
35
35
  Regexes are case-insensitive.`,
36
36
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
37
+ badExample: `FORM bar.
38
+ DATA foo.
39
+ ENDFORM.`,
40
+ goodExample: `FORM bar.
41
+ DATA lv_foo.
42
+ ENDFORM.`,
37
43
  };
38
44
  }
39
45
  getDescription(expected, actual) {
@@ -25,6 +25,15 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obscu
25
25
 
26
26
  Interface method names are ignored`,
27
27
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
28
+ badExample: `CLASS lcl DEFINITION.
29
+ PUBLIC SECTION.
30
+ METHODS matches.
31
+ ENDCLASS.
32
+
33
+ CLASS lcl IMPLEMENTATION.
34
+ METHOD matches.
35
+ ENDMETHOD.
36
+ ENDCLASS.`,
28
37
  };
29
38
  }
30
39
  getConfig() {
@@ -23,6 +23,13 @@ class MixReturning extends _abap_rule_1.ABAPRule {
23
23
  // eslint-disable-next-line max-len
24
24
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-either-returning-or-exporting-or-changing-but-not-a-combination`,
25
25
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
26
+ badExample: `CLASS lcl DEFINITION.
27
+ PUBLIC SECTION.
28
+ METHODS
29
+ foobar
30
+ EXPORTING foo TYPE i
31
+ RETURNING VALUE(rv_string) TYPE string.
32
+ ENDCLASS.`,
26
33
  };
27
34
  }
28
35
  getMessage() {
@@ -23,6 +23,10 @@ class PreferReturningToExporting extends _abap_rule_1.ABAPRule {
23
23
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-returning-to-exporting
24
24
  https://docs.abapopenchecks.org/checks/44/`,
25
25
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
26
+ badExample: `CLASS lcl DEFINITION.
27
+ PUBLIC SECTION.
28
+ METHODS test EXPORTING ev_foo TYPE i.
29
+ ENDCLASS.`,
26
30
  };
27
31
  }
28
32
  getConfig() {
@@ -27,6 +27,10 @@ class PreferredCompareOperator extends _abap_rule_1.ABAPRule {
27
27
  title: "Preferred compare operator",
28
28
  shortDescription: `Configure undesired operator variants`,
29
29
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
30
+ badExample: `IF foo EQ bar.
31
+ ENDIF.`,
32
+ goodExample: `IF foo = bar.
33
+ ENDIF.`,
30
34
  };
31
35
  }
32
36
  getDescription(operator) {
@@ -32,6 +32,8 @@ add ORDER BY PRIMARY KEY if in doubt
32
32
 
33
33
  If the target is a sorted/hashed table, no issue is reported`,
34
34
  tags: [_irule_1.RuleTag.SingleFile],
35
+ badExample: `SELECT * FROM db INTO TABLE @DATA(tab).`,
36
+ goodExample: `SELECT * FROM db INTO TABLE @DATA(tab) ORDER BY PRIMARY KEY.`,
35
37
  };
36
38
  }
37
39
  getConfig() {
@@ -28,6 +28,8 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
28
28
  shortDescription: `Allows you to enforce a pattern for TYPES definitions`,
29
29
  extendedInformation: `Does not run for TYPE POOLS`,
30
30
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
31
+ badExample: `TYPES foo TYPE i.`,
32
+ goodExample: `TYPES ty_foo TYPE i.`,
31
33
  };
32
34
  }
33
35
  getConfig() {
@@ -22,6 +22,16 @@ class UseClassBasedExceptions extends _abap_rule_1.ABAPRule {
22
22
  shortDescription: `Use class based exceptions, checks interface and class definitions`,
23
23
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-class-based-exceptions`,
24
24
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
25
+ badExample: `INTERFACE lif.
26
+ METHODS load_data
27
+ EXCEPTIONS
28
+ invalid_parameter.
29
+ ENDINTERFACE.`,
30
+ goodExample: `INTERFACE lif.
31
+ METHODS load_data
32
+ RAISING
33
+ cx_something.
34
+ ENDINTERFACE.`,
25
35
  };
26
36
  }
27
37
  getMessage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.107.1",
3
+ "version": "2.107.3",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -51,9 +51,9 @@
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
53
  "@microsoft/api-extractor": "^7.43.1",
54
- "@types/chai": "^4.3.14",
54
+ "@types/chai": "^4.3.16",
55
55
  "@types/mocha": "^10.0.6",
56
- "@types/node": "^20.12.7",
56
+ "@types/node": "^20.12.8",
57
57
  "chai": "^4.4.1",
58
58
  "eslint": "^8.57.0",
59
59
  "mocha": "^10.4.0",