mirror of
https://gitee.com/openharmony/developtools_ace_ets2bundle
synced 2024-11-27 02:30:55 +00:00
合规问题处理 Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I2bd7fcf560cb3ef9fde61107c03b0bc3e140067e
This commit is contained in:
parent
3d2b3e3641
commit
5c27ea9189
82
README.en.md
82
README.en.md
@ -1,82 +0,0 @@
|
||||
# developtools_ace-ets2bundle
|
||||
|
||||
#### Description
|
||||
Provide declarative paradigm syntax compilation conversion, syntax verification, rich and friendly syntax error prompting capabilities.
|
||||
|
||||
#### Software Architecture
|
||||
|
||||
* compiler/src: source code
|
||||
* test: unit test file
|
||||
* .eslintrc: eslint configure
|
||||
* babel.config.js: babel configure
|
||||
* main.js: source code
|
||||
* package.json: define what libraries will be installed into node_modules when you run `npm install`
|
||||
* tsconfig.json: the compiler options required to compile the project
|
||||
* webpack.config.js: webpack configuration information
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
```
|
||||
> npm -v
|
||||
6.14.8
|
||||
> node -v
|
||||
v12.18.3
|
||||
```
|
||||
Your `npm` and `node` should be of a later version. You can upgrade them to the **latest stable version**.
|
||||
|
||||
#### Installing
|
||||
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm config set registry http://registry.npm.taobao.org
|
||||
npm config set strict-ssl false
|
||||
npm cache clean -f
|
||||
npm install
|
||||
```
|
||||
|
||||
#### Quick Start
|
||||
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm run build
|
||||
npm run compile
|
||||
```
|
||||
The `sample` project will be compiled. The output is in the `sample/build` directory.
|
||||
|
||||
#### Create a new project
|
||||
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm run create [projectName]
|
||||
```
|
||||
|
||||
**Note**: If `projectName` is empty, create the `HelloAce` project by default.
|
||||
For example, use the following line to create a project named `foo`:
|
||||
```
|
||||
$ npm run create foo
|
||||
```
|
||||
The directory structure of project `foo`:
|
||||
- foo
|
||||
- pages
|
||||
- index.ets
|
||||
- app.ets
|
||||
- manifest.json
|
||||
|
||||
#### Create a new page
|
||||
|
||||
For example, create a file `bar.ets` in the `pages` directory. And then add the following lines to `"pages"` field in `manifest.json`:
|
||||
```
|
||||
"pages": [
|
||||
"pages/index",
|
||||
"pages/bar"
|
||||
]
|
||||
```
|
||||
|
||||
#### Compile a project
|
||||
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
$ npm run build
|
||||
$ npm run compile [projectName]
|
||||
```
|
||||
**Note**: If `projectName` is empty, compile the `sample` project by default. In the project root directory, the compilation result is in the `build` directory.
|
57
README.md
57
README.md
@ -1,21 +1,20 @@
|
||||
# developtools_ace-ets2bundle
|
||||
|
||||
#### 介绍
|
||||
#### Description
|
||||
Provide declarative paradigm syntax compilation conversion, syntax verification, rich and friendly syntax error prompting capabilities.
|
||||
|
||||
提供声明式范式的语法编译转换,语法验证,丰富友好的语法报错提示能力。
|
||||
#### Software Architecture
|
||||
|
||||
#### 软件架构
|
||||
* compiler/src: source code
|
||||
* test: unit test file
|
||||
* .eslintrc: eslint configure
|
||||
* babel.config.js: babel configure
|
||||
* main.js: source code
|
||||
* package.json: define what libraries will be installed into node_modules when you run `npm install`
|
||||
* tsconfig.json: the compiler options required to compile the project
|
||||
* webpack.config.js: webpack configuration information
|
||||
|
||||
* compiler/src: 编译转换工具源码
|
||||
* test: 单元测试用例
|
||||
* .eslintrc: eslint配置规则
|
||||
* babel.config.js: babel配置信息
|
||||
* main.js: 编译转换工具源码
|
||||
* package.json: 安装依赖软件版本信息
|
||||
* tsconfig.json: 编译工程配置信息
|
||||
* webpack.config.js: 打包工具脚本配置信息
|
||||
|
||||
#### 环境准备
|
||||
#### Prerequisites
|
||||
|
||||
```
|
||||
> npm -v
|
||||
@ -23,11 +22,11 @@
|
||||
> node -v
|
||||
v12.18.3
|
||||
```
|
||||
请安装最新稳定的node版本。
|
||||
Please install the **latest stable version**.
|
||||
|
||||
#### 安装
|
||||
#### Installing
|
||||
|
||||
进入到compiler目录
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm config set registry http://registry.npm.taobao.org
|
||||
npm config set strict-ssl false
|
||||
@ -35,37 +34,37 @@ npm cache clean -f
|
||||
npm install
|
||||
```
|
||||
|
||||
#### 快速开始
|
||||
#### Quick Start
|
||||
|
||||
进入到compiler目录
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm run build
|
||||
npm run compile
|
||||
```
|
||||
上述命令编译了compiler目录下的`sample`工程,编译结果在`sample\build`目录。
|
||||
The `sample` project will be compiled. The output is in the `sample/build` directory.
|
||||
|
||||
#### 创建一个新工程
|
||||
#### Creating a Project
|
||||
|
||||
进入到compiler目录
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
npm run create [projectName]
|
||||
```
|
||||
|
||||
**Note**: 如果`projectName`未指定,`HelloAce`为默认的工程名。
|
||||
例如创建一个`foo`工程:
|
||||
**Note**: If `projectName` is not specified, the `HelloAce` project will be compiled.
|
||||
For example, use the following line to create a project named `foo`:
|
||||
```
|
||||
$ npm run create foo
|
||||
```
|
||||
工程`foo`的目录结构:
|
||||
The directory structure of project `foo`:
|
||||
- foo
|
||||
- pages
|
||||
- index.ets
|
||||
- app.ets
|
||||
- manifest.json
|
||||
|
||||
#### 创建一个新的页面
|
||||
#### Creating a Page
|
||||
|
||||
例如在`pages`目录创建一个`bar.ets`页面,需要在manifest.json文件的`pages`新增一行,如下所示:
|
||||
For example, create a file `bar.ets` in the `pages` directory. And then add the following lines to `"pages"` field in `manifest.json`:
|
||||
```
|
||||
"pages": [
|
||||
"pages/index",
|
||||
@ -73,11 +72,11 @@ $ npm run create foo
|
||||
]
|
||||
```
|
||||
|
||||
#### 编译工程
|
||||
#### Compiling a Project
|
||||
|
||||
进入到compiler目录
|
||||
Enter the root directory of the compiler:
|
||||
```
|
||||
$ npm run build
|
||||
$ npm run compile [projectName]
|
||||
```
|
||||
**Note**: 如果`projectName`未指定,默认编译`sample`工程,编译结果在`sample\build`目录。
|
||||
**Note**: If `projectName` is not specified, the `sample` project will be compiled. In the project root directory, the compilation result is in the `build` directory.
|
||||
|
83
README_zh.md
Normal file
83
README_zh.md
Normal file
@ -0,0 +1,83 @@
|
||||
# developtools_ace-ets2bundle
|
||||
|
||||
#### 介绍
|
||||
|
||||
提供声明式范式的语法编译转换,语法验证,丰富友好的语法报错提示能力。
|
||||
|
||||
#### 软件架构
|
||||
|
||||
* compiler/src: 编译转换工具源码
|
||||
* test: 单元测试用例
|
||||
* .eslintrc: eslint配置规则
|
||||
* babel.config.js: babel配置信息
|
||||
* main.js: 编译转换工具源码
|
||||
* package.json: 安装依赖软件版本信息
|
||||
* tsconfig.json: 编译工程配置信息
|
||||
* webpack.config.js: 打包工具脚本配置信息
|
||||
|
||||
#### 环境准备
|
||||
|
||||
```
|
||||
> npm -v
|
||||
6.14.8
|
||||
> node -v
|
||||
v12.18.3
|
||||
```
|
||||
请安装最新稳定的node版本。
|
||||
|
||||
#### 安装
|
||||
|
||||
进入到compiler目录
|
||||
```
|
||||
npm config set registry http://registry.npm.taobao.org
|
||||
npm config set strict-ssl false
|
||||
npm cache clean -f
|
||||
npm install
|
||||
```
|
||||
|
||||
#### 快速开始
|
||||
|
||||
进入到compiler目录
|
||||
```
|
||||
npm run build
|
||||
npm run compile
|
||||
```
|
||||
上述命令编译了compiler目录下的`sample`工程,编译结果在`sample\build`目录。
|
||||
|
||||
#### 创建一个新工程
|
||||
|
||||
进入到compiler目录
|
||||
```
|
||||
npm run create [projectName]
|
||||
```
|
||||
|
||||
**Note**: 如果`projectName`未指定,`HelloAce`为默认的工程名。
|
||||
例如创建一个`foo`工程:
|
||||
```
|
||||
$ npm run create foo
|
||||
```
|
||||
工程`foo`的目录结构:
|
||||
- foo
|
||||
- pages
|
||||
- index.ets
|
||||
- app.ets
|
||||
- manifest.json
|
||||
|
||||
#### 创建一个新的页面
|
||||
|
||||
例如在`pages`目录创建一个`bar.ets`页面,需要在manifest.json文件的`pages`新增一行,如下所示:
|
||||
```
|
||||
"pages": [
|
||||
"pages/index",
|
||||
"pages/bar"
|
||||
]
|
||||
```
|
||||
|
||||
#### 编译工程
|
||||
|
||||
进入到compiler目录
|
||||
```
|
||||
$ npm run build
|
||||
$ npm run compile [projectName]
|
||||
```
|
||||
**Note**: 如果`projectName`未指定,默认编译`sample`工程,编译结果在`sample\build`目录。
|
@ -5,7 +5,7 @@
|
||||
"versionCode": 1,
|
||||
"minPlatformVersion": "1.0.1",
|
||||
"pages": [
|
||||
"pages/todo",
|
||||
"pages/willdo",
|
||||
"pages/index",
|
||||
"pages/home",
|
||||
"pages/home_preview",
|
||||
|
@ -729,7 +729,7 @@ struct FiltersView {
|
||||
let newValue: boolean = (data.length > 0) ? !data[0].show : false;
|
||||
data.forEach((c: CountryVM) => c.show = newValue);
|
||||
|
||||
// FIXME: hack to make this vew render and take chnaged 'show' CountryVM instances into account
|
||||
// hack to make this vew render and take chnaged 'show' CountryVM instances into account
|
||||
// this need @Observed CountryVM / createdObservableObject to work efficiently.
|
||||
this.countryHasChanged = !this.countryHasChanged
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
(in SwiftUI). Therefore, the app needs to provide a unique id for each array item.
|
||||
We do so by making each array item an object with a unique id.
|
||||
|
||||
TODO this id should be used as the 'key' argument when creating a Text.
|
||||
this id should be used as the 'key' argument when creating a Text.
|
||||
|
||||
*/
|
||||
|
||||
|
@ -16,12 +16,12 @@
|
||||
/**
|
||||
* ACE @ Web Helsinki
|
||||
*
|
||||
* eDSL version of TODO application
|
||||
* eDSL version of this application
|
||||
*
|
||||
* ( unverified due to lack of working eDSL transpiler )
|
||||
*
|
||||
* For comparison, the plain JS version of this app that works with ACE-Diff can be found here
|
||||
* https://rnd-gitlab-eu-c.huawei.com/zidanehbs/ace/ace/-/blob/fin-hmf-dev-ace-diff-clean/samples/common/res/hi_topapp/assets/js/default/acediff/todoListForEach.js
|
||||
*
|
||||
* This is the ouput the eDSL transpiler should generate.
|
||||
*/
|
||||
let tasks: Array<any> = [
|
||||
@ -159,7 +159,7 @@ struct RootView {
|
||||
Text((item.id + 1) + " : " + item.label)
|
||||
},
|
||||
|
||||
/* second parameter is a arrow function that takes an item as input
|
||||
/* second parameter is an arrow function that takes an item as input
|
||||
and returns a persistent nique id (or key ) */
|
||||
item => item.id
|
||||
) // ForEach
|
@ -856,7 +856,7 @@ function validateForbiddenUseStateType(propertyName: ts.Identifier, decorator: s
|
||||
function validateDuplicateDecorator(decorator: ts.Decorator, log: LogInfo[]): void {
|
||||
log.push({
|
||||
type: LogType.ERROR,
|
||||
message: `The decorator '${decorator.getText()}' cannot have the same name as the build-in ` +
|
||||
message: `The decorator '${decorator.getText()}' cannot have the same name as the built-in ` +
|
||||
`style attribute '${decorator.getText().replace('@', '')}'.`,
|
||||
pos: decorator.getStart()
|
||||
});
|
||||
|
@ -162,13 +162,13 @@ function addDependencies(node: ts.ClassDeclaration, defaultNameFromParent: strin
|
||||
if (defaultNameFromParent && node.modifiers && node.modifiers.length >= 2 && node.modifiers[0] &&
|
||||
node.modifiers[1] && node.modifiers[0].kind === ts.SyntaxKind.ExportKeyword &&
|
||||
node.modifiers[1].kind === ts.SyntaxKind.DefaultKeyword) {
|
||||
setDependencies(defaultNameFromParent, ComponentSet.links, ComponentSet.propertys,
|
||||
setDependencies(defaultNameFromParent, ComponentSet.links, ComponentSet.properties,
|
||||
ComponentSet.props);
|
||||
} else if (asNameFromParent.has(componentName)) {
|
||||
setDependencies(asNameFromParent.get(componentName), ComponentSet.links, ComponentSet.propertys,
|
||||
setDependencies(asNameFromParent.get(componentName), ComponentSet.links, ComponentSet.properties,
|
||||
ComponentSet.props);
|
||||
} else {
|
||||
setDependencies(componentName, ComponentSet.links, ComponentSet.propertys, ComponentSet.props);
|
||||
setDependencies(componentName, ComponentSet.links, ComponentSet.properties, ComponentSet.props);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,13 @@ export function addLog(type: LogType, message: string, pos: number, log: LogInfo
|
||||
}
|
||||
|
||||
export function getMessage(fileName: string, info: LogInfo): string {
|
||||
let messsage: string;
|
||||
let message: string;
|
||||
if (info.line && info.column) {
|
||||
messsage = `BUILD${info.type} File: ${fileName}:${info.line}:${info.column}\n ${info.message}`;
|
||||
message = `BUILD${info.type} File: ${fileName}:${info.line}:${info.column}\n ${info.message}`;
|
||||
} else {
|
||||
messsage = `BUILD${info.type} File: ${fileName}\n ${info.message}`;
|
||||
message = `BUILD${info.type} File: ${fileName}\n ${info.message}`;
|
||||
}
|
||||
return messsage;
|
||||
return message;
|
||||
}
|
||||
|
||||
class ComponentInfo {
|
||||
@ -222,4 +222,4 @@ export function toHashData(path: string) {
|
||||
const hash = createHash('sha256');
|
||||
hash.update(content);
|
||||
return hash.digest('hex');
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ export interface ComponentCollection {
|
||||
}
|
||||
|
||||
export interface IComponentSet {
|
||||
propertys: Set<string>;
|
||||
properties: Set<string>;
|
||||
regulars: Set<string>;
|
||||
states: Set<string>;
|
||||
links: Set<string>;
|
||||
@ -609,7 +609,7 @@ function isNonspecificChildIfStatement(node: ts.Node, specificChildSet: Set<stri
|
||||
function collectComponentProps(node: ts.StructDeclaration): void {
|
||||
const componentName: string = node.name.getText();
|
||||
const ComponentSet: IComponentSet = getComponentSet(node);
|
||||
propertyCollection.set(componentName, ComponentSet.propertys);
|
||||
propertyCollection.set(componentName, ComponentSet.properties);
|
||||
stateCollection.set(componentName, ComponentSet.states);
|
||||
linkCollection.set(componentName, ComponentSet.links);
|
||||
propCollection.set(componentName, ComponentSet.props);
|
||||
@ -622,7 +622,7 @@ function collectComponentProps(node: ts.StructDeclaration): void {
|
||||
}
|
||||
|
||||
export function getComponentSet(node: ts.StructDeclaration): IComponentSet {
|
||||
const propertys: Set<string> = new Set();
|
||||
const properties: Set<string> = new Set();
|
||||
const states: Set<string> = new Set();
|
||||
const links: Set<string> = new Set();
|
||||
const props: Set<string> = new Set();
|
||||
@ -632,15 +632,15 @@ export function getComponentSet(node: ts.StructDeclaration): IComponentSet {
|
||||
const provides: Set<string> = new Set();
|
||||
const consumes: Set<string> = new Set();
|
||||
const objectLinks: Set<string> = new Set();
|
||||
traversalComponentProps(node, propertys, regulars, states, links, props, storageProps,
|
||||
traversalComponentProps(node, properties, regulars, states, links, props, storageProps,
|
||||
storageLinks, provides, consumes, objectLinks);
|
||||
return {
|
||||
propertys, regulars, states, links, props, storageProps, storageLinks, provides,
|
||||
properties, regulars, states, links, props, storageProps, storageLinks, provides,
|
||||
consumes, objectLinks
|
||||
};
|
||||
}
|
||||
|
||||
function traversalComponentProps(node: ts.StructDeclaration, propertys: Set<string>,
|
||||
function traversalComponentProps(node: ts.StructDeclaration, properties: Set<string>,
|
||||
regulars: Set<string>, states: Set<string>, links: Set<string>, props: Set<string>,
|
||||
storageProps: Set<string>, storageLinks: Set<string>, provides: Set<string>,
|
||||
consumes: Set<string>, objectLinks: Set<string>): void {
|
||||
@ -650,7 +650,7 @@ function traversalComponentProps(node: ts.StructDeclaration, propertys: Set<stri
|
||||
node.members.forEach(item => {
|
||||
if (ts.isPropertyDeclaration(item) && ts.isIdentifier(item.name)) {
|
||||
const propertyName: string = item.name.getText();
|
||||
propertys.add(propertyName);
|
||||
properties.add(propertyName);
|
||||
if (!item.decorators || !item.decorators.length) {
|
||||
regulars.add(propertyName);
|
||||
} else {
|
||||
@ -735,10 +735,10 @@ export function preprocessExtend(content: string, extendCollection?: Set<string>
|
||||
});
|
||||
}
|
||||
|
||||
export function processSystemApi(content: string, isProcessWhiteList: boolean = false,
|
||||
export function processSystemApi(content: string, isProcessAllowList: boolean = false,
|
||||
sourcePath: string = null, isSystemModule: boolean = false): string {
|
||||
let REG_SYSTEM: RegExp;
|
||||
if (isProcessWhiteList) {
|
||||
if (isProcessAllowList) {
|
||||
REG_SYSTEM =
|
||||
/(import|const)\s+(.+)\s*=\s*(\_\_importDefault\()?require\(\s*['"]@(system|ohos)\.(\S+)['"]\s*\)(\))?/g;
|
||||
} else {
|
||||
@ -762,9 +762,9 @@ export function processSystemApi(content: string, isProcessWhiteList: boolean =
|
||||
if (!VALIDATE_MODULE.includes(systemValue)){
|
||||
importModuleCollection.add(systemValue);
|
||||
}
|
||||
if (!isProcessWhiteList && !isSystemModule) {
|
||||
if (!isProcessAllowList && !isSystemModule) {
|
||||
return item;
|
||||
} else if (isProcessWhiteList) {
|
||||
} else if (isProcessAllowList) {
|
||||
systemValue = item2;
|
||||
moduleType = item4;
|
||||
systemKey = item5;
|
||||
@ -798,7 +798,7 @@ function processInnerModule(content: string, systemValueCollection: Set<string>)
|
||||
}
|
||||
|
||||
const VALIDATE_MODULE_REG: RegExp = new RegExp('^(' + VALIDATE_MODULE.join('|') + ')');
|
||||
function validateWhiteListModule(moduleType: string, systemKey: string): boolean {
|
||||
function validateAllowListModule(moduleType: string, systemKey: string): boolean {
|
||||
return moduleType === 'ohos' && VALIDATE_MODULE_REG.test(systemKey);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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/LICENSE2.0
|
||||
* 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,
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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/LICENSE2.0
|
||||
* 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,
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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/LICENSE2.0
|
||||
* 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,
|
||||
|
Loading…
Reference in New Issue
Block a user