@abaplint/transpiler 2.13.19 → 2.13.21

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.
@@ -108,7 +108,8 @@ class MethodSourceTranspiler {
108
108
  const m = traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken));
109
109
  if (i === 0 && m) {
110
110
  this.prepend += "this.";
111
- if (this.privatePrefix && m.def.getVisibility() === core_1.Visibility.Private) {
111
+ if (this.privatePrefix && m.def.getVisibility() === core_1.Visibility.Private
112
+ && m.def.isStatic() === false) { // todo: this is probably wrong?
112
113
  this.prepend += "#";
113
114
  }
114
115
  }
@@ -8,6 +8,12 @@ class TypeNameOrInfer {
8
8
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
9
9
  const type = traversal.lookupInferred(node, scope);
10
10
  if (type === undefined) {
11
+ if (node.concatTokens() === "#") {
12
+ const sqlType = traversal.getSQLInferredType();
13
+ if (sqlType !== undefined) {
14
+ return sqlType;
15
+ }
16
+ }
11
17
  throw new Error("TypeNameOrInfer, type not found: " + node.concatTokens() + ", " + traversal.getCurrentObject().getName() + " line " + node.getFirstToken().getStart().getRow());
12
18
  }
13
19
  return type;
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IStatementTranspiler } from "./_statement_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class GenerateSubroutineTranspiler implements IStatementTranspiler {
6
+ transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateSubroutineTranspiler = void 0;
4
+ const chunk_1 = require("../chunk");
5
+ class GenerateSubroutineTranspiler {
6
+ transpile(_node, _traversal) {
7
+ return new chunk_1.Chunk(`throw new Error("GenerateSubroutine, not supported, transpiler");`);
8
+ }
9
+ }
10
+ exports.GenerateSubroutineTranspiler = GenerateSubroutineTranspiler;
11
+ //# sourceMappingURL=generate_subroutine.js.map
@@ -129,6 +129,7 @@ export * from "./set_language";
129
129
  export * from "./set_locale";
130
130
  export * from "./set_parameter";
131
131
  export * from "./set_pf_status";
132
+ export * from "./generate_subroutine";
132
133
  export * from "./set_screen";
133
134
  export * from "./set_titlebar";
134
135
  export * from "./shift";
@@ -145,6 +145,7 @@ __exportStar(require("./set_language"), exports);
145
145
  __exportStar(require("./set_locale"), exports);
146
146
  __exportStar(require("./set_parameter"), exports);
147
147
  __exportStar(require("./set_pf_status"), exports);
148
+ __exportStar(require("./generate_subroutine"), exports);
148
149
  __exportStar(require("./set_screen"), exports);
149
150
  __exportStar(require("./set_titlebar"), exports);
150
151
  __exportStar(require("./shift"), exports);
@@ -20,7 +20,7 @@ class InsertDatabaseTranspiler {
20
20
  }
21
21
  const from = node.findExpressionAfterToken("FROM");
22
22
  if (from && from.get() instanceof abaplint.Expressions.SQLSource) {
23
- const tvalues = traversal.traverse(from);
23
+ const tvalues = traversal.traverseWithTableContext(dbtab.concatTokens(), from);
24
24
  options.push(`"values": ` + tvalues.getCode());
25
25
  }
26
26
  const fromTable = node.findExpressionAfterToken("TABLE");
@@ -19,7 +19,7 @@ class ModifyDatabaseTranspiler {
19
19
  }
20
20
  const from = node.findExpressionAfterToken("FROM");
21
21
  if (from && from.get() instanceof abaplint.Expressions.SQLSource) {
22
- const tvalues = traversal.traverse(from);
22
+ const tvalues = traversal.traverseWithTableContext(dbtab.concatTokens(), from);
23
23
  options.push(`"values": ` + tvalues.getCode());
24
24
  }
25
25
  return new chunk_1.Chunk(`await abap.statements.modifyDatabase(${table.getCode()}, {${options.join(", ")}});`);
@@ -5,6 +5,7 @@ export declare class Traversal {
5
5
  private readonly spaghetti;
6
6
  private readonly file;
7
7
  private readonly obj;
8
+ private sqlInferredType;
8
9
  readonly reg: abaplint.IRegistry;
9
10
  readonly options: ITranspilerOptions | undefined;
10
11
  constructor(spaghetti: abaplint.ISpaghettiScope, file: abaplint.ABAPFile, obj: abaplint.ABAPObject, reg: abaplint.IRegistry, options?: ITranspilerOptions);
@@ -20,6 +21,8 @@ export declare class Traversal {
20
21
  private scopeCache;
21
22
  findCurrentScopeByToken(token: abaplint.Token): abaplint.ISpaghettiScopeNode | undefined;
22
23
  private fuctionGroupWorkaround;
24
+ getSQLInferredType(): abaplint.AbstractType | undefined;
25
+ traverseWithTableContext(tableName: string, expressionNode: abaplint.Nodes.ExpressionNode): Chunk;
23
26
  getInterfaceDefinition(token: abaplint.Token): abaplint.IInterfaceDefinition | undefined;
24
27
  getClassDefinition(token: abaplint.Token): abaplint.IClassDefinition | undefined;
25
28
  private isPrivateAttribute;
@@ -13,6 +13,7 @@ class Traversal {
13
13
  spaghetti;
14
14
  file;
15
15
  obj;
16
+ sqlInferredType;
16
17
  reg;
17
18
  options;
18
19
  constructor(spaghetti, file, obj, reg, options) {
@@ -107,6 +108,16 @@ class Traversal {
107
108
  }
108
109
  return undefined;
109
110
  }
111
+ getSQLInferredType() {
112
+ return this.sqlInferredType;
113
+ }
114
+ traverseWithTableContext(tableName, expressionNode) {
115
+ const tabl = this.reg.getObject("TABL", tableName);
116
+ this.sqlInferredType = tabl?.parseType(this.reg);
117
+ const result = this.traverse(expressionNode);
118
+ this.sqlInferredType = undefined;
119
+ return result;
120
+ }
110
121
  getInterfaceDefinition(token) {
111
122
  let scope = this.findCurrentScopeByToken(token);
112
123
  while (scope !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.19",
3
+ "version": "2.13.21",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",