@abaplint/transpiler 1.7.7 → 1.7.8

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.
@@ -31,6 +31,7 @@ class DatabaseSetup {
31
31
  }
32
32
  const type = obj.parseType(this.reg);
33
33
  if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length === 3) {
34
+ // todo, this should take the client number from the settings
34
35
  return `INSERT INTO t000 VALUES ('123', '', '');\n`;
35
36
  }
36
37
  else {
@@ -1,6 +1,6 @@
1
1
  import * as abaplint from "@abaplint/core";
2
2
  import { config } from "./validation";
3
- import { SkipSettings } from "./unit_test";
3
+ import { TestMethodList } from "./unit_test";
4
4
  import { Chunk } from "./chunk";
5
5
  export { config };
6
6
  export interface IFile {
@@ -46,7 +46,8 @@ export interface ITranspilerOptions {
46
46
  skipConstants?: boolean;
47
47
  /** sets behavior for unknown types, either fail at compile- or run-time */
48
48
  unknownTypes?: "compileError" | "runtimeError";
49
- skip?: SkipSettings;
49
+ skip?: TestMethodList;
50
+ only?: TestMethodList;
50
51
  }
51
52
  export declare class Transpiler {
52
53
  private readonly options;
@@ -28,14 +28,14 @@ class Transpiler {
28
28
  return new Transpiler().run(reg);
29
29
  }
30
30
  async run(reg, progress) {
31
- var _a;
31
+ var _a, _b;
32
32
  reg.parse();
33
33
  new keywords_1.Keywords().handle(reg);
34
34
  this.validate(reg);
35
35
  const dbSetup = new database_setup_1.DatabaseSetup(reg).run();
36
36
  const output = {
37
37
  objects: [],
38
- unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip),
38
+ unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
39
39
  initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup),
40
40
  databaseSetup: dbSetup,
41
41
  reg: reg,
@@ -3,5 +3,5 @@ import { IStatementTranspiler } from "./_statement_transpiler";
3
3
  import { Traversal } from "../traversal";
4
4
  import { Chunk } from "../chunk";
5
5
  export declare class CreateDataTranspiler implements IStatementTranspiler {
6
- transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
6
+ transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
7
  }
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateDataTranspiler = void 0;
4
+ const abaplint = require("@abaplint/core");
4
5
  const chunk_1 = require("../chunk");
5
6
  class CreateDataTranspiler {
6
- transpile(_node, _traversal) {
7
- return new chunk_1.Chunk(`throw "CreateDataTranspiler-todo";`);
7
+ transpile(node, traversal) {
8
+ const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
9
+ const target = traversal.traverse(targetNode);
10
+ return new chunk_1.Chunk("abap.statements.createData(" + target.getCode() + ");");
8
11
  }
9
12
  }
10
13
  exports.CreateDataTranspiler = CreateDataTranspiler;
@@ -1,11 +1,11 @@
1
1
  import * as abaplint from "@abaplint/core";
2
- export declare type SkipSettings = {
2
+ export declare type TestMethodList = {
3
3
  object: string;
4
4
  class: string;
5
5
  method: string;
6
6
  }[];
7
7
  export declare class UnitTest {
8
8
  initializationScript(reg: abaplint.IRegistry, dbSetup: string): string;
9
- unitTestScript(reg: abaplint.IRegistry, skip?: SkipSettings): string;
9
+ unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
10
10
  private buildImports;
11
11
  }
@@ -3,25 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnitTest = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  class UnitTest {
6
+ // todo, move this somewhere else, its much more than just unit test relevant
6
7
  initializationScript(reg, dbSetup) {
7
8
  return `import runtime from "@abaplint/runtime";
8
9
  global.abap = new runtime.ABAP();
9
10
  ${this.buildImports(reg)}
10
- export async function initDB() {
11
- return global.abap.initDB(\`${dbSetup}\`);
11
+ export async function initializeABAP(settings) {
12
+ await global.abap.initDB(\`${dbSetup}\`);
12
13
  }`;
13
14
  }
14
- unitTestScript(reg, skip) {
15
+ unitTestScript(reg, skip, _only) {
15
16
  let ret = `import fs from "fs";
16
17
  import path from "path";
17
18
  import {dirname} from 'path';
18
19
  import {fileURLToPath} from 'url';
19
20
  const __dirname = dirname(fileURLToPath(import.meta.url));
20
- import {initDB} from "./init.mjs";
21
+ import {initializeABAP} from "./init.mjs";
21
22
  import runtime from "@abaplint/runtime";
22
23
 
23
24
  async function run() {
24
- await initDB();
25
+ await initializeABAP();
25
26
  const unit = new runtime.UnitTestResult();
26
27
  let clas;
27
28
  let locl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@abaplint/core": "^2.83.21",
30
+ "@abaplint/core": "^2.83.23",
31
31
  "source-map": "^0.7.3"
32
32
  },
33
33
  "devDependencies": {