@abaplint/core 2.82.10 → 2.82.14

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.
@@ -324,6 +324,7 @@ declare namespace BasicTypes {
324
324
  CSequenceType,
325
325
  DataReference,
326
326
  DateType,
327
+ DecFloatType,
327
328
  DecFloat16Type,
328
329
  DecFloat34Type,
329
330
  FloatType,
@@ -878,10 +879,7 @@ declare class ConcatenatedConstant extends Expression {
878
879
 
879
880
  declare class ConceptsOfPackage extends AbstractObject {
880
881
  getType(): string;
881
- getAllowedNaming(): {
882
- maxLength: number;
883
- allowNamespace: boolean;
884
- };
882
+ getAllowedNaming(): IAllowedNaming;
885
883
  getDescription(): string | undefined;
886
884
  }
887
885
 
@@ -1241,6 +1239,13 @@ declare class DecFloat34Type extends AbstractType {
1241
1239
  containsVoid(): boolean;
1242
1240
  }
1243
1241
 
1242
+ declare class DecFloatType extends AbstractType {
1243
+ toText(): string;
1244
+ isGeneric(): boolean;
1245
+ toABAP(): string;
1246
+ containsVoid(): boolean;
1247
+ }
1248
+
1244
1249
  declare class Decimals extends Expression {
1245
1250
  getRunnable(): IStatementRunnable;
1246
1251
  }
@@ -2339,12 +2344,15 @@ declare interface IAliases {
2339
2344
  getAll(): readonly Alias[];
2340
2345
  }
2341
2346
 
2347
+ declare interface IAllowedNaming {
2348
+ maxLength: number;
2349
+ allowNamespace: boolean;
2350
+ customRegex?: RegExp;
2351
+ }
2352
+
2342
2353
  declare interface IArtifact {
2343
2354
  getType(): string;
2344
- getAllowedNaming(): {
2345
- maxLength: number;
2346
- allowNamespace: boolean;
2347
- };
2355
+ getAllowedNaming(): IAllowedNaming;
2348
2356
  }
2349
2357
 
2350
2358
  declare interface IAttributes {
@@ -3142,7 +3150,7 @@ export declare class Issue {
3142
3150
  static atRow(file: IFile, row: number, message: string, key: string, severity?: Severity): Issue;
3143
3151
  static atStatement(file: IFile, statement: StatementNode, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3144
3152
  static atPosition(file: IFile, start: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3145
- static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity): Issue;
3153
+ static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3146
3154
  static atRange(file: IFile, start: Position, end: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3147
3155
  static atToken(file: IFile, token: Token, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3148
3156
  static atIdentifier(identifier: Identifier, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
@@ -3600,10 +3608,7 @@ declare class Multiply implements IStatement {
3600
3608
 
3601
3609
  declare class Namespace extends AbstractObject {
3602
3610
  getType(): string;
3603
- getAllowedNaming(): {
3604
- maxLength: number;
3605
- allowNamespace: boolean;
3606
- };
3611
+ getAllowedNaming(): IAllowedNaming;
3607
3612
  getDescription(): string | undefined;
3608
3613
  }
3609
3614
 
@@ -5903,10 +5908,7 @@ declare class WebDynproComponentConfiguration extends AbstractObject {
5903
5908
 
5904
5909
  declare class WebMIME extends AbstractObject {
5905
5910
  getType(): string;
5906
- getAllowedNaming(): {
5907
- maxLength: number;
5908
- allowNamespace: boolean;
5909
- };
5911
+ getAllowedNaming(): IAllowedNaming;
5910
5912
  getDescription(): string | undefined;
5911
5913
  }
5912
5914
 
@@ -44,6 +44,18 @@ class ObjectOriented {
44
44
  }
45
45
  }
46
46
  }
47
+ addAliasedTypes(aliases) {
48
+ for (const alias of aliases.getAll()) {
49
+ const comp = alias.getComponent();
50
+ const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
51
+ if (idef) {
52
+ const found = idef.getTypeDefinitions().getByName(comp.split("~")[1]);
53
+ if (found) {
54
+ this.scope.addTypeNamed(alias.getName(), found);
55
+ }
56
+ }
57
+ }
58
+ }
47
59
  findMethodInInterface(interfaceName, methodName) {
48
60
  const idef = this.scope.findInterfaceDefinition(interfaceName);
49
61
  if (idef) {
@@ -7,7 +7,7 @@ const target_1 = require("../expressions/target");
7
7
  const dynamic_1 = require("../expressions/dynamic");
8
8
  class GetBadi {
9
9
  runSyntax(node, scope, filename) {
10
- for (const s of node.findDirectExpressions(Expressions.Source)) {
10
+ for (const s of node.findAllExpressions(Expressions.Source)) {
11
11
  new source_1.Source().runSyntax(s, scope, filename);
12
12
  }
13
13
  for (const t of node.findDirectExpressions(Expressions.Target)) {
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecFloatType = void 0;
4
+ const _abstract_type_1 = require("./_abstract_type");
5
+ class DecFloatType extends _abstract_type_1.AbstractType {
6
+ toText() {
7
+ return "```decfloat```";
8
+ }
9
+ isGeneric() {
10
+ return true;
11
+ }
12
+ toABAP() {
13
+ return "decfloat";
14
+ }
15
+ containsVoid() {
16
+ return false;
17
+ }
18
+ }
19
+ exports.DecFloatType = DecFloatType;
20
+ //# sourceMappingURL=decfloat_type.js.map
@@ -16,6 +16,7 @@ __exportStar(require("./clike_type"), exports);
16
16
  __exportStar(require("./csequence_type"), exports);
17
17
  __exportStar(require("./data_reference_type"), exports);
18
18
  __exportStar(require("./date_type"), exports);
19
+ __exportStar(require("./decfloat_type"), exports);
19
20
  __exportStar(require("./decfloat16_type"), exports);
20
21
  __exportStar(require("./decfloat34_type"), exports);
21
22
  __exportStar(require("./float_type"), exports);
@@ -32,6 +32,7 @@ class ClassDefinition extends _identifier_1.Identifier {
32
32
  this.parse(filename, scope);
33
33
  const helper = new _object_oriented_1.ObjectOriented(scope);
34
34
  helper.fromSuperClassesAndInterfaces(this);
35
+ helper.addAliasedTypes(this.aliases);
35
36
  this.attributes = new class_attributes_1.Attributes(this.node, this.filename, scope);
36
37
  this.types = this.attributes.getTypes();
37
38
  this.methodDefs = new method_definitions_1.MethodDefinitions(this.node, this.filename, scope);
package/build/src/ddic.js CHANGED
@@ -57,6 +57,8 @@ class DDIC {
57
57
  return new Types.XSequenceType();
58
58
  case "CLIKE":
59
59
  return new Types.CLikeType();
60
+ case "DECFLOAT":
61
+ return new Types.DecFloatType();
60
62
  case "ANY":
61
63
  return new Types.AnyType();
62
64
  case "SIMPLE":
@@ -48,7 +48,7 @@ class Issue {
48
48
  severity,
49
49
  });
50
50
  }
51
- static atRowRange(file, row, startCol, endCol, message, key, severity) {
51
+ static atRowRange(file, row, startCol, endCol, message, key, severity, fix) {
52
52
  const start = new position_1.Position(row, startCol);
53
53
  const end = new position_1.Position(row, endCol);
54
54
  severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
@@ -58,6 +58,7 @@ class Issue {
58
58
  key,
59
59
  start,
60
60
  end,
61
+ fix,
61
62
  severity,
62
63
  });
63
64
  }
@@ -10,6 +10,7 @@ class ConceptsOfPackage extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 30,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_-\d<> ]+$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -10,6 +10,7 @@ class Namespace extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 10,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^\/[A-Z_\d]{3,8}\/$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -59,6 +59,9 @@ class TableType extends _abstract_object_1.AbstractObject {
59
59
  else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype === "OBJECT") {
60
60
  type = new Types.TableType(new basic_1.GenericObjectReferenceType(), { withHeader: false }, this.getName());
61
61
  }
62
+ else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype === "DATA") {
63
+ type = new Types.TableType(new basic_1.DataReference(new basic_1.AnyType()), { withHeader: false }, this.getName());
64
+ }
62
65
  else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype !== undefined) {
63
66
  const lookup = ddic.lookupObject(this.parsedXML.rowtype);
64
67
  type = new Types.TableType(lookup.type, { withHeader: false }, this.getName());
@@ -10,6 +10,7 @@ class WebMIME extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 40,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^[A-Z_-\d/<> ]+$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.82.10";
71
+ return "2.82.14";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -30,19 +30,20 @@ class AllowedObjectNaming {
30
30
  }
31
31
  run(obj) {
32
32
  const allowed = obj.getAllowedNaming();
33
+ const name = obj.getName();
33
34
  let message = "";
34
- if (obj.getName().length > allowed.maxLength) {
35
+ if (name.length > allowed.maxLength) {
35
36
  message = "Name exceeds max length";
36
37
  }
37
- else if (allowed.allowNamespace === false && obj.getName().indexOf("/") >= 0) {
38
+ else if (allowed.allowNamespace === false && name.indexOf("/") >= 0) {
38
39
  message = "Namespace not allowed for object type";
39
40
  }
40
- else if (obj.getType() === "NSPC") {
41
- if (obj.getName().match(/^\/[A-Z_\d]{3,8}\/$/i) === null) {
41
+ else if (allowed.customRegex !== undefined) {
42
+ if (name.match(allowed.customRegex) === null) {
42
43
  message = "Name not allowed";
43
44
  }
44
45
  }
45
- else if (obj.getName().match(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_-\d<> ]+$/i) === null) {
46
+ else if (name.match(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_\d<> ]+$/i) === null) {
46
47
  message = "Name not allowed";
47
48
  }
48
49
  if (message.length > 0) {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SpaceBeforeColon = exports.SpaceBeforeColonConf = void 0;
4
+ const position_1 = require("../position");
5
+ const edit_helper_1 = require("../edit_helper");
4
6
  const issue_1 = require("../issue");
5
7
  const _abap_rule_1 = require("./_abap_rule");
6
8
  const _basic_rule_config_1 = require("./_basic_rule_config");
@@ -19,7 +21,7 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
19
21
  title: "Space before colon",
20
22
  shortDescription: `Checks that there are no spaces in front of colons in chained statements.`,
21
23
  extendedInformation: `https://docs.abapopenchecks.org/checks/80/`,
22
- tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
24
+ tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
23
25
  badExample: `DATA : foo TYPE string.`,
24
26
  goodExample: `DATA: foo TYPE string.`,
25
27
  };
@@ -44,8 +46,10 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
44
46
  else if (token.getStr() === ":"
45
47
  && prev.getRow() === token.getRow()
46
48
  && prev.getCol() + prev.getStr().length < token.getCol()) {
47
- const issue = issue_1.Issue.atRowRange(file, token.getRow(), prev.getEnd().getCol(), token.getStart().getCol(), this.getMessage(), this.getMetadata().key, this.conf.severity);
48
- // const issue = Issue.atToken(file, token, this.getMessage(), this.getMetadata().key);
49
+ const start = new position_1.Position(token.getRow(), prev.getEnd().getCol());
50
+ const end = new position_1.Position(token.getRow(), token.getStart().getCol());
51
+ const fix = edit_helper_1.EditHelper.deleteRange(file, start, end);
52
+ const issue = issue_1.Issue.atRowRange(file, start.getRow(), start.getCol(), end.getCol(), this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
49
53
  issues.push(issue);
50
54
  }
51
55
  prev = token;
@@ -40,9 +40,27 @@ class UnknownTypes {
40
40
  return [];
41
41
  }
42
42
  const spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
43
- return this.traverse(spaghetti.getTop());
43
+ const found = this.traverse(spaghetti.getTop());
44
+ return this.removeDuplicates(found);
44
45
  }
45
46
  /////////////////////
47
+ removeDuplicates(list) {
48
+ const deduplicated = [];
49
+ for (const result of list) {
50
+ let cont = false;
51
+ for (const d of deduplicated) {
52
+ if (result.getStart().equals(d.getStart())) {
53
+ cont = true;
54
+ break;
55
+ }
56
+ }
57
+ if (cont === true) {
58
+ continue;
59
+ }
60
+ deduplicated.push(result);
61
+ }
62
+ return deduplicated;
63
+ }
46
64
  traverse(node) {
47
65
  var _a;
48
66
  const ret = [];
@@ -73,7 +91,14 @@ class UnknownTypes {
73
91
  }
74
92
  }
75
93
  for (const v of node.getData().idefs) {
76
- const found = this.checkInterface(v);
94
+ const found = this.checkMethodParameters(v);
95
+ if (found) {
96
+ const message = "Contains unknown, " + found.found;
97
+ ret.push(issue_1.Issue.atIdentifier(found.id, message, this.getMetadata().key, this.conf.severity));
98
+ }
99
+ }
100
+ for (const v of node.getData().cdefs) {
101
+ const found = this.checkMethodParameters(v);
77
102
  if (found) {
78
103
  const message = "Contains unknown, " + found.found;
79
104
  ret.push(issue_1.Issue.atIdentifier(found.id, message, this.getMetadata().key, this.conf.severity));
@@ -84,7 +109,7 @@ class UnknownTypes {
84
109
  }
85
110
  return ret;
86
111
  }
87
- checkInterface(idef) {
112
+ checkMethodParameters(idef) {
88
113
  var _a;
89
114
  for (const m of ((_a = idef.getMethodDefinitions()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
90
115
  for (const p of m.getParameters().getAll()) {
@@ -5,6 +5,7 @@ const issue_1 = require("../issue");
5
5
  const _abap_rule_1 = require("./_abap_rule");
6
6
  const _basic_rule_config_1 = require("./_basic_rule_config");
7
7
  const _irule_1 = require("./_irule");
8
+ const edit_helper_1 = require("../edit_helper");
8
9
  class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
9
10
  }
10
11
  exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
@@ -19,7 +20,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
19
20
  title: "Unnecessary Chaining",
20
21
  shortDescription: `Find unnecessary chaining, all statements are checked`,
21
22
  extendedInformation: ``,
22
- tags: [_irule_1.RuleTag.SingleFile],
23
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
23
24
  badExample: `WRITE: bar.`,
24
25
  goodExample: `WRITE bar.`,
25
26
  };
@@ -47,8 +48,9 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
47
48
  else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
48
49
  continue;
49
50
  }
51
+ const fix = edit_helper_1.EditHelper.deleteRange(file, colon.getStart(), colon.getEnd());
50
52
  const message = "Unnecessary chaining";
51
- const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
53
+ const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key, this.conf.severity, fix);
52
54
  issues.push(issue);
53
55
  }
54
56
  return issues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.82.10",
3
+ "version": "2.82.14",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.18.19",
48
+ "@microsoft/api-extractor": "^7.18.20",
49
49
  "@types/chai": "^4.2.22",
50
50
  "@types/mocha": "^9.0.0",
51
51
  "@types/node": "^16.11.11",
52
52
  "chai": "^4.3.4",
53
- "eslint": "^8.3.0",
53
+ "eslint": "^8.4.0",
54
54
  "mocha": "^9.1.3",
55
55
  "c8": "^7.10.0",
56
56
  "source-map-support": "^0.5.21",