@abaplint/core 2.107.0 → 2.107.1

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.
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.107.0";
68
+ return "2.107.1";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -23,6 +23,8 @@ https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_gui
23
23
 
24
24
  Checkes files with extensions ".abap" and ".asddls"`,
25
25
  tags: [_irule_1.RuleTag.SingleFile],
26
+ badExample: `WRITE '뽑'.`,
27
+ goodExample: `WRITE cl_abap_conv_in_ce=>uccp( 'BF51' ).`,
26
28
  };
27
29
  }
28
30
  initialize(_reg) {
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlignTypeExpressions = exports.AlignTypeExpressionsConf = void 0;
4
- const issue_1 = require("../issue");
5
4
  const _abap_rule_1 = require("./_abap_rule");
6
5
  const _basic_rule_config_1 = require("./_basic_rule_config");
6
+ const objects_1 = require("../objects");
7
+ const ddic_1 = require("../ddic");
7
8
  const _irule_1 = require("./_irule");
8
- const Structures = require("../abap/3_structures/structures");
9
- const Statements = require("../abap/2_statements/statements");
9
+ const issue_1 = require("../issue");
10
+ const position_1 = require("../position");
10
11
  const Expressions = require("../abap/2_statements/expressions");
11
- /*
12
- import {EditHelper, IEdit} from "../edit_helper";
13
- */
12
+ const Statements = require("../abap/2_statements/statements");
13
+ const Structures = require("../abap/3_structures/structures");
14
+ const edit_helper_1 = require("../edit_helper");
14
15
  class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
16
+ constructor() {
17
+ super(...arguments);
18
+ /** Ignore global exception classes */
19
+ this.ignoreExceptions = true;
20
+ }
15
21
  }
16
22
  exports.AlignTypeExpressionsConf = AlignTypeExpressionsConf;
17
23
  class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
@@ -27,9 +33,11 @@ class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
27
33
  extendedInformation: `
28
34
  Currently works for METHODS + BEGIN OF
29
35
 
36
+ If BEGIN OF has an INCLUDE TYPE its ignored
37
+
30
38
  Also note that clean ABAP does not recommend aligning TYPE clauses:
31
39
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses`,
32
- tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
40
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
33
41
  badExample: `
34
42
  TYPES: BEGIN OF foo,
35
43
  bar TYPE i,
@@ -62,16 +70,45 @@ ENDINTERFACE.`,
62
70
  setConfig(conf) {
63
71
  this.conf = conf;
64
72
  }
65
- runParsed(file) {
73
+ runParsed(file, obj) {
66
74
  const issues = [];
67
75
  const stru = file.getStructure();
68
76
  if (stru === undefined) {
69
77
  return issues; // parser error
70
78
  }
79
+ const ddic = new ddic_1.DDIC(this.reg);
80
+ if (obj instanceof objects_1.Class) {
81
+ const definition = obj.getClassDefinition();
82
+ if (definition === undefined) {
83
+ return [];
84
+ }
85
+ else if (this.conf.ignoreExceptions && ddic.isException(definition, obj)) {
86
+ return [];
87
+ }
88
+ }
71
89
  issues.push(...this.checkTypes(stru, file));
72
90
  issues.push(...this.checkMethods(stru, file));
73
91
  return issues;
74
92
  }
93
+ check(fields, column, file) {
94
+ const issues = [];
95
+ for (const f of fields) {
96
+ if (f.after.getCol() === column) {
97
+ continue;
98
+ }
99
+ let fix = undefined;
100
+ if (f.after.getCol() < column) {
101
+ fix = edit_helper_1.EditHelper.insertAt(file, f.after, " ".repeat(column - f.after.getCol()));
102
+ }
103
+ else {
104
+ fix = edit_helper_1.EditHelper.deleteRange(file, new position_1.Position(f.after.getRow(), column), f.after);
105
+ }
106
+ const message = `Align TYPE expressions to column ${column}`;
107
+ const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity, fix);
108
+ issues.push(issue);
109
+ }
110
+ return issues;
111
+ }
75
112
  checkMethods(stru, file) {
76
113
  const issues = [];
77
114
  const methods = stru.findAllStatements(Statements.MethodDef);
@@ -98,14 +135,7 @@ ENDINTERFACE.`,
98
135
  });
99
136
  column = Math.max(column, name.getLastToken().getEnd().getCol() + 1);
100
137
  }
101
- for (const f of fields) {
102
- if (f.after.getCol() !== column) {
103
- // const fix = this.buildFix(f.name, column);
104
- const message = `Align TYPE expressions to column ${column}`;
105
- const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
106
- issues.push(issue);
107
- }
108
- }
138
+ issues.push(...this.check(fields, column, file));
109
139
  }
110
140
  return issues;
111
141
  }
@@ -113,6 +143,9 @@ ENDINTERFACE.`,
113
143
  const issues = [];
114
144
  const types = stru.findAllStructuresRecursive(Structures.Types);
115
145
  for (const t of types) {
146
+ if (t.findDirectStatement(Statements.IncludeType)) {
147
+ continue;
148
+ }
116
149
  const fields = [];
117
150
  let column = 0;
118
151
  const st = t.findDirectStatements(Statements.Type);
@@ -124,14 +157,7 @@ ENDINTERFACE.`,
124
157
  });
125
158
  column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
126
159
  }
127
- for (const f of fields) {
128
- if (f.after.getCol() !== column) {
129
- // const fix = this.buildFix(f.name, column);
130
- const message = `Align TYPE expressions to column ${column}`;
131
- const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
132
- issues.push(issue);
133
- }
134
- }
160
+ issues.push(...this.check(fields, column, file));
135
161
  }
136
162
  return issues;
137
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.107.0",
3
+ "version": "2.107.1",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",