From 7b897f07ebb8ac9bf04f489986cffa55da941f68 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 28 Jan 2025 14:08:55 -0500 Subject: [PATCH 1/7] Added printer transformer --- arkoala-arkts/libarkts/arktsconfig.json | 4 ++++ .../examples/src/example-printer-transformer.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts diff --git a/arkoala-arkts/libarkts/arktsconfig.json b/arkoala-arkts/libarkts/arktsconfig.json index ca68d7458..d27bfafe3 100644 --- a/arkoala-arkts/libarkts/arktsconfig.json +++ b/arkoala-arkts/libarkts/arktsconfig.json @@ -10,6 +10,10 @@ { "transform": "./examples/build/src/example-checked-transformer.js", "stage": "checked" + }, + { + "transform": "./examples/build/src/example-printer-transformer.js", + "stage": "checked" } ] } diff --git a/arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts b/arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts new file mode 100644 index 000000000..cad6728e4 --- /dev/null +++ b/arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts @@ -0,0 +1,14 @@ +import * as ts from "@koalaui/libarkts" +import { PrintVisitor } from './print-visitor' + +export interface TransformerOptions { + trace?: boolean, +} + +export default function printerTransformer( + userPluginOptions?: TransformerOptions +) { + return (node: ts.EtsScript) => { + return new PrintVisitor().visitor(node) + } +} -- Gitee From 3db9a6bb3bfe16533e2d19fec1755c903e9facbb Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 28 Jan 2025 14:12:40 -0500 Subject: [PATCH 2/7] more --- arkoala-arkts/libarkts/examples/tsconfig.json | 1 + incremental/compat/arktsconfig.json | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arkoala-arkts/libarkts/examples/tsconfig.json b/arkoala-arkts/libarkts/examples/tsconfig.json index 145cc7fc5..319f3ee85 100644 --- a/arkoala-arkts/libarkts/examples/tsconfig.json +++ b/arkoala-arkts/libarkts/examples/tsconfig.json @@ -9,6 +9,7 @@ "include": [ "./src/example-parsed-transformer.ts", "./src/example-checked-transformer.ts", + "./src/example-printer-transformer.ts", "./src/AbstractVisitor.ts", "./src/print-visitor.ts", "./src/builder-lambda-transformer.ts", diff --git a/incremental/compat/arktsconfig.json b/incremental/compat/arktsconfig.json index 6b515b376..a87afb738 100644 --- a/incremental/compat/arktsconfig.json +++ b/incremental/compat/arktsconfig.json @@ -7,7 +7,13 @@ "paths": { "#platform": ["./"], "@koalaui/compat": ["../"] - } + }, + "plugins": [ + { + "transform": "../../arkoala-arkts/libarkts/examples/build/src/example-printer-transformer.js", + "stage": "checked" + } + ] }, "include": ["src/index.ts", "src/arkts/**/*.ts"], "exclude": ["./src/arkts/index.ts"] -- Gitee From a3aa3fcd4eacc18e864cba18d59e0e271e0411ca Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 4 Feb 2025 20:01:21 +0300 Subject: [PATCH 3/7] Renamed examples to plugins --- arkoala-arkts/libarkts/{examples => plugins}/input/export.sts | 0 arkoala-arkts/libarkts/{examples => plugins}/input/f.sts | 0 arkoala-arkts/libarkts/{examples => plugins}/input/library.sts | 0 arkoala-arkts/libarkts/{examples => plugins}/input/main.sts | 0 arkoala-arkts/libarkts/{examples => plugins}/input/variable.sts | 0 .../libarkts/{examples => plugins}/src/AbstractVisitor.ts | 0 .../libarkts/{examples => plugins}/src/analysis-visitor.ts | 0 .../{examples => plugins}/src/builder-lambda-transformer.ts | 0 .../libarkts/{examples => plugins}/src/component-transformer.ts | 0 .../{examples => plugins}/src/example-checked-transformer.ts | 0 .../{examples => plugins}/src/example-parsed-transformer.ts | 0 .../{examples => plugins}/src/example-printer-transformer.ts | 0 .../libarkts/{examples => plugins}/src/function-transformer.ts | 0 .../libarkts/{examples => plugins}/src/memo-transformer.ts | 0 arkoala-arkts/libarkts/{examples => plugins}/src/print-visitor.ts | 0 .../libarkts/{examples => plugins}/src/transformation-context.ts | 0 arkoala-arkts/libarkts/{examples => plugins}/src/util.ts | 0 arkoala-arkts/libarkts/{examples => plugins}/tsconfig.json | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename arkoala-arkts/libarkts/{examples => plugins}/input/export.sts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/input/f.sts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/input/library.sts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/input/main.sts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/input/variable.sts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/AbstractVisitor.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/analysis-visitor.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/builder-lambda-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/component-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/example-checked-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/example-parsed-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/example-printer-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/function-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/memo-transformer.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/print-visitor.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/transformation-context.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/src/util.ts (100%) rename arkoala-arkts/libarkts/{examples => plugins}/tsconfig.json (100%) diff --git a/arkoala-arkts/libarkts/examples/input/export.sts b/arkoala-arkts/libarkts/plugins/input/export.sts similarity index 100% rename from arkoala-arkts/libarkts/examples/input/export.sts rename to arkoala-arkts/libarkts/plugins/input/export.sts diff --git a/arkoala-arkts/libarkts/examples/input/f.sts b/arkoala-arkts/libarkts/plugins/input/f.sts similarity index 100% rename from arkoala-arkts/libarkts/examples/input/f.sts rename to arkoala-arkts/libarkts/plugins/input/f.sts diff --git a/arkoala-arkts/libarkts/examples/input/library.sts b/arkoala-arkts/libarkts/plugins/input/library.sts similarity index 100% rename from arkoala-arkts/libarkts/examples/input/library.sts rename to arkoala-arkts/libarkts/plugins/input/library.sts diff --git a/arkoala-arkts/libarkts/examples/input/main.sts b/arkoala-arkts/libarkts/plugins/input/main.sts similarity index 100% rename from arkoala-arkts/libarkts/examples/input/main.sts rename to arkoala-arkts/libarkts/plugins/input/main.sts diff --git a/arkoala-arkts/libarkts/examples/input/variable.sts b/arkoala-arkts/libarkts/plugins/input/variable.sts similarity index 100% rename from arkoala-arkts/libarkts/examples/input/variable.sts rename to arkoala-arkts/libarkts/plugins/input/variable.sts diff --git a/arkoala-arkts/libarkts/examples/src/AbstractVisitor.ts b/arkoala-arkts/libarkts/plugins/src/AbstractVisitor.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/AbstractVisitor.ts rename to arkoala-arkts/libarkts/plugins/src/AbstractVisitor.ts diff --git a/arkoala-arkts/libarkts/examples/src/analysis-visitor.ts b/arkoala-arkts/libarkts/plugins/src/analysis-visitor.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/analysis-visitor.ts rename to arkoala-arkts/libarkts/plugins/src/analysis-visitor.ts diff --git a/arkoala-arkts/libarkts/examples/src/builder-lambda-transformer.ts b/arkoala-arkts/libarkts/plugins/src/builder-lambda-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/builder-lambda-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/builder-lambda-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/component-transformer.ts b/arkoala-arkts/libarkts/plugins/src/component-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/component-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/component-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/example-checked-transformer.ts b/arkoala-arkts/libarkts/plugins/src/example-checked-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/example-checked-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/example-checked-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/example-parsed-transformer.ts b/arkoala-arkts/libarkts/plugins/src/example-parsed-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/example-parsed-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/example-parsed-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts b/arkoala-arkts/libarkts/plugins/src/example-printer-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/example-printer-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/example-printer-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/function-transformer.ts b/arkoala-arkts/libarkts/plugins/src/function-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/function-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/function-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/memo-transformer.ts b/arkoala-arkts/libarkts/plugins/src/memo-transformer.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/memo-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/memo-transformer.ts diff --git a/arkoala-arkts/libarkts/examples/src/print-visitor.ts b/arkoala-arkts/libarkts/plugins/src/print-visitor.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/print-visitor.ts rename to arkoala-arkts/libarkts/plugins/src/print-visitor.ts diff --git a/arkoala-arkts/libarkts/examples/src/transformation-context.ts b/arkoala-arkts/libarkts/plugins/src/transformation-context.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/transformation-context.ts rename to arkoala-arkts/libarkts/plugins/src/transformation-context.ts diff --git a/arkoala-arkts/libarkts/examples/src/util.ts b/arkoala-arkts/libarkts/plugins/src/util.ts similarity index 100% rename from arkoala-arkts/libarkts/examples/src/util.ts rename to arkoala-arkts/libarkts/plugins/src/util.ts diff --git a/arkoala-arkts/libarkts/examples/tsconfig.json b/arkoala-arkts/libarkts/plugins/tsconfig.json similarity index 100% rename from arkoala-arkts/libarkts/examples/tsconfig.json rename to arkoala-arkts/libarkts/plugins/tsconfig.json -- Gitee From d714c43dcc56b0c1552798469af870240eb964c6 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 4 Feb 2025 20:08:53 +0300 Subject: [PATCH 4/7] wip --- arkoala-arkts/libarkts/arktsconfig.json | 8 ++++---- ...ple-checked-transformer.ts => checked-stage-plugin.ts} | 0 ...ample-parsed-transformer.ts => parsed-stage-plugin.ts} | 0 arkoala-arkts/user/arktsconfig-pure-sts.json | 6 +++++- incremental/compat/arktsconfig.json | 8 +------- 5 files changed, 10 insertions(+), 12 deletions(-) rename arkoala-arkts/libarkts/plugins/src/{example-checked-transformer.ts => checked-stage-plugin.ts} (100%) rename arkoala-arkts/libarkts/plugins/src/{example-parsed-transformer.ts => parsed-stage-plugin.ts} (100%) diff --git a/arkoala-arkts/libarkts/arktsconfig.json b/arkoala-arkts/libarkts/arktsconfig.json index d27bfafe3..3338eeae8 100644 --- a/arkoala-arkts/libarkts/arktsconfig.json +++ b/arkoala-arkts/libarkts/arktsconfig.json @@ -4,15 +4,15 @@ "baseUrl": ".", "plugins": [ { - "transform": "./examples/build/src/example-parsed-transformer.js", + "transform": "./examples/build/src/printer-plugin.js", "stage": "parsed" }, { - "transform": "./examples/build/src/example-checked-transformer.js", - "stage": "checked" + "transform": "./examples/build/src/parsed-stage-plugin.js", + "stage": "parsed" }, { - "transform": "./examples/build/src/example-printer-transformer.js", + "transform": "./examples/build/src/checked-stage-plugin.js", "stage": "checked" } ] diff --git a/arkoala-arkts/libarkts/plugins/src/example-checked-transformer.ts b/arkoala-arkts/libarkts/plugins/src/checked-stage-plugin.ts similarity index 100% rename from arkoala-arkts/libarkts/plugins/src/example-checked-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/checked-stage-plugin.ts diff --git a/arkoala-arkts/libarkts/plugins/src/example-parsed-transformer.ts b/arkoala-arkts/libarkts/plugins/src/parsed-stage-plugin.ts similarity index 100% rename from arkoala-arkts/libarkts/plugins/src/example-parsed-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/parsed-stage-plugin.ts diff --git a/arkoala-arkts/user/arktsconfig-pure-sts.json b/arkoala-arkts/user/arktsconfig-pure-sts.json index 8a930b0f0..a1bce1058 100644 --- a/arkoala-arkts/user/arktsconfig-pure-sts.json +++ b/arkoala-arkts/user/arktsconfig-pure-sts.json @@ -12,7 +12,11 @@ }, "plugins": [ { - "transform": "../libarkts/examples/build/src/example-parsed-transformer.js", + "transform": "../libarkts/examples/build/src/printer-plugin.js", + "stage": "parsed" + }, + { + "transform": "../libarkts/examples/build/src/parsed-plugin.js", "stage": "parsed" } ] diff --git a/incremental/compat/arktsconfig.json b/incremental/compat/arktsconfig.json index a87afb738..6b515b376 100644 --- a/incremental/compat/arktsconfig.json +++ b/incremental/compat/arktsconfig.json @@ -7,13 +7,7 @@ "paths": { "#platform": ["./"], "@koalaui/compat": ["../"] - }, - "plugins": [ - { - "transform": "../../arkoala-arkts/libarkts/examples/build/src/example-printer-transformer.js", - "stage": "checked" - } - ] + } }, "include": ["src/index.ts", "src/arkts/**/*.ts"], "exclude": ["./src/arkts/index.ts"] -- Gitee From 28f504b11975b883e82456c8a262a8b3911babee Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 4 Feb 2025 14:21:18 -0500 Subject: [PATCH 5/7] Some tweaks around plugins, directories and names --- arkoala-arkts/libarkts/arktsconfig.json | 6 +++--- arkoala-arkts/libarkts/package.json | 7 ++++--- .../{example-printer-transformer.ts => printer-plugin.ts} | 0 arkoala-arkts/libarkts/plugins/tsconfig.json | 6 +++--- arkoala-arkts/libarkts/src/arkts-api/static/global.ts | 2 +- arkoala-arkts/libarkts/src/es2panda.ts | 7 +++++-- .../libarkts/test/ts-api/demo-playground/classes.test.ts | 2 +- .../test/ts-api/demo-playground/memo-rewrites.test.ts | 2 +- .../visitors-and-transformers/analysis-visitor.test.ts | 6 +++--- .../builder-lambda-rewrite.test.ts | 2 +- .../visitors-and-transformers/function-rewrite.test.ts | 4 ++-- .../ts-api/visitors-and-transformers/memo-rewrite.test.ts | 2 +- .../ts-api/visitors-and-transformers/print-visitor.test.ts | 2 +- arkoala-arkts/user/arktsconfig-pure-sts.json | 4 ++-- 14 files changed, 28 insertions(+), 24 deletions(-) rename arkoala-arkts/libarkts/plugins/src/{example-printer-transformer.ts => printer-plugin.ts} (100%) diff --git a/arkoala-arkts/libarkts/arktsconfig.json b/arkoala-arkts/libarkts/arktsconfig.json index 3338eeae8..c3868f430 100644 --- a/arkoala-arkts/libarkts/arktsconfig.json +++ b/arkoala-arkts/libarkts/arktsconfig.json @@ -4,15 +4,15 @@ "baseUrl": ".", "plugins": [ { - "transform": "./examples/build/src/printer-plugin.js", + "transform": "./plugins/build/src/printer-plugin.js", "stage": "parsed" }, { - "transform": "./examples/build/src/parsed-stage-plugin.js", + "transform": "./plugins/build/src/parsed-stage-plugin.js", "stage": "parsed" }, { - "transform": "./examples/build/src/checked-stage-plugin.js", + "transform": "./plugins/build/src/checked-stage-plugin.js", "stage": "checked" } ] diff --git a/arkoala-arkts/libarkts/package.json b/arkoala-arkts/libarkts/package.json index c6d5d7394..321065a95 100644 --- a/arkoala-arkts/libarkts/package.json +++ b/arkoala-arkts/libarkts/package.json @@ -4,7 +4,8 @@ "main": "./build/src/es2panda.js", "types": "./build/src/arkts-api/index.d.ts", "exports": { - ".": "./build/src/arkts-api/index.js" + ".": "./build/src/arkts-api/index.js", + "./plugins/*": "./plugins/build/src/*.js" }, "files": [ "./build/*" @@ -20,8 +21,8 @@ "compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node", "compile:src": "npx ets-tsc -p ./tsconfig.json", "compile": "npm run compile:native && npm run compile:src", - "compile:plugin": "npx ets-tsc -p examples/tsconfig.json", - "run:js": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./examples/input/main.sts --arktsconfig ./arktsconfig.json --output ./build/abc/main.abc --dump-plugin-ast", + "compile:plugin": "npx ets-tsc -p plugins/tsconfig.json", + "run:js": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/main.sts --arktsconfig ./arktsconfig.json --output ./build/abc/main.abc --dump-plugin-ast", "run": "npm run compile && npm run compile:plugin && npm run run:js", "mocha": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0", "test": "npm run compile:native && npm run mocha", diff --git a/arkoala-arkts/libarkts/plugins/src/example-printer-transformer.ts b/arkoala-arkts/libarkts/plugins/src/printer-plugin.ts similarity index 100% rename from arkoala-arkts/libarkts/plugins/src/example-printer-transformer.ts rename to arkoala-arkts/libarkts/plugins/src/printer-plugin.ts diff --git a/arkoala-arkts/libarkts/plugins/tsconfig.json b/arkoala-arkts/libarkts/plugins/tsconfig.json index 319f3ee85..d0ce6f222 100644 --- a/arkoala-arkts/libarkts/plugins/tsconfig.json +++ b/arkoala-arkts/libarkts/plugins/tsconfig.json @@ -7,9 +7,9 @@ "module": "CommonJS" }, "include": [ - "./src/example-parsed-transformer.ts", - "./src/example-checked-transformer.ts", - "./src/example-printer-transformer.ts", + "./src/parsed-stage-plugin.ts", + "./src/checked-stage-plugin.ts", + "./src/printer-plugin.ts", "./src/AbstractVisitor.ts", "./src/print-visitor.ts", "./src/builder-lambda-transformer.ts", diff --git a/arkoala-arkts/libarkts/src/arkts-api/static/global.ts b/arkoala-arkts/libarkts/src/arkts-api/static/global.ts index c5e19a450..963bde426 100644 --- a/arkoala-arkts/libarkts/src/arkts-api/static/global.ts +++ b/arkoala-arkts/libarkts/src/arkts-api/static/global.ts @@ -20,7 +20,7 @@ import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from "../../gen import { initInterop, InteropNativeModule } from "../../InteropNativeModule" export default class global { - public static filePath: string = "./examples/input/main.sts" + public static filePath: string = "./plugins/input/main.sts" private static _config?: KNativePointer public static set config(config: KNativePointer) { diff --git a/arkoala-arkts/libarkts/src/es2panda.ts b/arkoala-arkts/libarkts/src/es2panda.ts index ae43bd70d..213e71587 100644 --- a/arkoala-arkts/libarkts/src/es2panda.ts +++ b/arkoala-arkts/libarkts/src/es2panda.ts @@ -106,10 +106,13 @@ function invokeWithPlugins(configPath: string, filePath: string, outputPath: str } function loadPlugin(configDir: string, jsonPlugin: any) { - const plugin = jsonPlugin.transform ?? throwError(`arktsconfig plugins objects should specify transform`) + const pluginPath = jsonPlugin.transform ?? throwError(`arktsconfig plugins objects should specify transform`) /** TODO: read and pass plugin options */ const options = jsonPlugin.options ?? {} - return require(path.resolve(configDir, plugin)).default() + const plugin = (pluginPath.startsWith(".") || pluginPath.startsWith("/")) ? + path.resolve(configDir, pluginPath) : pluginPath + + return require(plugin).default() } function selectPlugins(configDir: string, plugins: any[], stage: string): ((arg: arkts.Node) => arkts.Node)|undefined { diff --git a/arkoala-arkts/libarkts/test/ts-api/demo-playground/classes.test.ts b/arkoala-arkts/libarkts/test/ts-api/demo-playground/classes.test.ts index 1bb75a7b7..1665d41dd 100644 --- a/arkoala-arkts/libarkts/test/ts-api/demo-playground/classes.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/demo-playground/classes.test.ts @@ -1,6 +1,6 @@ // import * as util from "../../test-util" // import * as ts from "../../../src/ts-api" -// import { MemoTransformer } from "../../../examples/src/memo-transformer" +// import { MemoTransformer } from "../../../plugins/src/memo-transformer" // // suite(util.basename(__filename), () => { // test.skip("stinger-node-class", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/demo-playground/memo-rewrites.test.ts b/arkoala-arkts/libarkts/test/ts-api/demo-playground/memo-rewrites.test.ts index 20f4a4eaf..8b920be82 100644 --- a/arkoala-arkts/libarkts/test/ts-api/demo-playground/memo-rewrites.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/demo-playground/memo-rewrites.test.ts @@ -1,6 +1,6 @@ // import * as util from "../../test-util" // import * as ts from "../../../src/ts-api" -// import { MemoTransformer } from "../../../examples/src/memo-transformer" +// import { MemoTransformer } from "../../../plugins/src/memo-transformer" // // suite(util.getSuiteTitle(__filename), () => { // test.skip("function-stinger", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/analysis-visitor.test.ts b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/analysis-visitor.test.ts index 323262525..136595565 100644 --- a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/analysis-visitor.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/analysis-visitor.test.ts @@ -1,8 +1,8 @@ // import * as util from "../../test-util" // import * as ts from "../../../src/ts-api" -// import { AnalysisVisitor } from "../../../examples/src/analysis-visitor" -// import { Tracer } from "../../../examples/src/util" -// import { Rewrite } from "../../../examples/src/transformation-context" +// import { AnalysisVisitor } from "../../../plugins/src/analysis-visitor" +// import { Tracer } from "../../../plugins/src/util" +// import { Rewrite } from "../../../plugins/src/transformation-context" // // suite(util.getSuiteTitle(__filename), () => { // test("sample-1", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/builder-lambda-rewrite.test.ts b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/builder-lambda-rewrite.test.ts index 76ace9869..5098b3eec 100644 --- a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/builder-lambda-rewrite.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/builder-lambda-rewrite.test.ts @@ -1,7 +1,7 @@ // import * as util from "../../test-util" // import * as ts from "../../../src/ts-api" // import { factory } from "../../../src/ts-api" -// import { BuilderLambdaTransformer } from "../../../examples/src/builder-lambda-transformer" +// import { BuilderLambdaTransformer } from "../../../plugins/src/builder-lambda-transformer" // // suite.skip(util.getSuiteTitle(__filename), () => { // test("builder-lambda-transformer-sample-1", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/function-rewrite.test.ts b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/function-rewrite.test.ts index 0932796e5..7375d85b7 100644 --- a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/function-rewrite.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/function-rewrite.test.ts @@ -1,8 +1,8 @@ // import * as util from "../../test-util" // import * as ts from "../../../src/ts-api" // import global from "src/arkts-api/static/global" -// import { FunctionTransformer } from "../../../examples/src/function-transformer" -// import { PrintVisitor } from "../../../examples/src/print-visitor" +// import { FunctionTransformer } from "../../../plugins/src/function-transformer" +// import { PrintVisitor } from "../../../plugins/src/print-visitor" // // suite.skip(util.getSuiteTitle(__filename), () => { // test("function-transformer-sample-1", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/memo-rewrite.test.ts b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/memo-rewrite.test.ts index 7e8f32b06..9bdc32742 100644 --- a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/memo-rewrite.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/memo-rewrite.test.ts @@ -1,6 +1,6 @@ import * as util from "../../test-util" import * as ts from "../../../src/ts-api" -import { MemoTransformer } from "../../../examples/src/memo-transformer" +import { MemoTransformer } from "../../../plugins/src/memo-transformer" suite(util.basename(__filename), () => { test("memo-transformer-sample-1", function() { diff --git a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/print-visitor.test.ts b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/print-visitor.test.ts index 14747c33c..a9cd80a31 100644 --- a/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/print-visitor.test.ts +++ b/arkoala-arkts/libarkts/test/ts-api/visitors-and-transformers/print-visitor.test.ts @@ -1,6 +1,6 @@ // import * as ts from "../../../src/ts-api" // import * as util from "../../test-util" -// import { PrintVisitor } from "../../../examples/src/print-visitor" +// import { PrintVisitor } from "../../../plugins/src/print-visitor" // // suite.skip(util.getSuiteTitle(__filename), () => { // test("sample-1", function() { diff --git a/arkoala-arkts/user/arktsconfig-pure-sts.json b/arkoala-arkts/user/arktsconfig-pure-sts.json index a1bce1058..18c1a88e0 100644 --- a/arkoala-arkts/user/arktsconfig-pure-sts.json +++ b/arkoala-arkts/user/arktsconfig-pure-sts.json @@ -12,11 +12,11 @@ }, "plugins": [ { - "transform": "../libarkts/examples/build/src/printer-plugin.js", + "transform": "@koalaui/libarkts/plugins/printer-plugin", "stage": "parsed" }, { - "transform": "../libarkts/examples/build/src/parsed-plugin.js", + "transform": "@koalaui/libarkts/plugins/parsed-stage-plugin", "stage": "parsed" } ] -- Gitee From 770ba8391555d05741c9baeb33a67685ee92c379 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 4 Feb 2025 23:10:07 +0300 Subject: [PATCH 6/7] more --- arkoala-arkts/libarkts/playground/src/playground.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arkoala-arkts/libarkts/playground/src/playground.cc b/arkoala-arkts/libarkts/playground/src/playground.cc index 880c12aeb..8d8d7c475 100644 --- a/arkoala-arkts/libarkts/playground/src/playground.cc +++ b/arkoala-arkts/libarkts/playground/src/playground.cc @@ -42,7 +42,7 @@ int main() { // path to config "./arktsconfig.json", // path to source - "./examples/input/main.sts", + "./plugins/input/main.sts", "--stdlib", "../../incremental/tools/panda/node_modules/@panda/sdk/ets/stdlib" }; -- Gitee From ece76195c80ad5da45d03c62e63ff8014c00c950 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Wed, 5 Feb 2025 11:03:28 +0300 Subject: [PATCH 7/7] a copyright Signed-off-by: Alexander Gorshenev --- .../libarkts/plugins/src/printer-plugin.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arkoala-arkts/libarkts/plugins/src/printer-plugin.ts b/arkoala-arkts/libarkts/plugins/src/printer-plugin.ts index cad6728e4..f9301a018 100644 --- a/arkoala-arkts/libarkts/plugins/src/printer-plugin.ts +++ b/arkoala-arkts/libarkts/plugins/src/printer-plugin.ts @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import * as ts from "@koalaui/libarkts" import { PrintVisitor } from './print-visitor' -- Gitee