@abaplint/transpiler 2.6.16 → 2.6.18

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.
@@ -13,6 +13,6 @@ export declare class Chunk {
13
13
  stripLastNewline(): void;
14
14
  getCode(): string;
15
15
  toString(): string;
16
- runIndentationLogic(): this;
16
+ runIndentationLogic(ignoreSourceMap?: boolean): this;
17
17
  getMap(generatedFilename: string): string;
18
18
  }
@@ -46,7 +46,7 @@ class Chunk {
46
46
  const lines = this.raw.split("\n");
47
47
  const lineCount = lines.length;
48
48
  const lastLine = lines[lines.length - 1];
49
- append.mappings.forEach(m => {
49
+ for (const m of append.mappings) {
50
50
  // original stays the same, but adjust the generated positions
51
51
  const add = m;
52
52
  if (add.generated.line === 1 && this.raw.endsWith("\n") === false) {
@@ -56,7 +56,7 @@ class Chunk {
56
56
  add.generated.line += lineCount - 1;
57
57
  }
58
58
  this.mappings.push(add);
59
- });
59
+ }
60
60
  this.raw += append.getCode();
61
61
  return this;
62
62
  }
@@ -108,10 +108,13 @@ class Chunk {
108
108
  toString() {
109
109
  throw "error, dont toString a Chunk";
110
110
  }
111
- runIndentationLogic() {
111
+ runIndentationLogic(ignoreSourceMap = false) {
112
112
  let i = 0;
113
113
  let line = 1;
114
114
  const output = [];
115
+ if (ignoreSourceMap === true) {
116
+ this.mappings = [];
117
+ }
115
118
  for (const l of this.raw.split("\n")) {
116
119
  if (l.startsWith("}")) {
117
120
  i = i - 1;
@@ -11,7 +11,7 @@ class HandleABAP {
11
11
  this.options = options;
12
12
  }
13
13
  runObject(obj, reg) {
14
- var _a, _b;
14
+ var _a, _b, _c;
15
15
  let ret = [];
16
16
  if (obj instanceof abaplint.Objects.Program && obj.isInclude() === true) {
17
17
  // includes are only compiled along with the programs where its used?
@@ -27,7 +27,7 @@ class HandleABAP {
27
27
  const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options).traverse(rearranged);
28
28
  chunk.appendChunk(contents);
29
29
  chunk.stripLastNewline();
30
- chunk.runIndentationLogic();
30
+ chunk.runIndentationLogic((_b = this.options) === null || _b === void 0 ? void 0 : _b.ignoreSourceMap);
31
31
  const exports = this.findExports(file.getStructure());
32
32
  const filename = file.getFilename().replace(".abap", ".mjs").toLowerCase();
33
33
  const output = {
@@ -43,7 +43,7 @@ class HandleABAP {
43
43
  ret.push(output);
44
44
  }
45
45
  ret = this.rearrangeClassLocals(obj, ret);
46
- if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.addCommonJS) === true) {
46
+ if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.addCommonJS) === true) {
47
47
  ret.map(output => output.chunk = this.addImportsAndExports(output));
48
48
  }
49
49
  return ret;
@@ -7,7 +7,7 @@ const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class AssignTranspiler {
9
9
  transpile(node, traversal) {
10
- var _a;
10
+ var _a, _b;
11
11
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
12
12
  const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(abaplint.Expressions.Source).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode())) || [];
13
13
  const fs = new expressions_1.FieldSymbolTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.FSTarget), traversal).getCode();
@@ -59,8 +59,13 @@ class AssignTranspiler {
59
59
  if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Dynamic && first instanceof abaplint.Nodes.ExpressionNode) {
60
60
  const firstFirst = first.getChildren()[1];
61
61
  if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.Constant) {
62
- const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/);
63
- options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
62
+ const s = (_b = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)) === null || _b === void 0 ? void 0 : _b.toString();
63
+ if (s === "me") {
64
+ options.push(`dynamicSource: this.me`);
65
+ }
66
+ else {
67
+ options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
68
+ }
64
69
  }
65
70
  else if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
66
71
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
@@ -460,7 +460,7 @@ class Traversal {
460
460
  }
461
461
  const name = def.getName();
462
462
  if (def.isGlobal() === false) {
463
- const prefix = this.buildPrefix(def);
463
+ const prefix = this.buildPrefix();
464
464
  return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
465
465
  }
466
466
  else {
@@ -506,7 +506,7 @@ class Traversal {
506
506
  }
507
507
  if (def) {
508
508
  if (def.isGlobal() === false) {
509
- const prefix = this.buildPrefix(def);
509
+ const prefix = this.buildPrefix();
510
510
  return `abap.Classes['${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}']`;
511
511
  }
512
512
  else {
@@ -518,13 +518,8 @@ class Traversal {
518
518
  return "abap.Classes['" + name.toUpperCase() + "']";
519
519
  }
520
520
  }
521
- buildPrefix(def) {
522
- const file = this.reg.getFileByName(def.getFilename());
523
- if (file === undefined) {
524
- return "NOT_FOUND";
525
- }
526
- const obj = this.reg.findObjectForFile(file);
527
- return (obj === null || obj === void 0 ? void 0 : obj.getType()) + "-" + (obj === null || obj === void 0 ? void 0 : obj.getName());
521
+ buildPrefix() {
522
+ return this.obj.getType() + "-" + this.obj.getName();
528
523
  }
529
524
  ////////////////////////////
530
525
  traverseStructure(node) {
@@ -55,4 +55,6 @@ export interface ITranspilerOptions {
55
55
  keywords?: string[];
56
56
  /** dont insert into REPOSRC */
57
57
  skipReposrc?: boolean;
58
+ /** ignore source map */
59
+ ignoreSourceMap?: boolean;
58
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.6.16",
3
+ "version": "2.6.18",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "abaplint",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@abaplint/core": "^2.97.10",
31
+ "@abaplint/core": "^2.97.12",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {