@abaplint/core 2.118.8 → 2.118.10

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.
@@ -118,7 +118,7 @@ class CreateObject {
118
118
  this.validateParameters(cdef, node, input);
119
119
  }
120
120
  static checkInstantiationAllowed(cdef, input) {
121
- var _a, _b;
121
+ var _a, _b, _c, _d;
122
122
  const createVis = cdef.getCreateVisibility();
123
123
  if (createVis === visibility_1.Visibility.Public) {
124
124
  return undefined;
@@ -135,14 +135,23 @@ class CreateObject {
135
135
  input.scope.isLocalFriend(cdef.getName(), enclosingClass)) {
136
136
  return undefined;
137
137
  }
138
+ // subclasses of friends also have friendship
139
+ let enclosingSup = (_a = input.scope.findClassDefinition(enclosingClass)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
140
+ while (enclosingSup !== undefined) {
141
+ if (cdef.getFriends().some(f => f.toUpperCase() === enclosingSup.toUpperCase()) ||
142
+ input.scope.isLocalFriend(cdef.getName(), enclosingSup)) {
143
+ return undefined;
144
+ }
145
+ enclosingSup = (_b = input.scope.findClassDefinition(enclosingSup)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
146
+ }
138
147
  if (createVis === visibility_1.Visibility.Protected) {
139
148
  // subclasses are also allowed
140
- let sup = (_a = input.scope.findClassDefinition(enclosingClass)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
149
+ let sup = (_c = input.scope.findClassDefinition(enclosingClass)) === null || _c === void 0 ? void 0 : _c.getSuperClass();
141
150
  while (sup !== undefined) {
142
151
  if (sup.toUpperCase() === cdef.getName().toUpperCase()) {
143
152
  return undefined;
144
153
  }
145
- sup = (_b = input.scope.findClassDefinition(sup)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
154
+ sup = (_d = input.scope.findClassDefinition(sup)) === null || _d === void 0 ? void 0 : _d.getSuperClass();
146
155
  }
147
156
  }
148
157
  return cdef.getName() + " cannot be instantiated, class is defined as " +
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenameProgram = void 0;
4
+ const Statements = require("../../abap/2_statements/statements");
5
+ const Expressions = require("../../abap/2_statements/expressions");
6
+ const vscode_languageserver_types_1 = require("vscode-languageserver-types");
7
+ const __1 = require("..");
8
+ const renamer_helper_1 = require("./renamer_helper");
9
+ const _lsp_utils_1 = require("../../lsp/_lsp_utils");
10
+ const _abap_object_1 = require("../_abap_object");
11
+ class RenameProgram {
12
+ constructor(reg) {
13
+ this.reg = reg;
14
+ }
15
+ buildEdits(obj, oldName, newName) {
16
+ if (!(obj instanceof __1.Program)) {
17
+ throw new Error("RenameProgram, not a program");
18
+ }
19
+ const main = obj.getMainABAPFile();
20
+ if (main === undefined) {
21
+ throw new Error(`Main file not found, ${obj.getType()} ${obj.getName()}`);
22
+ }
23
+ let changes = [];
24
+ const helper = new renamer_helper_1.RenamerHelper(this.reg);
25
+ changes = changes.concat(helper.buildXMLFileEdits(obj, "NAME", oldName, newName));
26
+ changes = changes.concat(helper.renameFiles(obj, oldName, newName));
27
+ const edits = [];
28
+ for (const s of main.getStatements()) {
29
+ if (s.get() instanceof Statements.Report || s.get() instanceof Statements.Program) {
30
+ const exp = s.findFirstExpression(Expressions.ReportName);
31
+ if (exp) {
32
+ edits.push(vscode_languageserver_types_1.TextEdit.replace(_lsp_utils_1.LSPUtils.tokenToRange(exp.getFirstToken()), newName.toLowerCase()));
33
+ }
34
+ }
35
+ }
36
+ if (edits.length > 0) {
37
+ changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: main.getFilename(), version: 1 }, edits));
38
+ }
39
+ // Rename INCLUDE statements in all ABAP objects
40
+ for (const o of this.reg.getObjects()) {
41
+ if (o instanceof _abap_object_1.ABAPObject && o !== obj) {
42
+ for (const file of o.getABAPFiles()) {
43
+ const includeEdits = [];
44
+ for (const s of file.getStatements()) {
45
+ if (s.get() instanceof Statements.Include ||
46
+ s.get() instanceof Statements.Submit ||
47
+ s.get() instanceof Statements.Perform) {
48
+ for (const exp of s.findAllExpressions(Expressions.IncludeName)) {
49
+ if (exp && exp.getFirstToken().getStr().toUpperCase() === oldName.toUpperCase()) {
50
+ includeEdits.push(vscode_languageserver_types_1.TextEdit.replace(_lsp_utils_1.LSPUtils.tokenToRange(exp.getFirstToken()), newName.toLowerCase()));
51
+ }
52
+ }
53
+ }
54
+ }
55
+ if (includeEdits.length > 0) {
56
+ changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: file.getFilename(), version: 1 }, includeEdits));
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return {
62
+ documentChanges: changes,
63
+ };
64
+ }
65
+ }
66
+ exports.RenameProgram = RenameProgram;
67
+ //# sourceMappingURL=rename_program.js.map
@@ -7,6 +7,7 @@ const rename_data_element_1 = require("./rename_data_element");
7
7
  const rename_domain_1 = require("./rename_domain");
8
8
  const rename_global_class_1 = require("./rename_global_class");
9
9
  const rename_global_interface_1 = require("./rename_global_interface");
10
+ const rename_program_1 = require("./rename_program");
10
11
  const rename_table_1 = require("./rename_table");
11
12
  const rename_table_type_1 = require("./rename_table_type");
12
13
  const rename_message_class_1 = require("./rename_message_class");
@@ -61,6 +62,8 @@ class Renamer {
61
62
  return new rename_table_type_1.RenameTableType(this.reg);
62
63
  case "INTF":
63
64
  return new rename_global_interface_1.RenameGlobalInterface(this.reg);
65
+ case "PROG":
66
+ return new rename_program_1.RenameProgram(this.reg);
64
67
  case "MSAG":
65
68
  return new rename_message_class_1.RenameMessageClass(this.reg);
66
69
  case "SICF":
@@ -74,7 +74,7 @@ class Registry {
74
74
  }
75
75
  static abaplintVersion() {
76
76
  // magic, see build script "version.sh"
77
- return "2.118.8";
77
+ return "2.118.10";
78
78
  }
79
79
  getDDICReferences() {
80
80
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.118.8",
3
+ "version": "2.118.10",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",