@abaplint/core 2.99.0 → 2.99.2

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.
@@ -817,7 +817,11 @@ declare class ChapterOfBookStructure extends AbstractObject {
817
817
  declare class CharacterType extends AbstractType {
818
818
  private readonly length;
819
819
  constructor(length: number, extra?: AbstractTypeData);
820
- cloneType(qualifiedName?: string, ddicName?: string): CharacterType;
820
+ cloneType(input: {
821
+ qualifiedName?: string;
822
+ ddicName?: string;
823
+ derivedFromConstant?: boolean;
824
+ }): CharacterType;
821
825
  getLength(): number;
822
826
  toText(): string;
823
827
  toABAP(): string;
@@ -208,7 +208,7 @@ class TypeUtils {
208
208
  return false;
209
209
  }
210
210
  isAssignableStrict(source, target) {
211
- var _a, _b;
211
+ var _a, _b, _c, _d;
212
212
  /*
213
213
  console.dir(source);
214
214
  console.dir(target);
@@ -227,6 +227,20 @@ class TypeUtils {
227
227
  return false;
228
228
  }
229
229
  }
230
+ else if (source instanceof basic_1.HexType) {
231
+ if (target instanceof basic_1.HexType) {
232
+ if (((_c = source.getAbstractTypeData()) === null || _c === void 0 ? void 0 : _c.derivedFromConstant) === true) {
233
+ return source.getLength() <= target.getLength();
234
+ }
235
+ return source.getLength() === target.getLength();
236
+ }
237
+ else if (target instanceof basic_1.IntegerType) {
238
+ if (((_d = source.getAbstractTypeData()) === null || _d === void 0 ? void 0 : _d.derivedFromConstant) === true) {
239
+ return true;
240
+ }
241
+ return false;
242
+ }
243
+ }
230
244
  else if (source instanceof basic_1.StringType && target instanceof basic_1.StructureType) {
231
245
  if (this.structureContainsString(target)) {
232
246
  return false;
@@ -190,7 +190,7 @@ class BasicTypes {
190
190
  if (type instanceof basic_1.CharacterType
191
191
  && qualifiedName
192
192
  && qualifiedName.includes("-") === false) {
193
- type = type.cloneType(qualifiedName);
193
+ type = type.cloneType({ qualifiedName });
194
194
  }
195
195
  return type;
196
196
  }
@@ -94,10 +94,26 @@ class FieldChain {
94
94
  context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, refType);
95
95
  }
96
96
  else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {
97
- new field_offset_1.FieldOffset().runSyntax(current, scope, filename);
97
+ const offset = new field_offset_1.FieldOffset().runSyntax(current, scope, filename);
98
+ if (offset) {
99
+ if (context instanceof basic_1.CharacterType) {
100
+ context = new basic_1.CharacterType(context.getLength() - offset);
101
+ }
102
+ else if (context instanceof basic_1.HexType) {
103
+ context = new basic_1.HexType(context.getLength() - offset);
104
+ }
105
+ }
98
106
  }
99
107
  else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {
100
- new field_length_1.FieldLength().runSyntax(current, scope, filename);
108
+ const length = new field_length_1.FieldLength().runSyntax(current, scope, filename);
109
+ if (length) {
110
+ if (context instanceof basic_1.CharacterType) {
111
+ context = new basic_1.CharacterType(length);
112
+ }
113
+ else if (context instanceof basic_1.HexType) {
114
+ context = new basic_1.HexType(length);
115
+ }
116
+ }
101
117
  }
102
118
  }
103
119
  return context;
@@ -9,6 +9,15 @@ class FieldLength {
9
9
  const field = node.findDirectExpression(Expressions.SimpleFieldChain2);
10
10
  if (field) {
11
11
  new field_chain_1.FieldChain().runSyntax(field, scope, filename, _reference_1.ReferenceType.DataReadReference);
12
+ return undefined;
13
+ }
14
+ else {
15
+ const children = node.getChildren();
16
+ const num = children[children.length - 2];
17
+ if (num.getLastToken().getStr() === "*") {
18
+ return undefined;
19
+ }
20
+ return parseInt(num.getLastToken().getStr(), 10);
12
21
  }
13
22
  }
14
23
  }
@@ -9,6 +9,10 @@ class FieldOffset {
9
9
  const field = node.findDirectExpression(Expressions.SimpleFieldChain2);
10
10
  if (field) {
11
11
  new field_chain_1.FieldChain().runSyntax(field, scope, filename, _reference_1.ReferenceType.DataReadReference);
12
+ return undefined;
13
+ }
14
+ else {
15
+ return parseInt(node.getLastToken().getStr(), 10);
12
16
  }
13
17
  }
14
18
  }
@@ -10,13 +10,16 @@ class CharacterType extends _abstract_type_1.AbstractType {
10
10
  }
11
11
  this.length = length;
12
12
  }
13
- cloneType(qualifiedName, ddicName) {
13
+ cloneType(input) {
14
14
  const clone = Object.assign({}, this.getAbstractTypeData()) || {};
15
- if (qualifiedName) {
16
- clone.qualifiedName = qualifiedName;
15
+ if (input.qualifiedName) {
16
+ clone.qualifiedName = input.qualifiedName;
17
17
  }
18
- if (ddicName) {
19
- clone.ddicName = ddicName;
18
+ if (input.ddicName) {
19
+ clone.ddicName = input.ddicName;
20
+ }
21
+ if (input.derivedFromConstant) {
22
+ clone.derivedFromConstant = input.derivedFromConstant;
20
23
  }
21
24
  return new CharacterType(this.length, clone);
22
25
  }
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.99.0";
66
+ return "2.99.2";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -7,6 +7,7 @@ const issue_1 = require("../issue");
7
7
  const Expressions = require("../abap/2_statements/expressions");
8
8
  const _irule_1 = require("./_irule");
9
9
  const statements_1 = require("../abap/2_statements/statements");
10
+ const edit_helper_1 = require("../edit_helper");
10
11
  class OmitPrecedingZerosConf extends _basic_rule_config_1.BasicRuleConfig {
11
12
  }
12
13
  exports.OmitPrecedingZerosConf = OmitPrecedingZerosConf;
@@ -20,7 +21,7 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
20
21
  key: "omit_preceding_zeros",
21
22
  title: "Omit preceding zeros",
22
23
  shortDescription: `Omit preceding zeros from integer constants`,
23
- tags: [_irule_1.RuleTag.SingleFile],
24
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
24
25
  badExample: `int = -001.`,
25
26
  goodExample: `int = -1.`,
26
27
  };
@@ -43,7 +44,9 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
43
44
  if (s.get() instanceof statements_1.CallScreen || s.get() instanceof statements_1.SetScreen) {
44
45
  continue;
45
46
  }
46
- const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
47
+ const replace = str.replace(/^0+/, "");
48
+ const fix = edit_helper_1.EditHelper.replaceRange(file, token.getStart(), token.getEnd(), replace);
49
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity, fix);
47
50
  issues.push(issue);
48
51
  }
49
52
  }
@@ -51,7 +54,9 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
51
54
  const token = (_a = i.findDirectExpression(Expressions.SimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
52
55
  const str = token === null || token === void 0 ? void 0 : token.getStr();
53
56
  if (token && str && str.length > 1 && str.startsWith("0")) {
54
- const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
57
+ const replace = str.replace(/^0+/, "");
58
+ const fix = edit_helper_1.EditHelper.replaceRange(file, token.getStart(), token.getEnd(), replace);
59
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity, fix);
55
60
  issues.push(issue);
56
61
  }
57
62
  }
@@ -37,7 +37,7 @@ class SMIMConsistency {
37
37
  }
38
38
  const base = this.base(obj.getURL() || "");
39
39
  if (base !== "" && this.findFolder(base) === false) {
40
- const message = "Parent folder not found";
40
+ const message = `Parent folder "${base}" not found`;
41
41
  const position = new position_1.Position(1, 1);
42
42
  const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, message, this.getMetadata().key, this.conf.severity);
43
43
  issues.push(issue);
@@ -51,7 +51,8 @@ class SMIMConsistency {
51
51
  }
52
52
  findFolder(base) {
53
53
  for (const smim of this.reg.getObjectsByType("SMIM")) {
54
- if (base === smim.getURL()) {
54
+ const mime = smim;
55
+ if (base === mime.getURL() && mime.isFolder() === true) {
55
56
  return true;
56
57
  }
57
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.99.0",
3
+ "version": "2.99.2",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -47,10 +47,10 @@
47
47
  },
48
48
  "homepage": "https://abaplint.org",
49
49
  "devDependencies": {
50
- "@microsoft/api-extractor": "^7.34.5",
51
- "@types/chai": "^4.3.4",
50
+ "@microsoft/api-extractor": "^7.34.7",
51
+ "@types/chai": "^4.3.5",
52
52
  "@types/mocha": "^10.0.1",
53
- "@types/node": "^18.16.2",
53
+ "@types/node": "^18.16.3",
54
54
  "chai": "^4.3.7",
55
55
  "eslint": "^8.39.0",
56
56
  "mocha": "^10.2.0",