@abaplint/transpiler 2.1.83 → 2.1.84

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.
@@ -28,7 +28,7 @@ class FieldChainTranspiler {
28
28
  }
29
29
  else if (c.get() instanceof core_1.Expressions.AttributeName) {
30
30
  const interfaceName = traversal.isInterfaceAttribute(c.getFirstToken());
31
- let name = c.getFirstToken().getStr().replace("~", "$").toLowerCase();
31
+ let name = traversal_1.Traversal.escapeClassName(c.getFirstToken().getStr()).replace("~", "$").toLowerCase();
32
32
  if (prefix && interfaceName && name.startsWith(interfaceName) === false) {
33
33
  name = traversal_1.Traversal.escapeClassName(interfaceName) + "$" + name;
34
34
  }
@@ -28,7 +28,7 @@ export async function initializeABAP() {\n`;
28
28
  ret += ` const schemas = {sqlite, hdb, pg};\n`;
29
29
  ret += ` const insert = [];\n`;
30
30
  for (const i of dbSetup.insert) {
31
- ret += `insert.push(\`${i}\`);\n`;
31
+ ret += ` insert.push(\`${i}\`);\n`;
32
32
  }
33
33
  if (extraSetup === undefined) {
34
34
  ret += `// no setup logic specified in config\n`;
@@ -180,9 +180,10 @@ run().then(() => {
180
180
  }
181
181
  buildImports(reg, useImport) {
182
182
  // note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
183
- // todo, some sorting might be required? eg. a class constructor using constant from interface?
184
- // temporary sorting: by filename
183
+ // some sorting required: eg. a class constructor using constant from interface
184
+ var _a;
185
185
  const list = [];
186
+ const late = [];
186
187
  const imp = (filename) => {
187
188
  if (useImport === true) {
188
189
  return `import "./${filename}.mjs";`;
@@ -204,12 +205,21 @@ run().then(() => {
204
205
  list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.fugr.${m.getName().toLowerCase()}`));
205
206
  }
206
207
  }
207
- else if (obj instanceof abaplint.Objects.Class
208
- || obj instanceof abaplint.Objects.Interface) {
208
+ else if (obj instanceof abaplint.Objects.Class) {
209
+ if (obj.getName().toUpperCase() !== "CL_ABAP_CHAR_UTILITIES"
210
+ && ((_a = obj.getDefinition()) === null || _a === void 0 ? void 0 : _a.getMethodDefinitions().getByName("CLASS_CONSTRUCTOR")) !== undefined) {
211
+ // this will not solve all problems with class constors 100%, but probably good enough
212
+ late.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
213
+ }
214
+ else {
215
+ list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
216
+ }
217
+ }
218
+ else if (obj instanceof abaplint.Objects.Interface) {
209
219
  list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
210
220
  }
211
221
  }
212
- return list.sort().join("\n");
222
+ return [...list.sort(), ...late].join("\n");
213
223
  }
214
224
  }
215
225
  exports.UnitTest = UnitTest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.1.83",
3
+ "version": "2.1.84",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",