arkanalyzer 1.0.94 → 2.0.0-beta1
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.
- package/lib/Config.d.ts +7 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/Scene.d.ts +134 -170
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +412 -976
- package/lib/callgraph/algorithm/AbstractAnalysis.js +3 -2
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +1 -1
- package/lib/callgraph/model/CallGraph.js +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +1 -3
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.js +17 -7
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +4 -14
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +2 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
- package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +0 -1
- package/lib/cli/commands/cg.d.ts +1 -0
- package/lib/cli/commands/cg.d.ts.map +1 -1
- package/lib/cli/commands/cg.js +22 -18
- package/lib/cli/commands/ir.d.ts +1 -0
- package/lib/cli/commands/ir.d.ts.map +1 -1
- package/lib/cli/commands/ir.js +5 -2
- package/lib/core/base/Constant.d.ts +5 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +12 -9
- package/lib/core/base/Expr.d.ts +36 -20
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +206 -94
- package/lib/core/base/Local.d.ts +10 -20
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +25 -28
- package/lib/core/base/Position.d.ts +6 -0
- package/lib/core/base/Position.d.ts.map +1 -1
- package/lib/core/base/Position.js +37 -11
- package/lib/core/base/Ref.d.ts +45 -33
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +225 -51
- package/lib/core/base/Stmt.d.ts +19 -9
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +135 -52
- package/lib/core/base/Type.d.ts +67 -4
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +391 -20
- package/lib/core/base/TypeExpr.d.ts +6 -4
- package/lib/core/base/TypeExpr.d.ts.map +1 -1
- package/lib/core/base/TypeExpr.js +34 -10
- package/lib/core/base/Value.d.ts +20 -2
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/base/Value.js +12 -0
- package/lib/core/common/ArkIRTransformer.d.ts +18 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +94 -75
- package/lib/core/common/ArkValueTransformer.d.ts +21 -3
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +455 -265
- package/lib/core/common/Builtin.d.ts +48 -24
- package/lib/core/common/Builtin.d.ts.map +1 -1
- package/lib/core/common/Builtin.js +90 -52
- package/lib/core/common/CanonicalizerValidator.d.ts +308 -0
- package/lib/core/common/CanonicalizerValidator.d.ts.map +1 -0
- package/lib/core/common/CanonicalizerValidator.js +888 -0
- package/lib/core/common/Const.d.ts +3 -3
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +3 -3
- package/lib/core/common/DummyMainCreater.d.ts +2 -21
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +8 -105
- package/lib/core/common/IRInference.d.ts +55 -3
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +407 -126
- package/lib/core/common/IRUtils.d.ts +1 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +44 -13
- package/lib/core/common/ModelUtils.d.ts +44 -20
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +378 -208
- package/lib/core/common/SdkUtils.d.ts +35 -5
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +181 -53
- package/lib/core/common/SignatureCanonicalizer.d.ts +95 -0
- package/lib/core/common/SignatureCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/SignatureCanonicalizer.js +116 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.d.ts +176 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.d.ts.map +1 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.js +343 -0
- package/lib/core/common/SignatureModelCanonicalizer.d.ts +69 -0
- package/lib/core/common/SignatureModelCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/SignatureModelCanonicalizer.js +109 -0
- package/lib/core/common/StmtUseReplacer.d.ts +1 -0
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtUseReplacer.js +9 -0
- package/lib/core/common/StringUtils.d.ts +12 -1
- package/lib/core/common/StringUtils.d.ts.map +1 -1
- package/lib/core/common/StringUtils.js +36 -17
- package/lib/core/common/TempSignatureCanonicalizer.d.ts +82 -0
- package/lib/core/common/TempSignatureCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/TempSignatureCanonicalizer.js +177 -0
- package/lib/core/common/TypeInference.d.ts +24 -6
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +243 -117
- package/lib/core/common/ValueUtil.d.ts +2 -1
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +4 -1
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +21 -6
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +46 -33
- package/lib/core/graph/builder/IfBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/IfBuilder.js +6 -2
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +6 -2
- package/lib/core/inference/ModelInference.d.ts +24 -4
- package/lib/core/inference/ModelInference.d.ts.map +1 -1
- package/lib/core/inference/ModelInference.js +273 -79
- package/lib/core/inference/ValueInference.d.ts +3 -2
- package/lib/core/inference/ValueInference.d.ts.map +1 -1
- package/lib/core/inference/ValueInference.js +90 -40
- package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
- package/lib/core/inference/abc/AbcInference.js +28 -15
- package/lib/core/inference/arkts/ArkTsInference.d.ts +9 -3
- package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
- package/lib/core/inference/arkts/ArkTsInference.js +54 -16
- package/lib/core/model/ArkClass.d.ts +192 -18
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +852 -122
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +1 -2
- package/lib/core/model/ArkField.d.ts +34 -2
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +89 -14
- package/lib/core/model/ArkFile.d.ts +72 -12
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +275 -65
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +1 -2
- package/lib/core/model/ArkMethod.d.ts +101 -15
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +252 -39
- package/lib/core/model/ArkModule.d.ts +1 -1
- package/lib/core/model/ArkModule.js +1 -1
- package/lib/core/model/ArkNamespace.d.ts +80 -10
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +309 -76
- package/lib/core/model/ArkSignature.d.ts +242 -18
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +725 -95
- package/lib/core/model/builder/ArkClassBuilder.d.ts +6 -3
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +116 -71
- package/lib/core/model/builder/ArkExportBuilder.d.ts +1 -1
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.d.ts +0 -2
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +9 -43
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFileBuilder.js +32 -33
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +10 -3
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +40 -26
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +3 -2
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +45 -77
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkSignatureBuilder.js +26 -3
- package/lib/core/model/builder/BodyBuilder.d.ts +1 -0
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/BodyBuilder.js +37 -11
- package/lib/core/model/builder/builderUtils.d.ts +11 -1
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +124 -90
- package/lib/frontend/FrontendBuilder.d.ts +10 -6
- package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
- package/lib/frontend/FrontendBuilder.js +19 -45
- package/lib/frontend/ModuleScene.d.ts +43 -0
- package/lib/frontend/ModuleScene.d.ts.map +1 -0
- package/lib/frontend/ModuleScene.js +143 -0
- package/lib/frontend/SceneBuildStage.d.ts +15 -0
- package/lib/frontend/SceneBuildStage.d.ts.map +1 -0
- package/lib/frontend/SceneBuildStage.js +32 -0
- package/lib/frontend/SceneBuilder.d.ts +153 -0
- package/lib/frontend/SceneBuilder.d.ts.map +1 -0
- package/lib/frontend/SceneBuilder.js +859 -0
- package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +0 -2
- package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
- package/lib/frontend/arktsFrontend/ArktsFrontend.js +0 -18
- package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts +17 -0
- package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts.map +1 -0
- package/lib/frontend/arktsFrontend/FileBodyRemount.js +187 -0
- package/lib/frontend/common/ModuleBuilder.d.ts +4 -2
- package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -1
- package/lib/frontend/common/ModuleBuilder.js +19 -9
- package/lib/frontend/cppFrontend/CppFrontend.d.ts +0 -6
- package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/CppFrontend.js +0 -56
- package/lib/frontend/cppFrontend/base/Type.d.ts +7 -0
- package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/base/Type.js +29 -0
- package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +56 -56
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +124 -113
- package/lib/frontend/cppFrontend/common/Builtin.d.ts +29 -19
- package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/Builtin.js +56 -35
- package/lib/frontend/cppFrontend/common/IRInference.d.ts +7 -2
- package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/IRInference.js +61 -28
- package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -0
- package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/IRUtils.js +22 -10
- package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +19 -0
- package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ModelUtils.js +84 -3
- package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/TypeInference.js +44 -54
- package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +2 -1
- package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +1 -1
- package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/inference/CxxValueInference.js +41 -5
- package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +18 -28
- package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +2 -3
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +2 -2
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +31 -24
- package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +10 -16
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +0 -2
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +19 -37
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -0
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +30 -3
- package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/builderUtils.js +8 -4
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -2
- package/lib/save/json/JsonSerialization.js +2 -2
- package/lib/save/source/SourceStmt.js +1 -1
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +0 -9
- package/lib/statistics/StageStatistics.d.ts +195 -0
- package/lib/statistics/StageStatistics.d.ts.map +1 -0
- package/lib/statistics/StageStatistics.js +346 -0
- package/lib/statistics/StageStatisticsReporter.d.ts +58 -0
- package/lib/statistics/StageStatisticsReporter.d.ts.map +1 -0
- package/lib/statistics/StageStatisticsReporter.js +255 -0
- package/lib/utils/Canonicalizer.d.ts +9 -2
- package/lib/utils/Canonicalizer.d.ts.map +1 -1
- package/lib/utils/Canonicalizer.js +19 -2
- package/lib/utils/CxxSceneUtils.d.ts +7 -0
- package/lib/utils/CxxSceneUtils.d.ts.map +1 -1
- package/lib/utils/CxxSceneUtils.js +10 -1
- package/lib/utils/FileUtils.d.ts +0 -1
- package/lib/utils/FileUtils.d.ts.map +1 -1
- package/lib/utils/FileUtils.js +1 -9
- package/lib/utils/HashUtils.d.ts +9 -0
- package/lib/utils/HashUtils.d.ts.map +1 -0
- package/lib/utils/HashUtils.js +65 -0
- package/lib/utils/ModuleUtils.d.ts.map +1 -1
- package/lib/utils/ModuleUtils.js +24 -5
- package/lib/utils/VisitedSegment.d.ts +23 -0
- package/lib/utils/VisitedSegment.d.ts.map +1 -0
- package/lib/utils/VisitedSegment.js +64 -0
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +7 -7
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/getAllFiles.js +11 -8
- package/lib/utils/logger.d.ts +4 -0
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +16 -0
- package/lib/utils/parseArkSourceFile.d.ts +33 -0
- package/lib/utils/parseArkSourceFile.d.ts.map +1 -0
- package/lib/utils/parseArkSourceFile.js +131 -0
- package/package.json +1 -1
- package/lib/utils/DependenciesSort.d.ts +0 -3
- package/lib/utils/DependenciesSort.d.ts.map +0 -1
- package/lib/utils/DependenciesSort.js +0 -72
- package/lib/utils/crypto_utils.d.ts +0 -6
- package/lib/utils/crypto_utils.d.ts.map +0 -1
- package/lib/utils/crypto_utils.js +0 -57
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024-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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.fixupParentReferences = exports.parseArkSourceFile = void 0;
|
|
21
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
22
|
+
const DECLARATION_FILE_NAME = /\.d\.(ts|ets)$/;
|
|
23
|
+
/**
|
|
24
|
+
* Parse a source file, keeping the parser from building JSDoc nodes for declaration files.
|
|
25
|
+
*
|
|
26
|
+
* Documentation is read out of the raw text - `getLeadingCommentRanges` plus `substring` in
|
|
27
|
+
* ArkMetadataBuilder, and the scanner in every comment query - never out of `node.jsDoc`, so the JSDoc
|
|
28
|
+
* nodes the parser materialises are pure cost. They are 88% of the parse time of an SDK `.d.ts` file,
|
|
29
|
+
* which is where most of the build's declaration volume sits; project sources carry almost no JSDoc,
|
|
30
|
+
* so they are parsed unchanged.
|
|
31
|
+
*
|
|
32
|
+
* The parser decides from the comment opener alone, so the opener is blanked for the parse
|
|
33
|
+
* (`/**` becomes `/* `). That is one character per comment and it leaves the comment's extent and every
|
|
34
|
+
* offset in the file exactly where they were, so the only difference in the tree is the absent `jsDoc`
|
|
35
|
+
* array. The original text is put back on the SourceFile before anything reads it, which keeps
|
|
36
|
+
* text-derived comments, JSDoc metadata and line maps identical.
|
|
37
|
+
*/
|
|
38
|
+
function parseArkSourceFile(fileName, sourceText, setParentNodes, options) {
|
|
39
|
+
const parseText = DECLARATION_FILE_NAME.test(fileName) ? blankJsDocOpeners(sourceText) : sourceText;
|
|
40
|
+
const sourceFile = ohos_typescript_1.default.createSourceFile(fileName, parseText, ohos_typescript_1.default.ScriptTarget.Latest, false, undefined, options);
|
|
41
|
+
if (parseText !== sourceText) {
|
|
42
|
+
sourceFile.text = sourceText;
|
|
43
|
+
sourceFile.lineMap = undefined;
|
|
44
|
+
}
|
|
45
|
+
if (setParentNodes) {
|
|
46
|
+
fixupParentReferences(sourceFile);
|
|
47
|
+
}
|
|
48
|
+
return sourceFile;
|
|
49
|
+
}
|
|
50
|
+
exports.parseArkSourceFile = parseArkSourceFile;
|
|
51
|
+
const fixupStack = [];
|
|
52
|
+
const fixupChildren = [];
|
|
53
|
+
let fixupStackTop = 0;
|
|
54
|
+
let fixupChildCount = 0;
|
|
55
|
+
const collectFixupChild = (child) => {
|
|
56
|
+
fixupChildren[fixupChildCount++] = child;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Zero-allocation replacement for the parser's built-in parent fixup. The bundled walk
|
|
60
|
+
* (`setParentRecursive` -> `forEachChildRecursively` -> `gatherPossibleChildren`) allocates a
|
|
61
|
+
* children array plus a collector closure per node and grows two parallel work stacks with
|
|
62
|
+
* `unshift`/`push` - gigabytes of churn on a full build where every project file is parsed
|
|
63
|
+
* twice (signature round plus body remount). This explicit-stack walk reuses two module-level
|
|
64
|
+
* scratch arrays and one shared collector closure, and reproduces the same parent links,
|
|
65
|
+
* including the JSDoc nodes the bundled walk binds via `bindJSDoc`.
|
|
66
|
+
*
|
|
67
|
+
* The scratches are reset by cursor, never by `length = 0`: truncating a V8 array to zero
|
|
68
|
+
* drops its backing store, so every refill would reallocate from scratch (measured 12x the
|
|
69
|
+
* scavenge count of the cursor pattern). Spent slots are nulled to the high-water mark so
|
|
70
|
+
* the parsed tree stays collectable; null keeps the arrays in PACKED_ELEMENTS.
|
|
71
|
+
*/
|
|
72
|
+
function fixupParentReferences(rootNode) {
|
|
73
|
+
fixupStack[fixupStackTop++] = rootNode;
|
|
74
|
+
let stackHighWater = fixupStackTop;
|
|
75
|
+
let childHighWater = 0;
|
|
76
|
+
while (fixupStackTop > 0) {
|
|
77
|
+
const node = fixupStack[--fixupStackTop];
|
|
78
|
+
fixupChildCount = 0;
|
|
79
|
+
ohos_typescript_1.default.forEachChild(node, collectFixupChild);
|
|
80
|
+
const jsDoc = node.jsDoc;
|
|
81
|
+
if (jsDoc !== undefined) {
|
|
82
|
+
for (const doc of jsDoc) {
|
|
83
|
+
fixupChildren[fixupChildCount++] = doc;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (fixupChildCount > childHighWater) {
|
|
87
|
+
childHighWater = fixupChildCount;
|
|
88
|
+
}
|
|
89
|
+
for (let i = 0; i < fixupChildCount; i++) {
|
|
90
|
+
const child = fixupChildren[i];
|
|
91
|
+
child.parent = node;
|
|
92
|
+
fixupStack[fixupStackTop++] = child;
|
|
93
|
+
}
|
|
94
|
+
if (fixupStackTop > stackHighWater) {
|
|
95
|
+
stackHighWater = fixupStackTop;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const nullNode = null;
|
|
99
|
+
for (let i = 0; i < stackHighWater; i++) {
|
|
100
|
+
fixupStack[i] = nullNode;
|
|
101
|
+
}
|
|
102
|
+
for (let i = 0; i < childHighWater; i++) {
|
|
103
|
+
fixupChildren[i] = nullNode;
|
|
104
|
+
}
|
|
105
|
+
fixupStackTop = 0;
|
|
106
|
+
fixupChildCount = 0;
|
|
107
|
+
}
|
|
108
|
+
exports.fixupParentReferences = fixupParentReferences;
|
|
109
|
+
function blankJsDocOpeners(sourceText) {
|
|
110
|
+
const scanner = ohos_typescript_1.default.createScanner(ohos_typescript_1.default.ScriptTarget.Latest, false, ohos_typescript_1.default.LanguageVariant.Standard, sourceText);
|
|
111
|
+
const openers = [];
|
|
112
|
+
for (let token = scanner.scan(); token !== ohos_typescript_1.default.SyntaxKind.EndOfFileToken; token = scanner.scan()) {
|
|
113
|
+
if (token === ohos_typescript_1.default.SyntaxKind.MultiLineCommentTrivia) {
|
|
114
|
+
const pos = scanner.getTokenPos();
|
|
115
|
+
if (sourceText.startsWith('/**', pos) && sourceText[pos + 3] !== '/') {
|
|
116
|
+
openers.push(pos);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (openers.length === 0) {
|
|
121
|
+
return sourceText;
|
|
122
|
+
}
|
|
123
|
+
const parts = [];
|
|
124
|
+
let last = 0;
|
|
125
|
+
for (const pos of openers) {
|
|
126
|
+
parts.push(sourceText.slice(last, pos + 2), ' ');
|
|
127
|
+
last = pos + 3;
|
|
128
|
+
}
|
|
129
|
+
parts.push(sourceText.slice(last));
|
|
130
|
+
return parts.join('');
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DependenciesSort.d.ts","sourceRoot":"","sources":["../../src/utils/DependenciesSort.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIhD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,EAAE,CAoD/F"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2024-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.sortByDependency = void 0;
|
|
18
|
-
const ModelUtils_1 = require("../core/common/ModelUtils");
|
|
19
|
-
function sortByDependency(filesMap, projectName) {
|
|
20
|
-
const inDegree = new Map();
|
|
21
|
-
const adjacency = new Map();
|
|
22
|
-
filesMap.forEach((file, key) => {
|
|
23
|
-
inDegree.set(key, 0);
|
|
24
|
-
adjacency.set(key, new Set());
|
|
25
|
-
});
|
|
26
|
-
// Build dependency graph: if file A imports file B, add edge B -> A (B should be processed before A)
|
|
27
|
-
filesMap.forEach((file, fileKey) => {
|
|
28
|
-
let fromInfos = file.getImportInfos();
|
|
29
|
-
fromInfos = fromInfos.concat(file.getExportInfos());
|
|
30
|
-
for (const importInfo of fromInfos) {
|
|
31
|
-
const depFile = (0, ModelUtils_1.getArkFile)(importInfo);
|
|
32
|
-
if (!depFile || depFile.getProjectName() !== projectName) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const depKey = depFile.getFileSignature().toMapKey();
|
|
36
|
-
let importedFilesSet = adjacency.get(depKey);
|
|
37
|
-
if (depKey !== fileKey && importedFilesSet && !importedFilesSet.has(fileKey)) {
|
|
38
|
-
importedFilesSet.add(fileKey);
|
|
39
|
-
inDegree.set(fileKey, (inDegree.get(fileKey) || 0) + 1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
// Topological sort (Kahn's algorithm)
|
|
44
|
-
const queue = [];
|
|
45
|
-
for (const [key, degree] of inDegree) {
|
|
46
|
-
if (degree === 0) {
|
|
47
|
-
queue.push(key);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const result = [];
|
|
51
|
-
const visited = new Set();
|
|
52
|
-
while (queue.length > 0) {
|
|
53
|
-
const current = queue.shift();
|
|
54
|
-
visited.add(current);
|
|
55
|
-
result.push(filesMap.get(current));
|
|
56
|
-
for (const neighbor of adjacency.get(current)) {
|
|
57
|
-
const newDegree = (inDegree.get(neighbor) || 0) - 1;
|
|
58
|
-
inDegree.set(neighbor, newDegree);
|
|
59
|
-
if (newDegree === 0) {
|
|
60
|
-
queue.push(neighbor);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Add remaining files that are part of cycles
|
|
65
|
-
filesMap.forEach((file, key) => {
|
|
66
|
-
if (!visited.has(key)) {
|
|
67
|
-
result.push(file);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
exports.sortByDependency = sortByDependency;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto_utils.d.ts","sourceRoot":"","sources":["../../src/utils/crypto_utils.ts"],"names":[],"mappings":"AAiBA,qBAAa,WAAW;WACN,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;WAI/B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;WAIhD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAOlD"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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 __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.CryptoUtils = void 0;
|
|
41
|
-
const crypto = __importStar(require("crypto"));
|
|
42
|
-
class CryptoUtils {
|
|
43
|
-
static sha256(content) {
|
|
44
|
-
return this.hash(content, 'sha256');
|
|
45
|
-
}
|
|
46
|
-
static hash(content, algorithm) {
|
|
47
|
-
return crypto.createHash(algorithm).update(content).digest('base64url');
|
|
48
|
-
}
|
|
49
|
-
static hashcode(content) {
|
|
50
|
-
let h = 0;
|
|
51
|
-
for (let i = 0; i < content.length; i++) {
|
|
52
|
-
h = (Math.imul(31, h) + content.charCodeAt(i)) | 0;
|
|
53
|
-
}
|
|
54
|
-
return h;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.CryptoUtils = CryptoUtils;
|