@abaplint/transpiler 2.11.93 → 2.11.94

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.
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ export declare class DatabaseSchemaReuse {
3
+ private readonly myQuote;
4
+ constructor(quote: string);
5
+ private quote;
6
+ buildVIEW(view: abaplint.Objects.View): string;
7
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatabaseSchemaReuse = void 0;
4
+ class DatabaseSchemaReuse {
5
+ myQuote;
6
+ constructor(quote) {
7
+ this.myQuote = quote;
8
+ }
9
+ quote(name) {
10
+ return this.myQuote + name.toLowerCase() + this.myQuote;
11
+ }
12
+ buildVIEW(view) {
13
+ const fields = view.getFields();
14
+ let firstTabname = "";
15
+ const columns = fields?.map((f) => {
16
+ firstTabname = this.quote(f.TABNAME.toLowerCase());
17
+ return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
18
+ }).join(", ");
19
+ let from = "";
20
+ let previous = "";
21
+ for (const j of view.getJoin() || []) {
22
+ if (previous === "") {
23
+ from += this.quote(j.LTAB.toLowerCase()) + " INNER JOIN " + this.quote(j.RTAB.toLowerCase()) + " ON " + this.quote(j.LTAB.toLowerCase()) + "." + j.LFIELD.toLowerCase() + " = " + this.quote(j.RTAB.toLowerCase()) + "." + j.RFIELD.toLowerCase();
24
+ }
25
+ else if (previous === j.LTAB + "," + j.RTAB) {
26
+ from += " AND " + this.quote(j.LTAB.toLowerCase()) + "." + j.LFIELD.toLowerCase() + " = " + this.quote(j.RTAB.toLowerCase()) + "." + j.RFIELD.toLowerCase();
27
+ }
28
+ else {
29
+ from += " INNER JOIN " + this.quote(j.RTAB.toLowerCase()) + " ON " + this.quote(j.LTAB.toLowerCase()) + "." + j.LFIELD.toLowerCase() + " = " + this.quote(j.RTAB.toLowerCase()) + "." + j.RFIELD.toLowerCase();
30
+ }
31
+ previous = j.LTAB + "," + j.RTAB;
32
+ }
33
+ from = from.trim();
34
+ if (from === "") {
35
+ from = firstTabname;
36
+ }
37
+ return `CREATE VIEW ${this.quote(view.getName().toLowerCase())} AS SELECT ${columns} FROM ${from};\n`;
38
+ }
39
+ }
40
+ exports.DatabaseSchemaReuse = DatabaseSchemaReuse;
41
+ //# sourceMappingURL=_database_schema_reuse.js.map
@@ -2,37 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PGDatabaseSchema = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
+ const _database_schema_reuse_1 = require("./_database_schema_reuse");
6
+ const QUOTE = "\"";
5
7
  class PGDatabaseSchema {
6
8
  reg;
7
9
  constructor(reg) {
8
10
  this.reg = reg;
9
11
  }
10
12
  buildVIEW(view) {
11
- const fields = view.getFields();
12
- let firstTabname = "";
13
- const columns = fields?.map((f) => {
14
- firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
15
- return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
16
- }).join(", ");
17
- let from = "";
18
- let previous = "";
19
- for (const j of view.getJoin() || []) {
20
- if (previous === "") {
21
- from += "'" + j.LTAB.toLowerCase() + "' INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
22
- }
23
- else if (previous === j.LTAB + "," + j.RTAB) {
24
- from += " AND '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
25
- }
26
- else {
27
- from += " INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
28
- }
29
- previous = j.LTAB + "," + j.RTAB;
30
- }
31
- from = from.trim();
32
- if (from === "") {
33
- from = firstTabname;
34
- }
35
- return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\n`;
13
+ return new _database_schema_reuse_1.DatabaseSchemaReuse(QUOTE).buildVIEW(view);
36
14
  }
37
15
  buildTABL(tabl) {
38
16
  const type = tabl.parseType(this.reg);
@@ -3,7 +3,7 @@ import { DatabaseSchemaGenerator } from "./database_schema_generator";
3
3
  export declare class SnowflakeDatabaseSchema implements DatabaseSchemaGenerator {
4
4
  private readonly reg;
5
5
  constructor(reg: abaplint.IRegistry);
6
- buildVIEW(view: abaplint.Objects.View): string;
6
+ buildVIEW(_view: abaplint.Objects.View): string;
7
7
  buildTABL(tabl: abaplint.Objects.Table): string;
8
8
  private toType;
9
9
  }
@@ -7,32 +7,8 @@ class SnowflakeDatabaseSchema {
7
7
  constructor(reg) {
8
8
  this.reg = reg;
9
9
  }
10
- buildVIEW(view) {
11
- const fields = view.getFields();
12
- let firstTabname = "";
13
- const columns = fields?.map((f) => {
14
- firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
15
- return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
16
- }).join(", ");
17
- let from = "";
18
- let previous = "";
19
- for (const j of view.getJoin() || []) {
20
- if (previous === "") {
21
- from += "'" + j.LTAB.toLowerCase() + "' INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
22
- }
23
- else if (previous === j.LTAB + "," + j.RTAB) {
24
- from += " AND '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
25
- }
26
- else {
27
- from += " INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
28
- }
29
- previous = j.LTAB + "," + j.RTAB;
30
- }
31
- from = from.trim();
32
- if (from === "") {
33
- from = firstTabname;
34
- }
35
- return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\n`;
10
+ buildVIEW(_view) {
11
+ throw new Error("buildView, todo snowflake");
36
12
  }
37
13
  buildTABL(tabl) {
38
14
  const type = tabl.parseType(this.reg);
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SQLiteDatabaseSchema = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
+ const _database_schema_reuse_1 = require("./_database_schema_reuse");
6
+ const QUOTE = "'";
5
7
  class SQLiteDatabaseSchema {
6
8
  reg;
7
9
  constructor(reg) {
@@ -9,31 +11,7 @@ class SQLiteDatabaseSchema {
9
11
  }
10
12
  // https://www.sqlite.org/lang_createview.html
11
13
  buildVIEW(view) {
12
- const fields = view.getFields();
13
- let firstTabname = "";
14
- const columns = fields?.map((f) => {
15
- firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
16
- return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
17
- }).join(", ");
18
- let from = "";
19
- let previous = "";
20
- for (const j of view.getJoin() || []) {
21
- if (previous === "") {
22
- from += "'" + j.LTAB.toLowerCase() + "' INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
23
- }
24
- else if (previous === j.LTAB + "," + j.RTAB) {
25
- from += " AND '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
26
- }
27
- else {
28
- from += " INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
29
- }
30
- previous = j.LTAB + "," + j.RTAB;
31
- }
32
- from = from.trim();
33
- if (from === "") {
34
- from = firstTabname;
35
- }
36
- return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\n`;
14
+ return new _database_schema_reuse_1.DatabaseSchemaReuse(QUOTE).buildVIEW(view);
37
15
  }
38
16
  buildTABL(tabl) {
39
17
  const type = tabl.parseType(this.reg);
@@ -7,7 +7,6 @@ const _1 = require(".");
7
7
  const traversal_1 = require("../traversal");
8
8
  const field_symbol_1 = require("./field_symbol");
9
9
  const chunk_1 = require("../chunk");
10
- const feature_flags_1 = require("../feature_flags");
11
10
  class FieldChainTranspiler {
12
11
  addGet;
13
12
  addGetOffset;
@@ -48,8 +47,7 @@ class FieldChainTranspiler {
48
47
  // Do not mark constants as private JS fields. Constants are exposed on instances via constructor copying.
49
48
  const constants = cdef?.getAttributes().getConstants() || [];
50
49
  const isConstant = constants.some(cons => cons.getName().toUpperCase() === tokenName.toUpperCase());
51
- if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
52
- && attr?.getVisibility() === abaplint.Visibility.Private
50
+ if (attr?.getVisibility() === abaplint.Visibility.Private
53
51
  && isConstant === false) {
54
52
  const id = scope?.getParent()?.getParent()?.getIdentifier();
55
53
  if (id?.stype === abaplint.ScopeType.ClassImplementation
@@ -6,7 +6,6 @@ const abaplint = require("@abaplint/core");
6
6
  const traversal_1 = require("../traversal");
7
7
  const _1 = require(".");
8
8
  const chunk_1 = require("../chunk");
9
- const feature_flags_1 = require("../feature_flags");
10
9
  class TargetTranspiler {
11
10
  transpile(node, traversal) {
12
11
  const offset = [];
@@ -52,8 +51,7 @@ class TargetTranspiler {
52
51
  if (context instanceof abaplint.BasicTypes.ObjectReferenceType) {
53
52
  const cdef = traversal.findClassDefinition(context.getIdentifierName(), scope);
54
53
  const attr = cdef?.getAttributes().findByName(c.getFirstToken().getStr());
55
- if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
56
- && attr?.getVisibility() === abaplint.Visibility.Private) {
54
+ if (attr?.getVisibility() === abaplint.Visibility.Private) {
57
55
  const id = scope?.getParent()?.getParent()?.getIdentifier();
58
56
  if (id?.stype === abaplint.ScopeType.ClassImplementation
59
57
  && cdef?.getName().toUpperCase() === id.sname.toUpperCase()) {
@@ -1,3 +1 @@
1
- export declare const FEATURE_FLAGS: {
2
- PRIVATE_ATTRIBUTES: boolean;
3
- };
1
+ export declare const FEATURE_FLAGS: {};
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FEATURE_FLAGS = void 0;
4
- exports.FEATURE_FLAGS = {
5
- PRIVATE_ATTRIBUTES: true,
6
- };
4
+ exports.FEATURE_FLAGS = {};
7
5
  //# sourceMappingURL=feature_flags.js.map
@@ -5,7 +5,6 @@ const abaplint = require("@abaplint/core");
5
5
  const traversal_1 = require("../traversal");
6
6
  const transpile_types_1 = require("../transpile_types");
7
7
  const chunk_1 = require("../chunk");
8
- const feature_flags_1 = require("../feature_flags");
9
8
  class ClassImplementationTranspiler {
10
9
  transpile(node, traversal) {
11
10
  const ret = new chunk_1.Chunk();
@@ -75,7 +74,7 @@ class ClassImplementationTranspiler {
75
74
  return ret;
76
75
  }
77
76
  buildPrivate(node, traversal) {
78
- if (node === undefined || feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === false) {
77
+ if (node === undefined) {
79
78
  return "";
80
79
  }
81
80
  const cdef = traversal.getClassDefinition(node.getFirstToken());
@@ -9,7 +9,6 @@ const transpile_types_1 = require("./transpile_types");
9
9
  const chunk_1 = require("./chunk");
10
10
  const expressions_1 = require("./expressions");
11
11
  const keywords_1 = require("./keywords");
12
- const feature_flags_1 = require("./feature_flags");
13
12
  class Traversal {
14
13
  spaghetti;
15
14
  file;
@@ -187,7 +186,7 @@ class Traversal {
187
186
  }
188
187
  else if (this.isClassAttribute(t)) {
189
188
  let escaped = Traversal.escapeNamespace(name);
190
- if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true && this.isPrivateAttribute(t)) {
189
+ if (this.isPrivateAttribute(t)) {
191
190
  escaped = "#" + escaped;
192
191
  }
193
192
  name = "this." + escaped;
@@ -444,8 +443,7 @@ class Traversal {
444
443
  ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
445
444
  }
446
445
  else {
447
- if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
448
- && a.getVisibility() === abaplint.Visibility.Private) {
446
+ if (a.getVisibility() === abaplint.Visibility.Private) {
449
447
  escaped = "#" + escaped;
450
448
  }
451
449
  const name = "this." + escaped;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.11.93",
3
+ "version": "2.11.94",
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.210",
32
+ "@abaplint/core": "^2.113.217",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {