Skip to content

Commit

Permalink
add ViewTeee
Browse files Browse the repository at this point in the history
Signed-off-by: code-sunbo <[email protected]>
  • Loading branch information
code-sunbo committed Oct 23, 2024
1 parent 45562d4 commit 7857a2e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
29 changes: 29 additions & 0 deletions src/ex/ex05/ViewTreeTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PrinterBuilder, Scene, SceneConfig, ViewTreePrinter } from 'arkanalyzer';
import { join } from 'path';

let config: SceneConfig = new SceneConfig();
config.buildFromJson(join(__dirname, '../resources/CountDown/arkanalyzer_config.json'));
let scene: Scene = new Scene();
scene.buildBasicInfo(config);
scene.buildScene4HarmonyProject();
scene.collectProjectImportInfos();
scene.inferTypes();

let arkFile = scene.getFiles().find((file) => file.getName().endsWith('CountDown.ets'));
let arkClass = arkFile?.getClassWithName('CountDown');
let vt = arkClass?.getViewTree();
let root = vt?.getRoot();
root?.walk((item) => {
let values: string[] = [];
for (const field of item.stateValues) {
values.push(field.getName());
}
if (values.length > 0) {
console.log(`${item.name} using stateValues ${values.join(',')}`);
} else {
console.log(`${item.name}`);
}
return false;
});

PrinterBuilder.dump(new ViewTreePrinter(vt!), 'out/CountDownViewTree.dot');
10 changes: 10 additions & 0 deletions src/ex/resources/CountDown/arkanalyzer_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"targetProjectName": "CountDown",
"targetProjectDirectory": "src/ex/resources/CountDown",

"logPath": "ArkAnalyzer.log",
"logLevel": "INFO",

"sdks": [
]
}
13 changes: 0 additions & 13 deletions src/ex/resources/CountDown/build-profile.json5
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@
}
],
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "C:\\Users\\孙波\\.ohos\\config\\default_CountDown_3GOOG0gFdCssqFEhu-dVCDBnKp7nMLriE1AEDMhiyaU=.cer",
"storePassword": "0000001BB69805420FA5C560A40C42C39A735CD33812B24B5BFC387AE2F06B64470989410F58B928910E43",
"keyAlias": "debugKey",
"keyPassword": "0000001B8F7707786343340BE7A4556890DCA8CDBBC5526079E890F0E68976267FB07605C3C5DA6B553C8B",
"profile": "C:\\Users\\孙波\\.ohos\\config\\default_CountDown_3GOOG0gFdCssqFEhu-dVCDBnKp7nMLriE1AEDMhiyaU=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "C:\\Users\\孙波\\.ohos\\config\\default_CountDown_3GOOG0gFdCssqFEhu-dVCDBnKp7nMLriE1AEDMhiyaU=.p12"
}
}
]
},
"modules": [
Expand Down

0 comments on commit 7857a2e

Please sign in to comment.