@abaplint/core 2.84.2 → 2.84.6

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.
@@ -1155,6 +1155,7 @@ export declare class CurrentScope {
1155
1155
  getType(): ScopeType;
1156
1156
  push(stype: ScopeType, sname: string, start: Position, filename: string): void;
1157
1157
  isOO(): boolean;
1158
+ isTypePool(): boolean;
1158
1159
  setAllowHeaderUse(name: string): void;
1159
1160
  isAllowHeaderUse(name: string): boolean;
1160
1161
  pop(end: Position): SpaghettiScope;
@@ -1286,7 +1287,7 @@ declare class DataEnd implements IStatement {
1286
1287
 
1287
1288
  declare class DataReference extends AbstractType {
1288
1289
  private readonly type;
1289
- constructor(type: AbstractType, name?: string);
1290
+ constructor(type: AbstractType, qualifiedName?: string);
1290
1291
  toText(level: number): string;
1291
1292
  getType(): AbstractType;
1292
1293
  toABAP(): string;
@@ -1307,7 +1308,7 @@ declare class DDIC {
1307
1308
  private readonly reg;
1308
1309
  constructor(reg: IRegistry);
1309
1310
  isException(def: InfoClassDefinition | undefined, _obj: ABAPObject): boolean;
1310
- lookupBuiltinType(name: string, length?: number, decimals?: number): AbstractType | undefined;
1311
+ lookupBuiltinType(name: string, length?: number, decimals?: number, qualifiedName?: string): AbstractType | undefined;
1311
1312
  inErrorNamespace(name: string | undefined): boolean;
1312
1313
  lookupObject(name: string): ILookupResult;
1313
1314
  lookupNoVoid(name: string): ILookupResult | undefined;
@@ -3186,13 +3187,15 @@ declare interface IRenameParams {
3186
3187
  }
3187
3188
 
3188
3189
  export declare interface IRenameSettings {
3189
- /** output folder */
3190
- output: string;
3190
+ /** output folder, if value is empty or undefined the changes are written inline in the input folders */
3191
+ output?: string;
3191
3192
  /** list of regex, matches filenames to be skipped, case insensitive
3192
3193
  * @uniqueItems true
3193
3194
  */
3194
3195
  skip?: string[];
3195
- /** List of rename patterns */
3196
+ /** List of rename patterns
3197
+ * @uniqueItems true
3198
+ */
3196
3199
  patterns: {
3197
3200
  /** Object type, example "CLAS", regex, case insensitive */
3198
3201
  type: string;
@@ -4531,6 +4534,7 @@ export declare enum ScopeType {
4531
4534
  Dummy = "_dummy",
4532
4535
  Global = "_global",
4533
4536
  Program = "_program",
4537
+ TypePool = "_type_pool",
4534
4538
  FunctionGroup = "_function_group",
4535
4539
  ClassDefinition = "class_definition",
4536
4540
  Interface = "interface",
@@ -5431,7 +5435,7 @@ export { Structures }
5431
5435
  declare class StructureType extends AbstractType {
5432
5436
  private readonly indexed;
5433
5437
  private readonly components;
5434
- constructor(components: IStructureComponent[], name?: string);
5438
+ constructor(components: IStructureComponent[], qualifiedName?: string);
5435
5439
  getComponents(): IStructureComponent[];
5436
5440
  getComponentByName(name: string): AbstractType | undefined;
5437
5441
  toText(level: number): string;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CallTransformationParameters = void 0;
4
+ const _1 = require(".");
4
5
  const combi_1 = require("../combi");
5
6
  const dynamic_1 = require("./dynamic");
6
7
  const field_1 = require("./field");
7
8
  const integer_1 = require("./integer");
8
- const source_1 = require("./source");
9
9
  class CallTransformationParameters extends combi_1.Expression {
10
10
  getRunnable() {
11
- const field = (0, combi_1.seq)((0, combi_1.alt)(field_1.Field, integer_1.Integer), "=", source_1.Source);
11
+ const field = (0, combi_1.seq)((0, combi_1.alt)(field_1.Field, integer_1.Integer), "=", _1.SimpleSource3);
12
12
  return (0, combi_1.alt)((0, combi_1.plus)(field), dynamic_1.Dynamic);
13
13
  }
14
14
  }
@@ -8,7 +8,7 @@ class CallTransformation {
8
8
  const options = (0, combi_1.seq)("OPTIONS", expressions_1.CallTransformationOptions);
9
9
  const parameters = (0, combi_1.seq)("PARAMETERS", expressions_1.CallTransformationParameters);
10
10
  const objects = (0, combi_1.seq)("OBJECTS", expressions_1.CallTransformationParameters);
11
- const source2 = (0, combi_1.seq)("XML", expressions_1.Source);
11
+ const source2 = (0, combi_1.seq)("XML", expressions_1.SimpleSource3);
12
12
  const source = (0, combi_1.seq)("SOURCE", (0, combi_1.alt)(expressions_1.CallTransformationParameters, source2));
13
13
  const result2 = (0, combi_1.seq)("XML", expressions_1.Target);
14
14
  const result = (0, combi_1.seq)("RESULT", (0, combi_1.alt)(expressions_1.CallTransformationParameters, result2));
@@ -206,6 +206,7 @@ class CurrentScope {
206
206
  return undefined;
207
207
  }
208
208
  findTypePoolConstant(name) {
209
+ var _a;
209
210
  if (name === undefined || name.includes("_") === undefined) {
210
211
  return undefined;
211
212
  }
@@ -214,12 +215,12 @@ class CurrentScope {
214
215
  if (typePool === undefined) {
215
216
  return undefined;
216
217
  }
217
- const spag = new syntax_1.SyntaxLogic(this.reg, typePool).run().spaghetti.getFirstChild();
218
+ const spag = (_a = new syntax_1.SyntaxLogic(this.reg, typePool).run().spaghetti.getFirstChild()) === null || _a === void 0 ? void 0 : _a.getFirstChild();
218
219
  const found = spag === null || spag === void 0 ? void 0 : spag.findVariable(name);
219
220
  return found;
220
221
  }
221
222
  findTypePoolType(name) {
222
- var _a;
223
+ var _a, _b;
223
224
  if (name.includes("_") === undefined) {
224
225
  return undefined;
225
226
  }
@@ -228,8 +229,8 @@ class CurrentScope {
228
229
  if (typePool === undefined) {
229
230
  return undefined;
230
231
  }
231
- const spag = new syntax_1.SyntaxLogic(this.reg, typePool).run().spaghetti.getFirstChild();
232
- const found = (_a = spag === null || spag === void 0 ? void 0 : spag.findType(name)) === null || _a === void 0 ? void 0 : _a.getType();
232
+ const spag = (_a = new syntax_1.SyntaxLogic(this.reg, typePool).run().spaghetti.getFirstChild()) === null || _a === void 0 ? void 0 : _a.getFirstChild();
233
+ const found = (_b = spag === null || spag === void 0 ? void 0 : spag.findType(name)) === null || _b === void 0 ? void 0 : _b.getType();
233
234
  return found;
234
235
  }
235
236
  /** Lookup interface in local and global scope */
@@ -321,6 +322,10 @@ class CurrentScope {
321
322
  }
322
323
  return false;
323
324
  }
325
+ isTypePool() {
326
+ var _a;
327
+ return ((_a = this.current) === null || _a === void 0 ? void 0 : _a.getIdentifier().filename.endsWith(".type.abap")) === true || false;
328
+ }
324
329
  setAllowHeaderUse(name) {
325
330
  // workaround for SELECT FOR ALL ENTRIES
326
331
  this.allowHeaderUse = name;
@@ -7,6 +7,7 @@ var ScopeType;
7
7
  ScopeType["Dummy"] = "_dummy";
8
8
  ScopeType["Global"] = "_global";
9
9
  ScopeType["Program"] = "_program";
10
+ ScopeType["TypePool"] = "_type_pool";
10
11
  ScopeType["FunctionGroup"] = "_function_group";
11
12
  ScopeType["ClassDefinition"] = "class_definition";
12
13
  ScopeType["Interface"] = "interface";
@@ -140,7 +140,7 @@ class BasicTypes {
140
140
  }
141
141
  return type;
142
142
  }
143
- resolveTypeName(typeName, length, decimals) {
143
+ resolveTypeName(typeName, length, decimals, name) {
144
144
  if (typeName === undefined) {
145
145
  return undefined;
146
146
  }
@@ -149,7 +149,7 @@ class BasicTypes {
149
149
  return chain;
150
150
  }
151
151
  const chainText = typeName.concatTokens().toUpperCase();
152
- const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals);
152
+ const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, name);
153
153
  if (f !== undefined) {
154
154
  return f;
155
155
  }
@@ -196,7 +196,7 @@ class BasicTypes {
196
196
  if (nameExpr.countTokens() > 1) { // workaround for names with dashes
197
197
  name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());
198
198
  }
199
- const found = this.parseType(node);
199
+ const found = this.parseType(node, this.scope.isTypePool() ? name.getStr() : undefined);
200
200
  if (found) {
201
201
  return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);
202
202
  }
@@ -344,7 +344,7 @@ class BasicTypes {
344
344
  if (type === undefined) {
345
345
  return new Types.UnknownType("Type error, could not resolve \"" + name + "\", parseType");
346
346
  }
347
- return new Types.DataReference(type);
347
+ return new Types.DataReference(type, name);
348
348
  }
349
349
  else if (text === "TYPE STANDARD TABLE"
350
350
  || text === "TYPE SORTED TABLE"
@@ -392,7 +392,7 @@ class BasicTypes {
392
392
  found = this.resolveTypeRef(typename);
393
393
  }
394
394
  else if (text.startsWith("TYPE")) {
395
- found = this.resolveTypeName(typename, this.findLength(node), this.findDecimals(node));
395
+ found = this.resolveTypeName(typename, this.findLength(node), this.findDecimals(node), name);
396
396
  const concat = node.concatTokens().toUpperCase();
397
397
  if (found && concat.includes(" OCCURS ")) {
398
398
  found = new Types.TableType(found, { withHeader: concat.includes("WITH HEADER LINE") }, name);
@@ -9,7 +9,7 @@ const inline_data_1 = require("../expressions/inline_data");
9
9
  const dynamic_1 = require("../expressions/dynamic");
10
10
  class CallTransformation {
11
11
  runSyntax(node, scope, filename) {
12
- for (const s of node.findAllExpressions(Expressions.Source)) {
12
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
13
13
  new source_1.Source().runSyntax(s, scope, filename);
14
14
  }
15
15
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
@@ -8,9 +8,10 @@ const nodes_1 = require("../../nodes");
8
8
  const _typed_identifier_1 = require("../../types/_typed_identifier");
9
9
  const Basic = require("../../types/basic");
10
10
  const data_1 = require("../statements/data");
11
+ const _reference_1 = require("../_reference");
11
12
  class Data {
12
13
  runSyntax(node, scope, filename) {
13
- var _a, _b;
14
+ var _a;
14
15
  const name = node.findFirstExpression(Expressions.DefinitionName).getFirstToken();
15
16
  let table = false;
16
17
  const components = [];
@@ -35,8 +36,10 @@ class Data {
35
36
  }
36
37
  else if (c instanceof nodes_1.StatementNode && ctyp instanceof Statements.IncludeType) {
37
38
  // INCLUDES
38
- const typeName = (_a = c.findFirstExpression(Expressions.TypeName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
39
- let found = (_b = scope.findType(typeName)) === null || _b === void 0 ? void 0 : _b.getType();
39
+ const typeToken = (_a = c.findFirstExpression(Expressions.TypeName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
40
+ const typeName = typeToken === null || typeToken === void 0 ? void 0 : typeToken.getStr();
41
+ const foundId = scope.findType(typeName);
42
+ let found = foundId === null || foundId === void 0 ? void 0 : foundId.getType();
40
43
  if (found === undefined) {
41
44
  const f = scope.getDDIC().lookupTableOrView(typeName).type;
42
45
  if (f instanceof _typed_identifier_1.TypedIdentifier) {
@@ -46,6 +49,9 @@ class Data {
46
49
  found = f;
47
50
  }
48
51
  }
52
+ else {
53
+ scope.addReference(typeToken, foundId, _reference_1.ReferenceType.TypeReference, filename);
54
+ }
49
55
  if (found instanceof Basic.VoidType) {
50
56
  if (table === true) {
51
57
  return new _typed_identifier_1.TypedIdentifier(name, filename, new Basic.TableType(found, { withHeader: true }));
@@ -297,6 +297,12 @@ class SyntaxLogic {
297
297
  this.scope.push(stype, this.object.getName(), new position_1.Position(1, 1), main.getFilename());
298
298
  }
299
299
  }
300
+ else if (this.object instanceof objects_1.TypePool) {
301
+ const main = this.object.getMainABAPFile();
302
+ if (main !== undefined) {
303
+ this.scope.push(_scope_type_1.ScopeType.TypePool, this.object.getName(), new position_1.Position(1, 1), main.getFilename());
304
+ }
305
+ }
300
306
  for (const file of traversal) {
301
307
  this.currentFile = file;
302
308
  const structure = this.currentFile.getStructure();
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataReference = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  class DataReference extends _abstract_type_1.AbstractType {
6
- constructor(type, name) {
7
- super(name);
6
+ constructor(type, qualifiedName) {
7
+ super(qualifiedName);
8
8
  this.type = type;
9
9
  }
10
10
  toText(level) {
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StructureType = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  class StructureType extends _abstract_type_1.AbstractType {
6
- constructor(components, name) {
7
- super(name);
6
+ constructor(components, qualifiedName) {
7
+ super(qualifiedName);
8
8
  if (components.length === 0) {
9
9
  throw new Error("Structure does not contain any components");
10
10
  }
@@ -12,7 +12,7 @@ class StructureType extends _abstract_type_1.AbstractType {
12
12
  for (const c of components) {
13
13
  const upper = c.name.toUpperCase();
14
14
  if (this.indexed[upper] !== undefined) {
15
- throw new Error("Structure, duplicate field name \"" + upper + "\", " + name);
15
+ throw new Error("Structure, duplicate field name \"" + upper + "\", " + qualifiedName);
16
16
  }
17
17
  this.indexed[upper] = c.type;
18
18
  }
package/build/src/ddic.js CHANGED
@@ -43,7 +43,7 @@ class DDIC {
43
43
  const isException = ((superClassName === null || superClassName === void 0 ? void 0 : superClassName.match(/^.?cx_.*$/i)) || (superClassName === null || superClassName === void 0 ? void 0 : superClassName.match(/^\/.+\/cx_.*$/i))) ? true : false;
44
44
  return isException;
45
45
  }
46
- lookupBuiltinType(name, length, decimals) {
46
+ lookupBuiltinType(name, length, decimals, qualifiedName) {
47
47
  switch (name) {
48
48
  case "STRING":
49
49
  return new Types.StringType(name);
@@ -54,31 +54,31 @@ class DDIC {
54
54
  case "T":
55
55
  return new Types.TimeType(name);
56
56
  case "XSEQUENCE":
57
- return new Types.XSequenceType();
57
+ return new Types.XSequenceType(qualifiedName);
58
58
  case "CLIKE":
59
- return new Types.CLikeType();
59
+ return new Types.CLikeType(qualifiedName);
60
60
  case "DECFLOAT":
61
- return new Types.DecFloatType();
61
+ return new Types.DecFloatType(qualifiedName);
62
62
  case "ANY":
63
- return new Types.AnyType();
63
+ return new Types.AnyType(qualifiedName);
64
64
  case "SIMPLE":
65
- return new Types.SimpleType();
65
+ return new Types.SimpleType(qualifiedName);
66
66
  case "%_C_POINTER":
67
- return new Types.HexType(8);
67
+ return new Types.HexType(8, qualifiedName);
68
68
  case "TABLE":
69
69
  return new Types.TableType(new Types.AnyType(), { withHeader: false });
70
70
  case "DATA":
71
- return new Types.AnyType();
71
+ return new Types.AnyType(qualifiedName);
72
72
  case "NUMERIC":
73
- return new Types.NumericGenericType();
73
+ return new Types.NumericGenericType(qualifiedName);
74
74
  case "UTCLONG": // todo, take version into account
75
- return new Types.UTCLongType();
75
+ return new Types.UTCLongType(qualifiedName);
76
76
  case "DECFLOAT16":
77
- return new Types.DecFloat16Type();
77
+ return new Types.DecFloat16Type(qualifiedName);
78
78
  case "DECFLOAT34":
79
- return new Types.DecFloat34Type();
79
+ return new Types.DecFloat34Type(qualifiedName);
80
80
  case "CSEQUENCE":
81
- return new Types.CSequenceType();
81
+ return new Types.CSequenceType(qualifiedName);
82
82
  case "I":
83
83
  case "INT8": // todo, take version into account
84
84
  return new Types.IntegerType(name);
@@ -86,34 +86,34 @@ class DDIC {
86
86
  return new Types.FloatType(name);
87
87
  case "P":
88
88
  if (length && decimals) {
89
- return new Types.PackedType(length, decimals);
89
+ return new Types.PackedType(length, decimals, qualifiedName);
90
90
  }
91
91
  else if (length) {
92
- return new Types.PackedType(length, 0);
92
+ return new Types.PackedType(length, 0, qualifiedName);
93
93
  }
94
94
  else {
95
- return new Types.PackedType(1, 0);
95
+ return new Types.PackedType(1, 0, qualifiedName);
96
96
  }
97
97
  case "C":
98
98
  if (length) {
99
- return new Types.CharacterType(length);
99
+ return new Types.CharacterType(length, qualifiedName);
100
100
  }
101
101
  else {
102
- return new Types.CharacterType(1);
102
+ return new Types.CharacterType(1, qualifiedName);
103
103
  }
104
104
  case "X":
105
105
  if (length) {
106
- return new Types.HexType(length);
106
+ return new Types.HexType(length, qualifiedName);
107
107
  }
108
108
  else {
109
- return new Types.HexType(1);
109
+ return new Types.HexType(1, qualifiedName);
110
110
  }
111
111
  case "N":
112
112
  if (length) {
113
- return new Types.NumericType(length);
113
+ return new Types.NumericType(length, qualifiedName);
114
114
  }
115
115
  else {
116
- return new Types.NumericType(1);
116
+ return new Types.NumericType(1, qualifiedName);
117
117
  }
118
118
  }
119
119
  return undefined;
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.84.2";
71
+ return "2.84.6";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.84.2",
3
+ "version": "2.84.6",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -47,15 +47,15 @@
47
47
  "devDependencies": {
48
48
  "@microsoft/api-extractor": "^7.19.4",
49
49
  "@types/chai": "^4.3.0",
50
- "@types/mocha": "^9.0.0",
51
- "@types/node": "^17.0.9",
52
- "chai": "^4.3.4",
50
+ "@types/mocha": "^9.1.0",
51
+ "@types/node": "^17.0.12",
52
+ "chai": "^4.3.5",
53
53
  "eslint": "^8.7.0",
54
- "mocha": "^9.1.4",
54
+ "mocha": "^9.2.0",
55
55
  "c8": "^7.11.0",
56
56
  "source-map-support": "^0.5.21",
57
57
  "ts-json-schema-generator": "^0.97.0",
58
- "typescript": "^4.5.4"
58
+ "typescript": "^4.5.5"
59
59
  },
60
60
  "dependencies": {
61
61
  "fast-xml-parser": "^4.0.1",