arkanalyzer 1.0.87 → 1.0.89

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 (143) hide show
  1. package/config/arkanalyzer.json +11 -0
  2. package/lib/Config.d.ts +27 -2
  3. package/lib/Config.d.ts.map +1 -1
  4. package/lib/Config.js +65 -2
  5. package/lib/Scene.d.ts +5 -2
  6. package/lib/Scene.d.ts.map +1 -1
  7. package/lib/Scene.js +34 -67
  8. package/lib/callgraph/pointerAnalysis/context/Context.d.ts.map +1 -1
  9. package/lib/callgraph/pointerAnalysis/context/Context.js +10 -12
  10. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +1 -1
  11. package/lib/cli/commands/cg.d.ts +27 -6
  12. package/lib/cli/commands/cg.d.ts.map +1 -1
  13. package/lib/cli/commands/cg.js +9 -6
  14. package/lib/core/base/Expr.js +3 -3
  15. package/lib/core/base/Position.d.ts +1 -1
  16. package/lib/core/base/Position.d.ts.map +1 -1
  17. package/lib/core/base/Position.js +2 -2
  18. package/lib/core/base/Type.d.ts.map +1 -1
  19. package/lib/core/base/Type.js +1 -2
  20. package/lib/core/common/Const.d.ts +1 -0
  21. package/lib/core/common/Const.d.ts.map +1 -1
  22. package/lib/core/common/Const.js +2 -1
  23. package/lib/core/common/IRInference.d.ts.map +1 -1
  24. package/lib/core/common/IRInference.js +1 -1
  25. package/lib/core/common/IRUtils.d.ts.map +1 -1
  26. package/lib/core/common/IRUtils.js +3 -33
  27. package/lib/core/common/ModelUtils.d.ts +6 -0
  28. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  29. package/lib/core/common/ModelUtils.js +30 -0
  30. package/lib/core/common/SdkUtils.js +1 -1
  31. package/lib/core/common/TypeInference.d.ts +13 -0
  32. package/lib/core/common/TypeInference.d.ts.map +1 -1
  33. package/lib/core/common/TypeInference.js +44 -0
  34. package/lib/core/common/ValueUtil.d.ts +1 -1
  35. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  36. package/lib/core/common/ValueUtil.js +28 -12
  37. package/lib/core/graph/Cfg.d.ts.map +1 -1
  38. package/lib/core/graph/Cfg.js +0 -2
  39. package/lib/core/graph/DominanceFinder.d.ts +3 -0
  40. package/lib/core/graph/DominanceFinder.d.ts.map +1 -1
  41. package/lib/core/graph/DominanceFinder.js +42 -36
  42. package/lib/core/graph/DominanceTree.d.ts.map +1 -1
  43. package/lib/core/graph/DominanceTree.js +0 -4
  44. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  45. package/lib/core/inference/ValueInference.js +3 -2
  46. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  47. package/lib/core/inference/abc/AbcInference.js +2 -1
  48. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  49. package/lib/core/inference/arkts/ArkTsInference.js +3 -2
  50. package/lib/core/model/ArkClass.d.ts +3 -0
  51. package/lib/core/model/ArkClass.d.ts.map +1 -1
  52. package/lib/core/model/ArkClass.js +32 -6
  53. package/lib/core/model/ArkFile.d.ts.map +1 -1
  54. package/lib/core/model/ArkFile.js +0 -1
  55. package/lib/core/model/ArkMetadata.d.ts +32 -1
  56. package/lib/core/model/ArkMetadata.d.ts.map +1 -1
  57. package/lib/core/model/ArkMetadata.js +28 -3
  58. package/lib/core/model/builder/ArkMetadataBuilder.d.ts +21 -0
  59. package/lib/core/model/builder/ArkMetadataBuilder.d.ts.map +1 -0
  60. package/lib/core/model/builder/ArkMetadataBuilder.js +160 -0
  61. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  62. package/lib/core/model/builder/ArkMethodBuilder.js +32 -26
  63. package/lib/frontend/FrontendBuilder.d.ts +26 -0
  64. package/lib/frontend/FrontendBuilder.d.ts.map +1 -0
  65. package/lib/frontend/FrontendBuilder.js +108 -0
  66. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +16 -0
  67. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -0
  68. package/lib/frontend/arktsFrontend/ArktsFrontend.js +52 -0
  69. package/lib/frontend/cppFrontend/CppFrontend.d.ts +13 -0
  70. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -0
  71. package/lib/frontend/cppFrontend/CppFrontend.js +85 -0
  72. package/lib/frontend/cppFrontend/ast/index.d.ts +5 -0
  73. package/lib/frontend/cppFrontend/ast/index.d.ts.map +1 -0
  74. package/lib/frontend/cppFrontend/ast/index.js +31 -0
  75. package/lib/frontend/cppFrontend/ast/ts/ArkCxxAstNode.d.ts.map +1 -0
  76. package/lib/frontend/cppFrontend/ast/ts/astParser.d.ts +25 -0
  77. package/lib/frontend/cppFrontend/ast/ts/astParser.d.ts.map +1 -0
  78. package/lib/frontend/cppFrontend/ast/ts/astParser.js +280 -0
  79. package/lib/frontend/cppFrontend/ast/ts/astUtils.d.ts +18 -0
  80. package/lib/frontend/cppFrontend/ast/ts/astUtils.d.ts.map +1 -0
  81. package/lib/frontend/cppFrontend/ast/ts/astUtils.js +158 -0
  82. package/lib/frontend/cppFrontend/ast/{const.d.ts → ts/const.d.ts} +0 -13
  83. package/lib/frontend/cppFrontend/ast/ts/const.d.ts.map +1 -0
  84. package/lib/frontend/cppFrontend/ast/ts/const.js +58 -0
  85. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.d.ts +8 -0
  86. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.d.ts.map +1 -0
  87. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.js +90 -0
  88. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.d.ts +8 -0
  89. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.d.ts.map +1 -0
  90. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.js +180 -0
  91. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts +1 -1
  92. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
  93. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +55 -55
  94. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
  95. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
  96. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +151 -151
  97. package/lib/frontend/cppFrontend/common/IRInference.js +2 -2
  98. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -1
  99. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
  100. package/lib/frontend/cppFrontend/common/IRUtils.js +2 -2
  101. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts +1 -1
  102. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
  103. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +74 -74
  104. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts +1 -1
  105. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
  106. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +3 -3
  107. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts +1 -1
  108. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  109. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +1 -1
  110. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  111. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +16 -17
  112. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts +1 -1
  113. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts.map +1 -1
  114. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts +1 -1
  115. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  116. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +2 -2
  117. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +1 -1
  118. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  119. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +2 -2
  120. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -1
  121. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
  122. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts +1 -1
  123. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
  124. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +3 -3
  125. package/lib/index.d.ts +5 -2
  126. package/lib/index.d.ts.map +1 -1
  127. package/lib/index.js +14 -6
  128. package/lib/pass/Dispatcher.d.ts.map +1 -1
  129. package/lib/pass/Dispatcher.js +0 -4
  130. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  131. package/lib/save/source/SourceStmt.js +3 -1
  132. package/lib/utils/FileUtils.d.ts +1 -0
  133. package/lib/utils/FileUtils.d.ts.map +1 -1
  134. package/lib/utils/FileUtils.js +11 -3
  135. package/package.json +9 -4
  136. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts.map +0 -1
  137. package/lib/frontend/cppFrontend/ast/astUtils.d.ts +0 -51
  138. package/lib/frontend/cppFrontend/ast/astUtils.d.ts.map +0 -1
  139. package/lib/frontend/cppFrontend/ast/astUtils.js +0 -470
  140. package/lib/frontend/cppFrontend/ast/const.d.ts.map +0 -1
  141. package/lib/frontend/cppFrontend/ast/const.js +0 -134
  142. /package/lib/frontend/cppFrontend/ast/{ArkCxxAstNode.d.ts → ts/ArkCxxAstNode.d.ts} +0 -0
  143. /package/lib/frontend/cppFrontend/ast/{ArkCxxAstNode.js → ts/ArkCxxAstNode.js} +0 -0
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ArkMetadataBuilder = void 0;
21
+ const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
22
+ const Position_1 = require("../../base/Position");
23
+ const ArkMetadata_1 = require("../ArkMetadata");
24
+ class ArkMetadataBuilder {
25
+ static setComments(metadata, node, sourceFile, options) {
26
+ const leadingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, true);
27
+ if (leadingCommentsMetadata.getComments().length > 0) {
28
+ metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS, leadingCommentsMetadata);
29
+ }
30
+ const trailingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, false);
31
+ if (trailingCommentsMetadata.getComments().length > 0) {
32
+ metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.TRAILING_COMMENTS, trailingCommentsMetadata);
33
+ }
34
+ const jsDocMetadatas = this.getJSDocMetadata(node, sourceFile, options);
35
+ if (jsDocMetadatas.length > 0) {
36
+ metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.JSDOC, jsDocMetadatas);
37
+ }
38
+ }
39
+ static getCommentsMetadata(node, sourceFile, options, isLeading) {
40
+ const comments = [];
41
+ if ((isLeading && !options.enableLeadingComments) || (!isLeading && !options.enableTrailingComments)) {
42
+ return new ArkMetadata_1.CommentsMetadata(comments);
43
+ }
44
+ const commentRanges = (isLeading ? ohos_typescript_1.default.getLeadingCommentRanges(sourceFile.text, node.pos) : ohos_typescript_1.default.getTrailingCommentRanges(sourceFile.text, node.end)) || [];
45
+ const getPosition = (pos, end) => {
46
+ const start = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, pos);
47
+ const endPos = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, end);
48
+ return new Position_1.FullPosition(start.line + 1, start.character + 1, endPos.line + 1, endPos.character + 1);
49
+ };
50
+ for (const range of commentRanges) {
51
+ comments.push({
52
+ content: sourceFile.text.substring(range.pos, range.end).replace(/\r\n/g, '\n'),
53
+ position: getPosition(range.pos, range.end),
54
+ });
55
+ }
56
+ return new ArkMetadata_1.CommentsMetadata(comments);
57
+ }
58
+ static getJSDocMetadata(node, sourceFile, options) {
59
+ if (!options.enableJSDoc) {
60
+ return [];
61
+ }
62
+ const commentRanges = ohos_typescript_1.default.getLeadingCommentRanges(sourceFile.text, node.pos) || [];
63
+ const jsDocContents = commentRanges
64
+ .map(range => sourceFile.text.substring(range.pos, range.end).replace(/\r\n/g, '\n'))
65
+ .filter(content => content.startsWith('/**'));
66
+ if (jsDocContents.length === 0) {
67
+ return [];
68
+ }
69
+ const jsDocMetadatas = [];
70
+ for (const jsDocContent of jsDocContents) {
71
+ jsDocMetadatas.push(this.parseJSDocContent(jsDocContent));
72
+ }
73
+ return jsDocMetadatas;
74
+ }
75
+ static parseJSDocContent(content) {
76
+ const normalizedLines = content
77
+ .split('\n')
78
+ .map(line => line.replace(/^\s*\/\*\*?|\*\/\s*$|^\s*\*\s?(?!\/)/g, '').trim());
79
+ const descriptionLines = [];
80
+ const params = [];
81
+ const tags = [];
82
+ const returns = [];
83
+ const throws = [];
84
+ for (const line of normalizedLines) {
85
+ this.parseJSDocLine(line, descriptionLines, params, returns, throws, tags);
86
+ }
87
+ const description = descriptionLines.join('\n').trim();
88
+ return new ArkMetadata_1.JSDocMetadata(description, params, tags, returns, throws);
89
+ }
90
+ static parseJSDocLine(line, descriptionLines, params, returns, throws, tags) {
91
+ if (!line) {
92
+ return;
93
+ }
94
+ if (!line.startsWith('@')) {
95
+ descriptionLines.push(line);
96
+ return;
97
+ }
98
+ if (this.tryParseParam(line, params)) {
99
+ return;
100
+ }
101
+ if (this.tryParseReturns(line, returns)) {
102
+ return;
103
+ }
104
+ if (this.tryParseThrows(line, throws)) {
105
+ return;
106
+ }
107
+ this.tryParseGenericTag(line, tags);
108
+ }
109
+ static tryParseParam(line, params) {
110
+ const match = line.match(ArkMetadataBuilder.PARAM_TAG_REGEX);
111
+ if (!match) {
112
+ return false;
113
+ }
114
+ params.push({
115
+ name: match[2],
116
+ type: match[1].trim(),
117
+ description: match[3].trim(),
118
+ });
119
+ return true;
120
+ }
121
+ static tryParseReturns(line, returns) {
122
+ var _a;
123
+ const match = line.match(ArkMetadataBuilder.RETURNS_TAG_REGEX);
124
+ if (!match) {
125
+ return false;
126
+ }
127
+ returns.push({
128
+ type: (_a = match[1]) === null || _a === void 0 ? void 0 : _a.trim(),
129
+ description: match[2].trim(),
130
+ });
131
+ return true;
132
+ }
133
+ static tryParseThrows(line, throws) {
134
+ var _a;
135
+ const match = line.match(ArkMetadataBuilder.THROWS_TAG_REGEX);
136
+ if (!match) {
137
+ return false;
138
+ }
139
+ throws.push({
140
+ type: (_a = match[1]) === null || _a === void 0 ? void 0 : _a.trim(),
141
+ description: match[2].trim(),
142
+ });
143
+ return true;
144
+ }
145
+ static tryParseGenericTag(line, tags) {
146
+ const match = line.match(ArkMetadataBuilder.GENERIC_TAG_REGEX);
147
+ if (!match) {
148
+ return;
149
+ }
150
+ tags.push({
151
+ name: match[1],
152
+ description: match[2].trim(),
153
+ });
154
+ }
155
+ }
156
+ exports.ArkMetadataBuilder = ArkMetadataBuilder;
157
+ ArkMetadataBuilder.PARAM_TAG_REGEX = /^@param\s+\{\s*([^}]+?)\s*\}\s+([^\s-]+)\s*(?:-\s*)?(.*)$/;
158
+ ArkMetadataBuilder.RETURNS_TAG_REGEX = /^@returns?\s*(?:\{\s*([^}]+?)\s*\})?\s*(.*)$/;
159
+ ArkMetadataBuilder.THROWS_TAG_REGEX = /^@throws\s*(?:\{\s*([^}]+?)\s*\})?\s*(.*)$/;
160
+ ArkMetadataBuilder.GENERIC_TAG_REGEX = /^@([^\s]+)\s*(.*)$/;
@@ -1 +1 @@
1
- {"version":3,"file":"ArkMethodBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkMethodBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgBjC,OAAO,EAAkE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvG,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAmBzC,MAAM,MAAM,cAAc,GACpB,EAAE,CAAC,mBAAmB,GACtB,EAAE,CAAC,iBAAiB,GACpB,EAAE,CAAC,sBAAsB,GACzB,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,mBAAmB,GACtB,EAAE,CAAC,kBAAkB,GACrB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,6BAA6B,GAChC,EAAE,CAAC,wBAAwB,GAC3B,EAAE,CAAC,gBAAgB,CAAC;AAE1B,wBAAgB,iCAAiC,CAAC,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,GAAG,IAAI,CAYxJ;AAED,wBAAgB,0BAA0B,CACtC,UAAU,EAAE,cAAc,EAC1B,cAAc,EAAE,QAAQ,EACxB,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,eAAe,CAAC,EAAE,SAAS,GAC5B,IAAI,CAwDN;AAiDD,wBAA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AAI,4BAA4B,EAAE;IAIlD,gBAAgB,CAAC,aAAa,EAAE,4BAA4B,EAAE,GAAG,IAAI;IAIrE,OAAO,IAAI,KAAK,EAAE;CAG5B;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CASzE;AAmBD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,GAAG,CAAC,QAAQ,CAAa,GAAG,OAAO,CAyDvG;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAuB5G;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,GAAG,IAAI,CA+BjE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAepE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAW3E;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,GAAG,IAAI,CA4BnG;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,SAAS,GAAG,IAAI,CA8CrE"}
@@ -161,7 +161,7 @@ function buildMethodName(node, declaringClass, sourceFile, declaringMethod) {
161
161
  name = TSConst_1.CONSTRUCTOR_NAME;
162
162
  }
163
163
  else if (ohos_typescript_1.default.isConstructSignatureDeclaration(node)) {
164
- name = 'construct-signature';
164
+ name = Const_1.CONSTRUCT_SIGNATURE_NAME;
165
165
  }
166
166
  else if (ohos_typescript_1.default.isCallSignatureDeclaration(node)) {
167
167
  name = Const_1.CALL_SIGNATURE_NAME;
@@ -247,8 +247,6 @@ class MethodParameter {
247
247
  this.name = '';
248
248
  this.optional = false;
249
249
  this.restFlag = false;
250
- this.objElements = [];
251
- this.arrayElements = [];
252
250
  }
253
251
  getName() {
254
252
  return this.name;
@@ -301,7 +299,8 @@ function needDefaultConstructorInClass(arkClass) {
301
299
  const originClassType = arkClass.getCategory();
302
300
  return (arkClass.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME) === null &&
303
301
  (originClassType === ArkClass_1.ClassCategory.CLASS || originClassType === ArkClass_1.ClassCategory.OBJECT) &&
304
- arkClass.getName() !== Const_1.DEFAULT_ARK_CLASS_NAME &&
302
+ !arkClass.isDefaultArkClass() &&
303
+ !arkClass.isLibraryClass() &&
305
304
  !arkClass.isDeclare());
306
305
  }
307
306
  exports.needDefaultConstructorInClass = needDefaultConstructorInClass;
@@ -323,10 +322,10 @@ function recursivelyCheckAndBuildSuperConstructor(arkClass, visited = new Set())
323
322
  }
324
323
  function buildDefaultConstructor(arkClass, visited = new Set()) {
325
324
  var _a;
325
+ recursivelyCheckAndBuildSuperConstructor(arkClass, visited);
326
326
  if (!needDefaultConstructorInClass(arkClass)) {
327
327
  return false;
328
328
  }
329
- recursivelyCheckAndBuildSuperConstructor(arkClass, visited);
330
329
  const defaultConstructor = new ArkMethod_1.ArkMethod();
331
330
  defaultConstructor.setDeclaringArkClass(arkClass);
332
331
  defaultConstructor.setCode('');
@@ -487,41 +486,48 @@ function updateMethodSignaturesAndLineCols(method, presentMethod) {
487
486
  }
488
487
  exports.updateMethodSignaturesAndLineCols = updateMethodSignaturesAndLineCols;
489
488
  function replaceSuper2Constructor(constructor) {
490
- var _a, _b;
489
+ var _a, _b, _c;
491
490
  if (constructor.getName() !== TSConst_1.CONSTRUCTOR_NAME) {
492
491
  return;
493
492
  }
493
+ const startingBlock = (_a = constructor.getBody()) === null || _a === void 0 ? void 0 : _a.getCfg().getStartingBlock();
494
+ if (startingBlock === undefined) {
495
+ return;
496
+ }
497
+ let superInvokeStmt = null;
498
+ for (const stmt of startingBlock.getStmts()) {
499
+ if (stmt instanceof Stmt_1.ArkInvokeStmt) {
500
+ let invokeExpr = stmt.getInvokeExpr();
501
+ const methodSignature = invokeExpr.getMethodSignature();
502
+ if (methodSignature.getMethodSubSignature().getMethodName() === TSConst_1.SUPER_NAME) {
503
+ superInvokeStmt = stmt;
504
+ break;
505
+ }
506
+ }
507
+ }
508
+ if (!superInvokeStmt) {
509
+ return;
510
+ }
511
+ // If there are superInvokeStmt, then there must have constructor of its super class.
494
512
  const superClass = constructor.getDeclaringArkClass().getSuperClass();
495
513
  if (superClass === null) {
514
+ logger.error(`Can not find super class for class ${constructor.getDeclaringArkClass().getSignature().toString()}`);
496
515
  return;
497
516
  }
498
- const superConstructor = superClass.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
517
+ const superConstructor = (_b = superClass.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME)) !== null && _b !== void 0 ? _b : superClass.getMethodWithName(Const_1.CONSTRUCT_SIGNATURE_NAME);
499
518
  if (superConstructor === null) {
500
519
  if (needDefaultConstructorInClass(superClass)) {
501
520
  logger.error(`Can not find constructor method for class ${superClass.getSignature().toString()}`);
502
521
  }
503
522
  return;
504
523
  }
505
- const startingBlock = (_a = constructor.getBody()) === null || _a === void 0 ? void 0 : _a.getCfg().getStartingBlock();
506
- if (startingBlock === undefined) {
524
+ let base = (_c = constructor.getBody()) === null || _c === void 0 ? void 0 : _c.getLocals().get(TSConst_1.THIS_NAME);
525
+ if (base === undefined) {
526
+ logger.error(`Can not find local this in constructor method ${constructor.getSignature().toString()}`);
507
527
  return;
508
528
  }
509
- for (const stmt of startingBlock.getStmts()) {
510
- if (stmt instanceof Stmt_1.ArkInvokeStmt) {
511
- let invokeExpr = stmt.getInvokeExpr();
512
- const methodSignature = invokeExpr.getMethodSignature();
513
- if (methodSignature.getMethodSubSignature().getMethodName() !== TSConst_1.SUPER_NAME) {
514
- continue;
515
- }
516
- let base = (_b = constructor.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().get(TSConst_1.THIS_NAME);
517
- if (base === undefined) {
518
- logger.error(`Can not find local this in constructor method ${constructor.getSignature().toString()}`);
519
- return;
520
- }
521
- const newInvokeExpr = new Expr_1.ArkInstanceInvokeExpr(base, superConstructor.getSignature(), invokeExpr.getArgs());
522
- stmt.replaceInvokeExpr(newInvokeExpr);
523
- return;
524
- }
525
- }
529
+ const newInvokeExpr = new Expr_1.ArkInstanceInvokeExpr(base, superConstructor.getSignature(), superInvokeStmt.getInvokeExpr().getArgs());
530
+ superInvokeStmt.replaceInvokeExpr(newInvokeExpr);
531
+ return;
526
532
  }
527
533
  exports.replaceSuper2Constructor = replaceSuper2Constructor;
@@ -0,0 +1,26 @@
1
+ import { ModuleScene, Scene } from '../Scene';
2
+ import { ArkFile } from '../core/model/ArkFile';
3
+ export interface FrontendParseFailure {
4
+ filePath: string;
5
+ reason: unknown;
6
+ }
7
+ export interface FrontendParseResult {
8
+ arkFiles: ArkFile[];
9
+ failedFiles: FrontendParseFailure[];
10
+ }
11
+ /**
12
+ * Dispatches language front-ends and exposes a single build entry for {@link Scene} so the scene no longer
13
+ * branches on {@link Language} to pick {@link import('../core/model/builder/ArkFileBuilder').buildArkFileFromFile}
14
+ * vs the C++ builder.
15
+ */
16
+ export declare class FrontendBuilder {
17
+ private static partitionFilePaths;
18
+ private static collectFailedFilePaths;
19
+ static buildFilesIntoArkFiles(scene: Scene, filePaths: string[]): void;
20
+ static buildModuleFilesIntoArkFiles(moduleScene: ModuleScene, filePaths: string[]): void;
21
+ /**
22
+ * Builds a single project file into a pre-allocated {@link ArkFile} (the former `if (CXX) … else …` in `Scene`).
23
+ */
24
+ static buildProjectFileIntoArkFile(scene: Scene, filePath: string, arkFile: ArkFile): void;
25
+ }
26
+ //# sourceMappingURL=FrontendBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrontendBuilder.d.ts","sourceRoot":"","sources":["../../src/frontend/FrontendBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMhD,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAED;;;;GAIG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAajC,OAAO,CAAC,MAAM,CAAC,sBAAsB;WAOvB,sBAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;WAW/D,4BAA4B,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAe/F;;OAEG;WACW,2BAA2B,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;CAOpG"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.FrontendBuilder = void 0;
41
+ const ArkFile_1 = require("../core/model/ArkFile");
42
+ const ArktsFrontend_1 = require("./arktsFrontend/ArktsFrontend");
43
+ const CppFrontend_1 = require("./cppFrontend/CppFrontend");
44
+ const FileUtils_1 = require("../utils/FileUtils");
45
+ const logger_1 = __importStar(require("../utils/logger"));
46
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'FrontendBuilder');
47
+ /**
48
+ * Dispatches language front-ends and exposes a single build entry for {@link Scene} so the scene no longer
49
+ * branches on {@link Language} to pick {@link import('../core/model/builder/ArkFileBuilder').buildArkFileFromFile}
50
+ * vs the C++ builder.
51
+ */
52
+ class FrontendBuilder {
53
+ static partitionFilePaths(scene, filePaths) {
54
+ const cppFiles = [];
55
+ const arktsFiles = [];
56
+ for (const filePath of filePaths) {
57
+ if (FileUtils_1.FileUtils.getFileLanguage(filePath, scene.getFileLanguages()) === ArkFile_1.Language.CXX) {
58
+ cppFiles.push(filePath);
59
+ }
60
+ else {
61
+ arktsFiles.push(filePath);
62
+ }
63
+ }
64
+ return { cppFiles, arktsFiles };
65
+ }
66
+ static collectFailedFilePaths(scene, failedFiles) {
67
+ for (const failed of failedFiles) {
68
+ logger.error('Error parsing file:', failed.filePath, failed.reason);
69
+ scene.addUnhandledFilePath(failed.filePath);
70
+ }
71
+ }
72
+ static buildFilesIntoArkFiles(scene, filePaths) {
73
+ const { cppFiles, arktsFiles } = this.partitionFilePaths(scene, filePaths);
74
+ const arktsFrontend = new ArktsFrontend_1.ArktsFrontend();
75
+ const cppFrontend = new CppFrontend_1.CppFrontend();
76
+ const arktsResult = arktsFrontend.buildProjectFiles(scene, arktsFiles);
77
+ const cppResult = cppFrontend.buildProjectFiles(scene, cppFiles);
78
+ arktsResult.arkFiles.forEach(file => scene.setFile(file));
79
+ cppResult.arkFiles.forEach(file => scene.setFile(file));
80
+ this.collectFailedFilePaths(scene, [...arktsResult.failedFiles, ...cppResult.failedFiles]);
81
+ }
82
+ static buildModuleFilesIntoArkFiles(moduleScene, filePaths) {
83
+ const scene = moduleScene.getProjectScene();
84
+ const { cppFiles, arktsFiles } = this.partitionFilePaths(scene, filePaths);
85
+ const arktsFrontend = new ArktsFrontend_1.ArktsFrontend();
86
+ const cppFrontend = new CppFrontend_1.CppFrontend();
87
+ const arktsResult = arktsFrontend.buildProjectFiles(scene, arktsFiles);
88
+ const cppResult = cppFrontend.buildProjectFiles(scene, cppFiles);
89
+ [...arktsResult.arkFiles, ...cppResult.arkFiles].forEach(file => {
90
+ file.setModuleScene(moduleScene);
91
+ moduleScene.addArkFile(file);
92
+ scene.setFile(file);
93
+ });
94
+ this.collectFailedFilePaths(scene, [...arktsResult.failedFiles, ...cppResult.failedFiles]);
95
+ }
96
+ /**
97
+ * Builds a single project file into a pre-allocated {@link ArkFile} (the former `if (CXX) … else …` in `Scene`).
98
+ */
99
+ static buildProjectFileIntoArkFile(scene, filePath, arkFile) {
100
+ if (arkFile.getLanguage() === ArkFile_1.Language.CXX) {
101
+ new CppFrontend_1.CppFrontend().buildProjectFile(scene, filePath, arkFile);
102
+ }
103
+ else {
104
+ new ArktsFrontend_1.ArktsFrontend().buildProjectFile(scene, filePath, arkFile);
105
+ }
106
+ }
107
+ }
108
+ exports.FrontendBuilder = FrontendBuilder;
@@ -0,0 +1,16 @@
1
+ import { Scene } from '../../Scene';
2
+ import { ArkFile } from '../../core/model/ArkFile';
3
+ import { FrontendParseResult } from '../FrontendBuilder';
4
+ /**
5
+ * ArkTS/TS/JS: builds {@link ArkFile}s using the core TS/ArkTS pipeline (see {@link buildArkFileFromFile}).
6
+ */
7
+ export declare class ArktsFrontend {
8
+ /** Fills a project {@link ArkFile} from a source file; delegates to {@link buildArkFileFromFile}. */
9
+ buildProjectFile(scene: Scene, filePath: string, arkFile: ArkFile): void;
10
+ /**
11
+ * Non-project SDK file load (e.g. OpenHarmony SDK sources); mirrors the former {@link Scene} path for SDK files.
12
+ */
13
+ static buildArkFileFromSdkPath(absoluteFilePath: string, sdkPath: string, arkFile: ArkFile, sdkName: string): void;
14
+ buildProjectFiles(scene: Scene, filePaths: string[]): FrontendParseResult;
15
+ }
16
+ //# sourceMappingURL=ArktsFrontend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArktsFrontend.d.ts","sourceRoot":"","sources":["../../../src/frontend/arktsFrontend/ArktsFrontend.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAwB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI/E;;GAEG;AACH,qBAAa,aAAa;IAEtB,qGAAqG;IAC9F,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI/E;;OAEG;WACW,uBAAuB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlH,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,mBAAmB;CAenF"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ArktsFrontend = void 0;
18
+ const ArkFile_1 = require("../../core/model/ArkFile");
19
+ const ArkFileBuilder_1 = require("../../core/model/builder/ArkFileBuilder");
20
+ const FileUtils_1 = require("../../utils/FileUtils");
21
+ /**
22
+ * ArkTS/TS/JS: builds {@link ArkFile}s using the core TS/ArkTS pipeline (see {@link buildArkFileFromFile}).
23
+ */
24
+ class ArktsFrontend {
25
+ /** Fills a project {@link ArkFile} from a source file; delegates to {@link buildArkFileFromFile}. */
26
+ buildProjectFile(scene, filePath, arkFile) {
27
+ (0, ArkFileBuilder_1.buildArkFileFromFile)(filePath, scene.getRealProjectDir(), arkFile, scene.getProjectName());
28
+ }
29
+ /**
30
+ * Non-project SDK file load (e.g. OpenHarmony SDK sources); mirrors the former {@link Scene} path for SDK files.
31
+ */
32
+ static buildArkFileFromSdkPath(absoluteFilePath, sdkPath, arkFile, sdkName) {
33
+ (0, ArkFileBuilder_1.buildArkFileFromFile)(absoluteFilePath, sdkPath, arkFile, sdkName);
34
+ }
35
+ buildProjectFiles(scene, filePaths) {
36
+ const arkFiles = [];
37
+ const failedFiles = [];
38
+ for (const filePath of filePaths) {
39
+ try {
40
+ const arkFile = new ArkFile_1.ArkFile(FileUtils_1.FileUtils.getFileLanguage(filePath, scene.getFileLanguages()));
41
+ arkFile.setScene(scene);
42
+ this.buildProjectFile(scene, filePath, arkFile);
43
+ arkFiles.push(arkFile);
44
+ }
45
+ catch (error) {
46
+ failedFiles.push({ filePath, reason: error });
47
+ }
48
+ }
49
+ return { arkFiles, failedFiles };
50
+ }
51
+ }
52
+ exports.ArktsFrontend = ArktsFrontend;
@@ -0,0 +1,13 @@
1
+ import { Scene } from '../../Scene';
2
+ import { ArkFile } from '../../core/model/ArkFile';
3
+ import { FrontendParseResult } from '../FrontendBuilder';
4
+ /**
5
+ * C++ language frontend. Matches the former {@link Scene} branches for {@link Language#CXX}.
6
+ */
7
+ export declare class CppFrontend {
8
+ buildProjectFile(scene: Scene, filePath: string, arkFile: ArkFile): void;
9
+ buildProjectFiles(scene: Scene, filePaths: string[]): FrontendParseResult;
10
+ /** Returns true if astJsonDumper is available; otherwise logs a warning. */
11
+ private requireAstJsonDumper;
12
+ }
13
+ //# sourceMappingURL=CppFrontend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CppFrontend.d.ts","sourceRoot":"","sources":["../../../src/frontend/cppFrontend/CppFrontend.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAInD,OAAO,EAAwB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI/E;;GAEG;AACH,qBAAa,WAAW;IAEb,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAOxE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,mBAAmB;IAmBhF,4EAA4E;IAC5E,OAAO,CAAC,oBAAoB;CAO/B"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.CppFrontend = void 0;
41
+ const ArkFile_1 = require("../../core/model/ArkFile");
42
+ const ArkFile_2 = require("../../core/model/ArkFile");
43
+ const logger_1 = __importStar(require("../../utils/logger"));
44
+ const astUtils_1 = require("./ast/ts/astUtils");
45
+ const ArkFileBuilder_1 = require("./model/builder/ArkFileBuilder");
46
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'CppFrontend');
47
+ /**
48
+ * C++ language frontend. Matches the former {@link Scene} branches for {@link Language#CXX}.
49
+ */
50
+ class CppFrontend {
51
+ buildProjectFile(scene, filePath, arkFile) {
52
+ if (!this.requireAstJsonDumper()) {
53
+ return;
54
+ }
55
+ (0, ArkFileBuilder_1.buildArkFileFromFile)(filePath, scene.getRealProjectDir(), arkFile, scene.getProjectName(), scene.getIncludeDirs());
56
+ }
57
+ buildProjectFiles(scene, filePaths) {
58
+ if (!this.requireAstJsonDumper()) {
59
+ return { arkFiles: [], failedFiles: [] };
60
+ }
61
+ const arkFiles = [];
62
+ const failedFiles = [];
63
+ for (const filePath of filePaths) {
64
+ try {
65
+ const arkFile = new ArkFile_2.ArkFile(ArkFile_1.Language.CXX);
66
+ arkFile.setScene(scene);
67
+ (0, ArkFileBuilder_1.buildArkFileFromFile)(filePath, scene.getRealProjectDir(), arkFile, scene.getProjectName(), scene.getIncludeDirs());
68
+ arkFiles.push(arkFile);
69
+ }
70
+ catch (error) {
71
+ failedFiles.push({ filePath, reason: error });
72
+ }
73
+ }
74
+ return { arkFiles, failedFiles };
75
+ }
76
+ /** Returns true if astJsonDumper is available; otherwise logs a warning. */
77
+ requireAstJsonDumper() {
78
+ if ((0, astUtils_1.isAstJsonDumperAvailable)()) {
79
+ return true;
80
+ }
81
+ logger.warn('astJsonDumper.node is not available; skip C++ frontend build.');
82
+ return false;
83
+ }
84
+ }
85
+ exports.CppFrontend = CppFrontend;
@@ -0,0 +1,5 @@
1
+ export { getCxxImplementationFileExtensionSet, getCxxImplementationFileExtensions, getCxxHeaderFileExtensionSet, getCxxSourceFileExtensionSet, getCxxSourceFileExtensions, } from './ts/const';
2
+ export { astKind, CxxAstNode, CxxIncludeInfo, CxxTranslationUnit, defaultArg, getNodeStartLineAndCol, } from './ts/ArkCxxAstNode';
3
+ export { findCompileCommands, isAstJsonDumperAvailable } from './ts/astUtils';
4
+ export { AstParser } from './ts/astParser';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/ast/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,oCAAoC,EACpC,kCAAkC,EAClC,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,GAC7B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACH,OAAO,EACP,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,sBAAsB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AstParser = exports.isAstJsonDumperAvailable = exports.findCompileCommands = exports.getNodeStartLineAndCol = exports.astKind = exports.getCxxSourceFileExtensions = exports.getCxxSourceFileExtensionSet = exports.getCxxHeaderFileExtensionSet = exports.getCxxImplementationFileExtensions = exports.getCxxImplementationFileExtensionSet = void 0;
18
+ var const_1 = require("./ts/const");
19
+ Object.defineProperty(exports, "getCxxImplementationFileExtensionSet", { enumerable: true, get: function () { return const_1.getCxxImplementationFileExtensionSet; } });
20
+ Object.defineProperty(exports, "getCxxImplementationFileExtensions", { enumerable: true, get: function () { return const_1.getCxxImplementationFileExtensions; } });
21
+ Object.defineProperty(exports, "getCxxHeaderFileExtensionSet", { enumerable: true, get: function () { return const_1.getCxxHeaderFileExtensionSet; } });
22
+ Object.defineProperty(exports, "getCxxSourceFileExtensionSet", { enumerable: true, get: function () { return const_1.getCxxSourceFileExtensionSet; } });
23
+ Object.defineProperty(exports, "getCxxSourceFileExtensions", { enumerable: true, get: function () { return const_1.getCxxSourceFileExtensions; } });
24
+ var ArkCxxAstNode_1 = require("./ts/ArkCxxAstNode");
25
+ Object.defineProperty(exports, "astKind", { enumerable: true, get: function () { return ArkCxxAstNode_1.astKind; } });
26
+ Object.defineProperty(exports, "getNodeStartLineAndCol", { enumerable: true, get: function () { return ArkCxxAstNode_1.getNodeStartLineAndCol; } });
27
+ var astUtils_1 = require("./ts/astUtils");
28
+ Object.defineProperty(exports, "findCompileCommands", { enumerable: true, get: function () { return astUtils_1.findCompileCommands; } });
29
+ Object.defineProperty(exports, "isAstJsonDumperAvailable", { enumerable: true, get: function () { return astUtils_1.isAstJsonDumperAvailable; } });
30
+ var astParser_1 = require("./ts/astParser");
31
+ Object.defineProperty(exports, "AstParser", { enumerable: true, get: function () { return astParser_1.AstParser; } });