@abaplint/core 2.106.9 → 2.107.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.
@@ -6490,10 +6490,7 @@ declare class Table extends AbstractObject {
6490
6490
  private parsedData;
6491
6491
  getType(): string;
6492
6492
  getDescription(): string | undefined;
6493
- getAllowedNaming(): {
6494
- maxLength: number;
6495
- allowNamespace: boolean;
6496
- };
6493
+ getAllowedNaming(): IAllowedNaming;
6497
6494
  setDirty(): void;
6498
6495
  listKeys(reg: IRegistry): string[];
6499
6496
  parseType(reg: IRegistry): AbstractType;
@@ -35,12 +35,14 @@ class Table extends _abstract_object_1.AbstractObject {
35
35
  }
36
36
  getAllowedNaming() {
37
37
  let length = 30;
38
+ const regex = /^((\/[A-Z_\d]{3,8}\/)|[a-zA-Z0-9]{3})\w+$/;
38
39
  if (this.getTableCategory() === TableCategory.Transparent) {
39
40
  length = 16;
40
41
  }
41
42
  return {
42
43
  maxLength: length,
43
44
  allowNamespace: true,
45
+ customRegex: regex,
44
46
  };
45
47
  }
46
48
  setDirty() {
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.106.9";
68
+ return "2.107.0";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlignTypeExpressions = exports.AlignTypeExpressionsConf = 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 Structures = require("../abap/3_structures/structures");
9
+ const Statements = require("../abap/2_statements/statements");
10
+ const Expressions = require("../abap/2_statements/expressions");
11
+ /*
12
+ import {EditHelper, IEdit} from "../edit_helper";
13
+ */
14
+ class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
15
+ }
16
+ exports.AlignTypeExpressionsConf = AlignTypeExpressionsConf;
17
+ class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.conf = new AlignTypeExpressionsConf();
21
+ }
22
+ getMetadata() {
23
+ return {
24
+ key: "align_type_expressions",
25
+ title: "Align TYPE expressions",
26
+ shortDescription: `Align TYPE expressions in statements`,
27
+ extendedInformation: `
28
+ Currently works for METHODS + BEGIN OF
29
+
30
+ Also note that clean ABAP does not recommend aligning TYPE clauses:
31
+ 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],
33
+ badExample: `
34
+ TYPES: BEGIN OF foo,
35
+ bar TYPE i,
36
+ foobar TYPE i,
37
+ END OF foo.
38
+
39
+ INTERFACE lif.
40
+ METHODS bar
41
+ IMPORTING
42
+ foo TYPE i
43
+ foobar TYPE i.
44
+ ENDINTERFACE.`,
45
+ goodExample: `
46
+ TYPES: BEGIN OF foo,
47
+ bar TYPE i,
48
+ foobar TYPE i,
49
+ END OF foo.
50
+
51
+ INTERFACE lif.
52
+ METHODS bar
53
+ IMPORTING
54
+ foo TYPE i
55
+ foobar TYPE i.
56
+ ENDINTERFACE.`,
57
+ };
58
+ }
59
+ getConfig() {
60
+ return this.conf;
61
+ }
62
+ setConfig(conf) {
63
+ this.conf = conf;
64
+ }
65
+ runParsed(file) {
66
+ const issues = [];
67
+ const stru = file.getStructure();
68
+ if (stru === undefined) {
69
+ return issues; // parser error
70
+ }
71
+ issues.push(...this.checkTypes(stru, file));
72
+ issues.push(...this.checkMethods(stru, file));
73
+ return issues;
74
+ }
75
+ checkMethods(stru, file) {
76
+ const issues = [];
77
+ const methods = stru.findAllStatements(Statements.MethodDef);
78
+ for (const m of methods) {
79
+ const fields = [];
80
+ const params = m.findAllExpressions(Expressions.MethodParam);
81
+ let column = 0;
82
+ for (const p of params) {
83
+ const children = p.getChildren();
84
+ const name = children[children.length - 2];
85
+ fields.push({
86
+ nameEnd: name.getLastToken().getEnd(),
87
+ after: p.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
88
+ });
89
+ column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
90
+ }
91
+ const ret = m.findFirstExpression(Expressions.MethodDefReturning);
92
+ if (ret) {
93
+ const children = ret.getChildren();
94
+ const name = children[children.length - 2];
95
+ fields.push({
96
+ nameEnd: name.getLastToken().getEnd(),
97
+ after: ret.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
98
+ });
99
+ column = Math.max(column, name.getLastToken().getEnd().getCol() + 1);
100
+ }
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
+ }
109
+ }
110
+ return issues;
111
+ }
112
+ checkTypes(stru, file) {
113
+ const issues = [];
114
+ const types = stru.findAllStructuresRecursive(Structures.Types);
115
+ for (const t of types) {
116
+ const fields = [];
117
+ let column = 0;
118
+ const st = t.findDirectStatements(Statements.Type);
119
+ for (const s of st) {
120
+ const name = s.getChildren()[1];
121
+ fields.push({
122
+ nameEnd: name.getLastToken().getEnd(),
123
+ after: s.getChildren()[2].getFirstToken().getStart()
124
+ });
125
+ column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
126
+ }
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
+ }
135
+ }
136
+ return issues;
137
+ }
138
+ }
139
+ exports.AlignTypeExpressions = AlignTypeExpressions;
140
+ //# sourceMappingURL=align_type_expressions.js.map
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./7bit_ascii"), exports);
18
18
  __exportStar(require("./abapdoc"), exports);
19
19
  __exportStar(require("./align_parameters"), exports);
20
+ __exportStar(require("./align_type_expressions"), exports);
20
21
  __exportStar(require("./allowed_object_naming"), exports);
21
22
  __exportStar(require("./allowed_object_types"), exports);
22
23
  __exportStar(require("./ambiguous_statement"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.106.9",
3
+ "version": "2.107.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",