@idlizer/arktscgen 2.1.10-arktscgen-6 → 2.1.10-arktscgen-7

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.
Files changed (31) hide show
  1. package/build/libarkts-copy/native/meson.build +4 -4
  2. package/build/libarkts-copy/native/src/{bridges.cc → bridges.cpp} +11 -11
  3. package/build/libarkts-copy/native/src/{common.cc → common.cpp} +163 -108
  4. package/build/libarkts-copy/native/src/common.h +22 -22
  5. package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +9 -3
  6. package/build/libarkts-copy/package.json +2 -2
  7. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +8 -3
  8. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
  9. package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
  10. package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
  11. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +0 -1
  12. package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -10
  13. package/build/libarkts-copy/src/arkts-api/static/global.ts +0 -3
  14. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +4 -4
  15. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +7 -34
  16. package/build/libarkts-copy/src/index.ts +0 -1
  17. package/build/libarkts-copy/src/plugin-utils.ts +58 -33
  18. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -1
  19. package/build/libarkts-copy/tsconfig.json +0 -3
  20. package/lib/index.js +218 -36
  21. package/package.json +2 -2
  22. package/templates/{bridges.cc → bridges.cpp} +1 -1
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
  24. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
  25. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
  26. package/build/libarkts-copy/src/ts-api/index.ts +0 -27
  27. package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
  28. package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
  29. package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
  30. package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
  31. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
package/lib/index.js CHANGED
@@ -261,6 +261,9 @@ function isReferenceType(type) {
261
261
  function isEnum(type) {
262
262
  return type.kind == IDLKind.Enum;
263
263
  }
264
+ function isEnumMember(type) {
265
+ return type.kind == IDLKind.EnumMember;
266
+ }
264
267
  function isUnionType(type) {
265
268
  return type.kind == IDLKind.UnionType;
266
269
  }
@@ -1566,11 +1569,144 @@ function convertType(convertor, type) {
1566
1569
  return convertor.convertPrimitiveType(type);
1567
1570
  throw new Error(`Unknown type ${IDLKind[type.kind]}`);
1568
1571
  }
1572
+ function convertDeclaration(convertor, decl) {
1573
+ if (isImport(decl))
1574
+ return convertor.convertImport(decl);
1575
+ if (isNamespace(decl))
1576
+ return convertor.convertNamespace(decl);
1577
+ if (isInterface(decl))
1578
+ return convertor.convertInterface(decl);
1579
+ if (isEnum(decl))
1580
+ return convertor.convertEnum(decl);
1581
+ if (isEnumMember(decl))
1582
+ return convertor.convertEnum(decl.parent);
1583
+ if (isTypedef(decl))
1584
+ return convertor.convertTypedef(decl);
1585
+ if (isCallback(decl))
1586
+ return convertor.convertCallback(decl);
1587
+ if (isMethod(decl))
1588
+ return convertor.convertMethod(decl);
1589
+ if (isConstant(decl))
1590
+ return convertor.convertConstant(decl);
1591
+ throw new Error(`Unknown declaration type ${decl.kind ? IDLKind[decl.kind] : "(undefined kind)"}`);
1592
+ }
1569
1593
  function withInsideInstanceof(isInsideInstanceof, op) {
1570
1594
  const result = op();
1571
1595
  return result;
1572
1596
  }
1573
1597
 
1598
+ /*
1599
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
1600
+ * Licensed under the Apache License, Version 2.0 (the "License");
1601
+ * you may not use this file except in compliance with the License.
1602
+ * You may obtain a copy of the License at
1603
+ *
1604
+ * http://www.apache.org/licenses/LICENSE-2.0
1605
+ *
1606
+ * Unless required by applicable law or agreed to in writing, software
1607
+ * distributed under the License is distributed on an "AS IS" BASIS,
1608
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1609
+ * See the License for the specific language governing permissions and
1610
+ * limitations under the License.
1611
+ */
1612
+ class DeclarationNameConvertor {
1613
+ convertImport(decl) {
1614
+ console.warn("Imports are not implemented yet");
1615
+ return decl.name;
1616
+ }
1617
+ convertInterface(decl) {
1618
+ return decl.name;
1619
+ }
1620
+ convertEnum(decl) {
1621
+ return `${getNamespacesPathFor(decl).join('')}${decl.name}`;
1622
+ }
1623
+ convertTypedef(decl) {
1624
+ return decl.name;
1625
+ }
1626
+ convertCallback(decl) {
1627
+ var _a;
1628
+ return (_a = decl.name) !== null && _a !== void 0 ? _a : "MISSING CALLBACK NAME";
1629
+ }
1630
+ convertNamespace(node) {
1631
+ return node.name;
1632
+ }
1633
+ convertMethod(node) {
1634
+ return node.name;
1635
+ }
1636
+ convertConstant(node) {
1637
+ return node.name;
1638
+ }
1639
+ }
1640
+ DeclarationNameConvertor.I = new DeclarationNameConvertor();
1641
+ class TSFeatureNameConvertor extends DeclarationNameConvertor {
1642
+ convertEnum(decl) {
1643
+ const namespace = getNamespacesPathFor(decl).map(it => it.name);
1644
+ if (namespace.length > 0)
1645
+ return namespace[0];
1646
+ return decl.name;
1647
+ }
1648
+ }
1649
+ TSFeatureNameConvertor.I = new TSFeatureNameConvertor();
1650
+ class ETSDeclarationNameConvertor extends DeclarationNameConvertor {
1651
+ convertInterface(decl) {
1652
+ return getQualifiedName(decl, "namespace.name");
1653
+ }
1654
+ convertEnum(decl) {
1655
+ return getQualifiedName(decl, "namespace.name");
1656
+ }
1657
+ }
1658
+ ETSDeclarationNameConvertor.I = new ETSDeclarationNameConvertor();
1659
+ class CJDeclarationNameConvertor extends DeclarationNameConvertor {
1660
+ convertInterface(decl) {
1661
+ return decl.name;
1662
+ }
1663
+ convertEnum(decl) {
1664
+ return decl.name;
1665
+ }
1666
+ }
1667
+ CJDeclarationNameConvertor.I = new CJDeclarationNameConvertor();
1668
+ class KotlinDeclarationNameConvertor extends DeclarationNameConvertor {
1669
+ convertInterface(decl) {
1670
+ return removePoints(getQualifiedName(decl, "namespace.name"));
1671
+ }
1672
+ convertEnum(decl) {
1673
+ return removePoints(getQualifiedName(decl, "namespace.name"));
1674
+ }
1675
+ }
1676
+ KotlinDeclarationNameConvertor.I = new KotlinDeclarationNameConvertor();
1677
+ class ETSFeatureNameConvertor extends DeclarationNameConvertor {
1678
+ convertEnum(decl) {
1679
+ const namespace = getNamespacesPathFor(decl).map(it => it.name);
1680
+ if (namespace.length > 0)
1681
+ return namespace[0];
1682
+ return decl.name;
1683
+ }
1684
+ }
1685
+ ETSFeatureNameConvertor.I = new ETSFeatureNameConvertor();
1686
+ class CJFeatureNameConvertor extends DeclarationNameConvertor {
1687
+ convertEnum(decl) {
1688
+ return decl.name;
1689
+ }
1690
+ }
1691
+ CJFeatureNameConvertor.I = new CJFeatureNameConvertor();
1692
+ class KotlinFeatureNameConvertor extends DeclarationNameConvertor {
1693
+ convertInterface(decl) {
1694
+ return removePoints(getQualifiedName(decl, "namespace.name"));
1695
+ }
1696
+ convertEnum(decl) {
1697
+ return removePoints(getQualifiedName(decl, "namespace.name"));
1698
+ }
1699
+ }
1700
+ KotlinFeatureNameConvertor.I = new KotlinFeatureNameConvertor();
1701
+ function createDeclarationNameConvertor(language) {
1702
+ switch (language) {
1703
+ case Language.ARKTS: return ETSDeclarationNameConvertor.I;
1704
+ case Language.CPP:
1705
+ case Language.TS: return DeclarationNameConvertor.I;
1706
+ case Language.CJ: case Language.KOTLIN: default: throw new Error(`Language ${language.toString()} is not supported`);
1707
+ }
1708
+ }
1709
+
1574
1710
  /*
1575
1711
  * Copyright (c) 2024 Huawei Device Co., Ltd.
1576
1712
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1796,28 +1932,33 @@ class TsEnumEntityStatement {
1796
1932
  this.options = options;
1797
1933
  }
1798
1934
  write(writer) {
1799
- // writer.print(this.enumEntity.comment)
1800
- writer.print(`${this.options.isExport ? "export " : ""}${this.options.isDeclare ? "declare " : ""}enum ${this.enumEntity.name} {`);
1801
- writer.pushIndent();
1935
+ let enumName = convertDeclaration(createDeclarationNameConvertor(Language.ARKTS), this.enumEntity);
1936
+ enumName = enumName.split('.').at(-1);
1937
+ const correctStyleNames = [];
1938
+ const originalStyleNames = [];
1802
1939
  this.enumEntity.elements.forEach((member, index) => {
1803
- // writer.print(member.comment)
1804
- const initValue = member.initializer
1805
- ? ` = ${this.maybeQuoted(member.initializer)}` : ``;
1806
- writer.print(`${member.name}${initValue},`);
1807
- let originalName = getExtAttribute(member, IDLExtendedAttributes.OriginalEnumMemberName);
1808
- if (originalName) {
1809
- const initValue = ` = ${member.name}`;
1810
- writer.print(`${originalName}${initValue},`);
1811
- }
1940
+ var _a;
1941
+ const initText = (_a = member.initializer) !== null && _a !== void 0 ? _a : index;
1942
+ const isTypeString = typeof initText !== "number";
1943
+ const originalName = getExtAttribute(member, IDLExtendedAttributes.OriginalEnumMemberName);
1944
+ correctStyleNames.push({
1945
+ name: originalName ? member.name : `${member.name}_DUMMY`,
1946
+ alias: undefined,
1947
+ stringId: isTypeString ? initText : undefined,
1948
+ numberId: initText
1949
+ });
1950
+ originalStyleNames.push({
1951
+ name: originalName !== null && originalName !== void 0 ? originalName : member.name,
1952
+ alias: undefined,
1953
+ stringId: isTypeString ? initText : undefined,
1954
+ numberId: initText
1955
+ });
1812
1956
  });
1813
- writer.popIndent();
1814
- writer.print(`}`);
1815
- }
1816
- maybeQuoted(value) {
1817
- if (typeof value == "string")
1818
- return `"${value}"`;
1819
- else
1820
- return `${value}`;
1957
+ let members = originalStyleNames;
1958
+ if (this.enumEntity.elements.some(it => hasExtAttribute(it, IDLExtendedAttributes.OriginalEnumMemberName))) {
1959
+ members = members.concat(correctStyleNames);
1960
+ }
1961
+ writer.writeEnum(enumName, members, { isExport: this.options.isExport, isDeclare: this.options.isDeclare });
1821
1962
  }
1822
1963
  }
1823
1964
  class ReturnStatement {
@@ -5024,8 +5165,15 @@ class TSLanguageWriter extends LanguageWriter {
5024
5165
  }
5025
5166
  i32FromEnum(value, enumEntry) {
5026
5167
  const enumName = this.getNodeName(enumEntry);
5027
- if (isEnum(enumEntry) && isStringEnum(enumEntry)) {
5028
- return this.makeString(`Object.values(${enumName}).indexOf(${value.asString()})`);
5168
+ if (isStringEnum(enumEntry)) {
5169
+ let extractorStatement = this.makeString(`Object.values(${enumName}).indexOf(${value.asString()})`);
5170
+ if (enumEntry.elements.some(it => hasExtAttribute(it, IDLExtendedAttributes.OriginalEnumMemberName))) {
5171
+ extractorStatement = this.makeNaryOp('%', [
5172
+ extractorStatement,
5173
+ this.makeString(enumEntry.elements.length.toString())
5174
+ ]);
5175
+ }
5176
+ return extractorStatement;
5029
5177
  }
5030
5178
  return this.makeString(`${value.asString()}.valueOf()`);
5031
5179
  }
@@ -5103,6 +5251,9 @@ function rightmostIndexOf(array, predicate) {
5103
5251
  });
5104
5252
  return result;
5105
5253
  }
5254
+ function removePoints(s) {
5255
+ return s.split(/[\.\-]/g).join('_');
5256
+ }
5106
5257
 
5107
5258
  /*
5108
5259
  * Copyright (c) 2025 Huawei Device Co., Ltd.
@@ -7115,10 +7266,10 @@ class BridgesConstructions {
7115
7266
  return `result`;
7116
7267
  }
7117
7268
  static stringConstructor(name) {
7118
- return `StageArena::strdup(${name})`;
7269
+ return `StageArena::Strdup(${name})`;
7119
7270
  }
7120
7271
  static sequenceConstructor(first, length) {
7121
- return `StageArena::cloneVector(${first}, ${length})`;
7272
+ return `StageArena::CloneVector(${first}, ${length})`;
7122
7273
  }
7123
7274
  static referenceTypeCast(type) {
7124
7275
  return `reinterpret_cast<${type}>`;
@@ -7391,6 +7542,10 @@ function nodeNamespace(node) {
7391
7542
  var _a;
7392
7543
  return (_a = getNamespacesPathFor(node)[0]) === null || _a === void 0 ? void 0 : _a.name;
7393
7544
  }
7545
+ /**
7546
+ * Returns a fully qualified name for a node with no exceptions.
7547
+ * @note Primarily used to pass a name to Config' options.
7548
+ */
7394
7549
  function fqName(node) {
7395
7550
  return getQualifiedName(node, "namespace.name");
7396
7551
  }
@@ -7469,6 +7624,26 @@ function flatParentsImpl(ref, resolveReference) {
7469
7624
  }
7470
7625
  return result; // with self
7471
7626
  }
7627
+ /**
7628
+ * A fully qualified of a type that reference points to.
7629
+ * @note 'ir' namespace is ignored and treated as global namespace.
7630
+ */
7631
+ function makeFullyQualifiedName(ref, resolveReference) {
7632
+ const decl = resolveReference(ref);
7633
+ if (!decl) {
7634
+ return ref.name;
7635
+ }
7636
+ return getNamespacesPathFor(decl)
7637
+ .filter(n => n.name !== Config.irNamespace)
7638
+ .map(n => n.name)
7639
+ .concat(decl.name)
7640
+ .join('.');
7641
+ }
7642
+ /**
7643
+ * If namespaces of the reference and resolved declaration
7644
+ * are the same, non-qualified name is returned. Otherwise, a fully qualified.
7645
+ * @note 'ir' namespace is ignored and treated as global namespace.
7646
+ */
7472
7647
  function makeEnoughQualifiedName(ref, resolveReference) {
7473
7648
  const decl = resolveReference(ref);
7474
7649
  if (!decl) {
@@ -8436,8 +8611,7 @@ class PeersConstructions {
8436
8611
  * limitations under the License.
8437
8612
  */
8438
8613
  class Importer {
8439
- constructor(typechecker, dir, self) {
8440
- this.typechecker = typechecker;
8614
+ constructor(dir, self) {
8441
8615
  this.dir = dir;
8442
8616
  this.writer = createDefaultTypescriptWriter();
8443
8617
  this.seen = new Set([
@@ -8448,11 +8622,11 @@ class Importer {
8448
8622
  this.seen.add(self);
8449
8623
  }
8450
8624
  }
8451
- withPeerImport(ref, context) {
8452
- const name = makeEnoughQualifiedName(ref, this.typechecker.resolveReference.bind(this.typechecker));
8625
+ withPeerImport(name) {
8453
8626
  const fq = name.split('.');
8454
8627
  // import namespace name for fq names
8455
- return this.withPeerImport2(fq.length > 1 ? fq.slice(0, -1).join('.') : name);
8628
+ this.withPeerImport2(fq.length > 1 ? fq.slice(0, -1).join('.') : name);
8629
+ return name;
8456
8630
  }
8457
8631
  withPeerImport2(it) {
8458
8632
  if (this.seen.has(it)) {
@@ -8799,9 +8973,10 @@ class PeerPrinter {
8799
8973
  printPeer(iface, writer) {
8800
8974
  var _a;
8801
8975
  const _parent = (_a = iface.inheritance[0]) !== null && _a !== void 0 ? _a : createReferenceType(Config.defaultAncestor);
8976
+ const parentName = makeEnoughQualifiedName(_parent, this.typechecker.resolveReference.bind(this.typechecker));
8802
8977
  this.importer.addSeen(PeersConstructions.peerName(iface.name));
8803
8978
  writer.writeClass(PeersConstructions.peerName(iface.name), // XXX: Change peer name to iface.name
8804
- (writer) => this.printBody(iface, writer), this.importer.withPeerImport(_parent));
8979
+ (writer) => this.printBody(iface, writer), this.importer.withPeerImport(parentName));
8805
8980
  }
8806
8981
  printBody(iface, writer) {
8807
8982
  this.printConstructor(iface, writer);
@@ -9028,7 +9203,7 @@ function convertAndImport(importer, converter, type, config) {
9028
9203
  importer.withReexportImport(dropPrefix(type.name, Config.dataClassPrefix));
9029
9204
  }
9030
9205
  else {
9031
- importer.withPeerImport(type);
9206
+ importer.withPeerImport(result);
9032
9207
  }
9033
9208
  }
9034
9209
  }
@@ -9066,6 +9241,10 @@ class _LibraryTypeConvertor extends TopLevelTypeConvertor {
9066
9241
  }
9067
9242
  }
9068
9243
  class LibraryTypeConvertor extends _LibraryTypeConvertor {
9244
+ constructor(typechecker, fullQualified = false) {
9245
+ super(typechecker);
9246
+ this.fullQualified = fullQualified;
9247
+ }
9069
9248
  convertTypeReference(type) {
9070
9249
  const node = this.typechecker.resolveReference(type);
9071
9250
  if (node && isEnum(node)) {
@@ -9074,7 +9253,10 @@ class LibraryTypeConvertor extends _LibraryTypeConvertor {
9074
9253
  return `Es2panda${node.name.slice(Config.dataClassPrefix.length)}`;
9075
9254
  }
9076
9255
  }
9077
- return makeEnoughQualifiedName(type, this.typechecker.resolveReference.bind(this.typechecker));
9256
+ const resolver = this.typechecker.resolveReference.bind(this.typechecker);
9257
+ return this.fullQualified
9258
+ ? makeFullyQualifiedName(type, resolver)
9259
+ : makeEnoughQualifiedName(type, resolver);
9078
9260
  }
9079
9261
  }
9080
9262
 
@@ -9128,7 +9310,7 @@ class AllPeersPrinter extends MultiFilePrinter {
9128
9310
  return this.printFile(iface.name, ['*'], (printer, writer) => printer.printInterface(iface, writer));
9129
9311
  }
9130
9312
  printFile(name, exports, cb) {
9131
- const importer = new Importer(this.typechecker, '.', name);
9313
+ const importer = new Importer('.', name);
9132
9314
  const writer = this.makeWriter(importer);
9133
9315
  const printer = new PeerPrinter(this.config, this.typechecker, importer);
9134
9316
  cb(printer, writer);
@@ -9244,8 +9426,8 @@ class FactoryPrinter extends SingleFilePrinter {
9244
9426
  constructor(config, idl) {
9245
9427
  super(idl);
9246
9428
  this.config = config;
9247
- this.importer = new Importer(this.typechecker, `peers`);
9248
- this.converter = new LibraryTypeConvertor(this.typechecker);
9429
+ this.importer = new Importer(`peers`);
9430
+ this.converter = new LibraryTypeConvertor(this.typechecker, true /* fq names */);
9249
9431
  this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), {
9250
9432
  convert: (node) => convertAndImport(this.importer, this.converter, node, this.config)
9251
9433
  });
@@ -9530,7 +9712,7 @@ class DynamicEmitter {
9530
9712
  this.generatorVersion = `Unknown`;
9531
9713
  this.logDir = `./out/log-idl`;
9532
9714
  this.logCount = 0;
9533
- this.bridgesPrinter = new SingleFileEmitter((idl) => new BridgesPrinter(this.config, idl).print(), `libarkts/generated/native/bridges.cc`, `bridges.cc`, true);
9715
+ this.bridgesPrinter = new SingleFileEmitter((idl) => new BridgesPrinter(this.config, idl).print(), `libarkts/generated/native/bridges.cpp`, `bridges.cpp`, true);
9534
9716
  this.bindingsPrinter = new SingleFileEmitter((idl) => new BindingsPrinter(idl).print(), `libarkts/generated/Es2pandaNativeModule.ts`, `Es2pandaNativeModule.ts`, true);
9535
9717
  this.enumsPrinter = new SingleFileEmitter((idl) => new EnumsPrinter(idl).print(), `libarkts/generated/Es2pandaEnums.ts`, `Es2pandaEnums.ts`, true);
9536
9718
  this.indexPrinter = new SingleFileEmitter((idl) => new IndexPrinter(this.config, idl).print(), // overriden below
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlizer/arktscgen",
3
- "version": "2.1.10-arktscgen-6",
3
+ "version": "2.1.10-arktscgen-7",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "bin": "lib/index.js",
@@ -18,7 +18,7 @@
18
18
  "license": "Apache-2.0",
19
19
  "keywords": [],
20
20
  "dependencies": {
21
- "@idlizer/core": "2.1.10-arktscgen-6",
21
+ "@idlizer/core": "2.1.10-arktscgen-7",
22
22
  "@types/node": "^18.0.0",
23
23
  "commander": "^10.0.0",
24
24
  "typescript": "^4.9.5"
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
2
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -1,45 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { Program } from '../../../generated';
17
- import { traceGlobal } from '../../tracer';
18
-
19
- export function dumpProgramInfo(program: Program) {
20
- traceGlobal(() => `Program info:`);
21
- traceGlobal(() => `\tAbsoluteName: ${program.absoluteName}`);
22
- traceGlobal(() => `\tFileName: ${program.fileName}`);
23
- traceGlobal(() => `\tFileNameWithExtension: ${program.fileNameWithExtension}`);
24
- traceGlobal(() => `\tModuleName: ${program.moduleName}`);
25
- traceGlobal(() => `\tModulePrefix: ${program.modulePrefix}`);
26
- traceGlobal(() => `\tRelativeFilePath: ${program.relativeFilePath}`);
27
- traceGlobal(() => `\tResolvedFilePath: ${program.resolvedFilePath}`);
28
- traceGlobal(() => `\tSourceFileFolder: ${program.sourceFileFolder}`);
29
- traceGlobal(() => `\tSourceFilePath: ${program.sourceFilePath}`);
30
- }
31
-
32
- export function dumpProgramSrcFormatted(program: Program, recursive: boolean, withLines: boolean = true) {
33
- const lines = program.ast.dumpSrc();
34
- console.log(`// file: ${program.absoluteName}`);
35
- if (withLines) {
36
- console.log(
37
- lines
38
- .split('\n')
39
- .map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`)
40
- .join('\n')
41
- );
42
- } else {
43
- console.log(lines);
44
- }
45
- }