@abaplint/transpiler 2.11.63 → 2.11.64
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Nodes } from "@abaplint/core";
|
|
1
|
+
import { AbstractType, Nodes } from "@abaplint/core";
|
|
2
2
|
import { Traversal } from "../traversal";
|
|
3
3
|
import { Chunk } from "../chunk";
|
|
4
4
|
export declare class FieldAssignmentTranspiler {
|
|
5
|
-
transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
|
|
5
|
+
transpile(node: Nodes.ExpressionNode, traversal: Traversal, context?: AbstractType): Chunk;
|
|
6
6
|
}
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FieldAssignmentTranspiler = void 0;
|
|
4
4
|
const core_1 = require("@abaplint/core");
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
|
+
const abaplint = require("@abaplint/core");
|
|
7
|
+
const source_1 = require("./source");
|
|
6
8
|
class FieldAssignmentTranspiler {
|
|
7
|
-
transpile(node, traversal) {
|
|
9
|
+
transpile(node, traversal, context) {
|
|
8
10
|
const ret = new chunk_1.Chunk();
|
|
9
11
|
const field = node.findDirectExpression(core_1.Expressions.FieldSub);
|
|
10
12
|
if (field === undefined) {
|
|
@@ -14,7 +16,11 @@ class FieldAssignmentTranspiler {
|
|
|
14
16
|
if (source === undefined) {
|
|
15
17
|
throw new Error("FieldAssignmentTranspiler, Expected Source");
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
if (context instanceof abaplint.BasicTypes.StructureType) {
|
|
20
|
+
context = context.getComponentByName(field.concatTokens());
|
|
21
|
+
}
|
|
22
|
+
const sourc = new source_1.SourceTranspiler().transpile(source, traversal, context).getCode();
|
|
23
|
+
ret.appendString(`.setField("${field.concatTokens().toLowerCase()}", ${sourc})`);
|
|
18
24
|
return ret;
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -12,7 +12,7 @@ class StringTemplateSourceTranspiler {
|
|
|
12
12
|
let post = ")";
|
|
13
13
|
const formatting = node.findDirectExpression(core_1.Expressions.StringTemplateFormatting);
|
|
14
14
|
if (formatting) {
|
|
15
|
-
const options = this.build(formatting, traversal, context);
|
|
15
|
+
const options = this.build(formatting, traversal, context, node);
|
|
16
16
|
if (options) {
|
|
17
17
|
post = "," + options + ")";
|
|
18
18
|
}
|
|
@@ -24,7 +24,7 @@ class StringTemplateSourceTranspiler {
|
|
|
24
24
|
ret += pre + new _1.SourceTranspiler().transpile(c, traversal).getCode() + post;
|
|
25
25
|
return new chunk_1.Chunk(ret);
|
|
26
26
|
}
|
|
27
|
-
build(node, traversal, context) {
|
|
27
|
+
build(node, traversal, context, _top) {
|
|
28
28
|
let option = "";
|
|
29
29
|
let count = 0;
|
|
30
30
|
for (const c of node.getChildren()) {
|
|
@@ -45,10 +45,9 @@ class StringTemplateSourceTranspiler {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (option.startsWith(`"alpha":"in"`)) {
|
|
48
|
-
if (context
|
|
49
|
-
|
|
48
|
+
if (context !== undefined) {
|
|
49
|
+
option += `, "alphaInContext": ` + transpile_types_1.TranspileTypes.toType(context);
|
|
50
50
|
}
|
|
51
|
-
option += `, "alphaInContext": ` + transpile_types_1.TranspileTypes.toType(context);
|
|
52
51
|
}
|
|
53
52
|
if (option !== "") {
|
|
54
53
|
return "{" + option + "}";
|
|
@@ -26,7 +26,7 @@ class ValueBodyTranspiler {
|
|
|
26
26
|
const hasLines = body.findDirectExpression(core_1.Expressions.ValueBodyLine) !== undefined;
|
|
27
27
|
for (const child of body.getChildren()) {
|
|
28
28
|
if (child.get() instanceof core_1.Expressions.FieldAssignment && child instanceof core_1.Nodes.ExpressionNode) {
|
|
29
|
-
const transpiled = new field_assignment_1.FieldAssignmentTranspiler().transpile(child, traversal).getCode();
|
|
29
|
+
const transpiled = new field_assignment_1.FieldAssignmentTranspiler().transpile(child, traversal, context).getCode();
|
|
30
30
|
if (hasLines === false) {
|
|
31
31
|
ret.appendString(transpiled);
|
|
32
32
|
}
|
|
@@ -15,7 +15,8 @@ class MoveTranspiler {
|
|
|
15
15
|
if (targetExpressions.length === 1
|
|
16
16
|
&& sourceExpression?.getChildren().length === 1
|
|
17
17
|
&& sourceExpression.findDirectExpression(abaplint.Expressions.StringTemplate)
|
|
18
|
-
&& sourceExpression.concatTokens().toUpperCase().endsWith(" ALPHA = IN }|")
|
|
18
|
+
&& sourceExpression.concatTokens().toUpperCase().endsWith(" ALPHA = IN }|")
|
|
19
|
+
&& sourceExpression.concatTokens().toUpperCase().startsWith("|{")) {
|
|
19
20
|
const target = targets[0].getCode();
|
|
20
21
|
const tSource = traversal.traverse(sourceExpression.findFirstExpression(abaplint.Expressions.StringTemplateSource)?.findDirectExpression(abaplint.Expressions.Source));
|
|
21
22
|
ret.appendString(target + `.set(abap.alphaIn(${tSource.getCode()}, ${target}, ${target}));`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.64",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.113.
|
|
32
|
+
"@abaplint/core": "^2.113.191",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|