@abaplint/core 2.79.9 → 2.79.13

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.
@@ -2398,13 +2398,15 @@ declare interface IConfiguration {
2398
2398
  }
2399
2399
 
2400
2400
  declare interface IDDICReferences {
2401
- setUsing(obj: IObject, using: readonly IObject[]): void;
2402
- addUsing(obj: IObject, using: IObject | undefined): void;
2401
+ setUsing(obj: IObject, using: readonly IObjectAndToken[]): void;
2402
+ addUsing(obj: IObject, using: IObjectAndToken | undefined): void;
2403
2403
  clear(obj: IObject): void;
2404
- listUsing(obj: IObject): readonly IObject[];
2404
+ listUsing(obj: IObject): readonly IObjectAndToken[];
2405
2405
  listWhereUsed(obj: IObject): {
2406
2406
  type: string;
2407
2407
  name: string;
2408
+ token?: Token;
2409
+ filename?: string;
2408
2410
  }[];
2409
2411
  }
2410
2412
 
@@ -2908,6 +2910,12 @@ export declare interface IObject extends IArtifact {
2908
2910
  getXML(): string | undefined;
2909
2911
  }
2910
2912
 
2913
+ declare interface IObjectAndToken {
2914
+ object?: IObject;
2915
+ token?: Token;
2916
+ filename?: string;
2917
+ }
2918
+
2911
2919
  declare interface IParseResult {
2912
2920
  updated: boolean;
2913
2921
  runtime: number;
@@ -163,7 +163,7 @@ class BasicTypes {
163
163
  }
164
164
  const ddic = this.scope.getDDIC().lookup(chainText);
165
165
  if (ddic) {
166
- this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), ddic.object);
166
+ this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });
167
167
  if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {
168
168
  this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);
169
169
  }
@@ -469,7 +469,7 @@ class BasicTypes {
469
469
  foundType = found === null || found === void 0 ? void 0 : found.getType();
470
470
  if (foundType === undefined) {
471
471
  const f = this.scope.getDDIC().lookupTableOrView(subs[0]);
472
- this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), f.object);
472
+ this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object });
473
473
  if (f.type instanceof _typed_identifier_1.TypedIdentifier) {
474
474
  foundType = f.type.getType();
475
475
  }
@@ -13,7 +13,7 @@ class DeleteCluster {
13
13
  if (databaseName) {
14
14
  const found = (_a = scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(databaseName.concatTokens());
15
15
  if (found) {
16
- scope.getDDICReferences().addUsing(scope.getParentObj(), found.object);
16
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object });
17
17
  }
18
18
  }
19
19
  }
@@ -17,7 +17,7 @@ class Export {
17
17
  if (databaseName) {
18
18
  const found = (_a = scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(databaseName.concatTokens());
19
19
  if (found) {
20
- scope.getDDICReferences().addUsing(scope.getParentObj(), found.object);
20
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object });
21
21
  }
22
22
  }
23
23
  }
@@ -17,7 +17,7 @@ class Import {
17
17
  if (databaseName) {
18
18
  const found = (_a = scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(databaseName.concatTokens());
19
19
  if (found) {
20
- scope.getDDICReferences().addUsing(scope.getParentObj(), found.object);
20
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object });
21
21
  }
22
22
  }
23
23
  }
@@ -17,7 +17,7 @@ class Tables {
17
17
  }
18
18
  const found = (_b = scope.getDDIC()) === null || _b === void 0 ? void 0 : _b.lookupTableOrView(name);
19
19
  if (found) {
20
- scope.getDDICReferences().addUsing(scope.getParentObj(), found.object);
20
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object });
21
21
  scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
22
22
  return;
23
23
  }
@@ -50,9 +50,8 @@ class DDICReferences {
50
50
  for (const name in this.index) {
51
51
  for (const type in this.index[name]) {
52
52
  for (const f of this.index[name][type]) {
53
- if (f.getType() === searchType && f.getName() === searchName) {
54
- ret.push({ type, name });
55
- break; // current outermost loop
53
+ if (f.object && f.object.getType() === searchType && f.object.getName() === searchName) {
54
+ ret.push({ type, name, token: f.token, filename: f.filename });
56
55
  }
57
56
  }
58
57
  }
@@ -60,7 +60,7 @@ class DataElement extends _abstract_object_1.AbstractObject {
60
60
  }
61
61
  }
62
62
  if (lookup.object) {
63
- references.push(lookup.object);
63
+ references.push({ object: lookup.object });
64
64
  }
65
65
  reg.getDDICReferences().setUsing(this, references);
66
66
  return lookup.type;
@@ -15,6 +15,8 @@ class RenameDataElement {
15
15
  const helper = new renamer_helper_1.RenamerHelper(this.reg);
16
16
  changes = changes.concat(helper.buildXMLFileEdits(obj, "ROLLNAME", oldName, newName));
17
17
  changes = changes.concat(helper.renameFiles(obj, oldName, newName));
18
+ changes = changes.concat(helper.renameDDICCodeReferences(obj, oldName, newName));
19
+ changes = changes.concat(helper.renameDDICTABLReferences(obj, oldName, newName));
18
20
  return {
19
21
  documentChanges: changes,
20
22
  };
@@ -15,6 +15,7 @@ class RenameDomain {
15
15
  const helper = new renamer_helper_1.RenamerHelper(this.reg);
16
16
  changes = changes.concat(helper.buildXMLFileEdits(obj, "DOMNAME", oldName, newName));
17
17
  changes = changes.concat(helper.renameFiles(obj, oldName, newName));
18
+ changes = changes.concat(helper.renameDDICDTELReferences(obj, oldName, newName));
18
19
  return {
19
20
  documentChanges: changes,
20
21
  };
@@ -45,6 +45,7 @@ class RenameGlobalClass {
45
45
  changes = changes.concat(helper.buildXMLFileEdits(obj, "CLSNAME", oldName, newName));
46
46
  changes = changes.concat(helper.renameFiles(obj, oldName, newName));
47
47
  changes = changes.concat(helper.renameReferences(obj.getIdentifier(), oldName, newName));
48
+ changes = changes.concat(helper.renameDDICTABLReferences(obj, oldName, newName));
48
49
  return {
49
50
  documentChanges: changes,
50
51
  };
@@ -27,9 +27,54 @@ class RenamerHelper {
27
27
  // start with the last reference in the file first, if there are multiple refs per line
28
28
  return this.replaceRefs(refs, oldName, newName).reverse();
29
29
  }
30
- buildXMLFileEdits(clas, xmlTag, oldName, newName) {
30
+ renameDDICCodeReferences(obj, oldName, newName) {
31
31
  const changes = [];
32
- const xml = clas.getXMLFile();
32
+ const used = this.reg.getDDICReferences().listWhereUsed(obj);
33
+ for (const u of used) {
34
+ if (u.token === undefined || u.filename === undefined) {
35
+ continue;
36
+ }
37
+ const range = vscode_languageserver_types_1.Range.create(u.token.getStart().getRow() - 1, u.token.getStart().getCol() - 1, u.token.getStart().getRow() - 1, u.token.getStart().getCol() - 1 + oldName.length);
38
+ changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: u.filename, version: 1 }, [vscode_languageserver_types_1.TextEdit.replace(range, newName.toLowerCase())]));
39
+ }
40
+ return changes;
41
+ }
42
+ renameDDICTABLReferences(obj, oldName, newName) {
43
+ const changes = [];
44
+ const used = this.reg.getDDICReferences().listWhereUsed(obj);
45
+ const handled = {};
46
+ for (const u of used) {
47
+ if (u.type !== "TABL" || handled[u.name.toUpperCase()] === true) {
48
+ // a TABL might reference the object multiple times, but they are all fixes in one call to buildXMLFileEdits
49
+ continue;
50
+ }
51
+ const tabl = this.reg.getObject(u.type, u.name);
52
+ if (tabl === undefined) {
53
+ continue;
54
+ }
55
+ changes.push(...this.buildXMLFileEdits(tabl, "ROLLNAME", oldName, newName));
56
+ handled[u.name.toUpperCase()] = true;
57
+ }
58
+ return changes;
59
+ }
60
+ renameDDICDTELReferences(obj, oldName, newName) {
61
+ const changes = [];
62
+ const used = this.reg.getDDICReferences().listWhereUsed(obj);
63
+ for (const u of used) {
64
+ if (u.type !== "DTEL") {
65
+ continue;
66
+ }
67
+ const tabl = this.reg.getObject(u.type, u.name);
68
+ if (tabl === undefined) {
69
+ continue;
70
+ }
71
+ changes.push(...this.buildXMLFileEdits(tabl, "DOMNAME", oldName, newName));
72
+ }
73
+ return changes;
74
+ }
75
+ buildXMLFileEdits(object, xmlTag, oldName, newName) {
76
+ const changes = [];
77
+ const xml = object.getXMLFile();
33
78
  if (xml === undefined) {
34
79
  return [];
35
80
  }
@@ -74,7 +74,7 @@ class Table extends _abstract_object_1.AbstractObject {
74
74
  const lookup = ddic.lookupDataElement(field.ROLLNAME);
75
75
  components.push({ name: field.FIELDNAME, type: lookup.type });
76
76
  if (lookup.object) {
77
- references.push(lookup.object);
77
+ references.push({ object: lookup.object });
78
78
  }
79
79
  }
80
80
  else if (field.FIELDNAME === ".INCLUDE" || field.FIELDNAME === ".INCLU--AP") { // incude or append structure
@@ -84,7 +84,7 @@ class Table extends _abstract_object_1.AbstractObject {
84
84
  const lookup = ddic.lookupTableOrView(field.PRECFIELD);
85
85
  let found = lookup.type;
86
86
  if (lookup.object) {
87
- references.push(lookup.object);
87
+ references.push({ object: lookup.object });
88
88
  }
89
89
  if (found instanceof _typed_identifier_1.TypedIdentifier) {
90
90
  found = found.getType();
@@ -119,7 +119,7 @@ class Table extends _abstract_object_1.AbstractObject {
119
119
  const lookup = ddic.lookupTableOrView(field.ROLLNAME);
120
120
  components.push({ name: field.FIELDNAME, type: lookup.type });
121
121
  if (lookup.object) {
122
- references.push(lookup.object);
122
+ references.push({ object: lookup.object });
123
123
  }
124
124
  }
125
125
  else if (comptype === "R") {
@@ -136,7 +136,7 @@ class Table extends _abstract_object_1.AbstractObject {
136
136
  const lookup = ddic.lookupObject(field.ROLLNAME);
137
137
  components.push({ name: field.FIELDNAME, type: lookup.type });
138
138
  if (lookup.object) {
139
- references.push(lookup.object);
139
+ references.push({ object: lookup.object });
140
140
  }
141
141
  }
142
142
  }
@@ -144,13 +144,13 @@ class Table extends _abstract_object_1.AbstractObject {
144
144
  const lookup = ddic.lookupTableType(field.ROLLNAME);
145
145
  components.push({ name: field.FIELDNAME, type: lookup.type });
146
146
  if (lookup.object) {
147
- references.push(lookup.object);
147
+ references.push({ object: lookup.object });
148
148
  }
149
149
  }
150
150
  else if (comptype === "") { // built in
151
151
  const datatype = field.DATATYPE;
152
152
  if (datatype === undefined) {
153
- throw new Error("Expected DATATYPE");
153
+ throw new Error("Expected DATATYPE, while parsing TABL " + this.getName());
154
154
  }
155
155
  const length = field.LENG ? field.LENG : field.INTLEN;
156
156
  components.push({
@@ -38,28 +38,28 @@ class TableType extends _abstract_object_1.AbstractObject {
38
38
  const lookup = ddic.lookupTableOrView(this.parsedXML.rowtype);
39
39
  type = new Types.TableType(lookup.type, { withHeader: false }, this.getName());
40
40
  if (lookup.object) {
41
- references.push(lookup.object);
41
+ references.push({ object: lookup.object });
42
42
  }
43
43
  }
44
44
  else if (this.parsedXML.rowkind === "E") {
45
45
  const lookup = ddic.lookupDataElement(this.parsedXML.rowtype);
46
46
  type = new Types.TableType(lookup.type, { withHeader: false }, this.getName());
47
47
  if (lookup.object) {
48
- references.push(lookup.object);
48
+ references.push({ object: lookup.object });
49
49
  }
50
50
  }
51
51
  else if (this.parsedXML.rowkind === "L") {
52
52
  const lookup = ddic.lookupTableType(this.parsedXML.rowtype);
53
53
  type = new Types.TableType(lookup.type, { withHeader: false }, this.getName());
54
54
  if (lookup.object) {
55
- references.push(lookup.object);
55
+ references.push({ object: lookup.object });
56
56
  }
57
57
  }
58
58
  else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype !== undefined) {
59
59
  const lookup = ddic.lookupObject(this.parsedXML.rowtype);
60
60
  type = new Types.TableType(lookup.type, { withHeader: false }, this.getName());
61
61
  if (lookup.object) {
62
- references.push(lookup.object);
62
+ references.push({ object: lookup.object });
63
63
  }
64
64
  }
65
65
  else if (this.parsedXML.rowkind === "") {
@@ -37,7 +37,7 @@ class View extends _abstract_object_1.AbstractObject {
37
37
  const lookup = ddic.lookupTableOrView(field.TABNAME);
38
38
  let found = lookup.type;
39
39
  if (lookup.object) {
40
- references.push(lookup.object);
40
+ references.push({ object: lookup.object });
41
41
  }
42
42
  if (field.VIEWFIELD === ".APPEND") {
43
43
  // it is already expanded in the abapGit xml
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.79.9";
71
+ return "2.79.13";
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.79.9",
3
+ "version": "2.79.13",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",