diff --git a/.gitee/PULL_REQUEST_TEMPLATE.en.md b/.gitee/PULL_REQUEST_TEMPLATE.en.md index 3758df1abdb54e82dfd81d2da9e2c947c11e61aa..e8d76c6d8cb96f0ee66ae881797496b1eca37111 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.en.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.en.md @@ -12,3 +12,77 @@ _Please add detailed description_ ninja all tests ``` **All required pre-merge tests passed. Results are available in the internal CI.** + +#### Functional Testing (Mandatory unless the change only involves text) [wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E8%A6%81%E6%B1%82%E5%8F%8A%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B) +1. es2abc Test Cases (Debug Mode) +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Verifier Testing +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. 64-bit RK Compilation +- [ ] Passed +- [ ] Not applicable, no need to verify + +4. Compile macOS SDK +- [ ] Passed +- [ ] Not applicable, no need to verify + +#### Obfuscation Testing (Mandatory if ArkGuard-related changes are involved) [wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E6%B7%B7%E6%B7%86%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B?sort_id=11451209) +1. Unit Tests +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Compiler Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. TSC Extra Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +4. Test262 Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +5. Benchmark Tests +- [ ] Passed +- [ ] Not applicable, no need to verify + +6. Automated Application Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +7. Global Variable Check — Were any global variables created? If so, were they cleared? +- [ ] Global variables created and cleared +- [ ] Global variables created but not cleared +- [ ] No global variables created + +#### Compatibility Testing (for instruction generation or file format changes) +1. Minor Version Compatibility Test +- [ ] Version number added +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Major Version Compatibility Test +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. es2abc Version Compatibility Test +**Note: If the PR involves changes to version control test cases, you must also check its impact on other branches and confirm whether updates are needed in those branches.** +- [ ] Affected — Changes impact API/bytecode version and need to be synced to other branches +- [ ] Affected — Changes impact API/bytecode version but do not need to be synced to other branches +- [ ] Not affected — Changes do not involve API/bytecode version + +#### Performance Testing (e.g., new syntax checking scenarios) +- [ ] Passed +- [ ] Not applicable, no need to verify + +#### Command/abc format modification self-check, please contact the email below, synchronize to the relevant field +**Important: For modifications involving the abc2program, libpandafile and isa directories in the runtime_core repository, you must provide a compiled hap package for the helloworld project to the corresponding domain and contact the email address below.** +- [ ] Involved, already synchronized +- [ ] Not involved + +**Email:** wutao185@huawei.com \ No newline at end of file diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md index 88f741c6186ee818d97a7573724c92e25b60fc81..b2eed2595f19a7622862f5c150adb75e7c1ea992 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -16,47 +16,22 @@ ### 测试结果(测试截图直接贴在对应测试项,主干已知问题需明确引入pr/责任人) -#### 当前GGW中未添加的测试套(请在本地进行验证) -1.Fuzz编译测试 -``` -./build.sh --product-name rk3568 --build-target arkcompiler/runtime_core/tests/fuzztest:fuzztest -``` - -2."runtime_core/libpandabase/tests:host_unittest" -release模式: -``` -./build.sh --product-name rk3568 --build-target runtime_core_host_unittest -``` -debug模式: -``` -./build.sh --product-name rk3568 --build-target runtime_core_host_unittest --gn-args is_debug=true -``` - #### 功能测试(除仅涉及文本外必测项)[wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E8%A6%81%E6%B1%82%E5%8F%8A%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B) -1. test262测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 - -2. ut测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 - -3. verifier测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 +1. es2abc测试用例(Debug模式) +- [ ] 已通过 +- [ ] 不涉及,无需验证 -#### 独立编译测试(涉及BUILD.gn改动时必测项)[wiki](https://gitee.com/ark_standalone_build/docs#arkcompiler%E5%BC%80%E5%8F%91%E6%8C%87%E5%AF%BC) -1. test262 release - - [ ] 已通过 - - [ ] 不涉及,无需验证 +2. Verifier测试 +- [ ] 已通过 +- [ ] 不涉及,无需验证 -2. ut release - - [ ] 已通过 - - [ ] 不涉及,无需验证 +3. 64位RK编译 +- [ ] 已通过 +- [ ] 不涉及,无需验证 -3. ut debug - - [ ] 已通过 - - [ ] 不涉及,无需验证 +4. 编译mac平台sdk +- [ ] 已通过 +- [ ] 不涉及,无需验证 #### 混淆测试(涉及arkguard改动时必测项)[wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E6%B7%B7%E6%B7%86%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B?sort_id=11451209) 1. 单元测试 @@ -98,6 +73,12 @@ debug模式: - [ ] 已通过 - [ ] 不涉及,无需验证 +3. es2abc版本兼容性测试 +**说明:如PR涉及版本控制用例的变更,需同步检查修改对其他分支的影响,并确认是否要同步受影响的分支** + - [ ] 涉及,变更影响 API/字节码 版本, 需同步修改到其他分支 + - [ ] 涉及,变更影响 API/字节码 版本, 无需同步到其他分支 + - [ ] 不涉及,变更不涉及 API/字节码 版本 + #### 性能测试 (新增语法检查等场景) - [ ] 已通过 - [ ] 不涉及,无需验证 @@ -107,9 +88,8 @@ debug模式: - [ ] 涉及,已同步 - [ ] 不涉及 -**Email:** chenqiuyao@huawei.com +**Email:** wutao185@huawei.com ### 是否已执行L0用例 - [ ] 已验证 - [ ] 不涉及。如不涉及,请写明理由 - diff --git a/arkguard/src/ArkObfuscator.ts b/arkguard/src/ArkObfuscator.ts index 708aa9ce8911252876380236e3bea0e33f4e6ef9..2e4795e2cafe4109f447561417b9024d4da300e5 100644 --- a/arkguard/src/ArkObfuscator.ts +++ b/arkguard/src/ArkObfuscator.ts @@ -35,7 +35,13 @@ import type { import path from 'path'; -import { AtKeepCollections, LocalVariableCollections, PropCollections } from './utils/CommonCollections'; +import { + AtIntentCollections, + AtKeepCollections, + BytecodeObfuscationCollections, + LocalVariableCollections, + PropCollections +} from './utils/CommonCollections'; import type { IOptions } from './configs/IOptions'; import { FileUtils } from './utils/FileUtils'; import { TransformerManager } from './transformers/TransformerManager'; @@ -74,6 +80,7 @@ import { EventList, TimeAndMemTimeTracker, clearTimeAndMemPrinterData, + disablePrinterTimeAndMemConfig, initPerformanceTimeAndMemPrinter, } from './utils/PrinterTimeAndMemUtils'; @@ -89,9 +96,11 @@ export { } from './utils/PrinterUtils'; export { EventList, + PerfMode, TimeAndMemTimeTracker, - enableTimeAndMemoryPrint, blockTimeAndMemPrinter, + configurePerformancePrinter, + enableTimeAndMemoryPrint, } from './utils/PrinterTimeAndMemUtils'; import { Extension, type ProjectInfo, type FilePathObj } from './common/type'; export { type HvigorErrorInfo } from './common/type'; @@ -111,7 +120,7 @@ export { separateUniversalReservedItem, containWildcards, wildcardTransformer } export type { ReservedNameInfo } from './utils/TransformUtil'; export type { ReseverdSetForArkguard } from './common/ApiReader'; -export { initObfuscationConfig, initPrinterTimeAndMemConfig, printerTimeAndMemConfig, printerTimeAndMemDataConfig } from './initialization/Initializer'; +export { initObfuscationConfig, printerTimeAndMemDataConfig } from './initialization/Initializer'; export { nameCacheMap, unobfuscationNamesObj } from './initialization/CommonObject'; export { collectResevedFileNameInIDEConfig, // For running unit test. @@ -166,12 +175,15 @@ export function clearGlobalCaches(): void { UnobfuscationCollections.clear(); LocalVariableCollections.clear(); AtKeepCollections.clear(); + AtIntentCollections.clear(); renameFileNameModule.clearCaches(); clearUnobfuscationNamesObj(); clearHistoryUnobfuscatedMap(); clearTimeAndMemPrinterData(); + disablePrinterTimeAndMemConfig(); ApiExtractor.mConstructorPropertySet.clear(); ApiExtractor.mEnumMemberSet.clear(); + BytecodeObfuscationCollections.clear(); } export type ObfuscationResultType = { @@ -195,7 +207,7 @@ export class ArkObfuscator { // A text writer of Printer private mTextWriter: EmitTextWriter; - // Compiler Options for typescript,use to parse ast + // Compiler Options for typescript, use to parse ast private readonly mCompilerOptions: CompilerOptions; // User custom obfuscation profiles. @@ -348,6 +360,10 @@ export class ArkObfuscator { this.mCompilerOptions.sourceMap = true; } + if (this.mCustomProfiles.mAllowEtsAnnotations) { + this.mCompilerOptions.etsAnnotationsEnable = true; + } + const enableTopLevel: boolean = this.mCustomProfiles.mNameObfuscation?.mTopLevel; const exportObfuscation: boolean = this.mCustomProfiles.mExportObfuscation; const propertyObfuscation: boolean = this.mCustomProfiles.mNameObfuscation?.mRenameProperties; @@ -360,9 +376,8 @@ export class ArkObfuscator { this.mTransformers = new TransformerManager(this.mCustomProfiles).getTransformers(); initPerformancePrinter(this.mCustomProfiles); - - initPerformanceTimeAndMemPrinter(this.mCustomProfiles); + initPerformanceTimeAndMemPrinter(); if (needReadApiInfo(this.mCustomProfiles)) { // if -enable-property-obfuscation or -enable-export-obfuscation, collect language reserved keywords. let languageSet: Set = new Set(); @@ -454,27 +469,44 @@ export class ArkObfuscator { updatedCache[newKey] = value; continue; } + + const parts = scopeName.split('#'); + // 1: Get the last word 'zz' in '#xx#yy#zz'. + const lastScopeName: string = parts[parts.length - 1]; + const startPosition: SourceMapSegmentObj | null = sourceMapLink.traceSegment( // 1: The line number in originalCache starts from 1 while in source map starts from 0. Number(oldStartLine) - 1, Number(oldStartColumn) - 1, ''); // Minus 1 to get the correct original position. - if (!startPosition) { - // Do not save methods that do not exist in the source code, e.g. 'build' in ArkUI. + if (!startPosition && lastScopeName === value) { + // Do not save methods that do not exist in the source code and not be obfuscated, e.g. 'build' in ArkUI. continue; } const endPosition: SourceMapSegmentObj | null = sourceMapLink.traceSegment( Number(oldEndLine) - 1, Number(oldEndColumn) - 1, ''); // 1: Same as above. - if (!endPosition) { - // Do not save methods that do not exist in the source code, e.g. 'build' in ArkUI. + if (!endPosition && lastScopeName === value) { + // Do not save methods that do not exist in the source code and not be obfuscated, e.g. 'build' in ArkUI. continue; } - const startLine = startPosition.line + 1; // 1: The final line number in updatedCache should starts from 1. - const endLine = endPosition.line + 1; // 1: Same as above. - newKey = `${scopeName}:${startLine}:${endLine}`; - updatedCache[newKey] = value; + + if (!startPosition || !endPosition) { + updatedCache[scopeName] = value; + } else { + const startLine = startPosition.line + 1; // 1: The final line number in updatedCache should starts from 1. + const endLine = endPosition.line + 1; // 1: Same as above. + newKey = `${scopeName}:${startLine}:${endLine}`; + updatedCache[newKey] = value; + } } return updatedCache; } + public convertLineBasedOnSourceMapForTest( + targetCache: string, + sourceMapLink?: SourceMapLink + ): Map { + return this.convertLineBasedOnSourceMap(targetCache, sourceMapLink); + } + /** * Obfuscate ast of a file. * @param content ast or source code of a source file @@ -541,7 +573,7 @@ export class ArkObfuscator { startSingleFileEvent(EventList.CREATE_AST, performancePrinter.timeSumPrinter); let ast: SourceFile; if (typeof content === 'string') { - ast = TypeUtils.createObfSourceFile(sourceFilePath, content); + ast = TypeUtils.createObfSourceFile(sourceFilePath, content, this.mCompilerOptions); } else { ast = content; } diff --git a/arkguard/src/common/ApiExtractor.ts b/arkguard/src/common/ApiExtractor.ts index b6450ea21241063c734459db5816777470391d1c..e286f7d418071481928c6cd0f9e247856189b18d 100644 --- a/arkguard/src/common/ApiExtractor.ts +++ b/arkguard/src/common/ApiExtractor.ts @@ -14,15 +14,20 @@ */ import type { + AnnotationDeclaration, ClassDeclaration, CommentRange, + CompilerOptions, + Decorator, ElementAccessExpression, EnumDeclaration, ExportDeclaration, + Expression, FunctionDeclaration, InterfaceDeclaration, ModifiersArray, ModuleDeclaration, + NamedDeclaration, Node, ParameterDeclaration, PropertyAccessExpression, @@ -37,6 +42,7 @@ import { ClassElement, forEachChild, getLeadingCommentRangesOfNode, + isAnnotationDeclaration, isBinaryExpression, isClassDeclaration, isClassExpression, @@ -76,7 +82,9 @@ import { isParameter, isTypeParameterDeclaration, isIndexedAccessTypeNode, - Extension + Extension, + isCallExpression, + isDecorator } from 'typescript'; import fs from 'fs'; @@ -99,8 +107,13 @@ import { scanProjectConfig } from './ApiReader'; import { enumPropsSet } from '../utils/OhsUtil'; import { FileUtils } from '../utils/FileUtils'; import { supportedParsingExtension } from './type'; -import { addToSet, FileWhiteList, KeepInfo, projectWhiteListManager } from '../utils/ProjectCollections'; -import { AtKeepCollections } from '../utils/CommonCollections'; +import { + addToSet, + DECORATOR_WHITE_LIST, + FileWhiteList, KeepInfo, + projectWhiteListManager +} from '../utils/ProjectCollections'; +import { AtKeepCollections, BytecodeObfuscationCollections, PropCollections } from '../utils/CommonCollections'; import { hasExportModifier } from '../utils/NodeUtils'; export namespace ApiExtractor { @@ -135,7 +148,8 @@ export namespace ApiExtractor { | FunctionDeclaration | ModuleDeclaration | VariableDeclaration - | TypeAliasDeclaration; + | TypeAliasDeclaration + | AnnotationDeclaration; const KEEP_SYMBOL = '//@KeepSymbol'; const KEEP_AS_CONSUMER = '//@KeepAsConsumer'; @@ -143,6 +157,8 @@ export namespace ApiExtractor { let mCurrentExportedPropertySet: Set = new Set(); let mCurrentExportNameSet: Set = new Set(); + let decoratorMap: Map> = new Map>(); + let keepSymbolTemp: KeepInfo = { propertyNames: new Set(), globalNames: new Set(), @@ -688,11 +704,18 @@ export namespace ApiExtractor { projectWhiteListManager?.setCurrentCollector(fileName); - const sourceFile: SourceFile = createSourceFile(fileName, fs.readFileSync(fileName).toString(), ScriptTarget.ES2015, true); + let sourceFile: SourceFile = createSourceFile(fileName, fs.readFileSync(fileName).toString(), ScriptTarget.ES2015, true, undefined, { + etsAnnotationsEnable: true + }, true); mCurrentExportedPropertySet.clear(); collectWhiteListByApiType(sourceFile, apiType, fileName); + // collect field decorated by UI + if (scanProjectConfig.scanDecorator) { + collectAndAddFieldDecorator(sourceFile); + } + // collect names marked with '// @KeepSymbol' or '// @KeepAsConsumer', only support .ts/.ets if (shouldCollectAtKeep(fileName)) { collectAndAddAtKeepNames(sourceFile); @@ -710,6 +733,7 @@ export namespace ApiExtractor { mCurrentExportedPropertySet.forEach(item => mPropertySet.add(item)); mCurrentExportedPropertySet.clear(); exportOriginalNameSet.clear(); + decoratorMap.clear(); }; function shouldCollectAtKeep(fileName: string): boolean { @@ -756,6 +780,59 @@ export namespace ApiExtractor { addToSet(fileWhiteLists.fileKeepInfo.keepAsConsumer.globalNames, keepAsConsumerTemp.globalNames); addToSet(fileWhiteLists.fileKeepInfo.keepAsConsumer.propertyNames, keepAsConsumerTemp.propertyNames); } + if (scanProjectConfig.scanDecorator) { + const convertedMap = new Map( + Array.from(decoratorMap.entries()).map(([key, value]) => [key, Array.from(value)])); + if (!fileWhiteLists.bytecodeObfuscateKeepInfo) { + fileWhiteLists.bytecodeObfuscateKeepInfo = {}; + } + fileWhiteLists.bytecodeObfuscateKeepInfo.decoratorMap = Object.fromEntries(convertedMap); + const allProp = Array.from(convertedMap.values()).flat(); + allProp.forEach(value => BytecodeObfuscationCollections.decoratorProp.add(value)); + } + } + + function collectAndAddFieldDecorator(sourceFile: SourceFile): void { + visitDecorator(sourceFile); + } + + function getDecorators(node: Node): Decorator[] { + const decorators: Decorator[] = []; + forEachChild(node, child => { + if (isDecorator(child)) { + decorators.push(child); + } + }); + return decorators; + } + + function visitDecorator(node: Node): void { + const decorators = getDecorators(node) || []; + const propertyName = (node as NamedDeclaration).name?.getText(); + if (!propertyName) { + forEachChild(node, visitDecorator); + return; + } + + decorators.forEach(decorator => { + const expr = decorator.expression; + const decoratorName = getDecoratorName(expr); + if (!decoratorName || !isWhiteListedDecorator(decoratorName)) { + return; + } + ensureEntry(decoratorMap, decoratorName, () => new Set()); + const decoratorSet = decoratorMap.get(decoratorName)!; + + if (isCallExpression(expr)) { + expr.arguments.forEach(arg => { + const stripped = arg.getText().replace(/^['"]|['"]$/g, '').split('.'); + stripped.forEach(item => decoratorSet.add(item)); + }); + } + decoratorSet.add(propertyName); + + }); + forEachChild(node, visitDecorator); } function collectWhiteListByApiType(sourceFile: SourceFile, apiType: ApiType, fileName: string): void { @@ -1125,6 +1202,9 @@ export namespace ApiExtractor { case SyntaxKind.ModuleDeclaration: collectModuleDeclaration(node as ModuleDeclaration, sourceFile); break; + case SyntaxKind.AnnotationDeclaration: + collectAnnotationDeclaration(node as AnnotationDeclaration, sourceFile); + break; } forEachChild(node, child => collectNamesWithAtKeep(child, sourceFile)); } @@ -1361,6 +1441,13 @@ export namespace ApiExtractor { } } + function collectAnnotationDeclaration(node: AnnotationDeclaration, sourceFile: SourceFile): void { + const atKeepType: AtKeepType = getAtKeepType(node, sourceFile); + const isToplevel: boolean = isSourceFile(node.parent); + const isExported: boolean = hasExportModifier(node); + collectToplevelOrExportedNames(node, isToplevel, isExported, atKeepType); + } + function getAtKeepType(node: Node, sourceFile: SourceFile): AtKeepType { const ranges: CommentRange[] | undefined = getLeadingCommentRangesOfNode(node, sourceFile); let atKeepType: AtKeepType = AtKeepType.None; @@ -1414,4 +1501,24 @@ export namespace ApiExtractor { collector.globalNames.add(name); } } -} + + function ensureEntry(map: Map, key: K, createValue: () => V): void { + if (!map.has(key)) { + map.set(key, createValue()); + } + } + + function isWhiteListedDecorator(name: string): boolean { + return DECORATOR_WHITE_LIST.includes(name); + } + + function getDecoratorName(expr: Expression): string | undefined { + if (isCallExpression(expr)) { + return expr.expression.getText(); + } + if (isIdentifier(expr)) { + return expr.text; + } + return undefined; + } +} \ No newline at end of file diff --git a/arkguard/src/common/ApiReader.ts b/arkguard/src/common/ApiReader.ts index aecec4c60026d8889e52d7c96644b0de3d6ac4a2..0504003668884fbe480ef5a4a2545b3b0edcb7e9 100644 --- a/arkguard/src/common/ApiReader.ts +++ b/arkguard/src/common/ApiReader.ts @@ -28,7 +28,8 @@ export interface ScanProjectConfig { mkeepFilesAndDependencies?: Set, isHarCompiled?: boolean, mStripSystemApiArgs?: boolean, - mEnableAtKeep: boolean + mEnableAtKeep: boolean, + scanDecorator?: boolean; } // Settings for collect white lists. @@ -71,13 +72,18 @@ export function isEnabledPropertyObfuscation(customProfiles: IOptions): boolean customProfiles.mNameObfuscation.mRenameProperties); } -function initScanProjectConfig(customProfiles: IOptions, isHarCompiled?: boolean): void { +export function initScanProjectConfig( + customProfiles: IOptions, + isHarCompiled?: boolean, + scanDecorator: boolean = false +): void { scanProjectConfig.mPropertyObfuscation = customProfiles.mNameObfuscation?.mRenameProperties; scanProjectConfig.mKeepStringProperty = customProfiles.mNameObfuscation?.mKeepStringProperty; scanProjectConfig.mExportObfuscation = customProfiles.mExportObfuscation; scanProjectConfig.mkeepFilesAndDependencies = customProfiles.mKeepFileSourceCode?.mkeepFilesAndDependencies; scanProjectConfig.isHarCompiled = isHarCompiled; scanProjectConfig.mEnableAtKeep = customProfiles.mNameObfuscation?.mEnableAtKeep; + scanProjectConfig.scanDecorator = scanDecorator; } /** @@ -109,7 +115,7 @@ export interface ReseverdSetForArkguard { * @param customProfiles */ export function readProjectPropertiesByCollectedPaths(filesForCompilation: Set, - customProfiles: IOptions, isHarCompiled: boolean): ReseverdSetForArkguard { + customProfiles: IOptions, isHarCompiled: boolean, scanDecorator: boolean = false): ReseverdSetForArkguard { const apiType = ApiExtractor.ApiType; let scanningCommonType = undefined; if (needReadApiInfo(customProfiles)) { @@ -118,7 +124,7 @@ export function readProjectPropertiesByCollectedPaths(filesForCompilation: Set 0) { resultStr += ObConfigResolver.KEEP_GLOBAL_NAME + '\n'; this.reservedGlobalNames.forEach((item) => { @@ -250,10 +272,19 @@ export class ObConfigResolver { this.handleReservedArray(mergedConfigs); endFilesEvent(EventList.RESOLVE_OBFUSCATION_CONFIGS); + /** + * Bytecode obfuscate mode: + * temporary variable or in non-top-level scope is obfuscated to be added to the obfuscate name set, + * All names that appear in the confused name collection will be obfuscated later + * So when a developer-defined name has the same name as systemApi + * Without a whitelist, all the same names would be obfuscated, leading to devastating errors + * so in order to work properly, Bytecode obfuscate enables the obfuscate function and requires whitelist + */ let needKeepSystemApi = enableObfuscation && (mergedConfigs.options.enablePropertyObfuscation || - (mergedConfigs.options.enableExportObfuscation && mergedConfigs.options.enableToplevelObfuscation)); + (mergedConfigs.options.enableExportObfuscation && mergedConfigs.options.enableToplevelObfuscation) || + mergedConfigs.options.bytecodeObf.enable); if (needKeepSystemApi && sourceObConfig.obfuscationCacheDir) { const systemApiCachePath: string = path.join(sourceObConfig.obfuscationCacheDir, 'systemApiCache.json'); @@ -270,8 +301,8 @@ export class ObConfigResolver { } } - // when atKeep is enabled, we can not emit here since we need to collect names marked with atKeep - if (!mergedConfigs.options.enableAtKeep) { + // when obfuscation is enabled, we need to emit consumerConfig files after collecting whitelist. + if (!enableObfuscation) { this.emitConsumerConfigFiles(); } return mergedConfigs; @@ -364,6 +395,11 @@ export class ObConfigResolver { static readonly PRINT_NAMECACHE = '-print-namecache'; static readonly PRINT_KEPT_NAMES = '-print-kept-names'; static readonly APPLY_NAMECACHE = '-apply-namecache'; + // obfuscation options for bytecode obfuscation + static readonly ENABLE_BYTECODE_OBFUSCATION = '-enable-bytecode-obfuscation'; + static readonly ENABLE_BYTECODE_OBFUSCATION_DEBUGGING = '-enable-bytecode-obfuscation-debugging'; + static readonly ENABLE_BYTECODE_OBFUSCATION_ENHANCED = '-enable-bytecode-obfuscation-enhanced'; + static readonly ENABLE_BYTECODE_OBFUSCATION_ARKUI = '-enable-bytecode-obfuscation-arkui'; static readonly EXTRA_OPTIONS = '-extra-options'; static readonly STRIP_LANGUAGE_DEFAULT = 'strip-language-default'; static readonly STRIP_SYSTEM_API_ARGS = 'strip-system-api-args'; @@ -380,6 +416,14 @@ export class ObConfigResolver { private getTokenType(token: string): OptionType { switch (token) { + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION: + return OptionType.ENABLE_BYTECODE_OBFUSCATION; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_ENHANCED: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_ENHANCED; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_ARKUI: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_ARKUI; case ObConfigResolver.KEEP_DTS: return OptionType.KEEP_DTS; case ObConfigResolver.KEEP_GLOBAL_NAME: @@ -450,6 +494,26 @@ export class ObConfigResolver { tokenType = this.getTokenType(token); // handle switches cases switch (tokenType) { + case OptionType.ENABLE_BYTECODE_OBFUSCATION: { + configs.options.bytecodeObf.enable = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING: { + configs.options.bytecodeObf.debugging = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_ENHANCED: { + configs.options.bytecodeObf.enhanced = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_ARKUI: { + configs.options.bytecodeObf.obfArkUI = true; + extraOptionType = OptionType.NONE; + continue; + } case OptionType.DISABLE_OBFUSCATION: { configs.options.disableObfuscation = true; extraOptionType = OptionType.NONE; @@ -719,7 +783,7 @@ export class ObConfigResolver { } const arkUIReservedPropertyNames: string[] = this.collectUIApiWhitelist(existPreDefineFilePath, existArkUIWhitelistPath, config); let systemApiContent: SystemApiContent = {}; - if (config.options.enablePropertyObfuscation) { + if (config.options.enablePropertyObfuscation || config.options.bytecodeObf?.enable) { if (!config.options.stripSystemApiArgs) { UnobfuscationCollections.reservedSdkApiForLocal = new Set(ApiExtractor.mPropertySet); systemApiContent.ReservedLocalNames = Array.from(ApiExtractor.mPropertySet); @@ -728,7 +792,8 @@ export class ObConfigResolver { UnobfuscationCollections.reservedSdkApiForProp = savedNameAndPropertySet; systemApiContent.ReservedPropertyNames = Array.from(savedNameAndPropertySet); } - if (config.options.enableToplevelObfuscation && config.options.enableExportObfuscation) { + if ((config.options.enableToplevelObfuscation && config.options.enableExportObfuscation) || + config.options.bytecodeObf?.enable) { const savedExportNamesSet = new Set(ApiExtractor.mSystemExportSet); UnobfuscationCollections.reservedSdkApiForGlobal = savedExportNamesSet; systemApiContent.ReservedGlobalNames = Array.from(savedExportNamesSet); @@ -879,6 +944,7 @@ export class ObConfigResolver { selfConsumerConfig.mergeAllRules(dependencyConfigs); } this.addKeepConsumer(selfConsumerConfig, AtKeepCollections.keepAsConsumer); + this.addIntentCollections(selfConsumerConfig, AtIntentCollections); selfConsumerConfig.sortAndDeduplicate(); this.writeConsumerConfigFile(selfConsumerConfig, sourceObConfig.exportRulePath); } @@ -892,6 +958,15 @@ export class ObConfigResolver { }); } + private addIntentCollections(selfConsumerConfig: MergedConfig, intentCollections: KeepInfo): void { + intentCollections.propertyNames.forEach((propertyName) => { + selfConsumerConfig.reservedPropertyNames.push(propertyName); + }); + intentCollections.globalNames.forEach((globalName) =>{ + selfConsumerConfig.reservedGlobalNames.push(globalName); + }); + } + public genConsumerConfigFilesForTest( sourceObConfig: SourceObConfig, selfConsumerConfig: MergedConfig, @@ -1211,6 +1286,11 @@ export function printWhitelist(obfuscationOptions: ObOptions, nameOptions: IName whitelistObj.conf.push(...atKeepSet); } + let atIndentSet: Set = new Set(); + addToSet(atIndentSet, AtIntentCollections.propertyNames); + addToSet(atIndentSet, AtIntentCollections.globalNames); + whitelistObj.conf.push(...atIndentSet); + let enumSet: Set; if (enableProperty) { enumSet = UnobfuscationCollections.reservedEnum; @@ -1316,7 +1396,8 @@ export function enableObfuscatedFilePathConfig(isPackageModules: boolean, projec } const disableObfuscation = hasObfuscationConfig.options.disableObfuscation; const enableFileNameObfuscation = hasObfuscationConfig.options.enableFileNameObfuscation; - if (disableObfuscation || !enableFileNameObfuscation) { + const enableBytecodeObfuscation = hasObfuscationConfig.options.bytecodeObf?.enable; + if (disableObfuscation || !enableFileNameObfuscation || enableBytecodeObfuscation) { return false; } return true; diff --git a/arkguard/src/initialization/Initializer.ts b/arkguard/src/initialization/Initializer.ts index f8eef2a751a17ad88d2627f24997d825c4f14b61..c0262eb890c69e2a7f803189362af4436709841d 100644 --- a/arkguard/src/initialization/Initializer.ts +++ b/arkguard/src/initialization/Initializer.ts @@ -20,7 +20,7 @@ import { ArkObfuscator, blockPrinter, renameIdentifierModule } from '../ArkObfus import { collectResevedFileNameInIDEConfig, MergedConfig, ObConfigResolver, readNameCache } from './ConfigResolver'; import { type IOptions } from '../configs/IOptions'; import type { HvigorErrorInfo } from '../common/type'; -import { getObfuscationCacheDir } from '../utils/PrinterTimeAndMemUtils'; +import { blockTimeAndMemPrinter, getObfuscationCacheDir } from '../utils/PrinterTimeAndMemUtils'; // Record all unobfuscated properties and reasons. export const historyUnobfuscatedPropMap: Map = new Map(); @@ -44,13 +44,6 @@ export const printerConfig = { mOutputPath: '', }; -export const printerTimeAndMemConfig = { - // A sub-switch of mTimeAndMemPrinter used to control the obfuscation performance printing of files - mFilesPrinter: false, - // A sub-switch of mTimeAndMemPrinter used to control the obfuscation performance printing of singlefile - mSingleFilePrinter: false, -}; - export const printerTimeAndMemDataConfig = { // The switch for printing obfuscation performance data and memory data mTimeAndMemPrinter: false, @@ -58,22 +51,27 @@ export const printerTimeAndMemDataConfig = { mMoreTimePrint: false, }; -// Initialize the configuration of the TimeAndMem performance printer -export function initPrinterTimeAndMemConfig() { - printerTimeAndMemConfig.mFilesPrinter = true; - printerTimeAndMemConfig.mSingleFilePrinter = true; - printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; -} export function initObfuscationConfig(projectConfig: any, arkProjectConfig: any, printObfLogger: Function): void { const obConfig: ObConfigResolver = new ObConfigResolver(projectConfig, printObfLogger, true); - const mergedObConfig: MergedConfig = obConfig.resolveObfuscationConfigs(); + let mergedObConfig: MergedConfig = obConfig.resolveObfuscationConfigs(); + if (arkProjectConfig.allowEtsAnnotations) { + mergedObConfig.options.enableEtsAnnotation = arkProjectConfig.allowEtsAnnotations; + } const isHarCompiled: boolean = projectConfig.compileHar; - getObfuscationCacheDir(projectConfig); if (mergedObConfig.options.disableObfuscation) { blockPrinter(); + blockTimeAndMemPrinter(); return; } + getObfuscationCacheDir(projectConfig); + /** + * Only one of bytecode obfuscation and source code obfuscation will take effect. + * Enabling bytecode obfuscation is to obfuscate declaration files when compile bytecode har. + */ + const isBytecodeObfEnabled = mergedObConfig.options.bytecodeObf.enable; + arkProjectConfig.isBytecodeObfEnabled = isBytecodeObfEnabled; + arkProjectConfig.isArkguardEnabled = !isBytecodeObfEnabled; if (mergedObConfig.options.enableFileNameObfuscation) { const ohPackagePath = path.join(projectConfig.modulePath, 'oh-package.json5'); @@ -139,12 +137,12 @@ function initArkGuardConfig( }, mExportObfuscation: mergedObConfig.options.enableExportObfuscation, mPerformancePrinter: printerConfig, - mPerformanceTimeAndMemPrinter: printerTimeAndMemConfig, mKeepFileSourceCode: { mKeepSourceOfPaths: new Set(), mkeepFilesAndDependencies: new Set(), }, - mStripLanguageDefaultWhitelist: mergedObConfig.options.stripLanguageDefault + mStripLanguageDefaultWhitelist: mergedObConfig.options.stripLanguageDefault, + mAllowEtsAnnotations: mergedObConfig.options.enableEtsAnnotation, }; const arkObfuscator: ArkObfuscator = new ArkObfuscator(); diff --git a/arkguard/src/transformers/rename/RenameFileNameTransformer.ts b/arkguard/src/transformers/rename/RenameFileNameTransformer.ts index bab1c891c39391796433797c265b35099bd697a5..eab7543b3bf46ba08ed1c21bbbea4029c656cc33 100644 --- a/arkguard/src/transformers/rename/RenameFileNameTransformer.ts +++ b/arkguard/src/transformers/rename/RenameFileNameTransformer.ts @@ -101,7 +101,6 @@ namespace secharmony { const tempReservedName: string[] = ['.', '..', '']; configReservedFileNameOrPath.map(fileNameOrPath => { if (!fileNameOrPath || fileNameOrPath.length === 0) { - endFilesEvent(EventList.FILENAME_OBFUSCATION_INITIALIZATION); return; } const directories = FileUtils.splitFilePath(fileNameOrPath); diff --git a/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts b/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts index 53c45994d4253f398d5a66e9d02ee7b4eea498bf..f27fda5560042823bb4614265749b3884e25553c 100644 --- a/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts +++ b/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts @@ -39,7 +39,8 @@ import { isPropertyAssignment, isPrivateIdentifier, isParameter, - isPropertyAccessExpression + isPropertyAccessExpression, + isAnnotationDeclaration } from 'typescript'; import type { @@ -84,7 +85,7 @@ import type {INameGenerator, NameGeneratorOptions} from '../../generator/INameGe import type {IOptions} from '../../configs/IOptions'; import type { INameObfuscationOption, IUnobfuscationOption } from '../../configs/INameObfuscationOption'; import type {TransformPlugin} from '../TransformPlugin'; -import type { MangledSymbolInfo } from '../../common/type'; +import { annotationPrefix, type MangledSymbolInfo } from '../../common/type'; import {TransformerOrder} from '../TransformPlugin'; import {getNameGenerator, NameGeneratorType} from '../../generator/NameFactory'; import {TypeUtils} from '../../utils/TypeUtils'; @@ -99,12 +100,14 @@ import { } from '../../utils/TransformUtil'; import {NodeUtils} from '../../utils/NodeUtils'; import {ApiExtractor} from '../../common/ApiExtractor'; -import {performancePrinter, ArkObfuscator, cleanFileMangledNames} from '../../ArkObfuscator'; +import {performancePrinter, ArkObfuscator, cleanFileMangledNames, FileUtils} from '../../ArkObfuscator'; import { endSingleFileEvent, startSingleFileEvent } from '../../utils/PrinterUtils'; import { EventList, endSingleFileForMoreTimeEvent, startSingleFileForMoreTimeEvent } from '../../utils/PrinterTimeAndMemUtils'; import { isViewPUBasedClass } from '../../utils/OhsUtil'; import { + AtIntentCollections, AtKeepCollections, + BytecodeObfuscationCollections, LocalVariableCollections, PropCollections, UnobfuscationCollections @@ -153,6 +156,7 @@ namespace secharmony { let mangledLabelNames: Map = new Map(); let fileExportNames: Set = undefined; let fileImportNames: Set = undefined; + let currentFileType: string | undefined = undefined; exportElementsWithoutSymbol.clear(); exportSymbolAliasMap.clear(); nodeSymbolMap.clear(); @@ -181,6 +185,7 @@ namespace secharmony { if (!isSourceFile(node) || ArkObfuscator.isKeptCurrentFile) { return node; } + currentFileType = FileUtils.getFileSuffix(node.fileName).ext; isCurFileParamertersKept = shouldKeepCurFileParamerters(node, profile); const checkRecordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.CREATE_CHECKER); @@ -191,7 +196,7 @@ namespace secharmony { const scopeRecordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.SCOPE_ANALYZE); startSingleFileEvent(EventList.SCOPE_ANALYZE, performancePrinter.timeSumPrinter); - manager.analyze(node, checker, exportObfuscation); + manager.analyze(node, checker, exportObfuscation, currentFileType); endSingleFileEvent(EventList.SCOPE_ANALYZE, performancePrinter.timeSumPrinter); ArkObfuscator.stopRecordStage(scopeRecordInfo); @@ -312,11 +317,10 @@ namespace secharmony { recordHistoryUnobfuscatedNames(path); // For incremental build mangled = historyName; } else if (Reflect.has(def, 'obfuscateAsProperty')) { - // obfuscate toplevel, export - mangled = getPropertyMangledName(original, path); + mangled = getPropertyOrAnnotationMangledName(original, path); } else { // obfuscate local variable - mangled = getMangled(scope, generator); + mangled = getMangledLocalName(scope, generator); } // add new names to name cache let identifierCache = nameCache?.get(IDENTIFIER_CACHE); @@ -381,11 +385,7 @@ namespace secharmony { return mangledName; } - function getPropertyMangledName(original: string, nameWithScope: string): string { - if (isInTopLevelWhitelist(original, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { - return original; - } - + function getMangledName(original: string): string { const historyName: string = PropCollections.historyMangledTable?.get(original); let mangledName: string = historyName ? historyName : PropCollections.globalMangledTable.get(original); while (!mangledName) { @@ -442,6 +442,35 @@ namespace secharmony { return mangledName; } + function getPropertyMangledName(originalName: string, nameWithScope: string): string { + if (isInTopLevelWhitelist(originalName, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { + return originalName; + } + + let mangledName = getMangledName(originalName); + return mangledName; + } + + // mangle annotation name in intermediate files + function getAnnotationMangledNameWithPrefix(originalName: string, nameWithScope: string): string { + if (isInTopLevelWhitelist(originalName, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { + return `${annotationPrefix}${originalName}`; + } + let mangledName: string = `${annotationPrefix}${getMangledName(originalName)}`; + return mangledName; + } + + function getPropertyOrAnnotationMangledName(originalName: string, nameWithScope: string): string { + let name: string | undefined = originalName.startsWith(annotationPrefix) ? originalName.substring(annotationPrefix.length) : undefined; + if (name) { + // obfuscate annotation name with prefix, e.g. in intermediate files + return getAnnotationMangledNameWithPrefix(name, nameWithScope); + } else { + // obfuscate toplevel, export + return getPropertyMangledName(originalName, nameWithScope); + } + } + function isExcludeScope(scope: Scope): boolean { if (isClassScope(scope)) { return true; @@ -473,7 +502,7 @@ namespace secharmony { return found; } - function getMangled(scope: Scope, localGenerator: INameGenerator): string { + function getMangledLocalName(scope: Scope, localGenerator: INameGenerator): string { let mangled: string = ''; do { mangled = localGenerator.getName()!; @@ -846,9 +875,9 @@ namespace secharmony { tmpReservedProps.forEach(item => { PropCollections.reservedProperties.add(item); }); - PropCollections.globalMangledNamesInCache = new Set(PropCollections.historyMangledTable?.values()); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepSymbol.propertyNames); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepAsConsumer.propertyNames); + addToSet(PropCollections.reservedProperties, AtIntentCollections.propertyNames); if (profile?.mUniversalReservedProperties) { PropCollections.universalReservedProperties = [...profile.mUniversalReservedProperties]; @@ -863,10 +892,13 @@ namespace secharmony { UnobfuscationCollections.reservedSdkApiForProp.add(element); }); } + PropCollections.globalMangledNamesInCache = new Set(PropCollections.historyMangledTable?.values()); LocalVariableCollections.reservedConfig = new Set(profile?.mReservedNames ?? []); profile?.mReservedToplevelNames?.forEach(item => PropCollections.reservedProperties.add(item)); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepSymbol.globalNames); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepAsConsumer.globalNames); + addToSet(PropCollections.reservedProperties, AtIntentCollections.globalNames); + addToSet(UnobfuscationCollections.reservedSdkApiForProp, BytecodeObfuscationCollections.decoratorProp); profile?.mUniversalReservedToplevelNames?.forEach(item => PropCollections.universalReservedProperties.push(item)); isInitializedReservedList = true; } diff --git a/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts b/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts index d181c6f0ea1bf8733a75fe3e24f1bc26e9d90840..89fa6abb42b1ef9e7a04206c0f65fb65cf7c30e3 100644 --- a/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts +++ b/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts @@ -47,6 +47,7 @@ import type { TypeNode } from 'typescript'; +import { annotationPrefix } from '../../common/type'; import type {IOptions} from '../../configs/IOptions'; import type { INameObfuscationOption } from '../../configs/INameObfuscationOption'; import type {TransformPlugin} from '../TransformPlugin'; @@ -65,6 +66,7 @@ import { globalGenerator, nameCache } from './RenameIdentifierTransformer'; +import { FileUtils } from '../../ArkObfuscator'; import { UpdateMemberMethodName } from '../../utils/NameCacheUtil'; import { PropCollections, UnobfuscationCollections } from '../../utils/CommonCollections'; import { MemoryDottingDefine } from '../../utils/MemoryDottingDefine'; @@ -86,14 +88,14 @@ namespace secharmony { return renamePropertiesFactory; function renamePropertiesFactory(context: TransformationContext): Transformer { - + let currentFileType: string | undefined = undefined; return renamePropertiesTransformer; function renamePropertiesTransformer(node: Node): Node { if (isSourceFile(node) && ArkObfuscator.isKeptCurrentFile) { return node; } - + currentFileType = isSourceFile(node) ? FileUtils.getFileSuffix(node.fileName).ext : undefined; const recordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.PROPERTY_OBFUSCATION); startSingleFileEvent(EventList.PROPERTY_OBFUSCATION, performancePrinter.timeSumPrinter); @@ -115,6 +117,10 @@ namespace secharmony { } function renameProperties(node: Node): Node { + if (NodeUtils.isObjectLiteralInAnnotation(node, currentFileType)) { + return node; + } + if (!NodeUtils.isPropertyNode(node)) { return visitEachChild(node, renameProperties, context); } @@ -204,7 +210,13 @@ namespace secharmony { return node; } - let mangledName: string = getPropertyName(original); + let mangledName: string = original; + let name: string | undefined = original.startsWith(annotationPrefix) ? original.substring(annotationPrefix.length) : undefined; + if (name) { + mangledName = getAnnotationMangledNameWithPrefix(name); + } else { + mangledName = getPropertyMangledName(original); + } if (isStringLiteralLike(node)) { return factory.createStringLiteral(mangledName); @@ -233,7 +245,17 @@ namespace secharmony { return factory.createPrivateIdentifier('#' + mangledName); } - function getPropertyName(original: string): string { + function getPropertyMangledName(original: string): string { + let mangledName: string = getMangledName(original); + return mangledName; + } + + function getAnnotationMangledNameWithPrefix(original: string): string { + let mangledName: string = `${annotationPrefix}${getMangledName(original)}`; + return mangledName; + } + + function getMangledName(original: string): string { const historyName: string = PropCollections.historyMangledTable?.get(original); let mangledName: string = historyName ? historyName : PropCollections.globalMangledTable.get(original); while (!mangledName) { diff --git a/arkguard/src/utils/CommonCollections.ts b/arkguard/src/utils/CommonCollections.ts index 1db093f1eb3792385b1b8f8d3ee23e43cc2d5746..aa31e00fd0afd2bdd208b208f11b5a28c063c788 100644 --- a/arkguard/src/utils/CommonCollections.ts +++ b/arkguard/src/utils/CommonCollections.ts @@ -104,4 +104,22 @@ export namespace AtKeepCollections { keepAsConsumer.globalNames.clear(); keepAsConsumer.propertyNames.clear(); }; +} + +export namespace AtIntentCollections{ + export let propertyNames: Set = new Set(); + export let globalNames: Set = new Set(); + + export function clear(): void{ + propertyNames.clear(); + globalNames.clear(); + } +} + +export namespace BytecodeObfuscationCollections { + export let decoratorProp: Set = new Set(); + + export function clear(): void { + decoratorProp.clear(); + } } \ No newline at end of file diff --git a/arkguard/src/utils/NodeUtils.ts b/arkguard/src/utils/NodeUtils.ts index 08acca40723273c72bc7d30130cfa613ff73733e..c4701cc0af97cc4d0ffaca03deb8bfc42884ce1f 100644 --- a/arkguard/src/utils/NodeUtils.ts +++ b/arkguard/src/utils/NodeUtils.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +import { FileUtils } from './FileUtils'; import type { Expression, Identifier, @@ -24,7 +25,8 @@ import type { TransformerFactory, StringLiteralLike, NumericLiteral, - PrivateIdentifier + PrivateIdentifier, + PropertyAccessExpression, } from 'typescript'; import { canHaveModifiers, @@ -38,6 +40,7 @@ import { isClassExpression, isComputedPropertyName, isConstructorDeclaration, + isDecoratorOrAnnotation, isElementAccessExpression, isEnumMember, isGetAccessor, @@ -59,7 +62,8 @@ import { isVariableDeclaration, visitEachChild, isLiteralTypeNode, - isStringLiteralLike + isStringLiteralLike, + isObjectLiteralExpression } from 'typescript'; import { getViewPUClassProperties, @@ -67,7 +71,7 @@ import { isViewPUBasedClass, visitEnumInitializer } from './OhsUtil'; -import { Extension } from '../common/type'; +import { annotationPrefix, Extension } from '../common/type'; import { MergedConfig } from '../initialization/ConfigResolver'; export class NodeUtils { @@ -253,6 +257,36 @@ export class NodeUtils { return initializer && isCallExpression(initializer); } + public static isObjectLiteralInAnnotation(node: Node, currentFileType: string): boolean { + if (!node || !node.parent || !isObjectLiteralExpression(node) || !isCallExpression(node.parent) || !isDecoratorOrAnnotation(node.parent.parent)) { + return false; + } + if (currentFileType === Extension.DETS) { + return true; + } + const expr = node.parent.expression; + let name: string | undefined = undefined; + switch (expr.kind) { + case SyntaxKind.Identifier: + // @Anno({a: 0}), get 'Anno' + name = (expr as Identifier).text; + break; + case SyntaxKind.PropertyAccessExpression: + // @ns.Anno({a: 0}), get 'Anno' + name = (expr as PropertyAccessExpression).name.text; + break; + default: + name = undefined; + } + if (!name) { + return false; + } + if (currentFileType === Extension.TS && name.startsWith(annotationPrefix)) { + return true; + } + return false; + } + public static isDeclarationFile(node: SourceFile): boolean { return node.isDeclarationFile; } diff --git a/arkguard/src/utils/PrinterTimeAndMemUtils.ts b/arkguard/src/utils/PrinterTimeAndMemUtils.ts index b8b714f8f82317e2f89330e0554512c38a3ec82e..24c03c900b88066839d1174cee987d4f8bb22e07 100644 --- a/arkguard/src/utils/PrinterTimeAndMemUtils.ts +++ b/arkguard/src/utils/PrinterTimeAndMemUtils.ts @@ -21,6 +21,12 @@ import { performance } from 'perf_hooks'; import { performanceTimeAndMemPrinter } from '../ArkObfuscator'; import { printerTimeAndMemDataConfig } from '../initialization/Initializer'; +// DevEco Studio perf mode +export enum PerfMode { + NORMAL = 0, // Normal mode + ADVANCED = 1, // Advanced mode +}; + export enum EventList { OBFUSCATION_INITIALIZATION = 'Obfuscation initialization', SCAN_SYSTEMAPI = 'Scan system api', @@ -112,7 +118,7 @@ const MEMORY_PERFORMANCE_FILE_NAME = 'memoryPerformanceData.json'; // Memory per export const eventListTimeAndMemValues = new Set(Object.values(EventList)); export class TimeAndMemTimeTracker { - static obfuscationCacheDir: string = ''; // Obtain the directory of the obfuscated output file + static obfuscationCacheDir: string | undefined = ''; // Obtain the directory of the obfuscated output file private eventStack: Array<{ eventName: string; data: TimeAndMemInfo }> = []; timeDataArr: TimeInfo[] = []; memoryDataArr: MemInfo[] = []; @@ -195,21 +201,28 @@ export class TimeAndMemTimeTracker { /** * Initialize performance printer */ -export function initPerformanceTimeAndMemPrinter(mCustomProfiles: IOptions): void { - const printerConfig: IPrinterOption | undefined = mCustomProfiles.mPerformanceTimeAndMemPrinter; - - // If no performance printer configuration is provided, disable the printer and return. - if (!printerConfig) { +export function initPerformanceTimeAndMemPrinter(): void { + if (!printerTimeAndMemDataConfig.mTimeAndMemPrinter) { blockTimeAndMemPrinter(); - return; } +} - // Disable performance printer if no specific printer types (files, single file) are enabled. - const isPrinterDisabled = !(printerConfig.mFilesPrinter || printerConfig.mSingleFilePrinter); +/** + * Configures the performance printer based on the specified performance mode + */ +export function configurePerformancePrinter(perf: number): void { + if (perf === PerfMode.ADVANCED) { + initPrinterTimeAndMemConfig(); - if (isPrinterDisabled) { + // If singleFilePrinter and filesPrinter do not exist, create the corresponding instance + if (!performanceTimeAndMemPrinter.singleFilePrinter) { + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + } + if (!performanceTimeAndMemPrinter.filesPrinter) { + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + } + } else { blockTimeAndMemPrinter(); - return; } } @@ -217,6 +230,7 @@ export function initPerformanceTimeAndMemPrinter(mCustomProfiles: IOptions): voi * Disable performance printer */ export function blockTimeAndMemPrinter(): void { + disablePrinterTimeAndMemConfig(); performanceTimeAndMemPrinter.filesPrinter = undefined; performanceTimeAndMemPrinter.singleFilePrinter = undefined; } @@ -235,6 +249,20 @@ export function clearTimeAndMemPrinterData(): void { } } +/** + * Initialize the configuration of the TimeAndMem performance printer + */ +export function initPrinterTimeAndMemConfig(): void { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; +} + +/** + * Disable the configuration of the TimeAndMem performance printer + */ +export function disablePrinterTimeAndMemConfig(): void { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; +} + /** * Start recording singleFileForMoreTimePrinter event */ @@ -288,11 +316,13 @@ export function printMemoryPerformanceData(): void { * Write data of timeAndMemoryPerformance */ export async function writeTimeAndMemoryPerformanceData(data: (TimeInfo | MemInfo)[], fileName: string): Promise { - const filePath: string = path.join(TimeAndMemTimeTracker.obfuscationCacheDir, fileName); - try { - await fs.promises.writeFile(filePath, JSON.stringify(data, null, INDENTATION_SPACES)); - } catch (error) { - throw new Error('Failed to write file: ' + error.message.toString()); + if (TimeAndMemTimeTracker.obfuscationCacheDir) { + const filePath: string = path.join(TimeAndMemTimeTracker.obfuscationCacheDir, fileName); + try { + await fs.promises.writeFile(filePath, JSON.stringify(data, null, INDENTATION_SPACES)); + } catch (error) { + throw new Error('Failed to write file: ' + error.message.toString()); + } } } diff --git a/arkguard/src/utils/ProjectCollections.ts b/arkguard/src/utils/ProjectCollections.ts index 62071f3388fce53a2fd6f62182ab0d4b2d325e5e..e218b8b2479665158c740d695dc091893e79276e 100644 --- a/arkguard/src/utils/ProjectCollections.ts +++ b/arkguard/src/utils/ProjectCollections.ts @@ -15,7 +15,12 @@ import { ApiExtractor } from '../common/ApiExtractor'; import { FileUtils } from './FileUtils'; -import { AtKeepCollections, UnobfuscationCollections } from './CommonCollections'; +import { + AtIntentCollections, + AtKeepCollections, + BytecodeObfuscationCollections, + UnobfuscationCollections +} from './CommonCollections'; import * as crypto from 'crypto'; import * as ts from 'typescript'; import fs from 'fs'; @@ -51,6 +56,14 @@ export const FILE_NAMES_MAP: string = 'transformedFileNamesMap.json'; export const FILE_WHITE_LISTS: string = 'fileWhiteLists.json'; export const PROJECT_WHITE_LIST: string = 'projectWhiteList.json'; +// this while list is only used for bytecode obfuscation +export const DECORATOR_WHITE_LIST = [ + 'Monitor', + 'Track', + 'Trace', + 'AnimatableExtend' +]; + export interface KeepInfo { propertyNames: Set; globalNames: Set; @@ -111,6 +124,11 @@ export interface FileContent { * │ │ └── globalNames: Set * │ ├── enumProperties: Set * │ └── stringProperties: Set + * │ └── arkUIKeepInfo: KeepInfo + * │ ├── propertyNames: Set + * │ └── globalNames: Set + * └── bytecodeObfuscateKeepInfo: BytecodeObfuscateKeepInfo + * └── decoratorMap?: Map * └── fileReservedInfo: FileReservedInfo * ├── enumProperties: Set * └── propertyParams: Set @@ -122,6 +140,7 @@ export interface FileKeepInfo { exported: KeepInfo; // Exported names and properties. enumProperties: Set; // Enum properties. stringProperties: Set; // String properties. + arkUIKeepInfo?: KeepInfo; // Collecting classes and members } export interface FileReservedInfo { @@ -129,9 +148,14 @@ export interface FileReservedInfo { propertyParams: Set; // Properties parameters in constructor. } +export interface BytecodeObfuscateKeepInfo { + decoratorMap?: Object; // collect DecoratorMap +} + export interface FileWhiteList { fileKeepInfo: FileKeepInfo; fileReservedInfo: FileReservedInfo; + bytecodeObfuscateKeepInfo?: BytecodeObfuscateKeepInfo } export interface ProjectKeepInfo { @@ -241,6 +265,10 @@ export class ProjectWhiteListManager { }, enumProperties: new Set(), stringProperties: new Set(), + arkUIKeepInfo: { + propertyNames: new Set(), + globalNames: new Set(), + }, }; } @@ -311,14 +339,22 @@ export class ProjectWhiteListManager { }, enumProperties: arrayToSet(parsed[key].fileKeepInfo.enumProperties), stringProperties: arrayToSet(parsed[key].fileKeepInfo.stringProperties), + arkUIKeepInfo: parsed[key].fileKeepInfo.arkUIKeepInfo + ? { + propertyNames: arrayToSet(parsed[key].fileKeepInfo.arkUIKeepInfo.propertyNames), + globalNames: arrayToSet(parsed[key].fileKeepInfo.arkUIKeepInfo.globalNames), + } + : undefined, }; const fileReservedInfo: FileReservedInfo = { enumProperties: arrayToSet(parsed[key].fileReservedInfo.enumProperties), propertyParams: arrayToSet(parsed[key].fileReservedInfo.propertyParams), }; - - map.set(key, { fileKeepInfo, fileReservedInfo }); + const bytecodeObfuscateKeepInfo: BytecodeObfuscateKeepInfo = { + decoratorMap: parsed[key].bytecodeObfuscateKeepInfo?.decoratorMap, + }; + map.set(key, { fileKeepInfo, fileReservedInfo, bytecodeObfuscateKeepInfo }); } } @@ -349,12 +385,23 @@ export class ProjectWhiteListManager { }, enumProperties: setToArray(value.fileKeepInfo.enumProperties), stringProperties: setToArray(value.fileKeepInfo.stringProperties), + arkUIKeepInfo: value.fileKeepInfo.arkUIKeepInfo + ? { + propertyNames: setToArray(value.fileKeepInfo.arkUIKeepInfo.propertyNames), + globalNames: setToArray(value.fileKeepInfo.arkUIKeepInfo.globalNames), + } + : undefined, }, fileReservedInfo: { enumProperties: setToArray(value.fileReservedInfo.enumProperties), propertyParams: setToArray(value.fileReservedInfo.propertyParams), }, }; + if (value.bytecodeObfuscateKeepInfo?.decoratorMap) { + jsonData[key].bytecodeObfuscateKeepInfo = { + decoratorMap: value.bytecodeObfuscateKeepInfo.decoratorMap, + }; + } } const jsonString = JSON.stringify(jsonData, null, 2); @@ -462,6 +509,16 @@ export class ProjectWhiteListManager { projectKeepInfo.propertyNames.add(propertyName); }); + // Collect arkUIKeepInfo + fileWhiteList.fileKeepInfo.arkUIKeepInfo?.globalNames.forEach((globalName) => { + projectKeepInfo.globalNames.add(globalName); + AtIntentCollections.globalNames.add(globalName); + }); + fileWhiteList.fileKeepInfo.arkUIKeepInfo?.propertyNames.forEach((propertyName) => { + projectKeepInfo.propertyNames.add(propertyName); + AtIntentCollections.propertyNames.add(propertyName); + }); + // 2. Collect fileReservedInfo // Collect enumProperties fileWhiteList.fileReservedInfo.enumProperties.forEach((enumPropertyName) => { @@ -472,6 +529,13 @@ export class ProjectWhiteListManager { fileWhiteList.fileReservedInfo.propertyParams.forEach((propertyParam) => { projectReservedInfo.propertyParams.add(propertyParam); }); + + const decoratorMap = fileWhiteList.bytecodeObfuscateKeepInfo?.decoratorMap; + for (const key in decoratorMap) { + if (Object.prototype.hasOwnProperty.call(decoratorMap, key)) { + decoratorMap[key]?.forEach(item => projectKeepInfo.globalNames.add(item)); + } + } }); const projectWhiteList = { @@ -515,8 +579,18 @@ export class ProjectWhiteListManager { addToSet(UnobfuscationCollections.reservedExportName, fileWhiteList.fileKeepInfo.exported.globalNames); addToSet(UnobfuscationCollections.reservedExportNameAndProp, fileWhiteList.fileKeepInfo.exported.propertyNames); addToSet(UnobfuscationCollections.reservedStrProp, fileWhiteList.fileKeepInfo.stringProperties); + if (fileWhiteList.fileKeepInfo.arkUIKeepInfo) { + addToSet(AtIntentCollections.propertyNames, fileWhiteList.fileKeepInfo.arkUIKeepInfo.propertyNames); + addToSet(AtIntentCollections.globalNames, fileWhiteList.fileKeepInfo.arkUIKeepInfo.globalNames); + } addToSet(ApiExtractor.mConstructorPropertySet, fileWhiteList.fileReservedInfo.propertyParams); addToSet(ApiExtractor.mEnumMemberSet, fileWhiteList.fileReservedInfo.enumProperties); + const decoratorMap = fileWhiteList.bytecodeObfuscateKeepInfo?.decoratorMap; + for (const key in decoratorMap) { + if (Object.prototype.hasOwnProperty.call(decoratorMap, key)) { + decoratorMap[key]?.forEach(item => BytecodeObfuscationCollections.decoratorProp.add(item)); + } + } }); } diff --git a/arkguard/src/utils/ScopeAnalyzer.ts b/arkguard/src/utils/ScopeAnalyzer.ts index a2f2466039ad5876ee673773b7a1145aa56bc06f..620758608f87e88d7c2cf074edc82cbc31f42361 100644 --- a/arkguard/src/utils/ScopeAnalyzer.ts +++ b/arkguard/src/utils/ScopeAnalyzer.ts @@ -17,6 +17,7 @@ import { forEachChild, getModifiers, getOriginalNode, + isAnnotationPropertyDeclaration, isCatchClause, isClassDeclaration, isConstructorDeclaration, @@ -40,6 +41,7 @@ import { } from 'typescript'; import type { + AnnotationDeclaration, BreakOrContinueStatement, CaseBlock, CatchClause, @@ -70,7 +72,7 @@ import type { TypeElement } from 'typescript'; -import { NodeUtils } from './NodeUtils'; +import { hasExportModifier, NodeUtils } from './NodeUtils'; import { isParameterPropertyModifier, isViewPUBasedClass } from './OhsUtil'; import { TypeUtils } from './TypeUtils'; import { endSingleFileEvent, startSingleFileEvent } from '../utils/PrinterUtils'; @@ -284,7 +286,7 @@ namespace secharmony { * @param ast ast tree of a source file * @param checker */ - analyze(ast: SourceFile, checker: TypeChecker, isEnabledExportObfuscation: boolean): void; + analyze(ast: SourceFile, checker: TypeChecker, isEnabledExportObfuscation: boolean, currentFileType: string): void; /** * get root scope of a file @@ -307,6 +309,7 @@ namespace secharmony { let checker: TypeChecker = null; let upperLabel: Label | undefined = undefined; let exportObfuscation: boolean = false; + let fileType: string | undefined = undefined; return { getReservedNames, @@ -315,9 +318,10 @@ namespace secharmony { getScopeOfNode, }; - function analyze(ast: SourceFile, typeChecker: TypeChecker, isEnabledExportObfuscation = false): void { + function analyze(ast: SourceFile, typeChecker: TypeChecker, isEnabledExportObfuscation = false, currentFileType: string): void { checker = typeChecker; exportObfuscation = isEnabledExportObfuscation; + fileType = currentFileType; analyzeScope(ast); } @@ -445,7 +449,10 @@ namespace secharmony { break; case SyntaxKind.Identifier: - analyzeSymbol(node as Identifier); + // skip property in annotationDeclaration + if (!isAnnotationPropertyDeclaration(node.parent)) { + analyzeSymbol(node as Identifier); + } break; case SyntaxKind.TypeAliasDeclaration: @@ -469,7 +476,11 @@ namespace secharmony { break; case SyntaxKind.ObjectLiteralExpression: - analyzeObjectLiteralExpression(node as ObjectLiteralExpression); + // skip prop in annotation, e.g. @Anno({a: 0}) + // here, `a` will not be collected + if (!NodeUtils.isObjectLiteralInAnnotation(node as ObjectLiteralExpression, fileType)) { + analyzeObjectLiteralExpression(node as ObjectLiteralExpression); + } break; case SyntaxKind.ExportSpecifier: @@ -488,6 +499,11 @@ namespace secharmony { analyzeImportEqualsDeclaration(node as ImportEqualsDeclaration); break; + // add symbol of annotationDeclaration into global scope + case SyntaxKind.AnnotationDeclaration: + analyzeAnnotationDeclaration(node as AnnotationDeclaration); + break; + default: forEachChild(node, analyzeScope); break; @@ -1060,6 +1076,18 @@ namespace secharmony { forEachChild(node, analyzeScope); } + function analyzeAnnotationDeclaration(node: AnnotationDeclaration): void { + if (hasExportModifier(node)) { + current.exportNames.add(node.name.text); + root.fileExportNames.add(node.name.text); + } + let sym: Symbol | undefined = getAndRecordSymbolOfIdentifier(checker, node.name); + if (sym) { + current.addDefinition(sym, true); + } + forEachChild(node, analyzeScope); + } + function tryAddNoSymbolIdentifiers(node: Identifier): void { if (!isIdentifier(node)) { return; diff --git a/arkguard/src/utils/SourceMapMergingUtil.ts b/arkguard/src/utils/SourceMapMergingUtil.ts index 266f0d33cc4c9677b22066169789d55a757a0053..cb4746226a7603f7ef70dcd3103d53ca7bea49c7 100644 --- a/arkguard/src/utils/SourceMapMergingUtil.ts +++ b/arkguard/src/utils/SourceMapMergingUtil.ts @@ -74,6 +74,11 @@ export interface SourceMapSegmentObj { type MappingsNameType = { mappings: readonly SourceMapSegment[][]; names?: readonly string[] }; type TracedMappingsType = { mappings: SourceMapSegment[][]; names: string[]; sources: string[] }; +/** + * Type of the map parameter of the SourceMapLink class. + */ +export type MappingsNameTypeForTest = MappingsNameType; + /** * Provide api tools related to sourcemap. */ diff --git a/arkguard/src/utils/TypeUtils.ts b/arkguard/src/utils/TypeUtils.ts index cd143376b6519b249c4ed81ab6ccbb18063dedd7..1c80ffea5374c50f2310c24738a9d0e628823649 100644 --- a/arkguard/src/utils/TypeUtils.ts +++ b/arkguard/src/utils/TypeUtils.ts @@ -42,7 +42,7 @@ export class TypeUtils { * @param {string} sourceFilePath * @param {string} content - The content in sourceFilePath */ - public static createObfSourceFile(sourceFilePath: string, content: string): SourceFile { + public static createObfSourceFile(sourceFilePath: string, content: string, compilerOptions?: CompilerOptions): SourceFile { const pathOrExtension: PathAndExtension = FileUtils.getFileSuffix(sourceFilePath); const fileSuffix = pathOrExtension.ext; @@ -50,6 +50,10 @@ export class TypeUtils { sourceFilePath = pathOrExtension.path + Extension.TS; } + if (compilerOptions && compilerOptions.etsAnnotationsEnable === true) { + return createSourceFile(sourceFilePath, content, ScriptTarget.ES2015, true, undefined, compilerOptions, true); + } + return createSourceFile(sourceFilePath, content, ScriptTarget.ES2015, true); } diff --git a/arkguard/test/grammar/advanced_type/intersection_types.ts b/arkguard/test/grammar/advanced_type/intersection_types.ts index 182de6165ace90143339ba74036556a7589ed347..6d4457b850202196b45398ef6b5135b1207be64a 100644 --- a/arkguard/test/grammar/advanced_type/intersection_types.ts +++ b/arkguard/test/grammar/advanced_type/intersection_types.ts @@ -15,35 +15,36 @@ import assert = require('assert'); -function extend(first: T, second: U): T & U { - let result = {}; - for (let id in first) { - (result)[id] = (first)[id]; +function mergeObjects(primary: T, secondary: U): T & U { + const merged = {} as T & U; + + for (const prop in primary) { + merged[prop] = primary[prop] as any; } - for (let id in second) { - if (!result.hasOwnProperty(id)) { - (result)[id] = (second)[id]; + + for (const prop in secondary) { + if (!Object.prototype.hasOwnProperty.call(merged, prop)) { + merged[prop] = secondary[prop] as any; } } - return result; + return merged; } -class Person { - constructor(public name: string) { - } +class Human { + constructor(public username: string) {} } -interface Loggable { - log(): void; +interface LoggingCapability { + writeLog(): void; } -class ConsoleLogger implements Loggable { - log(): void { +class TerminalLogger implements LoggingCapability { + writeLog(): void { console.log('Jim'); } } -const jim = extend(new Person('Jim'), new ConsoleLogger()); -const n = jim.name; +const user = mergeObjects(new Human('Jim'), new TerminalLogger()); +const currentUser = user.username; -assert(n === 'Jim', 'success'); +assert(currentUser === 'Jim', 'success'); diff --git a/arkguard/test/grammar/advanced_type/predefined_types.ts b/arkguard/test/grammar/advanced_type/predefined_types.ts index 22d55829e5b3fcf1eebc0e353a4738e0211096de..d12d9d5acaa3d2b389b057e604da24706aea1b5a 100644 --- a/arkguard/test/grammar/advanced_type/predefined_types.ts +++ b/arkguard/test/grammar/advanced_type/predefined_types.ts @@ -13,8 +13,6 @@ * limitations under the License. */ -import assert = require('assert'); - type T00 = Exclude<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'b' | 'd' type T01 = Extract<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'a' | 'c' @@ -33,13 +31,13 @@ class C { y = 0; } -type T10 = ReturnType<() => string>; // string -type T11 = ReturnType<(s: string) => void>; // void -type T12 = ReturnType<(() => T)>; // {} -type T13 = ReturnType<(() => T)>; // number[] -type T14 = ReturnType; // { a: number, b: string } -type T15 = ReturnType; // any -type T16 = ReturnType; // any +type ResultString = ReturnType<() => string>; // string +type ResultVoid = ReturnType<(s: string) => void>; // void +type ResultGeneric = ReturnType<(() => T)>; // {} +type ResultConstrained = ReturnType<(() => T)>; // number[] +type ResultInstance = ReturnType; // { a: number, b: string } +type ResultAny = ReturnType; // any +type ResultNever = ReturnType; // any type T20 = InstanceType; // C type T21 = InstanceType; // any diff --git a/arkguard/test/grammar/advanced_type/predefined_types_expected.txt b/arkguard/test/grammar/advanced_type/predefined_types_expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b22f02196e0cb9e272af321cc65105966a3e1b51 --- /dev/null +++ b/arkguard/test/grammar/advanced_type/predefined_types_expected.txt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 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. + */ +type l1 = Exclude<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'b' | 'd' +type m1 = Extract<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'a' | 'c' +type n1 = Exclude void), Function>; // string | number +type o1 = Extract void), Function>; // () => void +type q1 = NonNullable; // string | number +type s1 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] +function j1(g2: string): any { + return { a: 1, b: g2 }; +} +class t1 { + x = 0; + y = 0; +} +type u1 = ReturnType<() => string>; // string +type v1 = ReturnType<(s: string) => void>; // void +type w1 = ReturnType<(() => T)>; // {} +type z1 = ReturnType<(() => T)>; // number[] +type a2 = ReturnType; // { a: number, b: string } +type b2 = ReturnType; // any +type c2 = ReturnType; // any +type d2 = InstanceType; // C +type e2 = InstanceType; // any +type f2 = InstanceType; // any diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts index ff334131470e9e6fd14d8cc753535d69e540c4da..4b9cb710891cd458674edd9108e77f798947494e 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts @@ -18,33 +18,33 @@ 1. + 2.0 + 3.; var i: number = 1; -var test1 = i.toString(); -var test3 = 3 .toString(); -var test4 = 3 .toString(); -var test5 = 3 .toString(); -var test6 = 3.['toString'](); -var test7 = 3 +var compactTest1 = i.toString(); +var compactTest3 = 3 .toString(); +var compactTest4 = 3 .toString(); +var compactTest5 = 3 .toString(); +var compactTest6 = 3.['toString'](); +var compactTest7 = 3 .toString(); -var test8 = new Number(4).toString(); -var test9 = 3. + 3.; -var test10 = 0 /* comment */.toString(); -var test11 = 3. /* comment */.toString(); -var test12 = 3 +var compactTest8 = new Number(4).toString(); +var compactTest9 = 3. + 3.; +var compactTest10 = 0 /* comment */.toString(); +var compactTest11 = 3. /* comment */.toString(); +var compactTest12 = 3 /* comment */ .toString(); var test122 = 3 /* comment */.toString(); var test1222 = 3 .toString(); -var test13 = 3. +var compactTest13 = 3. /* comment */.toString(); -var test14 = 3 +var compactTest14 = 3 // comment .toString(); -var test15 = 3. +var compactTest15 = 3. // comment .toString(); -var test16 = 3 // comment time +var compactTest16 = 3 // comment time .toString(); -var test17 = 3. // comment time again +var compactTest17 = 3. // comment time again .toString(); \ No newline at end of file diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt index c00d3215e58b153f0e11b2f915f94a5d247a8558..91796cd9c13e67a76ca123b35c6abbaacadb95bf 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt @@ -1 +1 @@ -1..toString();1.0.toString();1. + 2.0 + 3.;var i: number = 1;var test1 = i.toString();var test3 = 3..toString();var test4 = 3..toString();var test5 = 3..toString();var test6 = 3.['toString']();var test7 = 3 .toString();var test8 = new Number(4).toString();var test9 = 3. + 3.;var test10 = 0 .toString();var test11 = 3. .toString();var test12 = 3 .toString();var test122 = 3 .toString();var test1222 = 3 .toString();var test13 = 3. .toString();var test14 = 3 .toString();var test15 = 3. .toString();var test16 = 3 .toString();var test17 = 3. .toString(); \ No newline at end of file +1..toString();1.0.toString();1. + 2.0 + 3.;var i: number = 1;var compactTest1 = i.toString();var compactTest3 = 3..toString();var compactTest4 = 3..toString();var compactTest5 = 3..toString();var compactTest6 = 3.['toString']();var compactTest7 = 3 .toString();var compactTest8 = new Number(4).toString();var compactTest9 = 3. + 3.;var compactTest10 = 0 .toString();var compactTest11 = 3. .toString();var compactTest12 = 3 .toString();var test122 = 3 .toString();var test1222 = 3 .toString();var compactTest13 = 3. .toString();var compactTest14 = 3 .toString();var compactTest15 = 3. .toString();var compactTest16 = 3 .toString();var compactTest17 = 3. .toString(); \ No newline at end of file diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt index 4e7f94de3f118943977ec0128f86fab8d18e5580..69efdc4f7ce3090551b3225128d91851cf225550 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt @@ -6,5 +6,5 @@ "test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts" ], "names": [], - "mappings": "AAeA,EAAE,CAAC,QAAQ,EAAE,CACb,GAAG,CAAC,QAAQ,EAAE,CACd,EAAE,GAAG,GAAG,GAAG,EAAE,CAEb,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CACjB,IAAI,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,CACxB,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,CACzB,IAAI,KAAK,GAAG,CAAC,EAAK,QAAQ,EAAE,CAC5B,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,CACzB,IAAI,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,CAC5B,IAAI,KAAK,GAAG,CAAC,EACV,QAAQ,EAAE,CACb,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACpC,IAAI,KAAK,GAAG,EAAE,GAAG,EAAE,CACnB,IAAI,MAAM,GAAG,CAAC,CAAc,CAAC,QAAQ,EAAE,CACvC,IAAI,MAAM,GAAG,EAAE,CAAc,CAAC,QAAQ,EAAE,CACxC,IAAI,MAAM,GAAG,CAAC,CACC,EAAE,QAAQ,EAAE,CAC3B,IAAI,OAAO,GAAG,CAAC,CACF,EAAC,QAAQ,EAAE,CACxB,IAAI,QAAQ,GAAG,CAAC,EAEb,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CACA,EAAC,QAAQ,EAAE,CAC1B,IAAI,MAAM,GAAG,CAAC,CACF,CACT,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CACH,CACT,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,CAAC,CAAiB,CAC5B,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CAAsB,CAClC,QAAQ,EAAE,CAAC" + "mappings": "AAeA,EAAE,CAAC,QAAQ,EAAE,CACb,GAAG,CAAC,QAAQ,EAAE,CACd,EAAE,GAAG,GAAG,GAAG,EAAE,CAEb,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CACjB,IAAI,YAAY,GAAG,CAAC,CAAC,QAAQ,EAAE,CAC/B,IAAI,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,CAChC,IAAI,YAAY,GAAG,CAAC,EAAK,QAAQ,EAAE,CACnC,IAAI,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,CAChC,IAAI,YAAY,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,CACnC,IAAI,YAAY,GAAG,CAAC,EACjB,QAAQ,EAAE,CACb,IAAI,YAAY,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC3C,IAAI,YAAY,GAAG,EAAE,GAAG,EAAE,CAC1B,IAAI,aAAa,GAAG,CAAC,CAAc,CAAC,QAAQ,EAAE,CAC9C,IAAI,aAAa,GAAG,EAAE,CAAc,CAAC,QAAQ,EAAE,CAC/C,IAAI,aAAa,GAAG,CAAC,CACN,EAAE,QAAQ,EAAE,CAC3B,IAAI,OAAO,GAAG,CAAC,CACF,EAAC,QAAQ,EAAE,CACxB,IAAI,QAAQ,GAAG,CAAC,EAEb,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CACP,EAAC,QAAQ,EAAE,CAC1B,IAAI,aAAa,GAAG,CAAC,CACT,CACT,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CACV,CACT,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,CAAC,CAAiB,CACnC,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CAAsB,CACzC,QAAQ,EAAE,CAAC" } \ No newline at end of file diff --git a/arkguard/test/grammar/interface_validation/interface_class_method.ts b/arkguard/test/grammar/interface_validation/interface_class_method.ts index f9bea5f4f47237c416fce7cf45a0f63ec8774c0a..1636c31168cf4c4b56f53fccf3a1be72d2ed5e25 100644 --- a/arkguard/test/grammar/interface_validation/interface_class_method.ts +++ b/arkguard/test/grammar/interface_validation/interface_class_method.ts @@ -15,27 +15,27 @@ import assert = require('assert'); -interface ClockInterface { - currentTime: Date; +interface TimepieceInterface { + currentDateTime: Date; - setTime(d: Date); + updateTime(newTime: Date); } -class Clock implements ClockInterface { - currentTime: Date; +class WallClock implements TimepieceInterface { + currentDateTime: Date; - setTime(d: Date) { - this.currentTime = d; + updateTime(newTime: Date) { + this.currentDateTime = newTime; } - constructor(h: number, m: number) { + constructor(hour: number, minute: number) { } } -let nowClock = new Clock(3, 20); +let nowClock = new WallClock(3, 20); let now = Date.prototype; -nowClock.setTime(now); +nowClock.updateTime(now); -assert(nowClock.currentTime === now, 'success'); \ No newline at end of file +assert(nowClock.currentDateTime === now, 'success'); \ No newline at end of file diff --git a/arkguard/test/grammar/module_validation/name_space.ts b/arkguard/test/grammar/module_validation/name_space.ts index bc9379802add64166105995aa8e122fb2f3cb846..582fb7951301576551b9a4c761a0bbc94e52ce6a 100644 --- a/arkguard/test/grammar/module_validation/name_space.ts +++ b/arkguard/test/grammar/module_validation/name_space.ts @@ -15,33 +15,33 @@ import assert = require('assert'); -interface StringValidator { - isAcceptable(s: string): boolean; +interface TextValidationRule { + isValid(text: string): boolean; } -let lettersRegexp = /^[A-Za-z]+$/; -let numberRegexp = /^[0-9]+$/; +const alphabeticPattern = /^[A-Za-z]+$/; +const numericPattern = /^[0-9]+$/; -class LettersOnlyValidator implements StringValidator { - isAcceptable(s: string) { - return lettersRegexp.test(s); +class AlphabeticalValidator implements TextValidationRule { + isValid(text: string) { + return alphabeticPattern.test(text); } } -class ZipCodeValidator implements StringValidator { - isAcceptable(s: string) { - return s.length === 5 && numberRegexp.test(s); +class PostalCodeValidator implements TextValidationRule { + isValid(text: string) { + return text.length === 5 && numericPattern.test(text); } } -// Some samples to try -let strings = ["Hello", "98052", "101"]; +// Test cases +const testInputs = ["Hello", "98052", "101"]; -// Validators to use -let validators: { [s: string]: StringValidator; } = {}; -validators["ZIP code"] = new ZipCodeValidator(); -validators["Letters only"] = new LettersOnlyValidator(); +// Validation registry +const validationRules: { [ruleName: string]: TextValidationRule } = {}; +validationRules["Postal Code"] = new PostalCodeValidator(); +validationRules["Alphabetical"] = new AlphabeticalValidator(); -assert(validators["Letters only"].isAcceptable(strings[0]), 'success'); -assert(validators["ZIP code"].isAcceptable(strings[1]), 'success'); +assert(validationRules["Alphabetical"].isValid(testInputs[0]), 'success'); +assert(validationRules["Postal Code"].isValid(testInputs[1]), 'success'); diff --git a/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt new file mode 100644 index 0000000000000000000000000000000000000000..3886aed9a1183916a362572acc393ad76de4b970 --- /dev/null +++ b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt @@ -0,0 +1 @@ +#default \ No newline at end of file diff --git a/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt new file mode 100644 index 0000000000000000000000000000000000000000..810df52a853d84a165e48e3ab2a4af4c8b857a61 --- /dev/null +++ b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt @@ -0,0 +1,3 @@ +-enable-bytecode-obfuscation +-enable-bytecode-obfuscation-debugging +-enable-bytecode-obfuscation-enhanced \ No newline at end of file diff --git a/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt b/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt new file mode 100644 index 0000000000000000000000000000000000000000..43c1c46fc84eb2992a31048fbe38bc69b66fb977 --- /dev/null +++ b/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt @@ -0,0 +1 @@ +-enable-bytecode-obfuscation \ No newline at end of file diff --git a/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts b/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts index 1d4c9b1bb9829bb9a914131fd563454d29df5262..89cba1945921edec61072ab680f813db25229658 100644 --- a/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts +++ b/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts @@ -260,6 +260,15 @@ class Demo{ } expect(languageSet).to.deep.equal(UnobfuscationCollections.reservedLangForProperty); }); + + it('Tester: test case for enable annotation', function (){ + let configPath = "test/ut/arkobfuscator/iniTestObfConfig.json" + let obfuscator: ArkObfuscator = new ArkObfuscator(); + let config = FileUtils.readFileAsJson(configPath) as IOptions; + obfuscator.init(config); + + expect(config.mAllowEtsAnnotations).to.be.true; + }); }); }); diff --git a/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts b/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts index 57e552d25454399ac2feedd0138f4edc55f3d310..a345d5feb3e538a83a7bc568c0db1253cd83f8e3 100644 --- a/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts +++ b/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts @@ -67,6 +67,13 @@ import { SOURCE_FILE_PATHS, projectWhiteListManager } from '../../../src/utils/P import { FilePathObj } from '../../../src/common/type'; import { historyAllUnobfuscatedNamesMap } from '../../../src/initialization/Initializer'; import path from 'path'; +import { nameCache } from '../../../src/transformers/rename/RenameIdentifierTransformer'; +import { + decodeSourcemap, + MappingsNameTypeForTest, + Source, + SourceMapLink +} from '../../../src/utils/SourceMapMergingUtil'; describe('Tester Cases for ', function () { let obfuscator: ArkObfuscator; @@ -524,6 +531,67 @@ export declare function findElement(arr: T[], callback: (item: T) => boolean) }); }); + describe('test for ArkObfuscator.convertLineBasedOnSourceMap', () => { + it('there is no location but the value is obfuscated, it should be recorded in nameacahe', () => { + const identifierCache = new Map([ + ['#Person', 'Person'], + ['obfsucationValue:31:5:35:6', 'h'], + ['getName:75:5:77:6', 'getName'] + ]); + nameCache.set('IdentifierCache', identifierCache); + const source: Source = new Source('utils.ets', null); + const previousStageSourceMap: RawSourceMap = { + version: 3, + file: 'utils.ets', + sourceRoot: '', + sources: [ 'entry/src/main/ets/pages/utils/utils.ets'], + names: [], + mappings: '', + sourcesContent: undefined, + } + const decodedSourceMap = decodeSourcemap(previousStageSourceMap as RawSourceMap); + const sourceMapLink: SourceMapLink = new SourceMapLink(decodedSourceMap as MappingsNameTypeForTest, [source]); + + const result = obfuscator.convertLineBasedOnSourceMapForTest('IdentifierCache', sourceMapLink); + const expectedResult= { + '#Person': 'Person', + 'obfsucationValue': 'h' + }; + const compareResult = JSON.stringify(result) === JSON.stringify(expectedResult); + expect(compareResult).to.be.true; + }); + + it('there is start and end location, it should be recorded in nameacahe', () => { + const identifierCache = new Map([ + ['#Person', 'Person'], + ['#foo:1:1:3:2', 'foo'], + ['getName:75:5:77:6', 'getName'] + ]); + nameCache.set('IdentifierCache', identifierCache); + const source: Source = new Source('file.ts', null); + const previousStageSourceMap: RawSourceMap = { + "version": 3, + "file": "file.ts", + "sources": [ + "entry/src/main/ets/pages/file.ts" + ], + "names": [], + "mappings": "AAAA,MAAM,UAAU,GAAG;IACjB,OAAO,CAAC,CAAC;AACX,CAAC", + "sourceRoot": "" + } + const decodedSourceMap = decodeSourcemap(previousStageSourceMap as RawSourceMap); + const sourceMapLink: SourceMapLink = new SourceMapLink(decodedSourceMap as MappingsNameTypeForTest, [source]); + + const result = obfuscator.convertLineBasedOnSourceMapForTest('IdentifierCache', sourceMapLink); + const expectedResult= { + '#Person': 'Person', + '#foo:1:3': 'foo' + }; + const compareResult = JSON.stringify(result) === JSON.stringify(expectedResult); + expect(compareResult).to.be.true; + }); + }); + describe('test for clearGlobalCaches', () => { beforeEach(() => { PropCollections.globalMangledTable.set('test1', 'obfuscated1'); diff --git a/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json b/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json index c4ce5a7e3f7c189ce3119e04563df632d13371a1..c3373c14e770de596f085f95f63f772e808f60fa 100644 --- a/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json +++ b/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json @@ -16,5 +16,6 @@ "mReservedToplevelNames": ["a*", "*shoul?keep*", "func2"] }, "mEnableSourceMap": false, - "mEnableNameCache": false + "mEnableNameCache": false, + "mAllowEtsAnnotations": true } \ No newline at end of file diff --git a/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts b/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts index 93c20dfafab78c0178e60b64d346ef95e0df8c4f..37031bc400e776c45b2fc6b2329ddb149db64a97 100644 --- a/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts +++ b/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts @@ -259,6 +259,7 @@ describe('hsp support consumerFiles', () => { localHspConfig.dependencies.hars.push(remoteHarObfFile); const hspResolver = new ObConfigResolver({ obfuscationOptions: localHspConfig, compileHar: false, compileShared: true }, printObfLogger); hspResolver.resolveObfuscationConfigs(); + hspResolver.emitConsumerConfigFiles(); const hspObfuscationContent = fs.readFileSync(localHspConfig.exportRulePath, 'utf-8'); expect(hspObfuscationContent).not.to.include('-disable-obfuscation'); @@ -334,6 +335,7 @@ describe('hsp support consumerFiles', () => { localHarConfig.dependencies.hspLibraries?.push(localHspConfig.selfConfig); const localHarResolver = new ObConfigResolver({ obfuscationOptions: localHarConfig, compileHar: true, compileShared: false }, printObfLogger); localHarResolver.resolveObfuscationConfigs(); + localHarResolver.emitConsumerConfigFiles(); const localHarObfuscationContent = fs.readFileSync(localHarConfig.exportRulePath, 'utf-8'); @@ -412,6 +414,7 @@ describe('hsp support consumerFiles', () => { localHarConfig.dependencies.hsps?.push(remoteHspObfFile); const localHarResolver = new ObConfigResolver({ obfuscationOptions: localHarConfig, compileHar: true, compileShared: false }, printObfLogger); localHarResolver.resolveObfuscationConfigs(); + localHarResolver.emitConsumerConfigFiles(); const localHarObfuscationContent = fs.readFileSync(localHarConfig.exportRulePath, 'utf-8'); @@ -589,6 +592,8 @@ describe('hsp support consumerFiles', () => { localMainHspConfig.dependencies.hsps?.push(remoteHspObfFile); const localMainHspResolver = new ObConfigResolver({ obfuscationOptions: localMainHspConfig, compileHar: false, compileShared: true }, printObfLogger); localMainHspResolver.resolveObfuscationConfigs(); + localMainHspResolver.emitConsumerConfigFiles(); + const localMainHspObfuscationContent = fs.readFileSync(localMainHspConfig.exportRulePath, 'utf-8'); expect(localMainHspObfuscationContent).not.to.include('-enable-filename-obfuscation'); diff --git a/arkguard/test/ut/initialization/ConfigResolver.spec.ts b/arkguard/test/ut/initialization/ConfigResolver.spec.ts index f5b9bc480a08896c7d224991d512017553b34552..26c25a6592f3f3d3c79d1161a5a48c9f3a031e04 100644 --- a/arkguard/test/ut/initialization/ConfigResolver.spec.ts +++ b/arkguard/test/ut/initialization/ConfigResolver.spec.ts @@ -956,6 +956,24 @@ describe('test for ConfigResolve', function() { expect(configs.options.enableLibObfuscationOptions).to.be.true; }); + + it('should handle config correctly when enable bytecode obfuscation options', () => { + const configs: MergedConfig = new MergedConfig(); + configs.options = new ObOptionsForTest(); + + const configPath = './test/testData/obfuscation/enable_lib_obfuscation_options/obfuscation-rule.txt'; + const data = ` + -enable-bytecode-obfuscation + -enable-bytecode-obfuscation-debugging + -enable-bytecode-obfuscation-enhanced + -enable-bytecode-obfuscation-arkui + `; + newObConfigResolver.handleConfigContentForTest(data, configs, configPath); + expect(configs.options.bytecodeObf.enable).to.be.true; + expect(configs.options.bytecodeObf.debugging).to.be.true; + expect(configs.options.bytecodeObf.enhanced).to.be.true; + expect(configs.options.bytecodeObf.obfArkUI).to.be.true; + }); }); describe('1: test Api collectSystemApiWhitelist', function() { @@ -1188,6 +1206,52 @@ describe('test for ConfigResolve', function() { fs.unlinkSync(systemApiPath); }); + + it('1-5: test collectSystemApiWhitelist: -enable-bytecode-obfuscation', function () { + let obfuscationCacheDir = path.join(OBFUSCATE_TESTDATA_DIR, 'bytecode_obfuscation'); + let obfuscationOptions = { + 'selfConfig': { + 'ruleOptions': { + 'enable': true, + 'rules': [ + path.join(OBFUSCATE_TESTDATA_DIR, 'bytecode_obfuscation/bytecode_obfuscation.txt') + ] + }, + 'consumerRules': [], + }, + 'dependencies': { + 'libraries': [], + 'hars': [] + }, + 'obfuscationCacheDir': obfuscationCacheDir, + 'sdkApis': [ + path.join(OBFUSCATE_TESTDATA_DIR, 'system_api.d.ts') + ] + }; + let projectConfig = { + obfuscationOptions, + compileHar: false + }; + const obConfig: ObConfigResolver = new ObConfigResolver(projectConfig, undefined); + obConfig.resolveObfuscationConfigs(); + const reservedSdkApiForProp = UnobfuscationCollections.reservedSdkApiForProp; + const reservedSdkApiForGlobal = UnobfuscationCollections.reservedSdkApiForGlobal; + const reservedSdkApiForLocal = UnobfuscationCollections.reservedSdkApiForLocal; + + expect(reservedSdkApiForProp.size == 12).to.be.true; + expect(reservedSdkApiForGlobal.size == 3).to.be.true; + expect(reservedSdkApiForLocal.size == 8).to.be.true; + UnobfuscationCollections.clear(); + + let systemApiPath = obfuscationCacheDir + '/systemApiCache.json'; + const data = fs.readFileSync(systemApiPath, 'utf8'); + const systemApiContent = JSON.parse(data); + + expect(systemApiContent.ReservedLocalNames.length == 8).to.be.true; + expect(systemApiContent.ReservedPropertyNames.length == 12).to.be.true; + expect(systemApiContent.ReservedGlobalNames.length == 3).to.be.true; + fs.unlinkSync(systemApiPath); + }); }); }); @@ -2015,6 +2079,24 @@ describe('test for ConfigResolve', function() { const result = enableObfuscateFileName(isPackageModules, projectConfig); expect(result).to.be.false; }); + + it('should return false if obfuscation is enabled and bytecodeObf is enable', () => { + const isPackageModules = false; + const projectConfig = { + obfuscationMergedObConfig: { + options: { + disableObfuscation: false, + enableFileNameObfuscation: true, + bytecodeObf: { + enable: true + }, + }, + }, + buildMode: "not Debug" + }; + const result = enableObfuscatedFilePathConfig(isPackageModules, projectConfig); + expect(result).to.be.false; + }); }); describe('getRelativeSourcePath', () => { @@ -2171,6 +2253,7 @@ describe('test for ConfigResolve', function() { AtKeepCollections.clear(); const obConfigResolver = new ObConfigResolver(projectConfig, printObfLogger); obConfigResolver.resolveObfuscationConfigs(); + obConfigResolver.emitConsumerConfigFiles(); const atKeepContent = fs.readFileSync(sourceObConfig.exportRulePath, 'utf-8'); expect(atKeepContent).to.include('-enable-property-obfuscation'); expect(atKeepContent).to.include('-keep-global-name'); diff --git a/arkguard/test/ut/initialization/Initializer.spec.ts b/arkguard/test/ut/initialization/Initializer.spec.ts index 69ae8b1a74a59bea840589dc173b8265e4ee86c8..7657a550feefd6f7514ad08989fb70c4414ab04c 100644 --- a/arkguard/test/ut/initialization/Initializer.spec.ts +++ b/arkguard/test/ut/initialization/Initializer.spec.ts @@ -14,11 +14,23 @@ */ import { - clearHistoryUnobfuscatedMap, - historyAllUnobfuscatedNamesMap, - historyUnobfuscatedPropMap + clearHistoryUnobfuscatedMap, + historyAllUnobfuscatedNamesMap, + historyUnobfuscatedPropMap, + initObfuscationConfig } from '../../../src/initialization/Initializer'; -import { expect } from 'chai'; +import { + expect, + assert +} from 'chai'; +import { + describe, + it +} from 'mocha'; +import { + HvigorErrorInfo, + MergedConfig, +} from '../../../src/ArkObfuscator'; describe('Tester Cases for .', function () { it('Tester Cases for .', function () { @@ -31,3 +43,76 @@ describe('Tester Cases for .', function () { expect(historyUnobfuscatedPropMap.size).to.equal(0); }); }); + +function printObfLogger(errorInfo: string, errorCodeInfo: HvigorErrorInfo | string, level: string): void { + switch (level) { + case 'warn': + console.warn(errorInfo); + break; + case 'error': + console.error(errorInfo); + break; + default: + break; + } +} +const projectConfig = { + 'obfuscationOptions': { + 'selfConfig': { + 'ruleOptions': { + 'enable': true, + 'rules': ['./test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt'] + }, + 'consumerRules': [], + }, + 'dependencies': { + 'libraries': [], + 'hars': [] + }, + obfuscationCacheDir: "" + } +}; +interface ArkProjectConfig { + isBytecodeObfEnabled?: boolean; + isArkguardEnabled?: boolean; + allowEtsAnnotations?: boolean; + obfuscationMergedObConfig?: MergedConfig; +} + +describe('test for set arkguard mode property correctly for arkProjectConfig', function () { + describe('test for set arkguard mode property correctly for arkProjectConfig', () => { + it('should set isBytecodeObfEnabled when enable bytecodeObf', () => { + const arkProjectConfig: ArkProjectConfig = {}; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.true; + expect(arkProjectConfig.isArkguardEnabled).to.be.false; + }); + + it('should set isArkguardEnabled when enable arkguardObf', () => { + const arkProjectConfig: ArkProjectConfig = {}; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.rules = ['./test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt']; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isArkguardEnabled).to.be.true; + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.false; + }); + + it('should not set isArkguardEnabled and isBytecodeObfEnabled when obf is disabled', () => { + const arkProjectConfig: ArkProjectConfig = {}; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.enable = false; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.undefined; + expect(arkProjectConfig.isArkguardEnabled).to.be.undefined; + }); + + it('should not set enableEtsAnnotation if allowEtsAnnotations is enabled in arkProjectConfig', () => { + const arkProjectConfig: ArkProjectConfig = { + allowEtsAnnotations: true, + obfuscationMergedObConfig: new MergedConfig(), + }; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.enable = true; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.rules = ['./test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt']; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.obfuscationMergedObConfig?.options.enableEtsAnnotation).to.be.true; + }); + }); +}); diff --git a/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts b/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts index 6082c194a381940cfbbcd3d30d0bacf0188d3a3c..41856bcf8d6604e92596ab26aa214f1a893c6fd3 100644 --- a/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts +++ b/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts @@ -617,11 +617,138 @@ describe('Teste Cases for .', function () { const expectContent = `export declare function foo(para: number): void;`; assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); }) + + it('should obfuscate annotationDeclaration when top-level obfuscation is enable', () => { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `@interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `@interface __$$ETS_ANNOTATION$$__a { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should not obfuscate when annotationName is in top-level whitelist', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true + }; + assert.strictEqual(options !== undefined, true); + PropCollections.reservedProperties.add('Anno1'); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `@interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `@interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should not obfuscate when annotationName is exported and not enable export-obfuscation', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true, + 'mExportObfuscation': false, + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should obfuscate when annotationName is exported and enable export-obfuscation', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true, + 'mExportObfuscation': true, + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `export @interface __$$ETS_ANNOTATION$$__a { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) }) }) }) -function compareStringsIgnoreNewlines(str1: string, str2: string): boolean { +export function compareStringsIgnoreNewlines(str1: string, str2: string): boolean { const normalize = (str: string) => str.replace(/[\n\r\s]+/g, ''); return normalize(str1) === normalize(str2); } \ No newline at end of file diff --git a/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts b/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts index 24f8a3f516a3d97fe3d5631ff23442a46d79746c..213e75d6679d6bc377f3c973b6e3520b8a8dbc6f 100644 --- a/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts +++ b/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts @@ -33,6 +33,9 @@ import ts, { } from 'typescript'; import secharmony from '../../../src/transformers/rename/RenamePropertiesTransformer'; import { ArkObfuscator } from '../../../src/ArkObfuscator'; +import { compareStringsIgnoreNewlines } from './RenameIdentifierTransformer.spec'; +import { ArkObfuscatorForTest } from '../../../src/ArkObfuscatorForTest' +import { PropCollections } from '../../../src/utils/CommonCollections'; describe('Tester Cases for .', function () { @@ -202,5 +205,87 @@ describe('Tester Cases for .', function () { expect(((node.indexType as UnionTypeNode).types[0] as LiteralTypeNode).literal).to.be.equal(((parentNodes.indexType as UnionTypeNode).types[0] as LiteralTypeNode).literal); expect(((node.indexType as UnionTypeNode).types[1] as LiteralTypeNode).literal).to.be.equal(((parentNodes.indexType as UnionTypeNode).types[1] as LiteralTypeNode).literal); }); + + it('should not rename property in annotation decl and callsite when using prop', function () { + ArkObfuscator.isKeptCurrentFile = false; + options = { + mNameObfuscation: { + mEnable: true, + mNameGeneratorType: 1, + mRenameProperties: true, + mKeepStringProperty: false, + mReservedProperties: [] + }, + }; + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options as IOptions); + const fileContent = ` + @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + } + @__$$ETS_ANNOTATION$$__Anno1({prop: 1}) + class myClass1 { + prop1: number = 1; + } + let var1: myClass1 = new myClass1(); + let var2 = var1.prop1; + `; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = ` + @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + } + @__$$ETS_ANNOTATION$$__Anno1({ prop: 1 }) + class myClass1 { + g: number = 1; + } + let var1: myClass1 = new myClass1(); + let var2 = var1.g; + `; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }); + + it('should rename annotation called as prop when using prop obfuscation', function () { + ArkObfuscator.isKeptCurrentFile = false; + options = { + mNameObfuscation: { + mEnable: true, + mNameGeneratorType: 1, + mRenameProperties: true, + mKeepStringProperty: false, + mReservedProperties: [] + }, + }; + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options as IOptions); + const fileContent = ` + @ns.__$$ETS_ANNOTATION$$__Anno1({prop: 1}) + class myClass1 {} + `; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = ` + @ns.__$$ETS_ANNOTATION$$__g({ prop: 1 }) + class myClass1 {} + `; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }); }); }); diff --git a/arkguard/test/ut/utils/ApiExtractor.spec.ts b/arkguard/test/ut/utils/ApiExtractor.spec.ts index 0f29756774df4f0bfe1b9963a446f8849bed3198..628598b86bf5eced441aa88919fdf94b6dd059b2 100644 --- a/arkguard/test/ut/utils/ApiExtractor.spec.ts +++ b/arkguard/test/ut/utils/ApiExtractor.spec.ts @@ -1091,6 +1091,22 @@ describe('test for ApiExtractor', function () { expect(AtKeepCollections.keepAsConsumer.propertyNames.has('globalFunc04')).to.be.true; expect(AtKeepCollections.keepAsConsumer.propertyNames.has('globalMyClass04')).to.be.true; }) + it('should collect atKeep names from annotation declarations if enabled', function () { + let filePath: string = 'test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets'; + AtKeepCollections.clear(); + scanProjectConfig.mEnableAtKeep = true; + collectApi(filePath, ApiExtractor.ApiType.PROJECT); + expect(AtKeepCollections.keepSymbol.globalNames.size).to.be.equal(2); + expect(AtKeepCollections.keepSymbol.globalNames.has('MyAnnotation01')).to.be.true; + expect(AtKeepCollections.keepSymbol.globalNames.has('MyAnnotation02')).to.be.true; + expect(AtKeepCollections.keepSymbol.propertyNames.size).to.be.equal(1); + expect(AtKeepCollections.keepSymbol.propertyNames.has('MyAnnotation02')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.globalNames.size).to.be.equal(2); + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation04')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation05')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.propertyNames.size).to.be.equal(1); + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation05')).to.be.true; + }) it('should collect atKeep names from .ets', function () { let filePath: string = 'test/ut/utils/apiTest_visitAtKeepNames/atKeepTest01.ets'; AtKeepCollections.clear(); @@ -1200,5 +1216,15 @@ describe('test for ApiExtractor', function () { expect(fileWhiteList.fileKeepInfo.stringProperties.size).to.be.equal(0); expect(fileWhiteList.fileKeepInfo.structProperties.size).to.be.equal(0); }) + it('should collect decoratorMap if need scanDecorator', function () { + let filePath: string = 'test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets'; + scanProjectConfig.scanDecorator = true; + collectApi(filePath, ApiExtractor.ApiType.PROJECT); + const fileWhiteList: FileWhiteList = projectWhiteListManager?.getFileWhiteListMap().get(filePath)!; + if (fileWhiteList?.bytecodeObfuscateKeepInfo?.decoratorMap) { + const decoratorKeys = Object.keys(fileWhiteList.bytecodeObfuscateKeepInfo.decoratorMap); + expect(decoratorKeys.length).to.be.greaterThan(0); + } + }) }) }); \ No newline at end of file diff --git a/arkguard/test/ut/utils/ApiReader.spec.ts b/arkguard/test/ut/utils/ApiReader.spec.ts index 3d0e7ed55e06bd35a9960aff206fefb9c334ab81..32563048f2542087916c4c90acfc52b65dc082fe 100644 --- a/arkguard/test/ut/utils/ApiReader.spec.ts +++ b/arkguard/test/ut/utils/ApiReader.spec.ts @@ -13,7 +13,12 @@ * limitations under the License. */ -import { readProjectPropertiesByCollectedPaths, ReseverdSetForArkguard } from '../../../src/common/ApiReader'; +import { + readProjectPropertiesByCollectedPaths, + ReseverdSetForArkguard, + scanProjectConfig, + initScanProjectConfig +} from '../../../src/common/ApiReader'; import { assert, expect } from 'chai'; import { NameGeneratorType } from '../../../src/generator/NameFactory'; import { @@ -40,7 +45,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -88,7 +93,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -142,7 +147,7 @@ describe('test for ApiReader', function () { mRenameProperties: false, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -181,7 +186,7 @@ describe('test for ApiReader', function () { mRenameProperties: false, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -270,7 +275,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -360,7 +365,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -396,7 +401,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -486,7 +491,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -630,7 +635,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -776,7 +781,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -876,5 +881,58 @@ describe('test for ApiReader', function () { expect(fileWhiteList.fileKeepInfo.exported.propertyNames.has('otherElement2')).to.be.false; expect(fileWhiteList.fileKeepInfo.exported.propertyNames.has('o2')).to.be.true; }); + it('decorate collect test', function () { + const filePath = 'test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets' + const fileList: Set = new Set([filePath]); + let config: IOptions = { + mNameObfuscation: { + mEnable: true, + mReservedProperties: [], + mRenameProperties: true, + mKeepStringProperty: false, + mTopLevel: false, + mNameGeneratorType: NameGeneratorType.ORDERED, + mReservedNames: [], + mReservedToplevelNames: [] + } + }; + let cachePath = 'test/ut/utils/obfuscation'; + initProjectWhiteListManager(cachePath, false, false); + let projectAndLibs: ReseverdSetForArkguard = + readProjectPropertiesByCollectedPaths(fileList, + { + mNameObfuscation: config.mNameObfuscation, + mExportObfuscation: true, + mKeepFileSourceCode: { + mKeepSourceOfPaths: new Set(), + mkeepFilesAndDependencies: new Set(), + } + }, true, true); + const fileWhiteList: FileWhiteList = projectWhiteListManager!.getFileWhiteListMap().get(filePath)!; + if (fileWhiteList?.bytecodeObfuscateKeepInfo?.decoratorMap) { + const decoratorKeys = Object.keys(fileWhiteList.bytecodeObfuscateKeepInfo.decoratorMap); + expect(decoratorKeys.length).to.be.greaterThan(0); + } + }); + }); + + describe('test initScanProjectConfig', function () { + it('scanDecorator is false', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false, false) + expect(scanProjectConfig.scanDecorator).to.be.false; + }); + + it('scanDecorator is default', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false) + expect(scanProjectConfig.scanDecorator).to.be.false; + }); + + it('scanDecorator is true', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false, true) + expect(scanProjectConfig.scanDecorator).to.be.true; + }); }); }); \ No newline at end of file diff --git a/arkguard/test/ut/utils/KeepParameterUtils.spec.ts b/arkguard/test/ut/utils/KeepParameterUtils.spec.ts index 9c1e22f976a22e8c704a6449af40ebb7d9428cc5..5942689068cb9b4ad637a34ad6fa867d5a8b27af 100644 --- a/arkguard/test/ut/utils/KeepParameterUtils.spec.ts +++ b/arkguard/test/ut/utils/KeepParameterUtils.spec.ts @@ -212,8 +212,8 @@ describe('Tester Cases for shouldKeepParameter.', function () { it('Tester 2-10: When node is method and method name is not kept, shouldKeepParameter returns false', function () { let content = `declare class A { - constructor(para1: number); - method(para2: number): void; + constructor(para11: number); + method1(para12: number): void; }`; const ast = ts.createSourceFile(path, content, ts.ScriptTarget.ES2015, true); let method: ts.MethodDeclaration = (ast.statements[0] as ts.ClassDeclaration).members[1] as ts.MethodDeclaration; diff --git a/arkguard/test/ut/utils/NodeUtils.spec.ts b/arkguard/test/ut/utils/NodeUtils.spec.ts index ff2672b37ec77148a7e5a75b13f2e583b5ee3d87..5411595ce4413e78065c4131a946725faac968ac 100644 --- a/arkguard/test/ut/utils/NodeUtils.spec.ts +++ b/arkguard/test/ut/utils/NodeUtils.spec.ts @@ -581,4 +581,47 @@ describe('test for NodeUtils', function () { expect(hasExportModifier(sourceFile.statements[0])).to.be.true; }) }) + + describe('test for isObjectLiteralInAnnotation', function () { + it('should return false when node is not ObjectLiteral', function () { + const node = ts.factory.createObjectBindingPattern([]); + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.d.ets')).to.be.false; + }) + it('should return true if annotation is in .d.ets files', function () { + const node = ts.factory.createObjectLiteralExpression( + [ts.factory.createPropertyAssignment( + ts.factory.createIdentifier("a"), + ts.factory.createNumericLiteral("1") + )], + false + ); + const expr = ts.factory.createCallExpression( + ts.factory.createIdentifier("Anno1"), + undefined, + [node] + ); + (node as Mutable).parent = expr; + const decorator = ts.factory.createDecorator(expr); + (expr as Mutable).parent = decorator; + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.d.ets')).to.be.true; + }) + it('should return true if annotation is in .ts files and with annotationPrefix', function () { + const node = ts.factory.createObjectLiteralExpression( + [ts.factory.createPropertyAssignment( + ts.factory.createIdentifier("a"), + ts.factory.createNumericLiteral("1") + )], + false + ); + const expr = ts.factory.createCallExpression( + ts.factory.createIdentifier("__$$ETS_ANNOTATION$$__Anno1"), + undefined, + [node] + ); + (node as Mutable).parent = expr; + const decorator = ts.factory.createDecorator(expr); + (expr as Mutable).parent = decorator; + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.ts')).to.be.true; + }) +}) }) \ No newline at end of file diff --git a/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts b/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts index 4e7c2ce735dd3957d42034a478d5803a8f69030a..a3675c328738d2c8ad03a09490b8fba788936e0c 100644 --- a/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts +++ b/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts @@ -16,20 +16,23 @@ import * as fs from 'fs'; import * as path from 'path'; import { + PerfMode, TimeAndMemTimeTracker, clearTimeAndMemPrinterData, + configurePerformancePrinter, + disablePrinterTimeAndMemConfig, enableTimeAndMemoryPrint, endSingleFileForMoreTimeEvent, getObfuscationCacheDir, getMemoryPerformanceData, getTimePerformanceData, initPerformanceTimeAndMemPrinter, + initPrinterTimeAndMemConfig, startSingleFileForMoreTimeEvent, writeTimeAndMemoryPerformanceData, } from '../../../src/utils/PrinterTimeAndMemUtils'; import { expect } from 'chai'; import { performanceTimeAndMemPrinter } from '../../../src/ArkObfuscator'; -import type { IOptions } from '../../../src/configs/IOptions'; import { printerTimeAndMemDataConfig } from '../../../src/initialization/Initializer'; describe('test Cases for .', function () { @@ -67,35 +70,50 @@ describe('test Cases for .', function () { }); describe('Tester Cases for ', () => { - it('Printer config is not set', () => { - const mCustomProfiles: IOptions = {}; - initPerformanceTimeAndMemPrinter(mCustomProfiles); - expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; + it('should block performance printer when mTimeAndMemPrinter is false', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + initPerformanceTimeAndMemPrinter(); + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; - }); - - it('Printer config is set all false', () => { - const mCustomProfiles: IOptions = { - mPerformanceTimeAndMemPrinter: { - mFilesPrinter: false, - mSingleFilePrinter: false, - }, - }; - initPerformanceTimeAndMemPrinter(mCustomProfiles); expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; - expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; }); - - it('Printer config is set not all false', () => { - const mCustomProfiles: IOptions = { - mPerformanceTimeAndMemPrinter: { - mFilesPrinter: false, - mSingleFilePrinter: true, - }, - }; - initPerformanceTimeAndMemPrinter(mCustomProfiles); + + it('should not block performance printer when mTimeAndMemPrinter is true', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + initPerformanceTimeAndMemPrinter(); + + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.not.be.undefined; expect(performanceTimeAndMemPrinter.filesPrinter).to.not.be.undefined; + }); + }); + + describe('Tester Cases for ', () => { + it('should configure performance printer for advanced mode', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + performanceTimeAndMemPrinter.singleFilePrinter = undefined; + performanceTimeAndMemPrinter.filesPrinter = undefined; + + configurePerformancePrinter(PerfMode.ADVANCED); + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.not.be.undefined; + expect(performanceTimeAndMemPrinter.filesPrinter).to.not.be.undefined; + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.true; + }); + + it('should block performance printer for normal mode', () => { + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + configurePerformancePrinter(PerfMode.NORMAL); + + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; + expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; }); }); @@ -149,6 +167,22 @@ describe('test Cases for .', function () { }); }); + describe('Tester Cases for ', () => { + it('start a initPrinterTimeAndMemConfig', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + initPrinterTimeAndMemConfig(); + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.true; + }); + }); + + describe('Tester Cases for ', () => { + it('start a disablePrinterTimeAndMemConfig', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; + disablePrinterTimeAndMemConfig(); + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.false; + }); + }); + describe('Tester Cases for ', () => { it('start a singleFile event for more timeEvent when mMoreTimePrint is true', () => { if (!performanceTimeAndMemPrinter.singleFilePrinter) { @@ -273,6 +307,7 @@ describe('test Cases for .', function () { }); await enableTimeAndMemoryPrint(); + await new Promise(resolve => setTimeout(resolve, 100)); expect(fs.existsSync(timePerformanceFilePath)).to.be.true; expect(fs.existsSync(memoryPerformanceFilePath)).to.be.true; @@ -281,6 +316,11 @@ describe('test Cases for .', function () { describe('Tester Cases for ', () => { it('Write file error', () => { + const projectConfig = { + obfuscationOptions: { + obfuscationCacheDir: 'test/', + }, + }; const data = [ { 'name': 'BreakpointConstants.ts', @@ -289,6 +329,7 @@ describe('test Cases for .', function () { }, ]; const fileName = ''; + getObfuscationCacheDir(projectConfig); expect(writeTimeAndMemoryPerformanceData(data, fileName)).to.be.throw; }); }); diff --git a/arkguard/test/ut/utils/ProjectCollections.spec.ts b/arkguard/test/ut/utils/ProjectCollections.spec.ts index f1f6dcd6b3e3c686c2bb4d6eb3fe959e7e70727d..1695ac1e82cb370310c4b07b3b65c05e355a7d16 100644 --- a/arkguard/test/ut/utils/ProjectCollections.spec.ts +++ b/arkguard/test/ut/utils/ProjectCollections.spec.ts @@ -26,7 +26,7 @@ import { FileWhiteList, FileContent } from '../../../src/utils/ProjectCollections'; -import { AtKeepCollections, UnobfuscationCollections } from '../../../src/utils/CommonCollections'; +import { AtIntentCollections, AtKeepCollections, UnobfuscationCollections } from '../../../src/utils/CommonCollections'; import { ApiExtractor } from '../../../src/common/ApiExtractor' import { FileUtils } from '../../../src/utils/FileUtils'; import * as fs from 'fs'; @@ -113,6 +113,8 @@ describe('test for CommonCollections', function () { expect(fileWhiteLists.fileKeepInfo.exported?.globalNames.size).to.be.equal(0); expect(fileWhiteLists.fileKeepInfo.enumProperties.size).to.be.equal(0); expect(fileWhiteLists.fileKeepInfo.stringProperties.size).to.be.equal(0); + expect(fileWhiteLists.fileKeepInfo.arkUIKeepInfo?.propertyNames.size).to.be.equal(0); + expect(fileWhiteLists.fileKeepInfo.arkUIKeepInfo?.globalNames.size).to.be.equal(0); expect(fileWhiteLists.fileReservedInfo.enumProperties.size).to.be.equal(0); expect(fileWhiteLists.fileReservedInfo.propertyParams.size).to.be.equal(0); }); @@ -159,6 +161,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); const fileWhilteList: FileWhiteList | undefined = projectWhiteListManagerForTest.getFileWhiteListMap().get('testPath3'); @@ -171,6 +175,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteList?.fileKeepInfo.exported.globalNames.has('test7')).to.be.true; expect(fileWhilteList?.fileKeepInfo.exported.propertyNames.has('test8')).to.be.true; expect(fileWhilteList?.fileKeepInfo.stringProperties.has('test9')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.globalNames.has('test111')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.propertyNames.has('test112')).to.be.true; expect(fileWhilteList?.fileReservedInfo.enumProperties.has('test10')).to.be.true; expect(fileWhilteList?.fileReservedInfo.propertyParams.has('test11')).to.be.true; expect(fileWhilteListTemp.fileKeepInfo.keepSymbol?.globalNames.size).to.be.equal(1); @@ -184,6 +190,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteListTemp.fileKeepInfo.stringProperties.size).to.be.equal(1); expect(fileWhilteListTemp.fileReservedInfo.enumProperties.size).to.be.equal(1); expect(fileWhilteListTemp.fileReservedInfo.propertyParams.size).to.be.equal(1); + expect(fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.size).to.be.equal(1); + expect(fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.size).to.be.equal(1); }); it('should not collect atKeep if not enabled', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, false, false); @@ -198,6 +206,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); const fileWhilteList: FileWhiteList | undefined = projectWhiteListManager.getFileWhiteListMap().get('testPath4'); @@ -210,6 +220,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteList?.fileKeepInfo.exported.globalNames.has('test7')).to.be.true; expect(fileWhilteList?.fileKeepInfo.exported.propertyNames.has('test8')).to.be.true; expect(fileWhilteList?.fileKeepInfo.stringProperties.has('test9')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.globalNames.has('test111')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.propertyNames.has('test112')).to.be.true; expect(fileWhilteList?.fileReservedInfo.enumProperties.has('test10')).to.be.true; expect(fileWhilteList?.fileReservedInfo.propertyParams.has('test11')).to.be.true; }); @@ -236,6 +248,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo?.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo?.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); projectWhiteListManager.setCurrentCollector('testPath2'); @@ -262,6 +276,10 @@ describe('test for CommonCollections', function () { expect(UnobfuscationCollections.reservedStrProp.size==0).to.be.true; expect(ApiExtractor.mConstructorPropertySet.size==0).to.be.true; expect(ApiExtractor.mEnumMemberSet.size==0).to.be.true; + expect(AtIntentCollections.globalNames.size==1).to.be.true; + expect(AtIntentCollections.propertyNames.size==1).to.be.true; + expect(AtIntentCollections.globalNames.has('test111')).to.be.true; + expect(AtIntentCollections.propertyNames.has('test112')).to.be.true; }); it('should update fileWhiteLists and projectWhiteList if is incremental(project white list changed)', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, true, true); @@ -281,6 +299,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test122'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test123'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test31'); @@ -313,6 +333,8 @@ describe('test for CommonCollections', function () { expect(ApiExtractor.mConstructorPropertySet.has('test31')).to.be.true; expect(UnobfuscationCollections.reservedExportName.has('test33')).to.be.true; expect(UnobfuscationCollections.reservedExportNameAndProp.has('test12')).to.be.false; + expect(AtIntentCollections.globalNames.has('test122')).to.be.true; + expect(AtIntentCollections.propertyNames.has('test123')).to.be.true; }); it('should update fileWhiteLists and projectWhiteList if is incremental(project white list not changed)', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, true, true); @@ -332,6 +354,24 @@ describe('test for CommonCollections', function () { expect(projectWhiteListManager.getShouldReObfuscate()).to.be.false; }); }); + + describe('test for createProjectWhiteList when bytecodeObfuscate enable', function () { + it('should add property decorated to projectWhiteList when bytecodeObfuscate enable)', () => { + let projectWhiteListManager = new ProjectWhiteListManager(cachePath, false, false); + projectWhiteListManager.setCurrentCollector("testPath5") + const fileWhiteLists = projectWhiteListManager.createFileWhiteList(); + fileWhiteLists.bytecodeObfuscateKeepInfo = { + "decoratorMap": { + "Track": ["prop1"] + } + }; + projectWhiteListManager.getFileWhiteListMap().set("testPath5", fileWhiteLists); + projectWhiteListManager.createOrUpdateWhiteListCaches(); + const cacheContent = fs.readFileSync(projectWhiteListManager.getProjectWhiteListCachePath(), 'utf-8'); + const parsedCache = JSON.parse(cacheContent); + expect(parsedCache.projectKeepInfo.globalNames).to.include("prop1"); + }); + }) }) describe('test for FilePathManager', function () { diff --git a/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts b/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts index ed10c4ec266e3d5a92ce9832a2ca64cf61e61ee0..a9be991b62ad28f0994185cffb25638e89498b37 100644 --- a/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts +++ b/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts @@ -317,7 +317,7 @@ describe('ScopeAnalyzer ut', function () { sourceFile = createSourceFile(newFilePath, fileContent, ScriptTarget.ES2015, true); checker = TypeUtils.createChecker(sourceFile); scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, newFilePath); } describe('analyze', function () { @@ -456,7 +456,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); const functionDeclaration = sourceFile.statements[0] as FunctionDeclaration; const parameter = functionDeclaration.parameters[0] as ParameterDeclaration; @@ -472,7 +472,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); assert.strictEqual(reservedNames.size === 0, true); @@ -542,7 +542,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -581,13 +581,13 @@ describe('ScopeAnalyzer ut', function () { let scopeManager = createScopeManager(); it('exportObfuscation is false', function () { - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); const rootScope = scopeManager.getRootScope(); assert.deepEqual(rootScope.defs.size, 0); }); it('exportObfuscation is true', function () { - scopeManager.analyze(sourceFile, checker, true); + scopeManager.analyze(sourceFile, checker, true, filePath); const rootScope = scopeManager.getRootScope(); assert.strictEqual(rootScope.defs.size, 1); }); @@ -623,7 +623,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -666,7 +666,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -701,7 +701,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); diff --git a/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets b/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6464b217cfcc049996e4aad63162e0e64cfa488 --- /dev/null +++ b/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets @@ -0,0 +1,8 @@ +@ObservedV2 +class son{ + @Trace aaaa:number=100; +} + +class father{ + bbb:number=100; +} \ No newline at end of file diff --git a/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets b/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets new file mode 100644 index 0000000000000000000000000000000000000000..c78baa7d212e30fdf4556887babdd3baa3b3fbaa --- /dev/null +++ b/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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. + */ + +// @KeepSymbol +@interface MyAnnotation01 { + authorName: string; +} + +// @KeepSymbol +export @interface MyAnnotation02 { + authorName: string; +} + +@interface MyAnnotation03 { + // @KeepSymbol + authorName: string; +} + +// @KeepAsConsumer +@interface MyAnnotation04 { + authorName: string; +} + +// @KeepAsConsumer +export @interface MyAnnotation05 { + authorName: string; +} + +@interface MyAnnotation06 { + // @KeepAsConsumer + authorName: string; +} \ No newline at end of file diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json index 9112b78b8c162e2b22640688812abe5562b5a399..6bde5ff86f41a23d37e29854d37ad3d97906b01f 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ "globalNames": [] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -89,7 +101,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json index f0d382095b9c07298d38c9d700aba35cb3ef92e6..419d982f190777835007520932081ad18917268c 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -108,7 +120,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test123" + ], + "globalNames": [ + "test122" + ] + } }, "fileReservedInfo": { "enumProperties": [ diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json index 809b11a7834e2585c2f32c6e871671a0abf6e7fd..af417be3794957d5ec09c6ccfcd765e3db28256d 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -108,7 +120,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test123" + ], + "globalNames": [ + "test122" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -143,7 +163,11 @@ "enumProperties": [ "test02" ], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], diff --git a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json index d7ce25e326a86bc8b3f0962365f9ddd08a4f3e47..a2a5d19ca71fef5d36055828a0216b533cbd7a8c 100644 --- a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json +++ b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json @@ -9,12 +9,14 @@ "test02", "test6", "test9", + "test112", "test12" ], "globalNames": [ "test1", "test3", "test7", + "test111", "test13" ] }, diff --git a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json index 212230f3d0898b7467e954306840c9ab23a84caf..c3773352499cb6ebb61bea4d7330df463255b235 100644 --- a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json +++ b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json @@ -8,14 +8,18 @@ "test8", "test02", "test6", - "test9" + "test9", + "test112", + "test123" ], "globalNames": [ "test1", "test3", "test7", + "test111", "test33", - "test32" + "test32", + "test122" ] }, "projectReservedInfo": { diff --git a/arkguard/tools/timesum.py b/arkguard/tools/timesum.py index 20781a7d79c0715ba9e931a608bd09d41c772a98..d7515007b4aed0330f5b43c39eff482d77dc2608 100644 --- a/arkguard/tools/timesum.py +++ b/arkguard/tools/timesum.py @@ -19,6 +19,8 @@ limitations under the License. from collections import defaultdict import json import logging +import os +import stat # Configure logging to display timestamps and messages logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s") @@ -33,7 +35,8 @@ def gen_parent(data): """ # Sort the data by timestamp (ts) data = sorted(data, key=lambda x: x["ts"]) - for i in range(len(data)): + data_length = len(data) + for i in range(data_length): current = data[i] # Current event current_end = current["ts"] + current["dur"] # End time of the current event for j in range(i - 1, -1, -1): # Candidate parent event @@ -136,8 +139,12 @@ def re_gen_ts_and_dur(data_with_parent): flattened.extend(nodes) # Save the flattened data to a JSON file - with open("data.json", "w") as f: - json.dump(flattened, f, indent=2) + if os.path.exists('data.json'): + os.remove('data.json') + flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL + modes = stat.S_IWUSR | stat.S_IRUSR + with os.fdopen(os.open('data.json', flags, modes), 'w') as file: + json.dump(flattened, file, indent=2) return groups @@ -158,8 +165,8 @@ def group_by_parent(data): if __name__ == "__main__": # Load input data from a JSON file with open("timePerformanceData.json", "r") as f: - data = json.load(f) + datas = json.load(f) # Generate parent information for each event - data_with_parent = gen_parent(data) + data_with_parents = gen_parent(datas) # Regenerate timestamps and durations based on parent relationships - re_gen_ts_and_dur(data_with_parent) + re_gen_ts_and_dur(data_with_parents) diff --git a/bundle.json b/bundle.json index 0029c20177423dde5df05252502ca58f60d61776..3ea4b67716580490c83ee24a95b068b98b2402fd 100644 --- a/bundle.json +++ b/bundle.json @@ -1,5 +1,5 @@ { - "name": "@arkcompiller/ets_frontend", + "name": "@ohos/ets_frontend", "description": "支持应用TS/JS语言代码的编译,行为符合ArkUI框架需要的Strict模式的ES2015标准", "version": "3.1", "license": "Apache License 2.0", @@ -22,12 +22,11 @@ "runtime_core", "zlib", "bounds_checking_function", - "protobuf" + "protobuf", + "icu", + "abseil-cpp" ], - "third_party": [ - "json", - "icu" - ] + "third_party": [] }, "build": { "sub_component": [ diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index d7f663a2bb92b56aac0ea96c668bfc51ea120271..56f0a55564f9829840842e4c3ca74afb81840ac9 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -293,14 +293,18 @@ config("es2abc_config_src") { config("es2abc_config_common") { configs = [ "$ark_root:ark_config", - "$sdk_libc_secshared_config", "$ark_root/libpandafile:arkfile_public_config", "$ark_root/libpandabase:arkbase_public_config", "$ark_root/assembler:arkassembler_public_config", "$ark_root/abc2program:abc2program_public_config", - "$ark_third_party_root/json:nlohmann_json_config", ":es2abc_config_src", ] + if (defined(is_arkui_x) && is_arkui_x) { + configs += [ + "$sdk_libc_secshared_config", + "$ark_third_party_root/json:nlohmann_json_config", + ] + } if (enable_bytecode_optimizer) { defines = [ "ENABLE_BYTECODE_OPT" ] @@ -343,7 +347,11 @@ action_foreach("gen_keywords_headers") { # generate headers for es2panda compiler isa_gen = "${ark_root}/isa/gen.rb" -isa_gen_data = "$root_gen_dir/isa/isa.yaml" +if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + isa_gen_data = "$root_build_dir/gen/isa/isa.yaml" +} else { + isa_gen_data = "$root_gen_dir/isa/isa.yaml" +} isa_gen_require = "${ark_root}/isa/isapi.rb" action_foreach("gen_isa_headers") { deps = [ "//arkcompiler/runtime_core/isa:isa_combine" ] @@ -361,11 +369,13 @@ action_foreach("gen_isa_headers") { outputs = [ "${generated_header_dir}/{{source_name_part}}" ] script = "scripts/gen_isa.sh" - inputs = [ - "${isa_gen}", - "${isa_gen_data}", - "${isa_gen_require}", - ] + if (defined(ohos_indep_compiler_enable) && !ohos_indep_compiler_enable) { + inputs = [ + "${isa_gen}", + "${isa_gen_data}", + "${isa_gen_require}", + ] + } args = [ "-g", rebase_path("${isa_gen}"), @@ -394,21 +404,25 @@ ohos_static_library("es2panda_lib") { "../merge_abc:panda_assembly_proto_public_config", ] - include_dirs = [ - "${target_out_dir}", - "//third_party/icu/icu4c/source/common", - "//third_party/icu/icu4c/source/i18n", - "//third_party/icu/icu4c/source", - ] + include_dirs = [ "${target_out_dir}" ] deps = [ ":gen_isa_headers", ":gen_keywords_headers", - "$ark_third_party_root/icu/icu4c:static_icuuc", "../merge_abc:panda_assembly_proto_static", ] + external_deps = [ sdk_libc_secshared_dep ] + if (ark_standalone_build || (defined(is_arkui_x) && is_arkui_x)) { + deps += [ "$ark_third_party_root/icu/icu4c:static_icuuc" ] + include_dirs += [ + "//third_party/icu/icu4c/source/common", + "//third_party/icu/icu4c/source/i18n", + "//third_party/icu/icu4c/source", + ] + } else { + external_deps += [ "icu:static_icuuc" ] + } - external_deps = [] if (!is_arkui_x) { external_deps += [ "json:nlohmann_json_static", @@ -451,7 +465,14 @@ ohos_static_library("es2panda_lib") { "-Wno-c++20-designator", "-Wno-implicit-fallthrough", ] - + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ "runtime_core:libarkassembler_static" ] + if (enable_hilog) { + external_deps += [ "hilog:libhilog" ] + } + cflags += [ "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/compiler/generated") ] + } part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -481,7 +502,30 @@ ohos_executable("es2panda") { "//arkcompiler/ets_frontend/merge_abc:panda_assembly_proto_static", ] - external_deps = [ "zlib:libz" ] + external_deps = [ + "json:nlohmann_json_static", + "zlib:libz", + sdk_libc_secshared_dep, + ] + + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ + "abseil-cpp:absl_base_static", + "icu:shared_icuuc", + "runtime_core:libarkassembler_static", + ] + if (enable_hilog) { + external_deps += [ "hilog:libhilog" ] + } + cflags = [ + "-Wno-constant-conversion", + "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/bytecode_optimizer"), + "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/compiler/generated"), + ] + } + if (ark_standalone_build) { external_deps += [ "protobuf:protobuf_lite_static", diff --git a/es2panda/aot/emitFiles.cpp b/es2panda/aot/emitFiles.cpp index 10396d754610c0c05f3856e6da4a85b6d8babdde..121f0824f43a815d4c2ac6cb215cea27a2ff8fb3 100644 --- a/es2panda/aot/emitFiles.cpp +++ b/es2panda/aot/emitFiles.cpp @@ -49,13 +49,10 @@ void EmitFileQueue::Schedule() { ASSERT(jobsCount_ == 0); std::unique_lock lock(m_); - auto targetApi = options_->CompilerOptions().targetApiVersion; - auto targetSubApi = options_->CompilerOptions().targetApiSubVersion; if (mergeAbc_) { // generate merged abc - auto emitMergedAbcJob = new EmitMergedAbcJob(options_->CompilerOutput(), - options_->CompilerOptions().transformLib, progsInfo_, targetApi, targetSubApi); + auto emitMergedAbcJob = new EmitMergedAbcJob(options_, progsInfo_); // One job should be placed before the jobs on which it depends to prevent blocking jobs_.push_back(emitMergedAbcJob); jobsCount_++; @@ -65,6 +62,8 @@ void EmitFileQueue::Schedule() ScheduleEmitCacheJobs(emitMergedAbcJob); } } else { + auto targetApi = options_->CompilerOptions().targetApiVersion; + auto targetSubApi = options_->CompilerOptions().targetApiSubVersion; for (const auto &info: progsInfo_) { try { // generate multi abcs @@ -109,9 +108,11 @@ void EmitMergedAbcJob::Run() progs.push_back(&(info.second->program)); } + panda::pandasm::EmitterConfig emitConfig {targetApiVersion_, targetApiSubVersion_, + options_->CompilerOptions().isDebug, options_->CompilerOptions().fileThreadCount}; bool success = panda::pandasm::AsmEmitter::EmitPrograms( panda::os::file::File::GetExtendedFilePath(outputFileName_), progs, true, - targetApiVersion_, targetApiSubVersion_); + emitConfig); panda::Timer::timerEnd(panda::EVENT_EMIT_MERGED_PROGRAM, ""); diff --git a/es2panda/aot/emitFiles.h b/es2panda/aot/emitFiles.h index 9a223386c6741919cfc26cc7bef3efd565348038..f3d3ad2e78b307194375f647fc1956115bc80ff3 100644 --- a/es2panda/aot/emitFiles.h +++ b/es2panda/aot/emitFiles.h @@ -45,17 +45,19 @@ private: class EmitMergedAbcJob : public util::WorkerJob { public: - explicit EmitMergedAbcJob(const std::string &outputFileName, const std::string &transformLib, - const std::map &progsInfo, - uint8_t targetApi, std::string targetSubApi) - : outputFileName_(outputFileName), transformLib_(transformLib), - progsInfo_(progsInfo), targetApiVersion_(targetApi), targetApiSubVersion_(targetSubApi) {}; + explicit EmitMergedAbcJob(const std::unique_ptr &options, + const std::map &progsInfo) + : options_(options), outputFileName_(options->CompilerOutput()), + transformLib_(options->CompilerOptions().transformLib), + progsInfo_(progsInfo), targetApiVersion_(options->CompilerOptions().targetApiVersion), + targetApiSubVersion_(options->CompilerOptions().targetApiSubVersion) {}; NO_COPY_SEMANTIC(EmitMergedAbcJob); NO_MOVE_SEMANTIC(EmitMergedAbcJob); ~EmitMergedAbcJob() override = default; void Run() override; private: + const std::unique_ptr &options_; std::string outputFileName_; std::string transformLib_; const std::map &progsInfo_; diff --git a/es2panda/aot/options.cpp b/es2panda/aot/options.cpp index 0ae82fe65fdb6c60b9628bb340c07f2ff3dbccb1..3a4f766e5a064d40b9e26d26c797b459ce850f18 100644 --- a/es2panda/aot/options.cpp +++ b/es2panda/aot/options.cpp @@ -420,8 +420,8 @@ bool Options::Parse(int argc, const char **argv) "bc-min-version are enabled, only bc-version will take effects"); panda::PandArg bcMinVersion("bc-min-version", false, "Print ark bytecode minimum supported version"); // todo(huyunhui): change default api verion to 0 after refactoring - // Current api version is 18 - panda::PandArg targetApiVersion("target-api-version", 18, + // Current api version is 20 + panda::PandArg targetApiVersion("target-api-version", 20, "Specify the targeting api version for es2abc to generated the corresponding version of bytecode"); panda::PandArg targetBcVersion("target-bc-version", false, "Print the corresponding ark bytecode version"\ "for target api version. If both target-bc-version and bc-version are enabled, only target-bc-version"\ diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index 32b9e3809cb95483aee1f42278fc31916aca99e4..c26216945a93b8924f2a8439e2e3c1eb86f95a2c 100644 --- a/es2panda/binder/binder.cpp +++ b/es2panda/binder/binder.cpp @@ -757,6 +757,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) } case ir::AstNodeType::SUPER_EXPRESSION: { VariableScope *varScope = scope_->EnclosingVariableScope(); + CHECK_NOT_NULL(varScope); varScope->AddFlag(VariableScopeFlags::USE_SUPER); ResolveReferences(childNode); @@ -844,6 +845,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) if (Program()->Extension() == ScriptExtension::TS && (Program()->TargetApiVersion() < 11 || (!prop->IsStatic() && !prop->IsPrivate()))) { const ir::ScriptFunction *ctor = util::Helpers::GetContainingConstructor(prop); + CHECK_NOT_NULL(ctor); auto scopeCtx = LexicalScope::Enter(this, ctor->Scope()); ResolveReferences(childNode); break; diff --git a/es2panda/compiler/core/dynamicContext.cpp b/es2panda/compiler/core/dynamicContext.cpp index a6e2c3d60f869ed0da5b74792dce646fca4f63f2..5949319bc46e5e18f31266a8e77ba48570edd3f8 100644 --- a/es2panda/compiler/core/dynamicContext.cpp +++ b/es2panda/compiler/core/dynamicContext.cpp @@ -95,6 +95,17 @@ bool LexEnvContext::HasTryCatch() const return envScope_->HasEnv(); } +void LexEnvContext::HandleForUpdateDirectReturnContext() +{ + if (!envScope_->HasEnv()) { + return; + } + const auto *node = envScope_->Scope()->Node(); + if (node->IsForUpdateStatement()) { + pg_->PopLexEnv(node); + } +} + void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, const util::StringView &targetLabel) { @@ -105,7 +116,8 @@ void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, const auto *node = envScope_->Scope()->Node(); // Process the continue label in the ForUpdate Statement. if (node->IsForUpdateStatement()) { - if (targetLabel == LabelTarget::CONTINUE_LABEL || targetLabel == LabelTarget::BREAK_LABEL) { + if (targetLabel == LabelTarget::CONTINUE_LABEL || targetLabel == LabelTarget::BREAK_LABEL || + targetLabel == LabelTarget::RETURN_LABEL) { return; } diff --git a/es2panda/compiler/core/dynamicContext.h b/es2panda/compiler/core/dynamicContext.h index 3fa63347fd75b3c8d6fb343a2c89c3d4f7841f83..3ab8647bc270927d616d51862e0c195f537e84c6 100644 --- a/es2panda/compiler/core/dynamicContext.h +++ b/es2panda/compiler/core/dynamicContext.h @@ -125,6 +125,12 @@ public: { return tryEndFlag; } + /** + * Handle for update direct return context + * If the lexical environment context is in for update statement, pop the lexical environment + */ + void HandleForUpdateDirectReturnContext(); + private: VariableEnvScope *envScope_; CatchTable *catchTable_ {}; diff --git a/es2panda/compiler/core/emitter/emitter.cpp b/es2panda/compiler/core/emitter/emitter.cpp index 051e0d84d0fd7a81ac2b1da693f3fa65364a362c..3855d73498c1fc3809c821a5a5a9f66fbc519d3e 100644 --- a/es2panda/compiler/core/emitter/emitter.cpp +++ b/es2panda/compiler/core/emitter/emitter.cpp @@ -71,11 +71,15 @@ void FunctionEmitter::Generate(util::PatchFix *patchFixHelper) GenFunctionCatchTables(); GenLiteralBuffers(); GenConcurrentFunctionModuleRequests(); - GenAnnotations(); + if (pg_->Binder()->Program()->IsEnableAnnotations()) { + GenAnnotations(); + } if (patchFixHelper != nullptr) { patchFixHelper->ProcessFunction(pg_, func_, literalBuffers_); } - GenExpectedPropertyCountAnnotation(); + if (util::Helpers::IsEnableExpectedPropertyCountApiVersion(pg_->Binder()->Program()->TargetApiVersion())) { + GenExpectedPropertyCountAnnotation(); + } GenSlotNumberAnnotation(); if (pg_->Context()->IsMergeAbc()) { GenConcurrentModuleRequestsAnnotation(); @@ -207,11 +211,6 @@ void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, panda::pandasm: if (pg_->IsDebug()) { size_t insLen = GetIRNodeWholeLength(ins); - if (insLen != 0) { - pandaIns->ins_debug.bound_left = offset_; - pandaIns->ins_debug.bound_right = offset_ + insLen; - } - offset_ += insLen; pandaIns->ins_debug.column_number = columnNum; } @@ -453,10 +452,9 @@ void FunctionEmitter::GenFunctionInstructions() func_->ins.reserve(pg_->Insns().size()); for (const auto *ins : pg_->Insns()) { - auto &pandaIns = func_->ins.emplace_back(); - - ins->Transform(&pandaIns); - GenInstructionDebugInfo(ins, &pandaIns); + auto *pandaIns = ins->Transform(); + func_->ins.emplace_back(pandaIns); + GenInstructionDebugInfo(ins, pandaIns); } } @@ -668,7 +666,9 @@ Emitter::Emitter(CompilerContext *context): source_lang_(context->SourceLang()) } AddSharedModuleRecord(context); AddScopeNamesRecord(context); - AddExpectedPropertyCountRecord(); + if (util::Helpers::IsEnableExpectedPropertyCountApiVersion(context->Binder()->Program()->TargetApiVersion())) { + AddExpectedPropertyCountRecord(); + } AddSlotNumberRecord(); if (context->IsMergeAbc()) { AddConcurrentModuleRequestsRecord(); @@ -1257,7 +1257,7 @@ void Emitter::DumpAsm(const panda::pandasm::Program *prog) ss << ") {" << std::endl; for (const auto &ins : func.ins) { - ss << (ins.set_label ? "" : "\t") << ins.ToString("", true, func.GetTotalRegs()) << std::endl; + ss << (ins->IsLabel() ? "" : "\t") << ins->ToString("", true, func.GetTotalRegs()) << std::endl; } ss << "}" << std::endl << std::endl; diff --git a/es2panda/compiler/core/emitter/emitter.h b/es2panda/compiler/core/emitter/emitter.h index f43cf2f36de5a70bce851154e7177481a1595fc3..7353567fc52414202740c3d32ba840b41e788a3a 100644 --- a/es2panda/compiler/core/emitter/emitter.h +++ b/es2panda/compiler/core/emitter/emitter.h @@ -34,7 +34,7 @@ namespace panda::pandasm { struct Program; struct Function; -struct Ins; +class Ins; struct Record; } // namespace panda::pandasm diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp index 4806d01e945863fb973a04d9aea304d436751f2c..f2bb23e6996107fdacf3df580a268f0918f68058 100644 --- a/es2panda/compiler/core/pandagen.cpp +++ b/es2panda/compiler/core/pandagen.cpp @@ -105,7 +105,8 @@ void PandaGen::SetInSendable() size_t PandaGen::GetExpectedPropertyCount() const { - if (rootNode_->IsProgram()) { + if (rootNode_->IsProgram() || + !util::Helpers::IsEnableExpectedPropertyCountApiVersion(context_->Binder()->Program()->TargetApiVersion())) { return 0; } @@ -1267,6 +1268,15 @@ void PandaGen::ValidateClassDirectReturn(const ir::AstNode *node) BranchIfStrictNotUndefined(node, notUndefined); GetThis(func); ThrowIfSuperNotCorrectCall(func, 0); + + auto *iter = dynamicContext_; + while (iter) { + if (iter->Type() == DynamicContextType::LEX_ENV) { + auto *envContext = static_cast(iter); + envContext->HandleForUpdateDirectReturnContext(); + } + iter = iter->Prev(); + } Branch(node, condEnd); SetLabel(node, notUndefined); diff --git a/es2panda/compiler/debugger/debuginfoDumper.cpp b/es2panda/compiler/debugger/debuginfoDumper.cpp index 37d2beb5aaea490381b03d9ee91239ada5c06fb0..5bbbd2b5d716bc5260b8bdfe1cb4b9e6f9cacfff 100644 --- a/es2panda/compiler/debugger/debuginfoDumper.cpp +++ b/es2panda/compiler/debugger/debuginfoDumper.cpp @@ -55,7 +55,7 @@ void DebugInfoDumper::WrapArray(const char *name, const std::vector &array, b for (elem = array.begin(); elem != array.end(); ++elem) { Indent(); // NOLINTNEXTLINE - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { WriteIns(*elem); // NOLINTNEXTLINE } else if constexpr (std::is_same_v) { @@ -86,25 +86,19 @@ void DebugInfoDumper::WrapArray(const char *name, const std::vector &array, b ss_ << "]" << PutComma(comma); } -void DebugInfoDumper::WriteIns(const pandasm::Ins &ins) +void DebugInfoDumper::WriteIns(const pandasm::InsPtr &ins) { ss_ << "{"; - { - pandasm::Ins insCopy; - insCopy.opcode = ins.opcode; - insCopy.set_label = ins.set_label; - insCopy.label = ins.label; - WriteProperty("opcode", insCopy.ToString()); - } + WriteProperty("opcode", ins->OpcodeToString()); indent_++; - WrapArray("regs", ins.regs); - WrapArray("ids", ins.ids); - WrapArray("imms", ins.imms); + WrapArray("regs", ins->Regs()); + WrapArray("ids", ins->Ids()); + WrapArray("imms", ins->Imms()); ss_ << std::endl; Indent(); ss_ << "\"label\": " - << "\"" << ins.label << "\","; - WritePosInfo(ins.ins_debug); + << "\"" << (ins->IsLabel() ? ins->Label() : "") << "\","; + WritePosInfo(ins->ins_debug); indent_--; Indent(); ss_ << "}"; @@ -129,8 +123,6 @@ void DebugInfoDumper::WritePosInfo(const pandasm::debuginfo::Ins &posInfo) ss_ << std::endl; Indent(); ss_ << "\"debug_pos_info\": {"; - WriteProperty("boundLeft", posInfo.bound_left); - WriteProperty("boundRight", posInfo.bound_right); WriteProperty("sourceLineNum", static_cast(posInfo.line_number), false); Indent(); ss_ << "}" << std::endl; diff --git a/es2panda/compiler/debugger/debuginfoDumper.h b/es2panda/compiler/debugger/debuginfoDumper.h index a9d0aecf5ad882c84432dd1283e0b584016b0e50..02a6dfbbbfdbaf9a87cf3448dc21797b60a1544c 100644 --- a/es2panda/compiler/debugger/debuginfoDumper.h +++ b/es2panda/compiler/debugger/debuginfoDumper.h @@ -36,7 +36,7 @@ public: private: template void WrapArray(const char *name, const std::vector &array, bool comma = true); - void WriteIns(const pandasm::Ins &ins); + void WriteIns(const pandasm::InsPtr &ins); void WriteMetaData(const std::vector &metaData); void WriteProperty(const char *key, const Value &value, bool comma = true); void WritePosInfo(const pandasm::debuginfo::Ins &posInfo); diff --git a/es2panda/compiler/templates/isa.h.erb b/es2panda/compiler/templates/isa.h.erb index 9d5137be16beb2f485a1461f27f1544316ad5ad3..eeaef9e919d300d1e05b3d62dac41860be398271 100644 --- a/es2panda/compiler/templates/isa.h.erb +++ b/es2panda/compiler/templates/isa.h.erb @@ -57,11 +57,9 @@ public: return 0; } - void Transform(pandasm::Ins *ins) const override + pandasm::Ins *Transform() const override { - ins->opcode = pandasm::Opcode::INVALID; - ins->set_label = true; - ins->label = id_; + return new pandasm::LabelIns(id_); } ICSlot SetIcSlot(IcSizeType currentSlot) override @@ -236,30 +234,21 @@ public: return <%= reg_cnt %>; } - void Transform(pandasm::Ins* ins) const override + pandasm::Ins *Transform() const override { - ins->opcode = pandasm::Opcode::<%= node_kind %>; -% if op_map['reg'].length != 0 - ins->regs.reserve(<%= op_map['reg'].length %>); -% end -% if op_map['imm'].length != 0 - ins->imms.reserve(<%= op_map['imm'].length %>); -% end -% if op_map['str'].length + op_map['lbl'].length != 0 - ins->ids.reserve(<%= op_map['str'].length + op_map['lbl'].length %>); -% end -% for reg in op_map['reg'] - ins->regs.emplace_back(<%= reg %>); -% end -% for imm in op_map['imm'] - ins->imms.emplace_back(<%= imm %>); -% end -% for str in op_map['str'] - ins->ids.emplace_back(<%= str %>.Mutf8()); -% end -% for lbl in op_map['lbl'] - ins->ids.emplace_back(<%= lbl %>->Id()); +% pa_ins_args_list = Array.new +% ctor_arg_list.each do |arg| +% type = arg.split(" ")[0] +% name = arg.split(" ")[1] +% if type == "util::StringView" +% pa_ins_args_list.push("#{name}_.Mutf8()") +% elsif type == "Label*" +% pa_ins_args_list.push("#{name}_->Id()") +% else +% pa_ins_args_list.push("#{name}_") +% end % end + return new pandasm::<%= class_name %>(<%= pa_ins_args_list.join(", ") %>); } ICSlot SetIcSlot(IcSizeType slot) override diff --git a/es2panda/es2abc_config.gni b/es2panda/es2abc_config.gni index 7f9c8c833a0653ee3e86f41759b99f239f16c40b..9427086588d14b3b6294d1dce362f7f525ffd18e 100644 --- a/es2panda/es2abc_config.gni +++ b/es2panda/es2abc_config.gni @@ -64,7 +64,17 @@ template("es2abc_gen_abc") { script = "${es2abc_root}/scripts/generate_js_bytecode.py" deps = extra_dependencies - deps += es2abc_build_deps + if (ark_standalone_build || is_arkui_x) { + deps += es2abc_build_deps + } else { + if (host_toolchain == toolchain_mac) { + external_deps = ["ets_frontend:es2panda($toolchain_mac)"] + } else if (host_toolchain == toolchain_win) { + external_deps = ["ets_frontend:es2panda(${host_toolchain})"] + } else { + external_deps = ["ets_frontend:es2panda($toolchain_linux)"] + } + } args = [ "--src-js", @@ -125,7 +135,15 @@ template("es2abc_gen_newest_abc") { script = "${es2abc_root}/scripts/generate_js_bytecode.py" deps = extra_dependencies - deps += es2abc_build_deps + if (host_toolchain == toolchain_mac) { + external_deps = ["ets_frontend:es2panda($toolchain_mac)"] + } else if (host_toolchain == toolchain_win) { + external_deps = ["ets_frontend:es2panda(${host_toolchain})"] + } else if (ark_standalone_build) { + deps += es2abc_build_deps + } else { + external_deps = ["ets_frontend:es2panda($toolchain_linux)"] + } args = [ "--src-js", diff --git a/es2panda/es2panda.cpp b/es2panda/es2panda.cpp index 3bb600c0385622e95f9e2a1bf4113dedacca6175..ddd62b5d9ed6c5e269071188dafac115873cdcd9 100644 --- a/es2panda/es2panda.cpp +++ b/es2panda/es2panda.cpp @@ -223,9 +223,9 @@ void Compiler::DumpAsm(const panda::pandasm::Program *prog) int Compiler::CompileFiles(CompilerOptions &options, std::map &progsInfo, panda::ArenaAllocator *allocator) { - util::SymbolTable *symbolTable = nullptr; + std::unique_ptr symbolTable; if (!options.patchFixOptions.symbolTable.empty() || !options.patchFixOptions.dumpSymbolTable.empty()) { - symbolTable = new util::SymbolTable(options.patchFixOptions.symbolTable, + symbolTable = std::make_unique(options.patchFixOptions.symbolTable, options.patchFixOptions.dumpSymbolTable); if (!symbolTable->Initialize(options.targetApiVersion, options.targetApiSubVersion)) { std::cerr << "Failed to initialize for Hotfix." << std::endl; @@ -236,7 +236,7 @@ int Compiler::CompileFiles(CompilerOptions &options, bool failed = false; std::unordered_set optimizationPendingProgs; auto queue = new compiler::CompileFileQueue(options.fileThreadCount, &options, progsInfo, - optimizationPendingProgs, symbolTable, allocator); + optimizationPendingProgs, symbolTable.get(), allocator); try { queue->Schedule(); @@ -256,8 +256,6 @@ int Compiler::CompileFiles(CompilerOptions &options, if (!options.patchFixOptions.dumpSymbolTable.empty()) { symbolTable->WriteSymbolTable(); } - delete symbolTable; - symbolTable = nullptr; } if (options.requireGlobalOptimization) { diff --git a/es2panda/ir/base/annotation.h b/es2panda/ir/base/annotation.h index ce9c16f1721cc92318dbf4acff85b96bbbf93199..6df31ff5a5b4033782bcc32247f1b670f5ffadaf 100644 --- a/es2panda/ir/base/annotation.h +++ b/es2panda/ir/base/annotation.h @@ -20,8 +20,7 @@ #include #include #include - -#include +#include namespace panda::es2panda::compiler { class PandaGen; @@ -48,9 +47,7 @@ public: name_.insert(0, "."); expr = expr->AsMemberExpression()->Object(); } - name_.insert(0, expr->AsIdentifier()->Name().Utf8()); - name_.erase(0, std::strlen(annotationPrefix)); nameView_ = util::StringView(name_); } diff --git a/es2panda/ir/expressions/callExpression.cpp b/es2panda/ir/expressions/callExpression.cpp index 96085be9abf3b5aae3ab14ebbf795f948895d79f..cc1963c9c7e2328303b78c411401b456ba3ec07f 100644 --- a/es2panda/ir/expressions/callExpression.cpp +++ b/es2panda/ir/expressions/callExpression.cpp @@ -180,7 +180,11 @@ void CallExpression::Compile(compiler::PandaGen *pg) const realCallee->Compile(pg); } - pg->StoreAccumulator(this, callee); + if (realCallee->IsMemberExpression()) { + pg->StoreAccumulator(realCallee->AsMemberExpression()->Property(), callee); + } else { + pg->StoreAccumulator(this, callee); + } pg->GetOptionalChain()->CheckNullish(optional_, callee); if (containsSpread) { @@ -202,6 +206,16 @@ void CallExpression::Compile(compiler::PandaGen *pg) const } if (hasThis) { + /* + * To obtain more accurate line number information in the MemberExpression scenario, + * bind CallThis to the property node instead of the entire callee. + * especially for cases involving async stack tracing. + */ + if (realCallee->IsMemberExpression()) { + pg->CallThis(realCallee->AsMemberExpression()->Property(), callee, + static_cast(arguments_.size() + 1)); + return; + } pg->CallThis(this, callee, static_cast(arguments_.size() + 1)); return; } diff --git a/es2panda/ir/expressions/memberExpression.cpp b/es2panda/ir/expressions/memberExpression.cpp index c86f519c0a84935cbc97ad19c577e4c2b68acaaf..c36674e1608c5dd5e23ecb151f308d7cf5a034ce 100644 --- a/es2panda/ir/expressions/memberExpression.cpp +++ b/es2panda/ir/expressions/memberExpression.cpp @@ -93,9 +93,9 @@ void MemberExpression::Compile(compiler::PandaGen *pg, compiler::VReg objReg) co compiler::Operand prop = CompileKey(pg); if (object_->IsSuperExpression()) { - pg->LoadSuperProperty(this, objReg, prop); + pg->LoadSuperProperty(property_, objReg, prop); } else { - pg->LoadObjProperty(this, objReg, prop); + pg->LoadObjProperty(property_, objReg, prop); } } diff --git a/es2panda/ir/irnode.h b/es2panda/ir/irnode.h index 576c50cbf3a23e6f5b412c277434b10335623747..bde613106d340335170fef5d04fe8249cf14d994 100644 --- a/es2panda/ir/irnode.h +++ b/es2panda/ir/irnode.h @@ -33,7 +33,7 @@ class AstNode; } // namespace panda::es2panda::ir namespace panda::pandasm { -struct Ins; +class Ins; } // namespace panda::pandasm namespace panda::es2panda::compiler { @@ -120,7 +120,7 @@ public: virtual Formats GetFormats() const = 0; virtual size_t Registers([[maybe_unused]] std::array *regs) = 0; virtual size_t Registers([[maybe_unused]] std::array *regs) const = 0; - virtual void Transform(panda::pandasm::Ins *ins) const = 0; + virtual panda::pandasm::Ins *Transform() const = 0; virtual ICSlot SetIcSlot(IcSizeType currentSlot) = 0; virtual bool InlineCacheEnabled() = 0; virtual ICSlot GetIcSlot() = 0; diff --git a/es2panda/lexer/lexer.cpp b/es2panda/lexer/lexer.cpp index ff656fe34d5579f7be08ea2c3d605658b3e0ab2d..b5e4726b1e07a426a5f7450afb2411a0985045f3 100644 --- a/es2panda/lexer/lexer.cpp +++ b/es2panda/lexer/lexer.cpp @@ -271,6 +271,7 @@ void Lexer::ScanNumberLeadingZero() case LEX_CHAR_8: case LEX_CHAR_9: { ThrowError("Invalid octal digit"); + break; } default: { break; @@ -371,14 +372,27 @@ void Lexer::ConvertNumber(size_t exponentSignPos) GetToken().src_ = sv; } - try { - GetToken().number_ = static_cast(std::stold(utf8, nullptr)); - } catch (const std::invalid_argument &) { + errno = 0; + char *endptr = nullptr; + double value = std::strtod(utf8.c_str(), &endptr); + + if (endptr == utf8.c_str()) { ThrowError("Invalid number"); - } catch (const std::out_of_range &) { - // TODO(frobert): look for a more elegant solution to this - GetToken().number_ = std::numeric_limits::infinity(); + return; } + + /* + * Extreme value handling: + * If the number exceeds Number.MAX_VALUE (~1.7976931348623157e+308), treat it as Infinity / -Infinity + * If the number is smaller than Number.MIN_VALUE (5e-324), it may be rounded to 0.0 or Number.MIN_VALUE, + * depending on platform behavior. + */ + if (errno == ERANGE && std::abs(value) > std::numeric_limits::max()) { + value = (value > 0.0 ? std::numeric_limits::infinity() + : -std::numeric_limits::infinity()); + } + + GetToken().number_ = value; } void Lexer::ScanNumber(bool allowNumericSeparator, bool allowBigInt) { diff --git a/es2panda/lexer/token/token.h b/es2panda/lexer/token/token.h index 168af8dad068d953050888866a4c3c76d523bc69..383f9a1c229baee590ff412b5b16d64d4eed9d95 100644 --- a/es2panda/lexer/token/token.h +++ b/es2panda/lexer/token/token.h @@ -85,6 +85,11 @@ public: return src_; } + void SetIdent(const util::StringView &ident) + { + src_ = ident; + } + const util::StringView &BigInt() const { ASSERT(type_ == TokenType::LITERAL_NUMBER && (flags_ & TokenFlags::NUMBER_BIGINT)); diff --git a/es2panda/parser/parserImpl.cpp b/es2panda/parser/parserImpl.cpp index cf578562b764135d0c0878bee238ba18d9df6b22..0dab3b7005fa022e95dab4bb43f5501d3e77ae12 100644 --- a/es2panda/parser/parserImpl.cpp +++ b/es2panda/parser/parserImpl.cpp @@ -117,7 +117,9 @@ Program ParserImpl::Parse(const SourceFile &sourceFile, const CompilerOptions &o program_.SetDebug(options.isDebug); program_.SetTargetApiVersion(options.targetApiVersion); program_.SetTargetApiSubVersion(options.targetApiSubVersion); - program_.SetEnableAnnotations(options.enableAnnotations); + if (util::Helpers::IsSupportAnnotationVersion(program_.TargetApiVersion())) { + program_.SetEnableAnnotations(options.enableAnnotations); + } program_.SetEnableEtsImplements(options.enableEtsImplements); program_.SetShared(sourceFile.isSharedModule); program_.SetModuleRecordFieldName(options.moduleRecordFieldName); @@ -1489,7 +1491,7 @@ ir::Expression *ParserImpl::ParseTsTypeLiteralOrInterfaceMember() char32_t nextToken = lexer_->Lookahead(); if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY && nextToken != LEX_CHAR_LEFT_PAREN && nextToken != LEX_CHAR_COLON && nextToken != LEX_CHAR_COMMA && nextToken != LEX_CHAR_LESS_THAN && - nextToken != LEX_CHAR_SEMICOLON) { + nextToken != LEX_CHAR_SEMICOLON && nextToken != LEX_CHAR_QUESTION) { readonly = true; lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); } @@ -2787,6 +2789,47 @@ ir::Expression *ParserImpl::ParseClassKeyAnnotation() return nullptr; } +bool ParserImpl::CheckAnnotationPrefix(const util::StringView &Ident) +{ + auto prefixLen = std::strlen(ir::Annotation::annotationPrefix); + return Ident.Length() >= prefixLen && + Ident.Substr(0, prefixLen) == ir::Annotation::annotationPrefix; +} + +void ParserImpl::ThrowAnnotationNotEnable() +{ + std::string errMessage = + "Current configuration does not support using annotations. " + "Annotations can be used in the version of API 20 or higher versions.\n" + "Solutions: > Check the compatibleSdkVersion in build-profile.json5." + "> If compatibleSdkVersion is set to API 20 or higher version." + "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " + "enable-annotations options are correctly configured."; + ThrowSyntaxError(errMessage); +} + +ir::Statement *ParserImpl::ParseAnnotationUsage(ir::Expression *expr, lexer::SourcePosition start) +{ + auto *exprTemp = expr; + if (exprTemp->IsCallExpression()) { + exprTemp = expr->AsCallExpression()->Callee(); + } + if (exprTemp->IsMemberExpression() || exprTemp->IsIdentifier()) { + auto *ident = exprTemp->IsIdentifier() ? exprTemp->AsIdentifier() + : exprTemp->AsMemberExpression()->Property()->AsIdentifier(); + if (CheckAnnotationPrefix(ident->Name())) { + if (!program_.IsEnableAnnotations()) { + ThrowAnnotationNotEnable(); + } + ident->SetName(ident->Name().Substr(std::strlen(ir::Annotation::annotationPrefix), ident->Name().Length())); + ir::Statement *resultAnnotation = static_cast(AllocNode(expr)); + resultAnnotation->SetRange({start, expr->End()}); + return resultAnnotation; + } + } + return nullptr; +} + ir::Statement *ParserImpl::ParseDecoratorAndAnnotation() { ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT); @@ -2795,23 +2838,22 @@ ir::Statement *ParserImpl::ParseDecoratorAndAnnotation() lexer::SourcePosition start = lexer_->GetToken().Start(); lexer_->NextToken(); // eat '@' - if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && - lexer_->GetToken().Ident().Utf8().rfind(ir::Annotation::annotationPrefix, 0) != std::string_view::npos) { - // Annotation usage case - if (!program_.IsEnableAnnotations()) { - ThrowSyntaxError("Annotations are not enabled"); - } - ir::Expression *expr = ParseLeftHandSideExpression(); - ir::Statement *resultAnnotation = static_cast(AllocNode(expr)); - resultAnnotation->SetRange({start, expr->End()}); + ir::Expression *expr = ParseLeftHandSideExpression(); + auto *resultAnnotation = ParseAnnotationUsage(expr, start); + if (resultAnnotation != nullptr) { return resultAnnotation; } - ir::Expression *expr = ParseLeftHandSideExpression(); if (expr->IsIdentifier() && expr->AsIdentifier()->Name().Utf8() == ir::Annotation::interfaceString) { // Annotation declaration case if (!program_.IsEnableAnnotations()) { - ThrowSyntaxError("Annotations are not enabled"); + ThrowAnnotationNotEnable(); + } + + if (!CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + std::stringstream ss; + ss << "Annotation declaration need to be prefixed with '" << ir::Annotation::annotationPrefix << "'"; + ThrowSyntaxError(ss.str()); } lexer_->Rewind(lexPos); return nullptr; @@ -3135,13 +3177,16 @@ bool ParserImpl::IsMethodDefinitionsAreSame(const ir::MethodDefinition *property return IsPropertyKeysAreSame(property->Key(), overload->Key()); } -ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl) +ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl, bool isAnnotation) { if (!isDeclare) { CheckStrictReservedWord(); } - const util::StringView &identStr = lexer_->GetToken().Ident(); + const util::StringView &identStr = + isAnnotation ? lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length()) + : lexer_->GetToken().Ident(); *decl = Binder()->AddDecl(lexer_->GetToken().Start(), isDeclare, identStr); @@ -3154,7 +3199,7 @@ ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder } ir::ClassDefinition *ParserImpl::ParseClassDefinition(bool isDeclaration, bool idRequired, bool isDeclare, - bool isAbstract) + bool isAbstract, bool isAnnotation) { isDeclare = isDeclare | (context_.Status() & ParserStatus::IN_AMBIENT_CONTEXT); lexer::SourcePosition startLoc = lexer_->GetToken().Start(); @@ -3168,7 +3213,7 @@ ir::ClassDefinition *ParserImpl::ParseClassDefinition(bool isDeclaration, bool i if ((lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT) && (Extension() != ScriptExtension::TS || lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_IMPLEMENTS)) { - identNode = SetIdentNodeInClassDefinition(isDeclare, &decl); + identNode = SetIdentNodeInClassDefinition(isDeclare, &decl, isAnnotation); } else if (isDeclaration && idRequired) { ThrowSyntaxError("Unexpected token, expected an identifier."); } @@ -3735,7 +3780,9 @@ ArenaVector ParserImpl::ParseFunctionParams(bool isDeclare, } } + context_.Status() |= ParserStatus::FUNCTION_PARAM; ir::Expression *parameter = ParseFunctionParameter(isDeclare); + context_.Status() &= ~ParserStatus::FUNCTION_PARAM; ValidateFunctionParam(params, parameter, &seenOptional); params.push_back(parameter); @@ -4086,7 +4133,6 @@ ir::ScriptFunction *ParserImpl::ParseFunction(ParserStatus newStatus, funcParamScope->BindNode(funcNode); funcNode->SetRange({startLoc, endLoc}); funcNode->CalculateFunctionExpectedPropertyCount(); - return funcNode; } diff --git a/es2panda/parser/parserImpl.h b/es2panda/parser/parserImpl.h index a69af8e055f135e4ee3c80c84f4fa630b3ba24fd..3254760260be2bb6559dcbfb1eab16d30ff0af67 100644 --- a/es2panda/parser/parserImpl.h +++ b/es2panda/parser/parserImpl.h @@ -322,7 +322,11 @@ private: void CheckClassGeneratorMethod(ClassElmentDescriptor *desc); void CheckClassPrivateIdentifier(ClassElmentDescriptor *desc); void CheckFieldKey(ir::Expression *propName); + bool CheckAnnotationPrefix(const util::StringView &Ident); + void ThrowAnnotationNotEnable(); + ir::Expression *ParseClassKeyAnnotation(); + ir::Statement *ParseAnnotationUsage(ir::Expression *expr, lexer::SourcePosition start); ir::Statement *ParseDecoratorAndAnnotation(); std::pair, ArenaVector> ParseDecoratorsAndAnnotations(); ir::Statement *ParseClassElement(const ArenaVector &properties, @@ -335,9 +339,9 @@ private: ir::MethodDefinition *CheckClassMethodOverload(ir::Statement *property, ir::MethodDefinition **ctor, bool isDeclare, lexer::SourcePosition errorInfo, ir::MethodDefinition *lastOverload, bool implExists, bool isAbstract = false); - ir::Identifier *SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl); + ir::Identifier *SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl, bool isAnnotation = false); ir::ClassDefinition *ParseClassDefinition(bool isDeclaration, bool idRequired = true, bool isDeclare = false, - bool isAbstract = false); + bool isAbstract = false, bool isAnnotation = false); ir::Expression *ParseSuperClass(bool isDeclare, bool *hasSuperClass, bool *isExtendsFromNull); ArenaVector ParseTSClassImplements(bool isDeclare); void ValidateClassConstructor(const ir::MethodDefinition *ctor, @@ -602,7 +606,7 @@ private: ir::VariableDeclaration *ParseContextualLet(VariableParsingFlags flags, StatementParsingFlags stmFlags = StatementParsingFlags::ALLOW_LEXICAL, bool isDeclare = false); - void VerifySupportLazyImportVersion(bool isNamedImport); + void VerifySupportLazyImportVersion(); util::StringView GetNamespaceExportInternalName() { diff --git a/es2panda/parser/program/program.cpp b/es2panda/parser/program/program.cpp index 5151f3845c35b604012dd754b291710a9f0ec940..992292ea0023783bce88558618fc237f0615d396 100644 --- a/es2panda/parser/program/program.cpp +++ b/es2panda/parser/program/program.cpp @@ -48,6 +48,7 @@ Program::Program(Program &&other) targetApiVersion_(other.targetApiVersion_), useDefineSemantic_(other.useDefineSemantic_), isShared_(other.isShared_), + enableAnnotations_(other.enableAnnotations_), enableEtsImplements_(other.enableEtsImplements_), targetApiSubVersion_(other.targetApiSubVersion_), moduleRecordFieldName_(other.moduleRecordFieldName_), @@ -79,6 +80,7 @@ Program &Program::operator=(Program &&other) targetApiVersion_ = other.targetApiVersion_; useDefineSemantic_ = other.useDefineSemantic_; isShared_ = other.isShared_; + enableAnnotations_ = other.enableAnnotations_; enableEtsImplements_ = other.enableEtsImplements_; targetApiSubVersion_ = other.targetApiSubVersion_; moduleRecordFieldName_ = other.moduleRecordFieldName_; diff --git a/es2panda/parser/program/program.h b/es2panda/parser/program/program.h index 493fff1a021dd357725a7380477f3c0bebe004c8..f19e6ed06982fb58a80bb259ab59e2fa98fc8e4a 100644 --- a/es2panda/parser/program/program.h +++ b/es2panda/parser/program/program.h @@ -230,7 +230,7 @@ public: enableAnnotations_ = enableAnnotations; } - bool IsEnableAnnotations() + bool IsEnableAnnotations() const { return enableAnnotations_; } diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index 3a0b46e5ca19ada2c9740c7bfc5ab461dee5c0b0..b158dbae4e889c22e9181b959a159b02d6afdbd6 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -690,7 +690,7 @@ ir::ClassDeclaration *ParserImpl::ParseClassDeclaration(bool idRequired, ArenaVe bool isAbstract, bool isExported, bool isAnnotation) { lexer::SourcePosition startLoc = lexer_->GetToken().Start(); - ir::ClassDefinition *classDefinition = ParseClassDefinition(true, idRequired, isDeclare, isAbstract); + ir::ClassDefinition *classDefinition = ParseClassDefinition(true, idRequired, isDeclare, isAbstract, isAnnotation); if (isExported && !idRequired) { classDefinition->SetAsExportDefault(); } @@ -2610,6 +2610,10 @@ ir::ExportNamedDeclaration *ParserImpl::ParseExportNamedSpecifiers(const lexer:: } lexer::Token localToken = lexer_->GetToken(); + if (program_.IsEnableAnnotations() && CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + localToken.SetIdent(lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length())); + } auto *local = AllocNode(lexer_->GetToken().Ident()); local->SetRange(lexer_->GetToken().Loc()); @@ -2990,6 +2994,10 @@ void ParserImpl::ParseNamedImportSpecifiers(ArenaVector *specifie } lexer::Token importedToken = lexer_->GetToken(); + if (program_.IsEnableAnnotations() && CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + importedToken.SetIdent(lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length())); + } auto *imported = AllocNode(importedToken.Ident()); ir::Identifier *local = nullptr; imported->SetRange(lexer_->GetToken().Loc()); @@ -3186,30 +3194,18 @@ ir::AstNode *ParserImpl::ParseImportSpecifiers(ArenaVector *speci return nullptr; } -void ParserImpl::VerifySupportLazyImportVersion(bool isNamedImport) +void ParserImpl::VerifySupportLazyImportVersion() { - if (isNamedImport) { - if (!util::Helpers::IsSupportLazyImportVersion(program_.TargetApiVersion(), - program_.GetTargetApiSubVersion())) { - std::string errMessage = "Current configuration does not support using lazy import. Lazy import can be " - "used in the beta3 version of API 12 or higher versions.\n" - "Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5." - "> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured " - "as beta3." - "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " - "target-api-sub-version options are correctly configured."; - ThrowSyntaxError(errMessage); - } - } else { - if (!util::Helpers::IsSupportLazyImportDefaultVersion(program_.TargetApiVersion())) { - std::string errMessage = "Current configuration does not support using lazy import default." - "Lazy import can be used in the version of API 18 or higher versions.\n" - "Solutions: > Check the compatibleSdkVersion in build-profile.json5." - "> If compatibleSdkVersion is set to API 18." - "> If you're running es2abc in commandline without IDE, please check whether target-api-version " - "options are correctly configured."; - ThrowSyntaxError(errMessage); - } + if (!util::Helpers::IsSupportLazyImportVersion(program_.TargetApiVersion(), + program_.GetTargetApiSubVersion())) { + std::string errMessage = "Current configuration does not support using lazy import. Lazy import can be " + "used in the beta3 version of API 12 or higher versions.\n" + "Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5." + "> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured " + "as beta3." + "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " + "target-api-sub-version options are correctly configured."; + ThrowSyntaxError(errMessage); } } @@ -3246,7 +3242,7 @@ ir::Statement *ParserImpl::ParseImportDeclaration(StatementParsingFlags flags) lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_TYPE) && lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_FROM; if (isNamedImport || isDefaultImport) { - VerifySupportLazyImportVersion(isNamedImport); + VerifySupportLazyImportVersion(); isLazy = true; } else { lexer_->Rewind(savedPos); diff --git a/es2panda/parser/transformer/transformer.cpp b/es2panda/parser/transformer/transformer.cpp index f41498a83f45dcef9db6024a515f4a11a12ba249..ff06eafee3354db6d79f5cb4889f430b837439eb 100644 --- a/es2panda/parser/transformer/transformer.cpp +++ b/es2panda/parser/transformer/transformer.cpp @@ -697,15 +697,22 @@ std::vector Transformer::VisitInstanceProperty(ir::Cl ir::MemberExpression *left = nullptr; auto *member = GetClassMemberName(it->Key(), it->IsComputed(), it, false); + auto thisExpression = AllocNode(); + // Set the range of the 'this' expression to the property key's range + // for accurate debug to the original field. (e.g., the "prop" in '"prop" = 1'). + thisExpression->SetRange(member->Range()); if (member->IsIdentifier() && !it->IsComputed()) { - left = AllocNode(AllocNode(), member, + left = AllocNode(thisExpression, member, ir::MemberExpression::MemberExpressionKind::PROPERTY_ACCESS, false, false); } else { - left = AllocNode(AllocNode(), member, + left = AllocNode(thisExpression, member, ir::MemberExpression::MemberExpressionKind::ELEMENT_ACCESS, true, false); } + // Set the range of the property access expression (e.g., this["prop"] or this.prop) + // to the property key's range for accurate debug. + left->SetRange(member->Range()); auto assignment = AllocNode(left, it->Value(), lexer::TokenType::PUNCTUATOR_SUBSTITUTION); @@ -1558,20 +1565,33 @@ ir::Expression *Transformer::GetClassMemberName(ir::Expression *key, bool isComp { if (isComputed) { auto name = GetComputedPropertyBinding(node); - return AllocNode(name); + auto *ident = AllocNode(name); + ident->SetRange(key->Range()); + return ident; } if (key->IsIdentifier()) { if (inDecorator) { - return AllocNode(key->AsIdentifier()->Name()); + auto *strLiteral = AllocNode(key->AsIdentifier()->Name()); + strLiteral->SetRange(key->AsIdentifier()->Range()); + return strLiteral; } else { - return AllocNode(key->AsIdentifier()->Name()); + auto *ident = AllocNode(key->AsIdentifier()->Name()); + ident->SetRange(key->AsIdentifier()->Range()); + return ident; } } else if (key->IsStringLiteral()) { - return AllocNode(key->AsStringLiteral()->Str()); + auto *strLiteral = AllocNode(key->AsStringLiteral()->Str()); + strLiteral->SetRange(key->AsStringLiteral()->Range()); + return strLiteral; } else if (key->IsNumberLiteral()) { - return AllocNode(key->AsNumberLiteral()->Number(), key->AsNumberLiteral()->Str()); + auto *numLiteral = AllocNode(key->AsNumberLiteral()->Number(), + key->AsNumberLiteral()->Str()); + numLiteral->SetRange(key->AsNumberLiteral()->Range()); + return numLiteral; } else if (key->IsBigIntLiteral()) { - return AllocNode(key->AsBigIntLiteral()->Str()); + auto *bigIntLiteral = AllocNode(key->AsBigIntLiteral()->Str()); + bigIntLiteral->SetRange(key->AsBigIntLiteral()->Range()); + return bigIntLiteral; } UNREACHABLE(); return nullptr; diff --git a/es2panda/test/base64/availableTargetApiVersion/10/expected.txt b/es2panda/test/base64/availableTargetApiVersion/10/expected.txt index 7196886c4e5cf0f3cb19ad4d939f09f64e2e7c60..ea65d584ae2cfdff4b04e21864de8947fb8f8a77 100644 --- a/es2panda/test/base64/availableTargetApiVersion/10/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/10/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACQAAAJwBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJgBAAAAAAAASAAAAAEAAABIAAAArgAAAN8AAAASAQAAiAAAAJwBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN8AAAASAQAAiAAAAKIAAACpAAAARAEAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMCEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAAAFAQAAiAIBYQEAAAIABYwBAAAGVAEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQBIAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAAAAhgEAAA== +UEFOREEAAAAAAAAACQAAAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqgAAAN0AAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqgAAAN0AAACEAAAAngAAAKUAAAAOAQAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDEwIQALcHJpbnQAB3N0cgAzTF9FU1Nsb3ROdW1iZXJBbm5vdGF0aW9uOwAAAAAAgUAAAAIAABdmdW5jX21haW5fMAATTF9HTE9CQUw7AAAAAAABAAECAAABAAAA0AAAAIgCASsBAAACAAVWAQAABh4BAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/base64/availableTargetApiVersion/11/expected.txt b/es2panda/test/base64/availableTargetApiVersion/11/expected.txt index d27a626eee9142bd3f06b9183a03466dd2558b81..e4039082c8b3e142fe762b3e74c6659b351f6819 100644 --- a/es2panda/test/base64/availableTargetApiVersion/11/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/11/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACwACAJwBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJgBAAAAAAAASAAAAAEAAABIAAAArgAAAN8AAAASAQAAiAAAAJwBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN8AAAASAQAAiAAAAKIAAACpAAAARAEAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMSEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAAAFAQAAiAIBYQEAAAIABYwBAAAGVAEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQBIAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAAAAhgEAAA== +UEFOREEAAAAAAAAACwACAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqgAAAN0AAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqgAAAN0AAACEAAAAngAAAKUAAAAOAQAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDExIQALcHJpbnQAB3N0cgAzTF9FU1Nsb3ROdW1iZXJBbm5vdGF0aW9uOwAAAAAAgUAAAAIAABdmdW5jX21haW5fMAATTF9HTE9CQUw7AAAAAAABAAECAAABAAAA0AAAAIgCASsBAAACAAVWAQAABh4BAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/base64/availableTargetApiVersion/12/expected.txt b/es2panda/test/base64/availableTargetApiVersion/12/expected.txt index 3308f1d348bd13cb2e9859b58ff09dcd82aa17f8..5851b369e143eaff057f4c075e8764ac61acc54e 100644 --- a/es2panda/test/base64/availableTargetApiVersion/12/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/12/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAADAAGANgBAAAAAAAAAAAAAAQAAAA8AAAAAQAAANQBAAABAAAATAAAAAEAAABQAAAAugAAAOsAAAAdAQAAUAEAAIEBAACUAAAA2AEAAAQAAAB4AAAAAwAAAIgAAAD/////////////////////BgAAAOsAAAAdAQAAUAEAAJQAAACuAAAAtQAAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMiEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAACtMX0VTU2NvcGVOYW1lc1JlY29yZDsAAAAAAAEBAAIAAAEAAAAbAQAAAAKBAQAAAAEAM0xfRVNTbG90TnVtYmVyQW5ub3RhdGlvbjsAAAAAAIFAAAACAAAXZnVuY19tYWluXzAAE0xfR0xPQkFMOwAAAAAAAQABAgAAAwD//0MBAACIAgGeAQAAAgAFyQEAAAaRAQAAAAAAAAAVU2xvdE51bWJlcgACAAEAhQEAAAUAAAA3BwMhAERwRIFEkj4AAEgAAAIAPwEBAGEFPwICAGEGYAUqAwYAZQtriQEOAP////8PAAIAEQAAwwEAAA== +UEFOREEAAAAAAAAADAAGAKQBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAKABAAABAAAASAAAAAEAAABMAAAAtgAAAOgAAAAbAQAATAEAAJAAAACkAQAABAAAAHQAAAADAAAAhAAAAP////////////////////8GAAAAtgAAAOgAAAAbAQAAkAAAAKoAAACxAAAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDEyIQALcHJpbnQAB3N0cgArTF9FU1Njb3BlTmFtZXNSZWNvcmQ7AAAAAAABAQACAAABAAAA5gAAAAACTAEAAAABADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAMA//8OAQAAiAIBaQEAAAIABZQBAAAGXAEAAAAAAAAAFVNsb3ROdW1iZXIAAgABAFABAAAFAAAANwcDIQBEcESBRJI+AABIAAACAD8BAQBhBT8CAgBhBmAFKgMGAGULa4kBDgD/////DwACABEAAACOAQAA diff --git a/es2panda/test/base64/availableTargetApiVersion/9/expected.txt b/es2panda/test/base64/availableTargetApiVersion/9/expected.txt index 4493d88c5e760a6b4103669c127dee32f8184fa7..3a5ba6e9a24ed7dcf3b447e691140b28d93df3de 100644 --- a/es2panda/test/base64/availableTargetApiVersion/9/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/9/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACQAAAJgBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJQBAAAAAAAASAAAAAEAAABIAAAArQAAAN4AAAARAQAAiAAAAJgBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN4AAAARAQAAiAAAAKEAAACoAAAAQgEAAC9oZWxsbyB3b3JsZCwgdmVyc2lvbiA5IQALcHJpbnQAB3N0cgBJTF9FU0V4cGVjdGVkUHJvcGVydHlDb3VudEFubm90YXRpb247AAAAAACBQAAAAgAAM0xfRVNTbG90TnVtYmVyQW5ub3RhdGlvbjsAAAAAAIFAAAACAAAXZnVuY19tYWluXzAAE0xfR0xPQkFMOwAAAAAAAQABAgAAAQAAAAQBAACIAgFfAQAAAgAFigEAAAZSAQAAAO7uAAAVU2xvdE51bWJlcgAAAAEARgEAAAUAAAA3BwMhAERwRIFEkj4AAEgAAAIAPwEBAGEFPwICAGEGYAUqAwYAZQtriQEOAP////8PAAIAEQCEAQAA +UEFOREEAAAAAAAAACQAAAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqQAAANwAAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqQAAANwAAACEAAAAnQAAAKQAAAAOAQAAL2hlbGxvIHdvcmxkLCB2ZXJzaW9uIDkhAAtwcmludAAHc3RyADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAADPAAAAiAIBKwEAAAIABVYBAAAGHgEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..dfa8103e1bf36c2287c6f2bf4cdc93098f3ce40b --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt @@ -0,0 +1,162 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~@0=#C34(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .#~@1=#C35(any a0, any a1, any a2, any a3, any a4, any a5) { + nop +label_17: +label_0: + newlexenv 0x1 +label_11: +label_13: + ldai 0x19 + sta v1 + ldai 0x7 + sta v2 +label_7: + lda v1 + less 0x0, v2 + jeqz label_8 +label_9: +label_2: + definefunc 0x1, .#~@1=@1*#f43, 0x0 + stlexvar 0x0, 0x0 + definefunc 0x2, .#~@1=@1*#f46, 0x2 + ldundefined + sta v3 + ldundefined + stricteq 0x3, v3 + jeqz label_5 +label_4: + lda a2 + throw.ifsupernotcorrectcall 0x0 + poplexenv + mov v3, a2 +label_5: + lda v3 + return +label_10: +end_label_10: +label_19: +label_15: + lda.str 123 + sta v3 + tryldglobalbyname 0x4, print + callarg1 0x5, v3 + ldlexvar 0x0, 0x0 + sta v3 + poplexenv + newlexenv 0x1 + lda v3 + stlexvar 0x0, 0x0 + lda v2 + tonumeric 0x7 + inc 0x8 + sta v2 +label_12: +end_label_12: + jmp label_7 +label_20: + sta v0 +label_16: + poplexenv + lda v0 + throw +label_8: + poplexenv + ldundefined + sta v0 + mov v4, v0 + supercallthisrange 0x9, 0x0, v4 + sta v0 + lda a2 + throw.ifsupernotcorrectcall 0x1 + lda v0 + throw.ifsupernotcorrectcall 0x0 + lda v0 + return +label_18: +} + +.catchall label_9, end_label_10, label_19 + +.catchall label_11, end_label_12, label_20 + +slotNum = 0x0 +.language ECMAScript +.function any .#~@1=@1*#f43(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + return +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any .#~@1=@1*#f46(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + ldlexvar 0x1, 0x0 + sta v0 + throw.undefinedifholewithname C35 + lda v0 + return +label_2: +} + +slotNum = 0xc +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~@0=#C34, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + sttoglobalrecord 0x3, C34 + newlexenv 0x1 +label_2: +label_4: + tryldglobalbyname 0x4, C34 + sta v1 + defineclasswithbuffer 0x5, .#~@1=#C35, _2, 0x3, v1 + sta v1 + stlexvar 0x0, 0x0 + lda v1 + ldobjbyname 0x6, prototype +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda v1 + sttoglobalrecord 0x8, C35 + tryldglobalbyname 0x9, C35 + sta v0 + mov v2, v0 + newobjrange 0xa, 0x1, v2 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..f3a1fc3929458c2e90e6d1d99b0f5a3c324c7fad --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + for (let v40 = 7; v40 < 25; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + let x = '123'; + print(x); + } + } + super(); + } +} + +new C35(); diff --git a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts index 84370500e341ae7716a10fa55791095a854dac31..44f43d0ae8b93fafac7a4164091c496ec269a30c 100644 --- a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 42 } diff --git a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts index 56903a4827894404715e606172d83d02d49a0a99..49a9b8d2d8d86bfd4969346a04a525e330a924b0 100644 --- a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { b: boolean = true } diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..2a5d2772fd2923a497c5a03ada83b604bc8245f9 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } @@ -24,4 +24,3 @@ export class A {} @__$$ETS_ANNOTATION$$__Anno1() export default class B {} - diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts index 446556e337073a83d0a2df990549c128eafc0384..13ab7bdb6b46ded18550f221cbc6019943ba27ab 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts @@ -15,20 +15,20 @@ import * as Namespace1 from "./test-ts-export-annotations" -@__$$ETS_ANNOTATION$$__Namespace1.Anno() +@Namespace1.__$$ETS_ANNOTATION$$__Anno() class A {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno +@Namespace1.__$$ETS_ANNOTATION$$__Anno class B {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno1({a: 1, b: "string"}) +@Namespace1.__$$ETS_ANNOTATION$$__Anno1({a: 1, b: "string"}) class C {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2() +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2() class D {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2 +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2 class E {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno3({a: 1, b: "string"}) -class F {} \ No newline at end of file +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno3({a: 1, b: "string"}) +class F {} diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..6bea13acdc05d843f551afdf62e7a7d27cc561fd 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts index 734f114a32138d2d1ce2da8d3df63b0e5b7a59a0..de240324b1c1ae40e9672a936fed27be20d814d7 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Anno1, Anno2 } from "./test-ts-export-annotations" +import { __$$ETS_ANNOTATION$$__Anno1, __$$ETS_ANNOTATION$$__Anno2 } from "./test-ts-export-annotations" @__$$ETS_ANNOTATION$$__Anno1 class A {} diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts index 8bb5148dc721dad55760f4cf315cd6dd0f348a4c..b13f16c168dc4afec2966bf489d0c34eafae41d4 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[][][] = [[[true, false], [true, false]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts index 8f50c85fbff71f5f2e49017f2143631e206ccdbb..bf399ee5c9305cbeb60cfaec6c81828e837514d2 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = -314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[][][] = [[new Array(0)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[][][] = [[new Array(1)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[[42, -314, 42]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts index 8eeef595d0e2bbd1b6afbe902a3920b97f0c564b..a24f1a805f6938f5b29fa3a66b6379ecdb596eb2 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[][][] = [[new Array(2)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[][][] = [[new Array(3)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[["Hello", "world!", "Hello"]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-number.ts b/es2panda/test/compiler/annotations/declaration-3d-array-number.ts index e83e604801225ef9f226b3b862ad60e602dd2418..22d514157862b006230a5d89c581d1d5856c6104 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[][][] = [[[1, -2, 3], [4, -5, 6]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-string.ts b/es2panda/test/compiler/annotations/declaration-3d-array-string.ts index 9d2d477d78b5c09c70f7b74b42b74cc38f80640e..09a27904d4751c31a2b11852d7ccb84d003d5461 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[][][] = [[["hello", "world"], ["hello", "world"]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-array-boolean.ts index b5e92f592d43e9018fc8ef55a4931d9e1f89c936..c575410d77ecb84c7c4056b56f99dd36be3cc499 100644 --- a/es2panda/test/compiler/annotations/declaration-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[] = [true, false, true]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-array-enum-number.ts index d947e16c08f264c72522e47bdb51582c5d6dc8fb..139e108acbe8ba544fd8a31f859d48cb33bd23e9 100644 --- a/es2panda/test/compiler/annotations/declaration-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = -314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[] = new Array(0); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[] = new Array(1); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = [42, -314, 42]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-array-enum-string.ts index a55745424cd2cbffdff0f6844cd0e61f46a21db3..39e7411e1a54dfec881d36f64e0a08203b809baa 100644 --- a/es2panda/test/compiler/annotations/declaration-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[] = new Array(2); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[] = new Array(3); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = ["Hello", "world!", "Hello"]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-number.ts b/es2panda/test/compiler/annotations/declaration-array-number.ts index d573f6ebb3a1b6e184ad1aa23bb189d8f24308cd..13e7ce6232018cb48c06efb09457f279fa2be5b8 100644 --- a/es2panda/test/compiler/annotations/declaration-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[] = [1, -2, 3]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-string.ts b/es2panda/test/compiler/annotations/declaration-array-string.ts index 69cfe97efcf42aa24d331347f690be6f4c018abc..2de6642e2463d14334115eb53fe796878f86bf69 100644 --- a/es2panda/test/compiler/annotations/declaration-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[] = ["Hello", "world", "!"]; } diff --git a/es2panda/test/compiler/annotations/declaration-boolean.ts b/es2panda/test/compiler/annotations/declaration-boolean.ts index e9bf814b7e14fef3b349fe5c28dd3aefae01d47b..086025dbd9a81925f1c84429f7f88a27a32e022e 100644 --- a/es2panda/test/compiler/annotations/declaration-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-boolean.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean = true; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-combination.ts b/es2panda/test/compiler/annotations/declaration-combination.ts index 15fa1399e46e8c87bfa2a48eed28518b9efaa7a6..7eaa0d8662020b0f5903dfdf53d4857d8bcee05e 100644 --- a/es2panda/test/compiler/annotations/declaration-combination.ts +++ b/es2panda/test/compiler/annotations/declaration-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, -10] c: string diff --git a/es2panda/test/compiler/annotations/declaration-empty.ts b/es2panda/test/compiler/annotations/declaration-empty.ts index 4d205f1d28c5947498aa920c5ee887ea825a4a16..80ae4e05b8580a0eeb03456386a7854204744303 100644 --- a/es2panda/test/compiler/annotations/declaration-empty.ts +++ b/es2panda/test/compiler/annotations/declaration-empty.ts @@ -13,4 +13,4 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} diff --git a/es2panda/test/compiler/annotations/declaration-enum-number.ts b/es2panda/test/compiler/annotations/declaration-enum-number.ts index 095d97c985d0ca75c019935f770412d0b8878c07..74f82890046248d5b22dae7f8015a8a4ba17b26f 100644 --- a/es2panda/test/compiler/annotations/declaration-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-enum-number.ts @@ -18,11 +18,11 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type number a: E = new Number(0) as number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = 42; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-enum-string.ts b/es2panda/test/compiler/annotations/declaration-enum-string.ts index 668b13ba51d72057b1111438bd928c13bedd489f..e8f77e41a217e4caa3a3db46de289c62347a6b45 100644 --- a/es2panda/test/compiler/annotations/declaration-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-enum-string.ts @@ -18,11 +18,11 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type string a: E; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = "Hello"; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-number.ts b/es2panda/test/compiler/annotations/declaration-number.ts index 47f96358bc2142b3490c406048a8761e8d70f250..241b6909776cdb45499d6cf50d99c0dc8a10fe0f 100644 --- a/es2panda/test/compiler/annotations/declaration-number.ts +++ b/es2panda/test/compiler/annotations/declaration-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 42; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number = -314; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-string.ts b/es2panda/test/compiler/annotations/declaration-string.ts index 2f67dfdc93f9626c754bb871e1a3ea6eda569e78..52e99594617389227a8f3c2e932abc592571d4c2 100644 --- a/es2panda/test/compiler/annotations/declaration-string.ts +++ b/es2panda/test/compiler/annotations/declaration-string.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string = "Hello world!"; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts index b228a7be88bbcdc9acf8ad31da5fa7d30d5aea2e..e707f942b5deddf83713a8c326d93162c8f4d590 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts index 4439bb44647435b12b1217d6530bbedaa4f19297..3c503d4bdc442841224d4ec86bc0bb40042d38e9 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(0)]]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts index 3ea8b4242bbbf19418701fbf8dce909f75358500..175a0dcb7a93270affd66c1335480c174a2be5f4 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(2)]]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts index 880fe4b3a0ce614fb09658f56b12dc5034efa6ec..9dbe6711ed5b5491114969dd792ba535bf57c904 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts index 8bdbb7118e9996f7c99637dd147a82d0e24eb1b6..37e8437d72aa2c3145dca40ffa6691294fcb79e2 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts index 06ae0c99571fdd0308b644460b368e65d069b7d4..cd8fece8279a7d132e7a6398b85631455d073d2c 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts index 03162a2deff807a424dc76390e630d22eaa84c1a..07c2b6bb2f0f5c629986f44764655669ae399c8c 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2, } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(0); } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts index aa3bd9c9fbd145aba6be513f37384ffc078ad36b..52742a3241cc03aafcb0daf8228f2a14bdee1464 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world", } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(2); } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-number.ts b/es2panda/test/compiler/annotations/declaration-usage-array-number.ts index e2003df66c22c54a3302252748e0842a3752300c..2fe6ab909a70db9c28511dce3156556dfe604b73 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-string.ts b/es2panda/test/compiler/annotations/declaration-usage-array-string.ts index c14f9d9d8fd68fa1d0756c8f21d84b10da738391..c00fe674fcc5ac3a3cebb385e3c3a25224990fbe 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-boolean.ts index b47a2078487b87c4f8b679c8b12633597c77307a..3e7da49918ef6cf00cac1e7740bc1fb3464bc09a 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-combination.ts b/es2panda/test/compiler/annotations/declaration-usage-combination.ts index ca3633d57a3e83867c09edc7b3ab99426ce15cd1..30fa5b53c632a3c12675d4c6295c2f2cd9b85e6e 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-combination.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, -10] c: string diff --git a/es2panda/test/compiler/annotations/declaration-usage-empty.ts b/es2panda/test/compiler/annotations/declaration-usage-empty.ts index badbc9745a1434a8e45996e86aee590e4705958f..b781add198329819f7d9e2290005b6ac08b2e6f2 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-empty.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-empty.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} @__$$ETS_ANNOTATION$$__Anno class A { diff --git a/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts index 3bc341432f881e4b6a2d9ad9b0b72fa01ad923ed..ecba445cf885279b39c803c6e6d267855e3ee957 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E = new Number(0) as number; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts index d9c8f8e0477c4cf4d408da1c680efe924ab3e872..320500abe99431974fd5f281561301106df16035 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-number.ts b/es2panda/test/compiler/annotations/declaration-usage-number.ts index 34e2ac30ec1078242f3e0922547280ed6384173e..637713e19282cae6bd44de9a9827a0ddc003ede0 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-string.ts b/es2panda/test/compiler/annotations/declaration-usage-string.ts index 0c627768fd650a5e4bac6cac31df0b4baaf5d8b6..5ad01ef4ed9394074ca233092f0bf41cc67628ab 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; } diff --git a/es2panda/test/compiler/annotations/export.ts b/es2panda/test/compiler/annotations/export.ts index d11841f8a91f6fa63d0b960f671f4883982a4581..3dd42d6c7458e22e5114fef020eed609dc3a3e8f 100644 --- a/es2panda/test/compiler/annotations/export.ts +++ b/es2panda/test/compiler/annotations/export.ts @@ -15,9 +15,9 @@ // import tests are located in compiler/ts/annotations-projects -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/compiler/annotations/multiple-annotations.ts b/es2panda/test/compiler/annotations/multiple-annotations.ts index cf0af17c46b720c83ce8e40a6a328b68010b19f7..246af473b26a6a8d76defe52e36865f928a33bc7 100644 --- a/es2panda/test/compiler/annotations/multiple-annotations.ts +++ b/es2panda/test/compiler/annotations/multiple-annotations.ts @@ -13,15 +13,15 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number = 1; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { b: string = "string" } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { c: boolean[] = [true, false]; } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a98a541e1cfd9b3fc982dbc7d0174ed46c50ea2 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 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. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&module&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&module&&@ohos/lib/importfile2&"); + import("@normalized:N&&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + let b = "@normalized:N&&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + "@normalized:N&&bundle&lib/importfile1&"; + import(a); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b6252c67f1dd6029d825afb21f17aacfaababd9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/** + * Copyright (c) 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. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..3c35014906e6b28a3452825af397a0bb1487b1a0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json @@ -0,0 +1,12 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar": { + "lib": "2.0.0", + "@ohos/lib": "2.0.0" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..6f146bddc005d33fdf60e0a7556f8bad7c9b02ca --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt @@ -0,0 +1,1670 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-static-import& +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: importfile1.ts +record_name: bundle&lib/importfile1&2.0.0 +program_file: importfile2.ts +record_name: &@ohos/lib/importfile2&2.0.0 +program_file: importfile3.ts +record_name: &lib2/importfile3& +program_file: importfile4.ts +record_name: &@ohos/lib2/importfile4& + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2514, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2466 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2470 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2514 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2663, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2523 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2527 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2663 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2514, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2466 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2470 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2514 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2663, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2523 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2527 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2663 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c9b1c36d21c906a373e1b53da815a5fade14555 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 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 bytecodeharDynamicImport from "@normalized:N&&&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts new file mode 100644 index 0000000000000000000000000000000000000000..5635f70b7138307a334a7526af3c8d596a37dc73 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test1: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5267ff5e2937f60b551f7dc08245daca4a93ff68 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9a8057d7ba62b25ef432a284327fb347718ea56 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fedda824b526993822e0c90fc38728ec99e45f9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..185dca611160d3ada3534a652765594eb6ec9472 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:&@ohos/lib/importfile2&2.0.0 +importfile3:&lib2/importfile3& +importfile4:&@ohos/lib2/importfile4& +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..27094c100af48c267e81b02ae128158162289e0b --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..aacfd725551080ed37cc0ff7f3bd39b9b7179cd1 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..a8744ff6d302a7650651886c9655de5ad7c3e609 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json @@ -0,0 +1,44 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "bytecodehar1": { + "packageName": "bytecodehar1", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/bytecodehar2": { + "packageName": "@ohos/bytecodehar2", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "sourcehar": { + "packageName": "sourcehar", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..d327a5a78ae710fd6825297c7ad8bc8a44aeacec --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt @@ -0,0 +1,1354 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fe9e1625e9e5f9626041a272bd5853e1937ba51 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 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 { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new A(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f688431373716beb39877a74cd5d87297d0a64e3 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..30d55ea9aefa0f15c5b3654293d3f95021d5ae69 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 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. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&lib&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&lib&&@ohos/lib/importfile2&"); + import("@normalized:N&lib&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&lib&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&module&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&module&bundle&lib/importfile1&"; + let b = "@normalized:N&module&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&module&bundle&lib/importfile1&"; + "@normalized:N&module&bundle&lib/importfile1&"; + import(a); +} + +@interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A1 { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..e8d2d8608ccdee5f66f5df5c96c221b6b0353a8c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/** + * Copyright (c) 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. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +@interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..f7127bcf76b35ba74fb1a0d26f7adc3dd276681f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json @@ -0,0 +1,17 @@ +{ + "compileEntries": [ + "com.inter_app.hsp&myapp/inter-app-hsp-file-exec&" + ], + "hspPkgNames": [ + "lib", + "@ohos/lib" + ], + "updateVersionInfo": { + "bytecodehar": { + "lib": "2.0.0", + "@ohos/lib": "2.0.0" + } + }, + "needModifyRecord": true, + "bundleName": "com.inter_app.hsp" +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts new file mode 100644 index 0000000000000000000000000000000000000000..5635f70b7138307a334a7526af3c8d596a37dc73 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test1: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5267ff5e2937f60b551f7dc08245daca4a93ff68 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9a8057d7ba62b25ef432a284327fb347718ea56 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fedda824b526993822e0c90fc38728ec99e45f9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 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. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..cf4b80b652cb86899bbfe097ffbcf3b538ac6061 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt @@ -0,0 +1,1508 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +program_file: importfile3.ts +record_name: com.inter_app.hsp&lib2/importfile3& +program_file: importfile4.ts +record_name: com.inter_app.hsp&@ohos/lib2/importfile4& +program_file: inter-app-hsp-file-exec.ts +record_name: com.inter_app.hsp&myapp/inter-app-hsp-file-exec& + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x4, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2521 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2525 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"@normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4&"; "@normalized:N&&com.inter_app.hsp&lib2/importfile3&"; "@normalized:N&lib&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2570 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2574 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 0 +}, +{ + index: 34 + tag: 2 + val: 0 +}, +{ + index: 35 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"a"; "b"; "c"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_0 +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_0 +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x4, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2521 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2525 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"@normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4&"; "@normalized:N&&com.inter_app.hsp&lib2/importfile3&"; "@normalized:N&lib&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2570 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2574 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 0 +}, +{ + index: 34 + tag: 2 + val: 0 +}, +{ + index: 35 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"a"; "b"; "c"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_0 +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_0 +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A"; "print"; "prototype"; "test"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a849d9f969707261762ff0c326fa52f179632c5 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 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 bytecodeharDynamicImport from "@normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..7fff897e3c90a12ec32d3925d2a09d3e1ae7b9b1 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:com.inter_app.hsp&@ohos/lib/importfile2&2.0.0 +importfile3:com.inter_app.hsp&lib2/importfile3& +importfile4:com.inter_app.hsp&@ohos/lib2/importfile4& +inter-app-hsp-file-exec:com.inter_app.hsp&myapp/inter-app-hsp-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..a057a3927b5fe78c9e4448ead9970b7319988517 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts @@ -0,0 +1,34 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +function A(a) { + this.a = a + this.b = 1 + this.c = 2 +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3946722605096fbc5999375259e24199cef3fe32 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts @@ -0,0 +1,40 @@ +/** + * Copyright (c) 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 {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +class Example { + a: number; + + constructor() { + this.a = 0; + } + + setValue(value: number) { + this.a = value; + } +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..c040f93e6cb741f937769bb2c89c3458fbad1481 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2da8dcd93249f8f559d3d0a0f70346f048d9035 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..a8744ff6d302a7650651886c9655de5ad7c3e609 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json @@ -0,0 +1,44 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "bytecodehar1": { + "packageName": "bytecodehar1", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/bytecodehar2": { + "packageName": "@ohos/bytecodehar2", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "sourcehar": { + "packageName": "sourcehar", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..d6cd6d3e45ecf6f3b46b4267640feae85631a671 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt @@ -0,0 +1,1340 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 + +slotNum = 0x6 +expectedProperty = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + ldai 0x1 + stobjbyname 0x2, b, a2 + ldai 0x2 + stobjbyname 0x4, c, a2 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x5 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A, 0x1 + definefunc 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x2, &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B, &bytecodehar1/bytecodehar1-file1&2.0.0_2142, 0x0, v0 + ldobjbyname 0x3, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2080 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2084 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2142 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#A"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "a"; "b"; "bytecodehar1.file1.test"; "c"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example(any a0, any a1, any a2) { + ldai 0x0 + stobjbyname 0x0, a, a2 + lda a2 + return +} + +slotNum = 0x2 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0>#setValue(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example, &bytecodehar1/bytecodehar1-file2&2.0.0_2218, 0x0, v0 + ldobjbyname 0x2, prototype + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_2240, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2151 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: Example +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2160 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2218 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: setValue +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0>#setValue +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 1 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2240 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "a"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1601 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1605 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1706, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1658 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1662 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1706 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x1 + sta v0 + throw.undefinedifholewithname B + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: Anno1 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: B +}, +{ + index: 7 + tag: 5 + val: B +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~C=#C"; "B"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x6 +expectedProperty = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + ldai 0x1 + stobjbyname 0x2, b, a2 + ldai 0x2 + stobjbyname 0x4, c, a2 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x5 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A, 0x1 + definefunc 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x2, &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B, &bytecodehar1/bytecodehar1-file1&2.0.0_2142, 0x0, v0 + ldobjbyname 0x3, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2080 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2084 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2142 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#A"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "a"; "b"; "bytecodehar1.file1.test"; "c"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1601 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1605 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x1 + sta v0 + throw.undefinedifholewithname B + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: Anno1 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: B +}, +{ + index: 7 + tag: 5 + val: B +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~C=#C"; "B"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfb9dcabd30e577833eb1baf7e2f82ada2a1881c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 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 { test, __$$ETS_ANNOTATION$$__Anno1, B } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new B(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class C { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9215bd1f398efaf7980d8451eb64fbea1bc10dc --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..773f5fa662c2cd98b0b6e9da42f43ec157d05c10 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 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. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&module&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&module&&@ohos/lib/importfile2&"); + import("@normalized:N&&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + let b = "@normalized:N&&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + "@normalized:N&&bundle&lib/importfile1&"; + import(a); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..730ef9995187872998242685c0c477f23116e62d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 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. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..be6b280850e709ed18b7d46fd80490ebbf1e9376 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json @@ -0,0 +1,53 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "lib": { + "packageName": "lib", + "bundleName": "bundle", + "moduleName": "module", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/lib": { + "packageName": "@ohos/lib", + "bundleName": "", + "moduleName": "module", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "lib2": { + "packageName": "lib2", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/lib2": { + "packageName": "@ohos/lib2", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..951b2a1d14353002088d287324d24d43ac3593b7 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt @@ -0,0 +1,1670 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-static-import& +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: importfile1.ts +record_name: bundle&lib/importfile1&2.0.0 +program_file: importfile2.ts +record_name: &@ohos/lib/importfile2&2.0.0 +program_file: importfile3.ts +record_name: &lib2/importfile3& +program_file: importfile4.ts +record_name: &@ohos/lib2/importfile4& + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2498, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2450 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2454 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2498 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2647, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2507 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2511 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2647 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2498, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2450 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2454 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2498 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2647, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2507 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2511 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2647 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..572bc4616e688a06c0e967006701f1326f1d8d60 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 bytecodeharDynamicImport from "@normalized:N&&&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts similarity index 81% rename from ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts index fdc663f300ef9f576d2d764f0a8638fa1446c038..afc68146cdbba67e99626c8d8e621fce279997f7 100644 --- a/ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts @@ -13,7 +13,4 @@ * limitations under the License. */ -declare interface A { - [index :int]: string - } - /* @@? 17:14 Error SyntaxError: Index type must be number in index signature. */ +export const test1: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts new file mode 100644 index 0000000000000000000000000000000000000000..f31867bafae7f57cced3748a8aac231abda27d72 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..314b5403fc82ee28d43ea37dc891ad31ee5efc7c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..fad2380a354687a68f814a2f402d0fffe7936c6d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..185dca611160d3ada3534a652765594eb6ec9472 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:&@ohos/lib/importfile2&2.0.0 +importfile3:&lib2/importfile3& +importfile4:&@ohos/lib2/importfile4& +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..7478e0048213402e23cc0b7943b4732b63481299 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3716361621e705ebf971362f3a919d49d9c63bd1 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..43eafd903dcdabf37bff8b31ae5b227be5be0bb2 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json @@ -0,0 +1,13 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar1": { + "@ohos/bytecodehar2": "2.0.0" + }, + "@ohos/bytecodehar2": { + } + } +} diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..819272cd4acd1c633cef7a3df0de506fd9e7cbfa --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt @@ -0,0 +1,1354 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1826, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1764 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1768 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1826 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1897, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1835 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1839 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1897 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1589 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1593 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1694, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1646 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1650 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1694 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1826, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1764 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1768 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1826 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1589 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1593 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fe9e1625e9e5f9626041a272bd5853e1937ba51 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 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 { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new A(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f688431373716beb39877a74cd5d87297d0a64e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..7478e0048213402e23cc0b7943b4732b63481299 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 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 {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3716361621e705ebf971362f3a919d49d9c63bd1 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..43eafd903dcdabf37bff8b31ae5b227be5be0bb2 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json @@ -0,0 +1,13 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar1": { + "@ohos/bytecodehar2": "2.0.0" + }, + "@ohos/bytecodehar2": { + } + } +} diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..839d23a63be919aec0c375491c09e70baf8755e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt @@ -0,0 +1,1718 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file2&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: hap-add-file.ts +record_name: &myapp/hap-add-file& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&myapp/hap-add-file& + dynamicimport + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "@normalized:N&&&myapp/hap-add-file&"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &myapp/hap-add-file&.#*#modTest(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 + dynamicimport + tryldglobalbyname 0x0, test + callarg0 0x1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &myapp/hap-add-file&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-add-file&.#*#modTest, 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-add-file&_0 +------------------------------------ +slot &myapp/hap-add-file&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 0 +}, +{ + index: 5 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-add-file&.#*#modTest"; "@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&myapp/hap-add-file& + dynamicimport + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "@normalized:N&&&myapp/hap-add-file&"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &myapp/hap-add-file&.#*#modTest(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 + dynamicimport + tryldglobalbyname 0x0, test + callarg0 0x1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &myapp/hap-add-file&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-add-file&.#*#modTest, 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-add-file&_0 +------------------------------------ +slot &myapp/hap-add-file&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 0 +}, +{ + index: 5 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-add-file&.#*#modTest"; "@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..b50023d9adf7aef2e9ad2161f836c098168cd4e6 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 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 { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + import('@normalized:N&&&myapp/hap-add-file&') + test(); + let a = new A(); +} + + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..d06729e3fa0a08bce25100e75e28f0cd7ba2b0a8 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 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. + */ + + +function modTest() { + import('@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0'); + test(); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..92d7f0e7b62ef2bdfa7b8da43b2597890ec30fcb --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt @@ -0,0 +1,8 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& +mod/hap-add-file:&myapp/hap-add-file& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f688431373716beb39877a74cd5d87297d0a64e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 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 {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 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. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt b/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt index c581c730f7ff44bef5ea64c2b0acc388c8b1a82a..1de34365394260c519f6047728e4a78fff60c5f9 100644 --- a/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt +++ b/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt @@ -21,8 +21,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 1, "sourceLineNum": -1 } }, @@ -36,8 +34,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 1, - "boundRight": 2, "sourceLineNum": -1 } }, @@ -51,8 +47,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 2, - "boundRight": 3, "sourceLineNum": -1 } }, @@ -65,8 +59,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 3, - "boundRight": 8, "sourceLineNum": 15 } }, @@ -79,8 +71,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 8, - "boundRight": 10, "sourceLineNum": 15 } }, @@ -91,8 +81,6 @@ "imms": [], "label": "LABEL_2", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -105,8 +93,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 10, - "boundRight": 12, "sourceLineNum": 15 } }, @@ -119,8 +105,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 12, - "boundRight": 14, "sourceLineNum": 15 } }, @@ -133,8 +117,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 14, - "boundRight": 19, "sourceLineNum": 15 } }, @@ -149,8 +131,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 19, - "boundRight": 22, "sourceLineNum": 15 } }, @@ -163,8 +143,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 22, - "boundRight": 24, "sourceLineNum": 15 } }, @@ -177,8 +155,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 24, - "boundRight": 29, "sourceLineNum": 16 } }, @@ -191,8 +167,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 29, - "boundRight": 31, "sourceLineNum": 16 } }, @@ -205,8 +179,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 31, - "boundRight": 34, "sourceLineNum": 17 } }, @@ -217,8 +189,6 @@ "imms": [], "label": "LABEL_1", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -231,8 +201,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 34, - "boundRight": 36, "sourceLineNum": 15 } }, @@ -245,8 +213,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 36, - "boundRight": 38, "sourceLineNum": 15 } }, @@ -259,8 +225,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 38, - "boundRight": 40, "sourceLineNum": 15 } }, @@ -273,8 +237,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 40, - "boundRight": 42, "sourceLineNum": 15 } }, @@ -287,8 +249,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 42, - "boundRight": 44, "sourceLineNum": 15 } }, @@ -301,8 +261,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 44, - "boundRight": 46, "sourceLineNum": 15 } }, @@ -315,8 +273,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 46, - "boundRight": 48, "sourceLineNum": 15 } }, @@ -329,8 +285,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 48, - "boundRight": 50, "sourceLineNum": 15 } }, @@ -343,8 +297,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 50, - "boundRight": 52, "sourceLineNum": 15 } }, @@ -357,8 +309,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 52, - "boundRight": 54, "sourceLineNum": 15 } }, @@ -369,8 +319,6 @@ "imms": [], "label": "LABEL_0", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -383,8 +331,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 54, - "boundRight": 59, "sourceLineNum": 19 } }, @@ -399,8 +345,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 59, - "boundRight": 64, "sourceLineNum": 19 } }, @@ -413,8 +357,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 64, - "boundRight": 69, "sourceLineNum": 20 } }, @@ -427,8 +369,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 69, - "boundRight": 71, "sourceLineNum": 20 } }, @@ -439,8 +379,6 @@ "imms": [], "label": "LABEL_5", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 20 } }, @@ -453,8 +391,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 71, - "boundRight": 73, "sourceLineNum": 20 } }, @@ -467,8 +403,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 73, - "boundRight": 75, "sourceLineNum": 20 } }, @@ -481,8 +415,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 75, - "boundRight": 80, "sourceLineNum": 20 } }, @@ -497,8 +429,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 80, - "boundRight": 83, "sourceLineNum": 20 } }, @@ -511,8 +441,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 83, - "boundRight": 85, "sourceLineNum": 20 } }, @@ -525,8 +453,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 85, - "boundRight": 90, "sourceLineNum": 21 } }, @@ -539,8 +465,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 90, - "boundRight": 92, "sourceLineNum": 21 } }, @@ -555,8 +479,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 92, - "boundRight": 96, "sourceLineNum": 22 } }, @@ -569,8 +491,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 96, - "boundRight": 98, "sourceLineNum": 22 } }, @@ -583,8 +503,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 98, - "boundRight": 100, "sourceLineNum": 22 } }, @@ -597,8 +515,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 100, - "boundRight": 102, "sourceLineNum": 22 } }, @@ -611,8 +527,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 102, - "boundRight": 104, "sourceLineNum": 22 } }, @@ -627,8 +541,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 104, - "boundRight": 107, "sourceLineNum": 22 } }, @@ -639,8 +551,6 @@ "imms": [], "label": "LABEL_4", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -653,8 +563,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 107, - "boundRight": 109, "sourceLineNum": 20 } }, @@ -667,8 +575,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 109, - "boundRight": 111, "sourceLineNum": 20 } }, @@ -681,8 +587,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 111, - "boundRight": 113, "sourceLineNum": 20 } }, @@ -695,8 +599,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 113, - "boundRight": 115, "sourceLineNum": 20 } }, @@ -709,8 +611,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 115, - "boundRight": 117, "sourceLineNum": 20 } }, @@ -723,8 +623,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 117, - "boundRight": 119, "sourceLineNum": 20 } }, @@ -737,8 +635,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 119, - "boundRight": 121, "sourceLineNum": 20 } }, @@ -751,8 +647,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 121, - "boundRight": 123, "sourceLineNum": 20 } }, @@ -765,8 +659,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 123, - "boundRight": 125, "sourceLineNum": 20 } }, @@ -779,8 +671,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 125, - "boundRight": 127, "sourceLineNum": 20 } }, @@ -791,8 +681,6 @@ "imms": [], "label": "LABEL_3", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -805,8 +693,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 127, - "boundRight": 132, "sourceLineNum": 24 } }, @@ -819,8 +705,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 132, - "boundRight": 134, "sourceLineNum": 24 } }, @@ -831,8 +715,6 @@ "imms": [], "label": "LABEL_8", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -845,8 +727,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 134, - "boundRight": 136, "sourceLineNum": 24 } }, @@ -859,8 +739,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 136, - "boundRight": 138, "sourceLineNum": 24 } }, @@ -873,8 +751,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 138, - "boundRight": 143, "sourceLineNum": 24 } }, @@ -889,8 +765,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 143, - "boundRight": 146, "sourceLineNum": 24 } }, @@ -903,8 +777,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 146, - "boundRight": 148, "sourceLineNum": 24 } }, @@ -917,8 +789,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 148, - "boundRight": 153, "sourceLineNum": 25 } }, @@ -931,8 +801,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 153, - "boundRight": 155, "sourceLineNum": 25 } }, @@ -943,8 +811,6 @@ "imms": [], "label": "LABEL_11", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 25 } }, @@ -957,8 +823,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 155, - "boundRight": 157, "sourceLineNum": 25 } }, @@ -971,8 +835,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 157, - "boundRight": 159, "sourceLineNum": 25 } }, @@ -985,8 +847,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 159, - "boundRight": 164, "sourceLineNum": 25 } }, @@ -1001,8 +861,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 164, - "boundRight": 167, "sourceLineNum": 25 } }, @@ -1015,8 +873,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 167, - "boundRight": 169, "sourceLineNum": 25 } }, @@ -1029,8 +885,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 169, - "boundRight": 174, "sourceLineNum": 26 } }, @@ -1043,8 +897,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 174, - "boundRight": 176, "sourceLineNum": 26 } }, @@ -1055,8 +907,6 @@ "imms": [], "label": "LABEL_10", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -1069,8 +919,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 176, - "boundRight": 178, "sourceLineNum": 25 } }, @@ -1083,8 +931,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 178, - "boundRight": 180, "sourceLineNum": 25 } }, @@ -1097,8 +943,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 180, - "boundRight": 182, "sourceLineNum": 25 } }, @@ -1111,8 +955,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 182, - "boundRight": 184, "sourceLineNum": 25 } }, @@ -1125,8 +967,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 184, - "boundRight": 186, "sourceLineNum": 25 } }, @@ -1139,8 +979,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 186, - "boundRight": 188, "sourceLineNum": 25 } }, @@ -1153,8 +991,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 188, - "boundRight": 190, "sourceLineNum": 25 } }, @@ -1167,8 +1003,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 190, - "boundRight": 192, "sourceLineNum": 25 } }, @@ -1181,8 +1015,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 192, - "boundRight": 194, "sourceLineNum": 25 } }, @@ -1195,8 +1027,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 194, - "boundRight": 196, "sourceLineNum": 25 } }, @@ -1207,8 +1037,6 @@ "imms": [], "label": "LABEL_9", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -1219,8 +1047,6 @@ "imms": [], "label": "LABEL_7", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -1233,8 +1059,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 196, - "boundRight": 198, "sourceLineNum": 24 } }, @@ -1247,8 +1071,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 198, - "boundRight": 200, "sourceLineNum": 24 } }, @@ -1261,8 +1083,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 200, - "boundRight": 202, "sourceLineNum": 24 } }, @@ -1275,8 +1095,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 202, - "boundRight": 204, "sourceLineNum": 24 } }, @@ -1289,8 +1107,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 204, - "boundRight": 206, "sourceLineNum": 24 } }, @@ -1303,8 +1119,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 206, - "boundRight": 208, "sourceLineNum": 24 } }, @@ -1317,8 +1131,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 208, - "boundRight": 210, "sourceLineNum": 24 } }, @@ -1331,8 +1143,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 210, - "boundRight": 212, "sourceLineNum": 24 } }, @@ -1345,8 +1155,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 212, - "boundRight": 214, "sourceLineNum": 24 } }, @@ -1359,8 +1167,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 214, - "boundRight": 216, "sourceLineNum": 24 } }, @@ -1371,8 +1177,6 @@ "imms": [], "label": "LABEL_6", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -1383,8 +1187,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } }, @@ -1395,8 +1197,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } } diff --git a/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt b/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt index 90556498d0ac47a604fe9baee66cf5e3c3add079..be4b8491f7caf58d8d88913e48c0cffe18ee2c25 100644 --- a/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt +++ b/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt @@ -21,8 +21,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 1, "sourceLineNum": -1 } }, @@ -36,8 +34,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 1, - "boundRight": 2, "sourceLineNum": -1 } }, @@ -51,8 +47,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 2, - "boundRight": 3, "sourceLineNum": -1 } }, @@ -65,8 +59,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 3, - "boundRight": 8, "sourceLineNum": 15 } }, @@ -81,8 +73,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 8, - "boundRight": 13, "sourceLineNum": 15 } }, @@ -95,8 +85,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 13, - "boundRight": 18, "sourceLineNum": 17 } }, @@ -109,8 +97,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 18, - "boundRight": 20, "sourceLineNum": 17 } }, @@ -123,8 +109,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 20, - "boundRight": 23, "sourceLineNum": 18 } }, @@ -137,8 +121,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 23, - "boundRight": 28, "sourceLineNum": 22 } }, @@ -151,8 +133,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 28, - "boundRight": 30, "sourceLineNum": 22 } }, @@ -165,8 +145,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 30, - "boundRight": 33, "sourceLineNum": 23 } }, @@ -179,8 +157,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 33, - "boundRight": 38, "sourceLineNum": 25 } }, @@ -193,8 +169,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 38, - "boundRight": 40, "sourceLineNum": 25 } }, @@ -207,8 +181,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 40, - "boundRight": 45, "sourceLineNum": 27 } }, @@ -221,8 +193,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 45, - "boundRight": 47, "sourceLineNum": 27 } }, @@ -233,8 +203,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } }, @@ -245,8 +213,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } } diff --git a/es2panda/test/compiler/js/array-literal-1-expected.txt b/es2panda/test/compiler/js/array-literal-1-expected.txt index 1a9c6f0aeb65047698dda549f7fa0dda1d02d7c4..877137e32a7495feb394e0fe13a0f03b81df55a8 100644 --- a/es2panda/test/compiler/js/array-literal-1-expected.txt +++ b/es2panda/test/compiler/js/array-literal-1-expected.txt @@ -1 +1 @@ -TypeError: is not callable +TypeError: Object is not callable diff --git a/es2panda/test/compiler/js/json-parser-expected.txt b/es2panda/test/compiler/js/json-parser-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..09daa6cc4f4d62bf98424fd88eeb6ac120382257 --- /dev/null +++ b/es2panda/test/compiler/js/json-parser-expected.txt @@ -0,0 +1,49 @@ +1,2,3 1,2,3 +1 1 + +https://www.a.com https://www.a.com +https://www.b.com https://www.b.com +https://www.c.com https://www.c.com +[object Object] [object Object] +Infinity Infinity +-Infinity -Infinity +123 123 +SyntaxError SyntaxError +56320 56320 +{"a":"{\"width\": 18}"} {"a":"{\"width\": 18}"} +{"a":"{\"name\": \"张三\"}"} {"a":"{\"name\": \"张三\"}"} +{"1\u0000":"name"} {"1\u0000":"name"} +0 0 +-Infinity -Infinity +JSON.parse with backslash JSON.parse with backslash +"" "" +Uf Uf +啕晦 啕晦 +"" "" +Uf Uf +啕晦 啕晦 +SyntaxError SyntaxError +SyntaxError SyntaxError +SyntaxError SyntaxError +10 10 +hello hello +true true +14 14 +24 24 +29 29 +36 36 +46 46 +1.79e+308 1.79e+308 +Infinity Infinity +Infinity Infinity +2.225e-308 2.225e-308 +2.225e-309 2.225e-309 +3e-320 3e-320 +5e-324 5e-324 +0 0 +0 0 +2.225e-308 +2.225e-309 +3e-320 +5e-324 +SyntaxError SyntaxError diff --git a/es2panda/test/compiler/js/json-parser.js b/es2panda/test/compiler/js/json-parser.js new file mode 100644 index 0000000000000000000000000000000000000000..bb7a92d40a4a7b8322117cd695a9f62f878d3305 --- /dev/null +++ b/es2panda/test/compiler/js/json-parser.js @@ -0,0 +1,207 @@ +/* + * Copyright (c) 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. + */ + + +let json = JSON.parse("[ 1, 2, 3]"); +print(json,[1,2,3]); +let json2 = JSON.parse("[ 1 ]"); +print(json2,[1]); +let json3 = JSON.parse("[ ]"); +print(json3,[]); +let data = { + "11111111" : "https://www.a.com", + "22222222" : "https://www.b.com", + "00000000" : "https://www.c.com" +} +let strData = JSON.stringify(data); +let res = JSON.parse(strData); +print(res["11111111"],'https://www.a.com'); +print(res["22222222"],'https://www.b.com'); +print(res["00000000"],'https://www.c.com'); + +var a = `{"code": 0, "msg": "ok"}` +function reviver(k, v) { return v; } +var o = JSON.parse(a, reviver); +print(o.toString(),'[object Object]'); + +let strData2 = "1.7976971348623157e+308"; +let res2 = JSON.parse(strData2); +print(res2,Infinity); + +let strData3 = "-1.7976971348623157e+308"; +let res3 = JSON.parse(strData3); +print(res3,-Infinity); + +let strData4 = "123"; +let res4 = JSON.parse(strData4); +print(res4,123); + +try { + JSON.parse(`{"object": 42, "test":{}`) +} catch (error) { + print(error.name,'SyntaxError') + +} + +let strData5 = "\"\\uDC00\""; +let res5 = JSON.parse(strData5); +print(res5.codePointAt(0),56320) + +let strData6 = '{"a": "{\\"width\\": 18}"}' +print(JSON.stringify(JSON.parse(strData6)),'{"a":"{\\"width\\": 18}"}') + +let strData7 = '{"a": "{\\"name\\": \\"张三\\"}"}' +print(JSON.stringify(JSON.parse(strData7)),'{"a":"{\\"name\\": \\"张三\\"}"}') + +let strData8 = '{"1\\u0000":"name"}' +print(JSON.stringify(JSON.parse(strData8)),'{"1\\u0000":"name"}') + +print(JSON.parse('123.456e-789'),0); +print(1 / JSON.parse('-0'),-Infinity); + +var string = "JSON.parse with backslash"; +print(string,"JSON.parse with backslash"); +print(JSON.parse('"\\"\\""'),'""'); // utf8 -> utf8 +print(JSON.parse('"\\u0055\\u0066"'),'Uf'); // utf8 -> utf8 +print(JSON.parse('"\\u5555\\u6666"'),'啕晦'); // utf8 -> utf16 +print(JSON.parse('["\\"\\"","中文"]')[0],'""'); // utf16 -> utf8 +print(JSON.parse('["\\u0055\\u0066","中文"]')[0],'Uf'); // utf16 -> utf8 +print(JSON.parse('["\\u5555\\u6666","中文"]')[0],'啕晦'); // utf16 -> utf16 + +const strData9 = `{"k1":"hello","k2":3}`; +const strErr = strData9.substring(0, strData9.length - 2); +try { + JSON.parse(strErr); +} catch (err) { + print(err.name,'SyntaxError'); +} + +const strData10 = `{"k1":"hello","k2": 3}`; +const strErr2 = strData10.substring(0, strData10.length - 2); +try { + JSON.parse(strErr2); +} catch (err) { + print(err.name,'SyntaxError'); +} + +const strData11 = `{"k1":"hello","k2":311111}`; +const strErr3 = strData11.substring(0, strData11.length - 2); +try { + JSON.parse(strErr3); +} catch (err) { + print(err.name,'SyntaxError'); +} + +let jsonSingleStr = `{ + "a": 10, + "b": "hello", + "c": true, + "d": null, + "e": 5, + "f": 6, + "g": 7, + "h": 8, + "i": 9, + "j": 10, + "k": 11, + "l": 12, + "m": 13, + "n": 14, + "o": 15, + "p": 16, + "q": 17, + "r": 18, + "s": 19, + "t": 20, + "u": 21, + "v": 22, + "w": 23, + "x": 24, + "y": 25, + "z": 26, + "A": 27, + "B": 28, + "C": 29, + "D": 30, + "E": 31, + "F": 32, + "G": 33, + "H": 34, + "I": 35, + "J": 36, + "K": 37, + "L": 38, + "M": 39, + "N": 40, + "O": 41, + "P": 42, + "Q": 43, + "R": 44, + "S": 45, + "T": 46, + "U": 47, + "V": 48, + "W": 49, + "X": 50, + "Y": 51, + "Z": 52 +}`; + +let parsedObj = JSON.parse(jsonSingleStr); +print(parsedObj.a, 10); +print(parsedObj.b, 'hello'); +print(parsedObj.c, true); +print(parsedObj.n, 14); +print(parsedObj.x, 24); +print(parsedObj.C, 29); +print(parsedObj.J, 36); +print(parsedObj.T, 46); + +let numStr = `{ + "numberval1": 1.79e+308, + "numberval2": 1.7976931348623158e+309, + "numberval3": 5e+320, + "numberval4": 2.225e-308, + "numberval5": 2.225e-309, + "numberval6": 3e-320, + "numberval7": 5e-324, + "numberval8": 5e-325, + "numberval9": 7e-350 +}`; +let numParsedObj = JSON.parse(numStr); +print(numParsedObj.numberval1, 1.79e+308);// DBL_MAX +print(numParsedObj.numberval2, Infinity);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval3, Infinity);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval4, 2.225e-308);// DBL_MIN +print(numParsedObj.numberval5, 2.225e-309);// less than DBL_MIN +print(numParsedObj.numberval6, 3e-320);// less than DBL_MIN +print(numParsedObj.numberval7, 5e-324);// Number.MIN_VALUE +print(numParsedObj.numberval8, 0);// less than Number.MIN_VALUE, expect 0 +print(numParsedObj.numberval9, 0);// less than Number.MIN_VALUE, expect 0 + +print(2.225e-308); // 2.225e-308 +print(2.225e-309); // 2.225e-309 +print(3e-320); // 3e-320 +print(5e-324); // 5e-324 + +{ + let err = {}; + try { + JSON.parse(`{"object哈哈": 42, "test":{}`) + } catch (error) { + err = error; + } + print(err.name, 'SyntaxError'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ab2536e66495936b2204205a550c80b8b4d8355 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt @@ -0,0 +1,10 @@ +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js new file mode 100644 index 0000000000000000000000000000000000000000..75672f2a6b9c6964bf738b7dd38462a5a2623f2e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + for (let v40 = 0; v40 < 10; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + print(e52); + } + } + super(); + } +} +new C35(); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super-expected.txt diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js new file mode 100644 index 0000000000000000000000000000000000000000..d9f14924444f619b6875e940eb75b5f0d896dfc3 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + super(); + for (let v40 = 0; v40 < 10; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + print(e52); + } + } + } +} +new C35(); diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt new file mode 100644 index 0000000000000000000000000000000000000000..8cf0b55aaaaf93acdb66613576bdfa749ea3c659 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt @@ -0,0 +1,2 @@ +main_hap.ts +main_hap_import_file.ts diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt new file mode 100644 index 0000000000000000000000000000000000000000..128e160248bbfe2d832e30a4bb511a0aef8c35da --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt @@ -0,0 +1,2 @@ +sdk_hap.ts +sdk_hap_import_file.ts diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..f8c85e90b8ac47f49cc3df51a1f80ee4f48d501a --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt @@ -0,0 +1,306 @@ +slotNum = 0x2 +.language ECMAScript +.function any &src_hap_to/main_hap&.#*#main(any a0, any a1, any a2) { + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname mainHapAddTest + lda v0 + callarg0 0x0 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &src_hap_to/main_hap&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/main_hap&.#*#main, 0x0 + callarg0 0x1 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/main_hap&_1084 +------------------------------------ +slot &src_hap_to/main_hap&_1088 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: &src_hap_to/main_hap_import_file& +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: mainHapAddTest +}, +{ + index: 4 + tag: 5 + val: mainHapAddTest +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/main_hap&.#*#main"; "mainHapAddTest"; +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/main_hap_import_file&.#*#mainHapAddTest(any a0, any a1, any a2, any a3, any a4) { + lda a4 + add2 0x0, a3 + return +} + +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/main_hap_import_file&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/main_hap_import_file&.#*#mainHapAddTest, 0x2 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/main_hap_import_file&_1130 +------------------------------------ +slot &src_hap_to/main_hap_import_file&_1134 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: mainHapAddTest +}, +{ + index: 5 + tag: 5 + val: mainHapAddTest +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/main_hap_import_file&.#*#mainHapAddTest"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x2 +.language ECMAScript +.function any &src_hap_to/sdk_hap&.#*#main(any a0, any a1, any a2) { + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname sdkHapAddTest + lda v0 + callarg0 0x0 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &src_hap_to/sdk_hap&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/sdk_hap&.#*#main, 0x0 + callarg0 0x1 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/sdk_hap&_1051 +------------------------------------ +slot &src_hap_to/sdk_hap&_1055 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: &src_hap/sdk_hap_import_file& +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 4 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/sdk_hap&.#*#main"; "sdkHapAddTest"; +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest(any a0, any a1, any a2, any a3, any a4) { + lda a4 + add2 0x0, a3 + return +} + +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/sdk_hap_import_file&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest, 0x2 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/sdk_hap_import_file&_1097 +------------------------------------ +slot &src_hap_to/sdk_hap_import_file&_1101 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 5 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts new file mode 100644 index 0000000000000000000000000000000000000000..71370610b2920fe8a0eb3db310a42cf0e1251730 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 {mainHapAddTest} from '&src_hap_to/main_hap_import_file&' + +function main(): void { + mainHapAddTest(); +} + +main() diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts new file mode 100644 index 0000000000000000000000000000000000000000..b27f3ac054e476ab6ca42bfb6ebcf1071152f3d1 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +export function mainHapAddTest(a: number, b: number): number +{ + return a + b; +} \ No newline at end of file diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt new file mode 100644 index 0000000000000000000000000000000000000000..7a945914df60d5279963503cfc3feffe25c9c5d4 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt @@ -0,0 +1 @@ +src_hap:src_hap_to diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fc5ee282130b69148afbc05d4085c2556319ddd --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt @@ -0,0 +1,4 @@ +main_hap:&src_hap_to/main_hap& +main_hap_import_file:&src_hap_to/main_hap_import_file& +sdk_hap:&src_hap/sdk_hap& +sdk_hap_import_file:&src_hap/sdk_hap_import_file& diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts new file mode 100644 index 0000000000000000000000000000000000000000..8087e36196f4df495ece5b7d5b33a82ecb5cbd77 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 {sdkHapAddTest} from '&src_hap/sdk_hap_import_file&' + +function main(): void { + sdkHapAddTest(); +} + +main() diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts new file mode 100644 index 0000000000000000000000000000000000000000..041a885320f588cc68f561fb2d7b4fa1446fa172 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +export function sdkHapAddTest(a: number, b: number): number +{ + return a + b; +} \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4fd6ce6872b3ca43bf5892e5865ecae098c2c696 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt @@ -0,0 +1,38 @@ +1.79e+308 +Infinity +Infinity +2.225e-308 +2.225e-309 +3e-320 +5e-324 +0 +0 +-1.79e+308 +-Infinity +-Infinity +-2.225e-308 +-2.225e-309 +-3e-320 +-5e-324 +0 +0 +false +false +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f765b620664a54d33c37b3e4d0a211f75484f49 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 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. + */ + + +let numStr = `{ + "numberval1": 1.79e+308, + "numberval2": 1.7976931348623158e+309, + "numberval3": 5e+320, + "numberval4": 2.225e-308, + "numberval5": 2.225e-309, + "numberval6": 3e-320, + "numberval7": 5e-324, + "numberval8": 5e-325, + "numberval9": 7e-350, + "numberval10": -1.79e+308, + "numberval11": -1.7976931348623158e+309, + "numberval12": -5e+320, + "numberval13": -2.225e-308, + "numberval14": -2.225e-309, + "numberval15": -3e-320, + "numberval16": -5e-324, + "numberval17": -5e-325, + "numberval18": -7e-350 +}`; + +let numParsedObj = JSON.parse(numStr); +print(numParsedObj.numberval1);// DBL_MAX, 1.79e+308 +print(numParsedObj.numberval2);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval3);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval4);// DBL_MIN, 2.225e-308 +print(numParsedObj.numberval5);// less than DBL_MIN, 2.225e-309 +print(numParsedObj.numberval6);// less than DBL_MIN, 3e-320 +print(numParsedObj.numberval7);// Number.MIN_VALUE, 5e-324 +print(numParsedObj.numberval8);// less than Number.MIN_VALUE, expect 0 +print(numParsedObj.numberval9);// less than Number.MIN_VALUE, expect 0 + +print(numParsedObj.numberval10); // -1.79e+308 +print(numParsedObj.numberval11); // -Infinity +print(numParsedObj.numberval12); // -Infinity +print(numParsedObj.numberval13); // -2.225e-308 +print(numParsedObj.numberval14); // -2.225e-309 +print(numParsedObj.numberval15); // -3e-320 +print(numParsedObj.numberval16); // -5e-324 +print(numParsedObj.numberval17); // -0 +print(numParsedObj.numberval18); // -0 + +print(Object.is(numParsedObj.numberval2, numParsedObj.numberval11)) // false +print(Object.is(numParsedObj.numberval18, numParsedObj.numberval9)) // false + +print(Object.is(numParsedObj.numberval1, 1.79e+308)); // true +print(Object.is(numParsedObj.numberval2, Infinity)); // true +print(Object.is(numParsedObj.numberval3, Infinity)); // true +print(Object.is(numParsedObj.numberval4, 2.225e-308)); // true +print(Object.is(numParsedObj.numberval5, 2.225e-309)); // true +print(Object.is(numParsedObj.numberval6, 3e-320)); // true +print(Object.is(numParsedObj.numberval7, Number.MIN_VALUE)); // true +print(Object.is(numParsedObj.numberval8, 0)); // true +print(Object.is(numParsedObj.numberval9, 0)); // true + +print(Object.is(numParsedObj.numberval10, -1.79e+308)); // true +print(Object.is(numParsedObj.numberval11, -Infinity)); // true +print(Object.is(numParsedObj.numberval12, -Infinity)); // true +print(Object.is(numParsedObj.numberval13, -2.225e-308)); // true +print(Object.is(numParsedObj.numberval14, -2.225e-309)); // true +print(Object.is(numParsedObj.numberval15, -3e-320)); // true +print(Object.is(numParsedObj.numberval16, -5e-324)); // true +print(Object.is(numParsedObj.numberval17, -0)); // true, distinguishes from 0 +print(Object.is(numParsedObj.numberval18, -0)); // true \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9ee55078c115a54972821ed3759d4cce4ff5a666 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt @@ -0,0 +1,18 @@ +1.79e+308 +Infinity +Infinity +2.225e-308 +2.225e-309 +3e-320 +5e-324 +0 +0 +-1.79e+308 +-Infinity +-Infinity +-2.225e-308 +-2.225e-309 +-3e-320 +-5e-324 +0 +0 diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfa7afc80d33026c02b2700f1844cc7e9ef9c0fc --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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. + */ + + +print(1.79e+308); +print(1.7976931348623158e+309); +print(5e+320); +print(2.225e-308); +print(2.225e-309); +print(3e-320); +print(5e-324); +print(5e-325); +print(7e-350); + +print(-1.79e+308); +print(-1.7976931348623158e+309); +print(-5e+320); +print(-2.225e-308); +print(-2.225e-309); +print(-3e-320); +print(-5e-324); +print(-5e-325); +print(-7e-350); \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..25d54ae75586b1d426ebc99503cb5141b6319aec --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt @@ -0,0 +1,2 @@ +333 +111 1 diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts new file mode 100644 index 0000000000000000000000000000000000000000..717ae2477f4c7617015a2459b60ef6c117980a29 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + + +let a = "111"; +let b = "222"; +let c = true; +function test1() { + print("333") +} +function test2(aa : string = c ? (test1(),a) : (test1(),b), dd:number = 1) { + print(aa, dd); +} + +test2() diff --git a/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts b/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts index 0cb3633e5b585c7cf1cacae5fd2f579feae7c03b..c2ec7c2624228af689abe066be206a7b6ad13793 100644 --- a/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts +++ b/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts @@ -24,8 +24,8 @@ class C { } let c = new C(); -let env = ArkTools.getLexicalEnv(c.method1); -if (env !== undefined) { +let res = ArkTools.currentEnvIsGlobal(c.method1); +if (res !== true) { print(1); } else { print(2); diff --git a/es2panda/test/config.py b/es2panda/test/config.py index 6e57dedbad40e21ee0b2c5b275cae1cbebdc7e31..6cf0d5ede391eb662cc6c2aa3e066182908d756f 100644 --- a/es2panda/test/config.py +++ b/es2panda/test/config.py @@ -22,7 +22,26 @@ API_VERSION_MAP = { "API12beta2": "12.0.2.0", "API12beta3": "12.0.6.0", "API13": "12.0.6.0", + "API14": "12.0.6.0", + "API15": "12.0.6.0", + "API16": "12.0.6.0", + "API17": "12.0.6.0", + "API18": "13.0.1.0", + "API19": "13.0.1.0", + "API20": "13.0.1.0", } + +ARK_JS_VM_LIST = {"API9", "API10", "API11", "API12beta1", "API12beta3", "API18"} + +ES2ABC_API_SUPPORT = { + "default": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17", "API18"], + "5.0": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17"], + "5.1": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17", "API18"], +} + MIN_SUPPORT_BC_VERSION = "API12beta1" MIX_COMPILE_ENTRY_POINT = "import" diff --git a/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt index 4c936880569b6656f65a26c70923310db237b381..8c9283391a83cb6213cbd8d5f22274499acdde27 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -812,7 +812,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts b/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts index 8bb5148dc721dad55760f4cf315cd6dd0f348a4c..b13f16c168dc4afec2966bf489d0c34eafae41d4 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[][][] = [[[true, false], [true, false]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt index 0a07759fa1a9fae16b424b80c1fe18d1d238dfa9..8405fb734e1ed811f3b7d1fbfa51343a31f1343a 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -465,7 +465,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -770,7 +770,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -804,7 +804,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -1081,7 +1081,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts index 744a142fe28730bf84d1f48621bdcdd2254e9126..4a04e01d3ba4e4b68442a5c36ac47339c99bcf5d 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[][][] = [[new Array(0)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[][][] = [[new Array(1)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[[42, 314, 42]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt index 953a3b9d73e3d7aeea255f16224cb373666417f4..bbbcb10019dd63e85b541d61be034a411f8d0c93 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -465,7 +465,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -770,7 +770,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -804,7 +804,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -1081,7 +1081,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts index 8eeef595d0e2bbd1b6afbe902a3920b97f0c564b..a24f1a805f6938f5b29fa3a66b6379ecdb596eb2 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[][][] = [[new Array(2)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[][][] = [[new Array(3)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[["Hello", "world!", "Hello"]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt index 6731c66866aef0dcf8cabc5d330d5f8bfc5381ce..6ba651775b65a0184302e9369a8509a191a6197a 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -840,7 +840,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-number.ts b/es2panda/test/parser/annotations/declaration-3d-array-number.ts index 9b4c19e954ca1490a45ff58a91e65a12135e454c..63d77e8e81e28e70cd3e816d7083138190467ea6 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[][][] = [[[1, 2, 3], [4, 5, 6]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt index ab3dd1bc1da156b40340a5f16f8215899cb80ce3..f92907c304a6eb37acfbc8a7c4dc1353e42a2147 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -812,7 +812,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-string.ts b/es2panda/test/parser/annotations/declaration-3d-array-string.ts index 9d2d477d78b5c09c70f7b74b42b74cc38f80640e..09a27904d4751c31a2b11852d7ccb84d003d5461 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[][][] = [[["hello", "world"], ["hello", "world"]]]; } diff --git a/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt index 25bca148bd87373a4e9d5520d7d42a6f5b95137d..4d3196200f7b44bc2b28fa13c450dcac9f327fb0 100644 --- a/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-boolean.ts b/es2panda/test/parser/annotations/declaration-array-boolean.ts index b5e92f592d43e9018fc8ef55a4931d9e1f89c936..c575410d77ecb84c7c4056b56f99dd36be3cc499 100644 --- a/es2panda/test/parser/annotations/declaration-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[] = [true, false, true]; } diff --git a/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt index 2c0dff61970473caaca69c2548c5c5883b0db7c5..c54ae5762ca19c9250f1caa67d98f03f8276b196 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -409,7 +409,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -658,7 +658,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -692,7 +692,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-array-enum-number.ts index 11b05547110aa9349ccd85aab9adc3fb4b3428f0..fe4efedad57d14334d92389152c8be1405d4791c 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[] = new Array(0); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[] = new Array(1); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = [42, 314, 42]; } diff --git a/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt index ee84947486312f1c48dd90ff8ce7b6007bc619f4..e598eac92c747fde49129b7ffcf5d35a59dce700 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -409,7 +409,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -658,7 +658,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -692,7 +692,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-array-enum-string.ts index a55745424cd2cbffdff0f6844cd0e61f46a21db3..39e7411e1a54dfec881d36f64e0a08203b809baa 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[] = new Array(2); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[] = new Array(3); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = ["Hello", "world!", "Hello"]; } diff --git a/es2panda/test/parser/annotations/declaration-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-array-number-expected.txt index b977d890471435e412d9ee714d8d7d9c027df9da..b157c668a35b22da030fb708c4535819feae6629 100644 --- a/es2panda/test/parser/annotations/declaration-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-number.ts b/es2panda/test/parser/annotations/declaration-array-number.ts index 20b83d18433cd15daea94a5042bceed5f01f1aca..e2a8a5567227bf4df2eec0010fd4f1f289df0b1b 100644 --- a/es2panda/test/parser/annotations/declaration-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[] = [1, 2, 3]; } diff --git a/es2panda/test/parser/annotations/declaration-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-array-string-expected.txt index 280bb6e06cf931b868ad0e62d3633df7afd6a492..80e6ca76fcc5d3c739644c6365e4f2c32f17b71b 100644 --- a/es2panda/test/parser/annotations/declaration-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-string.ts b/es2panda/test/parser/annotations/declaration-array-string.ts index 69cfe97efcf42aa24d331347f690be6f4c018abc..2de6642e2463d14334115eb53fe796878f86bf69 100644 --- a/es2panda/test/parser/annotations/declaration-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[] = ["Hello", "world", "!"]; } diff --git a/es2panda/test/parser/annotations/declaration-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-boolean-expected.txt index 3ad0c6449779f9e817e4c6cfaa61b6cec77691b9..55945c1f9b4cbb83d40a2f512f8cae5fb0359236 100644 --- a/es2panda/test/parser/annotations/declaration-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-boolean.ts b/es2panda/test/parser/annotations/declaration-boolean.ts index e9bf814b7e14fef3b349fe5c28dd3aefae01d47b..086025dbd9a81925f1c84429f7f88a27a32e022e 100644 --- a/es2panda/test/parser/annotations/declaration-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-boolean.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean = true; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-combination-expected.txt b/es2panda/test/parser/annotations/declaration-combination-expected.txt index 43531af2d56bcf038b3e25fc76511057c409a67c..5fac4e23ca8ca8ee7b2c581b97dce5310756cde9 100644 --- a/es2panda/test/parser/annotations/declaration-combination-expected.txt +++ b/es2panda/test/parser/annotations/declaration-combination-expected.txt @@ -279,7 +279,7 @@ }, "end": { "line": 27, - "column": 16 + "column": 38 } } }, @@ -1416,7 +1416,7 @@ "loc": { "start": { "line": 27, - "column": 17 + "column": 39 }, "end": { "line": 38, diff --git a/es2panda/test/parser/annotations/declaration-combination.ts b/es2panda/test/parser/annotations/declaration-combination.ts index 79cb3c6032425101a731f9d8460a3d4ed52ad4e5..2c23ae9d6eb9413ee5b666d0ccc3c6b19788e1ae 100644 --- a/es2panda/test/parser/annotations/declaration-combination.ts +++ b/es2panda/test/parser/annotations/declaration-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, 10] c: string diff --git a/es2panda/test/parser/annotations/declaration-empty-expected.txt b/es2panda/test/parser/annotations/declaration-empty-expected.txt index 2d482ef3bf7baa0634ec0fdccc8e92a09f22701e..eabbd5ebed59971549630b47a04767fd300cdbb3 100644 --- a/es2panda/test/parser/annotations/declaration-empty-expected.txt +++ b/es2panda/test/parser/annotations/declaration-empty-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -95,7 +95,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -104,11 +104,11 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -121,7 +121,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } } diff --git a/es2panda/test/parser/annotations/declaration-empty.ts b/es2panda/test/parser/annotations/declaration-empty.ts index 4d205f1d28c5947498aa920c5ee887ea825a4a16..80ae4e05b8580a0eeb03456386a7854204744303 100644 --- a/es2panda/test/parser/annotations/declaration-empty.ts +++ b/es2panda/test/parser/annotations/declaration-empty.ts @@ -13,4 +13,4 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} diff --git a/es2panda/test/parser/annotations/declaration-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-enum-number-expected.txt index 5b5801e6bb461b4c2ab384b471b08bd07244d6b3..2861338efa556be75bb7acb3caf4f7405f7080df 100644 --- a/es2panda/test/parser/annotations/declaration-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -346,7 +346,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -380,7 +380,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -545,7 +545,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 28, diff --git a/es2panda/test/parser/annotations/declaration-enum-number.ts b/es2panda/test/parser/annotations/declaration-enum-number.ts index 095d97c985d0ca75c019935f770412d0b8878c07..74f82890046248d5b22dae7f8015a8a4ba17b26f 100644 --- a/es2panda/test/parser/annotations/declaration-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-enum-number.ts @@ -18,11 +18,11 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type number a: E = new Number(0) as number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = 42; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-enum-string-expected.txt index 090667cd366df32f40a521e0e200c8903bbef1dd..b259e706c72419dadb88d2ca1b5e3ecb850d87aa 100644 --- a/es2panda/test/parser/annotations/declaration-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -277,7 +277,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -311,7 +311,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -476,7 +476,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 28, diff --git a/es2panda/test/parser/annotations/declaration-enum-string.ts b/es2panda/test/parser/annotations/declaration-enum-string.ts index 668b13ba51d72057b1111438bd928c13bedd489f..e8f77e41a217e4caa3a3db46de289c62347a6b45 100644 --- a/es2panda/test/parser/annotations/declaration-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-enum-string.ts @@ -18,11 +18,11 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type string a: E; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = "Hello"; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-number-expected.txt b/es2panda/test/parser/annotations/declaration-number-expected.txt index d692da40994e60c33a2b000a841d517bb78f9d95..04bc5cdf91f5fe3fff19898f9e106a9f5d77e311 100644 --- a/es2panda/test/parser/annotations/declaration-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-number.ts b/es2panda/test/parser/annotations/declaration-number.ts index e5c48f9af641f0f0451ad667183c8164203d6cee..340bf0775121cf0aa3f3e170616d7863fce60745 100644 --- a/es2panda/test/parser/annotations/declaration-number.ts +++ b/es2panda/test/parser/annotations/declaration-number.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 42; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-string-expected.txt b/es2panda/test/parser/annotations/declaration-string-expected.txt index 45fdfa8882ac05aca4fb7f6b24c7f01151e4463d..e1d5699252b77da084321058fc483eaafa0f7d18 100644 --- a/es2panda/test/parser/annotations/declaration-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-string.ts b/es2panda/test/parser/annotations/declaration-string.ts index 2f67dfdc93f9626c754bb871e1a3ea6eda569e78..52e99594617389227a8f3c2e932abc592571d4c2 100644 --- a/es2panda/test/parser/annotations/declaration-string.ts +++ b/es2panda/test/parser/annotations/declaration-string.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string = "Hello world!"; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt index a4e4f5d1e82d74a12bf142aad26a926ea6095b4d..22b62cab12a136255338cc4739779e359b8553ad 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts index b228a7be88bbcdc9acf8ad31da5fa7d30d5aea2e..e707f942b5deddf83713a8c326d93162c8f4d590 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt index 2dbeae8061aec5a19f9275fa3397455ebdf8b4dc..2d65b1e6836573fc9368d4c758ca07e138a78bf1 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -545,7 +545,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -804,7 +804,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts index 112d363eaad046ee58e2504d9f4f2a482b9a3a59..7a8eb2c54925cde23ecd823ed3aef199248372ed 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(0)]]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt index 8911a2388b26c5728c2a942d27fe3cee8be67c49..6835399a7b9af20e533edc1d5066aec1673417f6 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -545,7 +545,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -804,7 +804,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts index 3ea8b4242bbbf19418701fbf8dce909f75358500..175a0dcb7a93270affd66c1335480c174a2be5f4 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(2)]]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt index c53855fdb4153b7457af023d6e0fba035ac87804..c3b2c24a2a206b5d077404a2c2752dec09e0d24c 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts index 9b32dad4ff7d4870557417742cc733ffaaebb54a..94b2ec54c9e68f424a113447b34d0fac6dfdb6ab 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt index a2d10906343c4a3bdd7e54d181b3c7581ebb9984..7c408210768edef8518d3ab714ee90d3397e3aeb 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts index 8bdbb7118e9996f7c99637dd147a82d0e24eb1b6..37e8437d72aa2c3145dca40ffa6691294fcb79e2 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt index 7588f64ce7d4636cf24107aa44f1a8cd3fc21df2..0fe8d00444ed91cb40c8bf34aab6f05e8efb409e 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts index 06ae0c99571fdd0308b644460b368e65d069b7d4..cd8fece8279a7d132e7a6398b85631455d073d2c 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt index ac78e9174353a9e1f3747a29e46829417c6f080e..1cf2806754de87b69f771bbcfdcfcfa2a89d4aa9 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -489,7 +489,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -718,7 +718,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts index 801fefe3f00ce1065410d499d662429b5fa778cb..0524e6a24061e029b58c17628eab418defb047e1 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2, } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(0); } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt index b2cc2f5d774d922f1df503732bbbdb4c0dfc9ddc..99c0d05521c5b8f91eb5887ad6cca9ccb24b5189 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -489,7 +489,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -718,7 +718,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts index aa3bd9c9fbd145aba6be513f37384ffc078ad36b..52742a3241cc03aafcb0daf8228f2a14bdee1464 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world", } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(2); } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt index ffb333697923a4b728f228084459c322c49860c7..1dacb954aa0d193e77ef3eee43ca9ca8f44d8b64 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-number.ts b/es2panda/test/parser/annotations/declaration-usage-array-number.ts index 47fc593175b4fa8ff2a64fb04fce8b61adb0fd25..995e9a06345d6a291a308254cec1cf665b13ae11 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt index 78da22a43a7798b5eba6f64c1e246cb2f130bd58..f9baa7b888e95148f6c55ede30d5548e8da0bdfa 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-string.ts b/es2panda/test/parser/annotations/declaration-usage-array-string.ts index c14f9d9d8fd68fa1d0756c8f21d84b10da738391..c00fe674fcc5ac3a3cebb385e3c3a25224990fbe 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt index b77604f15c3717ae11c95de27463a0a5ed32e4d7..3b769f56fa20cc908626e016fe700e394126d028 100644 --- a/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-boolean.ts index b47a2078487b87c4f8b679c8b12633597c77307a..3e7da49918ef6cf00cac1e7740bc1fb3464bc09a 100644 --- a/es2panda/test/parser/annotations/declaration-usage-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean; } diff --git a/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt b/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt index 22dba78913f600f7fc0cf9a3374c4c167ddc5655..c0ec68a50c611f3551716f35d888876ce82064c4 100644 --- a/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt @@ -279,7 +279,7 @@ }, "end": { "line": 27, - "column": 16 + "column": 38 } } }, @@ -1416,7 +1416,7 @@ "loc": { "start": { "line": 27, - "column": 17 + "column": 39 }, "end": { "line": 38, @@ -1530,7 +1530,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 40, @@ -2527,7 +2527,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 42, diff --git a/es2panda/test/parser/annotations/declaration-usage-combination.ts b/es2panda/test/parser/annotations/declaration-usage-combination.ts index 16b861ff38393433f3b5df2683e26b8c8b600c2f..ffac927a7597ccc0c53cde7819c78a833797e666 100644 --- a/es2panda/test/parser/annotations/declaration-usage-combination.ts +++ b/es2panda/test/parser/annotations/declaration-usage-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, 10] c: string diff --git a/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt b/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt index 4ab2bc897cff30e1458f345db3d9293a17b0bea6..06af843949b5c81d22b6ba07607f5999ddec2c26 100644 --- a/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -95,7 +95,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -104,11 +104,11 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -121,7 +121,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -216,7 +216,7 @@ "type": "Annotation", "expression": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 18, @@ -328,7 +328,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -452,7 +452,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 23, diff --git a/es2panda/test/parser/annotations/declaration-usage-empty.ts b/es2panda/test/parser/annotations/declaration-usage-empty.ts index badbc9745a1434a8e45996e86aee590e4705958f..b781add198329819f7d9e2290005b6ac08b2e6f2 100644 --- a/es2panda/test/parser/annotations/declaration-usage-empty.ts +++ b/es2panda/test/parser/annotations/declaration-usage-empty.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} @__$$ETS_ANNOTATION$$__Anno class A { diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt index 0f2c03ff8ebfb3c93eac4b7f3b291b128297be07..08708ed1c48f95f6e18337769ca142ef79b87730 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -346,7 +346,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -460,7 +460,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -646,7 +646,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-enum-number.ts index 693f1476e14f946bcfb570fdfd52acee7dcb4678..c296d79b90aa1e53f48c5017279bc3a835d56a7f 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E = new Number(0) as number; } diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt index 56ae1cc18a71bfd94c9c18ee16eef70783e08e54..1a8d1d292a7dc96eaa622d319834f6ef94d394a6 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -277,7 +277,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -391,7 +391,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -577,7 +577,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-enum-string.ts index d9c8f8e0477c4cf4d408da1c680efe924ab3e872..320500abe99431974fd5f281561301106df16035 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E; } diff --git a/es2panda/test/parser/annotations/declaration-usage-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-number-expected.txt index 96d98fe81f94be154e8c20dbf3a477c614cd3ee6..e43e54db0e5ece96e115e1f39faf0f1da4c1d77b 100644 --- a/es2panda/test/parser/annotations/declaration-usage-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-number.ts b/es2panda/test/parser/annotations/declaration-usage-number.ts index 50b8417b90ae216b9d84b38d781c557cc6ed4631..8fc55a987b0bee2f512ce35370d78c922d2473f8 100644 --- a/es2panda/test/parser/annotations/declaration-usage-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } diff --git a/es2panda/test/parser/annotations/declaration-usage-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-string-expected.txt index b8bec61953d09780cbb5b262a14437bd759ab717..613d0f63c96a41ebce407f627551a2398b8c2c93 100644 --- a/es2panda/test/parser/annotations/declaration-usage-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-string.ts b/es2panda/test/parser/annotations/declaration-usage-string.ts index 0c627768fd650a5e4bac6cac31df0b4baaf5d8b6..5ad01ef4ed9394074ca233092f0bf41cc67628ab 100644 --- a/es2panda/test/parser/annotations/declaration-usage-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; } diff --git a/es2panda/test/parser/annotations/export-expected.txt b/es2panda/test/parser/annotations/export-expected.txt index 4ae0d3f25dcada0cfeed10792de8c8514bed0a64..ddccdb842b6c87f0b5c286dce968b610d22b49a4 100644 --- a/es2panda/test/parser/annotations/export-expected.txt +++ b/es2panda/test/parser/annotations/export-expected.txt @@ -16,7 +16,7 @@ }, "end": { "line": 16, - "column": 24 + "column": 46 } } }, @@ -97,7 +97,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -106,11 +106,11 @@ "loc": { "start": { "line": 16, - "column": 25 + "column": 47 }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -123,7 +123,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -136,7 +136,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -155,7 +155,7 @@ }, "end": { "line": 18, - "column": 24 + "column": 46 } } }, @@ -306,7 +306,7 @@ "loc": { "start": { "line": 18, - "column": 25 + "column": 47 }, "end": { "line": 20, @@ -435,7 +435,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 22, @@ -619,7 +619,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 25, diff --git a/es2panda/test/parser/annotations/export.ts b/es2panda/test/parser/annotations/export.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..6bea13acdc05d843f551afdf62e7a7d27cc561fd 100644 --- a/es2panda/test/parser/annotations/export.ts +++ b/es2panda/test/parser/annotations/export.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/parser/annotations/import-qualified-expected.txt b/es2panda/test/parser/annotations/import-qualified-expected.txt index 5f41d5ec6c794cd017804ed80bc6792cc55defa2..4706b8ceea2d07224e35c72f56928d9a05ceb025 100644 --- a/es2panda/test/parser/annotations/import-qualified-expected.txt +++ b/es2panda/test/parser/annotations/import-qualified-expected.txt @@ -152,7 +152,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 18, @@ -160,7 +160,7 @@ }, "end": { "line": 18, - "column": 34 + "column": 12 } } }, @@ -170,7 +170,7 @@ "loc": { "start": { "line": 18, - "column": 35 + "column": 13 }, "end": { "line": 18, @@ -348,7 +348,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 21, @@ -356,7 +356,7 @@ }, "end": { "line": 21, - "column": 34 + "column": 12 } } }, @@ -366,7 +366,7 @@ "loc": { "start": { "line": 21, - "column": 35 + "column": 13 }, "end": { "line": 21, @@ -533,7 +533,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 24, @@ -541,7 +541,7 @@ }, "end": { "line": 24, - "column": 34 + "column": 12 } } }, @@ -551,7 +551,7 @@ "loc": { "start": { "line": 24, - "column": 35 + "column": 13 }, "end": { "line": 24, @@ -841,7 +841,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 27, @@ -849,7 +849,7 @@ }, "end": { "line": 27, - "column": 34 + "column": 12 } } }, @@ -859,11 +859,11 @@ "loc": { "start": { "line": 27, - "column": 35 + "column": 13 }, "end": { "line": 27, - "column": 45 + "column": 23 } } }, @@ -876,7 +876,7 @@ }, "end": { "line": 27, - "column": 45 + "column": 23 } } }, @@ -886,11 +886,11 @@ "loc": { "start": { "line": 27, - "column": 46 + "column": 24 }, "end": { "line": 27, - "column": 56 + "column": 34 } } }, @@ -903,7 +903,7 @@ }, "end": { "line": 27, - "column": 56 + "column": 34 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 27, - "column": 57 + "column": 35 }, "end": { "line": 27, @@ -1095,7 +1095,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 30, @@ -1103,7 +1103,7 @@ }, "end": { "line": 30, - "column": 34 + "column": 12 } } }, @@ -1113,11 +1113,11 @@ "loc": { "start": { "line": 30, - "column": 35 + "column": 13 }, "end": { "line": 30, - "column": 45 + "column": 23 } } }, @@ -1130,7 +1130,7 @@ }, "end": { "line": 30, - "column": 45 + "column": 23 } } }, @@ -1140,11 +1140,11 @@ "loc": { "start": { "line": 30, - "column": 46 + "column": 24 }, "end": { "line": 30, - "column": 56 + "column": 34 } } }, @@ -1157,7 +1157,7 @@ }, "end": { "line": 30, - "column": 56 + "column": 34 } } }, @@ -1167,7 +1167,7 @@ "loc": { "start": { "line": 30, - "column": 57 + "column": 35 }, "end": { "line": 30, @@ -1338,7 +1338,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 33, @@ -1346,7 +1346,7 @@ }, "end": { "line": 33, - "column": 34 + "column": 12 } } }, @@ -1356,11 +1356,11 @@ "loc": { "start": { "line": 33, - "column": 35 + "column": 13 }, "end": { "line": 33, - "column": 45 + "column": 23 } } }, @@ -1373,7 +1373,7 @@ }, "end": { "line": 33, - "column": 45 + "column": 23 } } }, @@ -1383,11 +1383,11 @@ "loc": { "start": { "line": 33, - "column": 46 + "column": 24 }, "end": { "line": 33, - "column": 56 + "column": 34 } } }, @@ -1400,7 +1400,7 @@ }, "end": { "line": 33, - "column": 56 + "column": 34 } } }, @@ -1410,7 +1410,7 @@ "loc": { "start": { "line": 33, - "column": 57 + "column": 35 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/import-qualified.ts b/es2panda/test/parser/annotations/import-qualified.ts index 61a16cadc23bdf4093d5231431b3f39fe03730b5..742f0f07ae26c1d3623f306f2097e0fa626ef272 100644 --- a/es2panda/test/parser/annotations/import-qualified.ts +++ b/es2panda/test/parser/annotations/import-qualified.ts @@ -15,20 +15,20 @@ import * as Namespace1 from "./a" -@__$$ETS_ANNOTATION$$__Namespace1.Anno() +@Namespace1.__$$ETS_ANNOTATION$$__Anno() class A {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno +@Namespace1.__$$ETS_ANNOTATION$$__Anno class B {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno1({a: 1, b: "string"}) +@Namespace1.__$$ETS_ANNOTATION$$__Anno1({a: 1, b: "string"}) class C {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2() +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2() class D {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2 +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2 class E {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno3({a: 1, b: "string"}) +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno3({a: 1, b: "string"}) class F {} \ No newline at end of file diff --git a/es2panda/test/parser/annotations/import-unqualified-expected.txt b/es2panda/test/parser/annotations/import-unqualified-expected.txt index c4468f2f494453208f12eee7054f1022c0fb4b12..cf5699a10342fd0b4634b761277ab5dfc3e71c60 100644 --- a/es2panda/test/parser/annotations/import-unqualified-expected.txt +++ b/es2panda/test/parser/annotations/import-unqualified-expected.txt @@ -205,7 +205,7 @@ "type": "Annotation", "expression": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 18, @@ -361,7 +361,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 21, @@ -530,7 +530,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 24, @@ -714,7 +714,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/multiple-annotations-expected.txt b/es2panda/test/parser/annotations/multiple-annotations-expected.txt index 2111cf0e0b4d168abfc132426ef9d37bb30f8176..135d60a478b86545dfa4aa64354bedc0c1a64599 100644 --- a/es2panda/test/parser/annotations/multiple-annotations-expected.txt +++ b/es2panda/test/parser/annotations/multiple-annotations-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -165,7 +165,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -199,7 +199,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -350,7 +350,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -384,7 +384,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -577,7 +577,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, @@ -691,7 +691,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 28, @@ -796,7 +796,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 29, @@ -901,7 +901,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno3", + "name": "Anno3", "loc": { "start": { "line": 30, @@ -1116,7 +1116,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 32, @@ -1221,7 +1221,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 33, @@ -1326,7 +1326,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno3", + "name": "Anno3", "loc": { "start": { "line": 34, diff --git a/es2panda/test/parser/annotations/multiple-annotations.ts b/es2panda/test/parser/annotations/multiple-annotations.ts index cf0af17c46b720c83ce8e40a6a328b68010b19f7..246af473b26a6a8d76defe52e36865f928a33bc7 100644 --- a/es2panda/test/parser/annotations/multiple-annotations.ts +++ b/es2panda/test/parser/annotations/multiple-annotations.ts @@ -13,15 +13,15 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number = 1; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { b: string = "string" } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { c: boolean[] = [true, false]; } diff --git a/es2panda/test/parser/js/language/import/lazy-import-expected.txt b/es2panda/test/parser/js/language/import/lazy-import-expected.txt index 4954838d6cc001d0aa8dde53ce5f6871eb745642..d8b751d51e8d777383cd772579e8700ea5059229 100644 --- a/es2panda/test/parser/js/language/import/lazy-import-expected.txt +++ b/es2panda/test/parser/js/language/import/lazy-import-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x6 -expectedProperty = 0x3 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt index a5a0f51d284f302b4377ff68cac0556af37b7922..592aff13d028666c9cbf346dcff965e03217645d 100644 --- a/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt @@ -1,2 +1,2 @@ -SyntaxError: Current configuration does not support using lazy import default.Lazy import can be used in the version of API 18 or higher versions. -Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 18.> If you're running es2abc in commandline without IDE, please check whether target-api-version options are correctly configured. [import-lazy-beta2-2.js:16:13] +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [import-lazy-beta2-2.js:16:13] diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt index aeccb2f589e10fd2675de4604f824907e5fb8b80..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt @@ -1,2 +0,0 @@ -SyntaxError: Current configuration does not support using lazy import default.Lazy import can be used in the version of API 18 or higher versions. -Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 18.> If you're running es2abc in commandline without IDE, please check whether target-api-version options are correctly configured. [import-lazy-2.js:16:13] diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt rename to es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1-expected.txt diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js new file mode 100644 index 0000000000000000000000000000000000000000..1be01909715173e3ac0e62f32098f04778e4eb92 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 lazy a from './a' \ No newline at end of file diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d9309c18906f21418839b077c5dba619fb60d059 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Unexpected token. [import-lazy-defalut-2.js:16:13] diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js new file mode 100644 index 0000000000000000000000000000000000000000..9311c81e83a1cb29495c319b4db09175470452e6 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 lazy type {a} from './a' \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-func-param10-expected.txt b/es2panda/test/parser/ts/test-func-param10-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2f0ae83bd703e6bbcaf119efaefcc567093b9794 --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param10-expected.txt @@ -0,0 +1,712 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + }, + "init": { + "type": "StringLiteral", + "value": "111", + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 14 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + }, + "init": { + "type": "StringLiteral", + "value": "222", + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 14 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + "init": { + "type": "BooleanLiteral", + "value": true, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 13 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 15 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "print", + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "333", + "loc": { + "start": { + "line": 21, + "column": 11 + }, + "end": { + "line": 21, + "column": 16 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 17 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 18 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test2", + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 15 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "aa", + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 18 + } + } + }, + "right": { + "type": "ConditionalExpression", + "test": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 31 + } + } + }, + "consequent": { + "type": "SequenceExpression", + "expressions": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 23, + "column": 35 + }, + "end": { + "line": 23, + "column": 40 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 35 + }, + "end": { + "line": 23, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 23, + "column": 43 + }, + "end": { + "line": 23, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 34 + }, + "end": { + "line": 23, + "column": 45 + } + } + }, + "alternate": { + "type": "SequenceExpression", + "expressions": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 23, + "column": 49 + }, + "end": { + "line": 23, + "column": 54 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 49 + }, + "end": { + "line": 23, + "column": 56 + } + } + }, + { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 23, + "column": 57 + }, + "end": { + "line": 23, + "column": 58 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 48 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "dd", + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 23, + "column": 64 + }, + "end": { + "line": 23, + "column": 70 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 61 + }, + "end": { + "line": 23, + "column": 63 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 23, + "column": 73 + }, + "end": { + "line": 23, + "column": 74 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 61 + }, + "end": { + "line": 23, + "column": 74 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "print", + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "aa", + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 24, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "dd", + "loc": { + "start": { + "line": 24, + "column": 15 + }, + "end": { + "line": 24, + "column": 17 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 76 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test2", + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 6 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 8 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 28, + "column": 1 + } + } +} diff --git a/es2panda/test/parser/ts/test-func-param10.ts b/es2panda/test/parser/ts/test-func-param10.ts new file mode 100644 index 0000000000000000000000000000000000000000..717ae2477f4c7617015a2459b60ef6c117980a29 --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param10.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + + +let a = "111"; +let b = "222"; +let c = true; +function test1() { + print("333") +} +function test2(aa : string = c ? (test1(),a) : (test1(),b), dd:number = 1) { + print(aa, dd); +} + +test2() diff --git a/es2panda/test/parser/ts/test-func-param11-expected.txt b/es2panda/test/parser/ts/test-func-param11-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..610308b8d9c8eb343a7d0be82a445b6439de739f --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param11-expected.txt @@ -0,0 +1,360 @@ +{ + "type": "Program", + "statements": [ + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "bar", + "loc": { + "start": { + "line": 17, + "column": 10 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "fn", + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 16 + } + } + }, + "right": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "Identifier", + "name": "b", + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 30 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 17, + "column": 34 + }, + "end": { + "line": 17, + "column": 35 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 38 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 34 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 41 + }, + "end": { + "line": 17, + "column": 42 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "log", + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "fn", + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 5, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 21 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 18, + "column": 24 + }, + "end": { + "line": 18, + "column": 25 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 52 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 20, + "column": 1 + } + } +} diff --git a/es2panda/test/parser/ts/test-func-param11.ts b/es2panda/test/parser/ts/test-func-param11.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e36915b21b10ec5973b188cd6103ddc1c01776b --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param11.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + + +function bar(fn = (b: number) => b + 1, a: string) { + console.log(fn(5), a); +} diff --git a/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt b/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..970e539cfff96898fc2bc0796450c18f039c6b88 --- /dev/null +++ b/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt @@ -0,0 +1,101 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": true, + "readonly": false, + "key": { + "type": "Identifier", + "name": "readonly", + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 20 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "test", + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } +} diff --git a/es2panda/test/parser/ts/test-readonly-optional-property.ts b/es2panda/test/parser/ts/test-readonly-optional-property.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f9df72f3a191ca5a7042f06a6057be18afcec25 --- /dev/null +++ b/es2panda/test/parser/ts/test-readonly-optional-property.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + + +interface test { + readonly?: number; +} \ No newline at end of file diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt index 5b64b2d04215f2c8526ec7f4203e13c5461bbff0..58587ab7649cee422721d48330ede07ad7aa24ba 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt @@ -63,12 +63,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, @@ -77,12 +77,12 @@ "name": "###A#auto_accessor_storage#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, @@ -90,12 +90,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt index dc2bdf78115563ca156789f0d64e58c7fee074f2..027f8933cd3e1a0a4975e073ea5d5c7a6f326bc3 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt @@ -164,12 +164,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, @@ -178,12 +178,12 @@ "name": "###Test#auto_accessor_storage#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, @@ -191,12 +191,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt index 822c6e99a9d91dd8b889bb7eec6b867df5455e1a..46330a78dbf8bae09a48b513da8c3d9809696663 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt @@ -76,12 +76,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, @@ -90,12 +90,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, @@ -103,12 +103,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt index 40bb140f3b04ebc6fa0da5af9b1fabc1b5b22e18..b22c158c2321839ba2f7e4d9e4f632f936467935 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt @@ -103,12 +103,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, @@ -117,12 +117,12 @@ "name": "prop", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, @@ -130,12 +130,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt index 7936bfad6d5464516dfeb051a95a18c8c357bc98..57e42ec3ecf1c3acf02fa64cd6498ec09886122e 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt @@ -268,12 +268,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, @@ -282,12 +282,12 @@ "name": "prop", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, @@ -295,12 +295,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt index 1548646ed413e2fb18d0340788a9f54437f053eb..3e56df7b4fc87decfd290201e0acaa9212495399 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt @@ -424,12 +424,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -438,12 +438,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -451,12 +451,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt index edaef8740c93924aa349706fc2aa271d7de93057..3c0ec91edb6cb0555d1e5b15326e10166eb530ee 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt @@ -890,12 +890,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 13 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt index 1dad3f2b1e6aa872b39fafea6b97529ab9f48aeb..8a02b47f7b312fd0565b3c89bd30d2c825e38bcf 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt @@ -424,12 +424,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -438,12 +438,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -451,12 +451,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -507,12 +507,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, @@ -521,12 +521,12 @@ "name": "###B#prop2#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, @@ -534,12 +534,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt index 4632b52a56404a3d35b63dbbc64130e36e3a1109..f826e0a0dc18e04cf20bb920d1750aaac09da22a 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt @@ -948,12 +948,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 13 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt index e4097e957069196bc9a42731f659f012f900637c..b4d0eec5fba219ed4a9edab52d64ed4764ee0434 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt @@ -303,12 +303,12 @@ "name": "p", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 26 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 27 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt index 226a8ad0d5f7f246e35cf45f518187618834fadc..173727186b5a3159e87a9afb7ce821d5943b9841 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt @@ -199,12 +199,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 17, + "column": 30 }, "end": { - "line": 1, - "column": 1 + "line": 17, + "column": 31 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt index b56614dff42a1bbe4a27afebb3004460da3f147d..8294b94320c35144bdd46fe78af6f2f72edb4bb5 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt @@ -214,12 +214,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 17, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 17, + "column": 25 } } }, diff --git a/es2panda/test/runner.py b/es2panda/test/runner.py index f378d108c383ef54f2a3cf610c6d82b24009c76a..9b625b98c185d5cb8247db3621fa5efa990c18bf 100755 --- a/es2panda/test/runner.py +++ b/es2panda/test/runner.py @@ -25,7 +25,7 @@ import re import shutil import subprocess import sys -from config import API_VERSION_MAP, MIN_SUPPORT_BC_VERSION, MIX_COMPILE_ENTRY_POINT +from config import API_VERSION_MAP, ARK_JS_VM_LIST, MIN_SUPPORT_BC_VERSION, MIX_COMPILE_ENTRY_POINT, ES2ABC_API_SUPPORT def is_directory(parser, arg): @@ -974,7 +974,6 @@ class CompilerProjectTest(Test): mod_files_info.append(abc_line) final_file_info_f.writelines(abc_line) - def gen_files_info(self, runner): # After collect_record_mapping, self.file_record_mapping stores {'source file name' : 'source file record name'} self.collect_record_mapping() @@ -1412,7 +1411,9 @@ class BcVersionTest(Test): 15: "12.0.6.0", 16: "12.0.6.0", 17: "12.0.6.0", - 18: "13.0.1.0" + 18: "13.0.1.0", + 19: "13.0.1.0", + 20: "13.0.1.0", } self.es2abc_script_expect = { 8: "0.0.0.2", @@ -1428,7 +1429,9 @@ class BcVersionTest(Test): 15: "12.0.6.0", 16: "12.0.6.0", 17: "12.0.6.0", - 18: "13.0.1.0" + 18: "13.0.1.0", + 19: "13.0.1.0", + 20: "13.0.1.0", } def run(self): @@ -1884,6 +1887,40 @@ class ArkJsVmDownload: # Obtain different versions of ark_js_vm and their depen self.git_clone(self.url, self.local_path) print("\ndownload finish.\n") +class CodeDownloader: + def __init__(self, args, url, components_name, max_retries=3): + self.build_dir = args.build_dir + self.url = url + self.local_path = path.join(self.build_dir, components_name) + self.max_retries = max_retries + + def run_cmd_cwd(self, cmd): + try: + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + _, _ = proc.communicate() + return proc.wait() + except Exception as e: + print(f"Error executing command: {e}") + return -1 + + def git_clone(self, git_url, code_dir): + cmd = ["git", "clone", git_url, code_dir, "--depth=1"] + retries = 1 + while retries <= self.max_retries: + ret = self.run_cmd_cwd(cmd) + if ret == 0: + break + else: + print(f"\nWarning: Attempt #{retries} to clone '{git_url}' failed. Retrying...") + retries += 1 + assert ret == 0, f"\nError: Cloning '{git_url}' failed." + + def run(self): + if not os.path.exists(self.local_path): + print(f"\nStart downloading {self.url}...\n") + self.git_clone(self.url, self.local_path) + print("\nDownload finished.\n") + print(self.local_path) class AbcTestCasesPrepare: def __init__(self, args): @@ -1907,34 +1944,42 @@ class AbcTestCasesPrepare: files = fnmatch.filter(files, self.test_root + "**" + self.args.filter) return files - def gen_abc_versions(self, flags, source_path): - for api_version in API_VERSION_MAP: + def get_output_path(self, source_path, main_version, beta_version, es2abc_version): + base = path.splitext(source_path)[0] + suffix = f"version_API{main_version}{beta_version}" + return f"{base}_{es2abc_version}_{suffix}.abc" if es2abc_version != "default" else f"{base}_{suffix}.abc" + + def gen_abc_versions(self, flags, source_path, es2abc_version): + supported_apis = ES2ABC_API_SUPPORT.get(es2abc_version) + for api_version in supported_apis: main_version, beta_version = AbcTestCasesPrepare.split_api_version(api_version) - output_path = "%s_version_API%s%s.abc" % ( - path.splitext(source_path)[0], - main_version, - beta_version, - ) + output_path = self.get_output_path(source_path, main_version, beta_version, es2abc_version) self.test_abc_path_list.add(output_path) - _, stderr = self.compile_for_target_version(flags, source_path, output_path, main_version, beta_version) + _, stderr = self.compile_for_target_version(flags, source_path, output_path, main_version, beta_version, es2abc_version) if stderr: - raise RuntimeError(f"abc generate error: " % (stderr.decode("utf-8", errors="ignore"))) + raise RuntimeError(f"abc generate error: {stderr}") - def gen_abc_tests(self, directory, extension, flags, abc_mode): + def gen_abc_tests(self, directory, extension, flags, abc_mode, es2abc_versions=["default"]): if abc_mode not in self.valid_mode_list: raise ValueError(f"Invalid abc_mode value: {abc_mode}") test_source_list = self.add_abc_directory(directory, extension) - for input_path in test_source_list: - self.gen_abc_versions(flags, input_path) - def compile_for_target_version(self, flags, input_path, output_path, target_api_version, target_api_sub_version=""): + for es2abc_version in es2abc_versions: + for input_path in test_source_list: + self.gen_abc_versions(flags, input_path, es2abc_version) + + def compile_for_target_version(self, flags, input_path, output_path, target_api_version, target_api_sub_version="", es2abc_version="default"): + es2panda_path = ( + self.es2panda if es2abc_version == "default" + else os.path.join(self.args.build_dir, "es2abc_version", es2abc_version, "es2abc") + ) cmd = [] - cmd.append(self.es2panda) + cmd.append(es2panda_path) cmd.append(input_path) cmd.extend(flags) cmd.append("--target-api-version=%s" % (target_api_version)) cmd.extend(["--output=%s" % (output_path)]) - if target_api_version != "": + if target_api_sub_version != "": cmd.append("--target-api-sub-version=%s" % (target_api_sub_version)) process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate(timeout=10) @@ -1969,7 +2014,6 @@ class AbcVersionControlRunner(Runner): def run(self): for test in self.tests: test.run(self) - self.args.abc_tests_prepare.remove_abc_tests() class VersionControlRunner(Runner): @@ -2046,6 +2090,7 @@ class TestAbcVersionControl(Test): if self.abc_mode == "mix_compile_mode" and test_stage != "runtime": support_name = "" expected_name = path.splitext(self.path)[0].split("_version_API")[0] + expected_name = re.sub(r"_(\d+\.\d+)(?=(_|$))", "", expected_name) expected_path = "%s_%s%s-expected.txt" % (expected_name, support_name, test_stage) return expected_path @@ -2068,51 +2113,74 @@ class TestAbcVersionControl(Test): cmd.extend(self.flags) cmd.append("--target-api-version=%s" % (target_api_version)) cmd.extend(["--output=%s" % (output_path)]) - if target_api_version != "": + if target_api_sub_version != "": cmd.append("--target-api-sub-version=%s" % (target_api_sub_version)) + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr - def generate_abc(self, runner, target_api_version, target_api_sub_version=""): - compile_expected_path = None - target_abc_name = ( - "%s_target_%s%s.abc" % (path.splitext(self.path)[0], target_api_version, target_api_sub_version) - ).replace("/", "_") - self.target_abc_path = path.join(runner.build_dir, target_abc_name) - _, stderr = self.compile_for_target_version( - runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version - ) - format_content = "" - self.is_support = False + def build_abc_filename(self, target_api_version, target_api_sub_version): + prefix = f"{path.splitext(self.path)[0]}" + abc_name = f"{prefix}_target_{target_api_version}{target_api_sub_version}.abc" + return abc_name.replace("/", "_") - # Extract the API versions of the input abc files from the file name of the test case. + def extract_input_versions(self): input_api_versions = self.extract_api_versions(path.split(self.path)[1]) input_version_numbers = [API_VERSION_MAP.get(api) for api in input_api_versions] - sorted(input_version_numbers, key=TestAbcVersionControl.version_number_to_tuple) - min_input_version_number = input_version_numbers[0] - max_input_version_number = input_version_numbers[-1] + return sorted(input_version_numbers, key=TestAbcVersionControl.version_number_to_tuple) + + def determine_expected_behavior(self, target_api_version, target_api_sub_version, input_version_numbers): target_version = "API" + target_api_version + target_api_sub_version target_version_number = API_VERSION_MAP.get(target_version) + min_input_version_number = input_version_numbers[0] + max_input_version_number = input_version_numbers[-1] + if TestAbcVersionControl.compare_version_number(target_version_number, self.min_support_version_number) < 0: compile_expected_path = self.get_path_to_expected( - self.is_support, "compile_target_version_below_min_support" + False, "compile_target_version_below_min_support" ) - format_content = target_api_version + return False, compile_expected_path, target_api_version + elif ( TestAbcVersionControl.compare_version_number(min_input_version_number, self.min_support_version_number) < 0 ): - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_cur_version_below_min_support") - format_content = self.path + compile_expected_path = self.get_path_to_expected(False, "compile_cur_version_below_min_support") + return False, compile_expected_path, self.path + elif TestAbcVersionControl.compare_version_number(target_version_number, max_input_version_number) < 0: - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_target_version_below_cur") - format_content = self.path + compile_expected_path = self.get_path_to_expected(False, "compile_target_version_below_cur") + return False, compile_expected_path, self.path + elif self.is_discard: - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_discard") - else: - self.is_support = True + compile_expected_path = self.get_path_to_expected(False, "compile_discard") + return False, compile_expected_path, "" + + return True, None, None + + def generate_abc(self, runner, target_api_version, target_api_sub_version=""): + compile_expected_path = None + target_abc_name = self.build_abc_filename(target_api_version, target_api_sub_version) + self.target_abc_path = path.join(runner.build_dir, target_abc_name) + + _, stderr = self.compile_for_target_version( + runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version + ) + format_content = "" + self.is_support = False + + # Extract the API versions of the input abc files from the file name of the test case. + input_version_numbers = self.extract_input_versions() + + is_support, compile_expected_path, format_content = self.determine_expected_behavior( + target_api_version, target_api_sub_version, input_version_numbers + ) + self.is_support = is_support + if self.is_support: if stderr: self.passed = False + else: + self.passed = True return stderr try: @@ -2123,18 +2191,12 @@ class TestAbcVersionControl(Test): self.passed = False return stderr - def execute_abc(self, runner, vm_api_version, vm_api_sub_version="", entry_point=""): + def execute_abc(self, runner, vm_version, entry_point=""): cmd = [] - if vm_api_version != "12": - vm_api_sub_version = "" - # there is no virtual machine with version api12beta2 available. - # chosen api12beta1 as a replacement. - elif vm_api_version == "12" and vm_api_sub_version == "beta2": - vm_api_sub_version = "beta1" ark_js_vm_dir = os.path.join( runner.build_dir, "ark_js_vm_version", - "API%s%s" % (vm_api_version, vm_api_sub_version), + vm_version, ) ld_library_path = os.path.join(ark_js_vm_dir, "lib") os.environ["LD_LIBRARY_PATH"] = ld_library_path @@ -2143,6 +2205,7 @@ class TestAbcVersionControl(Test): if entry_point != "": cmd.append("--entry-point=%s" % entry_point) cmd.append(self.target_abc_path) + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr @@ -2150,11 +2213,9 @@ class TestAbcVersionControl(Test): stderr = None target_version = "API" + target_api_version + target_api_sub_version target_version_number = API_VERSION_MAP.get(target_version) - for api_version in API_VERSION_MAP: - vm_api_version, vm_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) - vm_version = "API" + vm_api_version + vm_api_sub_version + for vm_version in ARK_JS_VM_LIST: vm_version_number = API_VERSION_MAP.get(vm_version) - _, stderr = self.execute_abc(runner, vm_api_version, vm_api_sub_version, self.entry_point) + _, stderr = self.execute_abc(runner, vm_version, self.entry_point) self.is_support = ( TestAbcVersionControl.compare_version_number(vm_version_number, target_version_number) >= 0 ) @@ -2188,26 +2249,141 @@ class TestAbcVersionControl(Test): target_api_version, target_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) stderr = self.generate_abc(runner, target_api_version, target_api_sub_version) if not self.passed: - self.error = stderr.decode("utf-8", errors="ignore") + self.error = stderr return self if stderr: continue stderr = self.test_abc_execution(runner, target_api_version, target_api_sub_version) self.remove_abc(self.target_abc_path) if not self.passed: - self.error = stderr.decode("utf-8", errors="ignore") + self.error = stderr return self return self +class Es2abcVersionControlRunner(Runner): + def __init__(self, args): + super().__init__(args, "Es2abcVersionControl") + self.valid_mode_list = ["non_merge_mode", "merge_mode"] + + def add_directory(self, directory, extension, flags, abc_mode, is_discard=False): + if abc_mode not in self.valid_mode_list: + raise ValueError(f"Invalid abc_mode value: {abc_mode}") + glob_expression = path.join(self.test_root, directory, "*.%s" % (extension)) + files = glob(glob_expression) + files = fnmatch.filter(files, self.test_root + "**" + self.args.filter) + self.tests += list(map(lambda f: TestEs2abcVersionControl(f, flags, abc_mode, is_discard), files)) + + def test_path(self, src): + return src + + def run(self): + for test in self.tests: + test.run(self) + self.args.abc_tests_prepare.remove_abc_tests() + +class TestEs2abcVersionControl(TestAbcVersionControl): + def __init__(self, test_path, flags, abc_mode, is_discard, es2abc_versions=None): + super().__init__(test_path, flags, abc_mode, is_discard) + self.es2abc_versions = es2abc_versions or list(ES2ABC_API_SUPPORT.keys()) + + @staticmethod + def version_str_to_tuple(version: str): + if isinstance(version, list): + version = ".".join(version) + return tuple(int(x) for x in version.split(".")) + + @classmethod + def get_max_supported_version(cls, es2abc_version: str) -> str: + supported_apis = ES2ABC_API_SUPPORT.get(es2abc_version, ES2ABC_API_SUPPORT["default"]) + max_api = max(supported_apis, key=lambda api: cls.version_str_to_tuple(API_VERSION_MAP[api])) + return API_VERSION_MAP[max_api] + + @classmethod + def should_skip_abc_file(cls, file_version: str, es2abc_version: str) -> bool: + max_supported_version = cls.get_max_supported_version(es2abc_version) + return cls.version_str_to_tuple(file_version) > cls.version_str_to_tuple(max_supported_version) + + def build_abc_filename(self, target_api_version, target_api_sub_version, es2abc_version): + prefix = f"{path.splitext(self.path)[0]}" + if es2abc_version == "default" or es2abc_version is None: + abc_name = f"{prefix}_target_{target_api_version}{target_api_sub_version}.abc" + else: + abc_name = f"{prefix}_{es2abc_version}_target_{target_api_version}{target_api_sub_version}.abc" + return abc_name.replace("/", "_") + + def compile_for_target_version( + self, runner, input_path, output_path, target_api_version, target_api_sub_version="", es2abc_version="default" + ): + cmd = [] + if es2abc_version != "default": + runner.es2panda = os.path.join(runner.build_dir, "es2abc_version", es2abc_version, "es2abc") + cmd.append(runner.es2panda) + cmd.append(input_path) + cmd.extend(self.flags) + cmd.append("--target-api-version=%s" % target_api_version) + cmd.extend(["--output=%s" % output_path]) + if target_api_sub_version: + cmd.append("--target-api-sub-version=%s" % target_api_sub_version) + self.es2abc_cmd = ' '.join(cmd) + stdout, stderr = self.run_process(cmd) + return stdout, stderr + + def generate_abc(self, runner, target_api_version, target_api_sub_version=""): + compile_expected_path = None + input_version_numbers = self.extract_input_versions() + + for es2abc_version in self.es2abc_versions: + target_abc_name = self.build_abc_filename(target_api_version, target_api_sub_version, es2abc_version) + self.target_abc_path = path.join(runner.build_dir, target_abc_name) + + _, stderr = self.compile_for_target_version( + runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version, es2abc_version + ) + + format_content = "" + self.is_support = False + + # The version of the abc file exceeds the maximum supported range of es2abc + if self.should_skip_abc_file(input_version_numbers, es2abc_version): + continue + + is_support, compile_expected_path, format_content = self.determine_expected_behavior( + target_api_version, target_api_sub_version, input_version_numbers + ) + self.is_support = is_support + if self.is_support: + if stderr: + self.passed = False + else: + self.passed = True + return stderr + + try: + with open(compile_expected_path, "r") as fp: + expected = fp.read() + self.passed = expected.format(format_content) in self.output and self.process.returncode in [0, 1] + except Exception: + self.passed = False + return stderr + return None + + def run(self, runner): + for api_version in API_VERSION_MAP: + target_api_version, target_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) + stderr = self.generate_abc(runner, target_api_version, target_api_sub_version) + if not self.passed: + self.error = stderr + return self + return self class TestVersionControl(Test): def __init__(self, test_path, flags, test_version, feature_type, module_path_list): Test.__init__(self, test_path, flags) self.beta_version_default = 3 - self.version_with_sub_version_list = [12] - self.target_api_version_list = ["9", "10", "11", "12", "18"] + self.version_with_sub_version_list = ["12"] + self.target_api_version_list = ["9", "10", "11", "12", "18", "20"] self.target_api_sub_version_list = ["beta1", "beta2", "beta3"] - self.specific_api_version_list = ["API11", "API12beta3"] + self.specific_api_version_list = ["API18", "API12beta3", "API11"] self.output = None self.process = None self.test_version = test_version @@ -2344,7 +2520,7 @@ class TestVersionControl(Test): def run_process(self, cmd): self.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = self.process.communicate() - self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore").split("\n")[0] + self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore") return stdout, stderr def run_process_compile(self, runner, target_api_version, target_api_sub_version="bata3", dump_type=""): @@ -2362,6 +2538,7 @@ class TestVersionControl(Test): cmd.append("--dump-ast") elif dump_type == "assembly": cmd.append("--dump-assembly") + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr @@ -2389,12 +2566,13 @@ class TestVersionControl(Test): ark_js_vm_path = os.path.join(ark_js_vm_dir, "ark_js_vm") cmd.append(ark_js_vm_path) cmd.append(self.test_abc_path) + self.log_cmd(cmd) self.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = self.process.communicate() self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore").split("\n")[0] return stdout, stderr - def run_for_single_version(self, runner, target_api_version, target_api_sub_version="beta3"): + def run_for_single_version(self, runner, target_api_version, target_api_sub_version=""): cur_api_version = "API" + target_api_version + target_api_sub_version is_support = True if self.compare_two_versions(cur_api_version, self.test_version) >= 0 else False compile_expected_path = None @@ -2415,6 +2593,7 @@ class TestVersionControl(Test): self.passed = False if not self.passed or (stderr and self.passed): return stderr + cur_api_version_number = API_VERSION_MAP.get(cur_api_version) for api_version in self.target_api_version_list: # The interception capability of API9 version of ark_js_vm has not yet been launched. if api_version == "9": @@ -2422,9 +2601,18 @@ class TestVersionControl(Test): for api_sub_version in self.target_api_sub_version_list: if not api_version in self.version_with_sub_version_list and api_sub_version != "beta3": continue + elif not api_version in self.version_with_sub_version_list: + api_sub_version = "" cur_runtime_api_version = "API" + api_version + api_sub_version + cur_runtime_api_version_number = API_VERSION_MAP.get(cur_runtime_api_version) is_below_abc_version = ( - False if self.compare_two_versions(cur_runtime_api_version, cur_api_version) >= 0 else True + False + if TestAbcVersionControl.compare_version_number( + cur_runtime_api_version_number, + cur_api_version_number, + ) + >= 0 + else True ) self.generate_module_abc(runner, cur_runtime_api_version) _, stderr = self.runtime_for_target_version(runner, api_version, api_sub_version) @@ -2498,8 +2686,21 @@ def prepare_for_obfuscation(compiler_test_infos, test_root): def add_directory_for_version_control(runners, args): - ark_js_vm_prepared = ArkJsVmDownload(args) - ark_js_vm_prepared.run() + tools = [ + { + "url": "https://gitee.com/zhongmingwei123123/ark_js_vm_version.git", + "components_name": "ark_js_vm_version" + }, + { + "url": "https://gitee.com/li_yue1999/es2abc_version.git", + "components_name": "es2abc_version" + } + ] + + for tool in tools: + downloader = CodeDownloader(args, tool['url'], tool['components_name']) + downloader.run() + runner = VersionControlRunner(args) runner.add_directory( "version_control/API11/syntax_feature", @@ -2591,33 +2792,44 @@ def add_directory_for_version_control(runners, args): "version_control/API12beta3/bytecode_feature/import_target", ) runner.add_directory( - "version_control/API16/bytecode_feature", + "version_control/API18/bytecode_feature", "js", [], - "API16", + "API18", "bytecode_feature", ) runner.add_directory( - "version_control/API16/bytecode_feature", + "version_control/API18/bytecode_feature", "ts", ["--module"], - "API16", + "API18", + "bytecode_feature", + ) + runner.add_directory( + "version_control/API20/bytecode_feature", + "ts", + ["--module", "--enable-annotations"], + "API20", "bytecode_feature", ) runners.append(runner) abc_tests_prepare = AbcTestCasesPrepare(args) + es2abc_versions = list(ES2ABC_API_SUPPORT.keys()) + abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/non_merge_mode", "js", ["--module"], "non_merge_mode", + es2abc_versions ) abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/merge_mode", "js", ["--module", "--merge-abc"], "merge_mode", + es2abc_versions ) abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/mixed_compile", @@ -2648,6 +2860,21 @@ def add_directory_for_version_control(runners, args): ) runners.append(abc_version_control_runner) + es2abc_version_control_runner = Es2abcVersionControlRunner(args) + es2abc_version_control_runner.add_directory( + "version_control/bytecode_version_control/non_merge_mode", + "abc", + ["--module", "--enable-abc-input"], + "non_merge_mode", + ) + es2abc_version_control_runner.add_directory( + "version_control/bytecode_version_control/merge_mode", + "abc", + ["--module", "--enable-abc-input", "--merge-abc"], + "merge_mode", + ) + runners.append(es2abc_version_control_runner) + def add_directory_for_regression(runners, args): runner = RegressionRunner(args) runner.add_directory("parser/concurrent", "js", ["--module", "--dump-ast"]) @@ -2676,7 +2903,8 @@ def add_directory_for_regression(runners, args): runner.add_directory("parser/js/language/import/syntax/api12/beta2", "js", ["--parse-only", "--module", "--target-api-version=12", "--target-api-sub-version=beta2"]) runner.add_directory("parser/js/language/import", "ts", - ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-version=18"]) + ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-version=12", + "--target-api-sub-version=beta3"]) runner.add_directory("parser/sendable_class", "ts", ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-sub-version=beta3"]) runner.add_directory("parser/sendable_class/api12beta2", "ts", @@ -2771,7 +2999,7 @@ def add_directory_for_compiler(runners, args): "--file-threads=8"])) compiler_test_infos.append(CompilerTestInfo("compiler/bytecodehar/projects", "ts", ["--merge-abc", "--dump-assembly", "--enable-abc-input", - "--dump-deps-info", "--remove-redundant-file", + "--dump-deps-info", "--remove-redundant-file", "--enable-annotations", "--dump-literal-buffer", "--dump-string", "--abc-class-threads=4"])) compiler_test_infos.append(CompilerTestInfo("compiler/bytecodehar/js/projects", "js", ["--merge-abc", "--dump-assembly", "--enable-abc-input", @@ -2782,7 +3010,7 @@ def add_directory_for_compiler(runners, args): "--abc-class-threads=4"])) compiler_test_infos.append(CompilerTestInfo("compiler/cache_projects", "ts", ["--merge-abc", "--dump-assembly", "--enable-abc-input", - "--dump-deps-info", "--remove-redundant-file", + "--dump-deps-info", "--remove-redundant-file", "--enable-annotations", "--dump-literal-buffer", "--dump-string", "--abc-class-threads=4", "--cache-file"])) diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 2657d967535b7d42723020d9ae130271fc7ca863..eae6c92044b0cfbcaf5744908d034235569763d1 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 13a61838909bb08d516049d0f3647ecd0d410330..918314e6e16548c4a76b4f01f92d40354167def8 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..13a61838909bb08d516049d0f3647ecd0d410330 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,73 @@ +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + callruntime.callinit 0x0, a2 + lda a3 + stobjbyname 0x2, a, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + lda.str a + definepropertybyname 0x0, a, a2 + returnundefined +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x0 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda.str b + sta v0 + mov v2, v1 + mov v3, v0 + newobjrange 0x4, 0x2, v2 + sta v0 + tryldglobalbyname 0x6, print + sta v1 + lda v0 + ldobjbyname 0x7, a + sta v0 + lda v1 + callarg1 0x9, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt index 477926b113c103bf6b1af54dac9b78cae8e9fbad..f8ea73ca5f3bc2b65c6462279538148ed44ae72d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index d5dbb31f3fa9b36d9ef5a5337c872e59d5cdba6d..b7e43e9e1fb3742bb4f8a4bf6d06dbd0363112dd 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index a4e2f5e25d68ac12686740a4b01fa1f00ae5bef0..d568dbc64c403cdaa4f769ffeee74f889a849be6 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 90da189592f8d76f107b81ff6da4fef6d3d8229f..2d887353700d529600f18099893bcf0c89261257 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x4 -expectedProperty = 0x1 .function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: label_0: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a4e2f5e25d68ac12686740a4b01fa1f00ae5bef0 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,103 @@ +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a3 + stprivateproperty 0x2, 0x0, 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#getPrivateField(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + ldprivateproperty 0x0, 0x0, 0x0 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldundefined + callruntime.defineprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#setPrivateField(any a0, any a1, any a2, any a3) { +label_1: +label_0: + lda a3 + stprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0x11 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~@0=#TestPrivateProperty, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~@0>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 + callruntime.createprivateproperty 0x1, _3 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + ldai 0xa + sta v0 + mov v3, v1 + mov v4, v0 + newobjrange 0x4, 0x2, v3 + sta v0 + ldobjbyname 0x6, setPrivateField + sta v1 + ldai 0x14 + sta v2 + lda v1 + callthis1 0x8, v0, v2 + tryldglobalbyname 0xa, print + sta v1 + lda v0 + ldobjbyname 0xb, getPrivateField + callthis0 0xd, v0 + sta v0 + lda v1 + callarg1 0xf, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt index f7d4404293294735de27c59e31d20633d84080be..382ae3503f71696fcf11789af52716b4c7944d29 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_property.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_property.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 63208d0f05f24cd30343f28341311e74ff69f5e9..0f3aceeaadb575a70660d8adcccc371c0875166e 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index e7087b0c6e227f487f71723bf8c89bd06d7fd6a6..2c0f076a938f21a23c07a55def36c83766324f0f 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7087b0c6e227f487f71723bf8c89bd06d7fd6a6 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,88 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + sta v0 + ldlexvar 0x1, 0x0 + sta v1 + throw.undefinedifholewithname a + lda v1 + callruntime.definefieldbyvalue 0x0, v0, a2 + returnundefined +label_2: +} + +slotNum = 0xc +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 + lda.str a + sta v0 + lda.str b + add2 0x0, v0 + stlexvar 0x0, 0x0 + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + ldlexvar 0x1, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + callruntime.topropertykey + stlexvar 0x0, 0x0 + defineclasswithbuffer 0x1, .#~A=#A, _2, 0x0, v1 + sta v1 + ldobjbyname 0x2, prototype + definemethod 0x4, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + mov v3, v1 + newobjrange 0x5, 0x1, v3 + sta v0 + tryldglobalbyname 0x7, print + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + ldobjbyvalue 0x8, v0 + sta v0 + lda v1 + callarg1 0xa, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt index 71dce896947194f79ee8dd4ff9d03da0dbff9c7a..2146d9664381b09bf5604ff65b464810c9185e3d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x0 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 69bb8f2086f3c64df358870bf9f387f7b38ab731..abb8d603e850df27ddec1d97e52b05829581e40d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -13,7 +13,6 @@ label_2: } slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 67e2e6c37a2ac26739c415cc91543a987fff4b5d..520550704fce57cc575b74d2e3627e27ab3ec0c4 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -13,7 +13,6 @@ label_2: } slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .#&X~@0=#TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..67e2e6c37a2ac26739c415cc91543a987fff4b5d --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,55 @@ +slotNum = 0x1 +.language ECMAScript +.function any .#&#X(any a0, any a1, any a2, any a3) { +label_1: +label_0: + newlexenv 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#&X~@0=#TestTypeA, _3, 0x0, v0 + stlexvar 0x0, 0x0 + returnundefined +label_2: +} + +slotNum = 0x6 +expectedProperty = 0x2 +.language ECMAScript +.function any .#&X~@0=#TestTypeA(any a0, any a1, any a2) { +label_1: +label_0: + lda.str A + stobjbyname 0x0, name, a2 + callruntime.ldsendableclass 0x0 + sta v0 + mov v1, v0 + newobjrange 0x2, 0x1, v1 + stobjbyname 0x4, test, a2 + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_4: +label_0: + ldundefined + sta v0 + definefunc 0x0, .#&#X, 0x1 + sta v1 + lda v0 + callruntime.istrue 0x1 + jnez label_3 +label_2: + createemptyobject + sta v0 +label_3: + lda v1 + callarg1 0x2, v0 + returnundefined +label_5: +} + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt index 6e671f61e26c94990488569cc9bc102a594d6f7d..c24923ed0ec6685bf48c1d87984262c7668e6211 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt @@ -32,7 +32,6 @@ label_8: .catchall label_2, end_label_3, label_9 slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 33c4531ae9437172fdeb6e84393e3cf2c5821524..9809190ee53e5e15cd9e1c0c73483b1c78f1cf93 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .InObjSyntax(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 4493a6c93d32e6185de7f9864d13c92b06590c83..0674d69a08d2e87afe0fbaee4417b7118392f5db 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -17,7 +17,6 @@ label_4: } slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 46915b5bf72ae6a9e27baadd2e35795017d661f8..6d4c25cbeeedc82abbc28782abf3057b3fb26c02 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -18,7 +18,6 @@ label_4: } slotNum = 0x4 -expectedProperty = 0x1 .function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { label_1: label_0: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4493a6c93d32e6185de7f9864d13c92b06590c83 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,95 @@ +slotNum = 0x3 +.language ECMAScript +.function any .#~@0<#getPrivateProperty(any a0, any a1, any a2, any a3) { +label_3: +label_0: + lda a3 + testin 0x0, 0x0, 0x0 + callruntime.isfalse 0x2 + jnez label_1 +label_2: + ldtrue + return +label_1: + ldfalse + return +label_4: +} + +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a3 + stprivateproperty 0x2, 0x0, 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + lda.str private + callruntime.defineprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~@0=#InObjSyntax, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~@0>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 + callruntime.createprivateproperty 0x1, _3 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + tryldglobalbyname 0x4, print + sta v0 + lda v1 + ldobjbyname 0x5, getPrivateProperty + sta v2 + lda.str foo + sta v3 + mov v4, v1 + mov v5, v3 + newobjrange 0x7, 0x2, v4 + sta v3 + lda v2 + callthis1 0x9, v1, v3 + sta v1 + lda v0 + callarg1 0xb, v1 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt index 07c1ce9d18fcc7a4de91ff1de1e1e6488c5525a0..6f86f64511d408bb2d3143b64453c710731cced2 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [in_obj_syntax.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [in_obj_syntax.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 9358f6779e4f0501600a2ad0be9ceaff35a5efe5..2417ecc1e70054fc2737a7d02af5e1a77b4f4063 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x3 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index aa00c9181c2dc6fbfcf0794e14911bc97cad2921..26d24c71b275f5ea1861d5dcb9bcdb5f9d4701cc 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x3 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa00c9181c2dc6fbfcf0794e14911bc97cad2921 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,75 @@ +slotNum = 0x2 +expectedProperty = 0x3 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x6 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + callruntime.definefieldbyindex 0x0, 0x1, a2 + ldlexvar 0x0, 0x0 + sta v0 + lda.str a + callruntime.definefieldbyvalue 0x2, v0, a2 + ldlexvar 0x1, 0x0 + sta v0 + throw.undefinedifholewithname a + lda v0 + definepropertybyname 0x4, b, a2 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 + lda.str a + stlexvar 0x0, 0x0 + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + ldlexvar 0x1, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + callruntime.topropertykey + stlexvar 0x0, 0x0 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x0, v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt index 302fa2a5806c5d48a639c70dc5d44f0cf7dc3f8e..18d32ff7d158922e027351f151fe92a66bbdc75d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x0 -expectedProperty = 0x3 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt index 9ebbe0fbe7673aa4767c89a542dfdeea59e23244..55353e1e07b6b90d300363d439cecc2b8247843e 100644 --- a/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_field.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_field.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt index 3303a190e5551ffebaf8c1f70044d891ffed8b83..7ac858525c0f11da695d238142bdbe6f0e421725 100644 --- a/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_method.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_method.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt index 5d5a117bc1f312c0fabed54858d0a50a2fc5239b..d1e3d87e4347f8e0dca9b155a0a3ef12aafbed39 100644 --- a/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [in_check_private_property.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [in_check_private_property.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 03c820216f70c914be786fab25909038d65ceacc..c79b8851104d495de84a5b6d3305979d220a82c0 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 048d8311b39588239503c1bdccf78518836e0c27..37095061777d94e7ff7da8abf4fd4ea91c39669f 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..048d8311b39588239503c1bdccf78518836e0c27 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,45 @@ +slotNum = 0x4 +expectedProperty = 0x2 +.language ECMAScript +.function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendableexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + callruntime.wideldsendableexternalmodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x2, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x8 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#SendableLazyLoading, _3, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt index c856ace10eeee1748a21c2a78b8964fb2d31aed2..dd9c93627ba79c5c22161a560f87f0634730700d 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 96% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 0d29c31ce79b818f12e196979de27cd718248290..6e71af8b31718335b7315424577f2895453596c8 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6e71af8b31718335b7315424577f2895453596c8 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,44 @@ +slotNum = 0x4 +.language ECMAScript +.function any .SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + wide.ldexternalmodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x2, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x8 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .SendableLazyLoading, _2, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..da0f8ed91a8f2f0f067b3bdf26265d5ca48cf82c --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +a1 diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index c5f203f625fe2cf1c908f4fcb303b354fbe029ed..ab6c662e2d9e5ce394e315d531ed1e6e67eba895 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index eb032750110552b4b42abde4fea04b03d2e206e7..d85ed5764e9862238e443405563a5636df871cc8 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -12,7 +11,6 @@ label_2: } slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .#~@1=#SendableTestClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb032750110552b4b42abde4fea04b03d2e206e7 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,55 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0xa +expectedProperty = 0x2 +.language ECMAScript +.function any .#~@1=#SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendablevar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + lda a2 + ldobjbyname 0x4, a1 + ldobjbyname 0x6, o + stobjbyname 0x8, u, a2 + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.newsendableenv 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#TopLevelSendableClass1, _3, 0x0, v0 + callruntime.stsendablevar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x1, .#~@1=#SendableTestClass1, _5, 0x0, v0 + sta v0 + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt index cde3ccc64189ca9ddef9c65bb595dd1ba85c7db9..fdad4e6d3a652e370b6ec44e1e7d6ec18ad7bb95 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,5 @@ +slotNum = 0xa .language ECMAScript - .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: label_0: @@ -8,9 +8,9 @@ label_0: throw.undefinedifholewithname TopLevelSendableClass1 mov v1, v0 newobjrange 0x0, 0x1, v1 - stobjbyname 0x2, I1, a2 + stobjbyname 0x2, a1, a2 lda a2 - ldobjbyname 0x4, I1 + ldobjbyname 0x4, a1 ldobjbyname 0x6, o stobjbyname 0x8, u, a2 lda a2 @@ -18,6 +18,8 @@ label_0: label_2: } +slotNum = 0x2 +.language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: label_0: @@ -28,21 +30,26 @@ label_0: label_2: } +slotNum = 0x8 +.language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: newlexenv 0x1 ldhole sta v0 - callruntime.definesendableclass 0x0, .TopLevelSendableClass1, _2, 0x0, v0 + defineclasswithbuffer 0x0, .TopLevelSendableClass1, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 stlexvar 0x0, 0x0 ldhole sta v0 - callruntime.definesendableclass 0x1, .SendableTestClass1, _4, 0x0, v0 + defineclasswithbuffer 0x3, .SendableTestClass1, _2, 0x0, v0 sta v0 + ldobjbyname 0x4, prototype mov v1, v0 - newobjrange 0x2, 0x1, v1 - ldundefined + newobjrange 0x6, 0x1, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 0f14e168d48b3eb32216ad318cf2a3259bab512d..9648548b638686eee08bccbddb4601b37b8817ec 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 72% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index d42096de0cb644cf4d6ab10902b64fefe1130ecb..9648548b638686eee08bccbddb4601b37b8817ec 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -32,7 +30,7 @@ label_0: label_2: } -slotNum = 0x8 +slotNum = 0x4 .language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: @@ -40,18 +38,14 @@ label_0: newlexenv 0x1 ldhole sta v0 - defineclasswithbuffer 0x0, .TopLevelSendableClass1, _1, 0x0, v0 - sta v0 - ldobjbyname 0x1, prototype - lda v0 + callruntime.definesendableclass 0x0, .TopLevelSendableClass1, _2, 0x0, v0 stlexvar 0x0, 0x0 ldhole sta v0 - defineclasswithbuffer 0x3, .SendableTestClass1, _2, 0x0, v0 + callruntime.definesendableclass 0x1, .SendableTestClass1, _4, 0x0, v0 sta v0 - ldobjbyname 0x4, prototype mov v1, v0 - newobjrange 0x6, 0x1, v1 + newobjrange 0x2, 0x1, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 6407e1d84bc14ce42abeec01422b74291505a244..1517375c8a7909a1c7d8320e7c039ac374d15e8e 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 4eb345368c176d8b5040719e8de9e473f4083ea9..a21d8fc54382d39b1e5412f370182fd5e05e6bb2 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -12,7 +11,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@10=#TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -25,7 +23,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@11=#TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -38,7 +35,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@12=#TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -51,7 +47,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@13=#TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -64,7 +59,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@14=#TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -77,7 +71,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@15=#TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -90,7 +83,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@16=#TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -103,7 +95,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@17=#TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -116,7 +107,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@18=#TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -129,7 +119,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@19=#TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -142,7 +131,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1=#TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -155,7 +143,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1a=#TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -168,7 +155,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1b=#TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -181,7 +167,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1c=#TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -194,7 +179,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1d=#TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -207,7 +191,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1e=#TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -220,7 +203,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1f=#TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -233,7 +215,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@20=#TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -246,7 +227,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@21=#TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -259,7 +239,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@22=#TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -272,7 +251,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@23=#TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -285,7 +263,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@24=#TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -298,7 +275,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@25=#TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -311,7 +287,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@26=#TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -324,7 +299,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@27=#TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -337,7 +311,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@28=#TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -350,7 +323,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@29=#TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -363,7 +335,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2=#TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -376,7 +347,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2a=#TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -389,7 +359,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2b=#TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -402,7 +371,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2c=#TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -415,7 +383,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2d=#TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -428,7 +395,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2e=#TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -441,7 +407,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2f=#TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -454,7 +419,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@30=#TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -467,7 +431,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@31=#TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -480,7 +443,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@32=#TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -493,7 +455,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@33=#TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -506,7 +467,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@34=#TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -519,7 +479,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@35=#TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -532,7 +491,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@36=#TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -545,7 +503,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@37=#TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -558,7 +515,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@38=#TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -571,7 +527,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@39=#TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -584,7 +539,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3=#TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -597,7 +551,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3a=#TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -610,7 +563,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3b=#TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -623,7 +575,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3c=#TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -636,7 +587,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3d=#TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -649,7 +599,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3e=#TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -662,7 +611,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3f=#TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -675,7 +623,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@40=#TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -688,7 +635,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@41=#TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -701,7 +647,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@42=#TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -714,7 +659,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@43=#TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -727,7 +671,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@44=#TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -740,7 +683,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@45=#TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -753,7 +695,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@46=#TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -766,7 +707,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@47=#TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -779,7 +719,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@48=#TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -792,7 +731,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@49=#TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -805,7 +743,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4=#TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -818,7 +755,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4a=#TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -831,7 +767,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4b=#TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -844,7 +779,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4c=#TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -857,7 +791,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4d=#TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -870,7 +803,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4e=#TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -883,7 +815,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4f=#TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -896,7 +827,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@50=#TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -909,7 +839,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@51=#TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -922,7 +851,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@52=#TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -935,7 +863,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@53=#TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -948,7 +875,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@54=#TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -961,7 +887,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@55=#TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -974,7 +899,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@56=#TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -987,7 +911,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@57=#TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -1000,7 +923,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@58=#TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -1013,7 +935,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@59=#TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -1026,7 +947,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5=#TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -1039,7 +959,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5a=#TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -1052,7 +971,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5b=#TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -1065,7 +983,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5c=#TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -1078,7 +995,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5d=#TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -1091,7 +1007,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5e=#TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -1104,7 +1019,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5f=#TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -1117,7 +1031,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@60=#TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -1130,7 +1043,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@61=#TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -1143,7 +1055,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@62=#TopLevelSendableClass99(any a0, any a1, any a2) { label_1: @@ -1156,7 +1067,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@63=#TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1169,7 +1079,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@64=#TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1182,7 +1091,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@65=#TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1195,7 +1103,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@66=#TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1208,7 +1115,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@67=#TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1221,7 +1127,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@68=#TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1234,7 +1139,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@69=#TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1247,7 +1151,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6=#TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -1260,7 +1163,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6a=#TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1273,7 +1175,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6b=#TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1286,7 +1187,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6c=#TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1299,7 +1199,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6d=#TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1312,7 +1211,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6e=#TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1325,7 +1223,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6f=#TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1338,7 +1235,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@70=#TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1351,7 +1247,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@71=#TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1364,7 +1259,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@72=#TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1377,7 +1271,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@73=#TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1390,7 +1283,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@74=#TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1403,7 +1295,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@75=#TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1416,7 +1307,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@76=#TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1429,7 +1319,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@77=#TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1442,7 +1331,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@78=#TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1455,7 +1343,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@79=#TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1468,7 +1355,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7=#TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -1481,7 +1367,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7a=#TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1494,7 +1379,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7b=#TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1507,7 +1391,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7c=#TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1520,7 +1403,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7d=#TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1533,7 +1415,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7e=#TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1546,7 +1427,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7f=#TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1559,7 +1439,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@80=#TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1572,7 +1451,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@81=#TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -1585,7 +1463,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@82=#TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -1598,7 +1475,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@83=#TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -1611,7 +1487,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@84=#TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -1624,7 +1499,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@85=#TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -1637,7 +1511,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@86=#TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -1650,7 +1523,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@87=#TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -1663,7 +1535,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@88=#TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -1676,7 +1547,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@89=#TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -1689,7 +1559,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8=#TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -1702,7 +1571,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8a=#TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -1715,7 +1583,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8b=#TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -1728,7 +1595,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8c=#TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -1741,7 +1607,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8d=#TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -1754,7 +1619,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8e=#TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -1767,7 +1631,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8f=#TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -1780,7 +1643,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@90=#TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -1793,7 +1655,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@91=#TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -1806,7 +1667,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@92=#TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -1819,7 +1679,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@93=#TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -1832,7 +1691,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@94=#TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -1845,7 +1703,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@95=#TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -1858,7 +1715,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@96=#TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -1871,7 +1727,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@97=#TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -1884,7 +1739,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@98=#TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -1897,7 +1751,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@99=#TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -1910,7 +1763,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9=#TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1923,7 +1775,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9a=#TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -1936,7 +1787,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9b=#TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -1949,7 +1799,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9c=#TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -1962,7 +1811,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9d=#TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -1975,7 +1823,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9e=#TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -1988,7 +1835,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9f=#TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2001,7 +1847,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a0=#TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2014,7 +1859,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a1=#TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2027,7 +1871,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a2=#TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2040,7 +1883,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a3=#TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2053,7 +1895,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a4=#TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2066,7 +1907,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a5=#TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2079,7 +1919,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a6=#TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2092,7 +1931,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a7=#TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2105,7 +1943,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a8=#TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2118,7 +1955,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a9=#TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2131,7 +1967,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a=#TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -2144,7 +1979,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@aa=#TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2157,7 +1991,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ab=#TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2170,7 +2003,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ac=#TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2183,7 +2015,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ad=#TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2196,7 +2027,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ae=#TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2209,7 +2039,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@af=#TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2222,7 +2051,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b0=#TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2235,7 +2063,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b1=#TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2248,7 +2075,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b2=#TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2261,7 +2087,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b3=#TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2274,7 +2099,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b4=#TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2287,7 +2111,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b5=#TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2300,7 +2123,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b6=#TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2313,7 +2135,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b7=#TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2326,7 +2147,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b8=#TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2339,7 +2159,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b9=#TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2352,7 +2171,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b=#TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -2365,7 +2183,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ba=#TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2378,7 +2195,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bb=#TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2391,7 +2207,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bc=#TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2404,7 +2219,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bd=#TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2417,7 +2231,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@be=#TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2430,7 +2243,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bf=#TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2443,7 +2255,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c0=#TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2456,7 +2267,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c1=#TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2469,7 +2279,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c2=#TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2482,7 +2291,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c3=#TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2495,7 +2303,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c4=#TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2508,7 +2315,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c5=#TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2521,7 +2327,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c6=#TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2534,7 +2339,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c7=#TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -2547,7 +2351,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c8=#TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -2560,7 +2363,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c9=#TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -2573,7 +2375,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c=#TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2586,7 +2387,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ca=#TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -2599,7 +2399,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cb=#TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -2612,7 +2411,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cc=#TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -2625,7 +2423,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cd=#TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -2638,7 +2435,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ce=#TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -2651,7 +2447,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cf=#TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -2664,7 +2459,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d0=#TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -2677,7 +2471,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d1=#TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -2690,7 +2483,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d2=#TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -2703,7 +2495,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d3=#TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -2716,7 +2507,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d4=#TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -2729,7 +2519,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d5=#TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -2742,7 +2531,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d6=#TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -2755,7 +2543,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d7=#TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -2768,7 +2555,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d8=#TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -2781,7 +2567,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d9=#TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -2794,7 +2579,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d=#TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2807,7 +2591,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@da=#TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -2820,7 +2603,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@db=#TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -2833,7 +2615,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@dc=#TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -2846,7 +2627,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@dd=#TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -2859,7 +2639,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@de=#TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -2872,7 +2651,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@df=#TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -2885,7 +2663,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e0=#TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -2898,7 +2675,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e1=#TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -2911,7 +2687,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e2=#TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -2924,7 +2699,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e3=#TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -2937,7 +2711,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e4=#TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -2950,7 +2723,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e5=#TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -2963,7 +2735,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e6=#TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -2976,7 +2747,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e7=#TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -2989,7 +2759,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e8=#TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3002,7 +2771,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e9=#TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3015,7 +2783,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e=#TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -3028,7 +2795,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ea=#TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3041,7 +2807,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@eb=#TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3054,7 +2819,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ec=#TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3067,7 +2831,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ed=#TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3080,7 +2843,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ee=#TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3093,7 +2855,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ef=#TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3106,7 +2867,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f0=#TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3119,7 +2879,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f1=#TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3132,7 +2891,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f2=#TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3145,7 +2903,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f3=#TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3158,7 +2915,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f4=#TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3171,7 +2927,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f5=#TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3184,7 +2939,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f6=#TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3197,7 +2951,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f7=#TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3210,7 +2963,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f8=#TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3223,7 +2975,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f9=#TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3236,7 +2987,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f=#TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -3249,7 +2999,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fa=#TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3262,7 +3011,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fb=#TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3275,7 +3023,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fc=#TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3288,7 +3035,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fd=#TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3301,7 +3047,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fe=#TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3314,7 +3059,6 @@ label_2: } slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .#~@ff=#SendableTestClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4eb345368c176d8b5040719e8de9e473f4083ea9 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,5907 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@10=#TopLevelSendableClass17(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@11=#TopLevelSendableClass18(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@12=#TopLevelSendableClass19(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@13=#TopLevelSendableClass20(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@14=#TopLevelSendableClass21(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@15=#TopLevelSendableClass22(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@16=#TopLevelSendableClass23(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@17=#TopLevelSendableClass24(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@18=#TopLevelSendableClass25(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@19=#TopLevelSendableClass26(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1=#TopLevelSendableClass2(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1a=#TopLevelSendableClass27(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1b=#TopLevelSendableClass28(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1c=#TopLevelSendableClass29(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1d=#TopLevelSendableClass30(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1e=#TopLevelSendableClass31(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1f=#TopLevelSendableClass32(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@20=#TopLevelSendableClass33(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@21=#TopLevelSendableClass34(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@22=#TopLevelSendableClass35(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@23=#TopLevelSendableClass36(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@24=#TopLevelSendableClass37(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@25=#TopLevelSendableClass38(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@26=#TopLevelSendableClass39(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@27=#TopLevelSendableClass40(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@28=#TopLevelSendableClass41(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@29=#TopLevelSendableClass42(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2=#TopLevelSendableClass3(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2a=#TopLevelSendableClass43(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2b=#TopLevelSendableClass44(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2c=#TopLevelSendableClass45(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2d=#TopLevelSendableClass46(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2e=#TopLevelSendableClass47(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2f=#TopLevelSendableClass48(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@30=#TopLevelSendableClass49(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@31=#TopLevelSendableClass50(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@32=#TopLevelSendableClass51(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@33=#TopLevelSendableClass52(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@34=#TopLevelSendableClass53(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@35=#TopLevelSendableClass54(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@36=#TopLevelSendableClass55(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@37=#TopLevelSendableClass56(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@38=#TopLevelSendableClass57(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@39=#TopLevelSendableClass58(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3=#TopLevelSendableClass4(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3a=#TopLevelSendableClass59(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3b=#TopLevelSendableClass60(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3c=#TopLevelSendableClass61(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3d=#TopLevelSendableClass62(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3e=#TopLevelSendableClass63(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3f=#TopLevelSendableClass64(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@40=#TopLevelSendableClass65(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@41=#TopLevelSendableClass66(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@42=#TopLevelSendableClass67(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@43=#TopLevelSendableClass68(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@44=#TopLevelSendableClass69(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@45=#TopLevelSendableClass70(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@46=#TopLevelSendableClass71(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@47=#TopLevelSendableClass72(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@48=#TopLevelSendableClass73(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@49=#TopLevelSendableClass74(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4=#TopLevelSendableClass5(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4a=#TopLevelSendableClass75(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4b=#TopLevelSendableClass76(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4c=#TopLevelSendableClass77(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4d=#TopLevelSendableClass78(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4e=#TopLevelSendableClass79(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4f=#TopLevelSendableClass80(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@50=#TopLevelSendableClass81(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@51=#TopLevelSendableClass82(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@52=#TopLevelSendableClass83(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@53=#TopLevelSendableClass84(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@54=#TopLevelSendableClass85(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@55=#TopLevelSendableClass86(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@56=#TopLevelSendableClass87(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@57=#TopLevelSendableClass88(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@58=#TopLevelSendableClass89(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@59=#TopLevelSendableClass90(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5=#TopLevelSendableClass6(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5a=#TopLevelSendableClass91(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5b=#TopLevelSendableClass92(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5c=#TopLevelSendableClass93(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5d=#TopLevelSendableClass94(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5e=#TopLevelSendableClass95(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5f=#TopLevelSendableClass96(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@60=#TopLevelSendableClass97(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@61=#TopLevelSendableClass98(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@62=#TopLevelSendableClass99(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@63=#TopLevelSendableClass100(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@64=#TopLevelSendableClass101(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@65=#TopLevelSendableClass102(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@66=#TopLevelSendableClass103(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@67=#TopLevelSendableClass104(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@68=#TopLevelSendableClass105(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@69=#TopLevelSendableClass106(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6=#TopLevelSendableClass7(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6a=#TopLevelSendableClass107(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6b=#TopLevelSendableClass108(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6c=#TopLevelSendableClass109(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6d=#TopLevelSendableClass110(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6e=#TopLevelSendableClass111(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6f=#TopLevelSendableClass112(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@70=#TopLevelSendableClass113(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@71=#TopLevelSendableClass114(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@72=#TopLevelSendableClass115(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@73=#TopLevelSendableClass116(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@74=#TopLevelSendableClass117(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@75=#TopLevelSendableClass118(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@76=#TopLevelSendableClass119(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@77=#TopLevelSendableClass120(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@78=#TopLevelSendableClass121(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@79=#TopLevelSendableClass122(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7=#TopLevelSendableClass8(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7a=#TopLevelSendableClass123(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7b=#TopLevelSendableClass124(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7c=#TopLevelSendableClass125(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7d=#TopLevelSendableClass126(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7e=#TopLevelSendableClass127(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7f=#TopLevelSendableClass128(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@80=#TopLevelSendableClass129(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@81=#TopLevelSendableClass130(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@82=#TopLevelSendableClass131(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@83=#TopLevelSendableClass132(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@84=#TopLevelSendableClass133(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@85=#TopLevelSendableClass134(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@86=#TopLevelSendableClass135(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@87=#TopLevelSendableClass136(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@88=#TopLevelSendableClass137(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@89=#TopLevelSendableClass138(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8=#TopLevelSendableClass9(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8a=#TopLevelSendableClass139(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8b=#TopLevelSendableClass140(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8c=#TopLevelSendableClass141(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8d=#TopLevelSendableClass142(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8e=#TopLevelSendableClass143(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8f=#TopLevelSendableClass144(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@90=#TopLevelSendableClass145(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@91=#TopLevelSendableClass146(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@92=#TopLevelSendableClass147(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@93=#TopLevelSendableClass148(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@94=#TopLevelSendableClass149(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@95=#TopLevelSendableClass150(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@96=#TopLevelSendableClass151(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@97=#TopLevelSendableClass152(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@98=#TopLevelSendableClass153(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@99=#TopLevelSendableClass154(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9=#TopLevelSendableClass10(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9a=#TopLevelSendableClass155(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9b=#TopLevelSendableClass156(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9c=#TopLevelSendableClass157(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9d=#TopLevelSendableClass158(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9e=#TopLevelSendableClass159(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9f=#TopLevelSendableClass160(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a0=#TopLevelSendableClass161(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a1=#TopLevelSendableClass162(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a2=#TopLevelSendableClass163(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a3=#TopLevelSendableClass164(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a4=#TopLevelSendableClass165(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a5=#TopLevelSendableClass166(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a6=#TopLevelSendableClass167(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a7=#TopLevelSendableClass168(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a8=#TopLevelSendableClass169(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a9=#TopLevelSendableClass170(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a=#TopLevelSendableClass11(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@aa=#TopLevelSendableClass171(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ab=#TopLevelSendableClass172(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ac=#TopLevelSendableClass173(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ad=#TopLevelSendableClass174(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ae=#TopLevelSendableClass175(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@af=#TopLevelSendableClass176(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b0=#TopLevelSendableClass177(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b1=#TopLevelSendableClass178(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b2=#TopLevelSendableClass179(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b3=#TopLevelSendableClass180(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b4=#TopLevelSendableClass181(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b5=#TopLevelSendableClass182(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b6=#TopLevelSendableClass183(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b7=#TopLevelSendableClass184(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b8=#TopLevelSendableClass185(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b9=#TopLevelSendableClass186(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b=#TopLevelSendableClass12(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ba=#TopLevelSendableClass187(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bb=#TopLevelSendableClass188(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bc=#TopLevelSendableClass189(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bd=#TopLevelSendableClass190(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@be=#TopLevelSendableClass191(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bf=#TopLevelSendableClass192(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c0=#TopLevelSendableClass193(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c1=#TopLevelSendableClass194(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c2=#TopLevelSendableClass195(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c3=#TopLevelSendableClass196(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c4=#TopLevelSendableClass197(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c5=#TopLevelSendableClass198(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c6=#TopLevelSendableClass199(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c7=#TopLevelSendableClass200(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c8=#TopLevelSendableClass201(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c9=#TopLevelSendableClass202(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c=#TopLevelSendableClass13(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ca=#TopLevelSendableClass203(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cb=#TopLevelSendableClass204(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cc=#TopLevelSendableClass205(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cd=#TopLevelSendableClass206(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ce=#TopLevelSendableClass207(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cf=#TopLevelSendableClass208(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d0=#TopLevelSendableClass209(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d1=#TopLevelSendableClass210(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d2=#TopLevelSendableClass211(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d3=#TopLevelSendableClass212(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d4=#TopLevelSendableClass213(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d5=#TopLevelSendableClass214(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d6=#TopLevelSendableClass215(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d7=#TopLevelSendableClass216(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d8=#TopLevelSendableClass217(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d9=#TopLevelSendableClass218(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d=#TopLevelSendableClass14(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@da=#TopLevelSendableClass219(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@db=#TopLevelSendableClass220(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@dc=#TopLevelSendableClass221(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@dd=#TopLevelSendableClass222(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@de=#TopLevelSendableClass223(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@df=#TopLevelSendableClass224(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e0=#TopLevelSendableClass225(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e1=#TopLevelSendableClass226(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e2=#TopLevelSendableClass227(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e3=#TopLevelSendableClass228(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e4=#TopLevelSendableClass229(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e5=#TopLevelSendableClass230(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e6=#TopLevelSendableClass231(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e7=#TopLevelSendableClass232(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e8=#TopLevelSendableClass233(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e9=#TopLevelSendableClass234(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e=#TopLevelSendableClass15(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ea=#TopLevelSendableClass235(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@eb=#TopLevelSendableClass236(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ec=#TopLevelSendableClass237(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ed=#TopLevelSendableClass238(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ee=#TopLevelSendableClass239(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ef=#TopLevelSendableClass240(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f0=#TopLevelSendableClass241(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f1=#TopLevelSendableClass242(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f2=#TopLevelSendableClass243(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f3=#TopLevelSendableClass244(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f4=#TopLevelSendableClass245(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f5=#TopLevelSendableClass246(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f6=#TopLevelSendableClass247(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f7=#TopLevelSendableClass248(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f8=#TopLevelSendableClass249(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f9=#TopLevelSendableClass250(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f=#TopLevelSendableClass16(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fa=#TopLevelSendableClass251(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fb=#TopLevelSendableClass252(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fc=#TopLevelSendableClass253(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fd=#TopLevelSendableClass254(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fe=#TopLevelSendableClass255(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x406 +expectedProperty = 0x101 +.language ECMAScript +.function any .#~@ff=#SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendablevar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + callruntime.ldsendablevar 0x0, 0x1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass2 + mov v1, v0 + newobjrange 0x4, 0x1, v1 + stobjbyname 0x6, a2, a2 + callruntime.ldsendablevar 0x0, 0x2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass3 + mov v1, v0 + newobjrange 0x8, 0x1, v1 + stobjbyname 0xa, a3, a2 + callruntime.ldsendablevar 0x0, 0x3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass4 + mov v1, v0 + newobjrange 0xc, 0x1, v1 + stobjbyname 0xe, a4, a2 + callruntime.ldsendablevar 0x0, 0x4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass5 + mov v1, v0 + newobjrange 0x10, 0x1, v1 + stobjbyname 0x12, a5, a2 + callruntime.ldsendablevar 0x0, 0x5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass6 + mov v1, v0 + newobjrange 0x14, 0x1, v1 + stobjbyname 0x16, a6, a2 + callruntime.ldsendablevar 0x0, 0x6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass7 + mov v1, v0 + newobjrange 0x18, 0x1, v1 + stobjbyname 0x1a, a7, a2 + callruntime.ldsendablevar 0x0, 0x7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass8 + mov v1, v0 + newobjrange 0x1c, 0x1, v1 + stobjbyname 0x1e, a8, a2 + callruntime.ldsendablevar 0x0, 0x8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass9 + mov v1, v0 + newobjrange 0x20, 0x1, v1 + stobjbyname 0x22, a9, a2 + callruntime.ldsendablevar 0x0, 0x9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass10 + mov v1, v0 + newobjrange 0x24, 0x1, v1 + stobjbyname 0x26, a10, a2 + callruntime.ldsendablevar 0x0, 0xa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass11 + mov v1, v0 + newobjrange 0x28, 0x1, v1 + stobjbyname 0x2a, a11, a2 + callruntime.ldsendablevar 0x0, 0xb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass12 + mov v1, v0 + newobjrange 0x2c, 0x1, v1 + stobjbyname 0x2e, a12, a2 + callruntime.ldsendablevar 0x0, 0xc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass13 + mov v1, v0 + newobjrange 0x30, 0x1, v1 + stobjbyname 0x32, a13, a2 + callruntime.ldsendablevar 0x0, 0xd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass14 + mov v1, v0 + newobjrange 0x34, 0x1, v1 + stobjbyname 0x36, a14, a2 + callruntime.ldsendablevar 0x0, 0xe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass15 + mov v1, v0 + newobjrange 0x38, 0x1, v1 + stobjbyname 0x3a, a15, a2 + callruntime.ldsendablevar 0x0, 0xf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass16 + mov v1, v0 + newobjrange 0x3c, 0x1, v1 + stobjbyname 0x3e, a16, a2 + callruntime.ldsendablevar 0x0, 0x10 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass17 + mov v1, v0 + newobjrange 0x40, 0x1, v1 + stobjbyname 0x42, a17, a2 + callruntime.ldsendablevar 0x0, 0x11 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass18 + mov v1, v0 + newobjrange 0x44, 0x1, v1 + stobjbyname 0x46, a18, a2 + callruntime.ldsendablevar 0x0, 0x12 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass19 + mov v1, v0 + newobjrange 0x48, 0x1, v1 + stobjbyname 0x4a, a19, a2 + callruntime.ldsendablevar 0x0, 0x13 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass20 + mov v1, v0 + newobjrange 0x4c, 0x1, v1 + stobjbyname 0x4e, a20, a2 + callruntime.ldsendablevar 0x0, 0x14 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass21 + mov v1, v0 + newobjrange 0x50, 0x1, v1 + stobjbyname 0x52, a21, a2 + callruntime.ldsendablevar 0x0, 0x15 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass22 + mov v1, v0 + newobjrange 0x54, 0x1, v1 + stobjbyname 0x56, a22, a2 + callruntime.ldsendablevar 0x0, 0x16 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass23 + mov v1, v0 + newobjrange 0x58, 0x1, v1 + stobjbyname 0x5a, a23, a2 + callruntime.ldsendablevar 0x0, 0x17 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass24 + mov v1, v0 + newobjrange 0x5c, 0x1, v1 + stobjbyname 0x5e, a24, a2 + callruntime.ldsendablevar 0x0, 0x18 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass25 + mov v1, v0 + newobjrange 0x60, 0x1, v1 + stobjbyname 0x62, a25, a2 + callruntime.ldsendablevar 0x0, 0x19 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass26 + mov v1, v0 + newobjrange 0x64, 0x1, v1 + stobjbyname 0x66, a26, a2 + callruntime.ldsendablevar 0x0, 0x1a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass27 + mov v1, v0 + newobjrange 0x68, 0x1, v1 + stobjbyname 0x6a, a27, a2 + callruntime.ldsendablevar 0x0, 0x1b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass28 + mov v1, v0 + newobjrange 0x6c, 0x1, v1 + stobjbyname 0x6e, a28, a2 + callruntime.ldsendablevar 0x0, 0x1c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass29 + mov v1, v0 + newobjrange 0x70, 0x1, v1 + stobjbyname 0x72, a29, a2 + callruntime.ldsendablevar 0x0, 0x1d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass30 + mov v1, v0 + newobjrange 0x74, 0x1, v1 + stobjbyname 0x76, a30, a2 + callruntime.ldsendablevar 0x0, 0x1e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass31 + mov v1, v0 + newobjrange 0x78, 0x1, v1 + stobjbyname 0x7a, a31, a2 + callruntime.ldsendablevar 0x0, 0x1f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass32 + mov v1, v0 + newobjrange 0x7c, 0x1, v1 + stobjbyname 0x7e, a32, a2 + callruntime.ldsendablevar 0x0, 0x20 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass33 + mov v1, v0 + newobjrange 0x80, 0x1, v1 + stobjbyname 0x82, a33, a2 + callruntime.ldsendablevar 0x0, 0x21 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass34 + mov v1, v0 + newobjrange 0x84, 0x1, v1 + stobjbyname 0x86, a34, a2 + callruntime.ldsendablevar 0x0, 0x22 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass35 + mov v1, v0 + newobjrange 0x88, 0x1, v1 + stobjbyname 0x8a, a35, a2 + callruntime.ldsendablevar 0x0, 0x23 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass36 + mov v1, v0 + newobjrange 0x8c, 0x1, v1 + stobjbyname 0x8e, a36, a2 + callruntime.ldsendablevar 0x0, 0x24 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass37 + mov v1, v0 + newobjrange 0x90, 0x1, v1 + stobjbyname 0x92, a37, a2 + callruntime.ldsendablevar 0x0, 0x25 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass38 + mov v1, v0 + newobjrange 0x94, 0x1, v1 + stobjbyname 0x96, a38, a2 + callruntime.ldsendablevar 0x0, 0x26 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass39 + mov v1, v0 + newobjrange 0x98, 0x1, v1 + stobjbyname 0x9a, a39, a2 + callruntime.ldsendablevar 0x0, 0x27 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass40 + mov v1, v0 + newobjrange 0x9c, 0x1, v1 + stobjbyname 0x9e, a40, a2 + callruntime.ldsendablevar 0x0, 0x28 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass41 + mov v1, v0 + newobjrange 0xa0, 0x1, v1 + stobjbyname 0xa2, a41, a2 + callruntime.ldsendablevar 0x0, 0x29 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass42 + mov v1, v0 + newobjrange 0xa4, 0x1, v1 + stobjbyname 0xa6, a42, a2 + callruntime.ldsendablevar 0x0, 0x2a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass43 + mov v1, v0 + newobjrange 0xa8, 0x1, v1 + stobjbyname 0xaa, a43, a2 + callruntime.ldsendablevar 0x0, 0x2b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass44 + mov v1, v0 + newobjrange 0xac, 0x1, v1 + stobjbyname 0xae, a44, a2 + callruntime.ldsendablevar 0x0, 0x2c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass45 + mov v1, v0 + newobjrange 0xb0, 0x1, v1 + stobjbyname 0xb2, a45, a2 + callruntime.ldsendablevar 0x0, 0x2d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass46 + mov v1, v0 + newobjrange 0xb4, 0x1, v1 + stobjbyname 0xb6, a46, a2 + callruntime.ldsendablevar 0x0, 0x2e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass47 + mov v1, v0 + newobjrange 0xb8, 0x1, v1 + stobjbyname 0xba, a47, a2 + callruntime.ldsendablevar 0x0, 0x2f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass48 + mov v1, v0 + newobjrange 0xbc, 0x1, v1 + stobjbyname 0xbe, a48, a2 + callruntime.ldsendablevar 0x0, 0x30 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass49 + mov v1, v0 + newobjrange 0xc0, 0x1, v1 + stobjbyname 0xc2, a49, a2 + callruntime.ldsendablevar 0x0, 0x31 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass50 + mov v1, v0 + newobjrange 0xc4, 0x1, v1 + stobjbyname 0xc6, a50, a2 + callruntime.ldsendablevar 0x0, 0x32 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass51 + mov v1, v0 + newobjrange 0xc8, 0x1, v1 + stobjbyname 0xca, a51, a2 + callruntime.ldsendablevar 0x0, 0x33 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass52 + mov v1, v0 + newobjrange 0xcc, 0x1, v1 + stobjbyname 0xce, a52, a2 + callruntime.ldsendablevar 0x0, 0x34 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass53 + mov v1, v0 + newobjrange 0xd0, 0x1, v1 + stobjbyname 0xd2, a53, a2 + callruntime.ldsendablevar 0x0, 0x35 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass54 + mov v1, v0 + newobjrange 0xd4, 0x1, v1 + stobjbyname 0xd6, a54, a2 + callruntime.ldsendablevar 0x0, 0x36 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass55 + mov v1, v0 + newobjrange 0xd8, 0x1, v1 + stobjbyname 0xda, a55, a2 + callruntime.ldsendablevar 0x0, 0x37 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass56 + mov v1, v0 + newobjrange 0xdc, 0x1, v1 + stobjbyname 0xde, a56, a2 + callruntime.ldsendablevar 0x0, 0x38 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass57 + mov v1, v0 + newobjrange 0xe0, 0x1, v1 + stobjbyname 0xe2, a57, a2 + callruntime.ldsendablevar 0x0, 0x39 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass58 + mov v1, v0 + newobjrange 0xe4, 0x1, v1 + stobjbyname 0xe6, a58, a2 + callruntime.ldsendablevar 0x0, 0x3a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass59 + mov v1, v0 + newobjrange 0xe8, 0x1, v1 + stobjbyname 0xea, a59, a2 + callruntime.ldsendablevar 0x0, 0x3b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass60 + mov v1, v0 + newobjrange 0xec, 0x1, v1 + stobjbyname 0xee, a60, a2 + callruntime.ldsendablevar 0x0, 0x3c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass61 + mov v1, v0 + newobjrange 0xf0, 0x1, v1 + stobjbyname 0xf2, a61, a2 + callruntime.ldsendablevar 0x0, 0x3d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass62 + mov v1, v0 + newobjrange 0xf4, 0x1, v1 + stobjbyname 0xf6, a62, a2 + callruntime.ldsendablevar 0x0, 0x3e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass63 + mov v1, v0 + newobjrange 0xf8, 0x1, v1 + stobjbyname 0xfa, a63, a2 + callruntime.ldsendablevar 0x0, 0x3f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass64 + mov v1, v0 + newobjrange 0xfc, 0x1, v1 + stobjbyname 0x100, a64, a2 + callruntime.ldsendablevar 0x0, 0x40 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass65 + mov v1, v0 + newobjrange 0x102, 0x1, v1 + stobjbyname 0x104, a65, a2 + callruntime.ldsendablevar 0x0, 0x41 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass66 + mov v1, v0 + newobjrange 0x106, 0x1, v1 + stobjbyname 0x108, a66, a2 + callruntime.ldsendablevar 0x0, 0x42 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass67 + mov v1, v0 + newobjrange 0x10a, 0x1, v1 + stobjbyname 0x10c, a67, a2 + callruntime.ldsendablevar 0x0, 0x43 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass68 + mov v1, v0 + newobjrange 0x10e, 0x1, v1 + stobjbyname 0x110, a68, a2 + callruntime.ldsendablevar 0x0, 0x44 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass69 + mov v1, v0 + newobjrange 0x112, 0x1, v1 + stobjbyname 0x114, a69, a2 + callruntime.ldsendablevar 0x0, 0x45 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass70 + mov v1, v0 + newobjrange 0x116, 0x1, v1 + stobjbyname 0x118, a70, a2 + callruntime.ldsendablevar 0x0, 0x46 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass71 + mov v1, v0 + newobjrange 0x11a, 0x1, v1 + stobjbyname 0x11c, a71, a2 + callruntime.ldsendablevar 0x0, 0x47 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass72 + mov v1, v0 + newobjrange 0x11e, 0x1, v1 + stobjbyname 0x120, a72, a2 + callruntime.ldsendablevar 0x0, 0x48 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass73 + mov v1, v0 + newobjrange 0x122, 0x1, v1 + stobjbyname 0x124, a73, a2 + callruntime.ldsendablevar 0x0, 0x49 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass74 + mov v1, v0 + newobjrange 0x126, 0x1, v1 + stobjbyname 0x128, a74, a2 + callruntime.ldsendablevar 0x0, 0x4a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass75 + mov v1, v0 + newobjrange 0x12a, 0x1, v1 + stobjbyname 0x12c, a75, a2 + callruntime.ldsendablevar 0x0, 0x4b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass76 + mov v1, v0 + newobjrange 0x12e, 0x1, v1 + stobjbyname 0x130, a76, a2 + callruntime.ldsendablevar 0x0, 0x4c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass77 + mov v1, v0 + newobjrange 0x132, 0x1, v1 + stobjbyname 0x134, a77, a2 + callruntime.ldsendablevar 0x0, 0x4d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass78 + mov v1, v0 + newobjrange 0x136, 0x1, v1 + stobjbyname 0x138, a78, a2 + callruntime.ldsendablevar 0x0, 0x4e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass79 + mov v1, v0 + newobjrange 0x13a, 0x1, v1 + stobjbyname 0x13c, a79, a2 + callruntime.ldsendablevar 0x0, 0x4f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass80 + mov v1, v0 + newobjrange 0x13e, 0x1, v1 + stobjbyname 0x140, a80, a2 + callruntime.ldsendablevar 0x0, 0x50 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass81 + mov v1, v0 + newobjrange 0x142, 0x1, v1 + stobjbyname 0x144, a81, a2 + callruntime.ldsendablevar 0x0, 0x51 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass82 + mov v1, v0 + newobjrange 0x146, 0x1, v1 + stobjbyname 0x148, a82, a2 + callruntime.ldsendablevar 0x0, 0x52 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass83 + mov v1, v0 + newobjrange 0x14a, 0x1, v1 + stobjbyname 0x14c, a83, a2 + callruntime.ldsendablevar 0x0, 0x53 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass84 + mov v1, v0 + newobjrange 0x14e, 0x1, v1 + stobjbyname 0x150, a84, a2 + callruntime.ldsendablevar 0x0, 0x54 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass85 + mov v1, v0 + newobjrange 0x152, 0x1, v1 + stobjbyname 0x154, a85, a2 + callruntime.ldsendablevar 0x0, 0x55 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass86 + mov v1, v0 + newobjrange 0x156, 0x1, v1 + stobjbyname 0x158, a86, a2 + callruntime.ldsendablevar 0x0, 0x56 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass87 + mov v1, v0 + newobjrange 0x15a, 0x1, v1 + stobjbyname 0x15c, a87, a2 + callruntime.ldsendablevar 0x0, 0x57 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass88 + mov v1, v0 + newobjrange 0x15e, 0x1, v1 + stobjbyname 0x160, a88, a2 + callruntime.ldsendablevar 0x0, 0x58 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass89 + mov v1, v0 + newobjrange 0x162, 0x1, v1 + stobjbyname 0x164, a89, a2 + callruntime.ldsendablevar 0x0, 0x59 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass90 + mov v1, v0 + newobjrange 0x166, 0x1, v1 + stobjbyname 0x168, a90, a2 + callruntime.ldsendablevar 0x0, 0x5a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass91 + mov v1, v0 + newobjrange 0x16a, 0x1, v1 + stobjbyname 0x16c, a91, a2 + callruntime.ldsendablevar 0x0, 0x5b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass92 + mov v1, v0 + newobjrange 0x16e, 0x1, v1 + stobjbyname 0x170, a92, a2 + callruntime.ldsendablevar 0x0, 0x5c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass93 + mov v1, v0 + newobjrange 0x172, 0x1, v1 + stobjbyname 0x174, a93, a2 + callruntime.ldsendablevar 0x0, 0x5d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass94 + mov v1, v0 + newobjrange 0x176, 0x1, v1 + stobjbyname 0x178, a94, a2 + callruntime.ldsendablevar 0x0, 0x5e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass95 + mov v1, v0 + newobjrange 0x17a, 0x1, v1 + stobjbyname 0x17c, a95, a2 + callruntime.ldsendablevar 0x0, 0x5f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass96 + mov v1, v0 + newobjrange 0x17e, 0x1, v1 + stobjbyname 0x180, a96, a2 + callruntime.ldsendablevar 0x0, 0x60 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass97 + mov v1, v0 + newobjrange 0x182, 0x1, v1 + stobjbyname 0x184, a97, a2 + callruntime.ldsendablevar 0x0, 0x61 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass98 + mov v1, v0 + newobjrange 0x186, 0x1, v1 + stobjbyname 0x188, a98, a2 + callruntime.ldsendablevar 0x0, 0x62 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass99 + mov v1, v0 + newobjrange 0x18a, 0x1, v1 + stobjbyname 0x18c, a99, a2 + callruntime.ldsendablevar 0x0, 0x63 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass100 + mov v1, v0 + newobjrange 0x18e, 0x1, v1 + stobjbyname 0x190, a100, a2 + callruntime.ldsendablevar 0x0, 0x64 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass101 + mov v1, v0 + newobjrange 0x192, 0x1, v1 + stobjbyname 0x194, a101, a2 + callruntime.ldsendablevar 0x0, 0x65 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass102 + mov v1, v0 + newobjrange 0x196, 0x1, v1 + stobjbyname 0x198, a102, a2 + callruntime.ldsendablevar 0x0, 0x66 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass103 + mov v1, v0 + newobjrange 0x19a, 0x1, v1 + stobjbyname 0x19c, a103, a2 + callruntime.ldsendablevar 0x0, 0x67 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass104 + mov v1, v0 + newobjrange 0x19e, 0x1, v1 + stobjbyname 0x1a0, a104, a2 + callruntime.ldsendablevar 0x0, 0x68 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass105 + mov v1, v0 + newobjrange 0x1a2, 0x1, v1 + stobjbyname 0x1a4, a105, a2 + callruntime.ldsendablevar 0x0, 0x69 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass106 + mov v1, v0 + newobjrange 0x1a6, 0x1, v1 + stobjbyname 0x1a8, a106, a2 + callruntime.ldsendablevar 0x0, 0x6a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass107 + mov v1, v0 + newobjrange 0x1aa, 0x1, v1 + stobjbyname 0x1ac, a107, a2 + callruntime.ldsendablevar 0x0, 0x6b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass108 + mov v1, v0 + newobjrange 0x1ae, 0x1, v1 + stobjbyname 0x1b0, a108, a2 + callruntime.ldsendablevar 0x0, 0x6c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass109 + mov v1, v0 + newobjrange 0x1b2, 0x1, v1 + stobjbyname 0x1b4, a109, a2 + callruntime.ldsendablevar 0x0, 0x6d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass110 + mov v1, v0 + newobjrange 0x1b6, 0x1, v1 + stobjbyname 0x1b8, a110, a2 + callruntime.ldsendablevar 0x0, 0x6e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass111 + mov v1, v0 + newobjrange 0x1ba, 0x1, v1 + stobjbyname 0x1bc, a111, a2 + callruntime.ldsendablevar 0x0, 0x6f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass112 + mov v1, v0 + newobjrange 0x1be, 0x1, v1 + stobjbyname 0x1c0, a112, a2 + callruntime.ldsendablevar 0x0, 0x70 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass113 + mov v1, v0 + newobjrange 0x1c2, 0x1, v1 + stobjbyname 0x1c4, a113, a2 + callruntime.ldsendablevar 0x0, 0x71 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass114 + mov v1, v0 + newobjrange 0x1c6, 0x1, v1 + stobjbyname 0x1c8, a114, a2 + callruntime.ldsendablevar 0x0, 0x72 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass115 + mov v1, v0 + newobjrange 0x1ca, 0x1, v1 + stobjbyname 0x1cc, a115, a2 + callruntime.ldsendablevar 0x0, 0x73 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass116 + mov v1, v0 + newobjrange 0x1ce, 0x1, v1 + stobjbyname 0x1d0, a116, a2 + callruntime.ldsendablevar 0x0, 0x74 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass117 + mov v1, v0 + newobjrange 0x1d2, 0x1, v1 + stobjbyname 0x1d4, a117, a2 + callruntime.ldsendablevar 0x0, 0x75 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass118 + mov v1, v0 + newobjrange 0x1d6, 0x1, v1 + stobjbyname 0x1d8, a118, a2 + callruntime.ldsendablevar 0x0, 0x76 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass119 + mov v1, v0 + newobjrange 0x1da, 0x1, v1 + stobjbyname 0x1dc, a119, a2 + callruntime.ldsendablevar 0x0, 0x77 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass120 + mov v1, v0 + newobjrange 0x1de, 0x1, v1 + stobjbyname 0x1e0, a120, a2 + callruntime.ldsendablevar 0x0, 0x78 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass121 + mov v1, v0 + newobjrange 0x1e2, 0x1, v1 + stobjbyname 0x1e4, a121, a2 + callruntime.ldsendablevar 0x0, 0x79 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass122 + mov v1, v0 + newobjrange 0x1e6, 0x1, v1 + stobjbyname 0x1e8, a122, a2 + callruntime.ldsendablevar 0x0, 0x7a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass123 + mov v1, v0 + newobjrange 0x1ea, 0x1, v1 + stobjbyname 0x1ec, a123, a2 + callruntime.ldsendablevar 0x0, 0x7b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass124 + mov v1, v0 + newobjrange 0x1ee, 0x1, v1 + stobjbyname 0x1f0, a124, a2 + callruntime.ldsendablevar 0x0, 0x7c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass125 + mov v1, v0 + newobjrange 0x1f2, 0x1, v1 + stobjbyname 0x1f4, a125, a2 + callruntime.ldsendablevar 0x0, 0x7d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass126 + mov v1, v0 + newobjrange 0x1f6, 0x1, v1 + stobjbyname 0x1f8, a126, a2 + callruntime.ldsendablevar 0x0, 0x7e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass127 + mov v1, v0 + newobjrange 0x1fa, 0x1, v1 + stobjbyname 0x1fc, a127, a2 + callruntime.ldsendablevar 0x0, 0x7f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass128 + mov v1, v0 + newobjrange 0x1fe, 0x1, v1 + stobjbyname 0x200, a128, a2 + callruntime.wideldsendablevar 0x0, 0x80 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass129 + mov v1, v0 + newobjrange 0x202, 0x1, v1 + stobjbyname 0x204, a129, a2 + callruntime.wideldsendablevar 0x0, 0x81 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass130 + mov v1, v0 + newobjrange 0x206, 0x1, v1 + stobjbyname 0x208, a130, a2 + callruntime.wideldsendablevar 0x0, 0x82 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass131 + mov v1, v0 + newobjrange 0x20a, 0x1, v1 + stobjbyname 0x20c, a131, a2 + callruntime.wideldsendablevar 0x0, 0x83 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass132 + mov v1, v0 + newobjrange 0x20e, 0x1, v1 + stobjbyname 0x210, a132, a2 + callruntime.wideldsendablevar 0x0, 0x84 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass133 + mov v1, v0 + newobjrange 0x212, 0x1, v1 + stobjbyname 0x214, a133, a2 + callruntime.wideldsendablevar 0x0, 0x85 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass134 + mov v1, v0 + newobjrange 0x216, 0x1, v1 + stobjbyname 0x218, a134, a2 + callruntime.wideldsendablevar 0x0, 0x86 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass135 + mov v1, v0 + newobjrange 0x21a, 0x1, v1 + stobjbyname 0x21c, a135, a2 + callruntime.wideldsendablevar 0x0, 0x87 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass136 + mov v1, v0 + newobjrange 0x21e, 0x1, v1 + stobjbyname 0x220, a136, a2 + callruntime.wideldsendablevar 0x0, 0x88 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass137 + mov v1, v0 + newobjrange 0x222, 0x1, v1 + stobjbyname 0x224, a137, a2 + callruntime.wideldsendablevar 0x0, 0x89 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass138 + mov v1, v0 + newobjrange 0x226, 0x1, v1 + stobjbyname 0x228, a138, a2 + callruntime.wideldsendablevar 0x0, 0x8a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass139 + mov v1, v0 + newobjrange 0x22a, 0x1, v1 + stobjbyname 0x22c, a139, a2 + callruntime.wideldsendablevar 0x0, 0x8b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass140 + mov v1, v0 + newobjrange 0x22e, 0x1, v1 + stobjbyname 0x230, a140, a2 + callruntime.wideldsendablevar 0x0, 0x8c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass141 + mov v1, v0 + newobjrange 0x232, 0x1, v1 + stobjbyname 0x234, a141, a2 + callruntime.wideldsendablevar 0x0, 0x8d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass142 + mov v1, v0 + newobjrange 0x236, 0x1, v1 + stobjbyname 0x238, a142, a2 + callruntime.wideldsendablevar 0x0, 0x8e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass143 + mov v1, v0 + newobjrange 0x23a, 0x1, v1 + stobjbyname 0x23c, a143, a2 + callruntime.wideldsendablevar 0x0, 0x8f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass144 + mov v1, v0 + newobjrange 0x23e, 0x1, v1 + stobjbyname 0x240, a144, a2 + callruntime.wideldsendablevar 0x0, 0x90 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass145 + mov v1, v0 + newobjrange 0x242, 0x1, v1 + stobjbyname 0x244, a145, a2 + callruntime.wideldsendablevar 0x0, 0x91 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass146 + mov v1, v0 + newobjrange 0x246, 0x1, v1 + stobjbyname 0x248, a146, a2 + callruntime.wideldsendablevar 0x0, 0x92 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass147 + mov v1, v0 + newobjrange 0x24a, 0x1, v1 + stobjbyname 0x24c, a147, a2 + callruntime.wideldsendablevar 0x0, 0x93 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass148 + mov v1, v0 + newobjrange 0x24e, 0x1, v1 + stobjbyname 0x250, a148, a2 + callruntime.wideldsendablevar 0x0, 0x94 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass149 + mov v1, v0 + newobjrange 0x252, 0x1, v1 + stobjbyname 0x254, a149, a2 + callruntime.wideldsendablevar 0x0, 0x95 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass150 + mov v1, v0 + newobjrange 0x256, 0x1, v1 + stobjbyname 0x258, a150, a2 + callruntime.wideldsendablevar 0x0, 0x96 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass151 + mov v1, v0 + newobjrange 0x25a, 0x1, v1 + stobjbyname 0x25c, a151, a2 + callruntime.wideldsendablevar 0x0, 0x97 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass152 + mov v1, v0 + newobjrange 0x25e, 0x1, v1 + stobjbyname 0x260, a152, a2 + callruntime.wideldsendablevar 0x0, 0x98 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass153 + mov v1, v0 + newobjrange 0x262, 0x1, v1 + stobjbyname 0x264, a153, a2 + callruntime.wideldsendablevar 0x0, 0x99 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass154 + mov v1, v0 + newobjrange 0x266, 0x1, v1 + stobjbyname 0x268, a154, a2 + callruntime.wideldsendablevar 0x0, 0x9a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass155 + mov v1, v0 + newobjrange 0x26a, 0x1, v1 + stobjbyname 0x26c, a155, a2 + callruntime.wideldsendablevar 0x0, 0x9b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass156 + mov v1, v0 + newobjrange 0x26e, 0x1, v1 + stobjbyname 0x270, a156, a2 + callruntime.wideldsendablevar 0x0, 0x9c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass157 + mov v1, v0 + newobjrange 0x272, 0x1, v1 + stobjbyname 0x274, a157, a2 + callruntime.wideldsendablevar 0x0, 0x9d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass158 + mov v1, v0 + newobjrange 0x276, 0x1, v1 + stobjbyname 0x278, a158, a2 + callruntime.wideldsendablevar 0x0, 0x9e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass159 + mov v1, v0 + newobjrange 0x27a, 0x1, v1 + stobjbyname 0x27c, a159, a2 + callruntime.wideldsendablevar 0x0, 0x9f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass160 + mov v1, v0 + newobjrange 0x27e, 0x1, v1 + stobjbyname 0x280, a160, a2 + callruntime.wideldsendablevar 0x0, 0xa0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass161 + mov v1, v0 + newobjrange 0x282, 0x1, v1 + stobjbyname 0x284, a161, a2 + callruntime.wideldsendablevar 0x0, 0xa1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass162 + mov v1, v0 + newobjrange 0x286, 0x1, v1 + stobjbyname 0x288, a162, a2 + callruntime.wideldsendablevar 0x0, 0xa2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass163 + mov v1, v0 + newobjrange 0x28a, 0x1, v1 + stobjbyname 0x28c, a163, a2 + callruntime.wideldsendablevar 0x0, 0xa3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass164 + mov v1, v0 + newobjrange 0x28e, 0x1, v1 + stobjbyname 0x290, a164, a2 + callruntime.wideldsendablevar 0x0, 0xa4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass165 + mov v1, v0 + newobjrange 0x292, 0x1, v1 + stobjbyname 0x294, a165, a2 + callruntime.wideldsendablevar 0x0, 0xa5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass166 + mov v1, v0 + newobjrange 0x296, 0x1, v1 + stobjbyname 0x298, a166, a2 + callruntime.wideldsendablevar 0x0, 0xa6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass167 + mov v1, v0 + newobjrange 0x29a, 0x1, v1 + stobjbyname 0x29c, a167, a2 + callruntime.wideldsendablevar 0x0, 0xa7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass168 + mov v1, v0 + newobjrange 0x29e, 0x1, v1 + stobjbyname 0x2a0, a168, a2 + callruntime.wideldsendablevar 0x0, 0xa8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass169 + mov v1, v0 + newobjrange 0x2a2, 0x1, v1 + stobjbyname 0x2a4, a169, a2 + callruntime.wideldsendablevar 0x0, 0xa9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass170 + mov v1, v0 + newobjrange 0x2a6, 0x1, v1 + stobjbyname 0x2a8, a170, a2 + callruntime.wideldsendablevar 0x0, 0xaa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass171 + mov v1, v0 + newobjrange 0x2aa, 0x1, v1 + stobjbyname 0x2ac, a171, a2 + callruntime.wideldsendablevar 0x0, 0xab + sta v0 + throw.undefinedifholewithname TopLevelSendableClass172 + mov v1, v0 + newobjrange 0x2ae, 0x1, v1 + stobjbyname 0x2b0, a172, a2 + callruntime.wideldsendablevar 0x0, 0xac + sta v0 + throw.undefinedifholewithname TopLevelSendableClass173 + mov v1, v0 + newobjrange 0x2b2, 0x1, v1 + stobjbyname 0x2b4, a173, a2 + callruntime.wideldsendablevar 0x0, 0xad + sta v0 + throw.undefinedifholewithname TopLevelSendableClass174 + mov v1, v0 + newobjrange 0x2b6, 0x1, v1 + stobjbyname 0x2b8, a174, a2 + callruntime.wideldsendablevar 0x0, 0xae + sta v0 + throw.undefinedifholewithname TopLevelSendableClass175 + mov v1, v0 + newobjrange 0x2ba, 0x1, v1 + stobjbyname 0x2bc, a175, a2 + callruntime.wideldsendablevar 0x0, 0xaf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass176 + mov v1, v0 + newobjrange 0x2be, 0x1, v1 + stobjbyname 0x2c0, a176, a2 + callruntime.wideldsendablevar 0x0, 0xb0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass177 + mov v1, v0 + newobjrange 0x2c2, 0x1, v1 + stobjbyname 0x2c4, a177, a2 + callruntime.wideldsendablevar 0x0, 0xb1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass178 + mov v1, v0 + newobjrange 0x2c6, 0x1, v1 + stobjbyname 0x2c8, a178, a2 + callruntime.wideldsendablevar 0x0, 0xb2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass179 + mov v1, v0 + newobjrange 0x2ca, 0x1, v1 + stobjbyname 0x2cc, a179, a2 + callruntime.wideldsendablevar 0x0, 0xb3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass180 + mov v1, v0 + newobjrange 0x2ce, 0x1, v1 + stobjbyname 0x2d0, a180, a2 + callruntime.wideldsendablevar 0x0, 0xb4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass181 + mov v1, v0 + newobjrange 0x2d2, 0x1, v1 + stobjbyname 0x2d4, a181, a2 + callruntime.wideldsendablevar 0x0, 0xb5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass182 + mov v1, v0 + newobjrange 0x2d6, 0x1, v1 + stobjbyname 0x2d8, a182, a2 + callruntime.wideldsendablevar 0x0, 0xb6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass183 + mov v1, v0 + newobjrange 0x2da, 0x1, v1 + stobjbyname 0x2dc, a183, a2 + callruntime.wideldsendablevar 0x0, 0xb7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass184 + mov v1, v0 + newobjrange 0x2de, 0x1, v1 + stobjbyname 0x2e0, a184, a2 + callruntime.wideldsendablevar 0x0, 0xb8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass185 + mov v1, v0 + newobjrange 0x2e2, 0x1, v1 + stobjbyname 0x2e4, a185, a2 + callruntime.wideldsendablevar 0x0, 0xb9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass186 + mov v1, v0 + newobjrange 0x2e6, 0x1, v1 + stobjbyname 0x2e8, a186, a2 + callruntime.wideldsendablevar 0x0, 0xba + sta v0 + throw.undefinedifholewithname TopLevelSendableClass187 + mov v1, v0 + newobjrange 0x2ea, 0x1, v1 + stobjbyname 0x2ec, a187, a2 + callruntime.wideldsendablevar 0x0, 0xbb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass188 + mov v1, v0 + newobjrange 0x2ee, 0x1, v1 + stobjbyname 0x2f0, a188, a2 + callruntime.wideldsendablevar 0x0, 0xbc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass189 + mov v1, v0 + newobjrange 0x2f2, 0x1, v1 + stobjbyname 0x2f4, a189, a2 + callruntime.wideldsendablevar 0x0, 0xbd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass190 + mov v1, v0 + newobjrange 0x2f6, 0x1, v1 + stobjbyname 0x2f8, a190, a2 + callruntime.wideldsendablevar 0x0, 0xbe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass191 + mov v1, v0 + newobjrange 0x2fa, 0x1, v1 + stobjbyname 0x2fc, a191, a2 + callruntime.wideldsendablevar 0x0, 0xbf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass192 + mov v1, v0 + newobjrange 0x2fe, 0x1, v1 + stobjbyname 0x300, a192, a2 + callruntime.wideldsendablevar 0x0, 0xc0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass193 + mov v1, v0 + newobjrange 0x302, 0x1, v1 + stobjbyname 0x304, a193, a2 + callruntime.wideldsendablevar 0x0, 0xc1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass194 + mov v1, v0 + newobjrange 0x306, 0x1, v1 + stobjbyname 0x308, a194, a2 + callruntime.wideldsendablevar 0x0, 0xc2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass195 + mov v1, v0 + newobjrange 0x30a, 0x1, v1 + stobjbyname 0x30c, a195, a2 + callruntime.wideldsendablevar 0x0, 0xc3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass196 + mov v1, v0 + newobjrange 0x30e, 0x1, v1 + stobjbyname 0x310, a196, a2 + callruntime.wideldsendablevar 0x0, 0xc4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass197 + mov v1, v0 + newobjrange 0x312, 0x1, v1 + stobjbyname 0x314, a197, a2 + callruntime.wideldsendablevar 0x0, 0xc5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass198 + mov v1, v0 + newobjrange 0x316, 0x1, v1 + stobjbyname 0x318, a198, a2 + callruntime.wideldsendablevar 0x0, 0xc6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass199 + mov v1, v0 + newobjrange 0x31a, 0x1, v1 + stobjbyname 0x31c, a199, a2 + callruntime.wideldsendablevar 0x0, 0xc7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass200 + mov v1, v0 + newobjrange 0x31e, 0x1, v1 + stobjbyname 0x320, a200, a2 + callruntime.wideldsendablevar 0x0, 0xc8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass201 + mov v1, v0 + newobjrange 0x322, 0x1, v1 + stobjbyname 0x324, a201, a2 + callruntime.wideldsendablevar 0x0, 0xc9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass202 + mov v1, v0 + newobjrange 0x326, 0x1, v1 + stobjbyname 0x328, a202, a2 + callruntime.wideldsendablevar 0x0, 0xca + sta v0 + throw.undefinedifholewithname TopLevelSendableClass203 + mov v1, v0 + newobjrange 0x32a, 0x1, v1 + stobjbyname 0x32c, a203, a2 + callruntime.wideldsendablevar 0x0, 0xcb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass204 + mov v1, v0 + newobjrange 0x32e, 0x1, v1 + stobjbyname 0x330, a204, a2 + callruntime.wideldsendablevar 0x0, 0xcc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass205 + mov v1, v0 + newobjrange 0x332, 0x1, v1 + stobjbyname 0x334, a205, a2 + callruntime.wideldsendablevar 0x0, 0xcd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass206 + mov v1, v0 + newobjrange 0x336, 0x1, v1 + stobjbyname 0x338, a206, a2 + callruntime.wideldsendablevar 0x0, 0xce + sta v0 + throw.undefinedifholewithname TopLevelSendableClass207 + mov v1, v0 + newobjrange 0x33a, 0x1, v1 + stobjbyname 0x33c, a207, a2 + callruntime.wideldsendablevar 0x0, 0xcf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass208 + mov v1, v0 + newobjrange 0x33e, 0x1, v1 + stobjbyname 0x340, a208, a2 + callruntime.wideldsendablevar 0x0, 0xd0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass209 + mov v1, v0 + newobjrange 0x342, 0x1, v1 + stobjbyname 0x344, a209, a2 + callruntime.wideldsendablevar 0x0, 0xd1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass210 + mov v1, v0 + newobjrange 0x346, 0x1, v1 + stobjbyname 0x348, a210, a2 + callruntime.wideldsendablevar 0x0, 0xd2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass211 + mov v1, v0 + newobjrange 0x34a, 0x1, v1 + stobjbyname 0x34c, a211, a2 + callruntime.wideldsendablevar 0x0, 0xd3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass212 + mov v1, v0 + newobjrange 0x34e, 0x1, v1 + stobjbyname 0x350, a212, a2 + callruntime.wideldsendablevar 0x0, 0xd4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass213 + mov v1, v0 + newobjrange 0x352, 0x1, v1 + stobjbyname 0x354, a213, a2 + callruntime.wideldsendablevar 0x0, 0xd5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass214 + mov v1, v0 + newobjrange 0x356, 0x1, v1 + stobjbyname 0x358, a214, a2 + callruntime.wideldsendablevar 0x0, 0xd6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass215 + mov v1, v0 + newobjrange 0x35a, 0x1, v1 + stobjbyname 0x35c, a215, a2 + callruntime.wideldsendablevar 0x0, 0xd7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass216 + mov v1, v0 + newobjrange 0x35e, 0x1, v1 + stobjbyname 0x360, a216, a2 + callruntime.wideldsendablevar 0x0, 0xd8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass217 + mov v1, v0 + newobjrange 0x362, 0x1, v1 + stobjbyname 0x364, a217, a2 + callruntime.wideldsendablevar 0x0, 0xd9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass218 + mov v1, v0 + newobjrange 0x366, 0x1, v1 + stobjbyname 0x368, a218, a2 + callruntime.wideldsendablevar 0x0, 0xda + sta v0 + throw.undefinedifholewithname TopLevelSendableClass219 + mov v1, v0 + newobjrange 0x36a, 0x1, v1 + stobjbyname 0x36c, a219, a2 + callruntime.wideldsendablevar 0x0, 0xdb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass220 + mov v1, v0 + newobjrange 0x36e, 0x1, v1 + stobjbyname 0x370, a220, a2 + callruntime.wideldsendablevar 0x0, 0xdc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass221 + mov v1, v0 + newobjrange 0x372, 0x1, v1 + stobjbyname 0x374, a221, a2 + callruntime.wideldsendablevar 0x0, 0xdd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass222 + mov v1, v0 + newobjrange 0x376, 0x1, v1 + stobjbyname 0x378, a222, a2 + callruntime.wideldsendablevar 0x0, 0xde + sta v0 + throw.undefinedifholewithname TopLevelSendableClass223 + mov v1, v0 + newobjrange 0x37a, 0x1, v1 + stobjbyname 0x37c, a223, a2 + callruntime.wideldsendablevar 0x0, 0xdf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass224 + mov v1, v0 + newobjrange 0x37e, 0x1, v1 + stobjbyname 0x380, a224, a2 + callruntime.wideldsendablevar 0x0, 0xe0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass225 + mov v1, v0 + newobjrange 0x382, 0x1, v1 + stobjbyname 0x384, a225, a2 + callruntime.wideldsendablevar 0x0, 0xe1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass226 + mov v1, v0 + newobjrange 0x386, 0x1, v1 + stobjbyname 0x388, a226, a2 + callruntime.wideldsendablevar 0x0, 0xe2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass227 + mov v1, v0 + newobjrange 0x38a, 0x1, v1 + stobjbyname 0x38c, a227, a2 + callruntime.wideldsendablevar 0x0, 0xe3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass228 + mov v1, v0 + newobjrange 0x38e, 0x1, v1 + stobjbyname 0x390, a228, a2 + callruntime.wideldsendablevar 0x0, 0xe4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass229 + mov v1, v0 + newobjrange 0x392, 0x1, v1 + stobjbyname 0x394, a229, a2 + callruntime.wideldsendablevar 0x0, 0xe5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass230 + mov v1, v0 + newobjrange 0x396, 0x1, v1 + stobjbyname 0x398, a230, a2 + callruntime.wideldsendablevar 0x0, 0xe6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass231 + mov v1, v0 + newobjrange 0x39a, 0x1, v1 + stobjbyname 0x39c, a231, a2 + callruntime.wideldsendablevar 0x0, 0xe7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass232 + mov v1, v0 + newobjrange 0x39e, 0x1, v1 + stobjbyname 0x3a0, a232, a2 + callruntime.wideldsendablevar 0x0, 0xe8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass233 + mov v1, v0 + newobjrange 0x3a2, 0x1, v1 + stobjbyname 0x3a4, a233, a2 + callruntime.wideldsendablevar 0x0, 0xe9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass234 + mov v1, v0 + newobjrange 0x3a6, 0x1, v1 + stobjbyname 0x3a8, a234, a2 + callruntime.wideldsendablevar 0x0, 0xea + sta v0 + throw.undefinedifholewithname TopLevelSendableClass235 + mov v1, v0 + newobjrange 0x3aa, 0x1, v1 + stobjbyname 0x3ac, a235, a2 + callruntime.wideldsendablevar 0x0, 0xeb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass236 + mov v1, v0 + newobjrange 0x3ae, 0x1, v1 + stobjbyname 0x3b0, a236, a2 + callruntime.wideldsendablevar 0x0, 0xec + sta v0 + throw.undefinedifholewithname TopLevelSendableClass237 + mov v1, v0 + newobjrange 0x3b2, 0x1, v1 + stobjbyname 0x3b4, a237, a2 + callruntime.wideldsendablevar 0x0, 0xed + sta v0 + throw.undefinedifholewithname TopLevelSendableClass238 + mov v1, v0 + newobjrange 0x3b6, 0x1, v1 + stobjbyname 0x3b8, a238, a2 + callruntime.wideldsendablevar 0x0, 0xee + sta v0 + throw.undefinedifholewithname TopLevelSendableClass239 + mov v1, v0 + newobjrange 0x3ba, 0x1, v1 + stobjbyname 0x3bc, a239, a2 + callruntime.wideldsendablevar 0x0, 0xef + sta v0 + throw.undefinedifholewithname TopLevelSendableClass240 + mov v1, v0 + newobjrange 0x3be, 0x1, v1 + stobjbyname 0x3c0, a240, a2 + callruntime.wideldsendablevar 0x0, 0xf0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass241 + mov v1, v0 + newobjrange 0x3c2, 0x1, v1 + stobjbyname 0x3c4, a241, a2 + callruntime.wideldsendablevar 0x0, 0xf1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass242 + mov v1, v0 + newobjrange 0x3c6, 0x1, v1 + stobjbyname 0x3c8, a242, a2 + callruntime.wideldsendablevar 0x0, 0xf2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass243 + mov v1, v0 + newobjrange 0x3ca, 0x1, v1 + stobjbyname 0x3cc, a243, a2 + callruntime.wideldsendablevar 0x0, 0xf3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass244 + mov v1, v0 + newobjrange 0x3ce, 0x1, v1 + stobjbyname 0x3d0, a244, a2 + callruntime.wideldsendablevar 0x0, 0xf4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass245 + mov v1, v0 + newobjrange 0x3d2, 0x1, v1 + stobjbyname 0x3d4, a245, a2 + callruntime.wideldsendablevar 0x0, 0xf5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass246 + mov v1, v0 + newobjrange 0x3d6, 0x1, v1 + stobjbyname 0x3d8, a246, a2 + callruntime.wideldsendablevar 0x0, 0xf6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass247 + mov v1, v0 + newobjrange 0x3da, 0x1, v1 + stobjbyname 0x3dc, a247, a2 + callruntime.wideldsendablevar 0x0, 0xf7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass248 + mov v1, v0 + newobjrange 0x3de, 0x1, v1 + stobjbyname 0x3e0, a248, a2 + callruntime.wideldsendablevar 0x0, 0xf8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass249 + mov v1, v0 + newobjrange 0x3e2, 0x1, v1 + stobjbyname 0x3e4, a249, a2 + callruntime.wideldsendablevar 0x0, 0xf9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass250 + mov v1, v0 + newobjrange 0x3e6, 0x1, v1 + stobjbyname 0x3e8, a250, a2 + callruntime.wideldsendablevar 0x0, 0xfa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass251 + mov v1, v0 + newobjrange 0x3ea, 0x1, v1 + stobjbyname 0x3ec, a251, a2 + callruntime.wideldsendablevar 0x0, 0xfb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass252 + mov v1, v0 + newobjrange 0x3ee, 0x1, v1 + stobjbyname 0x3f0, a252, a2 + callruntime.wideldsendablevar 0x0, 0xfc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass253 + mov v1, v0 + newobjrange 0x3f2, 0x1, v1 + stobjbyname 0x3f4, a253, a2 + callruntime.wideldsendablevar 0x0, 0xfd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass254 + mov v1, v0 + newobjrange 0x3f6, 0x1, v1 + stobjbyname 0x3f8, a254, a2 + callruntime.wideldsendablevar 0x0, 0xfe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass255 + mov v1, v0 + newobjrange 0x3fa, 0x1, v1 + stobjbyname 0x3fc, a255, a2 + lda a2 + ldobjbyname 0x3fe, a1 + ldobjbyname 0x400, o + stobjbyname 0x402, u, a2 + lda.str wide_sendable_test + stobjbyname 0x404, v, a2 + lda a2 + return +label_2: +} + +slotNum = 0x108 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.widenewsendableenv 0xff + ldhole + sta v0 + callruntime.definesendableclass 0x2, .#~@0=#TopLevelSendableClass1, _3, 0x0, v0 + callruntime.stsendablevar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x3, .#~@1=#TopLevelSendableClass2, _5, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x4, .#~@2=#TopLevelSendableClass3, _7, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2 + ldhole + sta v0 + callruntime.definesendableclass 0x5, .#~@3=#TopLevelSendableClass4, _9, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3 + ldhole + sta v0 + callruntime.definesendableclass 0x6, .#~@4=#TopLevelSendableClass5, _11, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4 + ldhole + sta v0 + callruntime.definesendableclass 0x7, .#~@5=#TopLevelSendableClass6, _13, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5 + ldhole + sta v0 + callruntime.definesendableclass 0x8, .#~@6=#TopLevelSendableClass7, _15, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6 + ldhole + sta v0 + callruntime.definesendableclass 0x9, .#~@7=#TopLevelSendableClass8, _17, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7 + ldhole + sta v0 + callruntime.definesendableclass 0xa, .#~@8=#TopLevelSendableClass9, _19, 0x0, v0 + callruntime.stsendablevar 0x0, 0x8 + ldhole + sta v0 + callruntime.definesendableclass 0xb, .#~@9=#TopLevelSendableClass10, _21, 0x0, v0 + callruntime.stsendablevar 0x0, 0x9 + ldhole + sta v0 + callruntime.definesendableclass 0xc, .#~@a=#TopLevelSendableClass11, _23, 0x0, v0 + callruntime.stsendablevar 0x0, 0xa + ldhole + sta v0 + callruntime.definesendableclass 0xd, .#~@b=#TopLevelSendableClass12, _25, 0x0, v0 + callruntime.stsendablevar 0x0, 0xb + ldhole + sta v0 + callruntime.definesendableclass 0xe, .#~@c=#TopLevelSendableClass13, _27, 0x0, v0 + callruntime.stsendablevar 0x0, 0xc + ldhole + sta v0 + callruntime.definesendableclass 0xf, .#~@d=#TopLevelSendableClass14, _29, 0x0, v0 + callruntime.stsendablevar 0x0, 0xd + ldhole + sta v0 + callruntime.definesendableclass 0x10, .#~@e=#TopLevelSendableClass15, _31, 0x0, v0 + callruntime.stsendablevar 0x0, 0xe + ldhole + sta v0 + callruntime.definesendableclass 0x11, .#~@f=#TopLevelSendableClass16, _33, 0x0, v0 + callruntime.stsendablevar 0x0, 0xf + ldhole + sta v0 + callruntime.definesendableclass 0x12, .#~@10=#TopLevelSendableClass17, _35, 0x0, v0 + callruntime.stsendablevar 0x0, 0x10 + ldhole + sta v0 + callruntime.definesendableclass 0x13, .#~@11=#TopLevelSendableClass18, _37, 0x0, v0 + callruntime.stsendablevar 0x0, 0x11 + ldhole + sta v0 + callruntime.definesendableclass 0x14, .#~@12=#TopLevelSendableClass19, _39, 0x0, v0 + callruntime.stsendablevar 0x0, 0x12 + ldhole + sta v0 + callruntime.definesendableclass 0x15, .#~@13=#TopLevelSendableClass20, _41, 0x0, v0 + callruntime.stsendablevar 0x0, 0x13 + ldhole + sta v0 + callruntime.definesendableclass 0x16, .#~@14=#TopLevelSendableClass21, _43, 0x0, v0 + callruntime.stsendablevar 0x0, 0x14 + ldhole + sta v0 + callruntime.definesendableclass 0x17, .#~@15=#TopLevelSendableClass22, _45, 0x0, v0 + callruntime.stsendablevar 0x0, 0x15 + ldhole + sta v0 + callruntime.definesendableclass 0x18, .#~@16=#TopLevelSendableClass23, _47, 0x0, v0 + callruntime.stsendablevar 0x0, 0x16 + ldhole + sta v0 + callruntime.definesendableclass 0x19, .#~@17=#TopLevelSendableClass24, _49, 0x0, v0 + callruntime.stsendablevar 0x0, 0x17 + ldhole + sta v0 + callruntime.definesendableclass 0x1a, .#~@18=#TopLevelSendableClass25, _51, 0x0, v0 + callruntime.stsendablevar 0x0, 0x18 + ldhole + sta v0 + callruntime.definesendableclass 0x1b, .#~@19=#TopLevelSendableClass26, _53, 0x0, v0 + callruntime.stsendablevar 0x0, 0x19 + ldhole + sta v0 + callruntime.definesendableclass 0x1c, .#~@1a=#TopLevelSendableClass27, _55, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1a + ldhole + sta v0 + callruntime.definesendableclass 0x1d, .#~@1b=#TopLevelSendableClass28, _57, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1b + ldhole + sta v0 + callruntime.definesendableclass 0x1e, .#~@1c=#TopLevelSendableClass29, _59, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1c + ldhole + sta v0 + callruntime.definesendableclass 0x1f, .#~@1d=#TopLevelSendableClass30, _61, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1d + ldhole + sta v0 + callruntime.definesendableclass 0x20, .#~@1e=#TopLevelSendableClass31, _63, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1e + ldhole + sta v0 + callruntime.definesendableclass 0x21, .#~@1f=#TopLevelSendableClass32, _65, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1f + ldhole + sta v0 + callruntime.definesendableclass 0x22, .#~@20=#TopLevelSendableClass33, _67, 0x0, v0 + callruntime.stsendablevar 0x0, 0x20 + ldhole + sta v0 + callruntime.definesendableclass 0x23, .#~@21=#TopLevelSendableClass34, _69, 0x0, v0 + callruntime.stsendablevar 0x0, 0x21 + ldhole + sta v0 + callruntime.definesendableclass 0x24, .#~@22=#TopLevelSendableClass35, _71, 0x0, v0 + callruntime.stsendablevar 0x0, 0x22 + ldhole + sta v0 + callruntime.definesendableclass 0x25, .#~@23=#TopLevelSendableClass36, _73, 0x0, v0 + callruntime.stsendablevar 0x0, 0x23 + ldhole + sta v0 + callruntime.definesendableclass 0x26, .#~@24=#TopLevelSendableClass37, _75, 0x0, v0 + callruntime.stsendablevar 0x0, 0x24 + ldhole + sta v0 + callruntime.definesendableclass 0x27, .#~@25=#TopLevelSendableClass38, _77, 0x0, v0 + callruntime.stsendablevar 0x0, 0x25 + ldhole + sta v0 + callruntime.definesendableclass 0x28, .#~@26=#TopLevelSendableClass39, _79, 0x0, v0 + callruntime.stsendablevar 0x0, 0x26 + ldhole + sta v0 + callruntime.definesendableclass 0x29, .#~@27=#TopLevelSendableClass40, _81, 0x0, v0 + callruntime.stsendablevar 0x0, 0x27 + ldhole + sta v0 + callruntime.definesendableclass 0x2a, .#~@28=#TopLevelSendableClass41, _83, 0x0, v0 + callruntime.stsendablevar 0x0, 0x28 + ldhole + sta v0 + callruntime.definesendableclass 0x2b, .#~@29=#TopLevelSendableClass42, _85, 0x0, v0 + callruntime.stsendablevar 0x0, 0x29 + ldhole + sta v0 + callruntime.definesendableclass 0x2c, .#~@2a=#TopLevelSendableClass43, _87, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2a + ldhole + sta v0 + callruntime.definesendableclass 0x2d, .#~@2b=#TopLevelSendableClass44, _89, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2b + ldhole + sta v0 + callruntime.definesendableclass 0x2e, .#~@2c=#TopLevelSendableClass45, _91, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2c + ldhole + sta v0 + callruntime.definesendableclass 0x2f, .#~@2d=#TopLevelSendableClass46, _93, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2d + ldhole + sta v0 + callruntime.definesendableclass 0x30, .#~@2e=#TopLevelSendableClass47, _95, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2e + ldhole + sta v0 + callruntime.definesendableclass 0x31, .#~@2f=#TopLevelSendableClass48, _97, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2f + ldhole + sta v0 + callruntime.definesendableclass 0x32, .#~@30=#TopLevelSendableClass49, _99, 0x0, v0 + callruntime.stsendablevar 0x0, 0x30 + ldhole + sta v0 + callruntime.definesendableclass 0x33, .#~@31=#TopLevelSendableClass50, _101, 0x0, v0 + callruntime.stsendablevar 0x0, 0x31 + ldhole + sta v0 + callruntime.definesendableclass 0x34, .#~@32=#TopLevelSendableClass51, _103, 0x0, v0 + callruntime.stsendablevar 0x0, 0x32 + ldhole + sta v0 + callruntime.definesendableclass 0x35, .#~@33=#TopLevelSendableClass52, _105, 0x0, v0 + callruntime.stsendablevar 0x0, 0x33 + ldhole + sta v0 + callruntime.definesendableclass 0x36, .#~@34=#TopLevelSendableClass53, _107, 0x0, v0 + callruntime.stsendablevar 0x0, 0x34 + ldhole + sta v0 + callruntime.definesendableclass 0x37, .#~@35=#TopLevelSendableClass54, _109, 0x0, v0 + callruntime.stsendablevar 0x0, 0x35 + ldhole + sta v0 + callruntime.definesendableclass 0x38, .#~@36=#TopLevelSendableClass55, _111, 0x0, v0 + callruntime.stsendablevar 0x0, 0x36 + ldhole + sta v0 + callruntime.definesendableclass 0x39, .#~@37=#TopLevelSendableClass56, _113, 0x0, v0 + callruntime.stsendablevar 0x0, 0x37 + ldhole + sta v0 + callruntime.definesendableclass 0x3a, .#~@38=#TopLevelSendableClass57, _115, 0x0, v0 + callruntime.stsendablevar 0x0, 0x38 + ldhole + sta v0 + callruntime.definesendableclass 0x3b, .#~@39=#TopLevelSendableClass58, _117, 0x0, v0 + callruntime.stsendablevar 0x0, 0x39 + ldhole + sta v0 + callruntime.definesendableclass 0x3c, .#~@3a=#TopLevelSendableClass59, _119, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3a + ldhole + sta v0 + callruntime.definesendableclass 0x3d, .#~@3b=#TopLevelSendableClass60, _121, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3b + ldhole + sta v0 + callruntime.definesendableclass 0x3e, .#~@3c=#TopLevelSendableClass61, _123, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3c + ldhole + sta v0 + callruntime.definesendableclass 0x3f, .#~@3d=#TopLevelSendableClass62, _125, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3d + ldhole + sta v0 + callruntime.definesendableclass 0x40, .#~@3e=#TopLevelSendableClass63, _127, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3e + ldhole + sta v0 + callruntime.definesendableclass 0x41, .#~@3f=#TopLevelSendableClass64, _129, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3f + ldhole + sta v0 + callruntime.definesendableclass 0x42, .#~@40=#TopLevelSendableClass65, _131, 0x0, v0 + callruntime.stsendablevar 0x0, 0x40 + ldhole + sta v0 + callruntime.definesendableclass 0x43, .#~@41=#TopLevelSendableClass66, _133, 0x0, v0 + callruntime.stsendablevar 0x0, 0x41 + ldhole + sta v0 + callruntime.definesendableclass 0x44, .#~@42=#TopLevelSendableClass67, _135, 0x0, v0 + callruntime.stsendablevar 0x0, 0x42 + ldhole + sta v0 + callruntime.definesendableclass 0x45, .#~@43=#TopLevelSendableClass68, _137, 0x0, v0 + callruntime.stsendablevar 0x0, 0x43 + ldhole + sta v0 + callruntime.definesendableclass 0x46, .#~@44=#TopLevelSendableClass69, _139, 0x0, v0 + callruntime.stsendablevar 0x0, 0x44 + ldhole + sta v0 + callruntime.definesendableclass 0x47, .#~@45=#TopLevelSendableClass70, _141, 0x0, v0 + callruntime.stsendablevar 0x0, 0x45 + ldhole + sta v0 + callruntime.definesendableclass 0x48, .#~@46=#TopLevelSendableClass71, _143, 0x0, v0 + callruntime.stsendablevar 0x0, 0x46 + ldhole + sta v0 + callruntime.definesendableclass 0x49, .#~@47=#TopLevelSendableClass72, _145, 0x0, v0 + callruntime.stsendablevar 0x0, 0x47 + ldhole + sta v0 + callruntime.definesendableclass 0x4a, .#~@48=#TopLevelSendableClass73, _147, 0x0, v0 + callruntime.stsendablevar 0x0, 0x48 + ldhole + sta v0 + callruntime.definesendableclass 0x4b, .#~@49=#TopLevelSendableClass74, _149, 0x0, v0 + callruntime.stsendablevar 0x0, 0x49 + ldhole + sta v0 + callruntime.definesendableclass 0x4c, .#~@4a=#TopLevelSendableClass75, _151, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4a + ldhole + sta v0 + callruntime.definesendableclass 0x4d, .#~@4b=#TopLevelSendableClass76, _153, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4b + ldhole + sta v0 + callruntime.definesendableclass 0x4e, .#~@4c=#TopLevelSendableClass77, _155, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4c + ldhole + sta v0 + callruntime.definesendableclass 0x4f, .#~@4d=#TopLevelSendableClass78, _157, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4d + ldhole + sta v0 + callruntime.definesendableclass 0x50, .#~@4e=#TopLevelSendableClass79, _159, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4e + ldhole + sta v0 + callruntime.definesendableclass 0x51, .#~@4f=#TopLevelSendableClass80, _161, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4f + ldhole + sta v0 + callruntime.definesendableclass 0x52, .#~@50=#TopLevelSendableClass81, _163, 0x0, v0 + callruntime.stsendablevar 0x0, 0x50 + ldhole + sta v0 + callruntime.definesendableclass 0x53, .#~@51=#TopLevelSendableClass82, _165, 0x0, v0 + callruntime.stsendablevar 0x0, 0x51 + ldhole + sta v0 + callruntime.definesendableclass 0x54, .#~@52=#TopLevelSendableClass83, _167, 0x0, v0 + callruntime.stsendablevar 0x0, 0x52 + ldhole + sta v0 + callruntime.definesendableclass 0x55, .#~@53=#TopLevelSendableClass84, _169, 0x0, v0 + callruntime.stsendablevar 0x0, 0x53 + ldhole + sta v0 + callruntime.definesendableclass 0x56, .#~@54=#TopLevelSendableClass85, _171, 0x0, v0 + callruntime.stsendablevar 0x0, 0x54 + ldhole + sta v0 + callruntime.definesendableclass 0x57, .#~@55=#TopLevelSendableClass86, _173, 0x0, v0 + callruntime.stsendablevar 0x0, 0x55 + ldhole + sta v0 + callruntime.definesendableclass 0x58, .#~@56=#TopLevelSendableClass87, _175, 0x0, v0 + callruntime.stsendablevar 0x0, 0x56 + ldhole + sta v0 + callruntime.definesendableclass 0x59, .#~@57=#TopLevelSendableClass88, _177, 0x0, v0 + callruntime.stsendablevar 0x0, 0x57 + ldhole + sta v0 + callruntime.definesendableclass 0x5a, .#~@58=#TopLevelSendableClass89, _179, 0x0, v0 + callruntime.stsendablevar 0x0, 0x58 + ldhole + sta v0 + callruntime.definesendableclass 0x5b, .#~@59=#TopLevelSendableClass90, _181, 0x0, v0 + callruntime.stsendablevar 0x0, 0x59 + ldhole + sta v0 + callruntime.definesendableclass 0x5c, .#~@5a=#TopLevelSendableClass91, _183, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5a + ldhole + sta v0 + callruntime.definesendableclass 0x5d, .#~@5b=#TopLevelSendableClass92, _185, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5b + ldhole + sta v0 + callruntime.definesendableclass 0x5e, .#~@5c=#TopLevelSendableClass93, _187, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5c + ldhole + sta v0 + callruntime.definesendableclass 0x5f, .#~@5d=#TopLevelSendableClass94, _189, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5d + ldhole + sta v0 + callruntime.definesendableclass 0x60, .#~@5e=#TopLevelSendableClass95, _191, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5e + ldhole + sta v0 + callruntime.definesendableclass 0x61, .#~@5f=#TopLevelSendableClass96, _193, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5f + ldhole + sta v0 + callruntime.definesendableclass 0x62, .#~@60=#TopLevelSendableClass97, _195, 0x0, v0 + callruntime.stsendablevar 0x0, 0x60 + ldhole + sta v0 + callruntime.definesendableclass 0x63, .#~@61=#TopLevelSendableClass98, _197, 0x0, v0 + callruntime.stsendablevar 0x0, 0x61 + ldhole + sta v0 + callruntime.definesendableclass 0x64, .#~@62=#TopLevelSendableClass99, _199, 0x0, v0 + callruntime.stsendablevar 0x0, 0x62 + ldhole + sta v0 + callruntime.definesendableclass 0x65, .#~@63=#TopLevelSendableClass100, _201, 0x0, v0 + callruntime.stsendablevar 0x0, 0x63 + ldhole + sta v0 + callruntime.definesendableclass 0x66, .#~@64=#TopLevelSendableClass101, _203, 0x0, v0 + callruntime.stsendablevar 0x0, 0x64 + ldhole + sta v0 + callruntime.definesendableclass 0x67, .#~@65=#TopLevelSendableClass102, _205, 0x0, v0 + callruntime.stsendablevar 0x0, 0x65 + ldhole + sta v0 + callruntime.definesendableclass 0x68, .#~@66=#TopLevelSendableClass103, _207, 0x0, v0 + callruntime.stsendablevar 0x0, 0x66 + ldhole + sta v0 + callruntime.definesendableclass 0x69, .#~@67=#TopLevelSendableClass104, _209, 0x0, v0 + callruntime.stsendablevar 0x0, 0x67 + ldhole + sta v0 + callruntime.definesendableclass 0x6a, .#~@68=#TopLevelSendableClass105, _211, 0x0, v0 + callruntime.stsendablevar 0x0, 0x68 + ldhole + sta v0 + callruntime.definesendableclass 0x6b, .#~@69=#TopLevelSendableClass106, _213, 0x0, v0 + callruntime.stsendablevar 0x0, 0x69 + ldhole + sta v0 + callruntime.definesendableclass 0x6c, .#~@6a=#TopLevelSendableClass107, _215, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6a + ldhole + sta v0 + callruntime.definesendableclass 0x6d, .#~@6b=#TopLevelSendableClass108, _217, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6b + ldhole + sta v0 + callruntime.definesendableclass 0x6e, .#~@6c=#TopLevelSendableClass109, _219, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6c + ldhole + sta v0 + callruntime.definesendableclass 0x6f, .#~@6d=#TopLevelSendableClass110, _221, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6d + ldhole + sta v0 + callruntime.definesendableclass 0x70, .#~@6e=#TopLevelSendableClass111, _223, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6e + ldhole + sta v0 + callruntime.definesendableclass 0x71, .#~@6f=#TopLevelSendableClass112, _225, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6f + ldhole + sta v0 + callruntime.definesendableclass 0x72, .#~@70=#TopLevelSendableClass113, _227, 0x0, v0 + callruntime.stsendablevar 0x0, 0x70 + ldhole + sta v0 + callruntime.definesendableclass 0x73, .#~@71=#TopLevelSendableClass114, _229, 0x0, v0 + callruntime.stsendablevar 0x0, 0x71 + ldhole + sta v0 + callruntime.definesendableclass 0x74, .#~@72=#TopLevelSendableClass115, _231, 0x0, v0 + callruntime.stsendablevar 0x0, 0x72 + ldhole + sta v0 + callruntime.definesendableclass 0x75, .#~@73=#TopLevelSendableClass116, _233, 0x0, v0 + callruntime.stsendablevar 0x0, 0x73 + ldhole + sta v0 + callruntime.definesendableclass 0x76, .#~@74=#TopLevelSendableClass117, _235, 0x0, v0 + callruntime.stsendablevar 0x0, 0x74 + ldhole + sta v0 + callruntime.definesendableclass 0x77, .#~@75=#TopLevelSendableClass118, _237, 0x0, v0 + callruntime.stsendablevar 0x0, 0x75 + ldhole + sta v0 + callruntime.definesendableclass 0x78, .#~@76=#TopLevelSendableClass119, _239, 0x0, v0 + callruntime.stsendablevar 0x0, 0x76 + ldhole + sta v0 + callruntime.definesendableclass 0x79, .#~@77=#TopLevelSendableClass120, _241, 0x0, v0 + callruntime.stsendablevar 0x0, 0x77 + ldhole + sta v0 + callruntime.definesendableclass 0x7a, .#~@78=#TopLevelSendableClass121, _243, 0x0, v0 + callruntime.stsendablevar 0x0, 0x78 + ldhole + sta v0 + callruntime.definesendableclass 0x7b, .#~@79=#TopLevelSendableClass122, _245, 0x0, v0 + callruntime.stsendablevar 0x0, 0x79 + ldhole + sta v0 + callruntime.definesendableclass 0x7c, .#~@7a=#TopLevelSendableClass123, _247, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7a + ldhole + sta v0 + callruntime.definesendableclass 0x7d, .#~@7b=#TopLevelSendableClass124, _249, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7b + ldhole + sta v0 + callruntime.definesendableclass 0x7e, .#~@7c=#TopLevelSendableClass125, _251, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7c + ldhole + sta v0 + callruntime.definesendableclass 0x7f, .#~@7d=#TopLevelSendableClass126, _253, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7d + ldhole + sta v0 + callruntime.definesendableclass 0x80, .#~@7e=#TopLevelSendableClass127, _255, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7e + ldhole + sta v0 + callruntime.definesendableclass 0x81, .#~@7f=#TopLevelSendableClass128, _257, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7f + ldhole + sta v0 + callruntime.definesendableclass 0x82, .#~@80=#TopLevelSendableClass129, _259, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x80 + ldhole + sta v0 + callruntime.definesendableclass 0x83, .#~@81=#TopLevelSendableClass130, _261, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x81 + ldhole + sta v0 + callruntime.definesendableclass 0x84, .#~@82=#TopLevelSendableClass131, _263, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x82 + ldhole + sta v0 + callruntime.definesendableclass 0x85, .#~@83=#TopLevelSendableClass132, _265, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x83 + ldhole + sta v0 + callruntime.definesendableclass 0x86, .#~@84=#TopLevelSendableClass133, _267, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x84 + ldhole + sta v0 + callruntime.definesendableclass 0x87, .#~@85=#TopLevelSendableClass134, _269, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x85 + ldhole + sta v0 + callruntime.definesendableclass 0x88, .#~@86=#TopLevelSendableClass135, _271, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x86 + ldhole + sta v0 + callruntime.definesendableclass 0x89, .#~@87=#TopLevelSendableClass136, _273, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x87 + ldhole + sta v0 + callruntime.definesendableclass 0x8a, .#~@88=#TopLevelSendableClass137, _275, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x88 + ldhole + sta v0 + callruntime.definesendableclass 0x8b, .#~@89=#TopLevelSendableClass138, _277, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x89 + ldhole + sta v0 + callruntime.definesendableclass 0x8c, .#~@8a=#TopLevelSendableClass139, _279, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8a + ldhole + sta v0 + callruntime.definesendableclass 0x8d, .#~@8b=#TopLevelSendableClass140, _281, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8b + ldhole + sta v0 + callruntime.definesendableclass 0x8e, .#~@8c=#TopLevelSendableClass141, _283, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8c + ldhole + sta v0 + callruntime.definesendableclass 0x8f, .#~@8d=#TopLevelSendableClass142, _285, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8d + ldhole + sta v0 + callruntime.definesendableclass 0x90, .#~@8e=#TopLevelSendableClass143, _287, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8e + ldhole + sta v0 + callruntime.definesendableclass 0x91, .#~@8f=#TopLevelSendableClass144, _289, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8f + ldhole + sta v0 + callruntime.definesendableclass 0x92, .#~@90=#TopLevelSendableClass145, _291, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x90 + ldhole + sta v0 + callruntime.definesendableclass 0x93, .#~@91=#TopLevelSendableClass146, _293, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x91 + ldhole + sta v0 + callruntime.definesendableclass 0x94, .#~@92=#TopLevelSendableClass147, _295, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x92 + ldhole + sta v0 + callruntime.definesendableclass 0x95, .#~@93=#TopLevelSendableClass148, _297, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x93 + ldhole + sta v0 + callruntime.definesendableclass 0x96, .#~@94=#TopLevelSendableClass149, _299, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x94 + ldhole + sta v0 + callruntime.definesendableclass 0x97, .#~@95=#TopLevelSendableClass150, _301, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x95 + ldhole + sta v0 + callruntime.definesendableclass 0x98, .#~@96=#TopLevelSendableClass151, _303, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x96 + ldhole + sta v0 + callruntime.definesendableclass 0x99, .#~@97=#TopLevelSendableClass152, _305, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x97 + ldhole + sta v0 + callruntime.definesendableclass 0x9a, .#~@98=#TopLevelSendableClass153, _307, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x98 + ldhole + sta v0 + callruntime.definesendableclass 0x9b, .#~@99=#TopLevelSendableClass154, _309, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x99 + ldhole + sta v0 + callruntime.definesendableclass 0x9c, .#~@9a=#TopLevelSendableClass155, _311, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9a + ldhole + sta v0 + callruntime.definesendableclass 0x9d, .#~@9b=#TopLevelSendableClass156, _313, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9b + ldhole + sta v0 + callruntime.definesendableclass 0x9e, .#~@9c=#TopLevelSendableClass157, _315, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9c + ldhole + sta v0 + callruntime.definesendableclass 0x9f, .#~@9d=#TopLevelSendableClass158, _317, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9d + ldhole + sta v0 + callruntime.definesendableclass 0xa0, .#~@9e=#TopLevelSendableClass159, _319, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9e + ldhole + sta v0 + callruntime.definesendableclass 0xa1, .#~@9f=#TopLevelSendableClass160, _321, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9f + ldhole + sta v0 + callruntime.definesendableclass 0xa2, .#~@a0=#TopLevelSendableClass161, _323, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa0 + ldhole + sta v0 + callruntime.definesendableclass 0xa3, .#~@a1=#TopLevelSendableClass162, _325, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa1 + ldhole + sta v0 + callruntime.definesendableclass 0xa4, .#~@a2=#TopLevelSendableClass163, _327, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa2 + ldhole + sta v0 + callruntime.definesendableclass 0xa5, .#~@a3=#TopLevelSendableClass164, _329, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa3 + ldhole + sta v0 + callruntime.definesendableclass 0xa6, .#~@a4=#TopLevelSendableClass165, _331, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa4 + ldhole + sta v0 + callruntime.definesendableclass 0xa7, .#~@a5=#TopLevelSendableClass166, _333, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa5 + ldhole + sta v0 + callruntime.definesendableclass 0xa8, .#~@a6=#TopLevelSendableClass167, _335, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa6 + ldhole + sta v0 + callruntime.definesendableclass 0xa9, .#~@a7=#TopLevelSendableClass168, _337, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa7 + ldhole + sta v0 + callruntime.definesendableclass 0xaa, .#~@a8=#TopLevelSendableClass169, _339, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa8 + ldhole + sta v0 + callruntime.definesendableclass 0xab, .#~@a9=#TopLevelSendableClass170, _341, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa9 + ldhole + sta v0 + callruntime.definesendableclass 0xac, .#~@aa=#TopLevelSendableClass171, _343, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xaa + ldhole + sta v0 + callruntime.definesendableclass 0xad, .#~@ab=#TopLevelSendableClass172, _345, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xab + ldhole + sta v0 + callruntime.definesendableclass 0xae, .#~@ac=#TopLevelSendableClass173, _347, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xac + ldhole + sta v0 + callruntime.definesendableclass 0xaf, .#~@ad=#TopLevelSendableClass174, _349, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xad + ldhole + sta v0 + callruntime.definesendableclass 0xb0, .#~@ae=#TopLevelSendableClass175, _351, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xae + ldhole + sta v0 + callruntime.definesendableclass 0xb1, .#~@af=#TopLevelSendableClass176, _353, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xaf + ldhole + sta v0 + callruntime.definesendableclass 0xb2, .#~@b0=#TopLevelSendableClass177, _355, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb0 + ldhole + sta v0 + callruntime.definesendableclass 0xb3, .#~@b1=#TopLevelSendableClass178, _357, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb1 + ldhole + sta v0 + callruntime.definesendableclass 0xb4, .#~@b2=#TopLevelSendableClass179, _359, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb2 + ldhole + sta v0 + callruntime.definesendableclass 0xb5, .#~@b3=#TopLevelSendableClass180, _361, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb3 + ldhole + sta v0 + callruntime.definesendableclass 0xb6, .#~@b4=#TopLevelSendableClass181, _363, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb4 + ldhole + sta v0 + callruntime.definesendableclass 0xb7, .#~@b5=#TopLevelSendableClass182, _365, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb5 + ldhole + sta v0 + callruntime.definesendableclass 0xb8, .#~@b6=#TopLevelSendableClass183, _367, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb6 + ldhole + sta v0 + callruntime.definesendableclass 0xb9, .#~@b7=#TopLevelSendableClass184, _369, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb7 + ldhole + sta v0 + callruntime.definesendableclass 0xba, .#~@b8=#TopLevelSendableClass185, _371, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb8 + ldhole + sta v0 + callruntime.definesendableclass 0xbb, .#~@b9=#TopLevelSendableClass186, _373, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb9 + ldhole + sta v0 + callruntime.definesendableclass 0xbc, .#~@ba=#TopLevelSendableClass187, _375, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xba + ldhole + sta v0 + callruntime.definesendableclass 0xbd, .#~@bb=#TopLevelSendableClass188, _377, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbb + ldhole + sta v0 + callruntime.definesendableclass 0xbe, .#~@bc=#TopLevelSendableClass189, _379, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbc + ldhole + sta v0 + callruntime.definesendableclass 0xbf, .#~@bd=#TopLevelSendableClass190, _381, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbd + ldhole + sta v0 + callruntime.definesendableclass 0xc0, .#~@be=#TopLevelSendableClass191, _383, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbe + ldhole + sta v0 + callruntime.definesendableclass 0xc1, .#~@bf=#TopLevelSendableClass192, _385, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbf + ldhole + sta v0 + callruntime.definesendableclass 0xc2, .#~@c0=#TopLevelSendableClass193, _387, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc0 + ldhole + sta v0 + callruntime.definesendableclass 0xc3, .#~@c1=#TopLevelSendableClass194, _389, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc1 + ldhole + sta v0 + callruntime.definesendableclass 0xc4, .#~@c2=#TopLevelSendableClass195, _391, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc2 + ldhole + sta v0 + callruntime.definesendableclass 0xc5, .#~@c3=#TopLevelSendableClass196, _393, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc3 + ldhole + sta v0 + callruntime.definesendableclass 0xc6, .#~@c4=#TopLevelSendableClass197, _395, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc4 + ldhole + sta v0 + callruntime.definesendableclass 0xc7, .#~@c5=#TopLevelSendableClass198, _397, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc5 + ldhole + sta v0 + callruntime.definesendableclass 0xc8, .#~@c6=#TopLevelSendableClass199, _399, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc6 + ldhole + sta v0 + callruntime.definesendableclass 0xc9, .#~@c7=#TopLevelSendableClass200, _401, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc7 + ldhole + sta v0 + callruntime.definesendableclass 0xca, .#~@c8=#TopLevelSendableClass201, _403, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc8 + ldhole + sta v0 + callruntime.definesendableclass 0xcb, .#~@c9=#TopLevelSendableClass202, _405, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc9 + ldhole + sta v0 + callruntime.definesendableclass 0xcc, .#~@ca=#TopLevelSendableClass203, _407, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xca + ldhole + sta v0 + callruntime.definesendableclass 0xcd, .#~@cb=#TopLevelSendableClass204, _409, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcb + ldhole + sta v0 + callruntime.definesendableclass 0xce, .#~@cc=#TopLevelSendableClass205, _411, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcc + ldhole + sta v0 + callruntime.definesendableclass 0xcf, .#~@cd=#TopLevelSendableClass206, _413, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcd + ldhole + sta v0 + callruntime.definesendableclass 0xd0, .#~@ce=#TopLevelSendableClass207, _415, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xce + ldhole + sta v0 + callruntime.definesendableclass 0xd1, .#~@cf=#TopLevelSendableClass208, _417, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcf + ldhole + sta v0 + callruntime.definesendableclass 0xd2, .#~@d0=#TopLevelSendableClass209, _419, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd0 + ldhole + sta v0 + callruntime.definesendableclass 0xd3, .#~@d1=#TopLevelSendableClass210, _421, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd1 + ldhole + sta v0 + callruntime.definesendableclass 0xd4, .#~@d2=#TopLevelSendableClass211, _423, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd2 + ldhole + sta v0 + callruntime.definesendableclass 0xd5, .#~@d3=#TopLevelSendableClass212, _425, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd3 + ldhole + sta v0 + callruntime.definesendableclass 0xd6, .#~@d4=#TopLevelSendableClass213, _427, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd4 + ldhole + sta v0 + callruntime.definesendableclass 0xd7, .#~@d5=#TopLevelSendableClass214, _429, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd5 + ldhole + sta v0 + callruntime.definesendableclass 0xd8, .#~@d6=#TopLevelSendableClass215, _431, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd6 + ldhole + sta v0 + callruntime.definesendableclass 0xd9, .#~@d7=#TopLevelSendableClass216, _433, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd7 + ldhole + sta v0 + callruntime.definesendableclass 0xda, .#~@d8=#TopLevelSendableClass217, _435, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd8 + ldhole + sta v0 + callruntime.definesendableclass 0xdb, .#~@d9=#TopLevelSendableClass218, _437, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd9 + ldhole + sta v0 + callruntime.definesendableclass 0xdc, .#~@da=#TopLevelSendableClass219, _439, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xda + ldhole + sta v0 + callruntime.definesendableclass 0xdd, .#~@db=#TopLevelSendableClass220, _441, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdb + ldhole + sta v0 + callruntime.definesendableclass 0xde, .#~@dc=#TopLevelSendableClass221, _443, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdc + ldhole + sta v0 + callruntime.definesendableclass 0xdf, .#~@dd=#TopLevelSendableClass222, _445, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdd + ldhole + sta v0 + callruntime.definesendableclass 0xe0, .#~@de=#TopLevelSendableClass223, _447, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xde + ldhole + sta v0 + callruntime.definesendableclass 0xe1, .#~@df=#TopLevelSendableClass224, _449, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdf + ldhole + sta v0 + callruntime.definesendableclass 0xe2, .#~@e0=#TopLevelSendableClass225, _451, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe0 + ldhole + sta v0 + callruntime.definesendableclass 0xe3, .#~@e1=#TopLevelSendableClass226, _453, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe1 + ldhole + sta v0 + callruntime.definesendableclass 0xe4, .#~@e2=#TopLevelSendableClass227, _455, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe2 + ldhole + sta v0 + callruntime.definesendableclass 0xe5, .#~@e3=#TopLevelSendableClass228, _457, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe3 + ldhole + sta v0 + callruntime.definesendableclass 0xe6, .#~@e4=#TopLevelSendableClass229, _459, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe4 + ldhole + sta v0 + callruntime.definesendableclass 0xe7, .#~@e5=#TopLevelSendableClass230, _461, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe5 + ldhole + sta v0 + callruntime.definesendableclass 0xe8, .#~@e6=#TopLevelSendableClass231, _463, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe6 + ldhole + sta v0 + callruntime.definesendableclass 0xe9, .#~@e7=#TopLevelSendableClass232, _465, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe7 + ldhole + sta v0 + callruntime.definesendableclass 0xea, .#~@e8=#TopLevelSendableClass233, _467, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe8 + ldhole + sta v0 + callruntime.definesendableclass 0xeb, .#~@e9=#TopLevelSendableClass234, _469, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe9 + ldhole + sta v0 + callruntime.definesendableclass 0xec, .#~@ea=#TopLevelSendableClass235, _471, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xea + ldhole + sta v0 + callruntime.definesendableclass 0xed, .#~@eb=#TopLevelSendableClass236, _473, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xeb + ldhole + sta v0 + callruntime.definesendableclass 0xee, .#~@ec=#TopLevelSendableClass237, _475, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xec + ldhole + sta v0 + callruntime.definesendableclass 0xef, .#~@ed=#TopLevelSendableClass238, _477, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xed + ldhole + sta v0 + callruntime.definesendableclass 0xf0, .#~@ee=#TopLevelSendableClass239, _479, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xee + ldhole + sta v0 + callruntime.definesendableclass 0xf1, .#~@ef=#TopLevelSendableClass240, _481, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xef + ldhole + sta v0 + callruntime.definesendableclass 0xf2, .#~@f0=#TopLevelSendableClass241, _483, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf0 + ldhole + sta v0 + callruntime.definesendableclass 0xf3, .#~@f1=#TopLevelSendableClass242, _485, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf1 + ldhole + sta v0 + callruntime.definesendableclass 0xf4, .#~@f2=#TopLevelSendableClass243, _487, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf2 + ldhole + sta v0 + callruntime.definesendableclass 0xf5, .#~@f3=#TopLevelSendableClass244, _489, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf3 + ldhole + sta v0 + callruntime.definesendableclass 0xf6, .#~@f4=#TopLevelSendableClass245, _491, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf4 + ldhole + sta v0 + callruntime.definesendableclass 0xf7, .#~@f5=#TopLevelSendableClass246, _493, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf5 + ldhole + sta v0 + callruntime.definesendableclass 0xf8, .#~@f6=#TopLevelSendableClass247, _495, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf6 + ldhole + sta v0 + callruntime.definesendableclass 0xf9, .#~@f7=#TopLevelSendableClass248, _497, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf7 + ldhole + sta v0 + callruntime.definesendableclass 0xfa, .#~@f8=#TopLevelSendableClass249, _499, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf8 + ldhole + sta v0 + callruntime.definesendableclass 0xfb, .#~@f9=#TopLevelSendableClass250, _501, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf9 + ldhole + sta v0 + callruntime.definesendableclass 0xfc, .#~@fa=#TopLevelSendableClass251, _503, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfa + ldhole + sta v0 + callruntime.definesendableclass 0xfd, .#~@fb=#TopLevelSendableClass252, _505, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfb + ldhole + sta v0 + callruntime.definesendableclass 0xfe, .#~@fc=#TopLevelSendableClass253, _507, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfc + ldhole + sta v0 + callruntime.definesendableclass 0x100, .#~@fd=#TopLevelSendableClass254, _509, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfd + ldhole + sta v0 + callruntime.definesendableclass 0x101, .#~@fe=#TopLevelSendableClass255, _511, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfe + ldhole + sta v0 + callruntime.definesendableclass 0x102, .#~@ff=#SendableTestClass1, _513, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x103, 0x1, v2 + sta v0 + tryldglobalbyname 0x105, print + sta v1 + lda v0 + ldobjbyname 0x106, v + sta v0 + lda v1 + callarg1 0x0, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt index 6cb40f7fb76e67872aeb9a7de77c205dbd96c971..6abb6478b6ef3dd027a05faf1bc024db17fc498c 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 50cd83163e1619f04dccf5fb1330d1e4e68be958..33c3a51f3e1e56de69ef1b5e5c28fb7435018554 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..33c3a51f3e1e56de69ef1b5e5c28fb7435018554 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,5651 @@ +slotNum = 0x406 +.language ECMAScript +.function any .SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + ldlexvar 0x0, 0x1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass2 + mov v1, v0 + newobjrange 0x4, 0x1, v1 + stobjbyname 0x6, a2, a2 + ldlexvar 0x0, 0x2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass3 + mov v1, v0 + newobjrange 0x8, 0x1, v1 + stobjbyname 0xa, a3, a2 + ldlexvar 0x0, 0x3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass4 + mov v1, v0 + newobjrange 0xc, 0x1, v1 + stobjbyname 0xe, a4, a2 + ldlexvar 0x0, 0x4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass5 + mov v1, v0 + newobjrange 0x10, 0x1, v1 + stobjbyname 0x12, a5, a2 + ldlexvar 0x0, 0x5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass6 + mov v1, v0 + newobjrange 0x14, 0x1, v1 + stobjbyname 0x16, a6, a2 + ldlexvar 0x0, 0x6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass7 + mov v1, v0 + newobjrange 0x18, 0x1, v1 + stobjbyname 0x1a, a7, a2 + ldlexvar 0x0, 0x7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass8 + mov v1, v0 + newobjrange 0x1c, 0x1, v1 + stobjbyname 0x1e, a8, a2 + ldlexvar 0x0, 0x8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass9 + mov v1, v0 + newobjrange 0x20, 0x1, v1 + stobjbyname 0x22, a9, a2 + ldlexvar 0x0, 0x9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass10 + mov v1, v0 + newobjrange 0x24, 0x1, v1 + stobjbyname 0x26, a10, a2 + ldlexvar 0x0, 0xa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass11 + mov v1, v0 + newobjrange 0x28, 0x1, v1 + stobjbyname 0x2a, a11, a2 + ldlexvar 0x0, 0xb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass12 + mov v1, v0 + newobjrange 0x2c, 0x1, v1 + stobjbyname 0x2e, a12, a2 + ldlexvar 0x0, 0xc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass13 + mov v1, v0 + newobjrange 0x30, 0x1, v1 + stobjbyname 0x32, a13, a2 + ldlexvar 0x0, 0xd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass14 + mov v1, v0 + newobjrange 0x34, 0x1, v1 + stobjbyname 0x36, a14, a2 + ldlexvar 0x0, 0xe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass15 + mov v1, v0 + newobjrange 0x38, 0x1, v1 + stobjbyname 0x3a, a15, a2 + ldlexvar 0x0, 0xf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass16 + mov v1, v0 + newobjrange 0x3c, 0x1, v1 + stobjbyname 0x3e, a16, a2 + ldlexvar 0x0, 0x10 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass17 + mov v1, v0 + newobjrange 0x40, 0x1, v1 + stobjbyname 0x42, a17, a2 + ldlexvar 0x0, 0x11 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass18 + mov v1, v0 + newobjrange 0x44, 0x1, v1 + stobjbyname 0x46, a18, a2 + ldlexvar 0x0, 0x12 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass19 + mov v1, v0 + newobjrange 0x48, 0x1, v1 + stobjbyname 0x4a, a19, a2 + ldlexvar 0x0, 0x13 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass20 + mov v1, v0 + newobjrange 0x4c, 0x1, v1 + stobjbyname 0x4e, a20, a2 + ldlexvar 0x0, 0x14 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass21 + mov v1, v0 + newobjrange 0x50, 0x1, v1 + stobjbyname 0x52, a21, a2 + ldlexvar 0x0, 0x15 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass22 + mov v1, v0 + newobjrange 0x54, 0x1, v1 + stobjbyname 0x56, a22, a2 + ldlexvar 0x0, 0x16 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass23 + mov v1, v0 + newobjrange 0x58, 0x1, v1 + stobjbyname 0x5a, a23, a2 + ldlexvar 0x0, 0x17 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass24 + mov v1, v0 + newobjrange 0x5c, 0x1, v1 + stobjbyname 0x5e, a24, a2 + ldlexvar 0x0, 0x18 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass25 + mov v1, v0 + newobjrange 0x60, 0x1, v1 + stobjbyname 0x62, a25, a2 + ldlexvar 0x0, 0x19 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass26 + mov v1, v0 + newobjrange 0x64, 0x1, v1 + stobjbyname 0x66, a26, a2 + ldlexvar 0x0, 0x1a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass27 + mov v1, v0 + newobjrange 0x68, 0x1, v1 + stobjbyname 0x6a, a27, a2 + ldlexvar 0x0, 0x1b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass28 + mov v1, v0 + newobjrange 0x6c, 0x1, v1 + stobjbyname 0x6e, a28, a2 + ldlexvar 0x0, 0x1c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass29 + mov v1, v0 + newobjrange 0x70, 0x1, v1 + stobjbyname 0x72, a29, a2 + ldlexvar 0x0, 0x1d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass30 + mov v1, v0 + newobjrange 0x74, 0x1, v1 + stobjbyname 0x76, a30, a2 + ldlexvar 0x0, 0x1e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass31 + mov v1, v0 + newobjrange 0x78, 0x1, v1 + stobjbyname 0x7a, a31, a2 + ldlexvar 0x0, 0x1f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass32 + mov v1, v0 + newobjrange 0x7c, 0x1, v1 + stobjbyname 0x7e, a32, a2 + ldlexvar 0x0, 0x20 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass33 + mov v1, v0 + newobjrange 0x80, 0x1, v1 + stobjbyname 0x82, a33, a2 + ldlexvar 0x0, 0x21 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass34 + mov v1, v0 + newobjrange 0x84, 0x1, v1 + stobjbyname 0x86, a34, a2 + ldlexvar 0x0, 0x22 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass35 + mov v1, v0 + newobjrange 0x88, 0x1, v1 + stobjbyname 0x8a, a35, a2 + ldlexvar 0x0, 0x23 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass36 + mov v1, v0 + newobjrange 0x8c, 0x1, v1 + stobjbyname 0x8e, a36, a2 + ldlexvar 0x0, 0x24 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass37 + mov v1, v0 + newobjrange 0x90, 0x1, v1 + stobjbyname 0x92, a37, a2 + ldlexvar 0x0, 0x25 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass38 + mov v1, v0 + newobjrange 0x94, 0x1, v1 + stobjbyname 0x96, a38, a2 + ldlexvar 0x0, 0x26 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass39 + mov v1, v0 + newobjrange 0x98, 0x1, v1 + stobjbyname 0x9a, a39, a2 + ldlexvar 0x0, 0x27 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass40 + mov v1, v0 + newobjrange 0x9c, 0x1, v1 + stobjbyname 0x9e, a40, a2 + ldlexvar 0x0, 0x28 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass41 + mov v1, v0 + newobjrange 0xa0, 0x1, v1 + stobjbyname 0xa2, a41, a2 + ldlexvar 0x0, 0x29 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass42 + mov v1, v0 + newobjrange 0xa4, 0x1, v1 + stobjbyname 0xa6, a42, a2 + ldlexvar 0x0, 0x2a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass43 + mov v1, v0 + newobjrange 0xa8, 0x1, v1 + stobjbyname 0xaa, a43, a2 + ldlexvar 0x0, 0x2b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass44 + mov v1, v0 + newobjrange 0xac, 0x1, v1 + stobjbyname 0xae, a44, a2 + ldlexvar 0x0, 0x2c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass45 + mov v1, v0 + newobjrange 0xb0, 0x1, v1 + stobjbyname 0xb2, a45, a2 + ldlexvar 0x0, 0x2d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass46 + mov v1, v0 + newobjrange 0xb4, 0x1, v1 + stobjbyname 0xb6, a46, a2 + ldlexvar 0x0, 0x2e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass47 + mov v1, v0 + newobjrange 0xb8, 0x1, v1 + stobjbyname 0xba, a47, a2 + ldlexvar 0x0, 0x2f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass48 + mov v1, v0 + newobjrange 0xbc, 0x1, v1 + stobjbyname 0xbe, a48, a2 + ldlexvar 0x0, 0x30 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass49 + mov v1, v0 + newobjrange 0xc0, 0x1, v1 + stobjbyname 0xc2, a49, a2 + ldlexvar 0x0, 0x31 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass50 + mov v1, v0 + newobjrange 0xc4, 0x1, v1 + stobjbyname 0xc6, a50, a2 + ldlexvar 0x0, 0x32 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass51 + mov v1, v0 + newobjrange 0xc8, 0x1, v1 + stobjbyname 0xca, a51, a2 + ldlexvar 0x0, 0x33 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass52 + mov v1, v0 + newobjrange 0xcc, 0x1, v1 + stobjbyname 0xce, a52, a2 + ldlexvar 0x0, 0x34 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass53 + mov v1, v0 + newobjrange 0xd0, 0x1, v1 + stobjbyname 0xd2, a53, a2 + ldlexvar 0x0, 0x35 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass54 + mov v1, v0 + newobjrange 0xd4, 0x1, v1 + stobjbyname 0xd6, a54, a2 + ldlexvar 0x0, 0x36 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass55 + mov v1, v0 + newobjrange 0xd8, 0x1, v1 + stobjbyname 0xda, a55, a2 + ldlexvar 0x0, 0x37 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass56 + mov v1, v0 + newobjrange 0xdc, 0x1, v1 + stobjbyname 0xde, a56, a2 + ldlexvar 0x0, 0x38 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass57 + mov v1, v0 + newobjrange 0xe0, 0x1, v1 + stobjbyname 0xe2, a57, a2 + ldlexvar 0x0, 0x39 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass58 + mov v1, v0 + newobjrange 0xe4, 0x1, v1 + stobjbyname 0xe6, a58, a2 + ldlexvar 0x0, 0x3a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass59 + mov v1, v0 + newobjrange 0xe8, 0x1, v1 + stobjbyname 0xea, a59, a2 + ldlexvar 0x0, 0x3b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass60 + mov v1, v0 + newobjrange 0xec, 0x1, v1 + stobjbyname 0xee, a60, a2 + ldlexvar 0x0, 0x3c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass61 + mov v1, v0 + newobjrange 0xf0, 0x1, v1 + stobjbyname 0xf2, a61, a2 + ldlexvar 0x0, 0x3d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass62 + mov v1, v0 + newobjrange 0xf4, 0x1, v1 + stobjbyname 0xf6, a62, a2 + ldlexvar 0x0, 0x3e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass63 + mov v1, v0 + newobjrange 0xf8, 0x1, v1 + stobjbyname 0xfa, a63, a2 + ldlexvar 0x0, 0x3f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass64 + mov v1, v0 + newobjrange 0xfc, 0x1, v1 + stobjbyname 0x100, a64, a2 + ldlexvar 0x0, 0x40 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass65 + mov v1, v0 + newobjrange 0x102, 0x1, v1 + stobjbyname 0x104, a65, a2 + ldlexvar 0x0, 0x41 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass66 + mov v1, v0 + newobjrange 0x106, 0x1, v1 + stobjbyname 0x108, a66, a2 + ldlexvar 0x0, 0x42 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass67 + mov v1, v0 + newobjrange 0x10a, 0x1, v1 + stobjbyname 0x10c, a67, a2 + ldlexvar 0x0, 0x43 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass68 + mov v1, v0 + newobjrange 0x10e, 0x1, v1 + stobjbyname 0x110, a68, a2 + ldlexvar 0x0, 0x44 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass69 + mov v1, v0 + newobjrange 0x112, 0x1, v1 + stobjbyname 0x114, a69, a2 + ldlexvar 0x0, 0x45 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass70 + mov v1, v0 + newobjrange 0x116, 0x1, v1 + stobjbyname 0x118, a70, a2 + ldlexvar 0x0, 0x46 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass71 + mov v1, v0 + newobjrange 0x11a, 0x1, v1 + stobjbyname 0x11c, a71, a2 + ldlexvar 0x0, 0x47 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass72 + mov v1, v0 + newobjrange 0x11e, 0x1, v1 + stobjbyname 0x120, a72, a2 + ldlexvar 0x0, 0x48 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass73 + mov v1, v0 + newobjrange 0x122, 0x1, v1 + stobjbyname 0x124, a73, a2 + ldlexvar 0x0, 0x49 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass74 + mov v1, v0 + newobjrange 0x126, 0x1, v1 + stobjbyname 0x128, a74, a2 + ldlexvar 0x0, 0x4a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass75 + mov v1, v0 + newobjrange 0x12a, 0x1, v1 + stobjbyname 0x12c, a75, a2 + ldlexvar 0x0, 0x4b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass76 + mov v1, v0 + newobjrange 0x12e, 0x1, v1 + stobjbyname 0x130, a76, a2 + ldlexvar 0x0, 0x4c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass77 + mov v1, v0 + newobjrange 0x132, 0x1, v1 + stobjbyname 0x134, a77, a2 + ldlexvar 0x0, 0x4d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass78 + mov v1, v0 + newobjrange 0x136, 0x1, v1 + stobjbyname 0x138, a78, a2 + ldlexvar 0x0, 0x4e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass79 + mov v1, v0 + newobjrange 0x13a, 0x1, v1 + stobjbyname 0x13c, a79, a2 + ldlexvar 0x0, 0x4f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass80 + mov v1, v0 + newobjrange 0x13e, 0x1, v1 + stobjbyname 0x140, a80, a2 + ldlexvar 0x0, 0x50 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass81 + mov v1, v0 + newobjrange 0x142, 0x1, v1 + stobjbyname 0x144, a81, a2 + ldlexvar 0x0, 0x51 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass82 + mov v1, v0 + newobjrange 0x146, 0x1, v1 + stobjbyname 0x148, a82, a2 + ldlexvar 0x0, 0x52 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass83 + mov v1, v0 + newobjrange 0x14a, 0x1, v1 + stobjbyname 0x14c, a83, a2 + ldlexvar 0x0, 0x53 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass84 + mov v1, v0 + newobjrange 0x14e, 0x1, v1 + stobjbyname 0x150, a84, a2 + ldlexvar 0x0, 0x54 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass85 + mov v1, v0 + newobjrange 0x152, 0x1, v1 + stobjbyname 0x154, a85, a2 + ldlexvar 0x0, 0x55 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass86 + mov v1, v0 + newobjrange 0x156, 0x1, v1 + stobjbyname 0x158, a86, a2 + ldlexvar 0x0, 0x56 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass87 + mov v1, v0 + newobjrange 0x15a, 0x1, v1 + stobjbyname 0x15c, a87, a2 + ldlexvar 0x0, 0x57 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass88 + mov v1, v0 + newobjrange 0x15e, 0x1, v1 + stobjbyname 0x160, a88, a2 + ldlexvar 0x0, 0x58 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass89 + mov v1, v0 + newobjrange 0x162, 0x1, v1 + stobjbyname 0x164, a89, a2 + ldlexvar 0x0, 0x59 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass90 + mov v1, v0 + newobjrange 0x166, 0x1, v1 + stobjbyname 0x168, a90, a2 + ldlexvar 0x0, 0x5a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass91 + mov v1, v0 + newobjrange 0x16a, 0x1, v1 + stobjbyname 0x16c, a91, a2 + ldlexvar 0x0, 0x5b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass92 + mov v1, v0 + newobjrange 0x16e, 0x1, v1 + stobjbyname 0x170, a92, a2 + ldlexvar 0x0, 0x5c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass93 + mov v1, v0 + newobjrange 0x172, 0x1, v1 + stobjbyname 0x174, a93, a2 + ldlexvar 0x0, 0x5d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass94 + mov v1, v0 + newobjrange 0x176, 0x1, v1 + stobjbyname 0x178, a94, a2 + ldlexvar 0x0, 0x5e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass95 + mov v1, v0 + newobjrange 0x17a, 0x1, v1 + stobjbyname 0x17c, a95, a2 + ldlexvar 0x0, 0x5f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass96 + mov v1, v0 + newobjrange 0x17e, 0x1, v1 + stobjbyname 0x180, a96, a2 + ldlexvar 0x0, 0x60 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass97 + mov v1, v0 + newobjrange 0x182, 0x1, v1 + stobjbyname 0x184, a97, a2 + ldlexvar 0x0, 0x61 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass98 + mov v1, v0 + newobjrange 0x186, 0x1, v1 + stobjbyname 0x188, a98, a2 + ldlexvar 0x0, 0x62 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass99 + mov v1, v0 + newobjrange 0x18a, 0x1, v1 + stobjbyname 0x18c, a99, a2 + ldlexvar 0x0, 0x63 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass100 + mov v1, v0 + newobjrange 0x18e, 0x1, v1 + stobjbyname 0x190, a100, a2 + ldlexvar 0x0, 0x64 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass101 + mov v1, v0 + newobjrange 0x192, 0x1, v1 + stobjbyname 0x194, a101, a2 + ldlexvar 0x0, 0x65 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass102 + mov v1, v0 + newobjrange 0x196, 0x1, v1 + stobjbyname 0x198, a102, a2 + ldlexvar 0x0, 0x66 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass103 + mov v1, v0 + newobjrange 0x19a, 0x1, v1 + stobjbyname 0x19c, a103, a2 + ldlexvar 0x0, 0x67 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass104 + mov v1, v0 + newobjrange 0x19e, 0x1, v1 + stobjbyname 0x1a0, a104, a2 + ldlexvar 0x0, 0x68 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass105 + mov v1, v0 + newobjrange 0x1a2, 0x1, v1 + stobjbyname 0x1a4, a105, a2 + ldlexvar 0x0, 0x69 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass106 + mov v1, v0 + newobjrange 0x1a6, 0x1, v1 + stobjbyname 0x1a8, a106, a2 + ldlexvar 0x0, 0x6a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass107 + mov v1, v0 + newobjrange 0x1aa, 0x1, v1 + stobjbyname 0x1ac, a107, a2 + ldlexvar 0x0, 0x6b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass108 + mov v1, v0 + newobjrange 0x1ae, 0x1, v1 + stobjbyname 0x1b0, a108, a2 + ldlexvar 0x0, 0x6c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass109 + mov v1, v0 + newobjrange 0x1b2, 0x1, v1 + stobjbyname 0x1b4, a109, a2 + ldlexvar 0x0, 0x6d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass110 + mov v1, v0 + newobjrange 0x1b6, 0x1, v1 + stobjbyname 0x1b8, a110, a2 + ldlexvar 0x0, 0x6e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass111 + mov v1, v0 + newobjrange 0x1ba, 0x1, v1 + stobjbyname 0x1bc, a111, a2 + ldlexvar 0x0, 0x6f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass112 + mov v1, v0 + newobjrange 0x1be, 0x1, v1 + stobjbyname 0x1c0, a112, a2 + ldlexvar 0x0, 0x70 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass113 + mov v1, v0 + newobjrange 0x1c2, 0x1, v1 + stobjbyname 0x1c4, a113, a2 + ldlexvar 0x0, 0x71 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass114 + mov v1, v0 + newobjrange 0x1c6, 0x1, v1 + stobjbyname 0x1c8, a114, a2 + ldlexvar 0x0, 0x72 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass115 + mov v1, v0 + newobjrange 0x1ca, 0x1, v1 + stobjbyname 0x1cc, a115, a2 + ldlexvar 0x0, 0x73 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass116 + mov v1, v0 + newobjrange 0x1ce, 0x1, v1 + stobjbyname 0x1d0, a116, a2 + ldlexvar 0x0, 0x74 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass117 + mov v1, v0 + newobjrange 0x1d2, 0x1, v1 + stobjbyname 0x1d4, a117, a2 + ldlexvar 0x0, 0x75 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass118 + mov v1, v0 + newobjrange 0x1d6, 0x1, v1 + stobjbyname 0x1d8, a118, a2 + ldlexvar 0x0, 0x76 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass119 + mov v1, v0 + newobjrange 0x1da, 0x1, v1 + stobjbyname 0x1dc, a119, a2 + ldlexvar 0x0, 0x77 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass120 + mov v1, v0 + newobjrange 0x1de, 0x1, v1 + stobjbyname 0x1e0, a120, a2 + ldlexvar 0x0, 0x78 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass121 + mov v1, v0 + newobjrange 0x1e2, 0x1, v1 + stobjbyname 0x1e4, a121, a2 + ldlexvar 0x0, 0x79 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass122 + mov v1, v0 + newobjrange 0x1e6, 0x1, v1 + stobjbyname 0x1e8, a122, a2 + ldlexvar 0x0, 0x7a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass123 + mov v1, v0 + newobjrange 0x1ea, 0x1, v1 + stobjbyname 0x1ec, a123, a2 + ldlexvar 0x0, 0x7b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass124 + mov v1, v0 + newobjrange 0x1ee, 0x1, v1 + stobjbyname 0x1f0, a124, a2 + ldlexvar 0x0, 0x7c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass125 + mov v1, v0 + newobjrange 0x1f2, 0x1, v1 + stobjbyname 0x1f4, a125, a2 + ldlexvar 0x0, 0x7d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass126 + mov v1, v0 + newobjrange 0x1f6, 0x1, v1 + stobjbyname 0x1f8, a126, a2 + ldlexvar 0x0, 0x7e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass127 + mov v1, v0 + newobjrange 0x1fa, 0x1, v1 + stobjbyname 0x1fc, a127, a2 + ldlexvar 0x0, 0x7f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass128 + mov v1, v0 + newobjrange 0x1fe, 0x1, v1 + stobjbyname 0x200, a128, a2 + wide.ldlexvar 0x0, 0x80 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass129 + mov v1, v0 + newobjrange 0x202, 0x1, v1 + stobjbyname 0x204, a129, a2 + wide.ldlexvar 0x0, 0x81 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass130 + mov v1, v0 + newobjrange 0x206, 0x1, v1 + stobjbyname 0x208, a130, a2 + wide.ldlexvar 0x0, 0x82 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass131 + mov v1, v0 + newobjrange 0x20a, 0x1, v1 + stobjbyname 0x20c, a131, a2 + wide.ldlexvar 0x0, 0x83 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass132 + mov v1, v0 + newobjrange 0x20e, 0x1, v1 + stobjbyname 0x210, a132, a2 + wide.ldlexvar 0x0, 0x84 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass133 + mov v1, v0 + newobjrange 0x212, 0x1, v1 + stobjbyname 0x214, a133, a2 + wide.ldlexvar 0x0, 0x85 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass134 + mov v1, v0 + newobjrange 0x216, 0x1, v1 + stobjbyname 0x218, a134, a2 + wide.ldlexvar 0x0, 0x86 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass135 + mov v1, v0 + newobjrange 0x21a, 0x1, v1 + stobjbyname 0x21c, a135, a2 + wide.ldlexvar 0x0, 0x87 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass136 + mov v1, v0 + newobjrange 0x21e, 0x1, v1 + stobjbyname 0x220, a136, a2 + wide.ldlexvar 0x0, 0x88 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass137 + mov v1, v0 + newobjrange 0x222, 0x1, v1 + stobjbyname 0x224, a137, a2 + wide.ldlexvar 0x0, 0x89 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass138 + mov v1, v0 + newobjrange 0x226, 0x1, v1 + stobjbyname 0x228, a138, a2 + wide.ldlexvar 0x0, 0x8a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass139 + mov v1, v0 + newobjrange 0x22a, 0x1, v1 + stobjbyname 0x22c, a139, a2 + wide.ldlexvar 0x0, 0x8b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass140 + mov v1, v0 + newobjrange 0x22e, 0x1, v1 + stobjbyname 0x230, a140, a2 + wide.ldlexvar 0x0, 0x8c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass141 + mov v1, v0 + newobjrange 0x232, 0x1, v1 + stobjbyname 0x234, a141, a2 + wide.ldlexvar 0x0, 0x8d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass142 + mov v1, v0 + newobjrange 0x236, 0x1, v1 + stobjbyname 0x238, a142, a2 + wide.ldlexvar 0x0, 0x8e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass143 + mov v1, v0 + newobjrange 0x23a, 0x1, v1 + stobjbyname 0x23c, a143, a2 + wide.ldlexvar 0x0, 0x8f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass144 + mov v1, v0 + newobjrange 0x23e, 0x1, v1 + stobjbyname 0x240, a144, a2 + wide.ldlexvar 0x0, 0x90 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass145 + mov v1, v0 + newobjrange 0x242, 0x1, v1 + stobjbyname 0x244, a145, a2 + wide.ldlexvar 0x0, 0x91 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass146 + mov v1, v0 + newobjrange 0x246, 0x1, v1 + stobjbyname 0x248, a146, a2 + wide.ldlexvar 0x0, 0x92 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass147 + mov v1, v0 + newobjrange 0x24a, 0x1, v1 + stobjbyname 0x24c, a147, a2 + wide.ldlexvar 0x0, 0x93 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass148 + mov v1, v0 + newobjrange 0x24e, 0x1, v1 + stobjbyname 0x250, a148, a2 + wide.ldlexvar 0x0, 0x94 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass149 + mov v1, v0 + newobjrange 0x252, 0x1, v1 + stobjbyname 0x254, a149, a2 + wide.ldlexvar 0x0, 0x95 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass150 + mov v1, v0 + newobjrange 0x256, 0x1, v1 + stobjbyname 0x258, a150, a2 + wide.ldlexvar 0x0, 0x96 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass151 + mov v1, v0 + newobjrange 0x25a, 0x1, v1 + stobjbyname 0x25c, a151, a2 + wide.ldlexvar 0x0, 0x97 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass152 + mov v1, v0 + newobjrange 0x25e, 0x1, v1 + stobjbyname 0x260, a152, a2 + wide.ldlexvar 0x0, 0x98 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass153 + mov v1, v0 + newobjrange 0x262, 0x1, v1 + stobjbyname 0x264, a153, a2 + wide.ldlexvar 0x0, 0x99 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass154 + mov v1, v0 + newobjrange 0x266, 0x1, v1 + stobjbyname 0x268, a154, a2 + wide.ldlexvar 0x0, 0x9a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass155 + mov v1, v0 + newobjrange 0x26a, 0x1, v1 + stobjbyname 0x26c, a155, a2 + wide.ldlexvar 0x0, 0x9b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass156 + mov v1, v0 + newobjrange 0x26e, 0x1, v1 + stobjbyname 0x270, a156, a2 + wide.ldlexvar 0x0, 0x9c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass157 + mov v1, v0 + newobjrange 0x272, 0x1, v1 + stobjbyname 0x274, a157, a2 + wide.ldlexvar 0x0, 0x9d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass158 + mov v1, v0 + newobjrange 0x276, 0x1, v1 + stobjbyname 0x278, a158, a2 + wide.ldlexvar 0x0, 0x9e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass159 + mov v1, v0 + newobjrange 0x27a, 0x1, v1 + stobjbyname 0x27c, a159, a2 + wide.ldlexvar 0x0, 0x9f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass160 + mov v1, v0 + newobjrange 0x27e, 0x1, v1 + stobjbyname 0x280, a160, a2 + wide.ldlexvar 0x0, 0xa0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass161 + mov v1, v0 + newobjrange 0x282, 0x1, v1 + stobjbyname 0x284, a161, a2 + wide.ldlexvar 0x0, 0xa1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass162 + mov v1, v0 + newobjrange 0x286, 0x1, v1 + stobjbyname 0x288, a162, a2 + wide.ldlexvar 0x0, 0xa2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass163 + mov v1, v0 + newobjrange 0x28a, 0x1, v1 + stobjbyname 0x28c, a163, a2 + wide.ldlexvar 0x0, 0xa3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass164 + mov v1, v0 + newobjrange 0x28e, 0x1, v1 + stobjbyname 0x290, a164, a2 + wide.ldlexvar 0x0, 0xa4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass165 + mov v1, v0 + newobjrange 0x292, 0x1, v1 + stobjbyname 0x294, a165, a2 + wide.ldlexvar 0x0, 0xa5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass166 + mov v1, v0 + newobjrange 0x296, 0x1, v1 + stobjbyname 0x298, a166, a2 + wide.ldlexvar 0x0, 0xa6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass167 + mov v1, v0 + newobjrange 0x29a, 0x1, v1 + stobjbyname 0x29c, a167, a2 + wide.ldlexvar 0x0, 0xa7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass168 + mov v1, v0 + newobjrange 0x29e, 0x1, v1 + stobjbyname 0x2a0, a168, a2 + wide.ldlexvar 0x0, 0xa8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass169 + mov v1, v0 + newobjrange 0x2a2, 0x1, v1 + stobjbyname 0x2a4, a169, a2 + wide.ldlexvar 0x0, 0xa9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass170 + mov v1, v0 + newobjrange 0x2a6, 0x1, v1 + stobjbyname 0x2a8, a170, a2 + wide.ldlexvar 0x0, 0xaa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass171 + mov v1, v0 + newobjrange 0x2aa, 0x1, v1 + stobjbyname 0x2ac, a171, a2 + wide.ldlexvar 0x0, 0xab + sta v0 + throw.undefinedifholewithname TopLevelSendableClass172 + mov v1, v0 + newobjrange 0x2ae, 0x1, v1 + stobjbyname 0x2b0, a172, a2 + wide.ldlexvar 0x0, 0xac + sta v0 + throw.undefinedifholewithname TopLevelSendableClass173 + mov v1, v0 + newobjrange 0x2b2, 0x1, v1 + stobjbyname 0x2b4, a173, a2 + wide.ldlexvar 0x0, 0xad + sta v0 + throw.undefinedifholewithname TopLevelSendableClass174 + mov v1, v0 + newobjrange 0x2b6, 0x1, v1 + stobjbyname 0x2b8, a174, a2 + wide.ldlexvar 0x0, 0xae + sta v0 + throw.undefinedifholewithname TopLevelSendableClass175 + mov v1, v0 + newobjrange 0x2ba, 0x1, v1 + stobjbyname 0x2bc, a175, a2 + wide.ldlexvar 0x0, 0xaf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass176 + mov v1, v0 + newobjrange 0x2be, 0x1, v1 + stobjbyname 0x2c0, a176, a2 + wide.ldlexvar 0x0, 0xb0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass177 + mov v1, v0 + newobjrange 0x2c2, 0x1, v1 + stobjbyname 0x2c4, a177, a2 + wide.ldlexvar 0x0, 0xb1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass178 + mov v1, v0 + newobjrange 0x2c6, 0x1, v1 + stobjbyname 0x2c8, a178, a2 + wide.ldlexvar 0x0, 0xb2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass179 + mov v1, v0 + newobjrange 0x2ca, 0x1, v1 + stobjbyname 0x2cc, a179, a2 + wide.ldlexvar 0x0, 0xb3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass180 + mov v1, v0 + newobjrange 0x2ce, 0x1, v1 + stobjbyname 0x2d0, a180, a2 + wide.ldlexvar 0x0, 0xb4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass181 + mov v1, v0 + newobjrange 0x2d2, 0x1, v1 + stobjbyname 0x2d4, a181, a2 + wide.ldlexvar 0x0, 0xb5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass182 + mov v1, v0 + newobjrange 0x2d6, 0x1, v1 + stobjbyname 0x2d8, a182, a2 + wide.ldlexvar 0x0, 0xb6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass183 + mov v1, v0 + newobjrange 0x2da, 0x1, v1 + stobjbyname 0x2dc, a183, a2 + wide.ldlexvar 0x0, 0xb7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass184 + mov v1, v0 + newobjrange 0x2de, 0x1, v1 + stobjbyname 0x2e0, a184, a2 + wide.ldlexvar 0x0, 0xb8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass185 + mov v1, v0 + newobjrange 0x2e2, 0x1, v1 + stobjbyname 0x2e4, a185, a2 + wide.ldlexvar 0x0, 0xb9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass186 + mov v1, v0 + newobjrange 0x2e6, 0x1, v1 + stobjbyname 0x2e8, a186, a2 + wide.ldlexvar 0x0, 0xba + sta v0 + throw.undefinedifholewithname TopLevelSendableClass187 + mov v1, v0 + newobjrange 0x2ea, 0x1, v1 + stobjbyname 0x2ec, a187, a2 + wide.ldlexvar 0x0, 0xbb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass188 + mov v1, v0 + newobjrange 0x2ee, 0x1, v1 + stobjbyname 0x2f0, a188, a2 + wide.ldlexvar 0x0, 0xbc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass189 + mov v1, v0 + newobjrange 0x2f2, 0x1, v1 + stobjbyname 0x2f4, a189, a2 + wide.ldlexvar 0x0, 0xbd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass190 + mov v1, v0 + newobjrange 0x2f6, 0x1, v1 + stobjbyname 0x2f8, a190, a2 + wide.ldlexvar 0x0, 0xbe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass191 + mov v1, v0 + newobjrange 0x2fa, 0x1, v1 + stobjbyname 0x2fc, a191, a2 + wide.ldlexvar 0x0, 0xbf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass192 + mov v1, v0 + newobjrange 0x2fe, 0x1, v1 + stobjbyname 0x300, a192, a2 + wide.ldlexvar 0x0, 0xc0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass193 + mov v1, v0 + newobjrange 0x302, 0x1, v1 + stobjbyname 0x304, a193, a2 + wide.ldlexvar 0x0, 0xc1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass194 + mov v1, v0 + newobjrange 0x306, 0x1, v1 + stobjbyname 0x308, a194, a2 + wide.ldlexvar 0x0, 0xc2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass195 + mov v1, v0 + newobjrange 0x30a, 0x1, v1 + stobjbyname 0x30c, a195, a2 + wide.ldlexvar 0x0, 0xc3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass196 + mov v1, v0 + newobjrange 0x30e, 0x1, v1 + stobjbyname 0x310, a196, a2 + wide.ldlexvar 0x0, 0xc4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass197 + mov v1, v0 + newobjrange 0x312, 0x1, v1 + stobjbyname 0x314, a197, a2 + wide.ldlexvar 0x0, 0xc5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass198 + mov v1, v0 + newobjrange 0x316, 0x1, v1 + stobjbyname 0x318, a198, a2 + wide.ldlexvar 0x0, 0xc6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass199 + mov v1, v0 + newobjrange 0x31a, 0x1, v1 + stobjbyname 0x31c, a199, a2 + wide.ldlexvar 0x0, 0xc7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass200 + mov v1, v0 + newobjrange 0x31e, 0x1, v1 + stobjbyname 0x320, a200, a2 + wide.ldlexvar 0x0, 0xc8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass201 + mov v1, v0 + newobjrange 0x322, 0x1, v1 + stobjbyname 0x324, a201, a2 + wide.ldlexvar 0x0, 0xc9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass202 + mov v1, v0 + newobjrange 0x326, 0x1, v1 + stobjbyname 0x328, a202, a2 + wide.ldlexvar 0x0, 0xca + sta v0 + throw.undefinedifholewithname TopLevelSendableClass203 + mov v1, v0 + newobjrange 0x32a, 0x1, v1 + stobjbyname 0x32c, a203, a2 + wide.ldlexvar 0x0, 0xcb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass204 + mov v1, v0 + newobjrange 0x32e, 0x1, v1 + stobjbyname 0x330, a204, a2 + wide.ldlexvar 0x0, 0xcc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass205 + mov v1, v0 + newobjrange 0x332, 0x1, v1 + stobjbyname 0x334, a205, a2 + wide.ldlexvar 0x0, 0xcd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass206 + mov v1, v0 + newobjrange 0x336, 0x1, v1 + stobjbyname 0x338, a206, a2 + wide.ldlexvar 0x0, 0xce + sta v0 + throw.undefinedifholewithname TopLevelSendableClass207 + mov v1, v0 + newobjrange 0x33a, 0x1, v1 + stobjbyname 0x33c, a207, a2 + wide.ldlexvar 0x0, 0xcf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass208 + mov v1, v0 + newobjrange 0x33e, 0x1, v1 + stobjbyname 0x340, a208, a2 + wide.ldlexvar 0x0, 0xd0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass209 + mov v1, v0 + newobjrange 0x342, 0x1, v1 + stobjbyname 0x344, a209, a2 + wide.ldlexvar 0x0, 0xd1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass210 + mov v1, v0 + newobjrange 0x346, 0x1, v1 + stobjbyname 0x348, a210, a2 + wide.ldlexvar 0x0, 0xd2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass211 + mov v1, v0 + newobjrange 0x34a, 0x1, v1 + stobjbyname 0x34c, a211, a2 + wide.ldlexvar 0x0, 0xd3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass212 + mov v1, v0 + newobjrange 0x34e, 0x1, v1 + stobjbyname 0x350, a212, a2 + wide.ldlexvar 0x0, 0xd4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass213 + mov v1, v0 + newobjrange 0x352, 0x1, v1 + stobjbyname 0x354, a213, a2 + wide.ldlexvar 0x0, 0xd5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass214 + mov v1, v0 + newobjrange 0x356, 0x1, v1 + stobjbyname 0x358, a214, a2 + wide.ldlexvar 0x0, 0xd6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass215 + mov v1, v0 + newobjrange 0x35a, 0x1, v1 + stobjbyname 0x35c, a215, a2 + wide.ldlexvar 0x0, 0xd7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass216 + mov v1, v0 + newobjrange 0x35e, 0x1, v1 + stobjbyname 0x360, a216, a2 + wide.ldlexvar 0x0, 0xd8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass217 + mov v1, v0 + newobjrange 0x362, 0x1, v1 + stobjbyname 0x364, a217, a2 + wide.ldlexvar 0x0, 0xd9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass218 + mov v1, v0 + newobjrange 0x366, 0x1, v1 + stobjbyname 0x368, a218, a2 + wide.ldlexvar 0x0, 0xda + sta v0 + throw.undefinedifholewithname TopLevelSendableClass219 + mov v1, v0 + newobjrange 0x36a, 0x1, v1 + stobjbyname 0x36c, a219, a2 + wide.ldlexvar 0x0, 0xdb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass220 + mov v1, v0 + newobjrange 0x36e, 0x1, v1 + stobjbyname 0x370, a220, a2 + wide.ldlexvar 0x0, 0xdc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass221 + mov v1, v0 + newobjrange 0x372, 0x1, v1 + stobjbyname 0x374, a221, a2 + wide.ldlexvar 0x0, 0xdd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass222 + mov v1, v0 + newobjrange 0x376, 0x1, v1 + stobjbyname 0x378, a222, a2 + wide.ldlexvar 0x0, 0xde + sta v0 + throw.undefinedifholewithname TopLevelSendableClass223 + mov v1, v0 + newobjrange 0x37a, 0x1, v1 + stobjbyname 0x37c, a223, a2 + wide.ldlexvar 0x0, 0xdf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass224 + mov v1, v0 + newobjrange 0x37e, 0x1, v1 + stobjbyname 0x380, a224, a2 + wide.ldlexvar 0x0, 0xe0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass225 + mov v1, v0 + newobjrange 0x382, 0x1, v1 + stobjbyname 0x384, a225, a2 + wide.ldlexvar 0x0, 0xe1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass226 + mov v1, v0 + newobjrange 0x386, 0x1, v1 + stobjbyname 0x388, a226, a2 + wide.ldlexvar 0x0, 0xe2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass227 + mov v1, v0 + newobjrange 0x38a, 0x1, v1 + stobjbyname 0x38c, a227, a2 + wide.ldlexvar 0x0, 0xe3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass228 + mov v1, v0 + newobjrange 0x38e, 0x1, v1 + stobjbyname 0x390, a228, a2 + wide.ldlexvar 0x0, 0xe4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass229 + mov v1, v0 + newobjrange 0x392, 0x1, v1 + stobjbyname 0x394, a229, a2 + wide.ldlexvar 0x0, 0xe5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass230 + mov v1, v0 + newobjrange 0x396, 0x1, v1 + stobjbyname 0x398, a230, a2 + wide.ldlexvar 0x0, 0xe6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass231 + mov v1, v0 + newobjrange 0x39a, 0x1, v1 + stobjbyname 0x39c, a231, a2 + wide.ldlexvar 0x0, 0xe7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass232 + mov v1, v0 + newobjrange 0x39e, 0x1, v1 + stobjbyname 0x3a0, a232, a2 + wide.ldlexvar 0x0, 0xe8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass233 + mov v1, v0 + newobjrange 0x3a2, 0x1, v1 + stobjbyname 0x3a4, a233, a2 + wide.ldlexvar 0x0, 0xe9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass234 + mov v1, v0 + newobjrange 0x3a6, 0x1, v1 + stobjbyname 0x3a8, a234, a2 + wide.ldlexvar 0x0, 0xea + sta v0 + throw.undefinedifholewithname TopLevelSendableClass235 + mov v1, v0 + newobjrange 0x3aa, 0x1, v1 + stobjbyname 0x3ac, a235, a2 + wide.ldlexvar 0x0, 0xeb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass236 + mov v1, v0 + newobjrange 0x3ae, 0x1, v1 + stobjbyname 0x3b0, a236, a2 + wide.ldlexvar 0x0, 0xec + sta v0 + throw.undefinedifholewithname TopLevelSendableClass237 + mov v1, v0 + newobjrange 0x3b2, 0x1, v1 + stobjbyname 0x3b4, a237, a2 + wide.ldlexvar 0x0, 0xed + sta v0 + throw.undefinedifholewithname TopLevelSendableClass238 + mov v1, v0 + newobjrange 0x3b6, 0x1, v1 + stobjbyname 0x3b8, a238, a2 + wide.ldlexvar 0x0, 0xee + sta v0 + throw.undefinedifholewithname TopLevelSendableClass239 + mov v1, v0 + newobjrange 0x3ba, 0x1, v1 + stobjbyname 0x3bc, a239, a2 + wide.ldlexvar 0x0, 0xef + sta v0 + throw.undefinedifholewithname TopLevelSendableClass240 + mov v1, v0 + newobjrange 0x3be, 0x1, v1 + stobjbyname 0x3c0, a240, a2 + wide.ldlexvar 0x0, 0xf0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass241 + mov v1, v0 + newobjrange 0x3c2, 0x1, v1 + stobjbyname 0x3c4, a241, a2 + wide.ldlexvar 0x0, 0xf1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass242 + mov v1, v0 + newobjrange 0x3c6, 0x1, v1 + stobjbyname 0x3c8, a242, a2 + wide.ldlexvar 0x0, 0xf2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass243 + mov v1, v0 + newobjrange 0x3ca, 0x1, v1 + stobjbyname 0x3cc, a243, a2 + wide.ldlexvar 0x0, 0xf3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass244 + mov v1, v0 + newobjrange 0x3ce, 0x1, v1 + stobjbyname 0x3d0, a244, a2 + wide.ldlexvar 0x0, 0xf4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass245 + mov v1, v0 + newobjrange 0x3d2, 0x1, v1 + stobjbyname 0x3d4, a245, a2 + wide.ldlexvar 0x0, 0xf5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass246 + mov v1, v0 + newobjrange 0x3d6, 0x1, v1 + stobjbyname 0x3d8, a246, a2 + wide.ldlexvar 0x0, 0xf6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass247 + mov v1, v0 + newobjrange 0x3da, 0x1, v1 + stobjbyname 0x3dc, a247, a2 + wide.ldlexvar 0x0, 0xf7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass248 + mov v1, v0 + newobjrange 0x3de, 0x1, v1 + stobjbyname 0x3e0, a248, a2 + wide.ldlexvar 0x0, 0xf8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass249 + mov v1, v0 + newobjrange 0x3e2, 0x1, v1 + stobjbyname 0x3e4, a249, a2 + wide.ldlexvar 0x0, 0xf9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass250 + mov v1, v0 + newobjrange 0x3e6, 0x1, v1 + stobjbyname 0x3e8, a250, a2 + wide.ldlexvar 0x0, 0xfa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass251 + mov v1, v0 + newobjrange 0x3ea, 0x1, v1 + stobjbyname 0x3ec, a251, a2 + wide.ldlexvar 0x0, 0xfb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass252 + mov v1, v0 + newobjrange 0x3ee, 0x1, v1 + stobjbyname 0x3f0, a252, a2 + wide.ldlexvar 0x0, 0xfc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass253 + mov v1, v0 + newobjrange 0x3f2, 0x1, v1 + stobjbyname 0x3f4, a253, a2 + wide.ldlexvar 0x0, 0xfd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass254 + mov v1, v0 + newobjrange 0x3f6, 0x1, v1 + stobjbyname 0x3f8, a254, a2 + wide.ldlexvar 0x0, 0xfe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass255 + mov v1, v0 + newobjrange 0x3fa, 0x1, v1 + stobjbyname 0x3fc, a255, a2 + lda a2 + ldobjbyname 0x3fe, a1 + ldobjbyname 0x400, o + stobjbyname 0x402, u, a2 + lda.str wide_sendable_test + stobjbyname 0x404, v, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass10(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass100(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass101(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass102(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass103(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass104(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass105(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass106(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass107(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass108(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass109(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass11(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass110(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass111(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass112(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass113(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass114(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass115(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass116(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass117(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass118(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass119(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass12(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass120(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass121(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass122(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass123(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass124(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass125(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass126(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass127(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass128(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass129(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass13(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass130(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass131(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass132(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass133(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass134(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass135(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass136(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass137(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass138(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass139(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass14(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass140(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass141(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass142(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass143(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass144(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass145(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass146(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass147(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass148(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass149(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass15(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass150(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass151(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass152(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass153(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass154(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass155(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass156(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass157(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass158(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass159(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass16(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass160(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass161(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass162(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass163(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass164(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass165(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass166(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass167(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass168(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass169(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass17(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass170(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass171(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass172(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass173(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass174(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass175(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass176(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass177(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass178(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass179(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass18(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass180(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass181(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass182(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass183(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass184(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass185(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass186(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass187(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass188(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass189(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass19(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass190(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass191(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass192(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass193(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass194(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass195(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass196(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass197(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass198(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass199(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass2(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass20(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass200(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass201(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass202(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass203(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass204(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass205(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass206(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass207(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass208(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass209(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass21(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass210(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass211(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass212(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass213(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass214(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass215(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass216(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass217(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass218(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass219(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass22(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass220(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass221(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass222(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass223(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass224(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass225(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass226(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass227(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass228(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass229(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass23(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass230(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass231(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass232(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass233(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass234(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass235(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass236(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass237(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass238(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass239(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass24(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass240(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass241(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass242(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass243(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass244(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass245(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass246(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass247(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass248(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass249(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass25(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass250(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass251(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass252(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass253(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass254(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass255(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass26(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass27(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass28(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass29(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass3(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass30(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass31(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass32(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass33(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass34(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass35(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass36(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass37(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass38(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass39(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass4(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass40(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass41(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass42(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass43(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass44(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass45(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass46(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass47(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass48(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass49(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass5(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass50(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass51(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass52(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass53(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass54(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass55(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass56(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass57(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass58(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass59(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass6(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass60(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass61(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass62(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass63(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass64(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass65(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass66(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass67(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass68(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass69(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass7(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass70(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass71(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass72(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass73(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass74(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass75(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass76(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass77(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass78(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass79(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass8(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass80(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass81(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass82(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass83(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass84(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass85(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass86(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass87(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass88(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass89(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass9(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass90(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass91(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass92(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass93(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass94(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass95(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass96(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass97(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass98(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass99(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x108 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + wide.newlexenv 0xff + ldhole + sta v0 + callruntime.definesendableclass 0x2, .TopLevelSendableClass1, _2, 0x0, v0 + stlexvar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x3, .TopLevelSendableClass2, _4, 0x0, v0 + stlexvar 0x0, 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x4, .TopLevelSendableClass3, _6, 0x0, v0 + stlexvar 0x0, 0x2 + ldhole + sta v0 + callruntime.definesendableclass 0x5, .TopLevelSendableClass4, _8, 0x0, v0 + stlexvar 0x0, 0x3 + ldhole + sta v0 + callruntime.definesendableclass 0x6, .TopLevelSendableClass5, _10, 0x0, v0 + stlexvar 0x0, 0x4 + ldhole + sta v0 + callruntime.definesendableclass 0x7, .TopLevelSendableClass6, _12, 0x0, v0 + stlexvar 0x0, 0x5 + ldhole + sta v0 + callruntime.definesendableclass 0x8, .TopLevelSendableClass7, _14, 0x0, v0 + stlexvar 0x0, 0x6 + ldhole + sta v0 + callruntime.definesendableclass 0x9, .TopLevelSendableClass8, _16, 0x0, v0 + stlexvar 0x0, 0x7 + ldhole + sta v0 + callruntime.definesendableclass 0xa, .TopLevelSendableClass9, _18, 0x0, v0 + stlexvar 0x0, 0x8 + ldhole + sta v0 + callruntime.definesendableclass 0xb, .TopLevelSendableClass10, _20, 0x0, v0 + stlexvar 0x0, 0x9 + ldhole + sta v0 + callruntime.definesendableclass 0xc, .TopLevelSendableClass11, _22, 0x0, v0 + stlexvar 0x0, 0xa + ldhole + sta v0 + callruntime.definesendableclass 0xd, .TopLevelSendableClass12, _24, 0x0, v0 + stlexvar 0x0, 0xb + ldhole + sta v0 + callruntime.definesendableclass 0xe, .TopLevelSendableClass13, _26, 0x0, v0 + stlexvar 0x0, 0xc + ldhole + sta v0 + callruntime.definesendableclass 0xf, .TopLevelSendableClass14, _28, 0x0, v0 + stlexvar 0x0, 0xd + ldhole + sta v0 + callruntime.definesendableclass 0x10, .TopLevelSendableClass15, _30, 0x0, v0 + stlexvar 0x0, 0xe + ldhole + sta v0 + callruntime.definesendableclass 0x11, .TopLevelSendableClass16, _32, 0x0, v0 + stlexvar 0x0, 0xf + ldhole + sta v0 + callruntime.definesendableclass 0x12, .TopLevelSendableClass17, _34, 0x0, v0 + stlexvar 0x0, 0x10 + ldhole + sta v0 + callruntime.definesendableclass 0x13, .TopLevelSendableClass18, _36, 0x0, v0 + stlexvar 0x0, 0x11 + ldhole + sta v0 + callruntime.definesendableclass 0x14, .TopLevelSendableClass19, _38, 0x0, v0 + stlexvar 0x0, 0x12 + ldhole + sta v0 + callruntime.definesendableclass 0x15, .TopLevelSendableClass20, _40, 0x0, v0 + stlexvar 0x0, 0x13 + ldhole + sta v0 + callruntime.definesendableclass 0x16, .TopLevelSendableClass21, _42, 0x0, v0 + stlexvar 0x0, 0x14 + ldhole + sta v0 + callruntime.definesendableclass 0x17, .TopLevelSendableClass22, _44, 0x0, v0 + stlexvar 0x0, 0x15 + ldhole + sta v0 + callruntime.definesendableclass 0x18, .TopLevelSendableClass23, _46, 0x0, v0 + stlexvar 0x0, 0x16 + ldhole + sta v0 + callruntime.definesendableclass 0x19, .TopLevelSendableClass24, _48, 0x0, v0 + stlexvar 0x0, 0x17 + ldhole + sta v0 + callruntime.definesendableclass 0x1a, .TopLevelSendableClass25, _50, 0x0, v0 + stlexvar 0x0, 0x18 + ldhole + sta v0 + callruntime.definesendableclass 0x1b, .TopLevelSendableClass26, _52, 0x0, v0 + stlexvar 0x0, 0x19 + ldhole + sta v0 + callruntime.definesendableclass 0x1c, .TopLevelSendableClass27, _54, 0x0, v0 + stlexvar 0x0, 0x1a + ldhole + sta v0 + callruntime.definesendableclass 0x1d, .TopLevelSendableClass28, _56, 0x0, v0 + stlexvar 0x0, 0x1b + ldhole + sta v0 + callruntime.definesendableclass 0x1e, .TopLevelSendableClass29, _58, 0x0, v0 + stlexvar 0x0, 0x1c + ldhole + sta v0 + callruntime.definesendableclass 0x1f, .TopLevelSendableClass30, _60, 0x0, v0 + stlexvar 0x0, 0x1d + ldhole + sta v0 + callruntime.definesendableclass 0x20, .TopLevelSendableClass31, _62, 0x0, v0 + stlexvar 0x0, 0x1e + ldhole + sta v0 + callruntime.definesendableclass 0x21, .TopLevelSendableClass32, _64, 0x0, v0 + stlexvar 0x0, 0x1f + ldhole + sta v0 + callruntime.definesendableclass 0x22, .TopLevelSendableClass33, _66, 0x0, v0 + stlexvar 0x0, 0x20 + ldhole + sta v0 + callruntime.definesendableclass 0x23, .TopLevelSendableClass34, _68, 0x0, v0 + stlexvar 0x0, 0x21 + ldhole + sta v0 + callruntime.definesendableclass 0x24, .TopLevelSendableClass35, _70, 0x0, v0 + stlexvar 0x0, 0x22 + ldhole + sta v0 + callruntime.definesendableclass 0x25, .TopLevelSendableClass36, _72, 0x0, v0 + stlexvar 0x0, 0x23 + ldhole + sta v0 + callruntime.definesendableclass 0x26, .TopLevelSendableClass37, _74, 0x0, v0 + stlexvar 0x0, 0x24 + ldhole + sta v0 + callruntime.definesendableclass 0x27, .TopLevelSendableClass38, _76, 0x0, v0 + stlexvar 0x0, 0x25 + ldhole + sta v0 + callruntime.definesendableclass 0x28, .TopLevelSendableClass39, _78, 0x0, v0 + stlexvar 0x0, 0x26 + ldhole + sta v0 + callruntime.definesendableclass 0x29, .TopLevelSendableClass40, _80, 0x0, v0 + stlexvar 0x0, 0x27 + ldhole + sta v0 + callruntime.definesendableclass 0x2a, .TopLevelSendableClass41, _82, 0x0, v0 + stlexvar 0x0, 0x28 + ldhole + sta v0 + callruntime.definesendableclass 0x2b, .TopLevelSendableClass42, _84, 0x0, v0 + stlexvar 0x0, 0x29 + ldhole + sta v0 + callruntime.definesendableclass 0x2c, .TopLevelSendableClass43, _86, 0x0, v0 + stlexvar 0x0, 0x2a + ldhole + sta v0 + callruntime.definesendableclass 0x2d, .TopLevelSendableClass44, _88, 0x0, v0 + stlexvar 0x0, 0x2b + ldhole + sta v0 + callruntime.definesendableclass 0x2e, .TopLevelSendableClass45, _90, 0x0, v0 + stlexvar 0x0, 0x2c + ldhole + sta v0 + callruntime.definesendableclass 0x2f, .TopLevelSendableClass46, _92, 0x0, v0 + stlexvar 0x0, 0x2d + ldhole + sta v0 + callruntime.definesendableclass 0x30, .TopLevelSendableClass47, _94, 0x0, v0 + stlexvar 0x0, 0x2e + ldhole + sta v0 + callruntime.definesendableclass 0x31, .TopLevelSendableClass48, _96, 0x0, v0 + stlexvar 0x0, 0x2f + ldhole + sta v0 + callruntime.definesendableclass 0x32, .TopLevelSendableClass49, _98, 0x0, v0 + stlexvar 0x0, 0x30 + ldhole + sta v0 + callruntime.definesendableclass 0x33, .TopLevelSendableClass50, _100, 0x0, v0 + stlexvar 0x0, 0x31 + ldhole + sta v0 + callruntime.definesendableclass 0x34, .TopLevelSendableClass51, _102, 0x0, v0 + stlexvar 0x0, 0x32 + ldhole + sta v0 + callruntime.definesendableclass 0x35, .TopLevelSendableClass52, _104, 0x0, v0 + stlexvar 0x0, 0x33 + ldhole + sta v0 + callruntime.definesendableclass 0x36, .TopLevelSendableClass53, _106, 0x0, v0 + stlexvar 0x0, 0x34 + ldhole + sta v0 + callruntime.definesendableclass 0x37, .TopLevelSendableClass54, _108, 0x0, v0 + stlexvar 0x0, 0x35 + ldhole + sta v0 + callruntime.definesendableclass 0x38, .TopLevelSendableClass55, _110, 0x0, v0 + stlexvar 0x0, 0x36 + ldhole + sta v0 + callruntime.definesendableclass 0x39, .TopLevelSendableClass56, _112, 0x0, v0 + stlexvar 0x0, 0x37 + ldhole + sta v0 + callruntime.definesendableclass 0x3a, .TopLevelSendableClass57, _114, 0x0, v0 + stlexvar 0x0, 0x38 + ldhole + sta v0 + callruntime.definesendableclass 0x3b, .TopLevelSendableClass58, _116, 0x0, v0 + stlexvar 0x0, 0x39 + ldhole + sta v0 + callruntime.definesendableclass 0x3c, .TopLevelSendableClass59, _118, 0x0, v0 + stlexvar 0x0, 0x3a + ldhole + sta v0 + callruntime.definesendableclass 0x3d, .TopLevelSendableClass60, _120, 0x0, v0 + stlexvar 0x0, 0x3b + ldhole + sta v0 + callruntime.definesendableclass 0x3e, .TopLevelSendableClass61, _122, 0x0, v0 + stlexvar 0x0, 0x3c + ldhole + sta v0 + callruntime.definesendableclass 0x3f, .TopLevelSendableClass62, _124, 0x0, v0 + stlexvar 0x0, 0x3d + ldhole + sta v0 + callruntime.definesendableclass 0x40, .TopLevelSendableClass63, _126, 0x0, v0 + stlexvar 0x0, 0x3e + ldhole + sta v0 + callruntime.definesendableclass 0x41, .TopLevelSendableClass64, _128, 0x0, v0 + stlexvar 0x0, 0x3f + ldhole + sta v0 + callruntime.definesendableclass 0x42, .TopLevelSendableClass65, _130, 0x0, v0 + stlexvar 0x0, 0x40 + ldhole + sta v0 + callruntime.definesendableclass 0x43, .TopLevelSendableClass66, _132, 0x0, v0 + stlexvar 0x0, 0x41 + ldhole + sta v0 + callruntime.definesendableclass 0x44, .TopLevelSendableClass67, _134, 0x0, v0 + stlexvar 0x0, 0x42 + ldhole + sta v0 + callruntime.definesendableclass 0x45, .TopLevelSendableClass68, _136, 0x0, v0 + stlexvar 0x0, 0x43 + ldhole + sta v0 + callruntime.definesendableclass 0x46, .TopLevelSendableClass69, _138, 0x0, v0 + stlexvar 0x0, 0x44 + ldhole + sta v0 + callruntime.definesendableclass 0x47, .TopLevelSendableClass70, _140, 0x0, v0 + stlexvar 0x0, 0x45 + ldhole + sta v0 + callruntime.definesendableclass 0x48, .TopLevelSendableClass71, _142, 0x0, v0 + stlexvar 0x0, 0x46 + ldhole + sta v0 + callruntime.definesendableclass 0x49, .TopLevelSendableClass72, _144, 0x0, v0 + stlexvar 0x0, 0x47 + ldhole + sta v0 + callruntime.definesendableclass 0x4a, .TopLevelSendableClass73, _146, 0x0, v0 + stlexvar 0x0, 0x48 + ldhole + sta v0 + callruntime.definesendableclass 0x4b, .TopLevelSendableClass74, _148, 0x0, v0 + stlexvar 0x0, 0x49 + ldhole + sta v0 + callruntime.definesendableclass 0x4c, .TopLevelSendableClass75, _150, 0x0, v0 + stlexvar 0x0, 0x4a + ldhole + sta v0 + callruntime.definesendableclass 0x4d, .TopLevelSendableClass76, _152, 0x0, v0 + stlexvar 0x0, 0x4b + ldhole + sta v0 + callruntime.definesendableclass 0x4e, .TopLevelSendableClass77, _154, 0x0, v0 + stlexvar 0x0, 0x4c + ldhole + sta v0 + callruntime.definesendableclass 0x4f, .TopLevelSendableClass78, _156, 0x0, v0 + stlexvar 0x0, 0x4d + ldhole + sta v0 + callruntime.definesendableclass 0x50, .TopLevelSendableClass79, _158, 0x0, v0 + stlexvar 0x0, 0x4e + ldhole + sta v0 + callruntime.definesendableclass 0x51, .TopLevelSendableClass80, _160, 0x0, v0 + stlexvar 0x0, 0x4f + ldhole + sta v0 + callruntime.definesendableclass 0x52, .TopLevelSendableClass81, _162, 0x0, v0 + stlexvar 0x0, 0x50 + ldhole + sta v0 + callruntime.definesendableclass 0x53, .TopLevelSendableClass82, _164, 0x0, v0 + stlexvar 0x0, 0x51 + ldhole + sta v0 + callruntime.definesendableclass 0x54, .TopLevelSendableClass83, _166, 0x0, v0 + stlexvar 0x0, 0x52 + ldhole + sta v0 + callruntime.definesendableclass 0x55, .TopLevelSendableClass84, _168, 0x0, v0 + stlexvar 0x0, 0x53 + ldhole + sta v0 + callruntime.definesendableclass 0x56, .TopLevelSendableClass85, _170, 0x0, v0 + stlexvar 0x0, 0x54 + ldhole + sta v0 + callruntime.definesendableclass 0x57, .TopLevelSendableClass86, _172, 0x0, v0 + stlexvar 0x0, 0x55 + ldhole + sta v0 + callruntime.definesendableclass 0x58, .TopLevelSendableClass87, _174, 0x0, v0 + stlexvar 0x0, 0x56 + ldhole + sta v0 + callruntime.definesendableclass 0x59, .TopLevelSendableClass88, _176, 0x0, v0 + stlexvar 0x0, 0x57 + ldhole + sta v0 + callruntime.definesendableclass 0x5a, .TopLevelSendableClass89, _178, 0x0, v0 + stlexvar 0x0, 0x58 + ldhole + sta v0 + callruntime.definesendableclass 0x5b, .TopLevelSendableClass90, _180, 0x0, v0 + stlexvar 0x0, 0x59 + ldhole + sta v0 + callruntime.definesendableclass 0x5c, .TopLevelSendableClass91, _182, 0x0, v0 + stlexvar 0x0, 0x5a + ldhole + sta v0 + callruntime.definesendableclass 0x5d, .TopLevelSendableClass92, _184, 0x0, v0 + stlexvar 0x0, 0x5b + ldhole + sta v0 + callruntime.definesendableclass 0x5e, .TopLevelSendableClass93, _186, 0x0, v0 + stlexvar 0x0, 0x5c + ldhole + sta v0 + callruntime.definesendableclass 0x5f, .TopLevelSendableClass94, _188, 0x0, v0 + stlexvar 0x0, 0x5d + ldhole + sta v0 + callruntime.definesendableclass 0x60, .TopLevelSendableClass95, _190, 0x0, v0 + stlexvar 0x0, 0x5e + ldhole + sta v0 + callruntime.definesendableclass 0x61, .TopLevelSendableClass96, _192, 0x0, v0 + stlexvar 0x0, 0x5f + ldhole + sta v0 + callruntime.definesendableclass 0x62, .TopLevelSendableClass97, _194, 0x0, v0 + stlexvar 0x0, 0x60 + ldhole + sta v0 + callruntime.definesendableclass 0x63, .TopLevelSendableClass98, _196, 0x0, v0 + stlexvar 0x0, 0x61 + ldhole + sta v0 + callruntime.definesendableclass 0x64, .TopLevelSendableClass99, _198, 0x0, v0 + stlexvar 0x0, 0x62 + ldhole + sta v0 + callruntime.definesendableclass 0x65, .TopLevelSendableClass100, _200, 0x0, v0 + stlexvar 0x0, 0x63 + ldhole + sta v0 + callruntime.definesendableclass 0x66, .TopLevelSendableClass101, _202, 0x0, v0 + stlexvar 0x0, 0x64 + ldhole + sta v0 + callruntime.definesendableclass 0x67, .TopLevelSendableClass102, _204, 0x0, v0 + stlexvar 0x0, 0x65 + ldhole + sta v0 + callruntime.definesendableclass 0x68, .TopLevelSendableClass103, _206, 0x0, v0 + stlexvar 0x0, 0x66 + ldhole + sta v0 + callruntime.definesendableclass 0x69, .TopLevelSendableClass104, _208, 0x0, v0 + stlexvar 0x0, 0x67 + ldhole + sta v0 + callruntime.definesendableclass 0x6a, .TopLevelSendableClass105, _210, 0x0, v0 + stlexvar 0x0, 0x68 + ldhole + sta v0 + callruntime.definesendableclass 0x6b, .TopLevelSendableClass106, _212, 0x0, v0 + stlexvar 0x0, 0x69 + ldhole + sta v0 + callruntime.definesendableclass 0x6c, .TopLevelSendableClass107, _214, 0x0, v0 + stlexvar 0x0, 0x6a + ldhole + sta v0 + callruntime.definesendableclass 0x6d, .TopLevelSendableClass108, _216, 0x0, v0 + stlexvar 0x0, 0x6b + ldhole + sta v0 + callruntime.definesendableclass 0x6e, .TopLevelSendableClass109, _218, 0x0, v0 + stlexvar 0x0, 0x6c + ldhole + sta v0 + callruntime.definesendableclass 0x6f, .TopLevelSendableClass110, _220, 0x0, v0 + stlexvar 0x0, 0x6d + ldhole + sta v0 + callruntime.definesendableclass 0x70, .TopLevelSendableClass111, _222, 0x0, v0 + stlexvar 0x0, 0x6e + ldhole + sta v0 + callruntime.definesendableclass 0x71, .TopLevelSendableClass112, _224, 0x0, v0 + stlexvar 0x0, 0x6f + ldhole + sta v0 + callruntime.definesendableclass 0x72, .TopLevelSendableClass113, _226, 0x0, v0 + stlexvar 0x0, 0x70 + ldhole + sta v0 + callruntime.definesendableclass 0x73, .TopLevelSendableClass114, _228, 0x0, v0 + stlexvar 0x0, 0x71 + ldhole + sta v0 + callruntime.definesendableclass 0x74, .TopLevelSendableClass115, _230, 0x0, v0 + stlexvar 0x0, 0x72 + ldhole + sta v0 + callruntime.definesendableclass 0x75, .TopLevelSendableClass116, _232, 0x0, v0 + stlexvar 0x0, 0x73 + ldhole + sta v0 + callruntime.definesendableclass 0x76, .TopLevelSendableClass117, _234, 0x0, v0 + stlexvar 0x0, 0x74 + ldhole + sta v0 + callruntime.definesendableclass 0x77, .TopLevelSendableClass118, _236, 0x0, v0 + stlexvar 0x0, 0x75 + ldhole + sta v0 + callruntime.definesendableclass 0x78, .TopLevelSendableClass119, _238, 0x0, v0 + stlexvar 0x0, 0x76 + ldhole + sta v0 + callruntime.definesendableclass 0x79, .TopLevelSendableClass120, _240, 0x0, v0 + stlexvar 0x0, 0x77 + ldhole + sta v0 + callruntime.definesendableclass 0x7a, .TopLevelSendableClass121, _242, 0x0, v0 + stlexvar 0x0, 0x78 + ldhole + sta v0 + callruntime.definesendableclass 0x7b, .TopLevelSendableClass122, _244, 0x0, v0 + stlexvar 0x0, 0x79 + ldhole + sta v0 + callruntime.definesendableclass 0x7c, .TopLevelSendableClass123, _246, 0x0, v0 + stlexvar 0x0, 0x7a + ldhole + sta v0 + callruntime.definesendableclass 0x7d, .TopLevelSendableClass124, _248, 0x0, v0 + stlexvar 0x0, 0x7b + ldhole + sta v0 + callruntime.definesendableclass 0x7e, .TopLevelSendableClass125, _250, 0x0, v0 + stlexvar 0x0, 0x7c + ldhole + sta v0 + callruntime.definesendableclass 0x7f, .TopLevelSendableClass126, _252, 0x0, v0 + stlexvar 0x0, 0x7d + ldhole + sta v0 + callruntime.definesendableclass 0x80, .TopLevelSendableClass127, _254, 0x0, v0 + stlexvar 0x0, 0x7e + ldhole + sta v0 + callruntime.definesendableclass 0x81, .TopLevelSendableClass128, _256, 0x0, v0 + stlexvar 0x0, 0x7f + ldhole + sta v0 + callruntime.definesendableclass 0x82, .TopLevelSendableClass129, _258, 0x0, v0 + wide.stlexvar 0x0, 0x80 + ldhole + sta v0 + callruntime.definesendableclass 0x83, .TopLevelSendableClass130, _260, 0x0, v0 + wide.stlexvar 0x0, 0x81 + ldhole + sta v0 + callruntime.definesendableclass 0x84, .TopLevelSendableClass131, _262, 0x0, v0 + wide.stlexvar 0x0, 0x82 + ldhole + sta v0 + callruntime.definesendableclass 0x85, .TopLevelSendableClass132, _264, 0x0, v0 + wide.stlexvar 0x0, 0x83 + ldhole + sta v0 + callruntime.definesendableclass 0x86, .TopLevelSendableClass133, _266, 0x0, v0 + wide.stlexvar 0x0, 0x84 + ldhole + sta v0 + callruntime.definesendableclass 0x87, .TopLevelSendableClass134, _268, 0x0, v0 + wide.stlexvar 0x0, 0x85 + ldhole + sta v0 + callruntime.definesendableclass 0x88, .TopLevelSendableClass135, _270, 0x0, v0 + wide.stlexvar 0x0, 0x86 + ldhole + sta v0 + callruntime.definesendableclass 0x89, .TopLevelSendableClass136, _272, 0x0, v0 + wide.stlexvar 0x0, 0x87 + ldhole + sta v0 + callruntime.definesendableclass 0x8a, .TopLevelSendableClass137, _274, 0x0, v0 + wide.stlexvar 0x0, 0x88 + ldhole + sta v0 + callruntime.definesendableclass 0x8b, .TopLevelSendableClass138, _276, 0x0, v0 + wide.stlexvar 0x0, 0x89 + ldhole + sta v0 + callruntime.definesendableclass 0x8c, .TopLevelSendableClass139, _278, 0x0, v0 + wide.stlexvar 0x0, 0x8a + ldhole + sta v0 + callruntime.definesendableclass 0x8d, .TopLevelSendableClass140, _280, 0x0, v0 + wide.stlexvar 0x0, 0x8b + ldhole + sta v0 + callruntime.definesendableclass 0x8e, .TopLevelSendableClass141, _282, 0x0, v0 + wide.stlexvar 0x0, 0x8c + ldhole + sta v0 + callruntime.definesendableclass 0x8f, .TopLevelSendableClass142, _284, 0x0, v0 + wide.stlexvar 0x0, 0x8d + ldhole + sta v0 + callruntime.definesendableclass 0x90, .TopLevelSendableClass143, _286, 0x0, v0 + wide.stlexvar 0x0, 0x8e + ldhole + sta v0 + callruntime.definesendableclass 0x91, .TopLevelSendableClass144, _288, 0x0, v0 + wide.stlexvar 0x0, 0x8f + ldhole + sta v0 + callruntime.definesendableclass 0x92, .TopLevelSendableClass145, _290, 0x0, v0 + wide.stlexvar 0x0, 0x90 + ldhole + sta v0 + callruntime.definesendableclass 0x93, .TopLevelSendableClass146, _292, 0x0, v0 + wide.stlexvar 0x0, 0x91 + ldhole + sta v0 + callruntime.definesendableclass 0x94, .TopLevelSendableClass147, _294, 0x0, v0 + wide.stlexvar 0x0, 0x92 + ldhole + sta v0 + callruntime.definesendableclass 0x95, .TopLevelSendableClass148, _296, 0x0, v0 + wide.stlexvar 0x0, 0x93 + ldhole + sta v0 + callruntime.definesendableclass 0x96, .TopLevelSendableClass149, _298, 0x0, v0 + wide.stlexvar 0x0, 0x94 + ldhole + sta v0 + callruntime.definesendableclass 0x97, .TopLevelSendableClass150, _300, 0x0, v0 + wide.stlexvar 0x0, 0x95 + ldhole + sta v0 + callruntime.definesendableclass 0x98, .TopLevelSendableClass151, _302, 0x0, v0 + wide.stlexvar 0x0, 0x96 + ldhole + sta v0 + callruntime.definesendableclass 0x99, .TopLevelSendableClass152, _304, 0x0, v0 + wide.stlexvar 0x0, 0x97 + ldhole + sta v0 + callruntime.definesendableclass 0x9a, .TopLevelSendableClass153, _306, 0x0, v0 + wide.stlexvar 0x0, 0x98 + ldhole + sta v0 + callruntime.definesendableclass 0x9b, .TopLevelSendableClass154, _308, 0x0, v0 + wide.stlexvar 0x0, 0x99 + ldhole + sta v0 + callruntime.definesendableclass 0x9c, .TopLevelSendableClass155, _310, 0x0, v0 + wide.stlexvar 0x0, 0x9a + ldhole + sta v0 + callruntime.definesendableclass 0x9d, .TopLevelSendableClass156, _312, 0x0, v0 + wide.stlexvar 0x0, 0x9b + ldhole + sta v0 + callruntime.definesendableclass 0x9e, .TopLevelSendableClass157, _314, 0x0, v0 + wide.stlexvar 0x0, 0x9c + ldhole + sta v0 + callruntime.definesendableclass 0x9f, .TopLevelSendableClass158, _316, 0x0, v0 + wide.stlexvar 0x0, 0x9d + ldhole + sta v0 + callruntime.definesendableclass 0xa0, .TopLevelSendableClass159, _318, 0x0, v0 + wide.stlexvar 0x0, 0x9e + ldhole + sta v0 + callruntime.definesendableclass 0xa1, .TopLevelSendableClass160, _320, 0x0, v0 + wide.stlexvar 0x0, 0x9f + ldhole + sta v0 + callruntime.definesendableclass 0xa2, .TopLevelSendableClass161, _322, 0x0, v0 + wide.stlexvar 0x0, 0xa0 + ldhole + sta v0 + callruntime.definesendableclass 0xa3, .TopLevelSendableClass162, _324, 0x0, v0 + wide.stlexvar 0x0, 0xa1 + ldhole + sta v0 + callruntime.definesendableclass 0xa4, .TopLevelSendableClass163, _326, 0x0, v0 + wide.stlexvar 0x0, 0xa2 + ldhole + sta v0 + callruntime.definesendableclass 0xa5, .TopLevelSendableClass164, _328, 0x0, v0 + wide.stlexvar 0x0, 0xa3 + ldhole + sta v0 + callruntime.definesendableclass 0xa6, .TopLevelSendableClass165, _330, 0x0, v0 + wide.stlexvar 0x0, 0xa4 + ldhole + sta v0 + callruntime.definesendableclass 0xa7, .TopLevelSendableClass166, _332, 0x0, v0 + wide.stlexvar 0x0, 0xa5 + ldhole + sta v0 + callruntime.definesendableclass 0xa8, .TopLevelSendableClass167, _334, 0x0, v0 + wide.stlexvar 0x0, 0xa6 + ldhole + sta v0 + callruntime.definesendableclass 0xa9, .TopLevelSendableClass168, _336, 0x0, v0 + wide.stlexvar 0x0, 0xa7 + ldhole + sta v0 + callruntime.definesendableclass 0xaa, .TopLevelSendableClass169, _338, 0x0, v0 + wide.stlexvar 0x0, 0xa8 + ldhole + sta v0 + callruntime.definesendableclass 0xab, .TopLevelSendableClass170, _340, 0x0, v0 + wide.stlexvar 0x0, 0xa9 + ldhole + sta v0 + callruntime.definesendableclass 0xac, .TopLevelSendableClass171, _342, 0x0, v0 + wide.stlexvar 0x0, 0xaa + ldhole + sta v0 + callruntime.definesendableclass 0xad, .TopLevelSendableClass172, _344, 0x0, v0 + wide.stlexvar 0x0, 0xab + ldhole + sta v0 + callruntime.definesendableclass 0xae, .TopLevelSendableClass173, _346, 0x0, v0 + wide.stlexvar 0x0, 0xac + ldhole + sta v0 + callruntime.definesendableclass 0xaf, .TopLevelSendableClass174, _348, 0x0, v0 + wide.stlexvar 0x0, 0xad + ldhole + sta v0 + callruntime.definesendableclass 0xb0, .TopLevelSendableClass175, _350, 0x0, v0 + wide.stlexvar 0x0, 0xae + ldhole + sta v0 + callruntime.definesendableclass 0xb1, .TopLevelSendableClass176, _352, 0x0, v0 + wide.stlexvar 0x0, 0xaf + ldhole + sta v0 + callruntime.definesendableclass 0xb2, .TopLevelSendableClass177, _354, 0x0, v0 + wide.stlexvar 0x0, 0xb0 + ldhole + sta v0 + callruntime.definesendableclass 0xb3, .TopLevelSendableClass178, _356, 0x0, v0 + wide.stlexvar 0x0, 0xb1 + ldhole + sta v0 + callruntime.definesendableclass 0xb4, .TopLevelSendableClass179, _358, 0x0, v0 + wide.stlexvar 0x0, 0xb2 + ldhole + sta v0 + callruntime.definesendableclass 0xb5, .TopLevelSendableClass180, _360, 0x0, v0 + wide.stlexvar 0x0, 0xb3 + ldhole + sta v0 + callruntime.definesendableclass 0xb6, .TopLevelSendableClass181, _362, 0x0, v0 + wide.stlexvar 0x0, 0xb4 + ldhole + sta v0 + callruntime.definesendableclass 0xb7, .TopLevelSendableClass182, _364, 0x0, v0 + wide.stlexvar 0x0, 0xb5 + ldhole + sta v0 + callruntime.definesendableclass 0xb8, .TopLevelSendableClass183, _366, 0x0, v0 + wide.stlexvar 0x0, 0xb6 + ldhole + sta v0 + callruntime.definesendableclass 0xb9, .TopLevelSendableClass184, _368, 0x0, v0 + wide.stlexvar 0x0, 0xb7 + ldhole + sta v0 + callruntime.definesendableclass 0xba, .TopLevelSendableClass185, _370, 0x0, v0 + wide.stlexvar 0x0, 0xb8 + ldhole + sta v0 + callruntime.definesendableclass 0xbb, .TopLevelSendableClass186, _372, 0x0, v0 + wide.stlexvar 0x0, 0xb9 + ldhole + sta v0 + callruntime.definesendableclass 0xbc, .TopLevelSendableClass187, _374, 0x0, v0 + wide.stlexvar 0x0, 0xba + ldhole + sta v0 + callruntime.definesendableclass 0xbd, .TopLevelSendableClass188, _376, 0x0, v0 + wide.stlexvar 0x0, 0xbb + ldhole + sta v0 + callruntime.definesendableclass 0xbe, .TopLevelSendableClass189, _378, 0x0, v0 + wide.stlexvar 0x0, 0xbc + ldhole + sta v0 + callruntime.definesendableclass 0xbf, .TopLevelSendableClass190, _380, 0x0, v0 + wide.stlexvar 0x0, 0xbd + ldhole + sta v0 + callruntime.definesendableclass 0xc0, .TopLevelSendableClass191, _382, 0x0, v0 + wide.stlexvar 0x0, 0xbe + ldhole + sta v0 + callruntime.definesendableclass 0xc1, .TopLevelSendableClass192, _384, 0x0, v0 + wide.stlexvar 0x0, 0xbf + ldhole + sta v0 + callruntime.definesendableclass 0xc2, .TopLevelSendableClass193, _386, 0x0, v0 + wide.stlexvar 0x0, 0xc0 + ldhole + sta v0 + callruntime.definesendableclass 0xc3, .TopLevelSendableClass194, _388, 0x0, v0 + wide.stlexvar 0x0, 0xc1 + ldhole + sta v0 + callruntime.definesendableclass 0xc4, .TopLevelSendableClass195, _390, 0x0, v0 + wide.stlexvar 0x0, 0xc2 + ldhole + sta v0 + callruntime.definesendableclass 0xc5, .TopLevelSendableClass196, _392, 0x0, v0 + wide.stlexvar 0x0, 0xc3 + ldhole + sta v0 + callruntime.definesendableclass 0xc6, .TopLevelSendableClass197, _394, 0x0, v0 + wide.stlexvar 0x0, 0xc4 + ldhole + sta v0 + callruntime.definesendableclass 0xc7, .TopLevelSendableClass198, _396, 0x0, v0 + wide.stlexvar 0x0, 0xc5 + ldhole + sta v0 + callruntime.definesendableclass 0xc8, .TopLevelSendableClass199, _398, 0x0, v0 + wide.stlexvar 0x0, 0xc6 + ldhole + sta v0 + callruntime.definesendableclass 0xc9, .TopLevelSendableClass200, _400, 0x0, v0 + wide.stlexvar 0x0, 0xc7 + ldhole + sta v0 + callruntime.definesendableclass 0xca, .TopLevelSendableClass201, _402, 0x0, v0 + wide.stlexvar 0x0, 0xc8 + ldhole + sta v0 + callruntime.definesendableclass 0xcb, .TopLevelSendableClass202, _404, 0x0, v0 + wide.stlexvar 0x0, 0xc9 + ldhole + sta v0 + callruntime.definesendableclass 0xcc, .TopLevelSendableClass203, _406, 0x0, v0 + wide.stlexvar 0x0, 0xca + ldhole + sta v0 + callruntime.definesendableclass 0xcd, .TopLevelSendableClass204, _408, 0x0, v0 + wide.stlexvar 0x0, 0xcb + ldhole + sta v0 + callruntime.definesendableclass 0xce, .TopLevelSendableClass205, _410, 0x0, v0 + wide.stlexvar 0x0, 0xcc + ldhole + sta v0 + callruntime.definesendableclass 0xcf, .TopLevelSendableClass206, _412, 0x0, v0 + wide.stlexvar 0x0, 0xcd + ldhole + sta v0 + callruntime.definesendableclass 0xd0, .TopLevelSendableClass207, _414, 0x0, v0 + wide.stlexvar 0x0, 0xce + ldhole + sta v0 + callruntime.definesendableclass 0xd1, .TopLevelSendableClass208, _416, 0x0, v0 + wide.stlexvar 0x0, 0xcf + ldhole + sta v0 + callruntime.definesendableclass 0xd2, .TopLevelSendableClass209, _418, 0x0, v0 + wide.stlexvar 0x0, 0xd0 + ldhole + sta v0 + callruntime.definesendableclass 0xd3, .TopLevelSendableClass210, _420, 0x0, v0 + wide.stlexvar 0x0, 0xd1 + ldhole + sta v0 + callruntime.definesendableclass 0xd4, .TopLevelSendableClass211, _422, 0x0, v0 + wide.stlexvar 0x0, 0xd2 + ldhole + sta v0 + callruntime.definesendableclass 0xd5, .TopLevelSendableClass212, _424, 0x0, v0 + wide.stlexvar 0x0, 0xd3 + ldhole + sta v0 + callruntime.definesendableclass 0xd6, .TopLevelSendableClass213, _426, 0x0, v0 + wide.stlexvar 0x0, 0xd4 + ldhole + sta v0 + callruntime.definesendableclass 0xd7, .TopLevelSendableClass214, _428, 0x0, v0 + wide.stlexvar 0x0, 0xd5 + ldhole + sta v0 + callruntime.definesendableclass 0xd8, .TopLevelSendableClass215, _430, 0x0, v0 + wide.stlexvar 0x0, 0xd6 + ldhole + sta v0 + callruntime.definesendableclass 0xd9, .TopLevelSendableClass216, _432, 0x0, v0 + wide.stlexvar 0x0, 0xd7 + ldhole + sta v0 + callruntime.definesendableclass 0xda, .TopLevelSendableClass217, _434, 0x0, v0 + wide.stlexvar 0x0, 0xd8 + ldhole + sta v0 + callruntime.definesendableclass 0xdb, .TopLevelSendableClass218, _436, 0x0, v0 + wide.stlexvar 0x0, 0xd9 + ldhole + sta v0 + callruntime.definesendableclass 0xdc, .TopLevelSendableClass219, _438, 0x0, v0 + wide.stlexvar 0x0, 0xda + ldhole + sta v0 + callruntime.definesendableclass 0xdd, .TopLevelSendableClass220, _440, 0x0, v0 + wide.stlexvar 0x0, 0xdb + ldhole + sta v0 + callruntime.definesendableclass 0xde, .TopLevelSendableClass221, _442, 0x0, v0 + wide.stlexvar 0x0, 0xdc + ldhole + sta v0 + callruntime.definesendableclass 0xdf, .TopLevelSendableClass222, _444, 0x0, v0 + wide.stlexvar 0x0, 0xdd + ldhole + sta v0 + callruntime.definesendableclass 0xe0, .TopLevelSendableClass223, _446, 0x0, v0 + wide.stlexvar 0x0, 0xde + ldhole + sta v0 + callruntime.definesendableclass 0xe1, .TopLevelSendableClass224, _448, 0x0, v0 + wide.stlexvar 0x0, 0xdf + ldhole + sta v0 + callruntime.definesendableclass 0xe2, .TopLevelSendableClass225, _450, 0x0, v0 + wide.stlexvar 0x0, 0xe0 + ldhole + sta v0 + callruntime.definesendableclass 0xe3, .TopLevelSendableClass226, _452, 0x0, v0 + wide.stlexvar 0x0, 0xe1 + ldhole + sta v0 + callruntime.definesendableclass 0xe4, .TopLevelSendableClass227, _454, 0x0, v0 + wide.stlexvar 0x0, 0xe2 + ldhole + sta v0 + callruntime.definesendableclass 0xe5, .TopLevelSendableClass228, _456, 0x0, v0 + wide.stlexvar 0x0, 0xe3 + ldhole + sta v0 + callruntime.definesendableclass 0xe6, .TopLevelSendableClass229, _458, 0x0, v0 + wide.stlexvar 0x0, 0xe4 + ldhole + sta v0 + callruntime.definesendableclass 0xe7, .TopLevelSendableClass230, _460, 0x0, v0 + wide.stlexvar 0x0, 0xe5 + ldhole + sta v0 + callruntime.definesendableclass 0xe8, .TopLevelSendableClass231, _462, 0x0, v0 + wide.stlexvar 0x0, 0xe6 + ldhole + sta v0 + callruntime.definesendableclass 0xe9, .TopLevelSendableClass232, _464, 0x0, v0 + wide.stlexvar 0x0, 0xe7 + ldhole + sta v0 + callruntime.definesendableclass 0xea, .TopLevelSendableClass233, _466, 0x0, v0 + wide.stlexvar 0x0, 0xe8 + ldhole + sta v0 + callruntime.definesendableclass 0xeb, .TopLevelSendableClass234, _468, 0x0, v0 + wide.stlexvar 0x0, 0xe9 + ldhole + sta v0 + callruntime.definesendableclass 0xec, .TopLevelSendableClass235, _470, 0x0, v0 + wide.stlexvar 0x0, 0xea + ldhole + sta v0 + callruntime.definesendableclass 0xed, .TopLevelSendableClass236, _472, 0x0, v0 + wide.stlexvar 0x0, 0xeb + ldhole + sta v0 + callruntime.definesendableclass 0xee, .TopLevelSendableClass237, _474, 0x0, v0 + wide.stlexvar 0x0, 0xec + ldhole + sta v0 + callruntime.definesendableclass 0xef, .TopLevelSendableClass238, _476, 0x0, v0 + wide.stlexvar 0x0, 0xed + ldhole + sta v0 + callruntime.definesendableclass 0xf0, .TopLevelSendableClass239, _478, 0x0, v0 + wide.stlexvar 0x0, 0xee + ldhole + sta v0 + callruntime.definesendableclass 0xf1, .TopLevelSendableClass240, _480, 0x0, v0 + wide.stlexvar 0x0, 0xef + ldhole + sta v0 + callruntime.definesendableclass 0xf2, .TopLevelSendableClass241, _482, 0x0, v0 + wide.stlexvar 0x0, 0xf0 + ldhole + sta v0 + callruntime.definesendableclass 0xf3, .TopLevelSendableClass242, _484, 0x0, v0 + wide.stlexvar 0x0, 0xf1 + ldhole + sta v0 + callruntime.definesendableclass 0xf4, .TopLevelSendableClass243, _486, 0x0, v0 + wide.stlexvar 0x0, 0xf2 + ldhole + sta v0 + callruntime.definesendableclass 0xf5, .TopLevelSendableClass244, _488, 0x0, v0 + wide.stlexvar 0x0, 0xf3 + ldhole + sta v0 + callruntime.definesendableclass 0xf6, .TopLevelSendableClass245, _490, 0x0, v0 + wide.stlexvar 0x0, 0xf4 + ldhole + sta v0 + callruntime.definesendableclass 0xf7, .TopLevelSendableClass246, _492, 0x0, v0 + wide.stlexvar 0x0, 0xf5 + ldhole + sta v0 + callruntime.definesendableclass 0xf8, .TopLevelSendableClass247, _494, 0x0, v0 + wide.stlexvar 0x0, 0xf6 + ldhole + sta v0 + callruntime.definesendableclass 0xf9, .TopLevelSendableClass248, _496, 0x0, v0 + wide.stlexvar 0x0, 0xf7 + ldhole + sta v0 + callruntime.definesendableclass 0xfa, .TopLevelSendableClass249, _498, 0x0, v0 + wide.stlexvar 0x0, 0xf8 + ldhole + sta v0 + callruntime.definesendableclass 0xfb, .TopLevelSendableClass250, _500, 0x0, v0 + wide.stlexvar 0x0, 0xf9 + ldhole + sta v0 + callruntime.definesendableclass 0xfc, .TopLevelSendableClass251, _502, 0x0, v0 + wide.stlexvar 0x0, 0xfa + ldhole + sta v0 + callruntime.definesendableclass 0xfd, .TopLevelSendableClass252, _504, 0x0, v0 + wide.stlexvar 0x0, 0xfb + ldhole + sta v0 + callruntime.definesendableclass 0xfe, .TopLevelSendableClass253, _506, 0x0, v0 + wide.stlexvar 0x0, 0xfc + ldhole + sta v0 + callruntime.definesendableclass 0x100, .TopLevelSendableClass254, _508, 0x0, v0 + wide.stlexvar 0x0, 0xfd + ldhole + sta v0 + callruntime.definesendableclass 0x101, .TopLevelSendableClass255, _510, 0x0, v0 + wide.stlexvar 0x0, 0xfe + ldhole + sta v0 + callruntime.definesendableclass 0x102, .SendableTestClass1, _512, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x103, 0x1, v2 + sta v0 + tryldglobalbyname 0x105, print + sta v1 + lda v0 + ldobjbyname 0x106, v + sta v0 + lda v1 + callarg1 0x0, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..85b14f1a81252a13aef8763a543c9a5fea4bd020 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,50 @@ +slotNum = 0x4 +.language ECMAScript +.function any .#~@0=#PropertyByName(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + lda a3 + stobjbyname 0x0, name, a2 + lda a4 + stobjbyname 0x2, age, a2 + lda a2 + return +label_2: +} + +slotNum = 0xa +.language ECMAScript +.function any .#~@0>#init(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, Object + sta v0 + ldobjbyname 0x1, defineProperty + sta v1 + lda.str name + sta v2 + createobjectwithbuffer 0x3, _2 + sta v3 + lda a2 + ldobjbyname 0x4, name + definepropertybyname 0x6, value, v3 + lda v1 + callthis3 0x8, v0, a2, v2, v3 + returnundefined +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~@0=#PropertyByName, _3, 0x2, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..601217c7f803b481980dfa92b43bbc592ea37673 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,50 @@ +slotNum = 0x4 +.language ECMAScript +.function any .PropertyByName(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + lda a3 + stobjbyname 0x0, name, a2 + lda a4 + stobjbyname 0x2, age, a2 + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .PropertyByName, _2, 0x2, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + +slotNum = 0xa +.language ECMAScript +.function any .init(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, Object + sta v0 + ldobjbyname 0x1, defineProperty + sta v1 + lda.str name + sta v2 + createobjectwithbuffer 0x3, _1 + sta v3 + lda a2 + ldobjbyname 0x4, name + definefieldbyname 0x6, value, v3 + lda v1 + callthis3 0x8, v0, a2, v2, v3 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts b/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts index 28f0f7ccd60b1c00cf6384d36d67b262bcadf414..7621af1e5d9b3862daa9db2cfd7f44f7e1fd3162 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +const defaultImportValue = 'a0'; +export default defaultImportValue; export const a1 = 'a1'; export const a2 = 'a2'; export const a3 = 'a3'; diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..674e91d58380a2a0a9c4e4ddc2a293b056139088 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,42 @@ +slotNum = 0x9 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_8: +label_0: + ldtrue + sta v0 + callruntime.isfalse 0x0 + jnez label_1 +label_2: + tryldglobalbyname 0x1, print + sta v0 + lda.str true + sta v1 + lda v0 + callarg1 0x2, v1 + jmp label_3 +label_1: + lda v0 + callruntime.istrue 0x4 + jnez label_4 +label_5: + ldtrue + jmp label_6 +label_4: + ldfalse +label_6: + callruntime.isfalse 0x5 + jnez label_3 +label_7: + tryldglobalbyname 0x6, print + sta v0 + lda.str false + sta v1 + lda v0 + callarg1 0x7, v1 +label_3: + returnundefined +label_9: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts index c6d38d659cc2f08b4ecbf4c2f85fd5aba971105b..af97b159ccf940eba25d768165c7c433c3030665 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import lazy { a1, a2 } from 'import_target/import_target' +import lazy defaultImportValue, { a1, a2 } from 'import_target/import_target'; class SendableLazyLoading { name: string = a1; @@ -23,4 +23,5 @@ class SendableLazyLoading { } let a: SendableLazyLoading = new SendableLazyLoading(); let b: string = a2; -print(a.name); \ No newline at end of file +print(a.name); +print(defaultImportValue); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index c16a17b509eec682c34ca20b640b22acbe916705..fffe779103603c565c59ed4291b3e8f845472983 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: @@ -14,7 +13,7 @@ label_0: label_2: } -slotNum = 0x8 +slotNum = 0xb .language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: @@ -35,6 +34,13 @@ label_0: sta v0 lda v1 callarg1 0x6, v0 + tryldglobalbyname 0x8, print + sta v0 + callruntime.ldlazymodulevar 0x2 + sta v1 + throw.undefinedifholewithname defaultImportValue + lda v0 + callarg1 0x9, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index c92d705a82f60af9eb8e273ccbe4ff80b91f30a2..4eb3781c08365867a1d3f2c902f364bb6d80f7a6 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x2 -expectedProperty = 0x1 .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: label_0: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e0604bf53bd57fc0fb37f1192e47543d62d32e6 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,49 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldlazysendablemodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + lda a2 + return +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#SendableLazyLoading, _4, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + callruntime.ldlazymodulevar 0x1 + throw.undefinedifholewithname a2 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + tryldglobalbyname 0x8, print + sta v0 + callruntime.ldlazymodulevar 0x2 + sta v1 + throw.undefinedifholewithname defaultImportValue + lda v0 + callarg1 0x9, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt index da0f8ed91a8f2f0f067b3bdf26265d5ca48cf82c..6e9673b4dea09d930a094450f02c1da3fd633950 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt @@ -1 +1,2 @@ a1 +a0 diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..7511f0e00ccb5dcc6989df72d90e24f0f5c69ad0 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [lazy_import_bytecode.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 3222f27c481265e6493a5d9c8a663a84d4cf2e67..851a53ce7363f5ce7229777de047982dffe9ffa1 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 3b520c914cdad34fd6e22aa8273715778451727a..568f9fd81ef5d8aecb3c1e95d412ecb4c4a301e3 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x2 -expectedProperty = 0x1 .function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { label_1: label_0: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3222f27c481265e6493a5d9c8a663a84d4cf2e67 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,40 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.wideldlazysendablemodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x0, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x9 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#WideSendableLazyLoading, _4, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + callruntime.wideldlazymodulevar 0xae + sta v1 + throw.undefinedifholewithname a256 + tryldglobalbyname 0x3, print + callarg1 0x4, v0 + tryldglobalbyname 0x6, print + callarg1 0x7, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..ab88cd29d06de314c32b532b9e460ea3ccadb4a7 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [wide_lazy_import_bytecode.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts b/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts index 4e0ec5ce3ab1c2dbfbc76e0dcf6f3974f995bf1c..6b52c1d49d3212a5ab1716ca26a88c2a636ae681 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts +++ b/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts @@ -17,4 +17,9 @@ export function lazyImportFunc(resolve) { print("lazy ImportFunc called"); resolve(1); +} + +export default function defaultImportFunc(resolve) { + print("lazy ImportFunc called"); + resolve(1); } \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts index 985261dcad35bd3a0ee8f8f2eec6acc94905daa8..d3081c17aadfef6b27544ed7204bd47e478c0229 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts @@ -13,5 +13,5 @@ * limitations under the License. */ -import lazy { lazyImportFunc } from 'import_target/import_target' +import lazy defaultImportFunc, { lazyImportFunc } from 'import_target/import_target' print("lazy import"); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt index bacfd1f3f009771155f2b5d30da1fb280e2bcc99..cdf751cc03236b839a427060c322ff6d998b627f 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt @@ -9,15 +9,42 @@ "loc": { "start": { "line": 16, - "column": 37 + "column": 56 }, "end": { "line": 16, - "column": 66 + "column": 85 } } }, "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "defaultImportFunc", + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, { "type": "ImportSpecifier", "local": { @@ -26,11 +53,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } }, @@ -40,11 +67,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } }, @@ -52,11 +79,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } } @@ -69,7 +96,7 @@ }, "end": { "line": 16, - "column": 66 + "column": 85 } } }, diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..6792ee776f64a7c5434c432c6e78250ea6cdb999 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [lazy_import.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..71d2c9ab90d726207311beb677d5ff4e2f418031 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +TypeError: is not callable \ No newline at end of file diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt.js b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt.js similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt.js rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt.js diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export.ts b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export.ts similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export.ts rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export.ts diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt diff --git a/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations.ts b/es2panda/test/version_control/API20/bytecode_feature/annotations.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cad18eb174c49ba7ea02d55265561848ba7c808 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + + +@interface __$$ETS_ANNOTATION$$__Anno { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno() +class A { } \ No newline at end of file diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..13510081b9bc44b4192aa01dadb03e5c04ca5537 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt @@ -0,0 +1 @@ +pandafile \ No newline at end of file diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..11dd37ab8b3eba4994f5ecd5ed78a1770745580d --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt @@ -0,0 +1,24 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_runtime_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d327c04a727e2e2662cbd9470a2e080282f675a7 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt @@ -0,0 +1,3 @@ +SyntaxError: Current configuration does not support using annotations. Annotations can be used in the version of API 20 or higher versions. +Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 20 or higher version.> If you're running es2abc in commandline without IDE, please check whether target-api-version and enable-annotations options are correctly configured. [annotations.ts:17:12] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/typescript/core/destructuringContext.cpp b/es2panda/typescript/core/destructuringContext.cpp index 2243a62b95c8e8002b90d50c923695fbcf11f142..9c84408246194670a97f54c63ad062f409e6b010 100644 --- a/es2panda/typescript/core/destructuringContext.cpp +++ b/es2panda/typescript/core/destructuringContext.cpp @@ -197,6 +197,7 @@ void DestructuringContext::HandleIdentifierPattern(const ir::AssignmentExpressio void ArrayDestructuringContext::ValidateInferedType() { + CHECK_NOT_NULL(inferedType_); if (!inferedType_->IsArrayType() && !inferedType_->IsUnionType() && (!inferedType_->IsObjectType() || !inferedType_->AsObjectType()->IsTupleType())) { checker_->ThrowTypeError( @@ -521,6 +522,7 @@ void ArrayDestructuringContext::Start() void ObjectDestructuringContext::ValidateInferedType() { + CHECK_NOT_NULL(inferedType_); if (!inferedType_->IsObjectType()) { return; } diff --git a/es2panda/typescript/types/typeRelation.cpp b/es2panda/typescript/types/typeRelation.cpp index b87d32b1352c06959645e7d7cb9b7a7495d4cc7f..0603f632c4802834130b8bdfd4316d6f5201c83d 100644 --- a/es2panda/typescript/types/typeRelation.cpp +++ b/es2panda/typescript/types/typeRelation.cpp @@ -82,6 +82,7 @@ bool TypeRelation::IsIdenticalTo(Type *source, Type *target) CHECK_NOT_NULL(target); result_ = CacheLookup(source, target, checker_->IdenticalResults(), RelationType::IDENTICAL); if (result_ == RelationResult::CACHE_MISS) { + CHECK_NOT_NULL(source); checker_->ResolveStructuredTypeMembers(source); checker_->ResolveStructuredTypeMembers(target); result_ = RelationResult::FALSE; diff --git a/es2panda/util/commonUtil.h b/es2panda/util/commonUtil.h index f63afffa7dcf694a46b4aa674ab996b0c5499e1e..036d49c7658dd5c9e9d12878a744cdc23d9d976e 100644 --- a/es2panda/util/commonUtil.h +++ b/es2panda/util/commonUtil.h @@ -48,6 +48,7 @@ constexpr char NORMALIZED_OHMURL_PREFIX = '@'; constexpr char SLASH_TAG = '/'; constexpr char CHAR_VERTICAL_LINE = '|'; constexpr char COLON_SEPARATOR = ':'; +constexpr char DOT_SEPARATOR = '.'; constexpr size_t ORIGINAL_PKG_NAME_POS = 0U; constexpr size_t TARGET_PKG_NAME_POS = 1U; @@ -104,15 +105,15 @@ void VisitDyanmicImports(ConstReferenceIf function, // The dynamicimport bytecode should not have label, otherwise the dyanmicimport might be a jump // target and its parameter is a variable instead of a constant string expression (Check // AbcCodeProcessor::AddJumpLabels for more details). - if (iter->opcode != pandasm::Opcode::DYNAMICIMPORT || iter->set_label) { + if ((*iter)->opcode != pandasm::Opcode::DYNAMICIMPORT || (*iter)->IsLabel()) { continue; } auto prevIns = iter - 1; - if (prevIns->opcode != pandasm::Opcode::LDA_STR) { + if ((*prevIns)->opcode != pandasm::Opcode::LDA_STR) { continue; } - ASSERT(prevIns->ids.size() == 1); - cb(prevIns->ids[0]); // 0: index of the string in lda.str bytecode + ASSERT((*prevIns)->Ids().size() == 1); + cb((*prevIns)->GetId(0)); // 0: index of the string in lda.str bytecode } } } // namespace panda::es2panda::util diff --git a/es2panda/util/helpers.cpp b/es2panda/util/helpers.cpp index 8d4d486be4f8b9264dec4c84b074eff9086cb9ea..e0cd4127024cff5e8002f30f66880dc8fc786b29 100644 --- a/es2panda/util/helpers.cpp +++ b/es2panda/util/helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -15,6 +15,7 @@ #include "helpers.h" +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #ifdef ENABLE_BYTECODE_OPT @@ -675,10 +677,9 @@ static std::string GetTempOutputName(const std::string &inputFile) void Helpers::AnalysisProgram(panda::pandasm::Program *prog, const std::string &inputFile) { +#ifdef PANDA_WITH_BYTECODE_OPTIMIZER std::map stat; std::map *statp = &stat; - -#ifdef PANDA_WITH_BYTECODE_OPTIMIZER auto tempOutput = GetTempOutputName(inputFile); bool exists = false; auto mapsp = &panda::bytecodeopt::BytecodeAnalysisResults::GetOrCreateBytecodeMaps(tempOutput, exists); @@ -699,11 +700,11 @@ void Helpers::AnalysisProgram(panda::pandasm::Program *prog, const std::string & void Helpers::OptimizeProgram(panda::pandasm::Program *prog, const std::string &inputFile) { - std::map stat; - std::map *statp = &stat; auto tempOutput = GetTempOutputName(inputFile); #ifdef PANDA_WITH_BYTECODE_OPTIMIZER + std::map stat; + std::map *statp = &stat; const uint32_t COMPONENT_MASK = panda::Logger::Component::ASSEMBLER | panda::Logger::Component::BYTECODE_OPTIMIZER | panda::Logger::Component::COMPILER; @@ -958,13 +959,41 @@ bool Helpers::BelongingToRecords(const std::string &name, const std::unordered_s return retainRecordSet.find(recordName) != retainRecordSet.end(); } +bool Helpers::IsInnerAnnotationRecordName(const std::string &name) +{ + return name == panda::abc2program::CONCURRENT_MODULE_REQUEST_RECORD_NAME || + name == panda::abc2program::SLOT_NUMBER_RECORD_NAME || + name == panda::abc2program::EXPECTED_PROPERTY_COUNT_RECORD_NAME; +} + +std::string Helpers::RemoveRecordSuffixAnnotationName(const std::string &name) +{ + auto pos = name.rfind(util::DOT_SEPARATOR); + if (pos == std::string::npos) { + return name; + } + return name.substr(0, pos); +} + void Helpers::RemoveProgramsRedundantData(std::map &progsInfo, const std::map> &resolvedDepsRelation) { auto progInfoIter = progsInfo.begin(); while (progInfoIter != progsInfo.end()) { + auto name = progInfoIter->first; + auto &program = progInfoIter->second->program; + /** + * The record name of a user-defined annotation is the annotation name concatenated with the record name of the + * file where it is declared. In order to preserve the annotated record, it is necessary to remove the + * concatenated annotation name from the record name before perform dependency matching. + */ + if (!util::RecordNotGeneratedFromBytecode(name) && + (program.record_table.begin()->second.metadata->GetAccessFlags() & ACC_ANNOTATION) != 0 && + !IsInnerAnnotationRecordName(program.record_table.begin()->first)) { + name = RemoveRecordSuffixAnnotationName(name); + } // remove redundant sourcefiles and bytecodefile data which are not dependant in compilation - if (resolvedDepsRelation.find(progInfoIter->first) == resolvedDepsRelation.end()) { + if (resolvedDepsRelation.find(name) == resolvedDepsRelation.end()) { progInfoIter = progsInfo.erase(progInfoIter); continue; } @@ -986,9 +1015,14 @@ bool Helpers::IsSupportLazyImportVersion(int apiVersion, std::string subApiVersi (subApiVersion == SUB_API_VERSION_1 || subApiVersion == SUB_API_VERSION_2))); } -bool Helpers::IsSupportLazyImportDefaultVersion(int apiVersion) +bool Helpers::IsEnableExpectedPropertyCountApiVersion(int apiVersion) +{ + return !(apiVersion < ENABLE_EXPECTED_PROPERTY_COUNT_MIN_SUPPORTED_API_VERSION); +} + +bool Helpers::IsSupportAnnotationVersion(int apiVersion) { - return !(apiVersion < LAZY_IMPORT_DEFAULT_MIN_SUPPORTED_API_VERSION); + return !(apiVersion < ANNOTATION_SUPPORTED_API_VERSION); } } // namespace panda::es2panda::util diff --git a/es2panda/util/helpers.h b/es2panda/util/helpers.h index e831d3727518480f2b2fdabb8bd3c57c335b558a..d2a0614fab33466bdd8a5d1c8f5ba974435d1b5f 100644 --- a/es2panda/util/helpers.h +++ b/es2panda/util/helpers.h @@ -182,11 +182,14 @@ public: static bool IsSpecialScopeName(const util::StringView &str); static bool BelongingToRecords(const std::string &name, const std::unordered_set &retainRecordSet, const std::string &delimiter = std::string(DOT)); + static bool IsInnerAnnotationRecordName(const std::string &name); + static std::string RemoveRecordSuffixAnnotationName(const std::string &name); static void RemoveProgramsRedundantData(std::map &progsInfo, const std::map> &resolveDepsRelation); static bool IsDefaultApiVersion(int apiVersion, std::string subApiVersion); static bool IsSupportLazyImportVersion(int apiVersion, std::string subApiVersion); - static bool IsSupportLazyImportDefaultVersion(int apiVersion); + static bool IsEnableExpectedPropertyCountApiVersion(int apiVersion); + static bool IsSupportAnnotationVersion(int apiVersion); static bool IsSupportEtsImplementsVersion(int apiVersion); static const uint32_t MAX_DOUBLE_DIGIT = 310; @@ -224,10 +227,11 @@ public: ABC_TO_PROGRAM_MIN_SUPPORTED_BYTECODE_VERSION {12, 0, 2, 0}; static const int32_t SENDABLE_FUNCTION_MIN_SUPPORTED_API_VERSION = 12; static const int32_t LAZY_IMPORT_MIN_SUPPORTED_API_VERSION = 12; - static const int32_t LAZY_IMPORT_DEFAULT_MIN_SUPPORTED_API_VERSION = 18; static const int32_t SENDABLE_LAZY_LOADING_MIN_SUPPORTED_API_VERSION = 12; static const int8_t SUPER_CALL_OPT_MIN_SUPPORTED_API_VERSION = 18; static const int8_t SENDABLE_CLASS_USING_LOCAL_MODULE_VAR_MIN_SUPPORTED_API_VERSION = 18; + static const int8_t ENABLE_EXPECTED_PROPERTY_COUNT_MIN_SUPPORTED_API_VERSION = 18; + static const int8_t ANNOTATION_SUPPORTED_API_VERSION = 20; static constexpr std::string_view SUB_API_VERSION_1 = "beta1"; static constexpr std::string_view SUB_API_VERSION_2 = "beta2"; static constexpr std::string_view DEFAULT_SUB_API_VERSION = SUB_API_VERSION_1; diff --git a/es2panda/util/patchFix.cpp b/es2panda/util/patchFix.cpp index e7c0dd5646409d14733a4461a33274cede0fc5a3..4a05c01108ebe254a14ca8a36e829325cfce24c3 100644 --- a/es2panda/util/patchFix.cpp +++ b/es2panda/util/patchFix.cpp @@ -176,18 +176,18 @@ std::vector> PatchFix::GenerateFunctionAndCl ss << ") {" << std::endl; for (const auto &ins : func->ins) { - ss << (ins.set_label ? "" : "\t") << ins.ToString("", true, func->GetTotalRegs()) << " "; - if (ins.opcode == panda::pandasm::Opcode::CREATEARRAYWITHBUFFER || - ins.opcode == panda::pandasm::Opcode::CREATEOBJECTWITHBUFFER) { - int64_t bufferIdx = GetLiteralIdxFromStringId(ins.ids[0]); + ss << (ins->IsLabel() ? "" : "\t") << ins->ToString("", true, func->GetTotalRegs()) << " "; + if (ins->opcode == panda::pandasm::Opcode::CREATEARRAYWITHBUFFER || + ins->opcode == panda::pandasm::Opcode::CREATEOBJECTWITHBUFFER) { + int64_t bufferIdx = GetLiteralIdxFromStringId(ins->GetId(0)); ss << ExpandLiteral(bufferIdx, literalBuffers) << " "; - } else if (ins.opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { - CollectFunctionsWithDefinedClasses(func->name, ins.ids[0]); - int64_t bufferIdx = GetLiteralIdxFromStringId(ins.ids[1]); + } else if (ins->opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { + CollectFunctionsWithDefinedClasses(func->name, ins->GetId(0)); + int64_t bufferIdx = GetLiteralIdxFromStringId(ins->GetId(1)); std::string literalStr = ExpandLiteral(bufferIdx, literalBuffers); auto classHash = Helpers::GetHashString(literalStr); - hashList.push_back(std::pair(ins.ids[0], classHash)); - CollectClassMemberFunctions(ins.ids[0], bufferIdx, literalBuffers); + hashList.push_back(std::pair(ins->GetId(0), classHash)); + CollectClassMemberFunctions(ins->GetId(0), bufferIdx, literalBuffers); } ss << " "; } @@ -319,27 +319,27 @@ uint32_t PatchFix::GetPatchLexicalIdx(const std::string &variableName) return topScopeLexEnvs_[variableName]; } -bool IsFunctionOrClassDefineIns(panda::pandasm::Ins &ins) +bool IsFunctionOrClassDefineIns(panda::pandasm::Ins *ins) { - if (ins.opcode == panda::pandasm::Opcode::DEFINEMETHOD || - ins.opcode == panda::pandasm::Opcode::DEFINEFUNC || - ins.opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { + if (ins->opcode == panda::pandasm::Opcode::DEFINEMETHOD || + ins->opcode == panda::pandasm::Opcode::DEFINEFUNC || + ins->opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { return true; } return false; } -bool IsStPatchVarIns(panda::pandasm::Ins &ins) +bool IsStPatchVarIns(panda::pandasm::Ins *ins) { - return ins.opcode == panda::pandasm::Opcode::WIDE_STPATCHVAR; + return ins->opcode == panda::pandasm::Opcode::WIDE_STPATCHVAR; } void PatchFix::CollectFuncDefineIns(panda::pandasm::Function *func) { for (size_t i = 0; i < func->ins.size(); ++i) { - if (IsFunctionOrClassDefineIns(func->ins[i])) { - funcDefineIns_.push_back(func->ins[i]); // push define ins - funcDefineIns_.push_back(func->ins[i + 1]); // push store ins + if (IsFunctionOrClassDefineIns(func->ins[i].get())) { + funcDefineIns_.push_back(func->ins[i].get()); // push define ins + funcDefineIns_.push_back(func->ins[i + 1].get()); // push store ins } } } @@ -377,31 +377,23 @@ void PatchFix::HandleModifiedDefinedClassFunc(panda::pandasm::Program *prog) } } -void PatchFix::AddHeadAndTailInsForPatchFuncMain0(std::vector &ins) +void PatchFix::AddHeadAndTailInsForPatchFuncMain0(std::vector &ins) { - panda::pandasm::Ins returnUndefine; - returnUndefine.opcode = pandasm::Opcode::RETURNUNDEFINED; - + auto returnUndefined = new pandasm::Returnundefined(); if (ins.size() == 0) { - ins.push_back(returnUndefine); + ins.emplace_back(returnUndefined); return; } - panda::pandasm::Ins newLexenv; - newLexenv.opcode = pandasm::Opcode::NEWLEXENV; - newLexenv.imms.reserve(1); - auto newFuncNum = long(ins.size() / 2); // each new function has 2 ins: define and store - newLexenv.imms.emplace_back(newFuncNum); - - ins.insert(ins.begin(), newLexenv); - ins.push_back(returnUndefine); + auto newLexenv = new pandasm::Newlexenv(long(ins.size() / 2)); // each new function has 2 ins: define and stor + ins.emplace(ins.begin(), newLexenv); + ins.emplace_back(returnUndefined); } -void PatchFix::AddTailInsForPatchFuncMain1(std::vector &ins) +void PatchFix::AddTailInsForPatchFuncMain1(std::vector &ins) { - panda::pandasm::Ins returnUndefined; - returnUndefined.opcode = pandasm::Opcode::RETURNUNDEFINED; - ins.push_back(returnUndefined); + auto returnUndefined = new pandasm::Returnundefined(); + ins.emplace_back(returnUndefined); } void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchFuncMain0, @@ -415,19 +407,19 @@ void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchF patchFuncMain1.params.emplace_back(panda::pandasm::Type("any", 0), patchFuncMain1.language); } - std::vector patchMain0DefineIns; - std::vector patchMain1DefineIns; + std::vector patchMain0DefineIns; + std::vector patchMain1DefineIns; for (size_t i = 0; i < funcDefineIns_.size(); ++i) { if (IsFunctionOrClassDefineIns(funcDefineIns_[i])) { - auto &name = funcDefineIns_[i].ids[0]; + auto name = funcDefineIns_[i]->GetId(0); if (newFuncNames_.count(name) && IsStPatchVarIns(funcDefineIns_[i + 1])) { - patchMain0DefineIns.push_back(funcDefineIns_[i]); - patchMain0DefineIns.push_back(funcDefineIns_[i + 1]); + patchMain0DefineIns.emplace_back(funcDefineIns_[i]->DeepCopy()); + patchMain0DefineIns.emplace_back(funcDefineIns_[i + 1]->DeepCopy()); continue; } if (patchFuncNames_.count(name) || modifiedClassNames_.count(name)) { - patchMain1DefineIns.push_back(funcDefineIns_[i]); + patchMain1DefineIns.emplace_back(funcDefineIns_[i]->DeepCopy()); continue; } } @@ -436,8 +428,8 @@ void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchF AddHeadAndTailInsForPatchFuncMain0(patchMain0DefineIns); AddTailInsForPatchFuncMain1(patchMain1DefineIns); - patchFuncMain0.ins = patchMain0DefineIns; - patchFuncMain1.ins = patchMain1DefineIns; + patchFuncMain0.ins = std::move(patchMain0DefineIns); + patchFuncMain1.ins = std::move(patchMain1DefineIns); patchFuncMain0.return_type = panda::pandasm::Type("any", 0); patchFuncMain1.return_type = panda::pandasm::Type("any", 0); diff --git a/es2panda/util/patchFix.h b/es2panda/util/patchFix.h index 1802233e0edb3f484bb2a6db2931bf0a9f43d2ee..db26b4a25e12f078c2755562b9858b636c8bd9b3 100644 --- a/es2panda/util/patchFix.h +++ b/es2panda/util/patchFix.h @@ -99,8 +99,8 @@ private: std::string ExpandLiteral(int64_t bufferIdx, LiteralBuffers &literalBuffers); std::string ConvertLiteralToString(std::vector &literalBuffer); void CollectFuncDefineIns(panda::pandasm::Function *func); - void AddHeadAndTailInsForPatchFuncMain0(std::vector &ins); - void AddTailInsForPatchFuncMain1(std::vector &ins); + void AddHeadAndTailInsForPatchFuncMain0(std::vector &ins); + void AddTailInsForPatchFuncMain1(std::vector &ins); void CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchFuncMain0, panda::pandasm::Function &patchFuncMain1); bool IsAnonymousOrSpecialOrDuplicateFunction(const std::string &funcName); @@ -135,7 +135,7 @@ private: ArenaUnorderedMap topScopeLexEnvs_; ArenaSet patchFuncNames_; ArenaSet newFuncNames_; - ArenaVector funcDefineIns_; + ArenaVector funcDefineIns_; ArenaSet modifiedClassNames_; ArenaUnorderedMap> classMemberFunctions_; ArenaUnorderedMap> funcDefinedClasses_; diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index 5a5df7e3977b3c1bb2d5f6d2dd826691effdd79f..dc95bac79ac2b55eb8d81d4bed9bdcb558a24adf 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -11,7 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} if (ark_standalone_build) { import("$build_root/ark.gni") @@ -23,12 +29,16 @@ config("libes2panda_public_config") { include_dirs = [ "$target_gen_dir", "$target_gen_dir/include", - "$target_gen_dir/generated", - "//third_party/icu/icu4c/source/common", - "//third_party/icu/icu4c/source/i18n", - "//third_party/icu/icu4c/source", "$ark_es2panda_root", ] + if (ark_standalone_build || ark_static_standalone_build) { + include_dirs += [ + "$target_gen_dir/generated", + "//third_party/icu/icu4c/source/common", + "//third_party/icu/icu4c/source/i18n", + "//third_party/icu/icu4c/source", + ] + } } action("check_build_system_consistency") { @@ -216,8 +226,8 @@ libes2panda_sources = [ "compiler/lowering/ets/cfgBuilderPhase.cpp", "compiler/lowering/ets/constantExpressionLowering.cpp", "compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp", - "compiler/lowering/ets/declareOverloadLowering.cpp", "compiler/lowering/ets/declGenPhase.cpp", + "compiler/lowering/ets/declareOverloadLowering.cpp", "compiler/lowering/ets/defaultParametersInConstructorLowering.cpp", "compiler/lowering/ets/defaultParametersLowering.cpp", "compiler/lowering/ets/dynamicImport.cpp", @@ -473,11 +483,11 @@ libes2panda_sources = [ "parser/ETSparserClasses.cpp", "parser/ETSparserEnums.cpp", "parser/ETSparserExpressions.cpp", - "parser/ETSparserJsDocInfo.cpp", "parser/ETSparserNamespaces.cpp", "parser/ETSparserStatements.cpp", "parser/ETSparserTypes.cpp", "parser/JSparser.cpp", + "parser/JsdocHelper.cpp", "parser/TSparser.cpp", "parser/ThrowingTypedParser.cpp", "parser/TypedParser.cpp", @@ -500,6 +510,7 @@ libes2panda_sources = [ "util/es2pandaMacros.cpp", "util/helpers.cpp", "util/importPathManager.cpp", + "util/nameMangler.cpp", "util/path.cpp", "util/perfMetrics.cpp", "util/plugin.cpp", @@ -766,7 +777,6 @@ HEADERS_TO_BE_PARSED = [ "ir/ets/etsParameterExpression.h", "ir/ts/tsTypeQuery.h", "ir/expressions/importExpression.h", - "ir/jsDocAllowed.h", "varbinder/variable.h", "varbinder/scope.h", "varbinder/varbinder.h", @@ -796,7 +806,6 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/varbinder/variableFlags.yaml", "$LIBGEN_DIR/gen/headers/ir/typed.yaml", "$LIBGEN_DIR/gen/headers/ir/annotationAllowed.yaml", - "$LIBGEN_DIR/gen/headers/ir/jsDocAllowed.yaml", "$LIBGEN_DIR/gen/headers/es2panda.yaml", "$LIBGEN_DIR/gen/headers/ir/statements/labelledStatement.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ts/unknownType.yaml", @@ -1056,7 +1065,7 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/util/importPathManager.yaml", "$LIBGEN_DIR/gen/headers/util/path.yaml", "$LIBGEN_DIR/gen/headers/util/arktsconfig.yaml", - "$LIBGEN_DIR/gen/headers/util/options.yaml" + "$LIBGEN_DIR/gen/headers/util/options.yaml", ] ES2PANDA_API = [ @@ -1130,26 +1139,45 @@ config("libes2panda_config") { ] } -libes2panda_configs = [ - "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + libes2panda_configs = [ "$ark_root:ark_config" ] + libes2panda_public_configs = [ "$ark_root:ark_config" ] +} else { + libes2panda_configs = + [ "//build/config/components/runtime_core/static_core:ark_common_config" ] + libes2panda_public_configs = + [ "//build/config/components/runtime_core/static_core:ark_common_config" ] +} + +if (ark_standalone_build || ark_static_standalone_build) { + libes2panda_configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libarkfile:arkfile_public_config", + "$ark_root/abc2program:arkts_abc2program_public_config", + ] +} + +libes2panda_configs += [ ":libes2panda_public_config", ":libes2panda_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/abc2program:arkts_abc2program_public_config", ] -libes2panda_public_configs = [ - "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", +if (ark_standalone_build || ark_static_standalone_build) { + libes2panda_public_configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libarkfile:arkfile_public_config", + "$ark_root/bytecode_optimizer:bytecodeopt_public_config", + "$ark_root/runtime:arkruntime_public_config", + "$ark_root/compiler:arkcompiler_public_config", + ] +} + +libes2panda_public_configs += [ ":libes2panda_public_config", ":libes2panda_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/bytecode_optimizer:bytecodeopt_public_config", - "$ark_root/compiler:arkcompiler_public_config", - "$ark_root/runtime:arkruntime_public_config", ] ohos_shared_library("libes2panda") { @@ -1179,17 +1207,31 @@ ohos_source_set("libes2panda_frontend_static") { ":gen_es2panda_lexer_token_inl", ":isa_gen_es2panda_formats_h", ":isa_gen_es2panda_isa_h", - "$ark_third_party_root/icu/icu4c:static_icui18n", - "$ark_third_party_root/icu/icu4c:static_icuuc", ] external_deps = [ + "runtime_core:libarktsabc2program_package", "runtime_core:libarktsassembler_package", "runtime_core:libarktsbase_package", "runtime_core:libarktscompiler_package", "runtime_core:libarktsfile_package", - "runtime_core:libarktsabc2program_package", sdk_libc_secshared_dep, ] + if (ark_standalone_build || ark_static_standalone_build) { + deps += [ + "$ark_third_party_root/icu/icu4c:static_icui18n", + "$ark_third_party_root/icu/icu4c:static_icuuc", + ] + } else { + external_deps += [ + "icu:static_icui18n", + "icu:static_icuuc", + "runtime_core:arkts_abc2program_public_headers", + "runtime_core:assembler_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + ] + } part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -1227,27 +1269,39 @@ ohos_source_set("libes2panda_public_frontend_static") { deps = [ ":libes2panda_frontend_static" ] - if (ark_standalone_build || ark_static_standalone_build) { - deps += [ - "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", - "$ark_root/abc2program:libarktsabc2program_package", - "$ark_root/assembler:libarktsassembler", - "$ark_root/compiler:libarktscompiler", - "$ark_root/libpandabase:libarktsbase", - "$ark_root/libpandafile:libarktsfile", - ] - } - if (target_os != "win" && target_os != "mingw" && target_os != "winuwp") { deps += [ ":generate_ets2panda_info" ] defines = [ "ES2PANDA_COMPILE_BY_GN" ] } external_deps = [ - "runtime_core:libarktsbytecodeopt_package", "runtime_core:libarktsabc2program_package", + "runtime_core:libarktsbytecodeopt_package", sdk_libc_secshared_dep, ] + + if (ark_standalone_build || ark_static_standalone_build) { + deps += [ + "$ark_root/abc2program:libarktsabc2program_package", + "$ark_root/assembler:libarktsassembler", + "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", + "$ark_root/compiler:libarktscompiler", + "$ark_root/libpandabase:libarktsbase", + "$ark_root/libarkfile:libarktsfile", + ] + } else { + external_deps += [ + "runtime_core:assembler_headers", + "runtime_core:bytecode_optimizer_headers", + "runtime_core:compiler_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + "runtime_core:runtime_headers", + "runtime_core:verification_headers", + ] + } + part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -1335,10 +1389,10 @@ template("panda_code_fix_gen") { destination = invoker.destination api = api_list if (defined(invoker.requires)) { - requires = invoker.requires + requires = invoker.requires } if (defined(invoker.extra_dependencies)) { - extra_dependencies = invoker.extra_dependencies + extra_dependencies = invoker.extra_dependencies } } } diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 73d465ae3641b94bb806b297268f3b89e79e5884..9ea3c3f73aa6b4fa696d2c0ad6d614db618e817c 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -516,6 +516,7 @@ set(ES2PANDA_LIB_SRC parser/expressionTSParser.cpp parser/ASparser.cpp parser/JSparser.cpp + parser/JsdocHelper.cpp parser/parserImpl.cpp parser/ETSFormattedParser.cpp parser/ETSparser.cpp @@ -523,7 +524,6 @@ set(ES2PANDA_LIB_SRC parser/ETSparserClasses.cpp parser/ETSparserEnums.cpp parser/ETSparserExpressions.cpp - parser/ETSparserJsDocInfo.cpp parser/ETSparserNamespaces.cpp parser/ETSparserStatements.cpp parser/ETSparserTypes.cpp @@ -648,6 +648,7 @@ set(ES2PANDA_LIB_SRC util/es2pandaMacros.cpp util/helpers.cpp util/importPathManager.cpp + util/nameMangler.cpp util/path.cpp util/plugin.cpp util/perfMetrics.cpp diff --git a/ets2panda/REVIEWERS b/ets2panda/REVIEWERS index 8c8a73c98b8f671a65906508fd6690993b3fe508..fd51adbf1c4668a5ce8589b6c0bb5cfde3f1b5c1 100644 --- a/ets2panda/REVIEWERS +++ b/ets2panda/REVIEWERS @@ -14,16 +14,17 @@ * @gavin1012_hw @zhuoli72 .* @zhuoli72 @Prof1983 @igelhaus -/arkguard/ @zhangchen168 +/arkguard/ @xiao-peiyang /es2panda/ @gavin1012_hw /ets2panda/ @igelhaus @Prof1983 -/ets2panda/ast_verifier @mbolshov ^igelhaus ^Prof1983 +/ets2panda/aot @dkofanov @gavin1012_hw ^igelhaus ^Prof1983 +/ets2panda/ast_verifier @mbolshov @dkofanov ^yyang16 ^igelhaus ^Prof1983 /ets2panda/bindings ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel /ets2panda/lexer @chernykhsergey @igelhaus ^zelentsovdmitry @Prof1983 /ets2panda/lsp ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel /ets2panda/parser @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/public @mbolshov ^igelhaus ^Prof1983 -/ets2panda/test ^igelhaus ^Prof1983 +/ets2panda/public @mbolshov @yyang16 ^igelhaus ^Prof1983 +/ets2panda/test ^akmaevaleksey ^igelhaus ^Prof1983 /legacy_bin/ @ctw-ian /merge_abc/ @gavin1012_hw /test/ @gavin1012_hw @@ -32,40 +33,68 @@ /test262/*.py @shirunova_viktoria @gavin1012_hw @zhuheng27 /test262/ignored*.txt @shirunova_viktoria @gavin1012_hw @kuchkovairina @zhuheng27 /test_ecma_bcopt/ @gavin1012_hw -/ets2panda/checker/ETS*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/checker/ETSAnalyzer.cpp @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 -/ets2panda/declgen_ets2ts/ @dreamdoomwalker ^trubachevilya ^ivagin ^hufeng20 ^igelhaus ^Prof1983 -/ets2panda/driver/ ^trubachevilya @dreamdoomwalker @chenqy930 @hufeng20 ^igelhaus ^Prof1983 -/ets2panda/linter/ @ragnvald @rosinskiyigor @eokolnov1 -/ets2panda/parser/ETSparser*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/expressionParser.cpp @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/parser*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/statementParser.cpp @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey +/ets2panda/checker/ @akmaevaleksey @zelentsovdmitry ^lirismankarina ^igelhaus ^Prof1983 +/ets2panda/checker/ETS*.* @zelentsovdmitry ^igelhaus ^Prof1983 +/ets2panda/checker/ETSAnalyzer.cpp ^akmaevaleksey @Ekkoruse ^igelhaus ^Prof1983 +/ets2panda/checker/ETSAnalyzerHelpers.* @lirismankarina ^igelhaus ^Prof1983 +/ets2panda/compiler/ @xuxjeeee @gogabr ^igelhaus ^Prof1983 ^zelentsovdmitry +/ets2panda/declgen_ets2ts/ @dreamdoomwalker ^trubachevilya ^ivagin ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 +/ets2panda/driver/ @trubachevilya @dreamdoomwalker ^chenqy930 ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 +/ets2panda/ir/ @ziziziiziziz @gavin1012_hw ^igelhaus ^Prof1983 +/ets2panda/linter/ @ragnvald @rosinskiyigor @eokolnov1 @liwentao_uiw ^utkugursel +/ets2panda/parser/ @mkaskov ^igelhaus ^Prof1983 ^chernykhsergey ^zelentsovdmitry /ets2panda/scripts/*-build.sh @titovatatiana ^igelhaus ^Prof1983 /ets2panda/scripts/arkui* @titovatatiana ^igelhaus ^Prof1983 -/ets2panda/util/arktsconfig* @dreamdoomwalker ^trubachevilya ^igelhaus ^Prof1983 -/ets2panda/util/diagnostic* @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/util/importPathManager* @dreamdoomwalker ^trubachevilya ^igelhaus ^Prof1983 +/ets2panda/test/ast @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/depanalyzer @trubachevilya @dreamdoomwalker ^igelhaus ^Prof1983 +/ets2panda/test/srcdump @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/test-lists @igelhaus ^Prof1983 +/ets2panda/test/utils @mbolshov ^igelhaus ^Prof1983 +/ets2panda/util/ @mkaskov @dkofanov ^igelhaus ^Prof1983 +/ets2panda/util/arktsconfig* @dreamdoomwalker @trubachevilya ^igelhaus ^Prof1983 +/ets2panda/util/diagnostic* @chernykhsergey @mkaskov ^igelhaus ^Prof1983 +/ets2panda/util/importPathManager* @dreamdoomwalker @trubachevilya ^igelhaus ^Prof1983 +/ets2panda/util/plugin.* @yyang16 @mbolshov ^igelhaus ^Prof1983 +/ets2panda/varbinder/ @lirismankarina @akmaevaleksey ^Ekkoruse ^zelentsovdmitry ^igelhaus ^Prof1983 /test/workload/ignored*.txt @shirunova_viktoria @kuchkovairina @gavin1012_hw @zhuheng27 -/ets2panda/checker/ets/function.cpp ^vpukhov @gogabr ^igelhaus ^Prof1983 -/ets2panda/checker/ets/helpers.cpp @zelentsovdmitry ^igelhaus ^Prof1983 -/ets2panda/checker/ets/object.cpp @zelentsovdmitry ^vpukhov ^igelhaus ^Prof1983 -/ets2panda/checker/types/ets @gogabr ^igelhaus ^Prof1983 @zelentsovdmitry +/ets2panda/checker/ets/ @lirismankarina ^igelhaus ^Prof1983 +/ets2panda/checker/ets/function.cpp @gogabr ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/checker/ets/helpers.cpp @xuxjeeee @zelentsovdmitry ^igelhaus ^Prof1983 +/ets2panda/checker/ets/object.cpp @xuxjeeee @zelentsovdmitry ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets @dkofanov ^igelhaus ^Prof1983 /ets2panda/checker/types/signature.* ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/checker/types/typeFlag.h ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/checker/types/typeRelation.* ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/compiler/core/ @zelentsovdmitry ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/checker/types/typeFlag.h ^vpukhov ^igelhaus ^Prof1983 @mkaskov +/ets2panda/checker/types/typeRelation.* ^vpukhov ^igelhaus ^Prof1983 @mkaskov +/ets2panda/compiler/core/ @zelentsovdmitry @xuxjeeee ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/compiler/core/compilerImpl.* @yyang16 @dkofanov ^xuxjeeee ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/phase.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/plugin_phase.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/util.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/ir/ets/ @lirismankarina @xuxjeeee ^igelhaus ^Prof1983 +/ets2panda/ir/expressions/ @mkaskov @ziziziiziziz ^igelhaus ^Prof1983 +/ets2panda/ir/statements/ @dkofanov @Ekkoruse ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/ir/statements/annotation* @lirismankarina @xuxjeeee ^igelhaus ^Prof1983 /ets2panda/test/test-lists/astchecker @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/test/test-lists/declgenets2ts @dreamdoomwalker ^hufeng20 ^igelhaus ^Prof1983 +/ets2panda/test/test-lists/declgenets2ts @dreamdoomwalker ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 /ets2panda/test/test-lists/parser @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/test/unit/lsp ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel +/ets2panda/test/unit/arktsconfig-parser @trubachevilya @dreamdoomwalker ^igelhaus ^Prof1983 +/ets2panda/test/unit/lsp @dreamdoomwalker @utkugursel ^igelhaus ^Prof1983 +/ets2panda/test/unit/plugin* @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/unit/public @mbolshov ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/Nullish.* ^vpukhov @gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsA* @xuxjeeee ^gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsE* @ziziziiziziz ^zelentsovdmitry ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/etsFunctionType.* ^vpukhov @gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsN* @ziziziiziziz ^zelentsovdmitry ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsT* @xuxjeeee ^gogabr ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/etsTypeParameter.* ^vpukhov @gogabr ^igelhaus ^Prof1983 -/ets2panda/checker/types/ets/etsUnionType.* @akmaevaleksey ^vpukhov @gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsUnionType.* @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/wildcardType.* ^vpukhov @gogabr ^igelhaus ^Prof1983 -/ets2panda/compiler/lowering/ets/ @akmaevaleksey ^igelhaus ^Prof1983 ^zelentsovdmitry -/ets2panda/compiler/lowering/ets/lambdaLowering.cpp ^vpukhov @akmaevaleksey @gogabr ^igelhaus ^Prof1983 -/ets2panda/compiler/lowering/ets/optionalLowering.cpp ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 -/ets2panda/compiler/lowering/ets/unionLowering.cpp ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 -/ets2panda/compiler/lowering/ets/topLevelStmts/.* ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/ @gogabr ^igelhaus ^Prof1983 ^zelentsovdmitry +/ets2panda/compiler/lowering/ets/const* @ziziziiziziz @lirismankarina ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/enum* @ziziziiziziz @dkofanov ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @Ekkoruse @gogabr ^vpukhov ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/optionalLowering.cpp @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/spread* @ziziziiziziz @dkofanov ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/unionLowering.cpp @Ekkoruse @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/ets/topLevelStmts/.* @lirismankarina @xuxjeeee ^akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 diff --git a/ets2panda/aot/BUILD.gn b/ets2panda/aot/BUILD.gn index 7efccf65854505a222c43bd299160c92bb3e5e2f..55f5f3e98d6100c3bdcf6e7ecf99ae3ec4c8c81c 100644 --- a/ets2panda/aot/BUILD.gn +++ b/ets2panda/aot/BUILD.gn @@ -11,7 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} if (ark_standalone_build) { import("$build_root/ark.gni") @@ -26,17 +32,28 @@ ohos_executable("ets2panda") { "$target_gen_dir", "$target_gen_dir/include", ] + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } + + if (ark_standalone_build || ark_static_standalone_build) { + configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libarkfile:arkfile_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/bytecode_optimizer:bytecodeopt_public_config", + "$ark_root/runtime:arkruntime_public_config", + "$ark_root/compiler:arkcompiler_public_config", + ] + } - configs = [ - "$ark_root:ark_config", - "$ark_root/assembler:arkassembler_public_config", - "$ark_es2panda_root:libes2panda_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/bytecode_optimizer:bytecodeopt_public_config", - "$ark_root/compiler:arkcompiler_public_config", - "$ark_root/runtime:arkruntime_public_config", - "$ark_root/abc2program:arkts_abc2program_public_config", + configs += [ + "$ark_es2panda_root:libes2panda_public_config" ] deps = [ @@ -48,7 +65,7 @@ ohos_executable("ets2panda") { deps += [ "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", "$ark_root/libpandabase:libarktsbase_package", - "$ark_root/libpandafile:libarktsfile_package", + "$ark_root/libarkfile:libarktsfile_package", ] } @@ -62,6 +79,23 @@ ohos_executable("ets2panda") { sdk_libc_secshared_dep, ] + if (!(ark_standalone_build || ark_static_standalone_build)) { + external_deps += [ + "runtime_core:assembler_headers", + "runtime_core:bytecode_optimizer_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + "runtime_core:runtime_headers", + "runtime_core:compiler_headers", + "runtime_core:verification_headers", + ] + } + + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ "icu:shared_icuuc" ] + } + libs = platform_libs ldflags = platform_ldflags if (is_linux) { diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 6772ec2a051b1633694c7890eab5e831a1cb7f84..420240cb0ee8c3f829f32ba08e3e68afa017d0f0 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -101,6 +101,15 @@ static int CompileMultipleFiles(es2panda::Compiler &compiler, std::vector &parserInputs, unsigned int returnCode) +{ + for (auto *input : parserInputs) { + delete input; + } + parserInputs.clear(); + return returnCode; +} + static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *options, util::DiagnosticEngine &diagnosticEngine) { @@ -111,6 +120,7 @@ static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *option } std::vector inputs {}; + std::vector parserInputs; unsigned int overallRes = 0; for (auto &[src, dst] : compilationList) { std::ifstream inputStream(src); @@ -120,14 +130,14 @@ static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *option } std::stringstream ss; ss << inputStream.rdbuf(); - auto *parserInput = new std::string(ss.str()); + parserInputs.push_back(new std::string(ss.str())); inputStream.close(); - es2panda::SourceFile input(src, *parserInput, options->IsModule(), std::string_view(dst)); + es2panda::SourceFile input(src, *parserInputs.back(), options->IsModule(), std::string_view(dst)); inputs.push_back(input); } if (options->IsPermArena() && (options->GetExtension() == util::gen::extension::ETS)) { - return CompileMultipleFiles(compiler, inputs, options, diagnosticEngine); + return ReleaseInputsAndReturn(parserInputs, CompileMultipleFiles(compiler, inputs, options, diagnosticEngine)); } for (auto &input : inputs) { @@ -141,7 +151,7 @@ static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *option overallRes |= static_cast(res); } } - return overallRes; + return ReleaseInputsAndReturn(parserInputs, overallRes); } static std::optional> InitializePlugins(std::vector const &names, diff --git a/ets2panda/ast_verifier/ASTVerifier.cpp b/ets2panda/ast_verifier/ASTVerifier.cpp index 9854161341dad190e547fec914f090536c2a9f5e..e55eaac5bb4bfcf16edb00c06b1de418aba183b4 100644 --- a/ets2panda/ast_verifier/ASTVerifier.cpp +++ b/ets2panda/ast_verifier/ASTVerifier.cpp @@ -80,7 +80,7 @@ static auto ExtractAst(const parser::Program &program, bool checkFullProgram) return astToCheck; } -void ASTVerifier::Verify(std::string_view phaseName) +void ASTVerifier::Verify(std::string_view phaseName) noexcept { if (context_.diagnosticEngine->IsAnyError()) { // NOTE(dkofanov): As for now, the policy is that ASTVerifier doesn't interrupt pipeline if there were errors diff --git a/ets2panda/ast_verifier/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h index 1bd190ef7657372f5f3b05fa905c94602a9fbac7..82c05434b9eb9123e957f3f1e471eef55cc4fa3b 100644 --- a/ets2panda/ast_verifier/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -108,7 +108,7 @@ public: } } - void Verify(std::string_view phaseName); + void Verify(std::string_view phaseName) noexcept; void IntroduceNewInvariants(std::string_view occurredPhaseName) { diff --git a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp index bb77859aed5faaa10db8e382b720112625617808..bf6ab126463ef72bdd5fcff959bce8227691f80f 100644 --- a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp +++ b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp @@ -19,7 +19,7 @@ #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsEnumDeclaration.h" #include "ir/ts/tsInterfaceBody.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h index 1afed1ea7fb3564257f089b7ccda30e024f3bbd2..ba478d93ecc064ff547ac87b49e9e25f7581289d 100644 --- a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h +++ b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_ARITHMETICOPERATIONVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_ARITHMETICOPERATIONVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkAbstractMethod.h b/ets2panda/ast_verifier/invariants/checkAbstractMethod.h index d2534f5483ea3017becd4dd6108ce2d7d4efde2a..174a685564664f5fa77352c57287319530a1a39b 100644 --- a/ets2panda/ast_verifier/invariants/checkAbstractMethod.h +++ b/ets2panda/ast_verifier/invariants/checkAbstractMethod.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKABSTRACTMETHOD_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKABSTRACTMETHOD_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkConstProperties.h b/ets2panda/ast_verifier/invariants/checkConstProperties.h index 379e446e7a90a5c09a018c1be19cf2a41f616c09..a4a042b1212389809609131311f4f1504535df00 100644 --- a/ets2panda/ast_verifier/invariants/checkConstProperties.h +++ b/ets2panda/ast_verifier/invariants/checkConstProperties.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKCONSTPROPERTIES_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKCONSTPROPERTIES_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h b/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h index f7766ab0b8370e8bb76bbada509f4aec9589033d..1137ee9848c28dc9418a75da18189c88b6a979a4 100644 --- a/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h +++ b/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSCOPEDECLARATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSCOPEDECLARATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkStructDeclaration.h b/ets2panda/ast_verifier/invariants/checkStructDeclaration.h index 931279a83c25db407b4612749cf19ec4b4849ee6..aa6d9ffe53e9dfe000c59308e950b81569f70848 100644 --- a/ets2panda/ast_verifier/invariants/checkStructDeclaration.h +++ b/ets2panda/ast_verifier/invariants/checkStructDeclaration.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSTRUCTDECLARATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSTRUCTDECLARATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h b/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h index d18220f781f94a2e7563cdc420aca729529d7714..a2a3070c25b20d307a04d462dc0904490e2fbdc2 100644 --- a/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h +++ b/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDHASVALIDPARENT_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDHASVALIDPARENT_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/everyChildInParentRange.h b/ets2panda/ast_verifier/invariants/everyChildInParentRange.h index c3406de3e0b04c9285e9b1b5dc8c4abb2ff482e2..fa25a4654465dc45f4304593faf99b1b32f2a6af 100644 --- a/ets2panda/ast_verifier/invariants/everyChildInParentRange.h +++ b/ets2panda/ast_verifier/invariants/everyChildInParentRange.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDINPARENTRANGE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDINPARENTRANGE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h b/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h index 15c3e45451cf0457a420023a642fbadd4140f302..ea2fa365dd30501f0cd0cb33c8340796e660956b 100644 --- a/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h +++ b/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_FORLOOPCORRECTLYINITIALIZED_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_FORLOOPCORRECTLYINITIALIZED_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/getterSetterValidation.h b/ets2panda/ast_verifier/invariants/getterSetterValidation.h index 4f4b1d4aed1ca3c3c5f867e857d62e619cb102f0..9d6bd4f22121c8a260a0d4c52f8f110a992fe170 100644 --- a/ets2panda/ast_verifier/invariants/getterSetterValidation.h +++ b/ets2panda/ast_verifier/invariants/getterSetterValidation.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_GETTERSETTERVALIDATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_GETTERSETTERVALIDATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/identifierHasVariable.h b/ets2panda/ast_verifier/invariants/identifierHasVariable.h index 8fc17ff9bba58291a17e394043688350b22342f1..72f9d271903f2d9c8246248651cea73ff2ad392f 100644 --- a/ets2panda/ast_verifier/invariants/identifierHasVariable.h +++ b/ets2panda/ast_verifier/invariants/identifierHasVariable.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IDENTIFIERHASVARIABLE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IDENTIFIERHASVARIABLE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "ir/expressions/identifier.h" diff --git a/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp b/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp index 6d6ff354876263cca9636e8da9367292bb816629..4832d10fb7b4853f971cc7314a5d4132f76e1953 100644 --- a/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp +++ b/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp @@ -14,7 +14,7 @@ */ #include "importExportAccessValid.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "ir/expressions/callExpression.h" #include "checker/types/ets/etsObjectType.h" #include "ir/module/importSpecifier.h" @@ -70,7 +70,7 @@ bool ImportExportAccessValid::ValidateExport(const varbinder::Variable *var) if (node == nullptr) { return false; } - return node->IsExported(); + return node->IsExported() || node->HasExportAlias(); } bool ImportExportAccessValid::InvariantImportExportMethod(const std::unordered_set &importedVariables, diff --git a/ets2panda/ast_verifier/invariants/importExportAccessValid.h b/ets2panda/ast_verifier/invariants/importExportAccessValid.h index 7977ee3a56e9059fec269c1bc737b4122cf94bf6..1eaf3cb642f7e24867e7d38924b43e4ca0a11fbf 100644 --- a/ets2panda/ast_verifier/invariants/importExportAccessValid.h +++ b/ets2panda/ast_verifier/invariants/importExportAccessValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IMPORTEXPORTACCESSVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IMPORTEXPORTACCESSVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp b/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp index 58ce2de70a8439b4446c9198aa3a03bd1de71147..7f8875f7a9a3ca63873ae1d15b0ea23875505acb 100644 --- a/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp +++ b/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp @@ -14,7 +14,7 @@ */ #include "modifierAccessValid.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "varbinder/variableFlags.h" #include "ir/expressions/memberExpression.h" #include "ir/expressions/callExpression.h" diff --git a/ets2panda/ast_verifier/invariants/modifierAccessValid.h b/ets2panda/ast_verifier/invariants/modifierAccessValid.h index a5fe690286f0f832a3e92b8a55a558cc8be340b4..5889a24cb725fc596c25d1e2e93abbe8c8f32456 100644 --- a/ets2panda/ast_verifier/invariants/modifierAccessValid.h +++ b/ets2panda/ast_verifier/invariants/modifierAccessValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_MODIFIERACCESSVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_MODIFIERACCESSVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasParent.h b/ets2panda/ast_verifier/invariants/nodeHasParent.h index c3f583c8d9b7cc72bbe2bdec15904481e9817b95..f5a77f9a3e09b316bf68b22e5cc50f9ebfd6ba13 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasParent.h +++ b/ets2panda/ast_verifier/invariants/nodeHasParent.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASPARENT_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASPARENT_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h b/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h index fed802ecb7d531d87106868fedb7def3bebbd026..a797369d03867595e09ca1f1fe4d9cb40b428e1b 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h +++ b/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASSOURCERANGE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASSOURCERANGE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasType.cpp b/ets2panda/ast_verifier/invariants/nodeHasType.cpp index e9f4d335a76d94795237156775c4a8c36d1f0d32..a269292f9f5a330eba313720803c4c29fe209b32 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasType.cpp +++ b/ets2panda/ast_verifier/invariants/nodeHasType.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "nodeHasType.h" #include "ir/base/classDefinition.h" #include "ir/base/methodDefinition.h" diff --git a/ets2panda/ast_verifier/invariants/nodeHasType.h b/ets2panda/ast_verifier/invariants/nodeHasType.h index edfee888c364fe11509d90b4cef6b0b0fe282e0d..c48d97ce8095479c72c9335c9ee02d918353aac1 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasType.h +++ b/ets2panda/ast_verifier/invariants/nodeHasType.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASTYPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASTYPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "checker/types/type.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h b/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h index e0e7bcaf36f3583d834edf86ef9372a467920f48..562cc47cb18bdc5215a4513bda732e3b479f1c14 100644 --- a/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h +++ b/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_REFERENCETYPEANNOTATIONISNULL_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_REFERENCETYPEANNOTATIONISNULL_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h b/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h index c39f50507244ae115b4c818cee22b899a8daface..7b4f0760cbf77bcc1cf48b68eaefb77467ae2e13 100644 --- a/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h +++ b/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_SEQUENCEEXPRESSIONHASLASTTYPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_SEQUENCEEXPRESSIONHASLASTTYPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp index 1aa6f1abf062c4b37663c31cb50160668839ef1a..08ae83ddcbbfc6f587371a7b93c306f0e8cd9491 100644 --- a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp +++ b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp @@ -15,7 +15,7 @@ #include "variableHasEnclosingScope.h" #include "variableHasScope.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h index 5d0cf636988ba868da9edffb947b4f22d6c8520f..fa75e280f00225ea0eb15b2ce99c99f252bcfe59 100644 --- a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h +++ b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASENCLOSINGSCOPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASENCLOSINGSCOPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasScope.cpp b/ets2panda/ast_verifier/invariants/variableHasScope.cpp index 0e072bf3845a13c8cda5f40a7d28c8ad2923d890..9b18ba8289d4d4a1a03daeedead8c049c92d4d73 100644 --- a/ets2panda/ast_verifier/invariants/variableHasScope.cpp +++ b/ets2panda/ast_verifier/invariants/variableHasScope.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "variableHasScope.h" #include "ir/base/scriptFunction.h" #include "ir/ts/tsEnumDeclaration.h" diff --git a/ets2panda/ast_verifier/invariants/variableHasScope.h b/ets2panda/ast_verifier/invariants/variableHasScope.h index 41d067774e285f773fc3c74c63f29a431abb515a..a6c7741c94677e9dcd630ef135ac1b1a0989069b 100644 --- a/ets2panda/ast_verifier/invariants/variableHasScope.h +++ b/ets2panda/ast_verifier/invariants/variableHasScope.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASSCOPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASSCOPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "varbinder/varbinder.h" diff --git a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.cpp b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.cpp index f3d85ee0a0b15c40b6d821c4930a88875a1c6fad..3b82e3e138bba29c4e11b0e3ebd3587a7b810a76 100644 --- a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.cpp +++ b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.cpp @@ -32,8 +32,8 @@ namespace ark::es2panda::compiler::ast_verifier { } const auto variableNode = variable->Declaration()->Node(); // NOTE(psaykerone): skip because, this exceptions need to be fixed in checker and lowering - if (variableNode->IsExported() || variableNode->IsDefaultExported() || id->Name().Utf8().find("field") == 0 || - variable->Name().Utf8().find("field") == 0) { + if (variableNode->IsExported() || variableNode->IsDefaultExported() || variableNode->HasExportAlias() || + id->Name().Utf8().find("field") == 0 || variable->Name().Utf8().find("field") == 0) { return {CheckDecision::CORRECT, CheckAction::CONTINUE}; } if (id->Name() == variable->Name()) { diff --git a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h index 5eb9e85e2162d29c4f8d695879da3c12cc63d44d..211c166828bcfc0c26dd1310fbc857d0fe2bebf2 100644 --- a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h +++ b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLENAMEIDENTIFIERNAMESAME_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLENAMEIDENTIFIERNAMESAME_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/bindings/.prettierignore b/ets2panda/bindings/.prettierignore index 2f3613c27765c7087fcd45acc3d317ba0611d214..518efe7433cc5e17dcbee89e3c68635376e48411 100644 --- a/ets2panda/bindings/.prettierignore +++ b/ets2panda/bindings/.prettierignore @@ -17,7 +17,9 @@ native/ dist/** dist-test/** node_modules/** -**.json +test/ets/** +tsconfig.json +**.json5 **.js **.md **.ets diff --git a/ets2panda/bindings/BUILD.gn b/ets2panda/bindings/BUILD.gn index 0e6be72fd93968839af67b16371f60a78528a488..80c318d66ab980c54db5741bcfd4105516df79bd 100644 --- a/ets2panda/bindings/BUILD.gn +++ b/ets2panda/bindings/BUILD.gn @@ -11,7 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} + if (ark_standalone_build) { import("$build_root/ark.gni") } else { @@ -26,13 +33,20 @@ shared_library("ts_bindings") { "./native/src/convertors-napi.cpp", "./native/src/lsp.cpp", ] + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs += [ "$ark_root:ark_config" ] + } else { + configs += [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } configs += [ "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", "../:libes2panda_public_config", "../:libes2panda_config", "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libarkfile:arkfile_public_config", ] deps = [ @@ -50,7 +64,8 @@ shared_library("ts_bindings") { if (ark_standalone_build) { deps += [ - "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", + "$ark_root/bytecode_optimizer:libarktsbytecodeopt_frontend_static", + "$ark_root/abc2program:arkts_abc2program_static", "$ark_third_party_root/bounds_checking_function:libsec_shared", ] include_dirs += [ "//third_party/node/src" ] @@ -193,7 +208,7 @@ shared_library("public") { "../:libes2panda_public_config", "../:libes2panda_config", "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libarkfile:arkfile_public_config", ] include_dirs = [ diff --git a/ets2panda/bindings/native/src/bridges.cpp b/ets2panda/bindings/native/src/bridges.cpp index b4f7bfdc24a1c97389df0e12cfda66fb76eaa250..d318f9816184aa75c2308a5e2c9b30744103363c 100644 --- a/ets2panda/bindings/native/src/bridges.cpp +++ b/ets2panda/bindings/native/src/bridges.cpp @@ -36,14 +36,23 @@ KNativePointer impl_CreateContextFromString(KNativePointer configPtr, KStringPtr } TS_INTEROP_3(CreateContextFromString, KNativePointer, KNativePointer, KStringPtr, KStringPtr) +KNativePointer impl_CreateContextFromStringWithHistory(KNativePointer configPtr, KStringPtr &sourcePtr, + KStringPtr &filenamePtr) +{ + auto config = reinterpret_cast(configPtr); + return GetPublicImpl()->CreateContextFromStringWithHistory(config, sourcePtr.data(), filenamePtr.data()); +} +TS_INTEROP_3(CreateContextFromStringWithHistory, KNativePointer, KNativePointer, KStringPtr, KStringPtr) + KInt impl_GenerateTsDeclarationsFromContext(KNativePointer contextPtr, KStringPtr &outputDeclEts, KStringPtr &outputEts, - KBoolean exportAll, KBoolean isolated) + KBoolean exportAll, KBoolean isolated, KStringPtr &recordFile) { auto context = reinterpret_cast(contextPtr); return static_cast(GetPublicImpl()->GenerateTsDeclarationsFromContext( - context, outputDeclEts.data(), outputEts.data(), exportAll != 0, isolated != 0)); + context, outputDeclEts.data(), outputEts.data(), exportAll != 0, isolated != 0, recordFile.data())); } -TS_INTEROP_5(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean, KBoolean) +TS_INTEROP_6(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean, KBoolean, + KStringPtr) KNativePointer impl_CreateContextFromFile(KNativePointer configPtr, KStringPtr &filenamePtr) { diff --git a/ets2panda/bindings/native/src/lsp.cpp b/ets2panda/bindings/native/src/lsp.cpp index 95a5fd779514ee81c73ddd7ad7b24dc1c6bba506..58fef1622a8c3fb58608c99debca3585d42e1b37 100644 --- a/ets2panda/bindings/native/src/lsp.cpp +++ b/ets2panda/bindings/native/src/lsp.cpp @@ -65,7 +65,7 @@ TS_INTEROP_3(getClassPropertyInfo, KNativePointer, KNativePointer, KInt, KBoolea KNativePointer impl_getRenameLocationFileName(KNativePointer renameLocationPtr) { auto *renameLocationRef = reinterpret_cast(renameLocationPtr); - return &renameLocationRef->fileName; + return new std::string(renameLocationRef->fileName); } TS_INTEROP_1(getRenameLocationFileName, KNativePointer, KNativePointer) @@ -445,7 +445,7 @@ TS_INTEROP_1(getDiagRelatedInfo, KNativePointer, KNativePointer) KNativePointer impl_getRelatedInfoMsg(KNativePointer relatedInfoPtr) { auto *relatedInfoRef = reinterpret_cast(relatedInfoPtr); - return &relatedInfoRef->message_; + return new std::string(relatedInfoRef->message_); } TS_INTEROP_1(getRelatedInfoMsg, KNativePointer, KNativePointer) @@ -459,7 +459,7 @@ TS_INTEROP_1(getRelatedInfoLoc, KNativePointer, KNativePointer) KNativePointer impl_getLocUri(KNativePointer locPtr) { auto *locRef = reinterpret_cast(locPtr); - return &locRef->uri_; + return new std::string(locRef->uri_); } TS_INTEROP_1(getLocUri, KNativePointer, KNativePointer) @@ -1617,7 +1617,7 @@ TS_INTEROP_3(getSpanOfEnclosingComment, KNativePointer, KNativePointer, KInt, KB KNativePointer impl_getInlayHintText(KNativePointer hintPtr) { auto *hint = reinterpret_cast(hintPtr); - return &hint->text; + return new std::string(hint->text); } TS_INTEROP_1(getInlayHintText, KNativePointer, KNativePointer) @@ -1672,7 +1672,7 @@ TS_INTEROP_2(getInlayHintList, KNativePointer, KNativePointer, KNativePointer) KNativePointer impl_getSignatureHelpParameterName(KNativePointer parameterPtr) { auto *parameterRef = reinterpret_cast(parameterPtr); - return ¶meterRef->GetName(); + return new std::string(parameterRef->GetName()); } TS_INTEROP_1(getSignatureHelpParameterName, KNativePointer, KNativePointer) @@ -1799,4 +1799,12 @@ KNativePointer impl_getSignatureHelpItems(KNativePointer context, KInt position) new SignatureHelpItems(ctx->getSignatureHelpItems(reinterpret_cast(context), position)); return textSpan; } -TS_INTEROP_2(getSignatureHelpItems, KNativePointer, KNativePointer, KInt) \ No newline at end of file +TS_INTEROP_2(getSignatureHelpItems, KNativePointer, KNativePointer, KInt) + +KInt impl_getOffsetByColAndLine(KNativePointer contextPtr, KInt line, KInt column) +{ + auto context = reinterpret_cast(contextPtr); + LSPAPI const *impl = GetImpl(); + return impl->getOffsetByColAndLine(context, line, column); +} +TS_INTEROP_3(getOffsetByColAndLine, KInt, KNativePointer, KInt, KInt) \ No newline at end of file diff --git a/ets2panda/bindings/package.json b/ets2panda/bindings/package.json index 61b96b42af3c19fb49cd8a46736b6a6db2c776ee..586b823c5bad393cd9b8569a72fce9f948a3561c 100644 --- a/ets2panda/bindings/package.json +++ b/ets2panda/bindings/package.json @@ -7,7 +7,8 @@ "@types/node": "^18.0.0", "prettier": "latest", "rimraf": "^6.0.1", - "typescript": "4.9.5" + "typescript": "4.9.5", + "jest-diff": "latest" }, "main": "dist/index.js", "scripts": { @@ -15,6 +16,7 @@ "test:compile": "tsc --build --verbose test/tsconfig.json", "test:build": "npm run test:clean && npm run test:compile", "test": "npm run test:build && node dist-test/test/run_tests.js ./test", + "test:update": "npm run test:build && node dist-test/test/run_tests.js ./test --update", "compile": "tsc --build --verbose tsconfig.json", "clean": "rimraf dist tsconfig.tsbuildinfo package-lock.json", "run": "npm run clean && npm run compile", diff --git a/ets2panda/bindings/src/common/Es2pandaNativeModule.ts b/ets2panda/bindings/src/common/Es2pandaNativeModule.ts index 94c9d9f76efa61c03ba9fea68e9558f3b5fed460..8d04990823d8281b5a571c4713ccc417224e91ff 100644 --- a/ets2panda/bindings/src/common/Es2pandaNativeModule.ts +++ b/ets2panda/bindings/src/common/Es2pandaNativeModule.ts @@ -74,12 +74,16 @@ export class Es2pandaNativeModule { _CreateContextFromString(config: KPtr, source: String, filename: String): KPtr { throw new Error('Not implemented'); } + _CreateContextFromStringWithHistory(config: KPtr, source: String, filename: String): KPtr { + throw new Error('Not implemented'); + } _GenerateTsDeclarationsFromContext( config: KPtr, outputDeclEts: String, outputEts: String, exportAll: KBoolean, - isolated: KBoolean + isolated: KBoolean, + recordFile: String ): KPtr { throw new Error('Not implemented'); } @@ -940,6 +944,10 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } + _getOffsetByColAndLine(context: KPtr, line: KInt, column: KInt): KInt { + throw new Error('Not implemented'); + } + _MemInitialize(pandaLibPath: KStringPtr): void { throw new Error('Not implemented'); } diff --git a/ets2panda/bindings/src/common/driver_helper.ts b/ets2panda/bindings/src/common/driver_helper.ts index 4bd68da844cfb88951afb8fa9b857efc8856deeb..18809ce73691e1e4ce14c6125997ceeb3e2d2ec7 100644 --- a/ets2panda/bindings/src/common/driver_helper.ts +++ b/ets2panda/bindings/src/common/driver_helper.ts @@ -77,10 +77,10 @@ export class DriverHelper { global.destroyCfg(); } - public generateTsDecl(declOutPath: string, etsOutPath: string, exportAll: boolean, isolated: boolean): void { + public generateTsDecl(declOutPath: string, etsOutPath: string, exportAll: boolean, isolated: boolean, recordFile: string): void { let exportAll_: KBoolean = exportAll ? 1 : 0; let isolated_: KBoolean = isolated ? 1 : 0; - global.es2panda._GenerateTsDeclarationsFromContext(this._cfg.peer, declOutPath, etsOutPath, exportAll_, isolated_); + global.es2panda._GenerateTsDeclarationsFromContext(this._cfg.peer, declOutPath, etsOutPath, exportAll_, isolated_, recordFile); } } diff --git a/ets2panda/bindings/src/common/types.ts b/ets2panda/bindings/src/common/types.ts index c8bc63bb52f1c5d0818dce52e2f8b8cc90d89b64..29edf9d82a22794cef0e38dd051c4cb8c4417350 100644 --- a/ets2panda/bindings/src/common/types.ts +++ b/ets2panda/bindings/src/common/types.ts @@ -104,6 +104,15 @@ export class Context extends ArktsObject { ); } + static createFromStringWithHistory(source: string): Context { + if (!global.configIsInitialized()) { + throwError(`Config not initialized`); + } + return new Context( + global.es2panda._CreateContextFromStringWithHistory(global.config, passString(source), passString(global.filePath)) + ); + } + static lspCreateFromString(source: string, filePath: string, cfg: Config): KPtr { if (cfg === undefined) { throwError(`Config not initialized`); @@ -151,6 +160,7 @@ export interface PathConfig { declgenOutDir: string; cacheDir?: string; externalApiPath?: string; + aceModuleJsonPath?: string; } export interface DeclgenConfig { diff --git a/ets2panda/bindings/src/common/ui_plugins_driver.ts b/ets2panda/bindings/src/common/ui_plugins_driver.ts index 1d30fb980313a62dfab333d979f6b776ca207725..464cd6b396dc8ef61bd9036fdb0dd07084331c12 100644 --- a/ets2panda/bindings/src/common/ui_plugins_driver.ts +++ b/ets2panda/bindings/src/common/ui_plugins_driver.ts @@ -65,12 +65,14 @@ class PluginContext { private program: object | undefined; private projectConfig: object | undefined; private contextPtr: KNativePointer | undefined; + private codingFilePath: string | undefined; constructor() { this.ast = undefined; this.program = undefined; this.projectConfig = undefined; this.contextPtr = undefined; + this.codingFilePath = undefined; } public setArkTSAst(ast: object): void { @@ -104,6 +106,18 @@ class PluginContext { public getContextPtr(): KNativePointer | undefined { return this.contextPtr; } + + public setCodingFilePath(codingFilePath: string): void { + this.codingFilePath = codingFilePath; + } + + public getCodingFilePath(): string | undefined { + return this.codingFilePath; + } + + public isCoding(): boolean { + return this.codingFilePath !== undefined; + } } export class PluginDriver { diff --git a/ets2panda/bindings/src/lsp/generateBuildConfig.ts b/ets2panda/bindings/src/lsp/generateBuildConfig.ts index 88206a3e5ffb1b254894443e9fcb7495bac34fe7..7eace71cb11d0a6bd3f9445e2a25b66f473516e2 100644 --- a/ets2panda/bindings/src/lsp/generateBuildConfig.ts +++ b/ets2panda/bindings/src/lsp/generateBuildConfig.ts @@ -24,6 +24,7 @@ export interface ModuleDescriptor { name: string; moduleType: string; srcPath: string; + aceModuleJsonPath?: string; } interface Json5Object { @@ -167,6 +168,10 @@ function createPluginMap(buildSdkPath: string): Record { return pluginMap; } +function addPluginPathConfigs(buildConfig: BuildConfig, module: ModuleDescriptor): void { + buildConfig.aceModuleJsonPath = module.aceModuleJsonPath; +} + export function generateBuildConfigs( pathConfig: PathConfig, modules?: ModuleDescriptor[] @@ -222,6 +227,7 @@ export function generateBuildConfigs( return depModule!.name; }) }; + addPluginPathConfigs(allBuildConfigs[module.name], module); } Object.entries(allBuildConfigs).forEach(([key, config]) => { if (enableDeclgen.get(key) === true) { diff --git a/ets2panda/bindings/src/lsp/lsp_helper.ts b/ets2panda/bindings/src/lsp/lsp_helper.ts index 4e2fc5e6f049f49a9fa30feaa0a9aa32d500e90f..aa72ccb120854eb0f89929914505a49acaf8a0a1 100644 --- a/ets2panda/bindings/src/lsp/lsp_helper.ts +++ b/ets2panda/bindings/src/lsp/lsp_helper.ts @@ -68,7 +68,7 @@ import { generateArkTsConfigs, generateModuleInfo } from './generateArkTSConfig' import * as fs from 'fs'; import * as path from 'path'; -import { KNativePointer, KPointer } from '../common/InteropTypes'; +import { KInt, KNativePointer, KPointer } from '../common/InteropTypes'; import { passPointerArray } from '../common/private'; import { NativePtrDecoder } from '../common/Platform'; import { Worker as ThreadWorker } from 'worker_threads'; @@ -77,10 +77,7 @@ import * as child_process from 'child_process'; import { DECL_ETS_SUFFIX, DEFAULT_CACHE_DIR, TS_SUFFIX } from '../common/preDefine'; import * as crypto from 'crypto'; import * as os from 'os'; -import { - changeDeclgenFileExtension, - getModuleNameAndPath -} from '../common/utils'; +import { changeDeclgenFileExtension, getModuleNameAndPath } from '../common/utils'; const ets2pandaCmdPrefix = ['-', '--extension', 'ets', '--arktsconfig']; @@ -106,6 +103,7 @@ export class Lsp { private buildConfigs: Record; // Map private moduleInfos: Record; // Map private pathConfig: PathConfig; + private lspDriverHelper = new LspDriverHelper(); constructor(pathConfig: PathConfig, getContentCallback?: (filePath: string) => string, modules?: ModuleDescriptor[]) { initBuildEnv(); @@ -158,8 +156,48 @@ export class Lsp { return getSource.replace(/\r\n/g, '\n'); } + private createContext(filename: String): [Config, KNativePointer] { + const filePath = path.resolve(filename.valueOf()); + const arktsconfig = this.moduleInfos[filePath]?.arktsConfigFile; + if (!arktsconfig) { + throw new Error(`Missing arktsconfig for ${filePath}`); + } + + const ets2pandaCmd = [...ets2pandaCmdPrefix, arktsconfig]; + const localCfg = this.lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + + const localCtx = this.lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + try { + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + const pluginContext = PluginDriver.getInstance().getPluginContext(); + pluginContext.setCodingFilePath(filePath); + pluginContext.setProjectConfig(buildConfig); + pluginContext.setContextPtr(localCtx); + + this.lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + + this.lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + return [localCfg, localCtx]; + } catch (error) { + this.lspDriverHelper.destroyContext(localCtx); + this.lspDriverHelper.destroyConfig(localCfg); + throw error; + } + } + + private destroyContext(config: Config, context: KNativePointer): void { + try { + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + } finally { + this.lspDriverHelper.destroyContext(context); + this.lspDriverHelper.destroyConfig(config); + } + } + generateDeclFile(): void { - let lspDriverHelper = new LspDriverHelper(); for (const [moduleName, buildConfig] of Object.entries(this.buildConfigs)) { if (!buildConfig.enableDeclgenEts2Ts) { continue; @@ -171,63 +209,39 @@ export class Lsp { if (!this.moduleInfos.hasOwnProperty(compilefilePath)) { return; } - let sourceFilePath = path.resolve(compilefilePath); - const moduleInfo = this.moduleInfos[compilefilePath]; - let arktsconfig = moduleInfo.arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, sourceFilePath, this.pandaLibPath); - const source = this.getFileSource(compilefilePath); - let localCtx = lspDriverHelper.createCtx(source, compilefilePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - // declgen file - let modulePath: string = path.relative(buildConfig.moduleRootPath, compilefilePath); - let declOut: string = ''; - let declBridgeOut: string = ''; - if (!moduleInfo.declgenV1OutPath) { - declOut = path.join(buildConfig.declgenOutDir, moduleName); - } - if (!moduleInfo.declgenBridgeCodePath) { - declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + const [cfg, ctx] = this.createContext(compilefilePath); + try { + // declgen file + let moduleInfo = this.moduleInfos[compilefilePath]; + let modulePath: string = path.relative(buildConfig.moduleRootPath, compilefilePath); + let declOut: string = ''; + let declBridgeOut: string = ''; + if (!moduleInfo.declgenV1OutPath) { + declOut = path.join(buildConfig.declgenOutDir, moduleName); + } + if (!moduleInfo.declgenBridgeCodePath) { + declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + } + let declEtsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenV1OutPath ?? declOut, modulePath), + DECL_ETS_SUFFIX + ); + let etsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, modulePath), + TS_SUFFIX + ); + ensurePathExists(declEtsOutputPath); + ensurePathExists(etsOutputPath); + global.es2pandaPublic._GenerateTsDeclarationsFromContext(ctx, declEtsOutputPath, etsOutputPath, 1, 0, ''); + } finally { + this.destroyContext(cfg, ctx); } - let declEtsOutputPath: string = changeDeclgenFileExtension( - path.join(moduleInfo.declgenV1OutPath ?? declOut, modulePath), - DECL_ETS_SUFFIX - ); - let etsOutputPath: string = changeDeclgenFileExtension( - path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, modulePath), - TS_SUFFIX - ); - ensurePathExists(declEtsOutputPath); - ensurePathExists(etsOutputPath); - global.es2pandaPublic._GenerateTsDeclarationsFromContext( - localCtx, - declEtsOutputPath, - etsOutputPath, - 1, - 0 - ); - let declfilePath = path.resolve(declEtsOutputPath); - let declgLocalCfg = lspDriverHelper.createCfg(ets2pandaCmd, declfilePath, this.pandaLibPath); - const declgSource = this.getFileSource(declfilePath); - let declgLocalCtx = lspDriverHelper.createCtx(declgSource, declfilePath, declgLocalCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(declgLocalCtx); - lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - // clean and destroy - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyContext(declgLocalCtx); }); } } modifyDeclFile(modifyFilePath: string, arktsConfigFile?: string): void { // source file - let lspDriverHelper = new LspDriverHelper(); let sourceFilePath = path.resolve(modifyFilePath.valueOf()); let moduleInfo: ModuleInfo; if (this.moduleInfos.hasOwnProperty(sourceFilePath)) { @@ -261,165 +275,108 @@ export class Lsp { if (!buildConfig.enableDeclgenEts2Ts) { return; } - let arktsconfig = moduleInfo.arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, sourceFilePath, this.pandaLibPath); - const source = this.getFileSource(sourceFilePath); - let localCtx = lspDriverHelper.createCtx(source, sourceFilePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - // declgen file - let declOut: string = ''; - let declBridgeOut: string = ''; - if (!moduleInfo.declgenV1OutPath) { - declOut = path.join(buildConfig.declgenOutDir, moduleName); + const [cfg, ctx] = this.createContext(sourceFilePath); + try { + // declgen file + let declOut: string = ''; + let declBridgeOut: string = ''; + if (!moduleInfo.declgenV1OutPath) { + declOut = path.join(buildConfig.declgenOutDir, moduleName); + } + if (!moduleInfo.declgenBridgeCodePath) { + declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + } + let filePathFromModuleRoot: string = path.relative(moduleRootPath, modifyFilePath); + let declEtsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenV1OutPath ?? declOut, filePathFromModuleRoot), + DECL_ETS_SUFFIX + ); + let etsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, filePathFromModuleRoot), + TS_SUFFIX + ); + ensurePathExists(declEtsOutputPath); + ensurePathExists(etsOutputPath); + global.es2pandaPublic._GenerateTsDeclarationsFromContext(ctx, declEtsOutputPath, etsOutputPath, 1, 0, ''); + } finally { + this.destroyContext(cfg, ctx); } - if (!moduleInfo.declgenBridgeCodePath) { - declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + } + + getOffsetByColAndLine(filename: String, line: number, column: number): number { + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getOffsetByColAndLine(ctx, line, column); + } finally { + this.destroyContext(cfg, ctx); } - let filePathFromModuleRoot: string = path.relative(moduleRootPath, modifyFilePath); - let declEtsOutputPath: string = changeDeclgenFileExtension( - path.join(moduleInfo.declgenV1OutPath ?? declOut, filePathFromModuleRoot), - DECL_ETS_SUFFIX - ); - let etsOutputPath: string = changeDeclgenFileExtension( - path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, filePathFromModuleRoot), - TS_SUFFIX - ); - ensurePathExists(declEtsOutputPath); - ensurePathExists(etsOutputPath); - global.es2pandaPublic._GenerateTsDeclarationsFromContext( - localCtx, - declEtsOutputPath, - etsOutputPath, - 1, - 0 - ); - let filePath = path.resolve(declEtsOutputPath); - let declgLocalCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const declgSource = this.getFileSource(filePath); - let declgLocalCtx = lspDriverHelper.createCtx(declgSource, filePath, declgLocalCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(declgLocalCtx); - lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - lspDriverHelper.destroyContext(declgLocalCtx); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); + return ptr; } getDefinitionAtPosition(filename: String, offset: number): LspDefinitionData { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getDefinitionAtPosition(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getDefinitionAtPosition(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDefinitionData(ptr); } getSemanticDiagnostics(filename: String): LspDiagsNode { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getSemanticDiagnostics(localCtx); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getSemanticDiagnostics(ctx); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDiagsNode(ptr); } getCurrentTokenValue(filename: String, offset: number): string { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getCurrentTokenValue(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getCurrentTokenValue(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return unpackString(ptr); } getImplementationAtPosition(filename: String, offset: number): LspDefinitionData { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getImplementationAtPosition(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getImplementationAtPosition(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDefinitionData(ptr); } getFileReferences(filename: String): LspReferenceData[] { - let lspDriverHelper = new LspDriverHelper(); - let searchFilePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[searchFilePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, searchFilePath, this.pandaLibPath); - const source = this.getFileSource(searchFilePath); - let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let isPackageModule = global.es2panda._isPackageModule(localCtx); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let isPackageModule: boolean; + const [cfg, searchCtx] = this.createContext(filename); + try { + isPackageModule = global.es2panda._isPackageModule(searchCtx); + } finally { + this.destroyContext(cfg, searchCtx); + } let result: LspReferenceData[] = []; - let compileFiles = this.moduleInfos[searchFilePath].compileFiles; + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; for (let i = 0; i < compileFiles.length; i++) { - let filePath = path.resolve(compileFiles[i]); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getFileReferences(searchFilePath, localCtx, isPackageModule); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(compileFiles[i]); + try { + ptr = global.es2panda._getFileReferences(path.resolve(filename.valueOf()), ctx, isPackageModule); + } finally { + this.destroyContext(cfg, ctx); + } let refs = new LspReferences(ptr); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); for (let j = 0; j < refs.referenceInfos.length; j++) { if (refs.referenceInfos[j].fileName !== '') { result.push(refs.referenceInfos[j]); @@ -430,38 +387,23 @@ export class Lsp { } getReferencesAtPosition(filename: String, offset: number): LspReferenceData[] { - let lspDriverHelper = new LspDriverHelper(); - let searchFilePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[searchFilePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, searchFilePath, this.pandaLibPath); - const source = this.getFileSource(searchFilePath); - let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let declInfo = global.es2panda._getDeclInfo(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let declInfo: KPointer; + const [cfg, searchCtx] = this.createContext(filename); + try { + declInfo = global.es2panda._getDeclInfo(searchCtx, offset); + } finally { + this.destroyContext(cfg, searchCtx); + } let result: LspReferenceData[] = []; - let compileFiles = this.moduleInfos[searchFilePath].compileFiles; + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; for (let i = 0; i < compileFiles.length; i++) { - let filePath = path.resolve(compileFiles[i]); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getReferencesAtPosition(localCtx, declInfo); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(compileFiles[i]); + try { + ptr = global.es2panda._getReferencesAtPosition(ctx, declInfo); + } finally { + this.destroyContext(cfg, ctx); + } let refs = new LspReferences(ptr); result.push(...refs.referenceInfos); } @@ -469,43 +411,25 @@ export class Lsp { } getTypeHierarchies(filename: String, offset: number): LspTypeHierarchiesInfo | null { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getTypeHierarchies(localCtx, localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + ptr = global.es2panda._getTypeHierarchies(ctx, ctx, offset); let ref = new LspTypeHierarchiesInfo(ptr); if (ref.fileName === '') { - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + this.destroyContext(cfg, ctx); return null; } let result: LspTypeHierarchiesInfo[] = []; - let compileFiles = this.moduleInfos[filePath].compileFiles; + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; for (let i = 0; i < compileFiles.length; i++) { - let filePath = path.resolve(compileFiles[i]); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let searchCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let searchCtx = lspDriverHelper.createCtx(source, filePath, searchCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(searchCtx); - lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getTypeHierarchies(searchCtx, localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(searchCtx); - lspDriverHelper.destroyConfig(searchCfg); - let refs = new LspTypeHierarchiesInfo(ptr); + let searchPtr: KPointer; + const [cfg, searchCtx] = this.createContext(compileFiles[i]); + try { + searchPtr = global.es2panda._getTypeHierarchies(searchCtx, ctx, offset); + } finally { + this.destroyContext(cfg, searchCtx); + } + let refs = new LspTypeHierarchiesInfo(searchPtr); if (i > 0) { result[0].subHierarchies.subOrSuper = result[0].subHierarchies.subOrSuper.concat( refs.subHierarchies.subOrSuper @@ -532,81 +456,46 @@ export class Lsp { } getClassHierarchyInfo(filename: String, offset: number): LspClassHierarchy { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getClassHierarchyInfo(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getClassHierarchyInfo(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspClassHierarchy(ptr); } getAliasScriptElementKind(filename: String, offset: number): LspCompletionEntryKind { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let kind = global.es2panda._getAliasScriptElementKind(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let kind: KInt; + const [cfg, ctx] = this.createContext(filename); + try { + kind = global.es2panda._getAliasScriptElementKind(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return kind; } getClassHierarchies(filename: String, offset: number): LspClassHierarchies { let contextList = []; - let lspDriverHelper = new LspDriverHelper(); - let localFilePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[localFilePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, localFilePath, this.pandaLibPath); - const source = this.getFileSource(localFilePath); - let localCtx = lspDriverHelper.createCtx(source, localFilePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - contextList.push({ ctx: localCtx, cfg: localCfg }); - let nativeContextList = global.es2panda._pushBackToNativeContextVector(localCtx, localCtx, 1); - let compileFiles = this.moduleInfos[localFilePath].compileFiles; + const [cfg, ctx] = this.createContext(filename); + contextList.push({ ctx: ctx, cfg: cfg }); + let nativeContextList = global.es2panda._pushBackToNativeContextVector(ctx, ctx, 1); + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; for (let i = 0; i < compileFiles.length; i++) { let filePath = path.resolve(compileFiles[i]); - if (localFilePath === filePath) { + if (path.resolve(filename.valueOf()) === filePath) { continue; } - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let searchCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let searchCtx = lspDriverHelper.createCtx(source, filePath, searchCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(searchCtx); - lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + const [searchCfg, searchCtx] = this.createContext(filePath); contextList.push({ ctx: searchCtx, cfg: searchCfg }); global.es2panda._pushBackToNativeContextVector(searchCtx, nativeContextList, 0); } let ptr = global.es2panda._getClassHierarchies(nativeContextList, filename, offset); PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); for (const { ctx, cfg } of contextList) { - lspDriverHelper.destroyContext(ctx); - lspDriverHelper.destroyConfig(cfg); + this.destroyContext(cfg, ctx); } return new LspClassHierarchies(ptr); } @@ -616,76 +505,46 @@ export class Lsp { offset: number, shouldCollectInherited: boolean = false ): LspClassPropertyInfo { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getClassPropertyInfo(localCtx, offset, shouldCollectInherited); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getClassPropertyInfo(ctx, offset, shouldCollectInherited); + } finally { + this.destroyContext(cfg, ctx); + } return new LspClassPropertyInfo(ptr); } getOrganizeImports(filename: String): LspFileTextChanges { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._organizeImports(localCtx, filename); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._organizeImports(ctx, filename); + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + } finally { + this.destroyContext(cfg, ctx); + } return new LspFileTextChanges(ptr); } findSafeDeleteLocation(filename: String, offset: number): LspSafeDeleteLocationInfo[] { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let declInfo = global.es2panda._getDeclInfo(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let declInfo: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + declInfo = global.es2panda._getDeclInfo(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } let result: LspSafeDeleteLocationInfo[] = []; - let compileFiles = this.moduleInfos[filePath].compileFiles; + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; for (let i = 0; i < compileFiles.length; i++) { - let filePath = path.resolve(compileFiles[i]); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._findSafeDeleteLocation(localCtx, declInfo); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [searchCfg, searchCtx] = this.createContext(compileFiles[i]); + try { + ptr = global.es2panda._findSafeDeleteLocation(searchCtx, declInfo); + } finally { + this.destroyContext(searchCfg, searchCtx); + } let refs = new LspSafeDeleteLocation(ptr); result.push(...refs.safeDeleteLocationInfos); } @@ -693,141 +552,82 @@ export class Lsp { } getCompletionEntryDetails(filename: String, offset: number, entryName: String): CompletionEntryDetails { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getCompletionEntryDetails(entryName, filename, localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getCompletionEntryDetails(entryName, filename, ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new CompletionEntryDetails(ptr); } getApplicableRefactors(filename: String, kind: String, offset: number): ApplicableRefactorItemInfo[] { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + let ptr: KPointer; let result: ApplicableRefactorItemInfo[] = []; - let ptr = global.es2panda._getApplicableRefactors(localCtx, kind, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getApplicableRefactors(ctx, kind, offset); + } finally { + this.destroyContext(cfg, ctx); + } let refs = new LspApplicableRefactorInfo(ptr); result.push(...refs.applicableRefactorInfo); return Array.from(new Set(result)); } getClassConstructorInfo(filename: String, offset: number, properties: string[]): LspClassConstructorInfo { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getClassConstructorInfo(localCtx, offset, passStringArray(properties)); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getClassConstructorInfo(ctx, offset, passStringArray(properties)); + } finally { + this.destroyContext(cfg, ctx); + } return new LspClassConstructorInfo(ptr); } getSyntacticDiagnostics(filename: String): LspDiagsNode { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - const packageName = this.moduleInfos[filePath].packageName; - const buildConfig = this.buildConfigs[packageName]; - PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getSyntacticDiagnostics(localCtx); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getSyntacticDiagnostics(ctx); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDiagsNode(ptr); } getSuggestionDiagnostics(filename: String): LspDiagsNode { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getSuggestionDiagnostics(localCtx); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getSuggestionDiagnostics(ctx); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDiagsNode(ptr); } getQuickInfoAtPosition(filename: String, offset: number): LspQuickInfo { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getQuickInfoAtPosition(filename, localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getQuickInfoAtPosition(filename, ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspQuickInfo(ptr); } getDocumentHighlights(filename: String, offset: number): LspDocumentHighlightsReferences { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getDocumentHighlights(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getDocumentHighlights(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspDocumentHighlightsReferences(ptr); } @@ -849,6 +649,10 @@ export class Lsp { offset += wildcard.length; } let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -861,159 +665,85 @@ export class Lsp { } toLineColumnOffset(filename: String, offset: number): LspLineAndCharacter { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._toLineColumnOffset(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._toLineColumnOffset(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspLineAndCharacter(ptr); } getSafeDeleteInfo(filename: String, position: number): boolean { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let result = global.es2panda._getSafeDeleteInfo(localCtx, position); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let result: boolean; + const [cfg, ctx] = this.createContext(filename); + try { + result = global.es2panda._getSafeDeleteInfo(ctx, position); + } finally { + this.destroyContext(cfg, ctx); + } return result; } findRenameLocations(filename: String, offset: number): LspRenameLocation[] { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let compileFiles = this.moduleInfos[filePath].compileFiles; + let compileFiles = this.moduleInfos[path.resolve(filename.valueOf())].compileFiles; const fileContexts: KPointer[] = []; - const fileConfigs: Config[] = [localCfg]; + const fileConfigs: Config[] = []; for (let i = 0; i < compileFiles.length; i++) { - let filePath = path.resolve(compileFiles[i]); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let compileFileCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let compileFileCtx = lspDriverHelper.createCtx(source, filePath, compileFileCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(compileFileCtx); - lspDriverHelper.proceedToState(compileFileCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(compileFileCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + const [compileFileCfg, compileFileCtx] = this.createContext(compileFiles[i]); fileContexts.push(compileFileCtx); fileConfigs.push(compileFileCfg); } - const ptr = global.es2panda._findRenameLocations( - fileContexts.length, - passPointerArray(fileContexts), - localCtx, - offset - ); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + const [cfg, ctx] = this.createContext(filename); + const ptr = global.es2panda._findRenameLocations(fileContexts.length, passPointerArray(fileContexts), ctx, offset); const result: LspRenameLocation[] = new NativePtrDecoder().decode(ptr).map((elPeer: KPointer) => { return new LspRenameLocation(elPeer); }); for (let i = 0; i < fileContexts.length; i++) { - lspDriverHelper.destroyContext(fileContexts[i]); - } - lspDriverHelper.destroyContext(localCtx); - for (const cfg of fileConfigs) { - lspDriverHelper.destroyConfig(cfg); + this.destroyContext(fileConfigs[i], fileContexts[i]); } + this.destroyContext(cfg, ctx); return Array.from(new Set(result)); } getRenameInfo(filename: String, offset: number): LspRenameInfoType { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getRenameInfo(localCtx, offset, this.pandaLibPath); - const success = global.es2panda._getRenameInfoIsSuccess(ptr); + let ptr: KPointer; let res: LspRenameInfoType; - if (success) { - res = new LspRenameInfoSuccess(global.es2panda._getRenameInfoSuccess(ptr)); - } else { - res = new LspRenameInfoFailure(global.es2panda._getRenameInfoFailure(ptr)); + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getRenameInfo(ctx, offset, this.pandaLibPath); + const success = global.es2panda._getRenameInfoIsSuccess(ptr); + if (success) { + res = new LspRenameInfoSuccess(global.es2panda._getRenameInfoSuccess(ptr)); + } else { + res = new LspRenameInfoFailure(global.es2panda._getRenameInfoFailure(ptr)); + } + } finally { + this.destroyContext(cfg, ctx); } - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); return res; } getSpanOfEnclosingComment(filename: String, offset: number, onlyMultiLine: boolean): LspTextSpan { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getSpanOfEnclosingComment(localCtx, offset, onlyMultiLine); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getSpanOfEnclosingComment(ctx, offset, onlyMultiLine); + } finally { + this.destroyContext(cfg, ctx); + } return new LspTextSpan(ptr); } getCodeFixesAtPosition(filename: String, start: number, end: number, errorCodes: number[]): CodeFixActionInfo[] { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getCodeFixesAtPosition( - localCtx, - start, - end, - new Int32Array(errorCodes), - errorCodes.length - ); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getCodeFixesAtPosition(ctx, start, end, new Int32Array(errorCodes), errorCodes.length); + } finally { + this.destroyContext(cfg, ctx); + } const codeFixActionInfoList = new CodeFixActionInfoList(ptr); const codeFixActionInfos: CodeFixActionInfo[] = []; codeFixActionInfos.push(...codeFixActionInfoList.codeFixActionInfos); @@ -1021,22 +751,14 @@ export class Lsp { } provideInlayHints(filename: String, span: TextSpan): LspInlayHint[] { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - const nativeSpan = global.es2panda._createTextSpan(span.start, span.length); - let ptr = global.es2panda._getInlayHintList(localCtx, nativeSpan); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + const nativeSpan = global.es2panda._createTextSpan(span.start, span.length); + ptr = global.es2panda._getInlayHintList(ctx, nativeSpan); + } finally { + this.destroyContext(cfg, ctx); + } const inlayHintList = new LspInlayHintList(ptr); const inlayHints: LspInlayHint[] = []; inlayHints.push(...inlayHintList.inlayHints); @@ -1044,21 +766,13 @@ export class Lsp { } getSignatureHelpItems(filename: String, offset: number): LspSignatureHelpItems { - let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; - let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); - PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getSignatureHelpItems(localCtx, offset); - PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + let ptr: KPointer; + const [cfg, ctx] = this.createContext(filename); + try { + ptr = global.es2panda._getSignatureHelpItems(ctx, offset); + } finally { + this.destroyContext(cfg, ctx); + } return new LspSignatureHelpItems(ptr); } diff --git a/ets2panda/bindings/test/README.md b/ets2panda/bindings/test/README.md index 0a6e5478bf6157e1439a310cb6c55474b87aa6f0..bce307bd3a7c4b9e782c71c91208b2dd33a84999 100644 --- a/ets2panda/bindings/test/README.md +++ b/ets2panda/bindings/test/README.md @@ -1,26 +1,19 @@ ### How to run bindings test? +first, you need download a SDK package, then unzip ets component into `bindings/test/` directory. +Download SDK package from [here](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist). + ```Bash +unzip /path/to/ets-xxx.zip -d /path/to/bindings/test/ cd /path/to/bindings -### check environment -# if you are using Linux shell -bash test/prepare.sh -# or if you are using Windows shell -powershell -f test/prepare.ps1 - ### run test npm install npm run test - -### restore the path to the original state -bash test/prepare.sh --restore -# or -powershell -f test/prepare.ps1 --restore ``` #### tips -1. If you want to update a lot of expected results, you can use `node dist-test/test/run_tests.js ./test --update` +1. If you want to update a lot of expected results, you can use `npm run test:update` to update all expected results. ### testcase directory structure . diff --git a/ets2panda/bindings/test/cases.ts b/ets2panda/bindings/test/cases.ts index 316424244ca6f00288d8b4d375fe66440e5fced6..2174a4d07f581da044ee87ad796c40ac97c60578 100644 --- a/ets2panda/bindings/test/cases.ts +++ b/ets2panda/bindings/test/cases.ts @@ -32,7 +32,7 @@ function resolveTestPath(relativePath: string): string { return path.join(PROJECT_ROOT, relativePath); } -export const testCases: TestCases = { +export const basicCases: TestCases = { getDefinitionAtPosition: { expectedFilePath: resolveTestPath('test/expected/getDefinitionAtPosition.json'), '1': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition2.ets'), 655], @@ -44,20 +44,22 @@ export const testCases: TestCases = { '7': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition13.ets'), 664], '8': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition15.ets'), 617], '9': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition17.ets'), 677], - '10': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition18.ets'), 930], - '11': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets'), 634] + '11': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets'), 634], + '12': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition2.ets'), 637] }, getSemanticDiagnostics: { expectedFilePath: resolveTestPath('test/expected/getSemanticDiagnostics.json'), '1': [resolveTestPath('test/testcases/getSemanticDiagnostics/getSemanticDiagnostics1.ets')], - '2': [resolveTestPath('test/testcases/getSemanticDiagnostics/getSemanticDiagnostics2.ets')] + '2': [resolveTestPath('test/testcases/getSemanticDiagnostics/getSemanticDiagnostics2.ets')], + '3': [resolveTestPath('test/testcases/getSemanticDiagnostics/getSemanticDiagnostics3.ets')] }, getCurrentTokenValue: { expectedFilePath: resolveTestPath('test/expected/getCurrentTokenValue.json'), '1': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue1.ets'), 611], '2': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue2.ets'), 612], '3': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue3.ets'), 612], - '4': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue4.ets'), 611] + '4': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue4.ets'), 611], + '5': [resolveTestPath('test/testcases/getCurrentTokenValue/getCurrentTokenValue5.ets'), 697] }, getFileReferences: { expectedFilePath: resolveTestPath('test/expected/getFileReferences.json'), @@ -71,12 +73,14 @@ export const testCases: TestCases = { expectedFilePath: resolveTestPath('test/expected/getReferencesAtPosition.json'), '1': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition1.ets'), 613], '2': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition2.ets'), 635], - '3': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition4.ets'), 625] + '3': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition4.ets'), 625], + '4': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition6.ets'), 697] }, getSyntacticDiagnostics: { expectedFilePath: resolveTestPath('test/expected/getSyntacticDiagnostics.json'), '1': [resolveTestPath('test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics1.ets')], - '2': [resolveTestPath('test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics2.ets')] + '2': [resolveTestPath('test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics2.ets')], + '3': [resolveTestPath('test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics3.ets')] }, getSuggestionDiagnostics: { expectedFilePath: resolveTestPath('test/expected/getSuggestionDiagnostics.json'), @@ -86,7 +90,8 @@ export const testCases: TestCases = { expectedFilePath: resolveTestPath('test/expected/getQuickInfoAtPosition.json'), '1': [resolveTestPath('test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition1.ets'), 626], '2': [resolveTestPath('test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition2.ets'), 618], - '3': [resolveTestPath('test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition3.ets'), 663] + '3': [resolveTestPath('test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition3.ets'), 663], + '4': [resolveTestPath('test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition4.ets'), 697] }, getDocumentHighlights: { expectedFilePath: resolveTestPath('test/expected/getDocumentHighlights.json'), @@ -96,7 +101,8 @@ export const testCases: TestCases = { '4': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights4.ets'), 626], '5': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights5.ets'), 619], '6': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights6.ets'), 657], - '7': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights7.ets'), 733] + '7': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights7.ets'), 733], + '8': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights8.ets'), 677] }, getCompletionAtPosition: { expectedFilePath: resolveTestPath('test/expected/getCompletionAtPosition.json'), @@ -113,12 +119,14 @@ export const testCases: TestCases = { '11': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition11.ets'), 682], '12': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition12.ets'), 720], '13': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition13.ets'), 658], - '14': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition14.ets'), 659] + '14': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition14.ets'), 659], + '15': [resolveTestPath('test/testcases/getCompletionAtPosition/getCompletionsAtPosition15.ets'), 722] }, toLineColumnOffset: { expectedFilePath: resolveTestPath('test/expected/toLineColumnOffset.json'), '1': [resolveTestPath('test/testcases/toLineColumnOffset/toLineColumnOffset1.ets'), 0], - '2': [resolveTestPath('test/testcases/toLineColumnOffset/toLineColumnOffset1.ets'), 642] + '2': [resolveTestPath('test/testcases/toLineColumnOffset/toLineColumnOffset1.ets'), 642], + '3': [resolveTestPath('test/testcases/toLineColumnOffset/toLineColumnOffset2.ets'), 709] }, getSpanOfEnclosingComment: { expectedFilePath: resolveTestPath('test/expected/getSpanOfEnclosingComment.json'), @@ -131,13 +139,23 @@ export const testCases: TestCases = { '1': [ resolveTestPath('test/testcases/provideInlayHints/provideInlayHints1.ets'), { start: 712, length: 11 } as TextSpan + ], + '2': [ + resolveTestPath('test/testcases/provideInlayHints/provideInlayHints2.ets'), + { start: 683, length: 5 } as TextSpan ] }, + getCodeFixesAtPosition: { + expectedFilePath: resolveTestPath('test/expected/getCodeFixesAtPosition.json'), + '1': [resolveTestPath('test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets'), 994, 995, [4000]] + }, getSignatureHelpItems: { expectedFilePath: resolveTestPath('test/expected/getSignatureHelpItems.json'), '1': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 613], '2': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 620], - '3': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 678] + '3': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 678], + '4': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems2.ets'), 697], + '5': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems2.ets'), 773] }, findRenameLocations: { expectedFilePath: resolveTestPath('test/expected/findRenameLocations.json'), @@ -148,7 +166,13 @@ export const testCases: TestCases = { }, getRenameInfo: { expectedFilePath: resolveTestPath('test/expected/getRenameInfo.json'), - '1': [resolveTestPath('test/testcases/getRenameInfo/getRenameInfo1.ets'), 615] + '1': [resolveTestPath('test/testcases/getRenameInfo/getRenameInfo1.ets'), 615], + '2': [resolveTestPath('test/testcases/getRenameInfo/getRenameInfo2.ets'), 626], + '3': [resolveTestPath('test/testcases/getRenameInfo/getRenameInfo3.ets'), 697] + }, + getOffsetByColAndLine: { + expectedFilePath: resolveTestPath('test/expected/getOffsetByColAndLine.json'), + '1': [resolveTestPath('test/testcases/getOffsetByColAndLine/getOffsetByColAndLine1.ets'), 51, 14] }, entry: { expectedFilePath: '', @@ -156,7 +180,7 @@ export const testCases: TestCases = { } }; -export const testSingleModuleCases: TestCases = { +export const singleModuleCases: TestCases = { generateDeclFile: { expectedFilePath: resolveTestPath('test/expected/generateDeclFile.json'), '1': [] @@ -167,4 +191,4 @@ export const testSingleModuleCases: TestCases = { } }; -export const getSpanOfEnclosingCommentTests = testCases.getSpanOfEnclosingComment; +export const getSpanOfEnclosingCommentTests = basicCases.getSpanOfEnclosingComment; diff --git a/ets2panda/bindings/test/expected/findRenameLocations.json b/ets2panda/bindings/test/expected/findRenameLocations.json index cc8a6bac0ead6eaad0dd130117507f0be5854a05..53743ac1c7e1bd73e6bce645a0678629d9853c33 100644 --- a/ets2panda/bindings/test/expected/findRenameLocations.json +++ b/ets2panda/bindings/test/expected/findRenameLocations.json @@ -4,33 +4,25 @@ "fileName": "findRenameLocations1.ets", "start": 708, "end": 711, - "line": 21, - "prefixText": "export class ", - "suffixText": " {" + "line": 21 }, { "fileName": "findRenameLocations2.ets", "start": 630, "end": 633, - "line": 15, - "prefixText": "import { dummy, abc, ", - "suffixText": " } from \"./findRenameLocations1.ets\";" + "line": 15 }, { "fileName": "findRenameLocations2.ets", "start": 738, "end": 741, - "line": 23, - "prefixText": "let myfoo = new ", - "suffixText": "(\"apples\", 1, 2, 3);" + "line": 23 }, { "fileName": "findRenameLocations2.ets", "start": 781, "end": 784, - "line": 24, - "prefixText": "let otherfoo = new ", - "suffixText": "(\"oranges\", 4, 5, 6);" + "line": 24 } ], "2": [ @@ -38,65 +30,49 @@ "fileName": "findRenameLocations1.ets", "start": 625, "end": 628, - "line": 15, - "prefixText": "export function ", - "suffixText": "(x: number): void {" + "line": 15 }, { "fileName": "findRenameLocations1.ets", "start": 1259, "end": 1262, - "line": 49, - "prefixText": "", - "suffixText": "(2);" + "line": 49 }, { "fileName": "findRenameLocations1.ets", "start": 1267, "end": 1270, - "line": 50, - "prefixText": "", - "suffixText": "(3);" + "line": 50 }, { "fileName": "findRenameLocations1.ets", "start": 1275, "end": 1278, - "line": 51, - "prefixText": "", - "suffixText": "(4);" + "line": 51 }, { "fileName": "findRenameLocations2.ets", "start": 625, "end": 628, - "line": 15, - "prefixText": "import { dummy, ", - "suffixText": ", Foo } from \"./findRenameLocations1.ets\";" + "line": 15 }, { "fileName": "findRenameLocations2.ets", "start": 694, "end": 697, - "line": 19, - "prefixText": "", - "suffixText": "(5);" + "line": 19 }, { "fileName": "findRenameLocations2.ets", "start": 702, "end": 705, - "line": 20, - "prefixText": "", - "suffixText": "(55);" + "line": 20 }, { "fileName": "findRenameLocations2.ets", "start": 711, "end": 714, - "line": 21, - "prefixText": "", - "suffixText": "(555);" + "line": 21 } ], "3": [ @@ -104,49 +80,37 @@ "fileName": "findRenameLocations1.ets", "start": 667, "end": 672, - "line": 18, - "prefixText": "export function ", - "suffixText": "(x: number): void {" + "line": 18 }, { "fileName": "findRenameLocations1.ets", "start": 1239, "end": 1244, - "line": 47, - "prefixText": "", - "suffixText": "(0);" + "line": 47 }, { "fileName": "findRenameLocations1.ets", "start": 1249, "end": 1254, - "line": 48, - "prefixText": "", - "suffixText": "(1);" + "line": 48 }, { "fileName": "findRenameLocations2.ets", "start": 618, "end": 623, - "line": 15, - "prefixText": "import { ", - "suffixText": ", abc, Foo } from \"./findRenameLocations1.ets\";" + "line": 15 }, { "fileName": "findRenameLocations2.ets", "start": 673, "end": 678, - "line": 17, - "prefixText": "", - "suffixText": "(4);" + "line": 17 }, { "fileName": "findRenameLocations2.ets", "start": 683, "end": 688, - "line": 18, - "prefixText": "", - "suffixText": "(44);" + "line": 18 } ], "4": [ @@ -154,25 +118,19 @@ "fileName": "findRenameLocations1.ets", "start": 718, "end": 722, - "line": 22, - "prefixText": " ", - "suffixText": ": string = \"unassigned\";" + "line": 22 }, { "fileName": "findRenameLocations1.ets", "start": 882, "end": 886, - "line": 27, - "prefixText": " this.", - "suffixText": " = name;" + "line": 27 }, { "fileName": "findRenameLocations2.ets", "start": 866, "end": 870, - "line": 28, - "prefixText": "console.log(myfoo.", - "suffixText": ")" + "line": 28 } ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/generateDeclFile.json b/ets2panda/bindings/test/expected/generateDeclFile.json index adaa8c41ba026024e8124327c13034438725b998..2eef5ba8ef8e1b09685b53ab5874f0cb87ea5ac4 100644 --- a/ets2panda/bindings/test/expected/generateDeclFile.json +++ b/ets2panda/bindings/test/expected/generateDeclFile.json @@ -10,4 +10,4 @@ "generateDeclFile8.d.ets", "generateDeclFile9.d.ets" ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json b/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json new file mode 100644 index 0000000000000000000000000000000000000000..24c432fbfca3cfd9de77d8e8451b6af27c19ed96 --- /dev/null +++ b/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json @@ -0,0 +1,28 @@ +{ + "1": [ + { + "changes": [ + { + "fileName": "getCodeFixesAtPosition1.ets", + "textChanges": [ + { + "span": { + "start": 990, + "length": 6 + }, + "newText": "" + } + ] + }, + { + "fileName": "getCodeFixesAtPosition1.ets", + "textChanges": [] + } + ], + "description": "Fix Description", + "fixName": "Fix", + "fixId_": "UI_PLUGIN_SUGGEST", + "fixAllDescription_": "Fix All Description" + } + ] +} diff --git a/ets2panda/bindings/test/expected/getCompletionAtPosition.json b/ets2panda/bindings/test/expected/getCompletionAtPosition.json index 043a9b5580a8653f7583d0d812e8b37f900d3ed4..9a1ba0a4ab5f585aa1a54ec984e3d09a56b0b826 100644 --- a/ets2panda/bindings/test/expected/getCompletionAtPosition.json +++ b/ets2panda/bindings/test/expected/getCompletionAtPosition.json @@ -186,5 +186,35 @@ "kind": 2, "data": null } + ], + "15": [ + { + "name": "isEmpty", + "sortText": "17", + "insertText": "", + "kind": 2, + "data": null + }, + { + "name": "peek", + "sortText": "17", + "insertText": "", + "kind": 2, + "data": null + }, + { + "name": "pop", + "sortText": "17", + "insertText": "", + "kind": 2, + "data": null + }, + { + "name": "push", + "sortText": "17", + "insertText": "", + "kind": 2, + "data": null + } ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getCurrentTokenValue.json b/ets2panda/bindings/test/expected/getCurrentTokenValue.json index 2efc1c7dcc7425280098742dee114aaf29f47d4e..7e8e9ca7cbaa75db8b4adad99797db4a7b4d162f 100644 --- a/ets2panda/bindings/test/expected/getCurrentTokenValue.json +++ b/ets2panda/bindings/test/expected/getCurrentTokenValue.json @@ -2,5 +2,6 @@ "1": "ab", "2": "ab", "3": "ab", - "4": "ab" -} \ No newline at end of file + "4": "ab", + "5": "pu" +} diff --git a/ets2panda/bindings/test/expected/getDefinitionAtPosition.json b/ets2panda/bindings/test/expected/getDefinitionAtPosition.json index 73b133987606044ddbf101795a4e7b21a1110a15..ad5c03a79633e1347a01634b8e2db2d8fcd65824 100644 --- a/ets2panda/bindings/test/expected/getDefinitionAtPosition.json +++ b/ets2panda/bindings/test/expected/getDefinitionAtPosition.json @@ -53,5 +53,10 @@ "fileName": "taskpool.ets", "start": 686, "length": 4 + }, + "12": { + "fileName": "getDefinitionAtPosition1.ets", + "start": 0, + "length": 0 } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getDocumentHighlights.json b/ets2panda/bindings/test/expected/getDocumentHighlights.json index 49190c9ce2c7e36b26677db053333613d4eb04fc..cb53f7cf9a11a73a903ae19164bb7c26cfa72379 100644 --- a/ets2panda/bindings/test/expected/getDocumentHighlights.json +++ b/ets2panda/bindings/test/expected/getDocumentHighlights.json @@ -313,5 +313,38 @@ ] } ] + }, + "8": { + "documentHighlights": [ + { + "fileName": "getDocumentHighlights8.ets", + "highlightSpans": [ + { + "fileName": "getDocumentHighlights8.ets", + "textSpan": { + "start": 628, + "length": 5 + }, + "contextSpan": { + "start": 0, + "length": 0 + }, + "kind": 3 + }, + { + "fileName": "getDocumentHighlights8.ets", + "textSpan": { + "start": 674, + "length": 5 + }, + "contextSpan": { + "start": 0, + "length": 0 + }, + "kind": 2 + } + ] + } + ] } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getFileReferences.json b/ets2panda/bindings/test/expected/getFileReferences.json index 270729c437bc25ccff94f07becd5a81f684b8ba2..dfa9cce006bd48d00b702448bd8ce1581c1186d8 100644 --- a/ets2panda/bindings/test/expected/getFileReferences.json +++ b/ets2panda/bindings/test/expected/getFileReferences.json @@ -23,4 +23,4 @@ "length": 29 } ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getFileSource.json b/ets2panda/bindings/test/expected/getFileSource.json index e893655add4e990ee5dee52a66bfe7be02fb141d..e78e8263809eb2e6790b12307f456fad30c3db94 100644 --- a/ets2panda/bindings/test/expected/getFileSource.json +++ b/ets2panda/bindings/test/expected/getFileSource.json @@ -1,3 +1,3 @@ { - "1": "/*\n * Copyright (c) 2025 Huawei Device Co., Ltd.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet a = 1;" -} \ No newline at end of file + "1": "/*\n * Copyright (c) 2025 Huawei Device Co., Ltd.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet a = 1;" +} diff --git a/ets2panda/bindings/test/expected/getOffsetByColAndLine.json b/ets2panda/bindings/test/expected/getOffsetByColAndLine.json new file mode 100644 index 0000000000000000000000000000000000000000..20feeefb6924fc3fe9e6de00ff27b882f8737c40 --- /dev/null +++ b/ets2panda/bindings/test/expected/getOffsetByColAndLine.json @@ -0,0 +1,3 @@ +{ + "1": 1373 +} diff --git a/ets2panda/bindings/test/expected/getQuickInfoAtPosition.json b/ets2panda/bindings/test/expected/getQuickInfoAtPosition.json index d8dd45871470028b82e634b66b599d7087f65e11..ab3f7ca7b7a3bd711a1e7f8b19e0ed3f7eb02356 100644 --- a/ets2panda/bindings/test/expected/getQuickInfoAtPosition.json +++ b/ets2panda/bindings/test/expected/getQuickInfoAtPosition.json @@ -1,6 +1,6 @@ { "1": { - "kind": "", + "kind": "enum member", "kindModifier": "static public readonly", "textSpan": { "start": 626, @@ -70,7 +70,7 @@ ] }, "3": { - "kind": "property", + "kind": "get", "kindModifier": "public abstract", "textSpan": { "start": 661, @@ -103,5 +103,64 @@ "kind": "returnType" } ] + }, + "4": { + "kind": "method", + "kindModifier": "public declare", + "textSpan": { + "start": 695, + "length": 4 + }, + "fileName": "getQuickInfoAtPosition4.ets", + "displayParts": [ + { + "text": "Stack", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "push", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "item", + "kind": "functionParameter" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameter" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "returnType" + } + ] } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getReferencesAtPosition.json b/ets2panda/bindings/test/expected/getReferencesAtPosition.json index 526e1ac25619fc3bbc93bf40deaacb4d251492c5..e487e7ef028a1fda1c6abc9466affaed9014552b 100644 --- a/ets2panda/bindings/test/expected/getReferencesAtPosition.json +++ b/ets2panda/bindings/test/expected/getReferencesAtPosition.json @@ -49,5 +49,17 @@ "start": 655, "length": 1 } + ], + "4": [ + { + "fileName": "getReferencesAtPosition6.ets", + "start": 695, + "length": 4 + }, + { + "fileName": "getReferencesAtPosition6.ets", + "start": 708, + "length": 4 + } ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getRenameInfo.json b/ets2panda/bindings/test/expected/getRenameInfo.json index 269aac96696f681ad622fee6587b90a272bf69cc..801d75bc296ca7ce95d18f148b599e4c8978a871 100644 --- a/ets2panda/bindings/test/expected/getRenameInfo.json +++ b/ets2panda/bindings/test/expected/getRenameInfo.json @@ -10,5 +10,13 @@ "start": 613, "length": 3 } + }, + "2": { + "canRenameFailure": false, + "localizedErrorMessage": "You cannot rename this element" + }, + "3": { + "canRenameFailure": false, + "localizedErrorMessage": "You cannot rename this element" } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getSemanticDiagnostics.json b/ets2panda/bindings/test/expected/getSemanticDiagnostics.json index 96a6551b8dfa9c62b550d290056103419fae7360..d2faf74bd4f52ea42694f860a42ab494cea35faf 100644 --- a/ets2panda/bindings/test/expected/getSemanticDiagnostics.json +++ b/ets2panda/bindings/test/expected/getSemanticDiagnostics.json @@ -6,7 +6,6 @@ "diagnostics": [ { "message": "Type '\"1\"' is not compatible with type 'Double' at index 1", - "source": "\"1\"", "range": { "start": { "line": 20, @@ -28,7 +27,6 @@ }, { "message": "No matching call signature for add(\"1\", Int)", - "source": "add", "range": { "start": { "line": 20, @@ -50,7 +48,6 @@ }, { "message": "Type '\"hello\"' cannot be assigned to type 'Double'", - "source": "\"hello\"", "range": { "start": { "line": 16, @@ -71,5 +68,51 @@ } } ] + }, + "3": { + "diagnostics": [ + { + "message": "Type '\"123\"' is not compatible with type 'Double' at index 1", + "range": { + "start": { + "line": 19, + "character": 10 + }, + "end": { + "line": 19, + "character": 15 + } + }, + "tags": [], + "relatedInfo": [], + "code": 2046, + "data": 0, + "severity": 1, + "codeDescription": { + "href": "test code description" + } + }, + { + "message": "No matching call signature for push(\"123\")", + "range": { + "start": { + "line": 19, + "character": 1 + }, + "end": { + "line": 19, + "character": 4 + } + }, + "tags": [], + "relatedInfo": [], + "code": 2127, + "data": 0, + "severity": 1, + "codeDescription": { + "href": "test code description" + } + } + ] } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getSignatureHelpItems.json b/ets2panda/bindings/test/expected/getSignatureHelpItems.json index 77744cd4ecdd2bac58b079393195563b2bc8fd99..1298c568414cbe6d1d84f1a5c99d2fe54153159d 100644 --- a/ets2panda/bindings/test/expected/getSignatureHelpItems.json +++ b/ets2panda/bindings/test/expected/getSignatureHelpItems.json @@ -295,5 +295,159 @@ "selectedItemIndex": 0, "argumentIndex": 1, "argumentCount": 0 + }, + "4": { + "items": [ + { + "prefixDisplayParts": [ + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "Double", + "kind": "typeName" + } + ], + "separatorDisplayParts": [], + "parameters": [ + { + "name": "item", + "documentation": [], + "displayParts": [ + { + "text": "item", + "kind": "paramName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "Double", + "kind": "typeName" + } + ] + } + ], + "documentation": [] + } + ], + "applicableSpan": { + "start": 691, + "length": 11 + }, + "selectedItemIndex": 0, + "argumentIndex": 0, + "argumentCount": 1 + }, + "5": { + "items": [ + { + "prefixDisplayParts": [ + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "Double|undefined", + "kind": "typeName" + } + ], + "separatorDisplayParts": [], + "parameters": [ + { + "name": "key", + "documentation": [], + "displayParts": [ + { + "text": "key", + "kind": "paramName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "String", + "kind": "typeName" + } + ] + } + ], + "documentation": [] + }, + { + "prefixDisplayParts": [ + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "Double|undefined", + "kind": "typeName" + } + ], + "separatorDisplayParts": [], + "parameters": [ + { + "name": "key", + "documentation": [], + "displayParts": [ + { + "text": "key", + "kind": "paramName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": "String", + "kind": "typeName" + } + ] + } + ], + "documentation": [] + } + ], + "applicableSpan": { + "start": 767, + "length": 12 + }, + "selectedItemIndex": 0, + "argumentIndex": 0, + "argumentCount": 1 } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getSpanOfEnclosingComment.json b/ets2panda/bindings/test/expected/getSpanOfEnclosingComment.json index 10e44761c4c7f610708c88334bab57ec50979c4f..ef15b8474c684d8babe957943722f9d9ee73c7b4 100644 --- a/ets2panda/bindings/test/expected/getSpanOfEnclosingComment.json +++ b/ets2panda/bindings/test/expected/getSpanOfEnclosingComment.json @@ -11,4 +11,4 @@ "start": 659, "length": 9 } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getSuggestionDiagnostics.json b/ets2panda/bindings/test/expected/getSuggestionDiagnostics.json index cd3d78acf8f1199d3918b328ceab6e0403ffaafe..1b00d3a830ea2505fb10aee10847fa7c6615ab57 100644 --- a/ets2panda/bindings/test/expected/getSuggestionDiagnostics.json +++ b/ets2panda/bindings/test/expected/getSuggestionDiagnostics.json @@ -3,323 +3,14 @@ "diagnostics": [ { "message": "This_may_be_converted_to_an_async_function", - "source": "", "range": { "start": { - "line": 15, - "character": 609 + "line": 16, + "character": 1 }, "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 609 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 609 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 609 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 15, - "character": 618 - }, - "end": { - "line": 17, - "character": 661 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 662 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 662 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { "line": 18, - "character": 662 - }, - "end": { - "line": 20, - "character": 717 + "character": 3 } }, "tags": [], @@ -333,37 +24,14 @@ }, { "message": "This_may_be_converted_to_an_async_function", - "source": "", "range": { "start": { - "line": 18, - "character": 662 + "line": 16, + "character": 10 }, "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 + "character": 3 } }, "tags": [], @@ -377,15 +45,14 @@ }, { "message": "This_may_be_converted_to_an_async_function", - "source": "", "range": { "start": { - "line": 18, - "character": 671 + "line": 19, + "character": 1 }, "end": { - "line": 20, - "character": 717 + "line": 21, + "character": 2 } }, "tags": [], @@ -399,125 +66,14 @@ }, { "message": "This_may_be_converted_to_an_async_function", - "source": "", "range": { "start": { - "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 671 - }, - "end": { - "line": 20, - "character": 717 - } - }, - "tags": [], - "relatedInfo": [], - "code": 0, - "data": 0, - "severity": 4, - "codeDescription": { - "href": "" - } - }, - { - "message": "This_may_be_converted_to_an_async_function", - "source": "", - "range": { - "start": { - "line": 18, - "character": 671 + "line": 19, + "character": 10 }, "end": { - "line": 20, - "character": 717 + "line": 21, + "character": 2 } }, "tags": [], @@ -531,4 +87,4 @@ } ] } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json b/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json index 37ff72da0fa39654a354aa2434f21d8f43e66507..2abdaa1016c19e827e076454b74a493e12bf45b1 100644 --- a/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json +++ b/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json @@ -6,7 +6,6 @@ "diagnostics": [ { "message": "Unexpected token 'add'.", - "source": "add", "range": { "start": { "line": 16, @@ -28,7 +27,6 @@ }, { "message": "Unexpected token, expected ',' or ')'.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -50,7 +48,6 @@ }, { "message": "Unexpected token ':'.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -72,7 +69,6 @@ }, { "message": "Unexpected token ':'.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -94,7 +90,6 @@ }, { "message": "Unexpected token 'number'.", - "source": "number", "range": { "start": { "line": 16, @@ -116,7 +111,6 @@ }, { "message": "Unexpected token ','.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -138,7 +132,6 @@ }, { "message": "Unexpected token ','.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -160,7 +153,6 @@ }, { "message": "Unexpected token 'b'.", - "source": "functon;\nadd(a);\n*ERROR_LITERAL*;\nnumber;\n*ERROR_LITERAL*;\n\nnumber;\n*ERROR_LITERAL*;\n{\n return ((a) + (b));\n}\nn = 333;\nres = add(n, n);", "range": { "start": { "line": 16, @@ -182,7 +174,6 @@ }, { "message": "Label must be followed by a loop statement.", - "source": "", "range": { "start": { "line": 16, @@ -204,7 +195,6 @@ }, { "message": "Unexpected token ')'.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -226,7 +216,6 @@ }, { "message": "Unexpected token ')'.", - "source": "*ERROR_LITERAL*", "range": { "start": { "line": 16, @@ -248,7 +237,6 @@ }, { "message": "Unexpected token '{'.", - "source": "{\n return ((a) + (b));\n}", "range": { "start": { "line": 16, @@ -270,7 +258,6 @@ }, { "message": "return keyword should be used in function body.", - "source": "return ((a) + (b));", "range": { "start": { "line": 17, @@ -291,5 +278,30 @@ } } ] + }, + "3": { + "diagnostics": [ + { + "message": "Unexpected token, expected 'from'.", + "range": { + "start": { + "line": 16, + "character": 1 + }, + "end": { + "line": 16, + "character": 52 + } + }, + "tags": [], + "relatedInfo": [], + "code": 1228, + "data": 0, + "severity": 1, + "codeDescription": { + "href": "test code description" + } + } + ] } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/modifyDeclFile.json b/ets2panda/bindings/test/expected/modifyDeclFile.json index 7fdd0ca29e096b806eabf4df9e425542065d18be..5718f834601f0bb0db309af84706591e48e639ff 100644 --- a/ets2panda/bindings/test/expected/modifyDeclFile.json +++ b/ets2panda/bindings/test/expected/modifyDeclFile.json @@ -1,7 +1,3 @@ { - "1": [ - "modifyDeclFile1.d.ets", - "modifyDeclFile2.d.ets", - "modifyDeclFile3.d.ets" - ] -} \ No newline at end of file + "1": ["modifyDeclFile1.d.ets", "modifyDeclFile2.d.ets", "modifyDeclFile3.d.ets"] +} diff --git a/ets2panda/bindings/test/expected/provideInlayHints.json b/ets2panda/bindings/test/expected/provideInlayHints.json index 2fcb8921af2f206fc19a95241126550f0e14bd1a..8e47e660c665f5c68d3cf5daeceda5a0f4d85c14 100644 --- a/ets2panda/bindings/test/expected/provideInlayHints.json +++ b/ets2panda/bindings/test/expected/provideInlayHints.json @@ -14,5 +14,30 @@ "whitespaceBefore": false, "whitespaceAfter": true } + ], + "2": [ + { + "text": "item", + "number": 687, + "kind": 1, + "whitespaceBefore": false, + "whitespaceAfter": true + } + ], + "3": [ + { + "text": "key", + "number": 750, + "kind": 1, + "whitespaceBefore": false, + "whitespaceAfter": true + }, + { + "text": "val", + "number": 755, + "kind": 1, + "whitespaceBefore": false, + "whitespaceAfter": true + } ] -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/expected/toLineColumnOffset.json b/ets2panda/bindings/test/expected/toLineColumnOffset.json index df135e00843c85304cca7f3dea794ca01f3d70c5..0ba3e4e454c623140ae8b67aea249ab99d6448c9 100644 --- a/ets2panda/bindings/test/expected/toLineColumnOffset.json +++ b/ets2panda/bindings/test/expected/toLineColumnOffset.json @@ -6,5 +6,9 @@ "2": { "line": 17, "character": 642 + }, + "3": { + "line": 18, + "character": 708 } -} \ No newline at end of file +} diff --git a/ets2panda/bindings/test/run_tests.ts b/ets2panda/bindings/test/run_tests.ts index 9e7ae34818e84998d3016c9f7b9d30f82a1b702f..08df9960ce0ca96927202c9c2cc6f5d472505b1b 100644 --- a/ets2panda/bindings/test/run_tests.ts +++ b/ets2panda/bindings/test/run_tests.ts @@ -16,8 +16,14 @@ import path from 'path'; import fs from 'fs'; import { Lsp, LspDefinitionData, LspCompletionInfo, LspDiagsNode, ModuleDescriptor, PathConfig } from '../src/index'; -import { testCases, testSingleModuleCases } from './cases'; +import { TestCases, basicCases, singleModuleCases } from './cases'; import { LspCompletionEntry } from '../src/lsp/lspNode'; +import { diff } from 'jest-diff'; + +interface NormalizeOptions { + fieldsToDelete?: string[]; // try to delete these fields in the expected result, just focus on the important fields + normalizeFileName?: boolean; +} interface ComparisonOptions { subMatch?: boolean; @@ -31,8 +37,8 @@ interface ComparisonOutcome { let updateMode = false; -function getModules(projectRoot: string): ModuleDescriptor[] { - return Object.keys(testCases).map((name) => { +function getModules(projectRoot: string, cases: TestCases): ModuleDescriptor[] { + return Object.keys(cases).map((name) => { const modulePath = path.join(projectRoot, name); return { arktsversion: '1.2', @@ -56,10 +62,7 @@ function getExpectedResult(filePath: string): any { // CC-OFFNXT(no_explicit_any) project code style function getFilesByDir(dirPath: string): string[] { try { - return fs.readdirSync(dirPath) - .filter(file => - fs.statSync(path.join(dirPath, file)).isFile() - ); + return fs.readdirSync(dirPath).filter((file) => fs.statSync(path.join(dirPath, file)).isFile()); } catch (err) { console.error(`Failed to load files from ${dirPath}: ${err}`); return []; @@ -117,19 +120,27 @@ function sortActualResult(testName: string, res: any): any { } // CC-OFFNXT(no_explicit_any) project code style -function normalizeData(obj: any): any { +function normalizeData(obj: any, options: NormalizeOptions = {}): any { + const { fieldsToDelete = [], normalizeFileName = true } = options; if (Array.isArray(obj)) { - return obj.map(normalizeData); + return obj.map((item) => normalizeData(item, options)); } else if (obj && typeof obj === 'object') { const newObj = { ...obj }; + // always remove 'peer' field if ('peer' in newObj) { - delete newObj.peer; // do not compare peer + delete newObj.peer; } - if (newObj.fileName) { + // remove specified fields + fieldsToDelete.forEach((field) => { + if (field in newObj) { + delete newObj[field]; + } + }); + if (normalizeFileName && newObj.fileName) { newObj.fileName = path.basename(newObj.fileName); } for (const key of Object.keys(newObj)) { - newObj[key] = normalizeData(newObj[key]); + newObj[key] = normalizeData(newObj[key], options); } return newObj; } @@ -172,7 +183,7 @@ function performComparison( expected: unknown, options: ComparisonOptions = {} ): ComparisonOutcome { - const { subMatch = false } = options; + const { subMatch: subMatch = false } = options; if (subMatch) { if (isSubObject(normalizedActual, expected)) { return { passed: true }; @@ -212,12 +223,14 @@ function compareResultsHelper( } console.log(`[${testName}] ❌ Failed`); - console.log(`Expected: ${comparison.expectedJSON}`); - console.log(`Actual: ${comparison.actualJSON}`); + const diffResult = diff(comparison.expectedJSON, comparison.actualJSON); + if (diffResult) { + console.log(diffResult); + } return false; } -function compareGetCompletionResult(testName: string, actual: unknown, expected: unknown): boolean { +function compareGetCompletionResult(testName: string, actual: unknown, expected: unknown): [boolean, unknown] { const completionResult = actual as LspCompletionInfo; const actualEntries = completionResult.entries as LspCompletionEntry[]; const expectedEntries = expected as { @@ -228,18 +241,26 @@ function compareGetCompletionResult(testName: string, actual: unknown, expected: data: null; }[]; - return compareResultsHelper(testName, normalizeData(actualEntries), expectedEntries, { - subMatch: true - } as ComparisonOptions); + const actualData = normalizeData(actualEntries); + return [ + compareResultsHelper(testName, actualData, expectedEntries, { + subMatch: true + } as ComparisonOptions), + actualData + ]; } -function compareDeclFileResult(testName: string, declgenOutDir: string, expected: unknown): boolean { +function compareDeclFileResult(testName: string, declgenOutDir: string, expected: unknown): [boolean, unknown] { let fileList: string[] = getFilesByDir(declgenOutDir); - const actualEntries = fileList.filter(file => file.endsWith('.d.ets')); + const actualEntries = fileList.filter((file) => file.endsWith('.d.ets')); const expectedEntries = expected as string[]; - return compareResultsHelper(testName, normalizeData(actualEntries), expectedEntries, { - subMatch: true - } as ComparisonOptions); + const actualData = normalizeData(actualEntries); + return [ + compareResultsHelper(testName, actualData, expectedEntries, { + subMatch: true + } as ComparisonOptions), + actualData + ]; } function findTextDefinitionPosition(sourceCode: string): number { @@ -271,60 +292,84 @@ function findTaskDefinitionPosition(sourceCode: string): number { throw new Error('Could not find Task definition in source code'); } -function compareGetDefinitionResult(testName: string, actual: any, expected: Record): boolean { +function compareGetDefinitionResult( + testName: string, + actual: unknown, + expected: Record +): [boolean, unknown] { + let expectedResult = expected; + const actualDef = actual as LspDefinitionData; + const fileName = actualDef.fileName as string; + const fileContent = fs.readFileSync(fileName, 'utf8'); // This is the definition info for the UI component. // File in the SDK might changed, so the offset needs to be checked dynamically. if (expected['fileName'] === 'text.d.ets') { - const actualDef = actual as LspDefinitionData; - const fileName = actualDef.fileName as string; - const fileContent = fs.readFileSync(fileName, 'utf8'); const expectedStart = findTextDefinitionPosition(fileContent); - const expectedResult = { + expectedResult = { ...expected, start: expectedStart }; - return compareResultsHelper(testName, normalizeData(actual), expectedResult); } // This is the definition info for the class in std library. // File in the SDK might changed, so the offset needs to be checked dynamically. if (expected['fileName'] === 'taskpool.ets') { - const actualDef = actual as LspDefinitionData; - const fileName = actualDef.fileName as string; - const fileContent = fs.readFileSync(fileName, 'utf8'); const expectedStart = findTaskDefinitionPosition(fileContent); - const expectedResult = { + expectedResult = { ...expected, start: expectedStart }; - return compareResultsHelper(testName, normalizeData(actual), expectedResult); } - return compareResultsHelper(testName, normalizeData(actual), expected); + const actualData = normalizeData(actual); + return [compareResultsHelper(testName, actualData, expectedResult), actualData]; } -// CC-OFFNXT(no_explicit_any) project code style -function compareResults(testName: string, index: string, actual: unknown, expected: unknown, declgenOutDir: string = ''): boolean { - const name = `${testName}:${index}`; +function compareResults( + caseName: string, + actual: unknown, + expected: unknown, + declgenOutDir: string = '' +): [boolean, unknown] { + const testName = caseName.substring(0, caseName.indexOf(':')); if (testName === 'getDefinitionAtPosition') { - return compareGetDefinitionResult(name, actual, expected as Record); + return compareGetDefinitionResult(caseName, actual, expected as Record); } if (testName === 'getCompletionAtPosition') { - return compareGetCompletionResult(name, actual, expected); + return compareGetCompletionResult(caseName, actual, expected); } if (testName === 'generateDeclFile' || testName === 'modifyDeclFile') { const declOutPath = path.join(declgenOutDir, 'dynamic', 'dep', 'declgenV1'); - return compareDeclFileResult(name, declOutPath, expected); + return compareDeclFileResult(caseName, declOutPath, expected); + } + if ( + testName === 'getSemanticDiagnostics' || + testName === 'getSyntacticDiagnostics' || + testName === 'getSuggestionDiagnostics' + ) { + const normalizeOption: NormalizeOptions = { + fieldsToDelete: ['source'] + }; + const actualData = normalizeData(actual, normalizeOption); + return [compareResultsHelper(caseName, actualData, expected), actualData]; } - return compareResultsHelper(name, normalizeData(actual), expected); + if (testName === 'findRenameLocations') { + const normalizeOption: NormalizeOptions = { + fieldsToDelete: ['prefixText', 'suffixText'] + }; + const actualData = normalizeData(actual, normalizeOption); + return [compareResultsHelper(caseName, actualData, expected), actualData]; + } + + const actualData = normalizeData(actual); + return [compareResultsHelper(caseName, actualData, expected), actualData]; } -function runTests(lsp: Lsp): string[] { +function runTests(lsp: Lsp, cases: TestCases, failedList: string[]): string[] { console.log('Running tests...'); - if (!testCases) { + if (!cases) { return []; } - let failedList: string[] = []; - for (const [testName, testConfig] of Object.entries(testCases)) { + for (const [testName, testConfig] of Object.entries(cases)) { const { expectedFilePath, ...testCaseVariants } = testConfig; const expectedResult = getExpectedResult(expectedFilePath); if (expectedResult === null) { @@ -339,12 +384,13 @@ function runTests(lsp: Lsp): string[] { for (const [index, params] of Object.entries(testCaseVariants)) { let pass = false; + let actualData = undefined; let actualResult = null; try { // CC-OFFNXT(no_explicit_any) project code style actualResult = (lsp as any)[testName](...params); actualResult = sortActualResult(testName, actualResult); - pass = compareResults(testName, index, actualResult, expectedResult[index]); + [pass, actualData] = compareResults(`${testName}:${index}`, actualResult, expectedResult[index]); } catch (error) { console.error(`[${testName}:${index}] ❌ Error: ${error}`); } @@ -353,7 +399,7 @@ function runTests(lsp: Lsp): string[] { } if (!pass && updateMode) { console.log(`Updating expected result for ${testName}:${index}`); - expectedResult[index] = normalizeData(actualResult); + expectedResult[index] = actualData; } } if (updateMode) { @@ -367,11 +413,11 @@ function runTests(lsp: Lsp): string[] { function runSingleTests(testDir: string, failedList: string[]): string[] { console.log('Running single tests...'); - if (!testSingleModuleCases) { + if (!singleModuleCases) { return []; } const testSrcPath = path.join(testDir, 'testcases'); - for (const [testName, testConfig] of Object.entries(testSingleModuleCases)) { + for (const [testName, testConfig] of Object.entries(singleModuleCases)) { const testBuildPath = path.join(testSrcPath, '.idea', '.deveco', testName); let pathConfig: PathConfig = { buildSdkPath: path.join(testDir, 'ets', 'ets1.2'), @@ -407,12 +453,18 @@ function runSingleTests(testDir: string, failedList: string[]): string[] { for (const [index, params] of Object.entries(testCaseVariants)) { let pass = false; + let actualData = undefined; let actualResult = null; try { // CC-OFFNXT(no_explicit_any) project code style actualResult = (lsp as any)[testName](...params); actualResult = sortActualResult(testName, actualResult); - pass = compareResults(testName, index, actualResult, expectedResult[index], pathConfig.declgenOutDir); + [pass, actualData] = compareResults( + `${testName}:${index}`, + actualResult, + expectedResult[index], + pathConfig.declgenOutDir + ); } catch (error) { console.error(`[${testName}:${index}] ❌ Error: ${error}`); } @@ -421,7 +473,7 @@ function runSingleTests(testDir: string, failedList: string[]): string[] { } if (!pass && updateMode) { console.log(`Updating expected result for ${testName}:${index}`); - expectedResult[index] = normalizeData(actualResult); + expectedResult[index] = actualData; } } if (updateMode) { @@ -433,8 +485,13 @@ function runSingleTests(testDir: string, failedList: string[]): string[] { return failedList; } -function run(lsp: Lsp, testDir: string): void { - let failedList = runTests(lsp); +function run(testDir: string, pathConfig: PathConfig): void { + let failedList: string[] = []; + + const basicModules = getModules(pathConfig.projectPath, basicCases); + const basicLsp = new Lsp(pathConfig, undefined, basicModules); + failedList = runTests(basicLsp, basicCases, failedList); + failedList = runSingleTests(testDir, failedList); console.log('Tests completed.'); @@ -446,26 +503,27 @@ function run(lsp: Lsp, testDir: string): void { console.error('Tests failed without AST cache'); process.exit(1); - } else { - if (!testCases) { - console.error('Failed to load test cases'); - } - if (!testSingleModuleCases) { - console.error('Failed to load single module test cases'); - } - if (!testCases && !testSingleModuleCases) { - console.error('Tests failed without AST cache'); - process.exit(1); - } } console.log('Finished test without ast cache'); } -async function runWithAstCache(lsp: Lsp, modules: ModuleDescriptor[], testDir: string): Promise { - await lsp.initAstCache(); - lsp.update(modules); - let failedList = runTests(lsp); - failedList = runSingleTests(testDir, failedList); +async function runWithAstCache(testDir: string, pathConfig: PathConfig): Promise { + let failedList: string[] = []; + // for generate ast cache + const entry_module = [ + { + arktsversion: '1.2', + name: 'entry', + moduleType: 'har', + srcPath: path.join(pathConfig.projectPath, 'entry') + } + ]; + + const basicModules = getModules(pathConfig.projectPath, basicCases); + const basicLsp = new Lsp(pathConfig, undefined, entry_module); + await basicLsp.initAstCache(); + basicLsp.update(basicModules); + failedList = runTests(basicLsp, basicCases, failedList); console.log('Tests completed.'); if (failedList.length > 0) { @@ -476,17 +534,6 @@ async function runWithAstCache(lsp: Lsp, modules: ModuleDescriptor[], testDir: s console.error('Tests failed with AST cache'); process.exit(1); - } else { - if (!testCases) { - console.error('Failed to load test cases'); - } - if (!testSingleModuleCases) { - console.error('Failed to load single module test cases'); - } - if (!testCases && !testSingleModuleCases) { - console.error('Tests failed without AST cache'); - process.exit(1); - } } console.log('Finished test with ast cache'); } @@ -500,28 +547,17 @@ if (require.main === module) { if (process.argv[3] && process.argv[3] === '--update') { updateMode = true; } + const testDir = path.resolve(process.argv[2]); - let pathConfig: PathConfig = { + const pathConfig: PathConfig = { buildSdkPath: path.join(testDir, 'ets', 'ets1.2'), projectPath: path.join(testDir, 'testcases'), declgenOutDir: '' }; - const modules = getModules(pathConfig.projectPath); process.env.BINDINGS_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'bindings'); process.env.PANDA_LIB_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'ets2panda', 'lib'); process.env.PANDA_BIN_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'ets2panda', 'bin'); - const lsp = new Lsp(pathConfig, undefined, modules); - run(lsp, testDir); - // for generate ast cache - const entry_module = [ - { - arktsversion: '1.2', - name: 'entry', - moduleType: 'har', - srcPath: path.join(pathConfig.projectPath, 'entry') - } - ]; - const lsp_1 = new Lsp(pathConfig, undefined, entry_module); - runWithAstCache(lsp_1, modules, testDir).then(() => {}); + run(testDir, pathConfig); + runWithAstCache(testDir, pathConfig).then(() => {}); } diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 b/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 index 8ee2596efddc104b26b6ec83ed6fac9ac144acf8..d361cd9947339c0cee25886c42ec923c723f70f8 100644 --- a/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 +++ b/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 @@ -14,11 +14,10 @@ */ { - "modelVersion": "5.0.1", - "description": "Please describe the basic information.", - "dependencies": { - "myDep": "file:../dep" + modelVersion: '5.0.1', + description: 'Please describe the basic information.', + dependencies: { + myDep: 'file:../dep' }, - "devDependencies": { - } + devDependencies: {} } diff --git a/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets b/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ac051ca62dbfb06be443f68172bf3ed900b0101 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 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 { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' +import { + Entry + Text, + TextAttributes, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView +} from '@ohos.arkui.component' +import { State, MutableSate, stateOf, observableProxy } from '@ohos.arkui.stateManagement' +import hilog from '@ohos.hilog' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .onClick(() => { + console.info("hello, :") + console.log(result.toString()) + }) + .width('100%') + } + .height('100%') + } +} + +@Entry +@Component +struct Index { + build() {} +} \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition15.ets b/ets2panda/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition15.ets new file mode 100644 index 0000000000000000000000000000000000000000..d00b745ae4d0f96ac9e707f0ed4c4fed03127067 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition15.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); +stk.p diff --git a/ets2panda/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue5.ets b/ets2panda/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue5.ets new file mode 100644 index 0000000000000000000000000000000000000000..98c76d7275e73210dc679cc43e75c2195a1e1f27 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue5.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); diff --git a/ets2panda/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets b/ets2panda/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets old mode 100644 new mode 100755 diff --git a/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights8.ets b/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights8.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d43a149b8b0b52c12d8ee4d06e19b7eac4f5d63 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights8.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getOffsetByColAndLine/getOffsetByColAndLine1.ets b/ets2panda/bindings/test/testcases/getOffsetByColAndLine/getOffsetByColAndLine1.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d9c5f8afa5efa49d6dba9accca728964f091ba3 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getOffsetByColAndLine/getOffsetByColAndLine1.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 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. + */ + +// comment of line + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' +import { + Entry + Text, + TextAttributes, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView +} from '@ohos.arkui.component' +import { State, MutableSate, stateOf, observableProxy } from '@ohos.arkui.stateManagement' +import hilog from '@ohos.hilog' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .onClick(() => { + console.info("hello, :") + console.log(result.toString()) + }) + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition4.ets b/ets2panda/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition4.ets new file mode 100644 index 0000000000000000000000000000000000000000..98c76d7275e73210dc679cc43e75c2195a1e1f27 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition4.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); diff --git a/ets2panda/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition6.ets b/ets2panda/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition6.ets new file mode 100644 index 0000000000000000000000000000000000000000..98c76d7275e73210dc679cc43e75c2195a1e1f27 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition6.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); diff --git a/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo2.ets b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo2.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab20d0867bc0ad0761ce8eb8dfa34a85a4ad73ed --- /dev/null +++ b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo2.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +let map1 = new Map(); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo3.ets b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo3.ets new file mode 100644 index 0000000000000000000000000000000000000000..98c76d7275e73210dc679cc43e75c2195a1e1f27 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo3.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); diff --git a/ets2panda/bindings/test/testcases/getSemanticDiagnostics/getSemanticDiagnostics3.ets b/ets2panda/bindings/test/testcases/getSemanticDiagnostics/getSemanticDiagnostics3.ets new file mode 100644 index 0000000000000000000000000000000000000000..705da5d5f5037e3b790f07e04d9b78129b7115ef --- /dev/null +++ b/ets2panda/bindings/test/testcases/getSemanticDiagnostics/getSemanticDiagnostics3.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push("123"); diff --git a/ets2panda/bindings/test/testcases/getSignatureHelpItems/getSignatureHelpItems2.ets b/ets2panda/bindings/test/testcases/getSignatureHelpItems/getSignatureHelpItems2.ets new file mode 100644 index 0000000000000000000000000000000000000000..551e7e896be9a72e4fdcc481fc997aec5c2eac84 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getSignatureHelpItems/getSignatureHelpItems2.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); + +let map = new Map(); +map.set("a", 1); +let a = map.get("a"); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics3.ets b/ets2panda/bindings/test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics3.ets new file mode 100644 index 0000000000000000000000000000000000000000..116e75a6113e06b17c637343d390e283cd69ddc5 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics3.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 {default as stack} frrom '@ohos.util.Stack'; \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 index 8ee2596efddc104b26b6ec83ed6fac9ac144acf8..d361cd9947339c0cee25886c42ec923c723f70f8 100644 --- a/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 @@ -14,11 +14,10 @@ */ { - "modelVersion": "5.0.1", - "description": "Please describe the basic information.", - "dependencies": { - "myDep": "file:../dep" + modelVersion: '5.0.1', + description: 'Please describe the basic information.', + dependencies: { + myDep: 'file:../dep' }, - "devDependencies": { - } + devDependencies: {} } diff --git a/ets2panda/bindings/test/testcases/provideInlayHints/provideInlayHints2.ets b/ets2panda/bindings/test/testcases/provideInlayHints/provideInlayHints2.ets new file mode 100644 index 0000000000000000000000000000000000000000..24211305cddf28d55724603478ad565a05d9e8cd --- /dev/null +++ b/ets2panda/bindings/test/testcases/provideInlayHints/provideInlayHints2.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 Stack from '@ohos.util.Stack'; +let stk = new Stack(); +stk.push(1); +stk.push(2); + +let map = new Map(); +map.set("a", 1); +let a = map.get("a"); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/toLineColumnOffset/toLineColumnOffset2.ets b/ets2panda/bindings/test/testcases/toLineColumnOffset/toLineColumnOffset2.ets new file mode 100644 index 0000000000000000000000000000000000000000..98c76d7275e73210dc679cc43e75c2195a1e1f27 --- /dev/null +++ b/ets2panda/bindings/test/testcases/toLineColumnOffset/toLineColumnOffset2.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 {default as stack} from '@ohos.util.Stack'; +let stk = new stack(); +stk.push(1); +stk.push(2); diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 4748735b14712406ac39fcfd00a2bbfc502f3660..2f97ff51179a905ed2f74b611bfefc82ce467d20 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -16,6 +16,7 @@ #include "ETSAnalyzer.h" #include "checker/ETSchecker.h" +#include "compiler/lowering/util.h" #include "generated/diagnostic.h" #include "checker/types/globalTypesHolder.h" #include "checker/types/ets/etsTupleType.h" @@ -23,11 +24,10 @@ #include "evaluate/scopedDebugInfoPlugin.h" #include "types/signature.h" #include "compiler/lowering/ets/setJumpTarget.h" -#include "compiler/lowering/util.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "types/ts/nullType.h" #include "types/type.h" -#include "types/typeFlag.h" +#include "checker/types/typeError.h" #include "util/es2pandaMacros.h" #include @@ -107,7 +107,18 @@ checker::Type *ETSAnalyzer::Check(ir::ClassProperty *st) const ETSChecker *checker = GetETSChecker(); if (st->Id()->Variable() == nullptr) { - st->Id()->Check(checker); + // Now invalid or dummy nodes obtaining after parsing don't have associated variables at all, that leads to + // incorrect AST and multiple reported errors in AST verifier. Need to create and bind [special]? variables for + // them with default TypeError set[?]. Why can't we directly check the 'Id'? During the process of + // resolveIdentifier, we might obtain the wrong variable, which breaks the consistency between the variable and + // its tsType. see wrong_variable_binding.ets for more details. + auto ident = st->Id(); + auto [decl, var] = checker->VarBinder()->NewVarDecl( + ident->Start(), compiler::GenName(checker->ProgramAllocator()).View()); + var->SetScope(checker->VarBinder()->GetScope()); + ident->SetVariable(var); + decl->BindNode(ident); + ident->SetTsType(var->SetTsType(checker->GlobalTypeError())); } ES2PANDA_ASSERT(st->Id()->Variable() != nullptr); @@ -168,15 +179,9 @@ static void HandleNativeAndAsyncMethods(ETSChecker *checker, ir::MethodDefinitio { auto *scriptFunc = node->Function(); ES2PANDA_ASSERT(scriptFunc != nullptr); - if (node->IsNative() && !node->IsConstructor() && !scriptFunc->IsSetter()) { - if (scriptFunc->ReturnTypeAnnotation() == nullptr) { - checker->LogError(diagnostic::NATIVE_WITHOUT_RETURN, {}, scriptFunc->Start()); - node->SetTsType(checker->GlobalTypeError()); - } - } if (util::Helpers::IsAsyncMethod(node)) { - if (scriptFunc->ReturnTypeAnnotation() != nullptr) { + if (scriptFunc->ReturnTypeAnnotation() != nullptr && scriptFunc->Signature() != nullptr) { auto *asyncFuncReturnType = scriptFunc->Signature()->ReturnType(); if (!asyncFuncReturnType->IsETSObjectType() || @@ -222,10 +227,6 @@ checker::Type *ETSAnalyzer::Check(ir::MethodDefinition *node) const return node->TsType(); }; - if (scriptFunc == nullptr) { - checker->LogError(diagnostic::FUNC_EXPR_INVALID, {}, node->Start()); - return returnErrorType(); - } checker->CheckAnnotations(scriptFunc->Annotations()); checker->CheckFunctionSignatureAnnotations(scriptFunc->Params(), scriptFunc->TypeParams(), scriptFunc->ReturnTypeAnnotation()); @@ -283,12 +284,6 @@ void ETSAnalyzer::CheckMethodModifiers(ir::MethodDefinition *node) const return; } - if (node->Function() == nullptr) { - checker->LogError(diagnostic::FUNC_EXPR_INVALID, {}, node->Start()); - node->SetTsType(checker->GlobalTypeError()); - return; - } - if ((node->IsAbstract() || (!node->Function()->HasBody() && !node->IsNative() && !node->IsDeclare())) && !(checker->HasStatus(checker::CheckerStatus::IN_ABSTRACT) || checker->HasStatus(checker::CheckerStatus::IN_INTERFACE))) { @@ -343,6 +338,32 @@ static void CheckDuplicationInOverloadDeclaration(ETSChecker *const checker, ir: } } +static void CheckOverloadSameNameMethod(ETSChecker *const checker, ir::OverloadDeclaration *const overloadDecl) +{ + Type *objectType = overloadDecl->Parent()->IsClassDefinition() + ? overloadDecl->Parent()->AsClassDefinition()->Check(checker) + : overloadDecl->Parent()->Parent()->AsTSInterfaceDeclaration()->Check(checker); + ES2PANDA_ASSERT(objectType->IsETSObjectType()); + + PropertySearchFlags searchFlags = PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION | + (overloadDecl->IsStatic() ? PropertySearchFlags::SEARCH_STATIC_METHOD + : PropertySearchFlags::SEARCH_INSTANCE_METHOD); + auto *sameNameMethod = objectType->AsETSObjectType()->GetProperty(overloadDecl->Id()->Name(), searchFlags); + if (sameNameMethod == nullptr) { + return; + } + + auto serachName = overloadDecl->Id()->Name().Mutf8(); + auto hasSameNameMethod = + std::find_if(overloadDecl->OverloadedList().begin(), overloadDecl->OverloadedList().end(), + [serachName](ir::Expression *overloadId) { + return overloadId->IsIdentifier() && overloadId->AsIdentifier()->Name().Is(serachName); + }); + if (hasSameNameMethod == overloadDecl->OverloadedList().end()) { + checker->LogError(diagnostic::OVERLOAD_SAME_NAME_METHOD, {serachName}, overloadDecl->Start()); + } +} + checker::Type *ETSAnalyzer::Check(ir::OverloadDeclaration *node) const { ETSChecker *checker = GetETSChecker(); @@ -350,38 +371,25 @@ checker::Type *ETSAnalyzer::Check(ir::OverloadDeclaration *node) const ES2PANDA_ASSERT(node->Key()); CheckDuplicationInOverloadDeclaration(checker, node); - - if (!node->Key()->IsIdentifier()) { - checker->LogError(diagnostic::OVERLOAD_NAME_MUST_BE_IDENTIFIER, {}, node->Key()->Start()); - } + CheckOverloadSameNameMethod(checker, node); if (node->IsConstructorOverloadDeclaration()) { ES2PANDA_ASSERT(node->Parent()->IsClassDefinition()); checker->CheckConstructorOverloadDeclaration(checker, node); - return nullptr; - } - - if (node->IsFunctionOverloadDeclaration()) { + } else if (node->IsFunctionOverloadDeclaration()) { ES2PANDA_ASSERT( node->Parent()->IsClassDefinition() && (compiler::HasGlobalClassParent(node) || node->Parent()->AsClassDefinition()->IsNamespaceTransformed())); checker->CheckFunctionOverloadDeclaration(checker, node); - return nullptr; - } - - if (node->IsClassMethodOverloadDeclaration()) { + } else if (node->IsClassMethodOverloadDeclaration()) { ES2PANDA_ASSERT(node->Parent()->IsClassDefinition()); checker->CheckClassMethodOverloadDeclaration(checker, node); - return nullptr; - } - - if (node->IsInterfaceMethodOverloadDeclaration()) { + } else if (node->IsInterfaceMethodOverloadDeclaration()) { ES2PANDA_ASSERT(node->Parent()->Parent()->IsTSInterfaceDeclaration()); checker->CheckInterfaceMethodOverloadDeclaration(checker, node); - return nullptr; } - return nullptr; + return checker->CreateSyntheticTypeFromOverload(node->Id()->Variable()); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::Property *expr) const @@ -400,7 +408,7 @@ checker::Type *ETSAnalyzer::Check(ir::SpreadElement *expr) const if (expr->PreferredType() != nullptr) { expr->Argument()->SetPreferredType(expr->PreferredType()); } - auto type = expr->AsSpreadElement()->Argument()->Check(checker); + auto type = expr->Argument()->Check(checker); Type *exprType = type->MaybeBaseTypeOfGradualType(); if (exprType->IsETSResizableArrayType()) { @@ -462,6 +470,10 @@ checker::Type *ETSAnalyzer::Check(ir::ETSFunctionType *node) const checker->CheckFunctionSignatureAnnotations(node->Params(), node->TypeParams(), node->ReturnType()); auto *signatureInfo = checker->ComposeSignatureInfo(node->TypeParams(), node->Params()); + if (signatureInfo == nullptr) { + ES2PANDA_ASSERT(GetChecker()->IsAnyError()); + return node->SetTsType(checker->GlobalTypeError()); + } auto *returnType = node->IsExtensionFunction() && node->ReturnType()->IsTSThisType() ? signatureInfo->params.front()->TsType() : checker->ComposeReturnType(node->ReturnType(), node->IsAsync()); @@ -556,9 +568,8 @@ static checker::Type *CheckInstantiatedNewType(ETSChecker *checker, ir::ETSNewCl { checker::Type *res = expr->GetTypeRef()->Check(checker); auto calleeType = res->MaybeBaseTypeOfGradualType(); - if (calleeType->IsTypeError()) { - return checker->InvalidateType(expr->GetTypeRef()); - } + FORWARD_TYPE_ERROR(checker, calleeType, expr->GetTypeRef()); + if (calleeType->IsETSUnionType()) { return checker->TypeError(expr->GetTypeRef(), diagnostic::UNION_NONCONSTRUCTIBLE, expr->Start()); } @@ -594,11 +605,11 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const if (expr->TsType() != nullptr) { return expr->TsType(); } + ETSChecker *checker = GetETSChecker(); auto *calleeType = CheckInstantiatedNewType(checker, expr); - if (calleeType->IsTypeError()) { - return checker->InvalidateType(expr); - } + FORWARD_TYPE_ERROR(checker, calleeType, expr); + auto *calleeObj = calleeType->MaybeBaseTypeOfGradualType()->AsETSObjectType(); expr->SetTsType(calleeType); @@ -706,12 +717,7 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNonNullishTypeNode *node) const return node->TsType(); } ETSChecker *checker = GetETSChecker(); - auto type = node->GetTypeNode()->Check(checker); - checker::Type *originalType = type->MaybeBaseTypeOfGradualType(); - if (!originalType->IsETSTypeParameter()) { - checker->LogError(diagnostic::ILLEGAL_NON_NULLISH_TYPE, {}, node->GetTypeNode()->Start()); - } - return node->SetTsType(checker->GetNonNullishType(type)); + return node->SetTsType(checker->GetNonNullishType(node->GetTypeNode()->Check(checker))); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSNullType *node) const @@ -967,9 +973,12 @@ checker::Type *ETSAnalyzer::Check(ir::ArrayExpression *expr) const return expr->TsType(); } - auto *preferredType = GetAppropriatePreferredType(expr->PreferredType(), [](Type *tp) -> bool { - return tp->IsETSArrayType() || tp->IsETSResizableArrayType() || tp->IsETSTupleType(); - }); + auto *preferredType = GetAppropriatePreferredType(expr->PreferredType(), &Type::IsAnyETSArrayOrTupleType); + + if (preferredType != nullptr && preferredType->IsETSReadonlyArrayType()) { + const auto elementType = preferredType->AsETSObjectType()->TypeArguments().front(); + preferredType = checker->CreateETSResizableArrayType(elementType); + } if (!IsArrayExpressionValidInitializerForType(checker, preferredType)) { checker->LogError(diagnostic::UNEXPECTED_ARRAY, {expr->PreferredType()}, expr->Start()); @@ -982,17 +991,17 @@ checker::Type *ETSAnalyzer::Check(ir::ArrayExpression *expr) const } expr->SetPreferredType(preferredType); - - if (!ValidArrayExprSizeForTupleSize(checker, preferredType, expr) || - !CheckArrayExpressionElements(checker, expr)) { - return checker->InvalidateType(expr); - } } if (preferredType == nullptr) { return checker->TypeError(expr, diagnostic::UNRESOLVABLE_ARRAY, expr->Start()); } + if (!ValidArrayExprSizeForTupleSize(checker, preferredType, expr) || + (!expr->Elements().empty() && !CheckArrayExpressionElements(checker, expr))) { + return checker->InvalidateType(expr); + } + expr->SetTsType(preferredType); if (!preferredType->IsETSResizableArrayType() && !preferredType->IsETSTupleType()) { ES2PANDA_ASSERT(preferredType->IsETSArrayType()); @@ -1218,7 +1227,7 @@ checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const } if (expr->target_ != nullptr && !expr->IsIgnoreConstAssign()) { - checker->ValidateUnaryOperatorOperand(expr->target_); + checker->ValidateUnaryOperatorOperand(expr->target_, expr); } auto [rightType, relationNode] = CheckAssignmentExprOperatorType(expr, leftType); @@ -1648,6 +1657,25 @@ checker::Type *ETSAnalyzer::GetCallExpressionReturnType(ir::CallExpression *expr // NOTE(vpukhov): #14902 substituted signature is not updated } +static void CheckOverloadCall(ETSChecker *checker, ir::CallExpression *expr) +{ + if (!expr->Callee()->IsMemberExpression() || !OverloadDeclaration(expr->Callee())) { + return; + } + + auto *sig = expr->Signature(); + auto *functionNode = sig->OwnerVar()->Declaration()->Node(); + ir::AstNode *parent = functionNode->Parent(); + + bool isExported = functionNode->IsExported() || functionNode->IsDefaultExported(); + if (parent != nullptr && parent->IsClassDefinition() && parent->AsClassDefinition()->IsNamespaceTransformed() && + !parent->AsClassDefinition()->IsDeclare() && !isExported) { + checker->LogError(diagnostic::NOT_EXPORTED, + {sig->OwnerVar()->Declaration()->Name(), parent->AsClassDefinition()->Ident()->Name()}, + expr->Start()); + } +} + checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const { ETSChecker *checker = GetETSChecker(); @@ -1671,16 +1699,14 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const CheckCallee(checker, expr); checker::TypeStackElement tse(checker, expr, {{diagnostic::CYCLIC_CALLEE, {}}}, expr->Start()); - if (tse.HasTypeError()) { - expr->SetTsType(checker->GlobalTypeError()); - return checker->GlobalTypeError(); - } + ERROR_SANITY_CHECK(checker, !tse.HasTypeError(), return expr->SetTsType(checker->GlobalTypeError())); checker::Type *const returnType = GetCallExpressionReturnType(expr, calleeType); expr->SetTsType(returnType); if (returnType->IsTypeError()) { return returnType; } + if (calleeType->IsETSArrowType()) { expr->SetUncheckedType(checker->GuaranteedTypeForUncheckedCast( checker->GlobalETSAnyType(), checker->MaybeBoxType(expr->Signature()->ReturnType()))); @@ -1693,11 +1719,7 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const checker->ComputeApparentType(returnType); } - if (returnType->IsTypeError()) { - expr->SetTsType(returnType); - return expr->TsType(); - } - + CheckOverloadCall(checker, expr); CheckVoidTypeExpression(checker, expr); CheckAbstractCall(checker, expr); return expr->TsType(); @@ -1795,9 +1817,10 @@ checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression *const use, Type *type) { ES2PANDA_ASSERT(use->IsIdentifier() || use->IsMemberExpression()); - if (!type->IsETSMethodType() || - (use->IsMemberExpression() && use->AsMemberExpression()->PropVar() != nullptr && - use->AsMemberExpression()->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC))) { + if (!type->IsETSMethodType()) { + if (use->Parent()->IsCallExpression() && type->IsETSObjectType() && use->IsMemberExpression()) { + checker->ValidateCallExpressionIdentifier(use->AsMemberExpression()->Property()->AsIdentifier(), type); + } return type; } auto const getUseSite = [use]() { @@ -1863,6 +1886,7 @@ checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const } expr->SetTsType(identType); + ES2PANDA_ASSERT(identType != nullptr); if (!identType->IsTypeError()) { checker->Context().CheckIdentifierSmartCastCondition(expr); } @@ -1977,6 +2001,7 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const auto *baseType = checker->GetNonConstantType(checker->GetApparentType(expr->Object()->Check(checker))); // Note: don't use possible smart cast to null-like types. // Such situation should be correctly resolved in the subsequent lowering. + ES2PANDA_ASSERT(baseType != nullptr); if (baseType->DefinitelyETSNullish() && expr->Object()->IsIdentifier()) { baseType = expr->Object()->AsIdentifier()->Variable()->TsType(); } @@ -1988,7 +2013,7 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const expr->Property()->AsIdentifier()->Name(), checker); reExportType.first != nullptr) { baseType = reExportType.first; - expr->object_->AsIdentifier()->SetTsType(baseType); + expr->object_->SetTsType(baseType); expr->property_->AsIdentifier()->SetName(reExportType.second); } } @@ -2351,12 +2376,6 @@ checker::ETSObjectType *ResolveUnionObjectTypeForObjectLiteral(ETSChecker *check } } - if (candidateObjectTypes.empty()) { - // No ETSObjectTypes in the union at all - checker->LogError(diagnostic::CLASS_COMPOSITE_INVALID_TARGET, {expr->PreferredType()}, expr->Start()); - return nullptr; - } - std::vector matchingObjectTypes; // Phase 2: Filter candidates using the helper function for (auto *potentialObjType : candidateObjectTypes) { @@ -2678,6 +2697,7 @@ static checker::Type *ComputeTypeOfType(ETSChecker *checker, checker::Type *argT { checker::Type *ret = nullptr; ArenaVector types(checker->ProgramAllocator()->Adapter()); + ES2PANDA_ASSERT(argType != nullptr); if (argType->IsETSUnionType()) { for (auto *it : argType->AsETSUnionType()->ConstituentTypes()) { checker::Type *elType = ComputeTypeOfType(checker, it); @@ -2719,6 +2739,7 @@ checker::Type *ETSAnalyzer::Check(ir::UnaryExpression *expr) const checker::Type *type = checker->CreateETSBigIntLiteralType(argType->AsETSBigIntType()->GetValue()); // We do not need this const anymore as we are negating the bigint object in runtime + ES2PANDA_ASSERT(type != nullptr); type->RemoveTypeFlag(checker::TypeFlag::CONSTANT); expr->argument_->SetTsType(type); expr->SetTsType(type); @@ -2759,25 +2780,23 @@ checker::Type *ETSAnalyzer::Check(ir::UpdateExpression *expr) const } checker::Type *operandType = expr->argument_->Check(checker); - if (operandType->IsTypeError()) { - return checker->InvalidateType(expr); - } + FORWARD_TYPE_ERROR(checker, operandType, expr); if (expr->Argument()->IsIdentifier()) { - checker->ValidateUnaryOperatorOperand(expr->Argument()->AsIdentifier()->Variable()); + checker->ValidateUnaryOperatorOperand(expr->Argument()->AsIdentifier()->Variable(), expr); } else if (expr->Argument()->IsTSAsExpression()) { if (auto *const asExprVar = expr->Argument()->AsTSAsExpression()->Variable(); asExprVar != nullptr) { - checker->ValidateUnaryOperatorOperand(asExprVar); + checker->ValidateUnaryOperatorOperand(asExprVar, expr); } } else if (expr->Argument()->IsTSNonNullExpression()) { if (auto *const nonNullExprVar = expr->Argument()->AsTSNonNullExpression()->Variable(); nonNullExprVar != nullptr) { - checker->ValidateUnaryOperatorOperand(nonNullExprVar); + checker->ValidateUnaryOperatorOperand(nonNullExprVar, expr); } } else if (expr->Argument()->IsMemberExpression()) { varbinder::LocalVariable *propVar = expr->argument_->AsMemberExpression()->PropVar(); if (propVar != nullptr) { - checker->ValidateUnaryOperatorOperand(propVar); + checker->ValidateUnaryOperatorOperand(propVar, expr); } } else { ES2PANDA_ASSERT(checker->IsAnyError()); @@ -2860,6 +2879,14 @@ static bool CheckIfLiteralValueIsAppropriate(ETSChecker *checker, Type *type, ir return !number.IsReal() && val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); } else if (number.IsDouble()) { + if (relation->IsIdenticalTo(type, checker->GlobalFloatBuiltinType())) { + auto doubleVal = number.GetDouble(); + if (doubleVal < std::numeric_limits::min() || doubleVal > std::numeric_limits::max()) { + return false; + } + auto floatVal = static_cast(doubleVal); + return static_cast(floatVal) == doubleVal; + } return relation->IsIdenticalTo(checker->GlobalDoubleBuiltinType(), type); } return true; @@ -2961,7 +2988,7 @@ checker::Type *ETSAnalyzer::Check(ir::ImportNamespaceSpecifier *st) const } if (importDecl->IsPureDynamic()) { - auto *type = checker->GlobalBuiltinDynamicType(importDecl->Language()); + auto *type = checker->GetImportSpecifierObjectType(importDecl, st->Local()->AsIdentifier())->AsETSObjectType(); checker->SetrModuleObjectTsType(st->Local(), type); return type; } @@ -3071,9 +3098,12 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationDeclaration *st) const } } - auto *annoDecl = st->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); - if (annoDecl != st && annoDecl->IsDeclare()) { - checker->CheckAmbientAnnotation(st, annoDecl); + auto baseName = st->GetBaseName(); + if (!baseName->IsErrorPlaceHolder() && baseName->Variable()->Declaration()->Node()->IsAnnotationDeclaration()) { + auto *annoDecl = baseName->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); + if (annoDecl != st && annoDecl->IsDeclare()) { + checker->CheckAmbientAnnotation(st, annoDecl); + } } return ReturnTypeForStatement(st); @@ -3102,18 +3132,23 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const ETSChecker *checker = GetETSChecker(); st->Expr()->Check(checker); - if (st->GetBaseName()->Variable() == nullptr || - !st->GetBaseName()->Variable()->Declaration()->Node()->IsAnnotationDeclaration()) { - checker->LogError(diagnostic::NOT_AN_ANNOTATION, {st->GetBaseName()->Name()}, st->GetBaseName()->Start()); + auto *baseName = st->GetBaseName(); + if (baseName->Variable() == nullptr || !baseName->Variable()->Declaration()->Node()->IsAnnotationDeclaration()) { + if (!baseName->IsErrorPlaceHolder()) { + checker->LogError(diagnostic::NOT_AN_ANNOTATION, {baseName->Name()}, baseName->Start()); + } + + ES2PANDA_ASSERT(checker->IsAnyError()); return ReturnTypeForStatement(st); } - auto *annoDecl = st->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); + auto *annoDecl = baseName->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); annoDecl->Check(checker); ArenaUnorderedMap fieldMap {checker->ProgramAllocator()->Adapter()}; for (auto *it : annoDecl->Properties()) { auto *field = it->AsClassProperty(); + ES2PANDA_ASSERT(field->Id() != nullptr); fieldMap.insert(std::make_pair(field->Id()->Name(), field)); } @@ -3127,7 +3162,7 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const checker->CheckSinglePropertyAnnotation(st, annoDecl); fieldMap.clear(); } else { - checker->CheckMultiplePropertiesAnnotation(st, st->GetBaseName()->Name(), fieldMap); + checker->CheckMultiplePropertiesAnnotation(st, baseName->Name(), fieldMap); } ProcessRequiredFields(fieldMap, st, checker); @@ -3219,11 +3254,6 @@ checker::Type *ETSAnalyzer::Check(ir::ForOfStatement *const st) const auto [smartCasts, clearFlag] = checker->Context().EnterLoop(*st, std::nullopt); checker::Type *const exprType = st->Right()->Check(checker)->MaybeBaseTypeOfGradualType(); - if (exprType == nullptr) { - checker->LogError(diagnostic::FOROF_CANT_INFER_SOURCE, {}, st->Right()->Start()); - return checker->GlobalTypeError(); - } - checker::Type *elemType = checker->GlobalTypeError(); if (exprType->IsETSStringType()) { @@ -3701,16 +3731,12 @@ checker::Type *ETSAnalyzer::Check(ir::TSAsExpression *expr) const checker->CheckAnnotations(expr->TypeAnnotation()->Annotations()); auto *const targetType = expr->TypeAnnotation()->AsTypeNode()->GetType(checker); - if (targetType->IsTypeError()) { - return checker->InvalidateType(expr); - } + FORWARD_TYPE_ERROR(checker, targetType, expr); expr->Expr()->SetPreferredType(targetType); auto const sourceType = expr->Expr()->Check(checker); - if (sourceType->IsTypeError()) { - return checker->InvalidateType(expr); - } + FORWARD_TYPE_ERROR(checker, sourceType, expr); if (sourceType->DefinitelyETSNullish() && !targetType->PossiblyETSNullish()) { return expr->SetTsType(checker->TypeError(expr, diagnostic::NULLISH_CAST_TO_NONNULLISH, expr->Start())); @@ -3756,9 +3782,7 @@ checker::Type *ETSAnalyzer::Check(ir::TSInterfaceDeclaration *st) const auto *stmtType = checker->BuildBasicInterfaceProperties(st); ES2PANDA_ASSERT(stmtType != nullptr); - if (stmtType->IsTypeError()) { - return st->SetTsType(stmtType); - } + FORWARD_TYPE_ERROR(checker, stmtType, st); auto *interfaceType = stmtType->IsGradualType() ? stmtType->AsGradualType()->GetBaseType()->AsETSObjectType() : stmtType->AsETSObjectType(); diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index 295eaa49b553b6c13d76c64661dd37e793643b17..fbba8ecfda8ff65845fcc3a0696bf65dbe9a74d7 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -15,6 +15,7 @@ #include "ETSAnalyzerHelpers.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "checker/types/typeError.h" namespace ark::es2panda::checker { @@ -51,10 +52,13 @@ void CheckExtensionIsShadowedInCurrentClassOrInterface(checker::ETSChecker *chec // check if there are class and interfaces' instance methods with the same name as extensions. auto *const methodVariable = objType->GetOwnProperty(methodName); - if (methodVariable == nullptr) { + if (methodVariable == nullptr || methodVariable->TsType()->IsTypeError()) { return; } + if (methodVariable->TsType()->IsTypeError()) { + return; + } const auto *const funcType = methodVariable->TsType()->AsETSFunctionType(); for (auto *funcSignature : funcType->CallSignatures()) { ES2PANDA_ASSERT(signature != nullptr); @@ -308,15 +312,11 @@ static bool HasIteratorInterface(ETSObjectType const *const objectType) } void CheckIteratorMethodReturnType(ETSChecker *checker, ir::ScriptFunction *scriptFunc, - const lexer::SourcePosition &position, const std::string &methodName) + const lexer::SourcePosition &position, + [[maybe_unused]] const std::string &methodName) { const auto *returnType = scriptFunc->Signature()->ReturnType()->MaybeBaseTypeOfGradualType(); - if (returnType == nullptr) { - checker->LogError(diagnostic::MISSING_RETURN_TYPE_2, {util::StringView(methodName)}, position); - return; - } - if (returnType->IsETSTypeParameter()) { returnType = checker->GetApparentType(returnType->AsETSTypeParameter()->GetConstraintType()); } @@ -372,12 +372,6 @@ checker::Signature *ResolveCallExtensionFunction(checker::Type *functionType, ch expr->Arguments().erase(expr->Arguments().begin()); return nullptr; } - if (!signature->HasSignatureFlag(SignatureFlags::EXTENSION_FUNCTION)) { - checker->LogError(diagnostic::PROPERTY_NONEXISTENT, - {memberExpr->Property()->AsIdentifier()->Name(), memberExpr->ObjType()->Name()}, - memberExpr->Property()->Start()); - return nullptr; - } SwitchMethodCallToFunctionCall(checker, expr, signature); return signature; @@ -514,10 +508,7 @@ ArenaVector GetUnionTypeSignatures(ETSChecker *checker, ch void ProcessExclamationMark(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType) { - if (operandType == nullptr || operandType->IsTypeError()) { - expr->SetTsType(checker->GlobalTypeError()); - return; - } + FORWARD_VALUE_ON_TYPE_ERROR(checker, operandType, expr, EMPTY_VALUE); expr->SetTsType(checker->GlobalETSBooleanBuiltinType()); } @@ -622,14 +613,6 @@ bool CheckReturnType(ETSChecker *checker, checker::Type *funcReturnType, checker checker->LogError(diagnostic::UNEXPECTED_VALUE_RETURN, {}, stArgument->Start()); return false; } - if (!checker::AssignmentContext(checker->Relation(), stArgument, argumentType, funcReturnType, - stArgument->Start(), std::nullopt, - checker::TypeRelationFlag::DIRECT_RETURN | checker::TypeRelationFlag::NO_THROW) - // CC-OFFNXT(G.FMT.02) project code style - .IsAssignable()) { - checker->LogError(diagnostic::RETURN_TYPE_MISMATCH, {}, stArgument->Start()); - return false; - } return true; } @@ -673,22 +656,6 @@ checker::Type *InferReturnType(ETSChecker *checker, ir::ScriptFunction *containi return () => {} ``` */ - if (stArgument != nullptr && stArgument->IsArrowFunctionExpression()) { - auto arrowFunc = stArgument->AsArrowFunctionExpression(); - auto typeAnnotation = arrowFunc->CreateTypeAnnotation(checker); - - auto *argumentType = arrowFunc->TsType(); - ES2PANDA_ASSERT(typeAnnotation != nullptr); - funcReturnType = typeAnnotation->GetType(checker); - if (!checker::AssignmentContext(checker->Relation(), arrowFunc, argumentType, funcReturnType, - stArgument->Start(), std::nullopt, - checker::TypeRelationFlag::DIRECT_RETURN | checker::TypeRelationFlag::NO_THROW) - // CC-OFFNXT(G.FMT.02) project code style - .IsAssignable()) { - checker->LogError(diagnostic::ARROW_TYPE_MISMATCH, {argumentType, funcReturnType}, stArgument->Start()); - return checker->GlobalTypeError(); - } - } containingFunc->Signature()->SetReturnType(funcReturnType); containingFunc->Signature()->RemoveSignatureFlag(checker::SignatureFlags::NEED_RETURN_TYPE); @@ -705,9 +672,7 @@ checker::Type *InferReturnType(ETSChecker *checker, ir::ScriptFunction *containi bool IsArrayExpressionValidInitializerForType(ETSChecker *checker, const Type *const arrayExprPreferredType) { const auto validForTarget = arrayExprPreferredType == nullptr // preferred type will be inferred from elements - || arrayExprPreferredType->IsETSArrayType() // valid for fixed array type - || arrayExprPreferredType->IsETSResizableArrayType() // valid for resizable array type - || arrayExprPreferredType->IsETSTupleType() // valid for tuple type + || arrayExprPreferredType->IsAnyETSArrayOrTupleType() // valid for array or tuple types || checker->Relation()->IsSupertypeOf(arrayExprPreferredType, // valid for 'Object' checker->GlobalETSObjectType()); @@ -801,8 +766,13 @@ void CheckAllConstPropertyInitialized(checker::ETSChecker *checker, ir::ETSModul continue; } - if (prop->AsClassProperty()->Key()->Variable()->HasFlag(varbinder::VariableFlags::INIT_IN_STATIC_BLOCK) && - !prop->AsClassProperty()->Key()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { + auto *classProp = prop->AsClassProperty(); + if (classProp->Key()->Variable() == nullptr) { + continue; + } + + if (classProp->Key()->Variable()->HasFlag(varbinder::VariableFlags::INIT_IN_STATIC_BLOCK) && + !classProp->Key()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { checker->LogError(diagnostic::MISSING_INIT_FOR_CONST_PACKAGE_PROP, {}, prop->Start()); } } diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index d63dcd1f115ce06087e78d98a04ea7097d03f476..3cde016475c0dc517a15fc6c6871511390634a11 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -258,7 +258,7 @@ static void IntializeFunctionInterfaces(GlobalTypesHolder *typeHolder) return typeHolder->GlobalFunctionBuiltinType(arity, hasRest)->AsETSObjectType(); }; - for (size_t arity = 0; arity < typeHolder->VariadicFunctionTypeThreshold(); arity++) { + for (size_t arity = 0; arity <= typeHolder->VariadicFunctionTypeThreshold(); arity++) { getItf(arity, false)->AddObjectFlag(ETSObjectFlags::FUNCTIONAL); getItf(arity, true)->AddObjectFlag(ETSObjectFlags::FUNCTIONAL); } @@ -433,6 +433,7 @@ bool ETSChecker::IsClassStaticMethod(checker::ETSObjectType *objType, checker::S TypeFlag::ETS_STRING_ENUM | TypeFlag::READONLY | TypeFlag::BIGINT_LITERAL | TypeFlag::ETS_TYPE_ALIAS | TypeFlag::TYPE_ERROR; + CHECK_NOT_NULL(type); auto res = static_cast(type->TypeFlags() & ~(TO_CLEAR)); ES2PANDA_ASSERT_POS(res == TypeFlag::NONE || helpers::math::IsPowerOfTwo(res & ~(TypeFlag::NONE)), ark::es2panda::GetPositionForDiagnostic()); @@ -677,29 +678,34 @@ ETSObjectType *ETSChecker::GlobalBuiltinDynamicType(Language lang) const ETSObjectType *ETSChecker::GlobalBuiltinBoxType(Type *contents) { - switch (TypeKind(contents)) { - case TypeFlag::ETS_BOOLEAN: + ES2PANDA_ASSERT(contents->IsETSReferenceType()); + if (!contents->IsETSUnboxableObject()) { + auto *base = AsETSObjectType(&GlobalTypesHolder::GlobalBoxBuiltinType); + auto substitution = Substitution {}; + ES2PANDA_ASSERT(base != nullptr); + substitution.emplace(base->TypeArguments()[0]->AsETSTypeParameter(), contents); + return base->Substitute(Relation(), &substitution); + } + + switch (contents->AsETSObjectType()->UnboxableKind()) { + case ETSObjectFlags::BUILTIN_BOOLEAN: return AsETSObjectType(&GlobalTypesHolder::GlobalBooleanBoxBuiltinType); - case TypeFlag::BYTE: + case ETSObjectFlags::BUILTIN_BYTE: return AsETSObjectType(&GlobalTypesHolder::GlobalByteBoxBuiltinType); - case TypeFlag::CHAR: - return AsETSObjectType(&GlobalTypesHolder::GlobalCharBoxBuiltinType); - case TypeFlag::SHORT: + case ETSObjectFlags::BUILTIN_SHORT: return AsETSObjectType(&GlobalTypesHolder::GlobalShortBoxBuiltinType); - case TypeFlag::INT: + case ETSObjectFlags::BUILTIN_CHAR: + return AsETSObjectType(&GlobalTypesHolder::GlobalCharBoxBuiltinType); + case ETSObjectFlags::BUILTIN_INT: return AsETSObjectType(&GlobalTypesHolder::GlobalIntBoxBuiltinType); - case TypeFlag::LONG: + case ETSObjectFlags::BUILTIN_LONG: return AsETSObjectType(&GlobalTypesHolder::GlobalLongBoxBuiltinType); - case TypeFlag::FLOAT: + case ETSObjectFlags::BUILTIN_FLOAT: return AsETSObjectType(&GlobalTypesHolder::GlobalFloatBoxBuiltinType); - case TypeFlag::DOUBLE: + case ETSObjectFlags::BUILTIN_DOUBLE: return AsETSObjectType(&GlobalTypesHolder::GlobalDoubleBoxBuiltinType); default: { - auto *base = AsETSObjectType(&GlobalTypesHolder::GlobalBoxBuiltinType); - auto substitution = Substitution {}; - ES2PANDA_ASSERT(base != nullptr); - substitution.emplace(base->TypeArguments()[0]->AsETSTypeParameter(), contents); - return base->Substitute(Relation(), &substitution); + ES2PANDA_UNREACHABLE(); } } } @@ -767,7 +773,7 @@ void ETSChecker::HandleUpdatedCallExpressionNode(ir::CallExpression *callExpr) VarBinder()->AsETSBinder()->HandleCustomNodes(callExpr); } -Type *ETSChecker::SelectGlobalIntegerTypeForNumeric(Type *type) const noexcept +Type *ETSChecker::SelectGlobalIntegerTypeForNumeric(Type *type) const { if (type->IsETSObjectType()) { auto const *objectType = type->AsETSObjectType(); @@ -809,4 +815,13 @@ bool ETSChecker::TypeHasDefaultValue(Type *tp) const Relation()->IsSupertypeOf(GlobalETSUndefinedType(), tp); } +/* Invoke method name in functional interfaces */ +std::string ETSChecker::FunctionalInterfaceInvokeName(size_t arity, bool hasRest) +{ + if (arity < GlobalBuiltinFunctionTypeVariadicThreshold()) { + return (hasRest ? "invokeR" : "invoke") + std::to_string(arity); + } + return "unsafeCall"; +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 40549ea10234e95a65448bd2e1935cb0d0022004..076eba0be40b98db38df1ff464f2be2b5003adb9 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -273,6 +273,7 @@ public: void CreateFunctionTypesFromAbstracts(const std::vector &abstracts, ArenaVector *target); void CheckCyclicConstructorCall(Signature *signature); + void CheckAnnotationReference(const ir::MemberExpression *memberExpr, const varbinder::LocalVariable *prop); std::vector ResolveMemberReference(const ir::MemberExpression *memberExpr, const ETSObjectType *target); varbinder::LocalVariable *ResolveOverloadReference(const ir::Identifier *ident, ETSObjectType *objType, @@ -446,6 +447,9 @@ public: Type *argumentType, Substitution *substitution); [[nodiscard]] bool EnhanceSubstitutionForReadonly(const ArenaVector &typeParams, ETSReadonlyType *paramType, Type *argumentType, Substitution *substitution); + [[nodiscard]] bool EnhanceSubstitutionForPartialTypeParam(const ArenaVector &typeParams, + ETSPartialTypeParameter *paramType, Type *argumentType, + Substitution *substitution); [[nodiscard]] bool EnhanceSubstitutionForObject(const ArenaVector &typeParams, ETSObjectType *paramType, Type *argumentType, Substitution *substitution); [[nodiscard]] bool EnhanceSubstitutionForFunction(const ArenaVector &typeParams, ETSFunctionType *paramType, @@ -586,9 +590,9 @@ public: void ReplaceScope(ir::AstNode *root, ir::AstNode *oldNode, varbinder::Scope *newScope); // Helpers + std::string FunctionalInterfaceInvokeName(size_t arity, bool hasRest); static std::string GetAsyncImplName(const util::StringView &name); static std::string GetAsyncImplName(ir::MethodDefinition *asyncMethod); - static bool IsAsyncImplMethod(ir::MethodDefinition const *method); std::vector GetNameForSynteticObjectType(const util::StringView &source); template void BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleObjType, ir::ETSImportDeclaration *importDecl, @@ -616,11 +620,11 @@ public: const ir::TSTypeParameterInstantiation *typeParams, size_t idx); Type *GetTypeFromTypeParameterReference(varbinder::LocalVariable *var, const lexer::SourcePosition &pos); Type *GetNonConstantType(Type *type); - checker::Type *GetElementTypeOfArray(checker::Type *type); + checker::Type *GetElementTypeOfArray(checker::Type *type) const; const checker::Type *GetElementTypeOfArray(const checker::Type *type) const; bool IsNullLikeOrVoidExpression(const ir::Expression *expr) const; bool IsConstantExpression(ir::Expression *expr, Type *type); - void ValidateUnaryOperatorOperand(varbinder::Variable *variable); + void ValidateUnaryOperatorOperand(varbinder::Variable *variable, ir::Expression *expr); void CheckFunctionSignatureAnnotations(const ArenaVector ¶ms, ir::TSTypeParameterDeclaration *typeParams, ir::TypeNode *returnTypeAnnotation); @@ -730,7 +734,7 @@ public: bool IsExtensionAccessorFunctionType(const checker::Type *type); bool IsArrayExprSizeValidForTuple(const ir::ArrayExpression *arrayExpr, const ETSTupleType *tuple); void ModifyPreferredType(ir::ArrayExpression *arrayExpr, Type *newPreferredType); - Type *SelectGlobalIntegerTypeForNumeric(Type *type) const noexcept; + Type *SelectGlobalIntegerTypeForNumeric(Type *type) const; ir::ClassProperty *ClassPropToImplementationProp(ir::ClassProperty *classProp, varbinder::ClassScope *scope); ir::Expression *GenerateImplicitInstantiateArg(const std::string &className); @@ -803,6 +807,8 @@ public: void MakePropertyNonNullish(ETSObjectType *classType, varbinder::LocalVariable *prop); void ValidateObjectLiteralForRequiredType(const ETSObjectType *requiredType, const ir::ObjectExpression *initObjExpr); + bool IsStaticInvoke(ir::MemberExpression *const expr); + void ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type); using NamedAccessMeta = std::tuple; static NamedAccessMeta FormNamedAccessMetadata(varbinder::Variable const *prop); @@ -903,6 +909,7 @@ public: void LogUnresolvedReferenceError(ir::Identifier *ident); void WrongContextErrorClassifyByType(ir::Identifier *ident); + Type *CreateSyntheticTypeFromOverload(varbinder::Variable *const var); void CreateOverloadSigContainer(Signature *overloadHelperSig) { @@ -996,7 +1003,6 @@ private: std::pair GetTargetIdentifierAndType(ir::Identifier *ident); void NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, const ETSObjectType *classType); - void ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type); void ValidateNewClassInstanceIdentifier(ir::Identifier *const ident); void ValidateMemberIdentifier(ir::Identifier *const ident); void ValidateAssignmentIdentifier(ir::Identifier *const ident, Type *const type); @@ -1015,7 +1021,6 @@ private: PropertySearchFlags GetSearchFlags(const ir::MemberExpression *memberExpr, const varbinder::Variable *targetRef); PropertySearchFlags GetInitialSearchFlags(const ir::MemberExpression *memberExpr); Type *GetTypeOfSetterGetter([[maybe_unused]] varbinder::Variable *var); - ETSFunctionType *CreateSyntheticTypeFromOverload(varbinder::Variable *const var); void IterateInVariableContext([[maybe_unused]] varbinder::Variable *const var); bool CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init, checker::Type *annotationType, varbinder::Variable *const bindingVar); @@ -1082,8 +1087,8 @@ private: // Static invoke bool SetStaticInvokeValues(ir::Identifier *const ident, ir::Identifier *classId, ir::Identifier *methodId, varbinder::LocalVariable *instantiateMethod); - void CreateTransformedCallee(ir::Identifier *classId, ir::Identifier *methodId, ir::Identifier *const ident, - varbinder::LocalVariable *instantiateMethod); + void CreateTransformedCallee(ir::Identifier *ident, ir::Identifier *classId, ir::Identifier *methodId, + ir::CallExpression *callExpr); bool TryTransformingToStaticInvoke(ir::Identifier *ident, const Type *resolvedType); // Partial diff --git a/ets2panda/checker/TSAnalyzer.cpp b/ets2panda/checker/TSAnalyzer.cpp index 44d5a3d824525e69a8147a6a8d9e201a9fc4ca03..655c154d5f62250d0c9fb34c1864a88a80a7bb09 100644 --- a/ets2panda/checker/TSAnalyzer.cpp +++ b/ets2panda/checker/TSAnalyzer.cpp @@ -802,7 +802,7 @@ void TSAnalyzer::CheckNonComputed(checker::ObjectDescriptor *desc, ir::Expressio if (prop->Key()->IsNumberLiteral()) { memberVar->AddFlag(varbinder::VariableFlags::NUMERIC_NAME); } - + ES2PANDA_ASSERT(desc != nullptr); varbinder::LocalVariable *foundMember = desc->FindProperty(propName); allPropertiesMap.insert({propName, it->Start()}); @@ -1740,6 +1740,7 @@ static void AddEnumValueDeclaration(checker::TSChecker *checker, double number, enumScope->AddDecl(checker->Allocator(), decl, ScriptExtension::TS); res = enumScope->FindLocal(memberStr, varbinder::ResolveBindingOptions::BINDINGS); ES2PANDA_ASSERT(res && res->IsEnumVariable()); + ES2PANDA_ASSERT(enumVar != nullptr); enumVar = res->AsEnumVariable(); enumVar->AsEnumVariable()->SetBackReference(); enumVar->SetTsType(checker->GlobalStringType()); @@ -1747,6 +1748,7 @@ static void AddEnumValueDeclaration(checker::TSChecker *checker, double number, ES2PANDA_ASSERT(res->IsEnumVariable()); enumVar = res->AsEnumVariable(); auto *decl = checker->Allocator()->New(memberStr); + ES2PANDA_ASSERT(decl != nullptr); decl->BindNode(variable->Declaration()->Node()); enumVar->ResetDecl(decl); } diff --git a/ets2panda/checker/ets/aliveAnalyzer.cpp b/ets2panda/checker/ets/aliveAnalyzer.cpp index 13abe6b9ca76eb040ad9d23fb9dc050246f31104..e4edb04a7a1eadcccc752a94d25838480119604d 100644 --- a/ets2panda/checker/ets/aliveAnalyzer.cpp +++ b/ets2panda/checker/ets/aliveAnalyzer.cpp @@ -243,7 +243,9 @@ void AliveAnalyzer::AnalyzeMethodDef(const ir::MethodDefinition *methodDef) status_ = LivenessStatus::ALIVE; AnalyzeStat(func->Body()); ES2PANDA_ASSERT(methodDef->TsType() && methodDef->TsType()->IsETSFunctionType()); - const auto *returnType = methodDef->TsType()->AsETSFunctionType()->FindSignature(func)->ReturnType(); + const auto *signature = methodDef->TsType()->AsETSFunctionType()->FindSignature(func); + ES2PANDA_ASSERT(signature != nullptr); + const auto *returnType = signature->ReturnType(); const auto isVoid = returnType->IsETSVoidType() || returnType == checker_->GlobalVoidType(); auto isPromiseVoid = false; diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index b76c779b5ae596684a2d710a8dac3be1938a5747..0415b8a2ed995975f24f4a9b63ce0343b3302612 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -16,6 +16,7 @@ #include "arithmetic.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/typeError.h" #include "lexer/token/token.h" namespace ark::es2panda::checker { @@ -322,9 +323,7 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( // Try to handle errors on a lower level RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); - if (leftType->IsTypeError()) { // both are errors - return GlobalTypeError(); - } + ERROR_TYPE_CHECK(this, leftType, return GlobalTypeError()); auto const promotedType = BinaryGetPromotedType(this, leftType, rightType, !isEqualOp); if (!CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right)) { @@ -390,9 +389,7 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlus( // Try to handle errors on a lower level RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); - if (leftType->IsTypeError()) { // both are errors - return GlobalTypeError(); - } + ERROR_TYPE_CHECK(this, leftType, return GlobalTypeError()); if (leftType->IsETSStringType() || rightType->IsETSStringType()) { if (operationType == lexer::TokenType::PUNCTUATOR_MINUS || @@ -502,9 +499,7 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise( RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); - if (leftType->IsTypeError()) { // both are errors - return GlobalTypeError(); - } + ERROR_TYPE_CHECK(this, leftType, return GlobalTypeError()); if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { LogError(diagnostic::BINOP_UNION, {}, pos); @@ -548,9 +543,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir:: { RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); - if (leftType->IsTypeError()) { // both are errors - return GlobalTypeError(); - } + ERROR_TYPE_CHECK(this, leftType, return GlobalTypeError()); + // Don't do any boxing for primitive type when another operand is Enum. Enum will become primitive type later. if (leftType->IsETSEnumType() || rightType->IsETSEnumType()) { left->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); @@ -658,12 +652,9 @@ std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expres checker::Type *leftType, checker::Type *rightType) { RepairTypeErrorsInOperands(&leftType, &rightType); - if (leftType->IsTypeError()) { // both are errors - // We still know that operation result should be boolean, so recover. - return {GlobalETSBooleanType(), GlobalETSObjectType()}; - } + // We still know that operation result should be boolean, so recover. + ERROR_TYPE_CHECK(this, leftType, return std::make_tuple(GlobalETSBooleanBuiltinType(), GlobalETSObjectType())); - checker::Type *tsType {}; if (!IsReferenceType(leftType) || !IsReferenceType(rightType)) { LogError(diagnostic::BINOP_NOT_REFERENCE, {}, pos); return {GlobalETSBooleanType(), GlobalETSObjectType()}; @@ -672,17 +663,11 @@ std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expres Relation()->SetNode(left); if (!CheckValidEqualReferenceType(leftType, rightType)) { LogOperatorCannotBeApplied(this, operationType, leftType, rightType, pos); - return {GlobalETSBooleanType(), GlobalETSObjectType()}; - } - - if (!Relation()->IsCastableTo(leftType, rightType) && !Relation()->IsCastableTo(rightType, leftType)) { + } else if (!Relation()->IsCastableTo(leftType, rightType) && !Relation()->IsCastableTo(rightType, leftType)) { LogOperatorCannotBeApplied(this, operationType, leftType, rightType, pos); - return {GlobalETSBooleanType(), GlobalETSObjectType()}; } - tsType = GlobalETSBooleanType(); - - return {tsType, GlobalETSObjectType()}; + return {GlobalETSBooleanType(), GlobalETSObjectType()}; } static Type *HandelReferenceBinaryEquality(ETSChecker *checker, BinaryArithmOperands const &ops) @@ -718,9 +703,7 @@ static Type *CheckBinaryOperatorEqual(ETSChecker *checker, BinaryArithmOperands { [[maybe_unused]] auto const [expr, typeL, typeR, reducedL, reducedR] = ops; - if (typeL->IsTypeError()) { // both are errors - return checker->GlobalTypeError(); - } + ERROR_TYPE_CHECK(checker, typeL, return checker->GlobalTypeError()); if (reducedL->IsETSBooleanType() && reducedR->IsETSBooleanType()) { if (reducedL->IsConstantType() && reducedR->IsConstantType()) { @@ -766,9 +749,7 @@ std::tuple ETSChecker::CheckBinaryOperatorLessGreater(ir::Expres { RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); - if (leftType->IsTypeError()) { // both are errors - return {GlobalETSBooleanBuiltinType(), GlobalTypeError()}; - } + ERROR_TYPE_CHECK(this, leftType, return std::make_tuple(GlobalETSBooleanBuiltinType(), GlobalTypeError())); if ((leftType->IsETSUnionType() || rightType->IsETSUnionType()) && operationType != lexer::TokenType::PUNCTUATOR_EQUAL && @@ -806,9 +787,7 @@ std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::Sour checker::Type *rightType) { RepairTypeErrorsInOperands(&leftType, &rightType); - if (leftType->IsTypeError()) { // both are errors - return {GlobalETSBooleanBuiltinType(), GlobalTypeError()}; - } + ERROR_TYPE_CHECK(this, leftType, return std::make_tuple(GlobalETSBooleanBuiltinType(), GlobalTypeError())); if (leftType->IsETSPrimitiveType() || rightType->IsETSPrimitiveType()) { LogError(diagnostic::BINOP_NOT_SAME, {}, pos); @@ -920,15 +899,13 @@ Type *ETSChecker::CheckBinaryOperatorNullishCoalescing(ir::Expression *left, ir: lexer::SourcePosition pos) { auto *leftType = left->TsType(); + leftType = GetNonNullishType(leftType); + + ERROR_TYPE_CHECK(this, leftType, return GlobalTypeError()); + if (leftType->IsETSPrimitiveType()) { LogError(diagnostic::COALESCE_NOT_REF, {}, pos); } - leftType = GetNonNullishType(leftType); - ES2PANDA_ASSERT(leftType != nullptr); - if (leftType->IsTypeError()) { - ES2PANDA_ASSERT(IsAnyError()); - return GlobalTypeError(); - } auto *rightType = MaybeBoxType(right->TsType()); if (IsTypeIdenticalTo(leftType, rightType)) { diff --git a/ets2panda/checker/ets/etsWarningAnalyzer.cpp b/ets2panda/checker/ets/etsWarningAnalyzer.cpp index f686ff057b060145f4a05ec2c80e36e202ad6338..f207387c3f3d1c864cf618001ad783eeda5b3e71 100644 --- a/ets2panda/checker/ets/etsWarningAnalyzer.cpp +++ b/ets2panda/checker/ets/etsWarningAnalyzer.cpp @@ -42,7 +42,7 @@ void ETSWarningAnalyzer::AnalyzeClassDefForFinalModifier(const ir::ClassDefiniti ES2PANDA_ASSERT(classDef != nullptr); if (program_ == nullptr || classDef->IsFinal() || classDef->IsAbstract() || classDef->IsStatic() || - classDef->IsGlobal() || classDef->IsExported()) { + classDef->IsGlobal() || classDef->IsExported() || classDef->HasExportAlias()) { return; } diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index b10a5e7edbf30a99907595fac61122e3559db908..901e786d7c94af2b3f429c17f246c58c7a3331bb 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -23,6 +23,7 @@ #include "checker/ets/typeRelationContext.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsPartialTypeParameter.h" #include "checker/types/gradualType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "ir/base/catchClause.h" @@ -56,6 +57,7 @@ #include "ir/ts/tsTypeParameterInstantiation.h" #include "parser/program/program.h" #include "util/helpers.h" +#include "util/nameMangler.h" #include @@ -117,6 +119,10 @@ bool ETSChecker::EnhanceSubstitutionForType(const ArenaVector &typeParam if (paramType->IsETSReadonlyType()) { return EnhanceSubstitutionForReadonly(typeParams, paramType->AsETSReadonlyType(), argumentType, substitution); } + if (paramType->IsETSPartialTypeParameter()) { + return EnhanceSubstitutionForPartialTypeParam(typeParams, paramType->AsETSPartialTypeParameter(), argumentType, + substitution); + } if (paramType->IsGradualType()) { return EnhanceSubstitutionForType(typeParams, paramType->AsGradualType()->GetBaseType(), argumentType, substitution); @@ -293,6 +299,18 @@ bool ETSChecker::EnhanceSubstitutionForFunction(const ArenaVector &typeP return res; } +bool ETSChecker::EnhanceSubstitutionForPartialTypeParam(const ArenaVector &typeParams, + ETSPartialTypeParameter *paramType, Type *argumentType, + Substitution *substitution) +{ + if (!argumentType->IsETSObjectType() || !argumentType->AsETSObjectType()->IsPartial()) { + return false; + } + ES2PANDA_ASSERT(argumentType->AsETSObjectType()->GetBaseType() != nullptr); + return EnhanceSubstitutionForType(typeParams, paramType->GetUnderlying(), + argumentType->AsETSObjectType()->GetBaseType(), substitution); +} + // Try to find the base type somewhere in object subtypes. Incomplete, yet safe static ETSObjectType *FindEnhanceTargetInSupertypes(ETSObjectType *object, ETSObjectType *base) { @@ -378,7 +396,7 @@ bool ETSChecker::CheckOptionalLambdaFunction(ir::Expression *argument, Signature auto *const arrowFuncExpr = argument->AsArrowFunctionExpression(); if (ir::ScriptFunction *const lambda = arrowFuncExpr->Function(); - CheckLambdaAssignable(substitutedSig->Function()->Params()[index], lambda)) { + CheckLambdaAssignable(substitutedSig->Params()[index]->Declaration()->Node()->AsExpression(), lambda)) { return true; } } @@ -428,13 +446,53 @@ static bool CheckArrowFunctionParamIfNeeded(ETSChecker *checker, Signature *subs return true; } +// Note: (Issue27688) if lambda is trailing lambda transferred, it must be in recheck. +// in signature matching, foo(()=>void) should be the same with foo() {} +static bool HasTransferredTrailingLambda(const ArenaVector &arguments) +{ + return !arguments.empty() && arguments.back()->IsArrowFunctionExpression() && + arguments.back()->AsArrowFunctionExpression()->Function()->IsTrailingLambda(); +} + +bool ValidateRestParameter(ETSChecker *checker, Signature *signature, const ArenaVector &arguments, + const lexer::SourcePosition &pos, TypeRelationFlag flags) +{ + size_t const argCount = arguments.size(); + size_t compareCount = argCount; + auto const hasRestParameter = signature->HasRestParameter(); + auto const reportError = (flags & TypeRelationFlag::NO_THROW) == 0; + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && !signature->Params().empty() && + signature->Params().back()->Declaration()->Node()->AsETSParameterExpression()->IsOptional()) { + compareCount = compareCount - 1; + } + + if (!hasRestParameter && argCount > 0 && arguments[argCount - 1]->IsSpreadElement()) { + if (reportError) { + checker->LogError(diagnostic::ERROR_ARKTS_SPREAD_ONLY_WITH_REST, {}, pos); + } + return false; + } + if (compareCount < signature->MinArgCount() || (argCount > signature->ArgCount() && !hasRestParameter)) { + if (reportError) { + checker->LogError(diagnostic::PARAM_COUNT_MISMATCH, {signature->MinArgCount(), argCount}, pos); + } + return false; + } + return !(argCount > signature->ArgCount() && hasRestParameter && + (flags & TypeRelationFlag::IGNORE_REST_PARAM) != 0); +} + // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP, G.FUD.05) solid logic bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, const ArenaVector &arguments, TypeRelationFlag flags, const std::vector &argTypeInferenceRequired, bool reportError) { auto commonArity = std::min(arguments.size(), substitutedSig->ArgCount()); - if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0) { + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 || HasTransferredTrailingLambda(arguments)) { + if (commonArity == 0) { + ES2PANDA_ASSERT(substitutedSig->GetSignatureInfo()->params.empty()); + return true; + } commonArity = commonArity - 1; } for (size_t index = 0; index < commonArity; ++index) { @@ -643,23 +701,10 @@ Signature *ETSChecker::ValidateSignature( size_t const argCount = arguments.size(); auto const hasRestParameter = signature->RestVar() != nullptr; auto const reportError = (flags & TypeRelationFlag::NO_THROW) == 0; - size_t compareCount = argCount; - if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && !signature->Params().empty() && - signature->Params().back()->Declaration()->Node()->AsETSParameterExpression()->IsOptional()) { - compareCount = compareCount - 1; - } - if (compareCount < signature->MinArgCount() || (argCount > signature->ArgCount() && !hasRestParameter)) { - if (reportError) { - LogError(diagnostic::PARAM_COUNT_MISMATCH, {signature->MinArgCount(), argCount}, pos); - } + if (!ValidateRestParameter(this, signature, arguments, pos, flags)) { return nullptr; } - - if (argCount > signature->ArgCount() && hasRestParameter && (flags & TypeRelationFlag::IGNORE_REST_PARAM) != 0) { - return nullptr; - } - auto count = std::min(signature->ArgCount(), argCount); // Check all required formal parameter(s) first // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -1380,8 +1425,7 @@ Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVector &arguments, const lexer::SourcePosition &pos) { - auto *var = type->GetProperty(compiler::Signatures::CONSTRUCTOR_OVERLOAD_DEFINITION_NAME, - PropertySearchFlags::SEARCH_STATIC_METHOD); + auto *var = type->GetProperty(compiler::Signatures::CONSTRUCTOR_NAME, PropertySearchFlags::SEARCH_STATIC_METHOD); if (var != nullptr && var->TsType()->IsETSFunctionType()) { return MatchOrderSignatures(var->TsType()->AsETSFunctionType()->CallSignatures(), nullptr, arguments, pos, TypeRelationFlag::NONE); @@ -1609,7 +1653,7 @@ static bool AppendSignatureInfoParam(ETSChecker *checker, SignatureInfo *sigInfo if (!param->IsOptional()) { ++sigInfo->minArgCount; } - ES2PANDA_ASSERT(!param->IsOptional() || + ES2PANDA_ASSERT(!param->IsOptional() || param->Ident()->TsType()->IsTypeError() || checker->Relation()->IsSupertypeOf(param->Ident()->TsType(), checker->GlobalETSUndefinedType())); return true; } @@ -1647,8 +1691,8 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * ES2PANDA_ASSERT(IsAnyError()); // #23134 return nullptr; } - if (!restParamType->IsETSTupleType() && !restParamType->IsETSArrayType() && - !restParamType->IsETSResizableArrayType()) { + ES2PANDA_ASSERT(restParamType != nullptr); + if (!restParamType->IsAnyETSArrayOrTupleType()) { LogError(diagnostic::ONLY_ARRAY_OR_TUPLE_FOR_REST, {}, param->Start()); return nullptr; } @@ -1944,7 +1988,7 @@ bool ETSChecker::CheckOverride(Signature *signature, ETSObjectType *site) auto *target = site->GetProperty(signature->Function()->Id()->Name(), flags); bool isOverridingAnySignature = false; - if (target == nullptr || target->TsType() == nullptr || !target->TsType()->IsETSFunctionType()) { + if (target == nullptr || target->TsType() == nullptr || target->TsType()->IsTypeError()) { return isOverridingAnySignature; } @@ -2199,9 +2243,9 @@ bool ETSChecker::IsReturnTypeSubstitutable(Signature *const s1, Signature *const std::string ETSChecker::GetAsyncImplName(const util::StringView &name) { - std::string implName(name); - implName += "$asyncimpl"; - return implName; + std::string newName = + util::NameMangler::GetInstance()->CreateMangledNameByTypeAndName(util::NameMangler::ASYNC, name); + return newName; } std::string ETSChecker::GetAsyncImplName(ir::MethodDefinition *asyncMethod) @@ -2213,16 +2257,6 @@ std::string ETSChecker::GetAsyncImplName(ir::MethodDefinition *asyncMethod) return GetAsyncImplName(asyncName->Name()); } -bool ETSChecker::IsAsyncImplMethod(ir::MethodDefinition const *method) -{ - auto methodName = method->Key()->AsIdentifier()->Name().Utf8(); - std::string_view asyncSuffix = "$asyncimpl"; - if (methodName.size() < asyncSuffix.size()) { - return false; - } - return methodName.substr(methodName.size() - asyncSuffix.size()) == asyncSuffix; -} - ir::MethodDefinition *ETSChecker::CreateMethod(const util::StringView &name, ir::ModifierFlags modifiers, ir::ScriptFunctionFlags flags, ArenaVector &¶ms, varbinder::FunctionParamScope *paramScope, ir::TypeNode *returnType, @@ -2477,13 +2511,19 @@ void ETSChecker::CacheFunctionalInterface(ir::ETSFunctionType *type, ETSObjectTy functionalInterfaceCache_.emplace(hash, ifaceType); } -void ETSChecker::CollectReturnStatements(ir::AstNode *parent) +void ETSChecker::CollectReturnStatements(ir::AstNode *parent) // NOTE: remove with #28178 { parent->Iterate([this](ir::AstNode *childNode) -> void { if (childNode->IsScriptFunction()) { return; } + auto scope = Scope(); + if (childNode->IsBlockStatement()) { + scope = childNode->AsBlockStatement()->Scope(); + } + checker::ScopeContext scopeCtx(this, scope); + if (childNode->IsReturnStatement()) { ir::ReturnStatement *returnStmt = childNode->AsReturnStatement(); returnStmt->Check(this); @@ -2855,14 +2895,12 @@ void ETSChecker::ThrowOverloadMismatch(util::StringView callName, const ArenaVec msg += argument->ToString(); } - if (index == arguments.size() - 1U) { - msg += ")"; - LogError(diagnostic::NO_MATCHING_SIG, {signatureKind, msg.c_str()}, pos); - return; + if (index != arguments.size() - 1U) { + msg += ", "; } - - msg += ", "; } + msg += ")"; + LogError(diagnostic::NO_MATCHING_SIG, {signatureKind, msg.c_str()}, pos); } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 095b9f0503e36efd4eabfe0252c84ded480c63d2..b7d1a386e70f2c2b8537470e0e73d55134783d2c 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include "checker/ETSchecker.h" @@ -26,7 +27,9 @@ #include "evaluate/scopedDebugInfoPlugin.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" +#include "util/es2pandaMacros.h" #include "util/helpers.h" +#include "util/nameMangler.h" namespace ark::es2panda::checker { @@ -153,7 +156,7 @@ void ETSChecker::WrongContextErrorClassifyByType(ir::Identifier *ident) void ETSChecker::NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, const ETSObjectType *classType) { - if (classVar == nullptr) { + if (classVar == nullptr || (classVar->TsType() != nullptr && classVar->TsType()->IsTypeError())) { LogUnresolvedReferenceError(ident); return; } @@ -325,10 +328,6 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *ident) ValidatePropertyAccess(resolved, Context().ContainingClass(), ident->Start()); SaveCapturedVariable(resolved, ident); - if (IsVariableOverloadDeclaration(resolved)) { - return CreateSyntheticTypeFromOverload(resolved); - } - return GetTypeOfVariable(resolved); } @@ -626,6 +625,7 @@ void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::Arr checker::Type *ETSChecker::FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags) { if ((flags & ir::ModifierFlags::OPTIONAL) != 0) { + ES2PANDA_ASSERT(bindingVar != nullptr); auto *variableType = bindingVar->TsType() != nullptr ? bindingVar->TsType() : GlobalTypeError(); bindingVar->SetTsType( !variableType->IsTypeError() ? CreateETSUnionType({GlobalETSUndefinedType(), variableType}) : variableType); @@ -913,11 +913,15 @@ checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::T ES2PANDA_ASSERT(IsAnyError()); } - // initType should not be nullptr. If an error occurs during check, set it to GlobalTypeError(). - if (bindingVar == nullptr || initType == nullptr || initType->IsTypeError()) { + if (bindingVar == nullptr) { return annotationType != nullptr ? annotationType : GlobalTypeError(); } + // initType should not be nullptr. If an error occurs during check, set it to GlobalTypeError(). + if (initType == nullptr || initType->IsTypeError()) { + return bindingVar->SetTsType(annotationType != nullptr ? annotationType : GlobalTypeError()); + } + if (typeAnnotation == nullptr && initType->IsETSFunctionType()) { annotationType = initType->AsETSFunctionType(); bindingVar->SetTsType(annotationType); @@ -1564,47 +1568,6 @@ void ETSChecker::SetArrayPreferredTypeForNestedMemberExpressions(ir::MemberExpre } } -// 22955: type alias should be instantiated with Substitute -static void CollectAliasParametersForBoxing(Type *expandedAliasType, std::set ¶metersNeedToBeBoxed, - bool needToBeBoxed) -{ - if (expandedAliasType->IsETSTypeParameter() && needToBeBoxed) { - parametersNeedToBeBoxed.insert(expandedAliasType); - } else if (expandedAliasType->IsETSObjectType()) { - auto objectType = expandedAliasType->AsETSObjectType(); - needToBeBoxed = objectType->GetDeclNode() != nullptr && (objectType->GetDeclNode()->IsClassDefinition() || - objectType->GetDeclNode()->IsTSInterfaceDeclaration()); - for (const auto typeArgument : objectType->TypeArguments()) { - CollectAliasParametersForBoxing(typeArgument, parametersNeedToBeBoxed, needToBeBoxed); - } - } else if (expandedAliasType->IsETSTupleType()) { - auto tupleType = expandedAliasType->AsETSTupleType(); - needToBeBoxed = false; - for (auto type : tupleType->GetTupleTypesList()) { - CollectAliasParametersForBoxing(type, parametersNeedToBeBoxed, needToBeBoxed); - } - } else if (expandedAliasType->IsETSArrayType()) { - auto arrayType = expandedAliasType->AsETSArrayType(); - needToBeBoxed = false; - auto elementType = arrayType->ElementType(); - CollectAliasParametersForBoxing(elementType, parametersNeedToBeBoxed, needToBeBoxed); - } else if (expandedAliasType->IsETSUnionType()) { - auto unionType = expandedAliasType->AsETSUnionType(); - needToBeBoxed = false; - for (auto type : unionType->ConstituentTypes()) { - CollectAliasParametersForBoxing(type, parametersNeedToBeBoxed, needToBeBoxed); - } - } else if (expandedAliasType->IsETSFunctionType()) { - auto functionType = expandedAliasType->AsETSFunctionType(); - needToBeBoxed = true; - for (auto param : functionType->ArrowSignature()->Params()) { - CollectAliasParametersForBoxing(param->TsType(), parametersNeedToBeBoxed, needToBeBoxed); - } - CollectAliasParametersForBoxing(functionType->ArrowSignature()->ReturnType(), parametersNeedToBeBoxed, - needToBeBoxed); - } -} - bool ETSChecker::CheckMinimumTypeArgsPresent(const ir::TSTypeAliasDeclaration *typeAliasNode, const ir::TSTypeParameterInstantiation *typeParams) { @@ -1635,11 +1598,10 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa ir::TSTypeAliasDeclaration *const typeAliasNode) { if (typeParams == nullptr && typeAliasNode->TypeParams() != nullptr) { - auto declTypeParams = typeAliasNode->TypeParams()->Params(); - auto isAllTypeParamsHasDefaultType = - std::find_if(declTypeParams.begin(), declTypeParams.end(), [](ir::TSTypeParameter *param) { - return param->DefaultType() == nullptr; - }) == declTypeParams.end(); + auto const ¶ms = typeAliasNode->TypeParams()->Params(); + auto isAllTypeParamsHasDefaultType = std::find_if(params.begin(), params.end(), [](ir::TSTypeParameter *param) { + return param->DefaultType() == nullptr; + }) == params.end(); if (!isAllTypeParamsHasDefaultType) { LogError(diagnostic::GENERIC_ALIAS_WITHOUT_PARAMS, {}, name->Start()); return GlobalTypeError(); @@ -1668,27 +1630,28 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Type *const aliasType = GetReferencedTypeBase(name); auto substitution = Substitution {}; + auto relation = Relation(); - std::set parametersNeedToBeBoxed; - auto expandedAliasType = aliasType->Substitute(Relation(), &substitution); - CollectAliasParametersForBoxing(expandedAliasType, parametersNeedToBeBoxed, false); - - for (std::size_t idx = 0; idx < typeAliasNode->TypeParams()->Params().size(); ++idx) { + for (std::size_t idx = 0U; idx < typeAliasNode->TypeParams()->Params().size(); ++idx) { auto *typeAliasTypeName = typeAliasNode->TypeParams()->Params().at(idx)->Name(); auto *typeAliasType = typeAliasTypeName->Variable()->TsType()->MaybeBaseTypeOfGradualType(); - if (!typeAliasType->IsETSTypeParameter()) { - continue; - } + if (typeAliasType->IsETSTypeParameter()) { + ir::TypeNode *typeNode = ResolveTypeNodeForTypeArg(typeAliasNode, typeParams, idx); + auto paramType = typeNode->GetType(this); + + EmplaceSubstituted(&substitution, typeAliasType->AsETSTypeParameter(), paramType); - ir::TypeNode *typeNode = ResolveTypeNodeForTypeArg(typeAliasNode, typeParams, idx); - auto paramType = typeNode->GetType(this); + auto *const maybeIrrelevantTypeArg = paramType->IsETSVoidType() ? GlobalETSUndefinedType() : paramType; + auto *constraintType = typeAliasType->AsETSTypeParameter()->GetConstraintType(); + if (maybeIrrelevantTypeArg->IsTypeError() || constraintType->IsTypeError()) { + continue; // Don't issue extra error notification! + } - if (parametersNeedToBeBoxed.find(typeAliasType) != parametersNeedToBeBoxed.end()) { - if (const auto boxedType = MaybeBoxInRelation(typeNode->GetType(this)); boxedType != nullptr) { - paramType = boxedType; + constraintType = constraintType->Substitute(relation, &substitution); + if (!relation->IsSupertypeOf(constraintType, maybeIrrelevantTypeArg)) { + LogError(diagnostic::TYPEARG_TYPEPARAM_SUBTYPING, {paramType, constraintType}, typeNode->Start()); } } - substitution.insert({typeAliasType->AsETSTypeParameter(), paramType}); // #21835: type argument is not boxed } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -1746,7 +1709,9 @@ void ETSChecker::BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleO if (!var->AsLocalVariable()->Declaration()->Node()->IsValidInCurrentPhase()) { continue; } - if ((var->AsLocalVariable()->Declaration()->Node()->IsExported()) && found) { + if ((var->AsLocalVariable()->Declaration()->Node()->IsExported() || + var->AsLocalVariable()->Declaration()->Node()->HasExportAlias()) && + found) { if (!aliasedName.Empty()) { moduleObjType->AddReExportAlias(var->Declaration()->Name(), aliasedName); } @@ -1756,6 +1721,11 @@ void ETSChecker::BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleO } } +template void ETSChecker::BindingsModuleObjectAddProperty( + ETSObjectType *, ir::ETSImportDeclaration *, const varbinder::Scope::VariableMap &, const util::StringView &); +template void ETSChecker::BindingsModuleObjectAddProperty( + ETSObjectType *, ir::ETSImportDeclaration *, const varbinder::Scope::VariableMap &, const util::StringView &); + util::StringView ETSChecker::FindPropNameForNamespaceImport(const util::StringView &originalName, const util::StringView &importPath) { @@ -1796,37 +1766,21 @@ void ETSChecker::SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjT program->SetASTChecked(); program->Ast()->Check(this); } - if (program->IsDeclForDynamicStaticInterop()) { - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); - - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); - - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); - - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); - } else { - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); - } + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); } void ETSChecker::SetrModuleObjectTsType(ir::Identifier *local, checker::ETSObjectType *moduleObjType) @@ -1855,6 +1809,10 @@ Type *ETSChecker::GetReferencedTypeBase(ir::Expression *name) return name->Check(this); } + if (name->IsLiteral()) { + return name->Check(this); + } + ES2PANDA_ASSERT(name->IsIdentifier()); if (name->AsIdentifier()->Variable() == nullptr) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -1899,28 +1857,28 @@ Type *ETSChecker::ResolveReferencedType(varbinder::LocalVariable *refVar, const } } -checker::Type *ETSChecker::GetElementTypeOfArray(checker::Type *type) +checker::Type *ETSChecker::GetElementTypeOfArray(checker::Type *type) const { if (type->IsTypeError()) { return GlobalTypeError(); } - if (type->IsETSArrayType()) { return type->AsETSArrayType()->ElementType(); } - - ES2PANDA_ASSERT(type->IsETSResizableArrayType()); - return type->AsETSResizableArrayType()->ElementType(); + if (type->IsETSResizableArrayType()) { + return type->AsETSResizableArrayType()->ElementType(); + } + if (type->IsETSReadonlyArrayType()) { + auto const &typeArgs = type->AsETSObjectType()->TypeArguments(); + ES2PANDA_ASSERT(!typeArgs.empty()); + return typeArgs.front(); + } + ES2PANDA_UNREACHABLE(); } const checker::Type *ETSChecker::GetElementTypeOfArray(const checker::Type *type) const { - if (type->IsETSArrayType()) { - return type->AsETSArrayType()->ElementType(); - } - - ES2PANDA_ASSERT(type->IsETSResizableArrayType()); - return type->AsETSResizableArrayType()->ElementType(); + return GetElementTypeOfArray(const_cast(type)); } void ETSChecker::ConcatConstantString(util::UString &target, Type *type) @@ -2185,6 +2143,7 @@ bool IsConstantMemberOrIdentifierExpression(ir::Expression *expression, bool che if (var == nullptr) { return false; } + ES2PANDA_ASSERT(var->TsType() != nullptr); bool isConst = checkForConst ? (var->TsType()->HasTypeFlag(checker::TypeFlag::CONSTANT)) : true; return ((var->Declaration()->IsConstDecl() && isConst) || (var->Declaration()->IsReadonlyDecl() && var->HasFlag(varbinder::VariableFlags::STATIC))); @@ -2715,10 +2674,10 @@ static void ReInitScopesForTypeAnnotation(ETSChecker *checker, ir::TypeNode *typ ir::ClassProperty *ETSChecker::ClassPropToImplementationProp(ir::ClassProperty *classProp, varbinder::ClassScope *scope) { - classProp->Key()->AsIdentifier()->SetName( - util::UString(std::string(compiler::Signatures::PROPERTY) + classProp->Key()->AsIdentifier()->Name().Mutf8(), - ProgramAllocator()) - .View()); + std::string newName = util::NameMangler::GetInstance()->CreateMangledNameByTypeAndName( + util::NameMangler::PROPERTY, classProp->Key()->AsIdentifier()->Name()); + + classProp->Key()->AsIdentifier()->SetName(util::UString(newName, ProgramAllocator()).View()); classProp->AddModifier(ir::ModifierFlags::PRIVATE); auto *fieldDecl = ProgramAllocator()->New(classProp->Key()->AsIdentifier()->Name()); @@ -3043,11 +3002,41 @@ void ETSChecker::GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *origin } } +void ETSChecker::CreateTransformedCallee(ir::Identifier *ident, ir::Identifier *classId, ir::Identifier *methodId, + ir::CallExpression *callExpr) +{ + ir::MemberExpression *transformedCallee = nullptr; + classId->SetRange(ident->Range()); + if (ident->Parent()->IsMemberExpression()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + transformedCallee = ProgramAllocNode( + ident->Parent()->AsMemberExpression(), methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + ident->Parent()->AsMemberExpression()->SetParent(transformedCallee); + } else { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + transformedCallee = ProgramAllocNode( + classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + transformedCallee->SetParent(callExpr); + } + + methodId->SetRange(ident->Range()); + transformedCallee->SetRange(ident->Range()); + // Note: Should not modify the AST + // Related issue: #issue27122 + callExpr->SetCallee(transformedCallee); +} + // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, const Type *resolvedType) { - ES2PANDA_ASSERT(ident->Parent()->IsCallExpression()); - ES2PANDA_ASSERT(ident->Parent()->AsCallExpression()->Callee() == ident); + ir::CallExpression *callExpr = nullptr; + if (ident->Parent()->IsMemberExpression()) { + callExpr = ident->Parent()->Parent()->AsCallExpression(); + } else { + ES2PANDA_ASSERT(ident->Parent()->IsCallExpression()); + ES2PANDA_ASSERT(ident->Parent()->AsCallExpression()->Callee() == ident); + callExpr = ident->Parent()->AsCallExpression(); + } if (!resolvedType->IsETSObjectType()) { return false; @@ -3082,20 +3071,8 @@ bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, cons } else if (propertyName == compiler::Signatures::STATIC_INVOKE_METHOD) { methodId->SetVariable(invokeMethod); } - - auto *transformedCallee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, - false); - - classId->SetRange(ident->Range()); - methodId->SetRange(ident->Range()); - transformedCallee->SetRange(ident->Range()); - - auto *callExpr = ident->Parent()->AsCallExpression(); - transformedCallee->SetParent(callExpr); - callExpr->SetCallee(transformedCallee); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + CreateTransformedCallee(ident, classId, methodId, callExpr); if (instantiateMethod != nullptr) { auto lexScope {varbinder::LexicalScope::Enter(VarBinder(), compiler::NearestScope(callExpr))}; // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -3138,7 +3115,7 @@ void ETSChecker::ImportNamespaceObjectTypeAddReExportType(ir::ETSImportDeclarati Type *ETSChecker::GetImportSpecifierObjectType(ir::ETSImportDeclaration *importDecl, ir::Identifier *ident) { - auto importPath = importDecl->ResolvedSource(); + auto importPath = importDecl->IsPureDynamic() ? importDecl->DeclPath() : importDecl->ResolvedSource(); parser::Program *program = SelectEntryOrExternalProgram(static_cast(VarBinder()), importPath); if (program == nullptr) { diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index d048894b2c4612f726fb4080c2ab5d61af1f5f67..e42f1d760e2d23ca7e2974b775b2e9e8dc29a780 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -84,11 +84,16 @@ static bool CheckGetterSetterDecl(varbinder::LocalVariable const *child, varbind static bool CheckOverloadDecl(varbinder::LocalVariable *child, varbinder::LocalVariable *parent) { - if (!child->Declaration()->Node()->IsOverloadDeclaration() || + if (!child->Declaration()->Node()->IsOverloadDeclaration() && !parent->Declaration()->Node()->IsOverloadDeclaration()) { return false; } + if (!child->Declaration()->Node()->IsOverloadDeclaration() || + !parent->Declaration()->Node()->IsOverloadDeclaration()) { + return true; + } + auto *childOverload = child->Declaration()->Node()->AsOverloadDeclaration(); auto *parentOverload = parent->Declaration()->Node()->AsOverloadDeclaration(); for (auto *baseMethodName : parentOverload->OverloadedList()) { @@ -365,6 +370,12 @@ bool ETSChecker::CheckDefaultTypeParameter(const ir::TSTypeParameter *param, Typ }; if (param->DefaultType() != nullptr) { + TypeStackElement tse(this, param->DefaultType(), {{diagnostic::TYPE_PARAM_CIRCULAR_DEFAULT_TYPE}}, + param->DefaultType()->Start()); + if (tse.HasTypeError()) { + return false; + } + param->DefaultType()->Iterate(checkDefault); } @@ -696,7 +707,9 @@ void ETSChecker::ResolveDeclaredMembersOfObject(const Type *type) auto *objectType = type->AsETSObjectType(); auto *declNode = objectType->GetDeclNode(); - if (declNode == nullptr || !(declNode->IsClassDefinition() || declNode->IsTSInterfaceDeclaration())) { + // Note: the DeclNode of ETSStringLiteralType is totally the same as its super type: `ETSObjectType-String`. + if (objectType->IsETSStringLiteralType() || declNode == nullptr || + !(declNode->IsClassDefinition() || declNode->IsTSInterfaceDeclaration())) { return; } @@ -1111,6 +1124,10 @@ void ETSChecker::ApplyModifiersAndRemoveImplementedAbstracts(ArenaVectorFields()) { + if (field->Declaration()->Node()->AsClassProperty()->IsStatic()) { + continue; + } + if (field->Name() == (*it)->Name()) { field->Declaration()->Node()->AddModifier(isGetSetExternal.isGetter && isGetSetExternal.isSetter ? ir::ModifierFlags::GETTER_SETTER @@ -1623,7 +1640,7 @@ bool ETSChecker::ValidateArrayIndex(ir::Expression *const expr, bool relaxed) return false; } - if (!relaxed || !expressionType->IsConstantType()) { + if (!relaxed || !expressionType->IsConstantType() || !expr->IsNumberLiteral()) { return true; } @@ -1814,6 +1831,11 @@ void ETSChecker::CheckCyclicConstructorCall(Signature *signature) return; } + // This is a condition set up to handle error scenarios. + if (signature->Function()->Body() == nullptr) { + return; + } + auto *funcBody = signature->Function()->Body()->AsBlockStatement(); TypeStackElement tse(this, signature, {{diagnostic::RECURSIVE_CTOR}}, signature->Function()->Start()); @@ -1871,7 +1893,7 @@ void ETSChecker::ValidateNamespaceProperty(varbinder::Variable *property, const { ir::AstNode *parent = nullptr; if (property->TsType() != nullptr && !property->TsType()->IsTypeError()) { - if (property->TsType()->IsETSMethodType()) { + if (property->TsType()->IsETSMethodType() && !property->HasFlag(varbinder::VariableFlags::OVERLOAD)) { auto funcType = property->TsType()->AsETSFunctionType(); property = funcType->CallSignatures()[0]->OwnerVar(); ES2PANDA_ASSERT(property != nullptr); @@ -2008,7 +2030,7 @@ PropertySearchFlags ETSChecker::GetInitialSearchFlags(const ir::MemberExpression switch (memberExpr->Parent()->Type()) { case ir::AstNodeType::CALL_EXPRESSION: { if (memberExpr->Parent()->AsCallExpression()->Callee() == memberExpr) { - return FUNCTIONAL_FLAGS; + return PropertySearchFlags::SEARCH_ALL; } break; } @@ -2274,6 +2296,15 @@ static ResolvedKind DecideResolvedKind(Type *typeOfGlobalFunctionVar) return ResolvedKind::EXTENSION_FUNCTION; } +void ETSChecker::CheckAnnotationReference(const ir::MemberExpression *memberExpr, const varbinder::LocalVariable *prop) +{ + // Note: there might be a better way to handle annotations + if (prop != nullptr && prop->Declaration() != nullptr && prop->Declaration()->IsAnnotationDecl() && + memberExpr->Parent()->IsCallExpression()) { + LogError(diagnostic::ANNOTATION_INSTANTIATION, {prop->Declaration()->Name()}, memberExpr->Start()); + } +} + // NOLINTNEXTLINE(readability-function-size) std::vector ETSChecker::ResolveMemberReference(const ir::MemberExpression *const memberExpr, const ETSObjectType *const target) @@ -2292,6 +2323,9 @@ std::vector ETSChecker::ResolveMemberReference(const ir::Member } auto searchName = target->GetReExportAliasValue(memberExpr->Property()->AsIdentifier()->Name()); auto *prop = target->GetProperty(searchName, searchFlag); + + CheckAnnotationReference(memberExpr, prop); + varbinder::Variable *const globalFunctionVar = ResolveInstanceExtension(memberExpr); if (targetRef != nullptr && targetRef->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE)) { // Note: extension function only for instance. @@ -2602,9 +2636,9 @@ Type *ETSChecker::GetApparentType(Type *type) if (type != res) { apparentTypes.insert({type, res}); } - apparentTypes.insert({res, res}); - return res; + return apparentTypes.insert({res, res}).first->second; }; + ES2PANDA_ASSERT(type != nullptr); if (type->IsGradualType()) { return cached(type->AsGradualType()->GetBaseType()); @@ -2614,6 +2648,17 @@ Type *ETSChecker::GetApparentType(Type *type) // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return cached(GetApparentType(type->AsETSTypeParameter()->GetConstraintType())); } + + if (type->IsETSTypeAliasType()) { + // For the recursive type aliases its target type is not ready at the moment of union type creation + // (and assemblyLUB type constructing). + if (auto *targetType = type->AsETSTypeAliasType()->GetTargetType(); targetType != nullptr) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return cached(GetApparentType(targetType)); + } + return type; + } + if (type->IsETSNonNullishType()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return cached( diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 7605fae5d9446dcf1e0fc33614220f9e14e808c1..534203ded5bac9a87d4b97ff82fd894fedc66d40 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -157,6 +157,10 @@ Type *ETSChecker::RemoveUndefinedType(Type *const type) return type; } + if (type->IsETSPartialTypeParameter()) { + return type; + } + if (type->IsETSUndefinedType()) { return GetGlobalTypesHolder()->GlobalETSNeverType(); } @@ -377,9 +381,6 @@ bool Type::IsETSMethodType() const if (type->IsETSTypeAliasType()) { // NOTE(vpukhov): #20561 return true; } - if (type->IsNeverType()) { // NOTE(vpukhov): #20562 We use ets/never and ts/never simultaneously - ES2PANDA_UNREACHABLE(); - } return type->HasTypeFlag(ETS_SANE_REFERENCE_TYPE); } @@ -486,7 +487,7 @@ Type *ETSChecker::GetTypeOfSetterGetter(varbinder::Variable *const var) return propType->FindSetter()->Params()[0]->TsType(); } -ETSFunctionType *ETSChecker::CreateSyntheticTypeFromOverload(varbinder::Variable *const var) +Type *ETSChecker::CreateSyntheticTypeFromOverload(varbinder::Variable *const var) { auto *overloadDeclaration = var->Declaration()->Node()->AsOverloadDeclaration(); std::vector signatures; @@ -495,6 +496,10 @@ ETSFunctionType *ETSChecker::CreateSyntheticTypeFromOverload(varbinder::Variable for (auto *overloadFunction : overloadDeclaration->OverloadedList()) { Type *functionType = overloadFunction->Check(this); + if (functionType->IsTypeError()) { + overloadDeclaration->SetTsType(GetGlobalTypesHolder()->GlobalTypeError()); + return GetGlobalTypesHolder()->GlobalTypeError(); + } ES2PANDA_ASSERT(functionType->IsETSFunctionType()); auto *signature = functionType->AsETSFunctionType()->CallSignatures().front(); if (std::find(signatures.begin(), signatures.end(), signature) != signatures.end()) { @@ -507,6 +512,9 @@ ETSFunctionType *ETSChecker::CreateSyntheticTypeFromOverload(varbinder::Variable syntheticFunctionType->AddCallSignature(s); } + syntheticFunctionType->SetVariable(var); + var->SetTsType(syntheticFunctionType); + overloadDeclaration->SetTsType(syntheticFunctionType); return syntheticFunctionType; } @@ -564,7 +572,7 @@ static Type *GetTypeFromVarLikeVariableDeclaration(ETSChecker *checker, varbinde var->SetTsType(checker->GlobalTypeError()); return checker->GlobalTypeError(); } - return declNode->Check(checker); + return var->SetTsType(declNode->Check(checker)); } Type *ETSChecker::GetTypeFromVariableDeclaration(varbinder::Variable *const var) @@ -689,6 +697,7 @@ Type *ETSChecker::GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable * case ir::AstNodeType::METHOD_DEFINITION: case ir::AstNodeType::CLASS_DEFINITION: return GetTypeOfVariable(prop); + case ir::AstNodeType::OVERLOAD_DECLARATION: case ir::AstNodeType::TS_ENUM_DECLARATION: return nullptr; default: @@ -731,7 +740,15 @@ Type *ETSChecker::GuaranteedTypeForUnionFieldAccess(ir::MemberExpression *member const auto &types = etsUnionType->ConstituentTypes(); ArenaVector apparentTypes {ProgramAllocator()->Adapter()}; const auto *prop = memberExpression->Property(); - const auto &propertyName = prop->IsIdentifier() ? prop->AsIdentifier()->Name() : prop->AsStringLiteral()->Str(); + util::StringView propertyName; + if (prop->IsIdentifier()) { + propertyName = prop->AsIdentifier()->Name(); + } else if (prop->IsStringLiteral()) { + propertyName = prop->AsStringLiteral()->Str(); + } else { + return GlobalTypeError(); + } + for (auto *type : types) { auto searchFlags = PropertySearchFlags::SEARCH_FIELD | PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE; @@ -1076,11 +1093,13 @@ void ETSChecker::ValidateThisUsage(const ir::TypeNode *returnTypeAnnotation) } if (returnTypeAnnotation->IsETSTypeReference() && IsFixedArray(returnTypeAnnotation->AsETSTypeReference()->Part())) { - auto elementType = returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams()->Params()[0]; - if (CheckAndLogInvalidThisUsage(elementType, diagnostic::NOT_ALLOWED_THIS_IN_ARRAY_TYPE)) { - return; + if (returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams() != nullptr) { + auto elementType = returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams()->Params()[0]; + if (CheckAndLogInvalidThisUsage(elementType, diagnostic::NOT_ALLOWED_THIS_IN_ARRAY_TYPE)) { + return; + } + ValidateThisUsage(elementType); } - ValidateThisUsage(elementType); return; } } @@ -1178,7 +1197,8 @@ static auto IsNonArrayLiteral(ir::Expression *init) return true; } - if (init->TsType()->IsETSEnumType() && init->TsType()->AsETSEnumType()->NodeIsEnumLiteral(init)) { + if (init->TsType() != nullptr && init->TsType()->IsETSEnumType() && + init->TsType()->AsETSEnumType()->NodeIsEnumLiteral(init)) { return true; } return false; @@ -1233,6 +1253,12 @@ void ETSChecker::CheckAnnotationPropertyType(ir::ClassProperty *property) return; } + // Avoid outputting the same syntax and type errors. + if (property->Value()->IsBrokenExpression()) { + ES2PANDA_ASSERT(IsAnyError()); + return; + } + LogError(diagnostic::ANNOTATION_FIELD_NONLITERAL, {}, property->Value()->Start()); } @@ -1539,7 +1565,9 @@ bool ETSChecker::ResolveLambdaArgumentType(Signature *signature, ir::Expression auto arrowFuncExpr = argument->AsArrowFunctionExpression(); bool typeValid = true; ir::ScriptFunction *const lambda = arrowFuncExpr->Function(); - if (!NeedTypeInference(lambda)) { + // Note: (Issue27688) if lambda is trailing lambda transferred, it must be in recheck. + // its type was cleared before the check, so here we need recheck it. + if (!NeedTypeInference(lambda) && !lambda->IsTrailingLambda()) { return typeValid; } @@ -1653,11 +1681,6 @@ static bool CheckAccessModifierForOverloadDeclaration(ETSChecker *const checker, const ir::ModifierFlags &overloadedMethodFlags, const lexer::SourcePosition &pos) { - if ((overloadedMethodFlags & (ir::ModifierFlags::ABSTRACT)) != 0) { - checker->LogError(diagnostic::OVERLOAD_MODIFIERS_ABSTRACT, {}, pos); - return false; - } - if (((overLoadAliasFlags ^ overloadedMethodFlags) & (ir::ModifierFlags::STATIC | ir::ModifierFlags::ASYNC)) != 0) { checker->LogError(diagnostic::OVERLOAD_SAME_ACCESS_MODIFIERS_STATIC_ASYNC, {}, pos); return false; @@ -1668,11 +1691,6 @@ static bool CheckAccessModifierForOverloadDeclaration(ETSChecker *const checker, return false; } - if ((overLoadAliasFlags & ir::ModifierFlags::EXPORT) != 0 && - (overloadedMethodFlags & ir::ModifierFlags::EXPORT) == 0) { - checker->LogError(diagnostic::OVERLOADED_NAME_MUST_ALSO_EXPORTED, {}, pos); - return false; - } return true; } @@ -1741,6 +1759,11 @@ void ETSChecker::CheckFunctionOverloadDeclaration(ETSChecker *checker, ir::Overl void ETSChecker::CheckClassMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const { + PropertySearchFlags searchFlags = + PropertySearchFlags::SEARCH_IN_BASE | PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::IS_GETTER | PropertySearchFlags::IGNORE_OVERLOAD | + (node->IsStatic() ? PropertySearchFlags::SEARCH_STATIC_METHOD : PropertySearchFlags::SEARCH_INSTANCE_METHOD); + for (auto *overloadedName : node->OverloadedList()) { if (!overloadedName->IsIdentifier()) { overloadedName->SetTsType(checker->GlobalTypeError()); @@ -1751,10 +1774,15 @@ void ETSChecker::CheckClassMethodOverloadDeclaration(ETSChecker *checker, ir::Ov Type *classType = node->Parent()->AsClassDefinition()->TsType(); ES2PANDA_ASSERT(classType->IsETSObjectType()); - PropertySearchFlags searchFlags = PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE | - PropertySearchFlags::SEARCH_IN_INTERFACES | PropertySearchFlags::IS_GETTER; auto *variable = checker->ResolveOverloadReference(ident->AsIdentifier(), classType->AsETSObjectType(), searchFlags); + + if (variable == nullptr && + checker->ResolveOverloadReference(ident->AsIdentifier(), classType->AsETSObjectType(), + searchFlags | PropertySearchFlags::SEARCH_METHOD) != nullptr) { + checker->LogError(diagnostic::OVERLOAD_SAME_ACCESS_MODIFIERS_STATIC_ASYNC, {}, ident->Start()); + continue; + } if (variable == nullptr) { checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, ident->Start()); ident->SetTsType(checker->GlobalTypeError()); @@ -1772,6 +1800,10 @@ void ETSChecker::CheckClassMethodOverloadDeclaration(ETSChecker *checker, ir::Ov void ETSChecker::CheckInterfaceMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const { + PropertySearchFlags searchFlags = + PropertySearchFlags::SEARCH_IN_BASE | PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::IS_GETTER | PropertySearchFlags::IGNORE_OVERLOAD | + (node->IsStatic() ? PropertySearchFlags::SEARCH_STATIC_METHOD : PropertySearchFlags::SEARCH_INSTANCE_METHOD); for (auto *overloadedName : node->OverloadedList()) { if (!overloadedName->IsIdentifier()) { overloadedName->SetTsType(checker->GlobalTypeError()); @@ -1779,9 +1811,26 @@ void ETSChecker::CheckInterfaceMethodOverloadDeclaration(ETSChecker *checker, ir } ir::Identifier *ident = overloadedName->AsIdentifier(); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - Type *identType = checker->ResolveIdentifier(ident); - ident->SetTsType(identType); + Type *interfaceType = node->Parent()->Parent()->AsTSInterfaceDeclaration()->TsType(); + ES2PANDA_ASSERT(interfaceType->IsETSObjectType()); + auto *variable = + checker->ResolveOverloadReference(ident->AsIdentifier(), interfaceType->AsETSObjectType(), searchFlags); + + if (variable == nullptr && + checker->ResolveOverloadReference(ident->AsIdentifier(), interfaceType->AsETSObjectType(), + searchFlags | PropertySearchFlags::SEARCH_METHOD) != nullptr) { + checker->LogError(diagnostic::OVERLOAD_SAME_ACCESS_MODIFIERS_STATIC_ASYNC, {}, ident->Start()); + continue; + } + if (variable == nullptr) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, ident->Start()); + ident->SetTsType(checker->GlobalTypeError()); + continue; + } + + ident->SetTsType(variable->TsType()); + ident->SetVariable(variable); + if (!CheckOverloadedName(checker, node, overloadedName)) { continue; } diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index 959fcad7731532ffdfb72a35ebfbf334621adbbd..0647747376011ea0ca40b6d0e99112785e9e2462 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -327,6 +327,8 @@ static ETSObjectType *InitializeGlobalBuiltinObjectType(ETSChecker *checker, Glo setType(GlobalTypeId::ETS_ARRAY, programAllocator->New(programAllocator, arrayObj)); return arrayObj; } + case GlobalTypeId::ETS_READONLY_ARRAY: + return setType(globalId, create(ETSObjectFlags::BUILTIN_READONLY_ARRAY))->AsETSObjectType(); case GlobalTypeId::ETS_BOOLEAN_BUILTIN: return create(ETSObjectFlags::BUILTIN_BOOLEAN); case GlobalTypeId::ETS_BYTE_BUILTIN: diff --git a/ets2panda/checker/ets/typeRelationContext.cpp b/ets2panda/checker/ets/typeRelationContext.cpp index 855ea818309eec24bf01bb68432e35ebd88e9010..d2835dec80367d14eb1aa29ef1050222f0848e85 100644 --- a/ets2panda/checker/ets/typeRelationContext.cpp +++ b/ets2panda/checker/ets/typeRelationContext.cpp @@ -99,7 +99,7 @@ void InstantiationContext::InstantiateType(ETSObjectType *type, ir::TSTypeParame } } - auto pos = (typeArgs == nullptr) ? lexer::SourcePosition() : typeArgs->Range().start; + auto pos = (typeArgs == nullptr) ? type->Variable()->Declaration()->Node()->Range().start : typeArgs->Range().start; InstantiateType(type, std::move(typeArgTypes), pos); ES2PANDA_ASSERT(result_->IsETSObjectType()); result_->AsETSObjectType()->AddObjectFlag(ETSObjectFlags::NO_OPTS); diff --git a/ets2panda/checker/ets/typeRelationContext.h b/ets2panda/checker/ets/typeRelationContext.h index ae20ce5ad1ceddc5f13cc6f8e61af4269b365b04..7ba41f94c85585a2607a67f9da63bea20b07c3ff 100644 --- a/ets2panda/checker/ets/typeRelationContext.h +++ b/ets2panda/checker/ets/typeRelationContext.h @@ -36,6 +36,7 @@ public: ES2PANDA_ASSERT(target != nullptr); ES2PANDA_ASSERT(node != nullptr); + ES2PANDA_ASSERT(source != nullptr); if (target->IsETSArrayType() && node->IsArrayExpression()) { assignable_ = ValidateArrayTypeInitializerByElement(relation, node->AsArrayExpression(), target->AsETSArrayType()); diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 076bdb34bd08c8caf9ac3258f87e77f9533311fb..93f6b5eccc737df9ed001d1f9d02975aa04d2d76 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -22,6 +22,7 @@ #include "ir/expressions/literals/undefinedLiteral.h" #include "varbinder/ETSBinder.h" #include "checker/types/ets/etsPartialTypeParameter.h" +#include "util/nameMangler.h" #include @@ -90,7 +91,9 @@ static std::pair GetPartialClassName(ETSChec { // Partial class name for class 'T' will be 'T$partial' auto const addSuffix = [checker](util::StringView name) { - return util::UString(name.Mutf8() + PARTIAL_CLASS_SUFFIX, checker->ProgramAllocator()).View(); + std::string newName = + util::NameMangler::GetInstance()->CreateMangledNameByTypeAndName(util::NameMangler::PARTIAL, name); + return util::UString(newName, checker->ProgramAllocator()).View(); }; auto declIdent = typeNode->IsClassDefinition() ? typeNode->AsClassDefinition()->Ident() @@ -120,11 +123,7 @@ static T *CloneNodeIfNotNullptr(T *node, ArenaAllocator *allocator) Type *ETSChecker::CreatePartialType(Type *const typeToBePartial) { ES2PANDA_ASSERT(typeToBePartial->IsETSReferenceType()); - if (typeToBePartial->IsTypeError()) { - return typeToBePartial; - } - - if (typeToBePartial->IsETSAnyType()) { + if (typeToBePartial->IsTypeError() || typeToBePartial->IsETSNeverType() || typeToBePartial->IsETSAnyType()) { return typeToBePartial; } @@ -249,10 +248,11 @@ ir::ClassProperty *ETSChecker::CreateNullishPropertyFromAccessor(ir::MethodDefin auto *prop = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocator()->New(ident, nullptr, nullptr, modifierFlag, ProgramAllocator(), false); - + ES2PANDA_ASSERT(prop != nullptr); prop->SetParent(newClassDefinition); ident->SetParent(prop); + ES2PANDA_ASSERT(accessor->Function() != nullptr); prop->SetTypeAnnotation(accessor->Function()->IsGetter() ? accessor->Function()->ReturnTypeAnnotation() : accessor->Function()->Params()[0]->AsETSParameterExpression()->TypeAnnotation()); @@ -262,12 +262,10 @@ ir::ClassProperty *ETSChecker::CreateNullishPropertyFromAccessor(ir::MethodDefin return CreateNullishProperty(prop, newClassDefinition); } - if (accessor->TsType() == nullptr) { - accessor->Parent()->Check(this); - } - + ES2PANDA_ASSERT(accessor->TsType()->IsETSFunctionType()); auto callSign = accessor->TsType()->AsETSFunctionType()->CallSignatures()[0]; + ES2PANDA_ASSERT(accessor->Function() != nullptr); auto tsType = accessor->Function()->IsGetter() ? callSign->ReturnType() : callSign->Params()[0]->TsType(); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -455,6 +453,7 @@ ir::ETSTypeReference *ETSChecker::BuildSuperPartialTypeReference( return superPartialRef; } +// CC-OFFNXT(huge_method[C++], G.FUN.01-CPP, G.FUD.05) solid logic void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newClassDefinition, ir::ClassDefinition *classDef) { @@ -508,8 +507,15 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla varbinder::ResolveBindingOptions::VARIABLES) != nullptr) { continue; } - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - newClassDefinition->EmplaceBody(CreateNullishPropertyFromAccessor(method, newClassDefinition)); + + if (method->TsType() == nullptr) { + method->Parent()->Check(this); + } + + if (method->TsType() != nullptr && !method->TsType()->IsTypeError()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + newClassDefinition->EmplaceBody(CreateNullishPropertyFromAccessor(method, newClassDefinition)); + } } } if (classDef->IsDeclare()) { @@ -523,6 +529,36 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla newClassDefinition->Variable()->SetTsType(nullptr); } +static void SetupFunctionParams(ir::ScriptFunction *function, varbinder::FunctionParamScope *paramScope, + checker::ETSChecker *checker) +{ + for (auto *params : function->Params()) { + auto *paramExpr = params->AsETSParameterExpression(); + if (paramExpr->Ident()->TypeAnnotation() == nullptr) { + paramExpr->Ident()->SetTsTypeAnnotation(nullptr); + } else { + auto *unionType = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + checker->ProgramAllocNode( + ArenaVector( + {paramExpr->Ident()->TypeAnnotation(), + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + checker->ProgramAllocNode(checker->ProgramAllocator())}, + checker->ProgramAllocator()->Adapter()), + checker->ProgramAllocator()); + ES2PANDA_ASSERT(unionType != nullptr); + paramExpr->Ident()->SetTsTypeAnnotation(unionType); + unionType->SetParent(paramExpr->Ident()); + } + auto [paramVar, node] = paramScope->AddParamDecl(checker->ProgramAllocator(), checker->VarBinder(), paramExpr); + if (node != nullptr) { + checker->VarBinder()->ThrowRedeclaration(node->Start(), paramVar->Name(), paramVar->Declaration()->Type()); + } + + paramExpr->SetVariable(paramVar); + } +} + // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic ir::MethodDefinition *ETSChecker::CreateNullishAccessor(ir::MethodDefinition *const accessor, ir::TSInterfaceDeclaration *interface) @@ -570,27 +606,8 @@ ir::MethodDefinition *ETSChecker::CreateNullishAccessor(ir::MethodDefinition *co ProgramAllocator()->Adapter()), ProgramAllocator())); } else { - for (auto *params : function->Params()) { - auto *paramExpr = params->AsETSParameterExpression(); - - auto *unionType = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode( - ArenaVector({paramExpr->Ident()->TypeAnnotation(), - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(ProgramAllocator())}, - ProgramAllocator()->Adapter()), - ProgramAllocator()); - paramExpr->Ident()->SetTsTypeAnnotation(unionType); - unionType->SetParent(paramExpr->Ident()); - - auto [paramVar, node] = paramScope->AddParamDecl(ProgramAllocator(), VarBinder(), paramExpr); - if (node != nullptr) { - VarBinder()->ThrowRedeclaration(node->Start(), paramVar->Name(), paramVar->Declaration()->Type()); - } - - paramExpr->SetVariable(paramVar); - } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + SetupFunctionParams(function, paramScope, this); } nullishAccessor->SetOverloads(ArenaVector(ProgramAllocator()->Adapter())); diff --git a/ets2panda/checker/ets/validateHelpers.cpp b/ets2panda/checker/ets/validateHelpers.cpp index feee4a04aa7381f7c5d899f5d5b3168f17f9547a..a0bf21d4d27999d9a2028f848dae48b167269201 100644 --- a/ets2panda/checker/ets/validateHelpers.cpp +++ b/ets2panda/checker/ets/validateHelpers.cpp @@ -51,15 +51,44 @@ void ETSChecker::ValidatePropertyAccess(varbinder::Variable *var, ETSObjectType } } +bool ETSChecker::IsStaticInvoke(ir::MemberExpression *const expr) +{ + ir::Identifier *ident = nullptr; + if (expr->Object()->IsIdentifier()) { + ident = expr->Object()->AsIdentifier(); + } else if (expr->Object()->IsMemberExpression()) { + auto object = expr->Object(); + + while (object->IsMemberExpression()) { + object = object->AsMemberExpression()->Object(); + } + if (object->IsIdentifier()) { + ident = object->AsIdentifier(); + } + } + + return (ident != nullptr && + (ident->Variable()->Declaration()->IsClassDecl() || ident->Variable()->Declaration()->IsImportDecl())); +} + void ETSChecker::ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type) { - if (ident->Variable()->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE) && - ident->Parent()->AsCallExpression()->Callee() != ident) { + ir::CallExpression *callExpr = nullptr; + if (ident->Parent()->IsMemberExpression() && IsStaticInvoke(ident->Parent()->AsMemberExpression())) { + callExpr = ident->Parent()->Parent()->AsCallExpression(); + } else if (ident->Parent()->IsCallExpression()) { + callExpr = ident->Parent()->AsCallExpression(); + } else { + return; + } + + if (ident->Variable()->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE) && callExpr->Callee() != ident && + callExpr->Callee() != ident->Parent()) { std::ignore = TypeError(ident->Variable(), diagnostic::CLASS_OR_IFACE_AS_OBJ, {ident->ToString()}, ident->Start()); } - if (ident->Parent()->AsCallExpression()->Callee() != ident) { + if (callExpr->Callee() != ident && callExpr->Callee() != ident->Parent()) { return; } @@ -203,7 +232,7 @@ void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident) } } -void ETSChecker::ValidateUnaryOperatorOperand(varbinder::Variable *variable) +void ETSChecker::ValidateUnaryOperatorOperand(varbinder::Variable *variable, ir::Expression *expr) { if (IsVariableGetterSetter(variable)) { return; @@ -221,7 +250,7 @@ void ETSChecker::ValidateUnaryOperatorOperand(varbinder::Variable *variable) } if (!HasStatus(CheckerStatus::IN_CONSTRUCTOR | CheckerStatus::IN_STATIC_BLOCK)) { std::ignore = TypeError(variable, diagnostic::FIELD_ASSIGN_TYPE_MISMATCH, {fieldType, variable->Name()}, - variable->Declaration()->Node()->Start()); + expr->Start()); } if (variable->HasFlag(varbinder::VariableFlags::INIT_IN_STATIC_BLOCK)) { diff --git a/ets2panda/checker/ts/destructuringContext.cpp b/ets2panda/checker/ts/destructuringContext.cpp index 62212a8fcac53a0723d372e7ae9608ebbcab3005..7fcbc2e9d905ac4dee37558f8e74a2cdf537f4a7 100644 --- a/ets2panda/checker/ts/destructuringContext.cpp +++ b/ets2panda/checker/ts/destructuringContext.cpp @@ -157,6 +157,7 @@ void DestructuringContext::HandleAssignmentPattern(ir::AssignmentExpression *ass ES2PANDA_ASSERT(defaultType != nullptr); if (validateDefault && assignmentPattern->Right()->IsObjectExpression() && assignmentPattern->Left()->IsObjectPattern()) { + ES2PANDA_ASSERT(defaultType != nullptr); ValidateObjectLiteralType(defaultType->AsObjectType(), assignmentPattern->Left()->AsObjectPattern()); } @@ -332,6 +333,7 @@ Type *ArrayDestructuringContext::CreateTupleTypeForRest(TupleType *tuple) ES2PANDA_ASSERT(memberVar != nullptr); memberVar->SetTsType(tupleElementType); elementFlags.push_back(memberFlag); + ES2PANDA_ASSERT(desc != nullptr); desc->properties.push_back(memberVar); index_++; diff --git a/ets2panda/checker/typeChecker/TypeChecker.cpp b/ets2panda/checker/typeChecker/TypeChecker.cpp index b9977ba38af132168115304b4eba1ef966c98192..aeb0e9e5f51bdbc79f0e6346457e0b3e1810c7ae 100644 --- a/ets2panda/checker/typeChecker/TypeChecker.cpp +++ b/ets2panda/checker/typeChecker/TypeChecker.cpp @@ -18,14 +18,6 @@ namespace ark::es2panda::checker { -void ETSTypeChecker::VisitArrowFunctionExpression(ir::ArrowFunctionExpression *node) -{ - Iterate(node); - if (!node->TsType()->IsETSObjectType()) { - LogError(diagnostic::INFER_FAIL_ON_LAMBDA, {node->TsType()}, node->Start()); - } -} - bool RunTypeChecker(Checker *checker, ScriptExtension ext, ir::AstNode *node) { switch (ext) { diff --git a/ets2panda/checker/typeChecker/TypeChecker.h b/ets2panda/checker/typeChecker/TypeChecker.h index 802f884a5c6a5d19d8dd23ba0a4add9ff72346b7..864753b273ad8713ffc5957a7b5456f8c59b6881 100644 --- a/ets2panda/checker/typeChecker/TypeChecker.h +++ b/ets2panda/checker/typeChecker/TypeChecker.h @@ -50,9 +50,6 @@ private: class ETSTypeChecker : public TypeChecker { public: explicit ETSTypeChecker(Checker *checker) : TypeChecker(checker) {} - -private: - void VisitArrowFunctionExpression(ir::ArrowFunctionExpression *node) override; }; class JSTypeChecker : public TypeChecker { diff --git a/ets2panda/checker/types/ets/etsAnyType.cpp b/ets2panda/checker/types/ets/etsAnyType.cpp index 8f36fb2b2123613809dc8f798044a89eebd61803..ea399276063cd735fb696ab45e416260bd38d9f9 100644 --- a/ets2panda/checker/types/ets/etsAnyType.cpp +++ b/ets2panda/checker/types/ets/etsAnyType.cpp @@ -14,6 +14,7 @@ */ #include "etsAnyType.h" +#include #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" @@ -62,6 +63,7 @@ void ETSAnyType::Cast(TypeRelation *relation, Type *target) if (relation->ApplyUnboxing()) { auto *const boxedTarget = relation->GetChecker()->AsETSChecker()->MaybeBoxInRelation(target); + ES2PANDA_ASSERT(boxedTarget != nullptr); conversion::Unboxing(relation, boxedTarget->AsETSObjectType()); relation->Result(true); } diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 58c4ea3ceade56f550d26cb6b0c7efbf58fbbf10..133c53eee87cf54b4f8942c4cc2f37457b5baf8b 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -56,9 +56,8 @@ ETSFunctionType::ETSFunctionType(ETSChecker *checker, Signature *signature) } // #22951: proper this type implementation -static void HackThisParameterInExtensionFunctionInvoke(ETSObjectType *interface, size_t arity) +static void HackThisParameterInExtensionFunctionInvoke(ETSObjectType *interface, std::string &invokeName) { - auto invokeName = FunctionalInterfaceInvokeName(arity, false); auto *property = interface->AsETSObjectType()->GetOwnProperty( util::StringView(invokeName)); ES2PANDA_ASSERT(property != nullptr); @@ -79,7 +78,13 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, auto sigParamsSize = signature->Params().size(); auto nPosParams = arity < sigParamsSize ? arity : sigParamsSize; auto *functionN = checker->GlobalBuiltinFunctionType(nPosParams, true); + + if (nPosParams >= checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold()) { + return functionN; + } + auto substitution = Substitution {}; + ES2PANDA_ASSERT(functionN != nullptr); for (size_t i = 0; i < nPosParams; i++) { substitution.emplace(functionN->TypeArguments()[i]->AsETSTypeParameter(), checker->MaybeBoxType(signature->Params()[i]->TsType())); @@ -98,14 +103,12 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, ES2PANDA_ASSERT(arity >= signature->MinArgCount() && arity <= signature->ArgCount()); - // Note: FunctionN is not supported yet + auto *funcIface = checker->GlobalBuiltinFunctionType(arity, false); if (arity >= checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold()) { - return nullptr; + return funcIface; } - auto *funcIface = checker->GlobalBuiltinFunctionType(arity, false); auto substitution = Substitution {}; - for (size_t i = 0; i < arity; i++) { substitution.emplace(funcIface->TypeArguments()[i]->AsETSTypeParameter(), checker->MaybeBoxType(signature->Params()[i]->TsType())); @@ -115,7 +118,8 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, auto result = funcIface->Substitute(checker->Relation(), &substitution, true, isExtensionHack); if (signature->HasSignatureFlag(SignatureFlags::THIS_RETURN_TYPE)) { - HackThisParameterInExtensionFunctionInvoke(result, arity); + auto invokeName = checker->FunctionalInterfaceInvokeName(arity, false); + HackThisParameterInExtensionFunctionInvoke(result, invokeName); } result->AddObjectFlag(checker::ETSObjectFlags::FUNCTIONAL); @@ -194,11 +198,17 @@ static Signature *EnhanceSignatureSubstitution(TypeRelation *relation, Signature return nullptr; } } + + if (!enhance(sub->ReturnType(), super->ReturnType())) { + return nullptr; + } + if (super->RestVar() != nullptr) { if (!enhance(sub->RestVar()->TsType(), super->RestVar()->TsType())) { return nullptr; } } + return sub->Substitute(relation, &substitution); } diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 9834924f2eac763cbd88ea9a3775de8f1a16d6eb..1d42b6745b67e535f5e49972712ccb531f04eec8 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -211,15 +211,51 @@ static void UpdateDeclarationForGetterSetter(varbinder::LocalVariable *res, cons res->Reset(decl, var->Flags()); } +static PropertySearchFlags UpdateOverloadDeclarationSearchFlags(const PropertySearchFlags &flags) +{ + if ((flags & PropertySearchFlags::IGNORE_OVERLOAD) != 0) { + return flags; + } + PropertySearchFlags syntheticFlags = flags; + if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) != 0) { + syntheticFlags &= ~PropertySearchFlags::SEARCH_INSTANCE_METHOD; + syntheticFlags |= PropertySearchFlags::SEARCH_INSTANCE_DECL; + } + if ((flags & PropertySearchFlags::SEARCH_STATIC_METHOD) != 0) { + syntheticFlags &= ~PropertySearchFlags::SEARCH_STATIC_METHOD; + syntheticFlags |= PropertySearchFlags::SEARCH_STATIC_DECL; + } + return syntheticFlags; +} + +static PropertySearchFlags UpdateMethodSearchFlags(const PropertySearchFlags &flags) +{ + if ((flags & PropertySearchFlags::IGNORE_OVERLOAD) != 0) { + return flags; + } + PropertySearchFlags syntheticFlags = flags; + if ((flags & PropertySearchFlags::SEARCH_INSTANCE_DECL) != 0) { + syntheticFlags &= ~PropertySearchFlags::SEARCH_INSTANCE_DECL; + syntheticFlags |= PropertySearchFlags::SEARCH_INSTANCE_METHOD; + } + if ((flags & PropertySearchFlags::SEARCH_STATIC_DECL) != 0) { + syntheticFlags &= ~PropertySearchFlags::SEARCH_STATIC_DECL; + syntheticFlags |= PropertySearchFlags::SEARCH_STATIC_METHOD; + } + return syntheticFlags; +} + varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(const util::StringView &name, PropertySearchFlags flags) const { std::vector signatures; // Since both "first match" and "best match" exist at present, overloadDeclarationCall is temporarily used. After // "best match" removed, this marking needs to be removed. - bool overloadDeclarationCall = false; - varbinder::LocalVariable *functionalInterface = - CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); + auto *overloadDeclaration = SearchFieldsDecls(name, UpdateOverloadDeclarationSearchFlags(flags)); + bool overloadDeclarationCall = overloadDeclaration != nullptr; + PropertySearchFlags syntheticFlags = overloadDeclarationCall ? UpdateOverloadDeclarationSearchFlags(flags) : flags; + + varbinder::LocalVariable *functionalInterface = CollectSignaturesForSyntheticType(signatures, name, syntheticFlags); // #22952: the called function *always* returns nullptr ES2PANDA_ASSERT(functionalInterface == nullptr); (void)functionalInterface; @@ -243,6 +279,10 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co res->SetTsType(funcType); funcType->SetVariable(res); + if (overloadDeclarationCall) { + res->Reset(overloadDeclaration->Declaration(), res->Flags()); + } + UpdateDeclarationForGetterSetter(res, funcType, flags); return res; @@ -279,6 +319,10 @@ bool ETSObjectType::ReplaceArgumentInSignature(std::vector &signatu void ETSObjectType::AddSignatureFromFunction(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, varbinder::LocalVariable *found) const { + if (found == nullptr || !found->TsType()->IsETSFunctionType()) { + return; + } + for (auto *it : found->TsType()->AsETSFunctionType()->CallSignatures()) { if (std::find(signatures.begin(), signatures.end(), it) != signatures.end()) { continue; @@ -294,15 +338,19 @@ void ETSObjectType::AddSignatureFromFunction(std::vector &signature } void ETSObjectType::AddSignatureFromOverload(std::vector &signatures, PropertySearchFlags flags, - varbinder::LocalVariable *found, bool &overloadDeclarationCall) const + varbinder::LocalVariable *found) const { + if (found == nullptr || !found->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + return; + } + + ES2PANDA_ASSERT(found->Declaration()->Node()->IsOverloadDeclaration()); auto *overloadDeclaration = found->Declaration()->Node()->AsOverloadDeclaration(); std::vector methodSignature; if (overloadDeclaration->Id()->IsErrorPlaceHolder()) { return; } - overloadDeclarationCall |= true; if (overloadDeclaration->IsConstructorOverloadDeclaration()) { return AddSignatureFromConstructor(signatures, found); } @@ -312,7 +360,7 @@ void ETSObjectType::AddSignatureFromOverload(std::vector &signature methodSignature.clear(); util::StringView methodName = method->IsIdentifier() ? method->AsIdentifier()->Name() : method->AsTSQualifiedName()->Right()->Name(); - CollectSignaturesForSyntheticType(methodSignature, methodName, flags, overloadDeclarationCall); + CollectSignaturesForSyntheticType(methodSignature, methodName, UpdateMethodSearchFlags(flags)); if (!methodSignature.empty()) { signatures.emplace_back(methodSignature.front()); } @@ -339,48 +387,43 @@ void ETSObjectType::AddSignatureFromConstructor(std::vector &signat } } -void ETSObjectType::AddSignature(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, - varbinder::LocalVariable *found, bool &overloadDeclarationCall) const -{ - if (found != nullptr && found->HasFlag(varbinder::VariableFlags::OVERLOAD)) { - if (!found->Declaration()->Node()->IsOverloadDeclaration()) { - return; - } - AddSignatureFromOverload(signatures, flags, found, overloadDeclarationCall); - } else if (found != nullptr && !found->TsType()->IsTypeError()) { - ES2PANDA_ASSERT(found->TsType()->IsETSFunctionType()); - AddSignatureFromFunction(signatures, flags, checker, found); - } -} - varbinder::LocalVariable *ETSObjectType::CollectSignaturesForSyntheticType(std::vector &signatures, const util::StringView &name, - PropertySearchFlags flags, - bool &overloadDeclarationCall) const + PropertySearchFlags flags) const { auto *checker = GetRelation()->GetChecker()->AsETSChecker(); if ((flags & PropertySearchFlags::SEARCH_STATIC_METHOD) != 0) { auto *found = GetOwnProperty(name); - AddSignature(signatures, flags, checker, found, overloadDeclarationCall); + AddSignatureFromFunction(signatures, flags, checker, found); } if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) != 0) { auto *found = GetOwnProperty(name); - AddSignature(signatures, flags, checker, found, overloadDeclarationCall); + AddSignatureFromFunction(signatures, flags, checker, found); + } + + if ((flags & PropertySearchFlags::SEARCH_STATIC_DECL) != 0) { + auto *found = GetOwnProperty(name); + AddSignatureFromOverload(signatures, flags, found); + } + + if ((flags & PropertySearchFlags::SEARCH_INSTANCE_DECL) != 0) { + auto *found = GetOwnProperty(name); + AddSignatureFromOverload(signatures, flags, found); } - if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) == 0) { + if ((flags & PropertySearchFlags::SEARCH_METHOD) == 0 && (flags & PropertySearchFlags::SEARCH_DECL) == 0) { return nullptr; } if (superType_ != nullptr && ((flags & PropertySearchFlags::SEARCH_IN_BASE) != 0)) { - superType_->CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); + superType_->CollectSignaturesForSyntheticType(signatures, name, flags); } if ((flags & PropertySearchFlags::SEARCH_IN_INTERFACES) != 0) { for (auto *interface : Interfaces()) { - interface->CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); + interface->CollectSignaturesForSyntheticType(signatures, name, flags); } } @@ -710,12 +753,12 @@ void ETSObjectType::AssignmentTarget(TypeRelation *const relation, Type *source) ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const { ES2PANDA_ASSERT(HasObjectFlag(ETSObjectFlags::FUNCTIONAL)); + auto checker = GetRelation()->GetChecker()->AsETSChecker(); // NOTE(vpukhov): this is still better than to retain any "functional" state in ETSObjectType - auto [foundArity, hasRest] = [this]() { - auto checker = GetRelation()->GetChecker()->AsETSChecker(); + auto [foundArity, hasRest] = [this, checker]() { auto baseType = GetConstOriginalBaseType(); - for (size_t arity = 0; arity < checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold(); ++arity) { + for (size_t arity = 0; arity <= checker->GlobalBuiltinFunctionTypeVariadicThreshold(); ++arity) { if (auto itf = checker->GlobalBuiltinFunctionType(arity, false); itf == baseType) { return std::make_pair(arity, false); } @@ -726,8 +769,9 @@ ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const ES2PANDA_UNREACHABLE(); }(); - std::string invokeName = FunctionalInterfaceInvokeName(foundArity, hasRest); - auto *invoke = GetOwnProperty(util::StringView(invokeName)); + std::string invokeName = checker->FunctionalInterfaceInvokeName(foundArity, hasRest); + auto *invoke = GetProperty(util::StringView(invokeName), + PropertySearchFlags::SEARCH_INSTANCE_METHOD | PropertySearchFlags::SEARCH_IN_INTERFACES); ES2PANDA_ASSERT(invoke != nullptr && invoke->TsType() != nullptr && invoke->TsType()->IsETSFunctionType()); return invoke->TsType()->AsETSFunctionType(); } diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index 2f81c4be7c98481b663be75eb3c0a94a6bb28383..5cd5fd394161155059a2033255c764ed7ad68ad4 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -262,6 +262,12 @@ public: return (flags_ & flag) != 0; } + bool IsETSStringLiteralType() const + { + return superType_ != nullptr && superType_->IsETSObjectType() && + superType_->HasObjectFlag(ETSObjectFlags::STRING); + } + ETSFunctionType *GetFunctionalInterfaceInvokeType() const; ETSObjectFlags BuiltInKind() const @@ -348,14 +354,12 @@ public: varbinder::LocalVariable *CreateSyntheticVarFromEverySignature(const util::StringView &name, PropertySearchFlags flags) const; varbinder::LocalVariable *CollectSignaturesForSyntheticType(std::vector &signatures, - const util::StringView &name, PropertySearchFlags flags, - bool &overloadDeclarationCall) const; - void AddSignature(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, - varbinder::LocalVariable *found, bool &overloadDeclarationCall) const; + const util::StringView &name, + PropertySearchFlags flags) const; void AddSignatureFromFunction(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, varbinder::LocalVariable *found) const; void AddSignatureFromOverload(std::vector &signatures, PropertySearchFlags flags, - varbinder::LocalVariable *found, bool &overloadDeclarationCall) const; + varbinder::LocalVariable *found) const; void AddSignatureFromConstructor(std::vector &signatures, varbinder::LocalVariable *found) const; bool ReplaceArgumentInSignature(std::vector &signatures, Signature *sigToInsert, TypeRelation *relation) const; diff --git a/ets2panda/checker/types/ets/etsObjectTypeConstants.h b/ets2panda/checker/types/ets/etsObjectTypeConstants.h index a13f0d46855cb24e9979b6690211803af8200293..b3a4e93f35c0672ccd9053edd73c7b07650a9c12 100644 --- a/ets2panda/checker/types/ets/etsObjectTypeConstants.h +++ b/ets2panda/checker/types/ets/etsObjectTypeConstants.h @@ -54,13 +54,14 @@ enum class ETSObjectFlags : std::uint64_t { BUILTIN_FLOAT = 1U << 30U, BUILTIN_DOUBLE = 1U << 31U, BUILTIN_ARRAY = 1ULL << 32U, + BUILTIN_READONLY_ARRAY = 1ULL << 33U, - INT_ENUM_OBJECT = 1ULL << 33U, - STRING_ENUM_OBJECT = 1ULL << 34U, + INT_ENUM_OBJECT = 1ULL << 34U, + STRING_ENUM_OBJECT = 1ULL << 35U, - EXTENSION_FUNCTION = 1ULL << 35U, - FUNCTIONAL_REFERENCE = 1ULL << 36U, - LAZY_IMPORT_OBJECT = 1ULL << 37U, + EXTENSION_FUNCTION = 1ULL << 36U, + FUNCTIONAL_REFERENCE = 1ULL << 37U, + LAZY_IMPORT_OBJECT = 1ULL << 38U, ENUM_OBJECT = INT_ENUM_OBJECT | STRING_ENUM_OBJECT, @@ -100,6 +101,7 @@ enum class PropertySearchFlags : std::uint32_t { DISALLOW_SYNTHETIC_METHOD_CREATION = 1U << 10U, IS_SETTER = 1U << 11U, IS_GETTER = 1U << 12U, + IGNORE_OVERLOAD = 1U << 13U, SEARCH_INSTANCE = SEARCH_INSTANCE_FIELD | SEARCH_INSTANCE_METHOD | SEARCH_INSTANCE_DECL, SEARCH_STATIC = SEARCH_STATIC_FIELD | SEARCH_STATIC_METHOD | SEARCH_STATIC_DECL, @@ -120,12 +122,6 @@ enum class PropertyType { COUNT, }; -/* Invoke method name in functional interfaces */ -inline std::string FunctionalInterfaceInvokeName(size_t arity, bool hasRest) -{ - return (hasRest ? "invokeR" : "invoke") + std::to_string(arity); -} - } // namespace ark::es2panda::checker namespace enumbitops { diff --git a/ets2panda/checker/types/ets/etsStringType.h b/ets2panda/checker/types/ets/etsStringType.h index ab6b6e07608388106a8f0b8b2fc043fbffb6f6c5..40595517acbb04c5404a68a828a6f2674bc8ffc2 100644 --- a/ets2panda/checker/types/ets/etsStringType.h +++ b/ets2panda/checker/types/ets/etsStringType.h @@ -22,7 +22,7 @@ namespace ark::es2panda::checker { class ETSStringType : public ETSObjectType { public: explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super) - : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, nullptr, + : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, super->GetDeclNode(), ETSObjectFlags::CLASS | ETSObjectFlags::STRING | ETSObjectFlags::RESOLVED_SUPER) { SetSuperType(super); @@ -30,7 +30,7 @@ public: explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, - std::make_tuple(nullptr, + std::make_tuple(super->GetDeclNode(), ETSObjectFlags::CLASS | ETSObjectFlags::STRING | ETSObjectFlags::RESOLVED_SUPER, relation)) { @@ -40,7 +40,7 @@ public: explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, util::StringView value) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, - std::make_tuple(nullptr, + std::make_tuple(super->GetDeclNode(), ETSObjectFlags::CLASS | ETSObjectFlags::STRING | ETSObjectFlags::RESOLVED_SUPER, relation)), value_(value) diff --git a/ets2panda/checker/types/ets/etsTypeAliasType.cpp b/ets2panda/checker/types/ets/etsTypeAliasType.cpp index e1e05bdb25bd611438881d21390abebceeb530df..c4394f5da3fe266019bd75c6910978978d6bd18b 100644 --- a/ets2panda/checker/types/ets/etsTypeAliasType.cpp +++ b/ets2panda/checker/types/ets/etsTypeAliasType.cpp @@ -250,7 +250,8 @@ bool ETSTypeAliasType::SubstituteTypeArgs(TypeRelation *const relation, ArenaVec for (auto *const arg : typeArguments_) { auto *const newArg = arg->Substitute(relation, substitution); - newTypeArgs.push_back(newArg); + ES2PANDA_ASSERT(newArg->IsETSReferenceType()); + newTypeArgs.emplace_back(newArg); anyChange = anyChange || (newArg != arg); } diff --git a/ets2panda/checker/types/ets/etsTypeParameter.cpp b/ets2panda/checker/types/ets/etsTypeParameter.cpp index ebb370321da70c44aa3855509d3387f22c3d2244..53c70fcfcc2cc884654aae6c0b78e1453262d4a5 100644 --- a/ets2panda/checker/types/ets/etsTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsTypeParameter.cpp @@ -141,8 +141,14 @@ Type *ETSTypeParameter::Substitute([[maybe_unused]] TypeRelation *relation, cons if (substitution == nullptr || substitution->empty()) { return this; } - if (auto repl = substitution->find(GetOriginal()); repl != substitution->end()) { - // 22955: The result is sometimes primitve. Can be reproduced for type aliases + + auto *type = GetDeclNode()->Name()->Variable()->TsType(); + if (type->IsTypeError()) { + return this; + } + + if (auto repl = substitution->find(type->AsETSTypeParameter()); repl != substitution->end()) { + ES2PANDA_ASSERT(repl->second->IsETSReferenceType()); return repl->second; } return this; @@ -158,7 +164,7 @@ void ETSTypeParameter::ToDebugInfoType(std::stringstream &ss) const GetConstraintType()->ToDebugInfoType(ss); } -ETSTypeParameter *ETSTypeParameter::GetOriginal() const noexcept +ETSTypeParameter *ETSTypeParameter::GetOriginal() const { return GetDeclNode()->Name()->Variable()->TsType()->AsETSTypeParameter(); } diff --git a/ets2panda/checker/types/ets/etsTypeParameter.h b/ets2panda/checker/types/ets/etsTypeParameter.h index d38b1b7b1d11ac0349d5ceb04e8d4b8916fc91f0..7eb6908b4b6ed65630b2a4553d4d35ba362cbae8 100644 --- a/ets2panda/checker/types/ets/etsTypeParameter.h +++ b/ets2panda/checker/types/ets/etsTypeParameter.h @@ -38,7 +38,7 @@ public: return declNode_; } - [[nodiscard]] ETSTypeParameter *GetOriginal() const noexcept; + [[nodiscard]] ETSTypeParameter *GetOriginal() const; [[nodiscard]] util::StringView const &Name() const noexcept; void SetDefaultType(Type *type) noexcept diff --git a/ets2panda/checker/types/ets/etsUnionType.cpp b/ets2panda/checker/types/ets/etsUnionType.cpp index 3bfeecc8cc9282d8c9d2cd9a936db99701553574..97b5f76d8bd976d910878cb9f7089e0866f5bf64 100644 --- a/ets2panda/checker/types/ets/etsUnionType.cpp +++ b/ets2panda/checker/types/ets/etsUnionType.cpp @@ -351,7 +351,7 @@ void ETSUnionType::CheckVarianceRecursively(TypeRelation *relation, VarianceFlag // ATTENTION! When calling this method we assume that 'AssignmentTarget(...)' check was passes successfully, // thus the required assignable type (or corresponding supertype) always exists. checker::Type *ETSUnionType::GetAssignableType(checker::ETSChecker *checker, checker::Type *sourceType, - [[maybe_unused]] std::optional value) const noexcept + [[maybe_unused]] std::optional value) const { for (auto *ctype : ConstituentTypes()) { if (checker->Relation()->IsSupertypeOf(ctype, sourceType)) { @@ -380,7 +380,7 @@ checker::Type *ETSUnionType::GetAssignableType(checker::ETSChecker *checker, che checker::Type *ETSUnionType::GetAssignableBuiltinType( checker::ETSChecker *checker, checker::ETSObjectType *sourceType, - std::map &numericTypes) const noexcept + std::map &numericTypes) const { for (auto *constituentType : constituentTypes_) { if (!constituentType->IsETSObjectType() && !constituentType->IsETSTupleType()) { @@ -405,7 +405,6 @@ checker::Type *ETSUnionType::GetAssignableBuiltinType( bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::Type *source, ArenaVector &unionTypes) noexcept { - std::map::const_iterator> numericTypes {}; source = checker->GetNonConstantType(source); bool rc = false; @@ -433,25 +432,12 @@ bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::Type *sour if (checker->Relation()->IsSupertypeOf(constituentType, source)) { rc = true; - } else if (!rc && constituentType->IsBuiltinNumeric()) { - if (auto const id = ETSObjectType::GetPrecedence(checker, constituentType->AsETSObjectType()); id > 0U) { - numericTypes.emplace(id, it); - } } ++it; } - if (rc) { - return true; - } - - if (source->IsBuiltinNumeric() && !numericTypes.empty()) { - unionTypes.erase((*std::prev(numericTypes.end())).second); - return true; - } - - return false; + return rc; } std::pair ETSUnionType::GetComplimentaryType(ETSChecker *const checker, diff --git a/ets2panda/checker/types/ets/etsUnionType.h b/ets2panda/checker/types/ets/etsUnionType.h index 71c9ac8601f4de50b818fac6c149ee28950068cb..0ae2e8a38bdf30728e7547aefc0292a7dea020fe 100644 --- a/ets2panda/checker/types/ets/etsUnionType.h +++ b/ets2panda/checker/types/ets/etsUnionType.h @@ -85,7 +85,7 @@ public: } [[nodiscard]] checker::Type *GetAssignableType(ETSChecker *checker, checker::Type *sourceType, - std::optional value) const noexcept; + std::optional value) const; [[nodiscard]] std::pair GetComplimentaryType(ETSChecker *checker, checker::Type *sourceType); @@ -102,7 +102,7 @@ private: [[nodiscard]] checker::Type *GetAssignableBuiltinType( checker::ETSChecker *checker, checker::ETSObjectType *sourceType, - std::map &numericTypes) const noexcept; + std::map &numericTypes) const; void CanonicalizedAssemblerType(ETSChecker *checker); void InitAssemblerTypeCache(ETSChecker *checker); diff --git a/ets2panda/checker/types/globalTypesHolder.cpp b/ets2panda/checker/types/globalTypesHolder.cpp index 1a3dd612203487fdf9636bb105b19026846b5efa..4bf67257acbf5114f924961e48c1706fdf6dca53 100644 --- a/ets2panda/checker/types/globalTypesHolder.cpp +++ b/ets2panda/checker/types/globalTypesHolder.cpp @@ -58,6 +58,7 @@ void GlobalTypesHolder::AddETSEscompatLayer() { // ETS escompat layer builtinNameMappings_.emplace("Array", GlobalTypeId::ETS_ARRAY_BUILTIN); + builtinNameMappings_.emplace("ReadonlyArray", GlobalTypeId::ETS_READONLY_ARRAY); builtinNameMappings_.emplace("Date", GlobalTypeId::ETS_DATE_BUILTIN); builtinNameMappings_.emplace("Error", GlobalTypeId::ETS_ERROR_BUILTIN); builtinNameMappings_.emplace("DivideByZeroError", GlobalTypeId::ETS_DIVIDE_BY_ZERO_ERROR_BUILTIN); @@ -85,7 +86,7 @@ void GlobalTypesHolder::AddFunctionTypes(ArenaAllocator *allocator) addTypes("LambdaR", GlobalTypeId::ETS_LAMBDAR0_CLASS, GlobalTypeId::ETS_LAMBDAR16_CLASS); builtinNameMappings_.emplace("FunctionN", GlobalTypeId::ETS_FUNCTIONN_CLASS); - builtinNameMappings_.emplace("LambdaN", GlobalTypeId::ETS_FUNCTIONN_CLASS); + builtinNameMappings_.emplace("LambdaN", GlobalTypeId::ETS_LAMBDAN_CLASS); } void GlobalTypesHolder::AddTupleTypes(ArenaAllocator *allocator) @@ -634,6 +635,11 @@ Type *GlobalTypesHolder::GlobalArrayBuiltinType() return globalTypes_.at(static_cast(GlobalTypeId::ETS_ARRAY_BUILTIN)); } +Type *GlobalTypesHolder::GlobalReadonlyArray() +{ + return globalTypes_.at(static_cast(GlobalTypeId::ETS_READONLY_ARRAY)); +} + Type *GlobalTypesHolder::GlobalBoxBuiltinType() { return globalTypes_.at(static_cast(GlobalTypeId::ETS_BOX_BUILTIN)); diff --git a/ets2panda/checker/types/globalTypesHolder.h b/ets2panda/checker/types/globalTypesHolder.h index 16d39147b08f7c7280db47bf3362ccff000bba4b..14e5a384237cd6756970b9da46172f960cf98ef3 100644 --- a/ets2panda/checker/types/globalTypesHolder.h +++ b/ets2panda/checker/types/globalTypesHolder.h @@ -16,7 +16,6 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_GLOBAL_TYPES_HOLDER_H #define ES2PANDA_COMPILER_CHECKER_TYPES_GLOBAL_TYPES_HOLDER_H -#include "ir/astNodeFlags.h" #include "checker/types/type.h" namespace ark::es2panda::checker { @@ -116,6 +115,7 @@ enum class GlobalTypeId : std::size_t { ETS_BIG_INT_BUILTIN, ETS_BIG_INT, ETS_ARRAY, + ETS_READONLY_ARRAY, ETS_FUNCTION0_CLASS, ETS_FUNCTION1_CLASS, @@ -328,6 +328,7 @@ public: // ETS escompat layer Type *GlobalArrayBuiltinType(); + Type *GlobalReadonlyArray(); Type *GlobalAssertionErrorBuiltinType(); Type *GlobalDivideByZeroErrorBuiltinType(); Type *GlobalNullPointerErrorBuiltinType(); diff --git a/ets2panda/checker/types/type.cpp b/ets2panda/checker/types/type.cpp index 61a6b8568e82040ac0fe3ebbed737ee8846d6c40..694499259016b06b0bea17986aa1a3dc766f89e3 100644 --- a/ets2panda/checker/types/type.cpp +++ b/ets2panda/checker/types/type.cpp @@ -30,6 +30,11 @@ bool Type::IsETSResizableArrayType() const return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_ARRAY); } +bool Type::IsETSReadonlyArrayType() const +{ + return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_READONLY_ARRAY); +} + bool Type::IsETSStringType() const { return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::STRING); diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index 3840d6ab66b98a8570b957cad0c6b5cde073c655..b0565a97d768a97e48fe6ff99f1413f9df69d67a 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -79,12 +79,20 @@ public: /* CC-OFFNXT(G.PRE.02) name part*/ \ typeName *As##typeName() \ { \ + if (IsTypeError()) { \ + LOG(INFO, ES2PANDA) << "Erroneous cast to '" << #typeName << "' type."; \ + throw std::exception(); \ + } \ ES2PANDA_ASSERT(Is##typeName()); \ /* CC-OFFNXT(G.PRE.05) The macro is used to generate a function. Return is needed*/ \ return reinterpret_cast(this); /* CC-OFF(G.PRE.02) name part*/ \ } \ const typeName *As##typeName() const \ { \ + if (IsTypeError()) { \ + LOG(INFO, ES2PANDA) << "Erroneous cast to '" << #typeName << "' type."; \ + throw std::exception(); \ + } \ ES2PANDA_ASSERT(Is##typeName()); \ /* CC-OFFNXT(G.PRE.05) The macro is used to generate a function. Return is needed*/ \ return reinterpret_cast(this); \ @@ -93,6 +101,7 @@ public: #undef TYPE_AS_CASTS bool IsETSResizableArrayType() const; + bool IsETSReadonlyArrayType() const; bool IsETSStringType() const; bool IsETSCharType() const; bool IsETSBigIntType() const; @@ -165,6 +174,11 @@ public: return HasTypeFlag(checker::TypeFlag::CONSTANT); } + bool IsAnyETSArrayOrTupleType() const + { + return IsETSArrayType() || IsETSResizableArrayType() || IsETSReadonlyArrayType() || IsETSTupleType(); + } + Type *MaybeBaseTypeOfGradualType(); TypeFlag TypeFlags() const diff --git a/ets2panda/checker/types/typeError.h b/ets2panda/checker/types/typeError.h index 9b2d87c4075983d6df1c4a553fad6b2c8f7b3a55..df378a1fa6a7f5954c2dcfee7fe5bbf3b4747588 100644 --- a/ets2panda/checker/types/typeError.h +++ b/ets2panda/checker/types/typeError.h @@ -42,8 +42,52 @@ public: { ss << ERROR_TYPE; } + + Type *Instantiate([[maybe_unused]] ArenaAllocator *allocator, [[maybe_unused]] TypeRelation *relation, + [[maybe_unused]] GlobalTypesHolder *globalTypes) override + { + return this; + } }; } // namespace ark::es2panda::checker +// NOLINTBEGIN(cppcoreguidelines-macro-usage) +#define EMPTY_VALUE + +// CC-OFFNXT(G.PRE.02-CPP) TypeError handling macro definition +#define ERROR_SANITY_CHECK(etsChecker, test, whatIfFails) \ + if (!(test)) { \ + ES2PANDA_ASSERT((etsChecker)->IsAnyError()); \ + whatIfFails; \ + } + +// CC-OFFNXT(G.PRE.02-CPP) TypeError handling macro definition +#define ERROR_TYPE_CHECK(etsChecker, testType, whatIfError) \ + ES2PANDA_ASSERT((testType) != nullptr); \ + if ((testType)->IsTypeError()) { \ + ES2PANDA_ASSERT((etsChecker)->IsAnyError()); \ + whatIfError; \ + } + +// CC-OFFNXT(G.PRE.02-CPP) TypeError handling macro definition +#define FORWARD_TYPE_ERROR(etsChecker, testType, target) \ + ES2PANDA_ASSERT((testType) != nullptr); \ + if ((testType)->IsTypeError()) { \ + ES2PANDA_ASSERT((etsChecker)->IsAnyError()); \ + /* CC-OFFNXT(G.PRE.05) error handling. */ \ + return (target)->SetTsType((etsChecker)->GlobalTypeError()); \ + } + +// CC-OFFNXT(G.PRE.02-CPP) TypeError handling macro definition +#define FORWARD_VALUE_ON_TYPE_ERROR(etsChecker, testType, target, value) \ + ES2PANDA_ASSERT((testType) != nullptr); \ + if ((testType)->IsTypeError()) { \ + ES2PANDA_ASSERT((etsChecker)->IsAnyError()); \ + (target)->SetTsType((etsChecker)->GlobalTypeError()); \ + /* CC-OFFNXT(G.PRE.05) error handling. */ \ + return value; \ + } +// NOLINTEND(cppcoreguidelines-macro-usage) + #endif diff --git a/ets2panda/checker/types/typeRelation.cpp b/ets2panda/checker/types/typeRelation.cpp index d6de75572207b5695a3c3cba510f209f23562674..c4b2fbb0869b7b727e396bd6b0eafb50eb559609 100644 --- a/ets2panda/checker/types/typeRelation.cpp +++ b/ets2panda/checker/types/typeRelation.cpp @@ -154,6 +154,8 @@ bool TypeRelation::IsAssignableTo(Type *source, Type *target) bool TypeRelation::IsComparableTo(Type *source, Type *target) { result_ = CacheLookup(source, target, checker_->ComparableResults(), RelationType::COMPARABLE); + ES2PANDA_ASSERT(source != nullptr); + ES2PANDA_ASSERT(target != nullptr); if (result_ == RelationResult::CACHE_MISS) { if (IsAssignableTo(source, target)) { return true; @@ -161,6 +163,7 @@ bool TypeRelation::IsComparableTo(Type *source, Type *target) result_ = RelationResult::FALSE; target->Compare(this, source); + ES2PANDA_ASSERT(source != nullptr); auto key = RelationHolder::MakeKey(source->Id(), target->Id()); checker_->ComparableResults().Insert(key, {result_, RelationType::COMPARABLE}); } diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index 1ae778a945176e180d5322d98fa8776da71b1814..852eb72ba2fbe9f75eaa01bd76326b106a6a5c3c 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.cpp @@ -320,10 +320,10 @@ void ETSLReference::SetValueGetterSetter(const ir::MemberExpression *memberExpr) { ES2PANDA_ASSERT(memberExpr->PropVar() != nullptr); const auto *sig = memberExpr->PropVar()->TsType()->AsETSFunctionType()->FindSetter(); + ES2PANDA_ASSERT(sig->Function() != nullptr); auto argReg = etsg_->AllocReg(); etsg_->StoreAccumulator(Node(), argReg); - ES2PANDA_ASSERT(sig->Function() != nullptr); if (sig->Function()->IsStatic()) { etsg_->CallExact(Node(), sig->InternalName(), argReg); } else if (memberExpr->Object()->IsSuperExpression()) { diff --git a/ets2panda/compiler/core/CFG.cpp b/ets2panda/compiler/core/CFG.cpp index d1e62215e0ce57411bba4c82e0486d888ec68346..701a766ef76d6906c28549e7b1959abe55aa113f 100644 --- a/ets2panda/compiler/core/CFG.cpp +++ b/ets2panda/compiler/core/CFG.cpp @@ -201,6 +201,7 @@ CFG::BasicBlock *CFG::Build(ir::ScriptFunction *scriptFunctionNode) } BasicBlock *entryBB = CreateNewBB({}); + ES2PANDA_ASSERT(entryBB != nullptr); entryBB->SetFlag(BasicBlockFlags::ENTRY); functionNodeBBMap_[scriptFunctionNode] = entryBB; if (scriptFunctionNode->Id() != nullptr) { @@ -507,6 +508,7 @@ CFG::BasicBlock *CFG::Build(ir::WhileStatement *whileStatementNode, BasicBlock * { ++inLoop_; auto testBB = CreateNewBB({bb}); + ES2PANDA_ASSERT(testBB != nullptr); testBB->SetFlag(BasicBlockFlags::CONDITION); --inLoop_; auto falseBB = CreateNewBB({testBB}, {&falseLabel_}); @@ -515,6 +517,7 @@ CFG::BasicBlock *CFG::Build(ir::WhileStatement *whileStatementNode, BasicBlock * bb = Build(whileStatementNode->Test(), testBB); auto trueBB = CreateNewBB({bb}, {&trueLabel_}); trueBB = Build(whileStatementNode->Body(), trueBB); + ES2PANDA_ASSERT(trueBB != nullptr); trueBB->AddSuccessor(testBB); --inLoop_; return falseBB; @@ -525,12 +528,14 @@ CFG::BasicBlock *CFG::Build(ir::DoWhileStatement *doWhileStatementNode, BasicBlo ++inLoop_; auto bodyBB = CreateNewBB({bb}); auto testBB = CreateNewBB({}); + ES2PANDA_ASSERT(testBB != nullptr); testBB->SetFlag(BasicBlockFlags::CONDITION); --inLoop_; auto falseBB = CreateNewBB({testBB}, {&falseLabel_}); ++inLoop_; loopStmtJumpTargetMap_[doWhileStatementNode] = std::make_pair(testBB, falseBB); bb = Build(doWhileStatementNode->Body(), bodyBB); + ES2PANDA_ASSERT(bb != nullptr); testBB = Build(doWhileStatementNode->Test(), testBB); bb->AddSuccessor(testBB); AddBBEdge(testBB, bodyBB, &trueLabel_); @@ -636,6 +641,7 @@ CFG::BasicBlock *CFG::Build(ir::ForOfStatement *forOfStatementNode, BasicBlock * loopStmtJumpTargetMap_[forOfStatementNode] = std::make_pair(bb, nextBB); bb = Build(forOfStatementNode->Body(), bb); --inLoop_; + ES2PANDA_ASSERT(bb != nullptr); bb->AddSuccessor(loopBB); bb->AddSuccessor(nextBB); return nextBB; @@ -656,6 +662,7 @@ CFG::BasicBlock *CFG::Build(ir::ForUpdateStatement *forUpdateStatementNode, Basi testBB = Build(forUpdateStatementNode->Test(), testBB); auto bodyBB = Build(forUpdateStatementNode->Body(), trueBB); bodyBB = Build(forUpdateStatementNode->Update(), bodyBB); + ES2PANDA_ASSERT(bodyBB != nullptr); bodyBB->AddSuccessor(testBB); --inLoop_; return falseBB; @@ -667,6 +674,7 @@ CFG::BasicBlock *CFG::Build(ir::ForUpdateStatement *forUpdateStatementNode, Basi loopStmtJumpTargetMap_[forUpdateStatementNode] = std::make_pair(bodyStartBB, nextBB); auto bodyBB = Build(forUpdateStatementNode->Body(), bodyStartBB); bodyBB = Build(forUpdateStatementNode->Update(), bodyBB); + ES2PANDA_ASSERT(bodyBB != nullptr); bodyBB->AddSuccessor(bodyStartBB); --inLoop_; return nextBB; diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 75fd7d3de505e7bba5f6d34adae7e5d6b9110aeb..9e26143b69d04766ede7873bbab22abb01dd8671 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -613,7 +613,7 @@ void ETSCompiler::Compile(const ir::BinaryExpression *expr) const compiler::VReg lhs = etsg->AllocReg(); if (expr->OperatorType() == lexer::TokenType::PUNCTUATOR_PLUS && expr->OperationType()->IsETSStringType()) { - etsg->BuildString(expr); + etsg->BuildString(expr, lhs); return; } @@ -649,6 +649,7 @@ static void ConvertRestArguments(checker::ETSChecker *const checker, const ir::C elements.emplace_back(expr->Arguments()[i]); } auto *arrayExpression = checker->AllocNode(std::move(elements), checker->Allocator()); + ES2PANDA_ASSERT(arrayExpression != nullptr); arrayExpression->SetParent(const_cast(expr)); auto restType = signature->RestVar()->TsType()->AsETSArrayType(); arrayExpression->SetTsType(restType); diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index ff54d72f975078fcf116ca670ad2aae73e73232d..672a2ace609f5b0853a2a17cab3f760d5341e7d8 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -15,11 +15,13 @@ #include "ETSGen-inl.h" +#include "compiler/core/codeGen.h" #include "compiler/core/regScope.h" #include "generated/isa.h" #include "generated/signatures.h" #include "ir/base/scriptFunction.h" #include "ir/base/classDefinition.h" +#include "ir/expression.h" #include "ir/statement.h" #include "ir/expressions/assignmentExpression.h" #include "ir/expressions/identifier.h" @@ -34,6 +36,8 @@ #include "compiler/base/lreference.h" #include "compiler/base/catchTable.h" #include "compiler/core/dynamicContext.h" +#include "macros.h" +#include "util/es2pandaMacros.h" #include "varbinder/ETSBinder.h" #include "varbinder/variable.h" #include "checker/types/type.h" @@ -661,10 +665,8 @@ void ETSGen::BranchIfIsInstance(const ir::AstNode *const node, const VReg srcReg } if (!target->IsETSNeverType()) { - // #21835: type-alias in ApparentType - TestIsInstanceType(node, std::tie(ifTrue, ifFalse), - target->IsETSTypeAliasType() ? target->AsETSTypeAliasType()->GetTargetType() : target, - srcReg, target->PossiblyETSNull()); + ES2PANDA_ASSERT(!target->IsETSTypeAliasType()); + TestIsInstanceType(node, std::tie(ifTrue, ifFalse), target, srcReg, target->PossiblyETSNull()); } SetLabel(node, ifFalse); @@ -675,7 +677,7 @@ void ETSGen::BranchIfIsInstance(const ir::AstNode *const node, const VReg srcReg void ETSGen::IsInstance(const ir::AstNode *const node, const VReg srcReg, const checker::Type *target) { target = Checker()->GetApparentType(target); - ES2PANDA_ASSERT(target->IsETSReferenceType() && GetAccumulatorType() != nullptr); + ES2PANDA_ASSERT(target != nullptr && target->IsETSReferenceType() && GetAccumulatorType() != nullptr); if (target->IsETSAnyType()) { // should be IsSupertypeOf(target, source) LoadAccumulatorBoolean(node, true); @@ -725,6 +727,7 @@ void ETSGen::InternalCheckCast(const ir::AstNode *node, const es2panda::checker: // Handle checkcast for interop if it is 1.2 type. void ETSGen::EmitAnyCheckCast(const ir::AstNode *node, const checker::Type *target) { + ES2PANDA_ASSERT(target != nullptr); if (!target->IsETSAnyType() && (target->IsETSObjectType() || target->IsETSArrayType() || target->IsETSTupleType())) { InternalCheckCast(node, target); @@ -779,6 +782,7 @@ void ETSGen::CheckedReferenceNarrowing(const ir::AstNode *node, const checker::T } target = Checker()->GetApparentType(target); + ES2PANDA_ASSERT(target != nullptr); ES2PANDA_ASSERT(target->IsETSReferenceType()); if (target->IsETSAnyType()) { // should be IsSupertypeOf(target, source) @@ -815,6 +819,7 @@ void ETSGen::GuardUncheckedType(const ir::AstNode *node, const checker::Type *un CheckedReferenceNarrowing(node, Checker()->MaybeBoxType(target)); // Because on previous step accumulator type may be set in CheckerReferenceNarrowing to boxed counterpart of // target We need to apply unbox conversion if needed to avoid RTE + ES2PANDA_ASSERT(GetAccumulatorType() != nullptr); if (target->IsETSPrimitiveType() && GetAccumulatorType()->IsETSUnboxableObject()) { ApplyConversion(node, target); } @@ -1288,6 +1293,7 @@ void ETSGen::CastToInt(const ir::AstNode *node) void ETSGen::CastToReftype(const ir::AstNode *const node, const checker::Type *const targetType, const bool unchecked) { + ES2PANDA_ASSERT(GetAccumulatorType() != nullptr); ES2PANDA_ASSERT(GetAccumulatorType()->IsETSReferenceType()); if (!unchecked) { @@ -1973,6 +1979,7 @@ static std::optional> SelectL ES2PANDA_ASSERT(alhs != nullptr && arhs != nullptr); alhs = alhs->IsETSStringType() ? checker->GlobalBuiltinETSStringType() : alhs; arhs = arhs->IsETSStringType() ? checker->GlobalBuiltinETSStringType() : arhs; + ES2PANDA_ASSERT(alhs != nullptr && arhs != nullptr); if (!alhs->IsETSObjectType() || !arhs->IsETSObjectType()) { return std::nullopt; } @@ -2306,6 +2313,77 @@ void ETSGen::UpdateBigInt(const ir::Expression *node, VReg arg, lexer::TokenType } } +void ETSGen::ConcatStrings(const ir::BinaryExpression *node, VReg lhs) +{ + ES2PANDA_ASSERT(node->OperationType()->IsETSStringType()); + node->CompileOperands(this, lhs); + RegScope rs(this); + auto rhs = AllocReg(); + StoreAccumulator(node->Right(), rhs); + + ToString(node->Left(), lhs); + StoreAccumulator(node->Left(), lhs); + + ToString(node->Right(), rhs); + StoreAccumulator(node->Right(), rhs); + + ES2PANDA_ASSERT(GetVRegType(lhs)->IsETSStringType()); + ES2PANDA_ASSERT(GetVRegType(rhs)->IsETSStringType()); + CallExact(node, Signatures::BUILTIN_STRING_BUILDER_CONCAT_STRING, lhs, rhs); + SetAccumulatorType(node->TsType()); +} + +void ETSGen::ToString(const ir::Expression *node, VReg arg) +{ + const auto regType = GetVRegType(arg); + if (regType->IsETSReferenceType()) { + if (regType->PossiblyETSUndefined()) { + const auto ifUndefined = AllocLabel(); + const auto end = AllocLabel(); + LoadAccumulator(node, arg); + BranchIfUndefined(node, ifUndefined); + CallVirtual(node, Signatures::BUILTIN_OBJECT_TO_STRING, arg); + SetAccumulatorType(Checker()->GlobalBuiltinETSStringType()); + JumpTo(node, end); + + SetLabel(node, ifUndefined); + LoadAccumulatorString(node, "undefined"); + + SetLabel(node, end); + return; + } + if (regType->IsETSStringType()) { + LoadAccumulator(node, arg); + } else { + CallVirtual(node, Signatures::BUILTIN_OBJECT_TO_STRING, arg); + SetAccumulatorType(Checker()->GlobalBuiltinETSStringType()); + } + return; + } + + using TSign = std::pair; + constexpr std::array TO_STRING_METHODS { + TSign {checker::TypeFlag::ETS_BOOLEAN, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_BOOLEAN}, + TSign {checker::TypeFlag::CHAR, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_CHAR}, + TSign {checker::TypeFlag::SHORT, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_INT}, + TSign {checker::TypeFlag::BYTE, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_INT}, + TSign {checker::TypeFlag::INT, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_INT}, + TSign {checker::TypeFlag::LONG, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_LONG}, + TSign {checker::TypeFlag::FLOAT, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_FLOAT}, + TSign {checker::TypeFlag::DOUBLE, Signatures::BUILTIN_STRING_BUILDER_TO_STRING_DOUBLE}, + }; + + const auto typeFlag = checker::ETSChecker::ETSType(regType); + const auto iter = std::find_if(TO_STRING_METHODS.begin(), TO_STRING_METHODS.end(), + [typeFlag](TSign p) { return p.first == typeFlag; }); + if (iter != TO_STRING_METHODS.end()) { + CallExact(node, iter->second, arg); + SetAccumulatorType(Checker()->GlobalBuiltinETSStringType()); + return; + } + ES2PANDA_UNREACHABLE(); +} + void ETSGen::StringBuilderAppend(const ir::AstNode *node, VReg builder) { RegScope rs(this); @@ -2381,7 +2459,17 @@ void ETSGen::StringBuilder(const ir::Expression *const left, const ir::Expressio StringBuilderAppend(right, builder); } -void ETSGen::BuildString(const ir::Expression *node) +void ETSGen::BuildString(const ir::BinaryExpression *node, VReg lhs) +{ + // #26986 use concat instead of append + if (Context()->config->options->IsEtsStringsConcat()) { + ConcatStrings(node, lhs); + return; + } + CreateStringBuilder(node); +} + +void ETSGen::CreateStringBuilder(const ir::Expression *node) { RegScope rs(this); @@ -2420,6 +2508,16 @@ void ETSGen::CallBigIntBinaryComparison(const ir::Expression *node, VReg lhs, VR } void ETSGen::BuildTemplateString(const ir::TemplateLiteral *node) +{ + // #26986 use concat instead of append + if (Context()->config->options->IsEtsStringsConcat()) { + ConcatTemplateString(node); + } else { + AppendTemplateString(node); + } +} + +void ETSGen::AppendTemplateString(const ir::TemplateLiteral *node) { RegScope rs(this); @@ -2428,21 +2526,17 @@ void ETSGen::BuildTemplateString(const ir::TemplateLiteral *node) auto builder = AllocReg(); StoreAccumulator(node, builder); - // Just to reduce extra nested level(s): auto const appendExpressions = [this, &builder](ArenaVector const &expressions, ArenaVector const &quasis) -> void { - auto const num = expressions.size(); - std::size_t i = 0U; - - while (i < num) { + ES2PANDA_ASSERT(quasis.size() == expressions.size() + 1); + for (size_t i = 0; i < expressions.size();) { StringBuilderAppend(expressions[i], builder); if (!quasis[++i]->Raw().Empty()) { StringBuilderAppend(quasis[i], builder); } } }; - if (auto const &quasis = node->Quasis(); !quasis.empty()) { if (!quasis[0]->Raw().Empty()) { StringBuilderAppend(quasis[0], builder); @@ -2452,9 +2546,56 @@ void ETSGen::BuildTemplateString(const ir::TemplateLiteral *node) appendExpressions(expressions, quasis); } } - CallExact(node, Signatures::BUILTIN_STRING_BUILDER_TO_STRING, builder); + SetAccumulatorType(node->TsType()); +} +void ETSGen::ConcatTemplateString(const ir::TemplateLiteral *node) +{ + const auto &quasis = node->Quasis(); + const auto &expressions = node->Expressions(); + if (quasis.empty()) { + LoadAccumulatorString(node, ""); + return; + } + ES2PANDA_ASSERT(quasis.size() == expressions.size() + 1); + const RegScope rs {this}; + const auto result = AllocReg(); + const auto reg = AllocReg(); + // collect expressions + std::vector buffer {}; + buffer.reserve(quasis.size() + expressions.size()); + if (!quasis[0]->Raw().Empty()) { + buffer.push_back(quasis[0]); + } + for (size_t i = 0; i < expressions.size(); ++i) { + buffer.push_back(expressions[i]); + if (!quasis[i + 1]->Raw().Empty()) { + buffer.push_back(quasis[i + 1]); + } + } + // concat buffered expressions + if (buffer.empty()) { + LoadAccumulatorString(node, ""); + return; + } + const auto node2str = [this, reg](const ir::Expression *expr) { + expr->Compile(this); + StoreAccumulator(expr, reg); + ToString(expr, reg); + ES2PANDA_ASSERT(GetAccumulatorType()->IsETSStringType()); + }; + auto iter = buffer.begin(); + node2str(*iter); + StoreAccumulator(node, result); + for (++iter; iter != buffer.end(); ++iter) { + node2str(*iter); + StoreAccumulator(*iter, reg); + CallExact(node, Signatures::BUILTIN_STRING_BUILDER_CONCAT_STRING, result, reg); + SetAccumulatorType(Checker()->GlobalBuiltinETSStringType()); + StoreAccumulator(node, result); + } + LoadAccumulator(node, result); SetAccumulatorType(node->TsType()); } diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 71ce602b2cb96500fec0689a1ffb17d324e71db5..4b306cccb2659231a1f06fa6f9dd783fe9a40d51 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -287,7 +287,9 @@ public: // Call, Construct void NewArray(const ir::AstNode *node, VReg arr, VReg dim, const checker::Type *arrType); void NewObject(const ir::AstNode *node, util::StringView name, VReg athis); - void BuildString(const ir::Expression *node); + void BuildString(const ir::BinaryExpression *node, VReg lhs); + void ConcatStrings(const ir::BinaryExpression *node, VReg lhs); + void ToString(const ir::Expression *node, VReg arg); void CallBigIntUnaryOperator(const ir::Expression *node, VReg arg, util::StringView signature); void CallBigIntBinaryOperator(const ir::Expression *node, VReg lhs, VReg rhs, util::StringView signature); void CallBigIntBinaryComparison(const ir::Expression *node, VReg lhs, VReg rhs, util::StringView signature); @@ -477,9 +479,12 @@ private: const VReg dummyReg_ = VReg::RegStart(); void LoadConstantObject(const ir::Expression *node, const checker::Type *type); + void CreateStringBuilder(const ir::Expression *node); void StringBuilderAppend(const ir::AstNode *node, VReg builder); void AppendString(const ir::Expression *binExpr, VReg builder); void StringBuilder(const ir::Expression *left, const ir::Expression *right, VReg builder); + void AppendTemplateString(const ir::TemplateLiteral *node); + void ConcatTemplateString(const ir::TemplateLiteral *node); util::StringView FormClassPropReference(varbinder::Variable const *var); void UnaryMinus(const ir::AstNode *node); void UnaryTilde(const ir::AstNode *node); diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index bf1a0dcb1933128bc9c1eab349d2bcdccc561830..4da7d669bffc01517c9a77c6411698abc5df42e5 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -41,6 +41,7 @@ #include "checker/types/ets/types.h" #include "checker/types/ets/etsPartialTypeParameter.h" #include "public/public.h" +#include "util/nameMangler.h" #include "assembly-program.h" @@ -128,7 +129,7 @@ static pandasm::Function GenScriptFunction(const ir::ScriptFunction *scriptFunc, !var->Declaration()->Node()->IsETSParameterExpression()) { continue; } - func.params.back().GetOrCreateMetadata().SetAnnotations(emitter->GenCustomAnnotations( + func.params.back().GetOrCreateMetadata()->SetAnnotations(emitter->GenCustomAnnotations( var->Declaration()->Node()->AsETSParameterExpression()->Annotations(), var->Name().Mutf8())); } @@ -220,11 +221,6 @@ static pandasm::Function GenExternalFunction(checker::Signature *signature, bool return func; } -static std::string GenerateMangledName(const std::string &baseName, const std::string &propName) -{ - return baseName + "$" + propName; -} - void FilterForSimultaneous(varbinder::ETSBinder *varbinder) { ArenaSet &classDefinitions = varbinder->GetGlobalRecordTable()->ClassDefinitions(); @@ -258,7 +254,8 @@ void ETSEmitter::GenAnnotation() auto *globalRecordTable = varbinder->GetGlobalRecordTable(); auto baseName = varbinder->GetRecordTable()->RecordName().Mutf8(); for (auto *annoDecl : globalRecordTable->AnnotationDeclarations()) { - auto newBaseName = GenerateMangledName(baseName, annoDecl->GetBaseName()->Name().Mutf8()); + std::string newBaseName = util::NameMangler::GetInstance()->CreateMangledNameForAnnotation( + baseName, annoDecl->GetBaseName()->Name().Mutf8()); GenCustomAnnotationRecord(annoDecl, newBaseName, annoDecl->IsDeclare()); } @@ -318,7 +315,8 @@ void ETSEmitter::GenExternalRecord(varbinder::RecordTable *recordTable, const pa const auto *varbinder = static_cast(Context()->parserProgram->VarBinder()); auto baseName = varbinder->GetRecordTable()->RecordName().Mutf8(); for (auto *annoDecl : recordTable->AnnotationDeclarations()) { - auto newBaseName = GenerateMangledName(baseName, annoDecl->GetBaseName()->Name().Mutf8()); + std::string newBaseName = util::NameMangler::GetInstance()->CreateMangledNameForAnnotation( + baseName, annoDecl->GetBaseName()->Name().Mutf8()); GenCustomAnnotationRecord(annoDecl, newBaseName, isExternalFromCompile || annoDecl->IsDeclare()); } @@ -786,8 +784,8 @@ LiteralArrayVector ETSEmitter::CreateLiteralArray(std::string &baseName, const i ProcessArrayElement(elem, literals, baseName, result); } - std::string litArrayName = GenerateMangledName(baseName, std::to_string(g_litArrayValueCount)); - ++g_litArrayValueCount; + std::string litArrayName = + util::NameMangler::GetInstance()->AppendToAnnotationName(baseName, std::to_string(g_litArrayValueCount++)); result.emplace_back(litArrayName, literals); return result; } @@ -807,7 +805,7 @@ void ETSEmitter::CreateLiteralArrayProp(const ir::ClassProperty *prop, std::stri auto value = prop->Value(); if (value != nullptr) { - std::string newBaseName = GenerateMangledName(baseName, field.name); + std::string newBaseName = util::NameMangler::GetInstance()->AppendToAnnotationName(baseName, field.name); auto litArray = CreateLiteralArray(newBaseName, value); for (const auto &item : litArray) { Program()->literalarrayTable.emplace(item.first, item.second); @@ -868,7 +866,7 @@ pandasm::AnnotationElement ETSEmitter::ProcessArrayType(const ir::ClassProperty { ES2PANDA_ASSERT(prop->Id() != nullptr); auto propName = prop->Id()->Name().Mutf8(); - std::string newBaseName = GenerateMangledName(baseName, propName); + std::string newBaseName = util::NameMangler::GetInstance()->AppendToAnnotationName(baseName, propName); auto litArrays = CreateLiteralArray(newBaseName, init); for (const auto &item : litArrays) { @@ -942,7 +940,8 @@ std::vector ETSEmitter::GenCustomAnnotations( for (auto *anno : annotationUsages) { auto *annoDecl = anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); if (!annoDecl->IsSourceRetention()) { - auto newBaseName = GenerateMangledName(baseName, anno->GetBaseName()->Name().Mutf8()); + std::string newBaseName = util::NameMangler::GetInstance()->CreateMangledNameForAnnotation( + baseName, anno->GetBaseName()->Name().Mutf8()); annotations.emplace_back(GenCustomAnnotation(anno, newBaseName)); } } diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index 8aea0d5139bdc7265b746ebac9a767967831edb6..cd36b35536ca68b350e211dba1cc2ac976942337 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -389,10 +389,21 @@ static bool ExecuteParsingAndCompiling(const CompilationUnit &unit, public_lib:: return !context->diagnosticEngine->IsAnyError(); } +static pandasm::Program *ClearContextAndReturnProgam(public_lib::Context *context, pandasm::Program *program) +{ + context->config = nullptr; + context->parser = nullptr; + context->ClearCheckers(); + context->ClearAnalyzers(); + context->phaseManager = nullptr; + context->parserProgram = nullptr; + context->emitter = nullptr; + return program; +} + template -static pandasm::Program *Compile(const CompilationUnit &unit, CompilerImpl *compilerImpl, - [[maybe_unused]] public_lib::Context *context) +static pandasm::Program *Compile(const CompilationUnit &unit, CompilerImpl *compilerImpl, public_lib::Context *context) { ir::DisableContextHistory(); auto config = public_lib::ConfigImpl {}; @@ -438,11 +449,11 @@ static pandasm::Program *Compile(const CompilationUnit &unit, CompilerImpl *comp context->GetChecker()->Initialize(varbinder); if (!ExecuteParsingAndCompiling(unit, context)) { - return nullptr; + return ClearContextAndReturnProgam(context, nullptr); } MarkAsLowered(program); - return EmitProgram(compilerImpl, context, unit); + return ClearContextAndReturnProgam(context, EmitProgram(compilerImpl, context, unit)); } pandasm::Program *CompilerImpl::Compile(const CompilationUnit &unit, public_lib::Context *context) diff --git a/ets2panda/compiler/core/emitter.cpp b/ets2panda/compiler/core/emitter.cpp index 91ee21b4fbf99d78828bc937e9f8db083017d03b..65863727490ecbd49f91417349b2595efb460fba 100644 --- a/ets2panda/compiler/core/emitter.cpp +++ b/ets2panda/compiler/core/emitter.cpp @@ -31,11 +31,6 @@ #include "util/es2pandaMacros.h" #include "public/public.h" -#include -#include -#include -#include - namespace ark::es2panda::compiler { using LiteralPair = std::pair; @@ -215,17 +210,17 @@ void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, pandasm::Ins *p } auto nodeRange = astNode->Range(); - pandaIns->insDebug.lineNumber = nodeRange.start.line + 1; + pandaIns->insDebug.SetLineNumber(nodeRange.start.line + 1U); if (cg_->IsDebug()) { size_t insLen = GetIRNodeWholeLength(ins); if (insLen != 0) { - pandaIns->insDebug.boundLeft = offset_; - pandaIns->insDebug.boundRight = offset_ + insLen; + pandaIns->insDebug.SetBoundLeft(offset_); + pandaIns->insDebug.SetBoundRight(offset_ + insLen); } offset_ += insLen; - pandaIns->insDebug.wholeLine = WholeLine(nodeRange); + pandaIns->insDebug.SetWholeLine(WholeLine(nodeRange)); } } @@ -413,7 +408,10 @@ static void UpdateLiteralBufferId([[maybe_unused]] ark::pandasm::Ins *ins, [[may #ifdef PANDA_WITH_ECMASCRIPT switch (ins->opcode) { case pandasm::Opcode::ECMA_DEFINECLASSWITHBUFFER: { - ins->imms.back() = std::get(ins->imms.back()) + offset; + if (auto pos = ins->ImmSize(); pos > 0U) { + --pos; + ins->SetImm(pos, std::get(ins->GetImm(pos)) + offset); + } break; } case pandasm::Opcode::ECMA_CREATEARRAYWITHBUFFER: @@ -421,9 +419,12 @@ static void UpdateLiteralBufferId([[maybe_unused]] ark::pandasm::Ins *ins, [[may case pandasm::Opcode::ECMA_CREATEOBJECTHAVINGMETHOD: case pandasm::Opcode::ECMA_DEFINECLASSPRIVATEFIELDS: { constexpr int BASE10 = 10; - uint32_t storedOffset = strtoul(ins->ids.back().data(), nullptr, BASE10); - storedOffset += offset; - ins->ids.back() = std::to_string(storedOffset); + if (auto pos = ins->IDSize(); pos > 0U) { + --pos; + auto storedOffset = std::strtoul(ins->GetID(pos).data(), nullptr, BASE10); + storedOffset += offset; + ins->SetID(pos, std::to_string(storedOffset)); + } break; } default: { @@ -484,7 +485,7 @@ static std::string DumpAsmFunction(std::string name, const pandasm::Function &fu ss << ") {" << std::endl; for (const auto &ins : func.ins) { - ss << (ins.setLabel ? "" : "\t") << ins.ToString("", true, func.GetTotalRegs()) << std::endl; + ss << (ins.HasLabel() ? "" : "\t") << ins.ToString("", true, func.GetTotalRegs()) << std::endl; } ss << "}" << std::endl << std::endl; diff --git a/ets2panda/compiler/core/emitter.h b/ets2panda/compiler/core/emitter.h index 84049be833c5801b44ffd519df33a6851417c1d1..7e2623cc38f6a6f1c37ff01b0aa8caa488a4c1db 100644 --- a/ets2panda/compiler/core/emitter.h +++ b/ets2panda/compiler/core/emitter.h @@ -29,8 +29,8 @@ namespace ark::pandasm { struct Program; -struct Function; -struct Ins; +class Function; +class Ins; namespace debuginfo { struct LocalVariable; } // namespace debuginfo diff --git a/ets2panda/compiler/core/programElement.h b/ets2panda/compiler/core/programElement.h index 59e31f6525b86c119ee225492b3c10aa52bee445..481f69375731a0c4506758b5d9a3b1ab92b7932a 100644 --- a/ets2panda/compiler/core/programElement.h +++ b/ets2panda/compiler/core/programElement.h @@ -20,8 +20,8 @@ #include "compiler/base/literals.h" namespace ark::pandasm { -struct Ins; -struct Function; +class Ins; +class Function; } // namespace ark::pandasm namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/debugger/debuginfoDumper.cpp b/ets2panda/compiler/debugger/debuginfoDumper.cpp index f51e14e13eac4f0efb8b8f501ea09e881ce7fc65..77a380803ef536a5718c06f2f3460be01c62b6bf 100644 --- a/ets2panda/compiler/debugger/debuginfoDumper.cpp +++ b/ets2panda/compiler/debugger/debuginfoDumper.cpp @@ -17,9 +17,6 @@ #include "util/es2pandaMacros.h" -#include -#include - namespace ark::es2panda::debuginfo { DebugInfoDumper::DebugInfoDumper(const pandasm::Program *prog) : prog_(prog) {} @@ -88,24 +85,113 @@ void DebugInfoDumper::WrapArray(const char *name, const std::vector &array, b ss_ << "]" << PutComma(comma); } +void DebugInfoDumper::WrapRegArray(ark::pandasm::Ins const &ins, bool comma) +{ + ss_ << std::endl; + Indent(); + ss_ << "\"regs\": " + << "["; + + auto const size = ins.RegSize(); + if (size == 0U) { + ss_ << "]" << PutComma(comma); + return; + } + + ss_ << "\n"; + ++indent_; + + for (std::size_t i = 0U; i < size;) { + Indent(); + ss_ << ins.GetReg(i); + if (++i < size) { + ss_ << ','; + } + ss_ << '\n'; + } + + --indent_; + Indent(); + + ss_ << "]" << PutComma(comma); +} + +void DebugInfoDumper::WrapIDArray(ark::pandasm::Ins const &ins, bool comma) +{ + ss_ << std::endl; + Indent(); + ss_ << "\"ids\": " + << "["; + + auto const size = ins.IDSize(); + if (size == 0U) { + ss_ << "]" << PutComma(comma); + return; + } + + ss_ << "\n"; + ++indent_; + + for (std::size_t i = 0U; i < size;) { + Indent(); + ss_ << ins.GetID(i); + if (++i < size) { + ss_ << ','; + } + ss_ << '\n'; + } + + --indent_; + Indent(); + + ss_ << "]" << PutComma(comma); +} + +void DebugInfoDumper::WrapImmArray(ark::pandasm::Ins const &ins, bool comma) +{ + ss_ << std::endl; + Indent(); + ss_ << "\"imms\": " + << "["; + + auto const size = ins.ImmSize(); + if (size == 0U) { + ss_ << "]" << PutComma(comma); + return; + } + + ss_ << "\n"; + ++indent_; + + for (std::size_t i = 0U; i < size;) { + Indent(); + auto value = ins.GetImm(i); + ss_ << (std::holds_alternative(value) ? std::to_string(std::get(value)) + : std::to_string(std::get(value))); + if (++i < size) { + ss_ << ','; + } + ss_ << '\n'; + } + + --indent_; + Indent(); + + ss_ << "]" << PutComma(comma); +} + void DebugInfoDumper::WriteIns(const pandasm::Ins &ins) { ss_ << "{"; - { - pandasm::Ins insCopy; - insCopy.opcode = ins.opcode; - insCopy.setLabel = ins.setLabel; - insCopy.label = ins.label; - WriteProperty("opcode", insCopy.ToString()); - } + WriteProperty("opcode", ins.ToString()); indent_++; - WrapArray("regs", ins.regs); - WrapArray("ids", ins.ids); - WrapArray("imms", ins.imms); + WrapRegArray(ins); + WrapIDArray(ins); + WrapImmArray(ins); ss_ << std::endl; Indent(); ss_ << "\"label\": " - << "\"" << ins.label << "\","; + << "\"" << (ins.HasLabel() ? ins.Label().c_str() : "") << "\","; WritePosInfo(ins.insDebug); indent_--; Indent(); @@ -131,10 +217,10 @@ void DebugInfoDumper::WritePosInfo(const pandasm::debuginfo::Ins &posInfo) ss_ << std::endl; Indent(); ss_ << "\"debug_pos_info\": {"; - WriteProperty("boundLeft", posInfo.boundLeft); - WriteProperty("boundRight", posInfo.boundRight); - WriteProperty("sourceLineNum", static_cast(posInfo.lineNumber)); - WriteProperty("wholeLine", posInfo.wholeLine, false); + WriteProperty("boundLeft", posInfo.BoundLeft()); + WriteProperty("boundRight", posInfo.BoundRight()); + WriteProperty("sourceLineNum", posInfo.LineNumber()); + WriteProperty("wholeLine", posInfo.WholeLine(), false); Indent(); ss_ << "}" << std::endl; } @@ -152,7 +238,7 @@ void DebugInfoDumper::WriteVariableInfo(const pandasm::debuginfo::LocalVariable ss_ << "}"; } -void DebugInfoDumper::DumpFuncBody(std::string name, const pandasm::Function &func) +void DebugInfoDumper::DumpFuncBody(std::string const &name, const pandasm::Function &func) { indent_++; Indent(); @@ -216,18 +302,19 @@ void DebugInfoDumper::Dump() std::cout << ss_.str(); } -void DebugInfoDumper::WriteProperty(const char *key, const Value &value, bool comma) +template +void DebugInfoDumper::WriteProperty(const char *key, T &&value, bool comma) { + static_assert(std::is_arithmetic_v> || std::is_same_v>, + "Invalid data type."); ss_ << std::endl; indent_++; Indent(); ss_ << "\"" << key << "\": "; - if (std::holds_alternative(value)) { - ss_ << "\"" << std::get(value) << "\""; - } else if (std::holds_alternative(value)) { - ss_ << std::to_string(std::get(value)); - } else if (std::holds_alternative(value)) { - ss_ << std::to_string(std::get(value)); + if constexpr (std::is_arithmetic_v>) { + ss_ << std::to_string(std::forward(value)); + } else { + ss_ << "\"" << std::forward(value) << "\""; } comma ? ss_ << "," : ss_ << std::endl; diff --git a/ets2panda/compiler/debugger/debuginfoDumper.h b/ets2panda/compiler/debugger/debuginfoDumper.h index 9ee90387c4d10e979198cd5997dbd63e37fb7098..beb79180879e86fc0cf9e599cea0a85d896ae8f2 100644 --- a/ets2panda/compiler/debugger/debuginfoDumper.h +++ b/ets2panda/compiler/debugger/debuginfoDumper.h @@ -22,8 +22,6 @@ namespace ark::es2panda::debuginfo { -using Value = std::variant; - class DebugInfoDumper { public: explicit DebugInfoDumper(const pandasm::Program *prog); @@ -36,14 +34,18 @@ public: private: template void WrapArray(const char *name, const std::vector &array, bool comma = true); + void WrapRegArray(ark::pandasm::Ins const &ins, bool comma = true); + void WrapIDArray(ark::pandasm::Ins const &ins, bool comma = true); + void WrapImmArray(ark::pandasm::Ins const &ins, bool comma = true); void WriteIns(const pandasm::Ins &ins); void WriteMetaData(const std::vector &metaData); - void WriteProperty(const char *key, const Value &value, bool comma = true); + template + void WriteProperty(const char *key, T &&value, bool comma = true); void WritePosInfo(const pandasm::debuginfo::Ins &posInfo); void WriteVariableInfo(const pandasm::debuginfo::LocalVariable &localVariableDebug); void Indent(); void DumpFunctions(const std::map &table); - void DumpFuncBody(std::string name, const pandasm::Function &func); + void DumpFuncBody(std::string const &name, const pandasm::Function &func); const pandasm::Program *prog_; std::stringstream ss_; diff --git a/ets2panda/compiler/lowering/checkerPhase.cpp b/ets2panda/compiler/lowering/checkerPhase.cpp index e6b73d36a4d3835fa1ae3bd7db0a295471234af0..d01f5603ed1dd88bcb7d1f2f4a790bd7eb994062 100644 --- a/ets2panda/compiler/lowering/checkerPhase.cpp +++ b/ets2panda/compiler/lowering/checkerPhase.cpp @@ -48,8 +48,16 @@ bool CheckerPhase::Perform(public_lib::Context *ctx, [[maybe_unused]] parser::Pr for (auto stmt : program->Ast()->Statements()) { stmt->AddAstNodeFlags(ir::AstNodeFlags::NOCLEANUP); } - auto checkerResult = ctx->GetChecker()->StartChecker(ctx->parserProgram->VarBinder(), *ctx->config->options); - return program->Extension() == ScriptExtension::ETS ? true : checkerResult; -} + if (program->Extension() == ScriptExtension::ETS) { + try { + ctx->GetChecker()->StartChecker(ctx->parserProgram->VarBinder(), *ctx->config->options); + } catch (std::exception &e) { + // nothing to do - just to avoid program crash + } + return true; + } + + return ctx->GetChecker()->StartChecker(ctx->parserProgram->VarBinder(), *ctx->config->options); +} } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/ambientLowering.cpp b/ets2panda/compiler/lowering/ets/ambientLowering.cpp index 5e88122100f96e8685c4aa52f15f0a24bd20b76f..9609e91605fdf3c17e7490f11d3246f749883e0b 100644 --- a/ets2panda/compiler/lowering/ets/ambientLowering.cpp +++ b/ets2panda/compiler/lowering/ets/ambientLowering.cpp @@ -56,26 +56,28 @@ ir::MethodDefinition *CreateMethodFunctionDefinition(ir::DummyNode *node, public ir::MethodDefinitionKind funcKind) { auto parser = ctx->parser->AsETSParser(); + auto allocator = ctx->allocator; auto indexName = node->GetIndexName(); - auto const returnType = node->GetReturnTypeLiteral()->AsETSTypeReferencePart()->GetIdent(); - if (returnType->IsErrorPlaceHolder()) { + if (node->IsBrokenStatement()) { return nullptr; } if (indexName == ERROR_LITERAL) { indexName = "_"; } std::string sourceCode; + if (funcKind == ir::MethodDefinitionKind::GET) { - sourceCode = "$_get(" + std::string(indexName) + " : number) : " + std::string(returnType->Name()); + sourceCode = "$_get (" + std::string(indexName) + " : @@T1) : @@T2 "; } else if (funcKind == ir::MethodDefinitionKind::SET) { - sourceCode = "$_set(" + std::string(indexName) + " : number, " + "value : " + std::string(returnType->Name()) + - " ) : void"; + sourceCode = "$_set (" + std::string(indexName) + " : @@T1, value : @@T2) : void"; } else { ES2PANDA_UNREACHABLE(); } - auto methodDefinition = parser->CreateFormattedClassMethodDefinition(sourceCode); + auto methodDefinition = + parser->CreateFormattedClassMethodDefinition(sourceCode, node->IndexTypeAnno()->Clone(allocator, nullptr), + node->GetReturnTypeLiteral()->Clone(allocator, nullptr)); // NOTE(kaskov): #23399 It is temporary solution, we set default SourcePosition in all nodes in generated code compiler::SetSourceRangesRecursively(methodDefinition, node->Range()); diff --git a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp index 1affd68bbf51fb98621f4f1edf87c6ea977fb033..be15ae71a728ab845bcecc16c3347c18d2a49559 100644 --- a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp +++ b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp @@ -128,12 +128,13 @@ ir::MethodDefinition *CreateAsyncProxy(checker::ETSChecker *checker, ir::MethodD ir::ClassDefinition *classDef) { ir::ScriptFunction *asyncFunc = asyncMethod->Function(); + ES2PANDA_ASSERT(asyncFunc != nullptr); if (!asyncFunc->IsExternal()) { checker->VarBinder()->AsETSBinder()->GetRecordTable()->EmplaceSignatures(asyncFunc->Scope(), asyncFunc); } ir::MethodDefinition *implMethod = CreateAsyncImplMethod(checker, asyncMethod, classDef); - ES2PANDA_ASSERT(implMethod->Function() != nullptr); + ES2PANDA_ASSERT(implMethod != nullptr && implMethod->Function() != nullptr && implMethod->Id() != nullptr); varbinder::FunctionScope *implFuncScope = implMethod->Function()->Scope(); for (auto *decl : asyncFunc->Scope()->Decls()) { auto res = asyncFunc->Scope()->Bindings().find(decl->Name()); @@ -163,14 +164,17 @@ ir::MethodDefinition *CreateAsyncProxy(checker::ETSChecker *checker, ir::MethodD void ComposeAsyncImplMethod(checker::ETSChecker *checker, ir::MethodDefinition *node) { + ES2PANDA_ASSERT(checker->FindAncestorGivenByType(node, ir::AstNodeType::CLASS_DEFINITION)); auto *classDef = checker->FindAncestorGivenByType(node, ir::AstNodeType::CLASS_DEFINITION)->AsClassDefinition(); ir::MethodDefinition *implMethod = CreateAsyncProxy(checker, node, classDef); implMethod->Check(checker); node->SetAsyncPairMethod(implMethod); + ES2PANDA_ASSERT(node->Function() != nullptr); if (node->Function()->IsOverload()) { auto *baseOverloadImplMethod = node->BaseOverloadMethod()->AsyncPairMethod(); + ES2PANDA_ASSERT(implMethod->Function() != nullptr && baseOverloadImplMethod->Function() != nullptr); implMethod->Function()->Id()->SetVariable(baseOverloadImplMethod->Function()->Id()->Variable()); baseOverloadImplMethod->AddOverload(implMethod); implMethod->SetParent(baseOverloadImplMethod); diff --git a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp index 0277b45394722568b48f7dc7b3856321096f8d79..3c5f9f78520201beb779196e7c42151909f0d76e 100644 --- a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp +++ b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp @@ -155,6 +155,7 @@ static void HandleFunctionParam(public_lib::Context *ctx, ir::ETSParameterExpres auto *newDecl = allocator->New(newVarName.View(), newDeclarator); auto *newVar = allocator->New(newDecl, oldVar->Flags()); + ES2PANDA_ASSERT(newVar != nullptr); newVar->SetTsType(boxedType); newDeclarator->Id()->AsIdentifier()->SetVariable(newVar); @@ -165,6 +166,7 @@ static void HandleFunctionParam(public_lib::Context *ctx, ir::ETSParameterExpres auto *newDeclaration = util::NodeAllocator::ForceSetParent( allocator, ir::VariableDeclaration::VariableDeclarationKind::CONST, allocator, std::move(declVec)); + ES2PANDA_ASSERT(newDeclaration != nullptr); newDeclaration->SetParent(body); newDeclaration->SetRange(param->Range()); bodyStmts.insert(bodyStmts.begin(), newDeclaration); diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 6a08c0793267ff64310552dba8c2f47a6080a596..d70dd6580e128c896032c0d83853498d75726e41 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -244,7 +244,19 @@ template static ir::AstNode *FloatingPointNumberLiteralCast(const ir::Literal *num, public_lib::Context *context) { if (sizeof(From) > sizeof(To)) { - // Constant narrowing floating point conversion is not permitted + // double -> float + auto doubleVal = GetVal(num); + if (doubleVal < std::numeric_limits::min() || doubleVal > std::numeric_limits::max()) { + LogError(context, diagnostic::CONSTANT_VALUE_OUT_OF_RANGE, {}, num->Start()); + return const_cast(num); + } + + auto floatVal = static_cast(doubleVal); + if (static_cast(floatVal) == doubleVal) { + auto parent = const_cast(num)->Parent(); + return CreateNumberLiteral(floatVal, parent, num->Range(), context->allocator); + } + LogError(context, diagnostic::CONSTANT_FLOATING_POINT_COVERSION, {}, num->Start()); return const_cast(num); } @@ -616,6 +628,9 @@ static TargetType PerformMultiplicativeOperation(TargetType leftNum, TargetType return std::numeric_limits::max(); } if constexpr (std::is_integral_v) { + if (isIntegralDivideResOverflow()) { + return 0; + } return leftNum % rightNum; } else { return std::fmod(leftNum, rightNum); @@ -915,7 +930,7 @@ static ir::AstNode *HandleBitwiseLogicalExpression(const ir::BinaryExpression *e return HandleNumericBitwiseLogicalExpression(expr, context); } - if (!left->IsBooleanLiteral() && !right->IsBooleanLiteral()) { + if (!left->IsBooleanLiteral() || !right->IsBooleanLiteral()) { LogError(context, diagnostic::WRONG_OPERAND_TYPE_FOR_BINARY_EXPRESSION, {}, expr->Start()); return CreateErrorIdentifier(expr, context->allocator); } @@ -1085,6 +1100,7 @@ static ir::AstNode *FoldLogicalUnaryExpression(const ir::UnaryExpression *unary, { auto resNode = util::NodeAllocator::Alloc(allocator, !TestLiteral(unary->Argument()->AsLiteral())); + ES2PANDA_ASSERT(resNode != nullptr); resNode->SetParent(const_cast(unary)->Parent()); resNode->SetRange(unary->Range()); return resNode; @@ -1176,13 +1192,19 @@ static varbinder::Variable *ResolveMemberExpressionProperty(ir::MemberExpression if (decl->IsClassDecl()) { // NOTE(gogabr) : for some reason, ETSGLOBAL points to class declaration instead of definition. auto *declNode = decl->AsClassDecl()->Node(); - auto *classDef = declNode->IsClassDefinition() ? declNode->AsClassDefinition() - : declNode->IsClassDeclaration() ? declNode->AsClassDeclaration()->Definition() - : nullptr; - ES2PANDA_ASSERT(classDef != nullptr); + if (declNode->IsClassDefinition()) { + scope = declNode->AsClassDefinition()->Scope(); + } else if (declNode->IsClassDeclaration()) { + auto *classDef = declNode->AsClassDeclaration()->Definition(); + if (classDef != nullptr) { + // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) + scope = classDef->Scope(); + } + } - // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) - scope = classDef->Scope(); + if (scope == nullptr) { + return nullptr; + } } else if (decl->IsEnumLiteralDecl()) { scope = decl->AsEnumLiteralDecl()->Node()->AsTSEnumDeclaration()->Scope(); } else { @@ -1245,6 +1267,11 @@ static bool IsInTSEnumMemberInit(const ir::AstNode *n) ir::AstNode *ConstantExpressionLowering::UnfoldResolvedReference(ir::AstNode *resolved, ir::AstNode *node) { + if (unfoldingSet_.count(resolved) > 0) { + return node; + } + unfoldingSet_.insert(resolved); + ir::AstNode *resNode = nullptr; if (resolved->IsClassProperty()) { auto propVal = resolved->AsClassElement()->Value(); @@ -1267,7 +1294,9 @@ ir::AstNode *ConstantExpressionLowering::UnfoldResolvedReference(ir::AstNode *re } if (resNode != nullptr) { - return MaybeUnfold(resNode); + auto res = MaybeUnfold(resNode); + unfoldingSet_.erase(resolved); + return res; } // failed to unfold @@ -1280,10 +1309,27 @@ ir::AstNode *ConstantExpressionLowering::MaybeUnfoldIdentifier(ir::Identifier *n return node; } + // Left-Hand-Side identifiers in UpdateExpression or BinaryExpression cannot be unfolded + if (node->Parent()->IsUpdateExpression() && node->Parent()->AsUpdateExpression()->Argument() == node) { + return node; + } + + if (node->Parent()->IsAssignmentExpression() && node->Parent()->AsAssignmentExpression()->Left() == node) { + return node; + } + auto *resolved = ResolveIdentifier(node); if (resolved == nullptr || !(resolved->Declaration()->IsConstDecl() || resolved->Declaration()->IsReadonlyDecl())) { return node; } + + auto *parent = node->Parent(); + while (parent != nullptr && (parent->IsMemberExpression() || parent->IsTSQualifiedName())) { + parent = parent->Parent(); + } + if (parent != nullptr && (parent->IsETSTypeReferencePart() || parent->IsETSTypeReference())) { + return node; + } return UnfoldResolvedReference(resolved->Declaration()->Node(), node); } diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h index 0bf1aead0f276b24723988984f48e463c48c1248..531871759fc22641437a042d9ec846634f106f64 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h @@ -55,6 +55,7 @@ private: public_lib::Context *context_ {nullptr}; parser::Program *program_ {nullptr}; varbinder::ETSBinder *varbinder_ {nullptr}; + std::unordered_set unfoldingSet_; }; } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp index c65dccccc6d3d4c2d39897303954f1810eb8b925..ad3cebeced6a13ed458e27f8656c5ab8b21e2295 100644 --- a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp @@ -64,7 +64,7 @@ void BuildOverloadHelperFunction(public_lib::Context *ctx, ir::MethodDefinition auto *varBinder = ctx->GetChecker()->VarBinder()->AsETSBinder(); auto const &[minArg, maxArg, needHelperOverload, isDeclare, hasRestVar, returnVoid] = method->GetOverloadInfo(); - ES2PANDA_ASSERT(needHelperOverload); + ES2PANDA_ASSERT(needHelperOverload && method->Function() != nullptr); auto params = ArenaVector(allocator->Adapter()); GenerateOverloadHelperParams(ctx, minArg, maxArg, hasRestVar, params); @@ -77,6 +77,7 @@ void BuildOverloadHelperFunction(public_lib::Context *ctx, ir::MethodDefinition allocator, ir::ScriptFunction::ScriptFunctionData {nullptr, ir::FunctionSignature(nullptr, std::move(params), returnAnno), functionFlag, method->Function()->Modifiers()}); + ES2PANDA_ASSERT(func != nullptr && method->Id() != nullptr); auto *methodId = ctx->AllocNode(method->Id()->Name(), allocator); func->SetIdent(methodId); auto *funcExpr = ctx->AllocNode(func); @@ -85,7 +86,8 @@ void BuildOverloadHelperFunction(public_lib::Context *ctx, ir::MethodDefinition method->Modifiers(), allocator, false); method->AddOverload(helperOverload); - ES2PANDA_ASSERT(helperOverload->Function()); + ES2PANDA_ASSERT(helperOverload->Function() != nullptr); + ES2PANDA_ASSERT(helperOverload->Id() != nullptr); helperOverload->Function()->ClearFlag((ir::ScriptFunctionFlags::OVERLOAD)); helperOverload->SetParent(method); diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index 3b7466ef9f897a990ee8dd8fc993079a97ad7dc7..5f71a7becde5865645818d97b9dcffbbf2035a3b 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -27,6 +27,10 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, util::Diagn bool hasRestParameter = false; for (auto *const it : function->Params()) { + if (it->IsBrokenExpression()) { + continue; + } + auto const *const param = it->AsETSParameterExpression(); if (param->IsRestParameter()) { @@ -35,8 +39,11 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, util::Diagn } if (hasRestParameter) { - util::DiagnosticMessageParams diagnosticParams = {}; - diagnosticEngine.LogDiagnostic(diagnostic::REST_PARAM_LAST, std::move(diagnosticParams), param->Start()); + // NOTE(pronai): This seems to be covered in parser. As the comment above says, it's unclear why the + // lowering is needed. + ES2PANDA_UNREACHABLE_POS(param->Start()); + diagnosticEngine.LogDiagnostic(diagnostic::REST_PARAM_NOT_LAST, util::DiagnosticMessageParams {}, + param->Start()); } if (param->IsOptional()) { @@ -133,8 +140,8 @@ static ir::BlockStatement *CreateFunctionBody(ir::MethodDefinition *method, publ { auto const allocator = ctx->allocator; ArenaVector funcStatements(allocator->Adapter()); - ES2PANDA_ASSERT(method->Id()); + ES2PANDA_ASSERT(method->Id() != nullptr); auto *const callee = util::NodeAllocator::ForceSetParent(allocator, method->Id()->Name(), allocator); @@ -142,6 +149,7 @@ static ir::BlockStatement *CreateFunctionBody(ir::MethodDefinition *method, publ auto *paramInst = CreateTypeParameterInstantiation(method, ctx); auto *callExpression = util::NodeAllocator::ForceSetParent( allocator, accessor != nullptr ? accessor : callee, std::move(funcCallArgs), paramInst, false, false); + ES2PANDA_ASSERT(callExpression != nullptr); callExpression->SetRange(method->Range()); // NOTE: Used to locate the original node when an error occurs funcStatements.push_back(util::NodeAllocator::ForceSetParent(allocator, callExpression)); @@ -182,14 +190,15 @@ static void CreateFunctionOverload(ir::MethodDefinition *method, ArenaVectorallocator; auto *funcExpression = CreateFunctionExpression(method, ctx, std::move(funcDefinitionArgs), std::move(funcCallArgs)); + ES2PANDA_ASSERT(funcExpression != nullptr); auto *ident = funcExpression->Function()->Id()->Clone(allocator, nullptr); auto *const overloadMethod = util::NodeAllocator::ForceSetParent( allocator, method->Kind(), ident, funcExpression, method->Modifiers(), allocator, false); + ES2PANDA_ASSERT(overloadMethod != nullptr && overloadMethod->Function() != nullptr); overloadMethod->Function()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD | ir::ScriptFunctionFlags::SYNTHETIC); overloadMethod->SetRange(funcExpression->Range()); - ES2PANDA_ASSERT(overloadMethod->Function()); if (!method->IsDeclare() && method->Parent()->IsTSInterfaceBody()) { overloadMethod->Function()->Body()->AsBlockStatement()->ClearStatements(); } @@ -207,11 +216,13 @@ static void ExpandOptionalParameterAnnotationsToUnions(public_lib::Context *ctx, for (auto p : function->Params()) { auto param = p->AsETSParameterExpression(); if (param->IsOptional() && param->Initializer() == nullptr) { - param->SetTypeAnnotation(util::NodeAllocator::ForceSetParent( - allocator, - ArenaVector({param->TypeAnnotation(), allocator->New(allocator)}, - allocator->Adapter()), - allocator)); + ArenaVector typeNodes(allocator->Adapter()); + if (param->TypeAnnotation() != nullptr) { + typeNodes.emplace_back(param->TypeAnnotation()); + } + typeNodes.emplace_back(allocator->New(allocator)); + param->SetTypeAnnotation( + util::NodeAllocator::ForceSetParent(allocator, std::move(typeNodes), allocator)); param->TypeAnnotation()->SetParent(param->Ident()); } } @@ -243,6 +254,7 @@ static void ClearOptionalParameters(public_lib::Context *ctx, ir::ScriptFunction static void ProcessGlobalFunctionDefinition(ir::MethodDefinition *method, public_lib::Context *ctx) { + ES2PANDA_ASSERT(method->Function() != nullptr); auto allocator = ctx->allocator; ExpandOptionalParameterAnnotationsToUnions(ctx, method->Function()); auto const ¶ms = method->Function()->Params(); @@ -260,10 +272,12 @@ static void ProcessGlobalFunctionDefinition(ir::MethodDefinition *method, public for (size_t i = 0; i < params.size() - paramsToCut; ++i) { auto param = params[i]->AsETSParameterExpression(); - callArgs.push_back(param->Ident()->CloneReference(allocator, nullptr)->AsIdentifier()); - ES2PANDA_ASSERT(param->Ident()->Clone(allocator, nullptr)); - functionParams.push_back(allocator->New( - param->Ident()->Clone(allocator, nullptr)->AsIdentifier(), false, allocator)); + auto *cloneRef = param->Ident()->CloneReference(allocator, nullptr); + auto *clone = param->Ident()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(cloneRef != nullptr && clone != nullptr); + callArgs.push_back(cloneRef->AsIdentifier()); + functionParams.push_back( + allocator->New(clone->AsIdentifier(), false, allocator)); } for (size_t i = params.size() - paramsToCut; i < params.size(); ++i) { @@ -315,6 +329,9 @@ bool DefaultParametersInConstructorLowering::PostconditionForModule([[maybe_unus return false; } for (auto *const it : node->AsMethodDefinition()->Function()->Params()) { + if (it->IsBrokenExpression()) { + continue; + } auto const *const param = it->AsETSParameterExpression(); if (param->IsOptional()) { return true; diff --git a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp index 901046c0779895a5ad1c2f3ea9c424f54a5eefae..2c7afb91de09f6858c4fe0525b746f225d4ed6b4 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp @@ -98,6 +98,7 @@ static void TransformFunction(public_lib::Context *ctx, ir::ScriptFunction *func } if (param->AsETSParameterExpression()->TypeAnnotation() == nullptr) { // #23134 ES2PANDA_ASSERT(ctx->diagnosticEngine->IsAnyError()); + param->AsETSParameterExpression()->SetInitializer(nullptr); continue; } defaultParams.push_back(param->AsETSParameterExpression()); diff --git a/ets2panda/compiler/lowering/ets/dynamicImport.cpp b/ets2panda/compiler/lowering/ets/dynamicImport.cpp index 2801433e224662e81108ea569e0cbf726f1b9dec..819e81ad1e1b8dfab60ddf433377d68dc6da88ed 100644 --- a/ets2panda/compiler/lowering/ets/dynamicImport.cpp +++ b/ets2panda/compiler/lowering/ets/dynamicImport.cpp @@ -28,6 +28,8 @@ using AstNodePtr = ir::AstNode *; static constexpr std::string_view LAZY_IMPORT_OBJECT_SUFFIX = "%%lazyImportObject-"; static constexpr std::string_view FIELD_NAME = "value"; +static checker::Type *CreateModuleObjectType(public_lib::Context *ctx, ir::ETSImportDeclaration *importDecl); + ir::ClassDeclaration *GetOrCreateLazyImportObjectClass(ark::ArenaAllocator *allocator, ir::ETSImportDeclaration *importDecl, parser::Program *program) { @@ -99,13 +101,68 @@ static void AddImportInitializationStatement(public_lib::Context *ctx, ir::ETSIm statements->push_back(util::NodeAllocator::ForceSetParent(allocator, initializer)); } -checker::Type *CreateModuleObjectType(public_lib::Context *ctx, ir::ETSImportDeclaration *importDecl) +static void ImportNamespaceObjectTypeAddReExportType(public_lib::Context *ctx, varbinder::ETSBinder *varbinder, + ir::ETSImportDeclaration *importDecl, + checker::ETSObjectType *lastObjectType) +{ + for (auto item : varbinder->AsETSBinder()->ReExportImports()) { + if (importDecl->DeclPath() != item->GetProgramPath().Mutf8()) { + continue; + } + auto *reExportType = CreateModuleObjectType(ctx, item->GetETSImportDeclarations()); + if (reExportType->IsTypeError()) { + continue; + } + ES2PANDA_ASSERT(lastObjectType != nullptr); + lastObjectType->AddReExports(reExportType->AsETSObjectType()); + for (auto node : importDecl->Specifiers()) { + if (node->IsImportSpecifier()) { + auto specifier = node->AsImportSpecifier(); + lastObjectType->AddReExportAlias(specifier->Imported()->Name(), specifier->Local()->Name()); + } + } + } +} + +static void SetPropertiesForModuleObject(public_lib::Context *ctx, checker::ETSObjectType *moduleObjType, + const util::StringView &importPath, ir::ETSImportDeclaration *importDecl) +{ + auto checker = ctx->GetChecker()->AsETSChecker(); + auto varbinder = static_cast(checker->VarBinder()->AsETSBinder()); + parser::Program *program = + checker->SelectEntryOrExternalProgram(static_cast(varbinder), importPath); + // Check imported properties before assigning them to module object + ES2PANDA_ASSERT(program != nullptr); + if (!program->IsASTChecked()) { + // NOTE: helps to avoid endless loop in case of recursive imports that uses all bindings + program->SetASTChecked(); + program->Ast()->Check(checker); + } + + checker->BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); + + checker->BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); + + checker->BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); + + checker->BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); + + checker->BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); +} + +static checker::Type *CreateModuleObjectType(public_lib::Context *ctx, ir::ETSImportDeclaration *importDecl) { auto checker = ctx->GetChecker()->AsETSChecker(); auto varbinder = static_cast(checker->VarBinder()->AsETSBinder()); auto allocator = checker->ProgramAllocator(); - const auto importPath = importDecl->DeclPath(); + const auto importPath = importDecl->DeclPath() == util::ImportPathManager::DUMMY_PATH ? importDecl->ResolvedSource() + : importDecl->DeclPath(); auto program = checker->SelectEntryOrExternalProgram(varbinder, importPath); if (program == nullptr) { return checker->GlobalTypeError(); @@ -124,11 +181,29 @@ checker::Type *CreateModuleObjectType(public_lib::Context *ctx, ir::ETSImportDec auto *rootDecl = allocator->New(moduleName); auto *rootVar = allocator->New(rootDecl, varbinder::VariableFlags::NONE); rootVar->SetTsType(moduleObjectType); - checker->SetPropertiesForModuleObject(moduleObjectType, importPath, nullptr); + ImportNamespaceObjectTypeAddReExportType(ctx, program->VarBinder()->AsETSBinder(), importDecl, moduleObjectType); + SetPropertiesForModuleObject(ctx, moduleObjectType, importPath, nullptr); + moduleObjectType->AddObjectFlag(checker::ETSObjectFlags::LAZY_IMPORT_OBJECT); return moduleObjectType; } +static void FillVarMapForImportSpecifiers(const ArenaVector &specifiers, ir::ClassDefinition *classDef, + ArenaUnorderedMap &varMap) +{ + for (auto specifier : specifiers) { + if (specifier->IsImportSpecifier()) { + auto *var = specifier->AsImportSpecifier()->Imported()->Variable(); + var->AddFlag(varbinder::VariableFlags::DYNAMIC); + varMap.insert({var, classDef}); + } else if (specifier->IsImportNamespaceSpecifier()) { + auto *var = specifier->AsImportNamespaceSpecifier()->Local()->Variable(); + var->AddFlag(varbinder::VariableFlags::DYNAMIC); + varMap.insert({var, classDef}); + } + } +} + static void BuildLazyImportObject(public_lib::Context *ctx, ir::ETSImportDeclaration *importDecl, parser::Program *program, ArenaUnorderedMap &moduleMap, @@ -144,11 +219,7 @@ static void BuildLazyImportObject(public_lib::Context *ctx, ir::ETSImportDeclara } auto *classDecl = GetOrCreateLazyImportObjectClass(allocator, importDecl, program); - for (auto specifier : importDecl->Specifiers()) { - auto var = specifier->AsImportSpecifier()->Imported()->Variable(); - var->AddFlag(varbinder::VariableFlags::DYNAMIC); - varMap.insert({var, classDecl->Definition()}); - } + FillVarMapForImportSpecifiers(importDecl->Specifiers(), classDecl->Definition(), varMap); const auto className = classDecl->Definition()->Ident()->Name(); auto found = moduleMap.find(className); @@ -160,7 +231,6 @@ static void BuildLazyImportObject(public_lib::Context *ctx, ir::ETSImportDeclara auto *objType = CreateModuleObjectType(ctx, importDecl)->AsETSObjectType(); moduleMap.insert({className, objType}); - objType->AddObjectFlag(checker::ETSObjectFlags::LAZY_IMPORT_OBJECT); auto moduleType = checker->CreateGradualType(objType, Language::Id::JS); auto parser = ctx->parser->AsETSParser(); @@ -182,10 +252,6 @@ static void BuildLazyImportObject(public_lib::Context *ctx, ir::ETSImportDeclara classDecl->Definition()->EmplaceBody(initializer); initializer->SetParent(classDecl->Definition()); - for (auto specifier : importDecl->Specifiers()) { - varMap.insert({specifier->AsImportSpecifier()->Imported()->Variable(), classDecl->Definition()}); - } - program->GlobalClass()->EmplaceBody(classDecl); classDecl->SetParent(program->GlobalClass()); @@ -195,15 +261,32 @@ static void BuildLazyImportObject(public_lib::Context *ctx, ir::ETSImportDeclara classDecl->Check(checker); } +static ir::MemberExpression *CreateTripleMemberExpr(ArenaAllocator *allocator, const util::StringView &left, + const util::StringView &middle, const util::StringView &right) +{ + auto *leftId = allocator->New(left, allocator); + auto *middleId = allocator->New(middle, allocator); + auto *expr = util::NodeAllocator::ForceSetParent( + allocator, leftId, middleId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + auto *rightId = allocator->New(right, allocator); + return util::NodeAllocator::ForceSetParent( + allocator, expr, rightId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); +} + static AstNodePtr TransformIdentifier(ir::Identifier *ident, public_lib::Context *ctx, const ArenaUnorderedMap &varMap) { auto checker = ctx->GetChecker()->AsETSChecker(); auto varBinder = checker->VarBinder()->AsETSBinder(); auto allocator = checker->ProgramAllocator(); + if (ident->Variable()->Declaration() != nullptr && ident->Variable()->Declaration()->Node() != nullptr && + ident->Variable()->Declaration()->Node()->IsImportNamespaceSpecifier()) { + return ident; + } const auto parent = ident->Parent(); - if (parent->IsImportSpecifier() || parent->IsScriptFunction() || parent->IsMethodDefinition()) { + if (parent->IsImportSpecifier() || parent->IsImportNamespaceSpecifier() || parent->IsScriptFunction() || + parent->IsMethodDefinition()) { return ident; } @@ -212,22 +295,80 @@ static AstNodePtr TransformIdentifier(ir::Identifier *ident, public_lib::Context return ident; } - auto newIdent = allocator->New(ident->Variable()->Name(), allocator); - auto *leftId = allocator->New(varIt->second->Ident()->Name(), allocator); - auto *rightId = allocator->New(FIELD_NAME, allocator); - - auto *expr = util::NodeAllocator::ForceSetParent( - allocator, leftId, rightId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + auto *memberExpr = + CreateTripleMemberExpr(allocator, varIt->second->Ident()->Name(), FIELD_NAME, ident->Variable()->Name()); + memberExpr->SetParent(parent); + // Ensure that it will not be incorrectly converted to ArrowType. + if (parent->IsCallExpression() && parent->AsCallExpression()->Callee() == ident) { + parent->AsCallExpression()->SetCallee(memberExpr); + } + CheckLoweredNode(varBinder, checker, memberExpr); + return memberExpr; +} - auto *memberExpr = util::NodeAllocator::ForceSetParent( - allocator, expr, newIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); +AstNodePtr TransformTsQualifiedName(ir::TSQualifiedName *qualifiedName, public_lib::Context *ctx, + const ArenaUnorderedMap &varMap) +{ + auto checker = ctx->GetChecker()->AsETSChecker(); + auto varBinder = checker->VarBinder()->AsETSBinder(); + auto allocator = checker->ProgramAllocator(); + if (!qualifiedName->Left()->IsIdentifier()) { + return qualifiedName; + } + auto *moduleId = qualifiedName->Left()->AsIdentifier(); + if (moduleId->Variable() != nullptr && moduleId->Variable()->Declaration() != nullptr && + !moduleId->Variable()->Declaration()->Node()->IsImportNamespaceSpecifier()) { + return qualifiedName; + } + auto varIt = varMap.find(moduleId->Variable()); + if (varIt == varMap.end()) { + return qualifiedName; + } + const auto parent = qualifiedName->Parent(); + auto *newIdent = allocator->New(qualifiedName->Right()->AsIdentifier()->Name(), allocator); + auto *memberExpr = CreateTripleMemberExpr(allocator, varIt->second->Ident()->Name(), FIELD_NAME, newIdent->Name()); memberExpr->SetParent(parent); + // Ensure that it will not be incorrectly converted to ArrowType. + if (parent->IsCallExpression() && parent->AsCallExpression()->Callee() == qualifiedName) { + parent->AsCallExpression()->SetCallee(memberExpr); + } CheckLoweredNode(varBinder, checker, memberExpr); - return memberExpr; } +AstNodePtr TransformMemberExpression(ir::MemberExpression *memberExpr, public_lib::Context *ctx, + const ArenaUnorderedMap &varMap) +{ + auto checker = ctx->GetChecker()->AsETSChecker(); + auto varBinder = checker->VarBinder()->AsETSBinder(); + auto allocator = checker->ProgramAllocator(); + if (!memberExpr->Object()->IsIdentifier() || !memberExpr->Property()->IsIdentifier()) { + return memberExpr; + } + auto *moduleId = memberExpr->Object()->AsIdentifier(); + if (moduleId->Variable()->Declaration() != nullptr && + !moduleId->Variable()->Declaration()->Node()->IsImportNamespaceSpecifier()) { + return memberExpr; + } + auto varIt = varMap.find(moduleId->Variable()); + if (varIt == varMap.end()) { + return memberExpr; + } + const auto parent = memberExpr->Parent(); + auto *newIdent = allocator->New(memberExpr->Property()->AsIdentifier()->Name(), allocator); + auto *res = CreateTripleMemberExpr(allocator, varIt->second->Ident()->Name(), FIELD_NAME, newIdent->Name()); + res->SetParent(parent); + + // Ensure that it will not be incorrectly converted to ArrowType. + if (parent->IsCallExpression() && parent->AsCallExpression()->Callee() == memberExpr) { + parent->AsCallExpression()->SetCallee(res); + } + CheckLoweredNode(varBinder, checker, res); + + return res; +} + bool DynamicImport::PerformForModule(public_lib::Context *ctx, parser::Program *program) { auto allocator = ctx->GetChecker()->ProgramAllocator(); @@ -244,6 +385,12 @@ bool DynamicImport::PerformForModule(public_lib::Context *ctx, parser::Program * if (node->IsIdentifier() && node->AsIdentifier()->Variable() != nullptr) { return TransformIdentifier(node->AsIdentifier(), ctx, varMap); } + if (node->IsTSQualifiedName()) { + return TransformTsQualifiedName(node->AsTSQualifiedName(), ctx, varMap); + } + if (node->IsMemberExpression() && node->AsMemberExpression()->PropVar() != nullptr) { + return TransformMemberExpression(node->AsMemberExpression(), ctx, varMap); + } return node; }, Name()); diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index 8db2e4c678fc9769adbcfd0cfafe417f656c7ac7..600b13a35c81e7811381239e00921936d15d21a0 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -167,6 +167,7 @@ template auto *const arrayClassProp = AllocNode( arrayIdent, arrayExpr, typeAnnotation, ir::ModifierFlags::STATIC | ir::ModifierFlags::PRIVATE | ir::ModifierFlags::READONLY, Allocator(), false); + ES2PANDA_ASSERT(arrayClassProp != nullptr); arrayClassProp->SetParent(enumClass); enumClass->EmplaceBody(arrayClassProp); @@ -327,6 +328,7 @@ ir::ClassDeclaration *EnumLoweringPhase::CreateClass(ir::TSEnumDeclaration *cons CreateCCtorForEnumClass(classDef); } CreateCtorForEnumClass(classDef, enumType); + classDecl->SetRange(enumDecl->Range()); return classDecl; } @@ -345,6 +347,7 @@ void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumC ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::HIDDEN, ir::ModifierFlags::STATIC, Language(Language::Id::ETS)}); + ES2PANDA_ASSERT(func != nullptr); func->SetIdent(id); id->SetParent(func); @@ -354,6 +357,7 @@ void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumC auto *const methodDef = AllocNode(ir::MethodDefinitionKind::METHOD, identClone, funcExpr, ir::ModifierFlags::PRIVATE | ir::ModifierFlags::STATIC, Allocator(), false); + ES2PANDA_ASSERT(methodDef != nullptr); methodDef->SetParent(enumClass); enumClass->EmplaceBody(methodDef); } @@ -600,7 +604,6 @@ ir::ClassDeclaration *EnumLoweringPhase::CreateEnumStringClassFromEnumDeclaratio enumClassDecl->SetParent(enumDecl->Parent()); ProcessEnumClassDeclaration(enumDecl, flags, enumClassDecl); - return enumClassDecl; } diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp index e74ea9ce958031501326d405317cba0fd98355ad..7ec0e78cdb05ace25f14aeeb6d0d8d97d06baabb 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp @@ -85,9 +85,10 @@ void GenericBridgesPhase::AddGenericBridge(ir::ClassDefinition const *const clas auto const sourceCode = CreateMethodDefinitionString(classDefinition, baseSignature, derivedFunction, typeNodes); - auto *const bridgeMethod = - parser->CreateFormattedClassMethodDefinition(sourceCode, typeNodes)->AsMethodDefinition(); - ES2PANDA_ASSERT(bridgeMethod); + auto *const bridgeMethodDefinition = parser->CreateFormattedClassMethodDefinition(sourceCode, typeNodes); + ES2PANDA_ASSERT(bridgeMethodDefinition != nullptr); + auto *const bridgeMethod = bridgeMethodDefinition->AsMethodDefinition(); + ES2PANDA_ASSERT(bridgeMethod != nullptr && methodDefinition->Id() != nullptr); bridgeMethod->AddModifier(methodDefinition->Modifiers()); bridgeMethod->ClearModifier(ir::ModifierFlags::NATIVE | ir::ModifierFlags::ABSTRACT); bridgeMethod->AddAstNodeFlags(methodDefinition->GetAstNodeFlags()); @@ -208,7 +209,7 @@ static ir::MethodDefinition *FindBridgeCandidate(ir::ClassDefinition const *cons // Skip `static`, `final` and special methods... if (baseMethod->Kind() != ir::MethodDefinitionKind::METHOD || baseMethod->IsStatic() || baseMethod->IsFinal() || - baseMethod->Id()->Name().Utf8().find("lambda$invoke$") != std::string_view::npos) { + baseMethod->Id()->Name().Utf8().find("lambda_invoke-") != std::string_view::npos) { return nullptr; } @@ -264,7 +265,7 @@ void GenericBridgesPhase::CreateGenericBridges(ir::ClassDefinition const *const } GenericBridgesPhase::Substitutions GenericBridgesPhase::GetSubstitutions( - checker::ETSObjectType const *const objectType, ArenaVector const &typeParameters) const noexcept + checker::ETSObjectType const *const objectType, ArenaVector const &typeParameters) const { auto const &typeArguments = objectType->TypeArguments(); auto const parameterNumber = typeParameters.size(); diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.h b/ets2panda/compiler/lowering/ets/genericBridgesLowering.h index c9b64c44d1eb0d56df7b2f71a79335b24c080bc5..a15c7ed01de3946dd06977c8e2dfb6307cce0338 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.h +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.h @@ -42,7 +42,7 @@ private: ArenaVector const &interfaces) const; Substitutions GetSubstitutions(checker::ETSObjectType const *const objectType, - ArenaVector const &typeParameters) const noexcept; + ArenaVector const &typeParameters) const; void CreateGenericBridges(ir::ClassDefinition const *classDefinition, Substitutions &substitutions, ArenaVector const &items) const; diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp index 4998efb733f78c29999d516dbd1121855d97180b..65cd44cfd1f2c185ec097ef8714a83c357c8fdbd 100644 --- a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -20,6 +20,7 @@ #include "generated/signatures.h" #include "ir/expressions/assignmentExpression.h" #include "util/helpers.h" +#include "util/nameMangler.h" namespace ark::es2panda::compiler { @@ -152,9 +153,8 @@ static void FillClassBody(public_lib::Context *ctx, ArenaVector * copyIfaceMethod->Function()->SetSignature(ifaceMethod->Function()->Signature()); if (currentType != nullptr) { - auto instanProp = - currentType->GetOwnProperty(ifaceMethod->Id()->Name()); - auto funcType = (instanProp != nullptr) ? instanProp->TsType() : nullptr; + auto prop = currentType->GetOwnProperty(ifaceMethod->Id()->Name()); + auto funcType = (prop != nullptr) ? prop->TsType() : nullptr; if (funcType != nullptr) { ES2PANDA_ASSERT(funcType->IsETSFunctionType() && funcType->AsETSFunctionType()->FindGetter() != nullptr); @@ -163,8 +163,9 @@ static void FillClassBody(public_lib::Context *ctx, ArenaVector * } // Field identifier - util::UString anonClassFieldName( - std::string(compiler::Signatures::PROPERTY) + ifaceMethod->Id()->Name().Mutf8(), ctx->allocator); + std::string newName = util::NameMangler::GetInstance()->CreateMangledNameByTypeAndName( + util::NameMangler::PROPERTY, ifaceMethod->Id()->Name()); + util::UString anonClassFieldName(newName, ctx->allocator); auto *field = CreateAnonClassField(ctx, copyIfaceMethod, anonClassFieldName); if (field->IsReadonly()) { readonlyFields.push_back( diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index c5a750ef4538fe80e89d750b8958610e26b9c6ee..542d287cdf63ddb21ee8e6f715249c60299e8ba8 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -78,6 +78,7 @@ ir::FunctionSignature InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter if (isSetter) { auto paramIdent = field->Key()->AsIdentifier()->Clone(ctx->Allocator(), nullptr); + ES2PANDA_ASSERT(paramIdent != nullptr); paramIdent->SetTsTypeAnnotation(field->TypeAnnotation()->Clone(ctx->Allocator(), nullptr)); paramIdent->TypeAnnotation()->SetParent(paramIdent); @@ -86,6 +87,7 @@ ir::FunctionSignature InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter InitScopesPhaseETS::RunExternalNode(paramIdent, varbinder); auto *const paramExpression = ctx->AllocNode(paramIdent, false, ctx->Allocator()); + ES2PANDA_ASSERT(paramExpression != nullptr); paramExpression->SetRange(paramIdent->Range()); auto [paramVar, node] = paramScope->AddParamDecl(ctx->Allocator(), varbinder, paramExpression); if (node != nullptr) { @@ -109,6 +111,7 @@ ir::MethodDefinition *InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter auto classScope = NearestScope(field); auto *paramScope = ctx->Allocator()->New(ctx->Allocator(), classScope); auto *functionScope = ctx->Allocator()->New(ctx->Allocator(), paramScope); + ES2PANDA_ASSERT(functionScope != nullptr); functionScope->BindParamScope(paramScope); paramScope->BindFunctionScope(functionScope); @@ -122,7 +125,8 @@ ir::MethodDefinition *InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter ctx->Allocator(), ir::ScriptFunction::ScriptFunctionData { nullptr, std::move(signature), // CC-OFF(G.FMT.02) project code style // CC-OFFNXT(G.FMT.02) project code style - isSetter ? ir::ScriptFunctionFlags::SETTER : ir::ScriptFunctionFlags::GETTER, flags}); + isSetter ? ir::ScriptFunctionFlags::SETTER : ir::ScriptFunctionFlags::GETTER, flags, + classScope->Node()->AsTSInterfaceDeclaration()->Language()}); func->SetRange(field->Range()); func->SetScope(functionScope); @@ -153,7 +157,9 @@ ir::MethodDefinition *InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter if (!field->Annotations().empty()) { ArenaVector functionAnnotations(ctx->Allocator()->Adapter()); for (auto *annotationUsage : field->Annotations()) { - functionAnnotations.push_back(annotationUsage->Clone(ctx->Allocator(), method)->AsAnnotationUsage()); + auto annoClone = annotationUsage->Clone(ctx->Allocator(), method)->AsAnnotationUsage(); + InitScopesPhaseETS::RunExternalNode(annoClone, varbinder); + functionAnnotations.push_back(annoClone); } method->Function()->SetAnnotations(std::move(functionAnnotations)); } @@ -256,6 +262,7 @@ ir::Expression *InterfacePropertyDeclarationsPhase::UpdateInterfaceProperties(pu } auto newInterface = ctx->AllocNode(std::move(newPropertyList)); + ES2PANDA_ASSERT(newInterface != nullptr); newInterface->SetRange(interface->Range()); newInterface->SetParent(interface->Parent()); diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index f621292487d3bbf1aea48fc397109aa79ad8969f..753115eafd1faf593d72cb569aff0ef05ebb03d2 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -20,6 +20,7 @@ #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" #include "util/options.h" +#include "util/nameMangler.h" namespace ark::es2panda::compiler { @@ -51,6 +52,7 @@ struct LambdaClassInvokeInfo { size_t arity = 0; util::StringView restParameterIdentifier = ""; util::StringView restArgumentIdentifier = ""; + ArenaVector *argNames = nullptr; }; static std::pair FindEnclosingClassAndFunction(ir::AstNode *ast) @@ -88,13 +90,122 @@ static void ResetCalleeCount() static util::StringView CreateCalleeName(ArenaAllocator *allocator) { - auto name = util::UString(util::StringView("lambda$invoke$"), allocator); std::lock_guard lock(g_calleeCountMutex); - name.Append(std::to_string(g_calleeCount++)); + auto name = util::UString( + util::StringView(util::NameMangler::GetInstance()->CreateMangledNameForLambdaInvoke(g_calleeCount++)), + allocator); return name.View(); } -static std::pair CloneTypeParams( +static void ProcessTypeParameterProperties(checker::ETSTypeParameter *oldTypeParam, + checker::ETSTypeParameter *newTypeParam, + ir::TSTypeParameter *newTypeParamNode, checker::Substitution *substitution, + public_lib::Context *ctx) +{ + auto *checker = ctx->GetChecker()->AsETSChecker(); + auto *allocator = ctx->allocator; + if (auto *oldConstraint = oldTypeParam->GetConstraintType(); oldConstraint != nullptr) { + auto *newConstraint = oldConstraint->Substitute(checker->Relation(), substitution); + newTypeParam->SetConstraintType(newConstraint); + auto *newConstraintNode = allocator->New(newConstraint, allocator); + ES2PANDA_ASSERT(newConstraintNode != nullptr); + newTypeParamNode->SetConstraint(newConstraintNode); + newConstraintNode->SetParent(newTypeParamNode); + } + + if (auto *oldDefault = oldTypeParam->GetDefaultType(); oldDefault != nullptr) { + auto *newDefault = oldDefault->Substitute(checker->Relation(), substitution); + newTypeParam->SetDefaultType(newDefault); + auto *newDefaultNode = allocator->New(newDefault, allocator); + ES2PANDA_ASSERT(newDefaultNode != nullptr); + newTypeParamNode->SetDefaultType(newDefaultNode); + newDefaultNode->SetParent(newTypeParamNode); + } +} + +// NOTE (smartin): The two methods 'CreateNewTypeParamVectors' and 'SetConstraintTypeAndDefaultTypeForTypeParams' +// contain very similar logic that can be found in 'CloneTypeParamsForClass'. Merge these later if possible +static void FillNewTypeParamVectors(ThreadSafeArenaAllocator *allocator, + ArenaVector &newTypeParams, + ArenaVector &newTypeParamNodes, + const checker::Signature *const lambdaSig, + checker::Substitution *const substitution) +{ + for (auto *ix : lambdaSig->TypeParams()) { + auto *oldTypeParam = ix->AsETSTypeParameter(); + auto *newTypeParamId = allocator->New(oldTypeParam->Name(), allocator); + auto *newTypeParamNode = util::NodeAllocator::ForceSetParent(allocator, newTypeParamId, + nullptr, nullptr, allocator); + auto *newTypeParam = allocator->New(); + newTypeParam->SetDeclNode(newTypeParamNode); + + auto *newTypeParamDecl = allocator->New(newTypeParamId->Name()); + newTypeParamDecl->BindNode(newTypeParamNode); + auto *newTypeParamVar = + allocator->New(newTypeParamDecl, varbinder::VariableFlags::TYPE_PARAMETER); + + newTypeParamVar->SetTsType(newTypeParam); + newTypeParamId->SetVariable(newTypeParamVar); + + newTypeParams.push_back(newTypeParam); + newTypeParamNodes.push_back(newTypeParamNode); + substitution->emplace(oldTypeParam, newTypeParam); + } +} + +static void SetConstraintTypeAndDefaultTypeForTypeParams(public_lib::Context *ctx, + const ArenaVector &newTypeParams, + const ArenaVector &newTypeParamNodes, + const checker::Signature *const lambdaSig, + const checker::Substitution *const substitution) +{ + auto *allocator = ctx->allocator; + auto *checker = ctx->GetChecker()->AsETSChecker(); + + for (size_t ix = 0; ix < lambdaSig->TypeParams().size(); ix++) { + auto *oldTypeParam = lambdaSig->TypeParams()[ix]->AsETSTypeParameter(); + + if (auto *oldConstraint = oldTypeParam->GetConstraintType(); oldConstraint != nullptr) { + auto *newConstraint = oldConstraint->Substitute(checker->Relation(), substitution); + newTypeParams[ix]->SetConstraintType(newConstraint); + newTypeParamNodes[ix]->SetConstraint(allocator->New(newConstraint, allocator)); + newTypeParamNodes[ix]->Constraint()->SetParent(newTypeParamNodes[ix]); + } + if (auto *oldDefault = oldTypeParam->GetDefaultType(); oldDefault != nullptr) { + auto *newDefault = oldDefault->Substitute(checker->Relation(), substitution); + newTypeParams[ix]->SetDefaultType(newDefault); + newTypeParamNodes[ix]->SetDefaultType(allocator->New(newDefault, allocator)); + newTypeParamNodes[ix]->DefaultType()->SetParent(newTypeParamNodes[ix]); + } + } +} + +static ir::TSTypeParameterDeclaration *CloneTypeParamsForSignature(public_lib::Context *ctx, + LambdaClassInvokeInfo *lciInfo) +{ + ir::TSTypeParameterDeclaration *oldIrTypeParams = lciInfo->callee->Function()->TypeParams(); + checker::Signature *lambdaSig = lciInfo->lambdaSignature; + // NOTE (smartin): the first condition can be deleted, once the generic lambdas generate correct invoke function + // into the global scope (currently we don't generate type params for them) + if (oldIrTypeParams == nullptr || lambdaSig->TypeParams().empty()) { + return nullptr; + } + + auto *allocator = ctx->allocator; + auto newTypeParams = ArenaVector(allocator->Adapter()); + auto newTypeParamNodes = ArenaVector(allocator->Adapter()); + + FillNewTypeParamVectors(allocator, newTypeParams, newTypeParamNodes, lambdaSig, lciInfo->substitution); + SetConstraintTypeAndDefaultTypeForTypeParams(ctx, newTypeParams, newTypeParamNodes, lambdaSig, + lciInfo->substitution); + + auto *newIrTypeParams = util::NodeAllocator::ForceSetParent( + allocator, std::move(newTypeParamNodes), oldIrTypeParams->RequiredParams()); + + return newIrTypeParams; +} + +static std::pair CloneTypeParamsForClass( public_lib::Context *ctx, ir::TSTypeParameterDeclaration *oldIrTypeParams, ir::ScriptFunction *enclosingFunction, varbinder::Scope *enclosingScope) { @@ -103,7 +214,6 @@ static std::pair CloneT } auto *allocator = ctx->allocator; - auto *checker = ctx->GetChecker()->AsETSChecker(); auto *newScope = allocator->New(allocator, enclosingScope); auto newTypeParams = ArenaVector(allocator->Adapter()); @@ -117,14 +227,14 @@ static std::pair CloneT auto *newTypeParamNode = util::NodeAllocator::ForceSetParent(allocator, newTypeParamId, nullptr, nullptr, allocator); auto *newTypeParam = allocator->New(); - ES2PANDA_ASSERT(newTypeParam); - newTypeParam->SetDeclNode(newTypeParamNode); - auto *newTypeParamDecl = allocator->New(newTypeParamId->Name()); - newTypeParamDecl->BindNode(newTypeParamNode); auto *newTypeParamVar = allocator->New(newTypeParamDecl, varbinder::VariableFlags::TYPE_PARAMETER); + ES2PANDA_ASSERT(newTypeParam != nullptr && newScope != nullptr && newTypeParamDecl != nullptr && + newTypeParamVar != nullptr); + newTypeParam->SetDeclNode(newTypeParamNode); + newTypeParamDecl->BindNode(newTypeParamNode); newTypeParamVar->SetTsType(newTypeParam); newScope->InsertBinding(newTypeParamId->Name(), newTypeParamVar); newTypeParamId->SetVariable(newTypeParamVar); @@ -136,23 +246,12 @@ static std::pair CloneT for (size_t ix = 0; ix < oldIrTypeParams->Params().size(); ix++) { auto *oldTypeParam = enclosingFunction->Signature()->TypeParams()[ix]->AsETSTypeParameter(); - - if (auto *oldConstraint = oldTypeParam->GetConstraintType(); oldConstraint != nullptr) { - auto *newConstraint = oldConstraint->Substitute(checker->Relation(), &substitution); - newTypeParams[ix]->SetConstraintType(newConstraint); - newTypeParamNodes[ix]->SetConstraint(allocator->New(newConstraint, allocator)); - newTypeParamNodes[ix]->Constraint()->SetParent(newTypeParamNodes[ix]); - } - if (auto *oldDefault = oldTypeParam->GetDefaultType(); oldDefault != nullptr) { - auto *newDefault = oldDefault->Substitute(checker->Relation(), &substitution); - newTypeParams[ix]->SetDefaultType(newDefault); - newTypeParamNodes[ix]->SetDefaultType(allocator->New(newDefault, allocator)); - newTypeParamNodes[ix]->DefaultType()->SetParent(newTypeParamNodes[ix]); - } + ProcessTypeParameterProperties(oldTypeParam, newTypeParams[ix], newTypeParamNodes[ix], &substitution, ctx); } auto *newIrTypeParams = util::NodeAllocator::ForceSetParent( allocator, std::move(newTypeParamNodes), oldIrTypeParams->RequiredParams()); + ES2PANDA_ASSERT(newIrTypeParams != nullptr); newIrTypeParams->SetScope(newScope); return {newIrTypeParams, std::move(substitution)}; @@ -166,6 +265,7 @@ inline static varbinder::Variable *InitNewParameterVariable(varbinder::VarBinder checker::Type *newParamType, varbinder::ParamScope *paramScope) { + ES2PANDA_ASSERT(param != nullptr); auto *var = varBinder->AddParamDecl(param); var->SetTsType(newParamType); var->SetScope(paramScope); @@ -201,7 +301,7 @@ ParamsAndVarMap CreateLambdaCalleeParameters(public_lib::Context *ctx, ir::Arrow auto *oldParamType = oldParam->AsETSParameterExpression()->Ident()->TsType(); auto *newParamType = oldParamType->Substitute(checker->Relation(), substitution); auto *newParam = oldParam->AsETSParameterExpression()->Clone(allocator, nullptr); - ES2PANDA_ASSERT(newParam); + ES2PANDA_ASSERT(newParam != nullptr); if (newParam->IsOptional()) { newParam->SetOptional(false); @@ -341,7 +441,7 @@ static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::Ar auto enclosingScope = info->callReceiver != nullptr ? classScope->InstanceMethodScope() : classScope->StaticMethodScope(); - auto [newTypeParams, subst0] = CloneTypeParams(ctx, oldTypeParams, info->enclosingFunction, enclosingScope); + auto [newTypeParams, subst0] = CloneTypeParamsForClass(ctx, oldTypeParams, info->enclosingFunction, enclosingScope); auto &substitution = subst0; // NOTE(gogabr): needed to capture in a lambda later. auto *scopeForMethod = newTypeParams != nullptr ? newTypeParams->Scope() : enclosingScope; @@ -527,7 +627,7 @@ static void CreateLambdaClassConstructor(public_lib::Context *ctx, ir::ClassDefi // NOTE(vpukhov): requires the optimization based on the array type // CC-OFFNXT(G.FUN.01, huge_method) solid logic static ArenaVector CreateRestArgumentsArrayReallocation( - public_lib::Context *ctx, LambdaClassInvokeInfo const *lciInfo) + public_lib::Context *ctx, LambdaClassInvokeInfo const *lciInfo, size_t startIdx) { if (!lciInfo->lambdaSignature->HasRestParameter() || lciInfo->lambdaSignature->RestVar()->TsType()->IsETSTupleType()) { @@ -546,54 +646,49 @@ static ArenaVector CreateRestArgumentsArrayReall ? elementType : checker->CreateETSUnionType({elementType, checker->GlobalETSUndefinedType()}); std::stringstream statements; - auto restParameterIndex = GenName(allocator).View(); - auto spreadArrIterator = GenName(allocator).View(); + auto restParameterLen = GenName(allocator).View(); ir::Statement *args = nullptr; if (restParameterSubstituteType->IsETSArrayType()) { auto tmpArray = GenName(allocator).View(); - statements << "let @@I1: int = 0;"; - if (elementType->IsETSReferenceType()) { - // NOTE(vpukhov): this is a clear null-safety violation that should be rewitten with a runtime intrinsic - statements << "let @@I2: FixedArray<@@T3> = new (@@T4)[@@I5.length];"; - } else { - statements << "let @@I2: FixedArray<@@T3> = new (@@T4)[@@I5.length];"; - } - statements << "let @@I6 = @@I7 as FixedArray<@@T8>;" + // NOTE(vpukhov): this is a clear null-safety violation (when elementType->IsETSReferenceType()) that should be + // rewitten with a runtime intrinsic + // CC-OFFNXT(G.FMT.06) false positive + statements << "let @@I1: int = @@I2.length - " << startIdx + << ";" + // CC-OFFNXT(G.FMT.06) false positive + << "let @@I3: FixedArray<@@T4> = new (@@T5)[@@I6];" // CC-OFFNXT(G.FMT.06) false positive - << "for (let @@I9: @@T10 of @@I11){" + << "let @@I7 = @@I8 as FixedArray<@@T9>;" // CC-OFFNXT(G.FMT.06) false positive - << " @@I12[@@I13] = @@I14 as @@T15;" - // CC-OFFNXT(G.FMT.06, G.FMT.06-CPP) false positive - << " @@I16 = @@I17 + 1;" + << "for (let i: int = 0; i < @@I10; i = i + 1) {" + // CC-OFFNXT(G.FMT.06) false positive + << " @@I11[i] = @@I12[i + " << startIdx << "] as @@T13;" << "}"; args = parser->CreateFormattedStatement( - statements.str(), restParameterIndex, tmpArray, elementTypeWithDefault, elementTypeWithDefault, - lciInfo->restParameterIdentifier, lciInfo->restArgumentIdentifier, tmpArray, elementType, spreadArrIterator, - checker->GlobalETSAnyType(), lciInfo->restParameterIdentifier, lciInfo->restArgumentIdentifier, - restParameterIndex, spreadArrIterator, elementType, restParameterIndex, restParameterIndex); + statements.str(), restParameterLen, lciInfo->restParameterIdentifier, tmpArray, elementTypeWithDefault, + elementTypeWithDefault, restParameterLen, lciInfo->restArgumentIdentifier, tmpArray, elementType, + restParameterLen, lciInfo->restArgumentIdentifier, lciInfo->restParameterIdentifier, elementType); } else { ES2PANDA_ASSERT(restParameterSubstituteType->IsETSResizableArrayType()); auto *typeNode = allocator->New( checker->GetElementTypeOfArray(lciInfo->lambdaSignature->RestVar()->TsType()), allocator); - statements << "let @@I1: int = 0;" - // CC-OFFNXT(G.FMT.06) false positive - << "let @@I2 = new Array<@@T3>(@@I4.length);" - // CC-OFFNXT(G.FMT.06) false positive - << "for (let @@I5:@@T6 of @@I7){" + // CC-OFFNXT(G.FMT.06) false positive + statements << "let @@I1: int = @@I2.length - " << startIdx + << ";" // CC-OFFNXT(G.FMT.06) false positive - << " @@I8.$_set(@@I9, @@I10 as @@T11);" + << "let @@I3 = new Array<@@T4>(@@I5);" // CC-OFFNXT(G.FMT.06) false positive - << " @@I12 = @@I13 + 1;" + << "for (let i: int = 0; i < @@I6; i = i + 1) {" // CC-OFFNXT(G.FMT.06) false positive + << " @@I7.$_set(i, @@I8[i + " << startIdx << "] as @@T9);" << "}"; - args = parser->CreateFormattedStatement( - statements.str(), restParameterIndex, lciInfo->restArgumentIdentifier, typeNode, - lciInfo->restParameterIdentifier, spreadArrIterator, checker->GlobalETSAnyType(), - lciInfo->restParameterIdentifier, lciInfo->restArgumentIdentifier, restParameterIndex, spreadArrIterator, - checker->MaybeBoxType(elementType), restParameterIndex, restParameterIndex); + args = parser->CreateFormattedStatement(statements.str(), restParameterLen, lciInfo->restParameterIdentifier, + lciInfo->restArgumentIdentifier, typeNode, restParameterLen, + restParameterLen, lciInfo->restArgumentIdentifier, + lciInfo->restParameterIdentifier, typeNode); } - ES2PANDA_ASSERT(args); + ES2PANDA_ASSERT(args != nullptr); return ArenaVector(args->AsBlockStatement()->Statements()); } @@ -604,12 +699,15 @@ static void CreateInvokeMethodRestParameter(public_lib::Context *ctx, LambdaClas auto *checker = ctx->GetChecker()->AsETSChecker(); auto *restIdent = Gensym(allocator); - ES2PANDA_ASSERT(restIdent); + ES2PANDA_ASSERT(restIdent != nullptr); lciInfo->restParameterIdentifier = restIdent->Name(); auto *spread = allocator->New(ir::AstNodeType::REST_ELEMENT, allocator, restIdent); - auto *arr = lciInfo->lambdaSignature->RestVar()->TsType()->IsETSTupleType() - ? lciInfo->lambdaSignature->RestVar()->TsType() + ES2PANDA_ASSERT(spread != nullptr); + auto *restVar = lciInfo->lambdaSignature->RestVar(); + auto *arr = (restVar != nullptr && restVar->TsType()->IsETSTupleType()) + ? restVar->TsType() : checker->CreateETSArrayType(checker->GlobalETSAnyType()); + auto *typeAnnotation = allocator->New(arr, allocator); spread->SetTsTypeAnnotation(typeAnnotation); @@ -623,6 +721,24 @@ static void CreateInvokeMethodRestParameter(public_lib::Context *ctx, LambdaClas params->push_back(param); } +static ir::Expression *SetRestIdentOfCallArguments(public_lib::Context *ctx, LambdaClassInvokeInfo const *lciInfo) +{ + auto *allocator = ctx->allocator; + + auto restType = lciInfo->lambdaSignature->RestVar()->TsType(); + auto *restIdent = allocator->New( + restType->IsETSTupleType() ? lciInfo->restParameterIdentifier : lciInfo->restArgumentIdentifier, allocator); + if (restType->IsETSArrayType() || restType->IsETSTupleType()) { + auto *spread = allocator->New(ir::AstNodeType::SPREAD_ELEMENT, allocator, restIdent); + restIdent->SetParent(spread); + return spread; + } + + ES2PANDA_ASSERT(restType->IsETSResizableArrayType()); + restIdent->AddAstNodeFlags(ir::AstNodeFlags::RESIZABLE_REST); + return restIdent; +} + static ArenaVector CreateCallArgumentsForLambdaClassInvoke(public_lib::Context *ctx, LambdaInfo const *info, LambdaClassInvokeInfo const *lciInfo, @@ -653,28 +769,58 @@ static ArenaVector CreateCallArgumentsForLambdaClassInvoke(pub if (!lciInfo->lambdaSignature->HasRestParameter()) { return callArguments; } - auto restType = lciInfo->lambdaSignature->RestVar()->TsType(); - auto *restIdent = allocator->New( - restType->IsETSTupleType() ? lciInfo->restParameterIdentifier : lciInfo->restArgumentIdentifier, allocator); - if (restType->IsETSArrayType() || restType->IsETSTupleType()) { - auto *spread = allocator->New(ir::AstNodeType::SPREAD_ELEMENT, allocator, restIdent); - restIdent->SetParent(spread); - callArguments.push_back(spread); - } else { - ES2PANDA_ASSERT(restType->IsETSResizableArrayType()); - restIdent->AddAstNodeFlags(ir::AstNodeFlags::RESIZABLE_REST); - callArguments.push_back(restIdent); + callArguments.push_back(SetRestIdentOfCallArguments(ctx, lciInfo)); + return callArguments; +} + +static ArenaVector CreateCallArgumentsForLambdaClassInvokeN(public_lib::Context *ctx, + LambdaInfo const *info, + LambdaClassInvokeInfo const *lciInfo) +{ + auto *allocator = ctx->allocator; + auto *parser = ctx->parser->AsETSParser(); + auto *checker = ctx->GetChecker()->AsETSChecker(); + + auto callArguments = ArenaVector(allocator->Adapter()); + for (auto *captured : *info->capturedVars) { + auto *arg = parser->CreateFormattedExpression("this.@@I1", AvoidMandatoryThis(captured->Name())); + callArguments.push_back(arg); + } + + ES2PANDA_ASSERT(lciInfo->argNames->size() == + lciInfo->lambdaSignature->ArgCount() - lciInfo->lambdaSignature->MinArgCount()); + + for (size_t idx = 0; idx < lciInfo->lambdaSignature->MinArgCount(); ++idx) { + auto lambdaParam = lciInfo->lambdaSignature->Params().at(idx); + auto argName = lciInfo->restParameterIdentifier; + auto *type = lambdaParam->TsType()->Substitute(checker->Relation(), lciInfo->substitution); + auto arg = parser->CreateFormattedExpression("@@I1[" + std::to_string(idx) + "] as @@T2 as @@T3", argName, + checker->MaybeBoxType(type), type); + callArguments.push_back(arg); + } + for (size_t nameIdx = 0, idx = lciInfo->lambdaSignature->MinArgCount(); idx < lciInfo->lambdaSignature->ArgCount(); + ++idx, ++nameIdx) { + auto arg = parser->CreateFormattedExpression("@@I1", (*lciInfo->argNames)[nameIdx]); + callArguments.push_back(arg); } + + if (!lciInfo->lambdaSignature->HasRestParameter()) { + return callArguments; + } + + callArguments.push_back(SetRestIdentOfCallArguments(ctx, lciInfo)); return callArguments; } static ir::CallExpression *CreateCallForLambdaClassInvoke(public_lib::Context *ctx, LambdaInfo const *info, - LambdaClassInvokeInfo const *lciInfo, bool wrapToObject) + LambdaClassInvokeInfo const *lciInfo, bool wrapToObject, + bool isInvokeN) { auto *allocator = ctx->allocator; auto *parser = ctx->parser->AsETSParser(); - auto callArguments = CreateCallArgumentsForLambdaClassInvoke(ctx, info, lciInfo, wrapToObject); + auto callArguments = isInvokeN ? CreateCallArgumentsForLambdaClassInvokeN(ctx, info, lciInfo) + : CreateCallArgumentsForLambdaClassInvoke(ctx, info, lciInfo, wrapToObject); ir::Expression *calleeReceiver; if (info->callReceiver != nullptr) { calleeReceiver = parser->CreateFormattedExpression("this.@@I1", "$this"); @@ -685,8 +831,25 @@ static ir::CallExpression *CreateCallForLambdaClassInvoke(public_lib::Context *c auto *calleeMemberExpr = util::NodeAllocator::ForceSetParent( allocator, calleeReceiver, lciInfo->callee->Key()->Clone(allocator, nullptr)->AsExpression(), ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - auto *call = parser->CreateFormattedExpression("@@E1(@@[E2)", calleeMemberExpr, std::move(callArguments)) - ->AsCallExpression(); + + auto *call = util::NodeAllocator::ForceSetParent(allocator, calleeMemberExpr, + std::move(callArguments), nullptr, false); + + // NOTE (smartin): the condition would be better to check the size of the signature's type parameters. But currently + // generic lambdas don't allocate type parameters for they global invoke function, so fix this when the generation + // will be corrected + if (lciInfo->callee->Function()->TypeParams() != nullptr) { + auto origCallTypeParams = lciInfo->lambdaSignature->TypeParams(); + auto typeArgs = ArenaVector(allocator->Adapter()); + for (auto *tp : origCallTypeParams) { + typeArgs.push_back(allocator->New( + tp->Substitute(ctx->GetChecker()->Relation(), lciInfo->substitution), allocator)); + } + auto *typeArg = + util::NodeAllocator::ForceSetParent(allocator, std::move(typeArgs)); + call->SetTypeParams(typeArg); + typeArg->SetParent(call); + } if (lciInfo->classDefinition->TypeParams() != nullptr) { auto typeArgs = ArenaVector(allocator->Adapter()); @@ -711,8 +874,8 @@ static ir::BlockStatement *CreateLambdaClassInvokeBody(public_lib::Context *ctx, auto *checker = ctx->GetChecker()->AsETSChecker(); auto *anyType = checker->GlobalETSAnyType(); - auto *call = CreateCallForLambdaClassInvoke(ctx, info, lciInfo, wrapToObject); - auto bodyStmts = CreateRestArgumentsArrayReallocation(ctx, lciInfo); + auto *call = CreateCallForLambdaClassInvoke(ctx, info, lciInfo, wrapToObject, false); + auto bodyStmts = CreateRestArgumentsArrayReallocation(ctx, lciInfo, 0); if (lciInfo->lambdaSignature->ReturnType() == checker->GlobalVoidType()) { auto *callStmt = util::NodeAllocator::ForceSetParent(allocator, call); @@ -739,9 +902,11 @@ static void CreateLambdaClassInvokeMethod(public_lib::Context *ctx, LambdaInfo c auto *checker = ctx->GetChecker()->AsETSChecker(); auto *anyType = checker->GlobalETSAnyType(); + auto *invokeSigTypeParams = CloneTypeParamsForSignature(ctx, lciInfo); + auto params = ArenaVector(allocator->Adapter()); for (size_t idx = 0; idx < lciInfo->arity; ++idx) { - auto lparam = lciInfo->lambdaSignature->Params().at(idx); + auto *lparam = lciInfo->lambdaSignature->Params().at(idx); auto *type = wrapToObject ? anyType : lparam->TsType()->Substitute(checker->Relation(), lciInfo->substitution); auto *id = util::NodeAllocator::ForceSetParent( allocator, lparam->Name(), allocator->New(type, allocator), allocator); @@ -764,7 +929,7 @@ static void CreateLambdaClassInvokeMethod(public_lib::Context *ctx, LambdaInfo c allocator, allocator, ir::ScriptFunction::ScriptFunctionData { CreateLambdaClassInvokeBody(ctx, info, lciInfo, wrapToObject), - ir::FunctionSignature(nullptr, std::move(params), returnType2, hasReceiver), functionFlag}); + ir::FunctionSignature(invokeSigTypeParams, std::move(params), returnType2, hasReceiver), functionFlag}); auto *invokeId = allocator->New(methodName, allocator); func->SetIdent(invokeId); @@ -781,6 +946,82 @@ static void CreateLambdaClassInvokeMethod(public_lib::Context *ctx, LambdaInfo c invokeMethod->SetParent(lciInfo->classDefinition); } +static ir::BlockStatement *CreateLambdaClassInvokeNBody(public_lib::Context *ctx, LambdaInfo const *info, + LambdaClassInvokeInfo *lciInfo) +{ + auto *allocator = ctx->allocator; + auto *checker = ctx->GetChecker()->AsETSChecker(); + auto *parser = ctx->parser->AsETSParser(); + + auto bodyStmts = CreateRestArgumentsArrayReallocation(ctx, lciInfo, lciInfo->lambdaSignature->MinArgCount()); + auto tempVarNames = allocator->New>(allocator->Adapter()); + + for (size_t idx = lciInfo->lambdaSignature->MinArgCount(); idx < lciInfo->arity; ++idx) { + auto lambdaParam = lciInfo->lambdaSignature->Params().at(idx); + auto argName = lciInfo->restParameterIdentifier; + auto *type = lambdaParam->TsType()->Substitute(checker->Relation(), lciInfo->substitution); + std::stringstream stream; + stream << "let @@I1 = @@I2.length > " << idx << " ? @@I3[" << idx << "] as @@T4 as @@T5 : undefined;"; + tempVarNames->push_back(GenName(allocator)); + auto stmt = parser->CreateFormattedStatement(stream.str(), tempVarNames->back(), argName, argName, + checker->MaybeBoxType(type), type); + bodyStmts.push_back(stmt); + } + + lciInfo->argNames = tempVarNames; + auto *call = CreateCallForLambdaClassInvoke(ctx, info, lciInfo, false, true); + + if (lciInfo->lambdaSignature->ReturnType() == checker->GlobalVoidType()) { + auto *callStmt = util::NodeAllocator::ForceSetParent(allocator, call); + bodyStmts.push_back(callStmt); + auto *returnStmt = + util::NodeAllocator::ForceSetParent(allocator, allocator->New()); + bodyStmts.push_back(returnStmt); + } else { + auto *returnStmt = util::NodeAllocator::ForceSetParent(allocator, call); + bodyStmts.push_back(returnStmt); + } + + return util::NodeAllocator::ForceSetParent(allocator, allocator, std::move(bodyStmts)); +} + +static void CreateLambdaClassInvokeN(public_lib::Context *ctx, LambdaInfo const *info, LambdaClassInvokeInfo *lciInfo) +{ + auto *allocator = ctx->allocator; + auto *checker = ctx->GetChecker()->AsETSChecker(); + auto *anyType = checker->GlobalETSAnyType(); + + auto params = ArenaVector(allocator->Adapter()); + CreateInvokeMethodRestParameter(ctx, lciInfo, ¶ms); + + if (lciInfo->lambdaSignature->HasRestParameter()) { + lciInfo->restArgumentIdentifier = GenName(allocator).View(); + } + + auto *returnType = allocator->New(anyType, allocator); + bool hasReceiver = lciInfo->lambdaSignature->HasSignatureFlag(checker::SignatureFlags::EXTENSION_FUNCTION); + ir::ScriptFunctionFlags functionFlag = ir::ScriptFunctionFlags::METHOD; + auto *func = util::NodeAllocator::ForceSetParent( + allocator, allocator, + ir::ScriptFunction::ScriptFunctionData { + CreateLambdaClassInvokeNBody(ctx, info, lciInfo), + ir::FunctionSignature(nullptr, std::move(params), returnType, hasReceiver), functionFlag}); + + auto *invokeId = allocator->New("unsafeCall", allocator); + func->SetIdent(invokeId); + + auto *funcExpr = util::NodeAllocator::ForceSetParent(allocator, func); + + auto *invokeIdClone = invokeId->Clone(allocator, nullptr); + auto *invokeMethod = util::NodeAllocator::ForceSetParent( + allocator, ir::MethodDefinitionKind::METHOD, invokeIdClone, funcExpr, ir::ModifierFlags::NONE, allocator, + false); + ES2PANDA_ASSERT(!invokeMethod->IsStatic()); + + lciInfo->classDefinition->EmplaceBody(invokeMethod); + invokeMethod->SetParent(lciInfo->classDefinition); +} + static checker::ETSObjectType *FunctionTypeToLambdaProviderType(checker::ETSChecker *checker, checker::Signature *signature) { @@ -788,10 +1029,6 @@ static checker::ETSObjectType *FunctionTypeToLambdaProviderType(checker::ETSChec ES2PANDA_ASSERT(checker->GlobalBuiltinLambdaType(signature->ArgCount(), true)); return checker->GlobalBuiltinLambdaType(signature->ArgCount(), true)->AsETSObjectType(); } - // Note: FunctionN is not supported yet - if (signature->ArgCount() >= checker->GlobalBuiltinFunctionTypeVariadicThreshold()) { - return nullptr; - } return checker->GlobalBuiltinLambdaType(signature->ArgCount(), false)->AsETSObjectType(); } @@ -801,9 +1038,10 @@ static checker::ETSObjectType *FunctionTypeToLambdaProviderType(checker::ETSChec static void CorrectTheTrueThisForExtensionLambda(public_lib::Context *ctx, ir::ClassDeclaration *lambdaClass, size_t arity, bool hasRestParam) { + auto *checker = ctx->GetChecker()->AsETSChecker(); auto *classScope = lambdaClass->Definition()->Scope(); ArenaVector invokeFuncsOfLambda(ctx->Allocator()->Adapter()); - auto invokeName = checker::FunctionalInterfaceInvokeName(arity, hasRestParam); + auto invokeName = checker->FunctionalInterfaceInvokeName(arity, hasRestParam); invokeFuncsOfLambda.emplace_back( classScope->FindLocal(compiler::Signatures::LAMBDA_OBJECT_INVOKE, varbinder::ResolveBindingOptions::METHODS)); invokeFuncsOfLambda.emplace_back( @@ -843,12 +1081,9 @@ static ir::ClassDeclaration *CreateEmptyLambdaClassDeclaration(public_lib::Conte auto *checker = ctx->GetChecker()->AsETSChecker(); auto *varBinder = ctx->GetChecker()->VarBinder()->AsETSBinder(); - auto lambdaClassName = util::UString {std::string_view {"LambdaObject-"}, allocator}; + auto lambdaClassName = util::UString { + std::string_view {util::NameMangler::GetInstance()->CreateMangledNameForLambdaObject(info->name)}, allocator}; - util::StringView &objectName = info->calleeClass != nullptr ? info->calleeClass->Definition()->Ident()->Name() - : info->calleeInterface->Id()->Name(); - - lambdaClassName.Append(objectName).Append("$").Append(info->name); ES2PANDA_ASSERT(lambdaProviderClass); auto *providerTypeReference = checker->AllocNode( checker->AllocNode( @@ -880,6 +1115,17 @@ static ir::ClassDeclaration *CreateEmptyLambdaClassDeclaration(public_lib::Conte return classDeclaration; } +static void SetModifiersForFunctionReference(ir::ClassDefinition *classDefinition, ir::MethodDefinition *callee, + LambdaInfo const *info) +{ + if (info->isFunctionReference) { + ES2PANDA_ASSERT(callee->Function()); + classDefinition->SetFunctionalReferenceReferencedMethod(callee); + classDefinition->SetModifiers(classDefinition->Modifiers() | + ir::ClassDefinitionModifiers::FUNCTIONAL_REFERENCE); + } +} + static ir::ClassDeclaration *CreateLambdaClass(public_lib::Context *ctx, checker::ETSFunctionType *fntype, ir::MethodDefinition *callee, LambdaInfo const *info) { @@ -888,7 +1134,7 @@ static ir::ClassDeclaration *CreateLambdaClass(public_lib::Context *ctx, checker auto *oldTypeParams = (info->enclosingFunction != nullptr) ? info->enclosingFunction->TypeParams() : nullptr; auto [newTypeParams, subst0] = - CloneTypeParams(ctx, oldTypeParams, info->enclosingFunction, ctx->parserProgram->GlobalClassScope()); + CloneTypeParamsForClass(ctx, oldTypeParams, info->enclosingFunction, ctx->parserProgram->GlobalClassScope()); auto &substitution = subst0; // NOTE(gogabr): needed to capture in a lambda later. auto fnInterface = fntype->Substitute(checker->Relation(), &substitution)->ArrowToFunctionalInterface(checker); @@ -899,12 +1145,7 @@ static ir::ClassDeclaration *CreateLambdaClass(public_lib::Context *ctx, checker auto classDeclaration = CreateEmptyLambdaClassDeclaration(ctx, info, newTypeParams, fnInterface, lambdaProviderClass); auto classDefinition = classDeclaration->Definition(); - if (info->isFunctionReference) { - ES2PANDA_ASSERT(callee->Function()); - classDefinition->SetFunctionalReferenceReferencedMethod(callee); - classDefinition->SetModifiers(classDefinition->Modifiers() | - ir::ClassDefinitionModifiers::FUNCTIONAL_REFERENCE); - } + SetModifiersForFunctionReference(classDefinition, callee, info); CreateLambdaClassFields(ctx, classDefinition, info, &substitution); CreateLambdaClassConstructor(ctx, classDefinition, info, &substitution); @@ -917,17 +1158,24 @@ static ir::ClassDeclaration *CreateLambdaClass(public_lib::Context *ctx, checker lciInfo.substitution = &substitution; lciInfo.lambdaSignature = signature; - for (size_t arity = signature->MinArgCount(); arity <= signature->ArgCount(); ++arity) { - lciInfo.arity = arity; - auto invokeMethodName = - util::UString {checker::FunctionalInterfaceInvokeName(arity, signature->HasRestParameter()), ctx->allocator} - .View(); - CreateLambdaClassInvokeMethod(ctx, info, &lciInfo, invokeMethodName, true); - // NOTE(vpukhov): for optional methods, the required invokeRk k={min, max-1} is not emitted + if (signature->ArgCount() < checker->GlobalBuiltinFunctionTypeVariadicThreshold()) { + for (size_t arity = signature->MinArgCount(); arity <= signature->ArgCount(); ++arity) { + lciInfo.arity = arity; + auto invokeMethodName = + util::UString {checker->FunctionalInterfaceInvokeName(arity, signature->HasRestParameter()), + ctx->allocator} + .View(); + CreateLambdaClassInvokeMethod(ctx, info, &lciInfo, invokeMethodName, true); + // NOTE(vpukhov): for optional methods, the required invokeRk k={min, max-1} is not emitted + } + } else { + lciInfo.arity = signature->ArgCount(); + CreateLambdaClassInvokeN(ctx, info, &lciInfo); } + if (signature->HasRestParameter() && signature->RestVar()->TsType()->IsETSTupleType()) { auto invokeMethodName = - util::UString {checker::FunctionalInterfaceInvokeName(lciInfo.arity + 1, signature->HasRestParameter()), + util::UString {checker->FunctionalInterfaceInvokeName(lciInfo.arity + 1, signature->HasRestParameter()), ctx->allocator} .View(); CreateLambdaClassInvokeMethod(ctx, info, &lciInfo, invokeMethodName, true); @@ -1035,12 +1283,13 @@ static ir::ScriptFunction *GetWrappingLambdaParentFunction(public_lib::Context * ir::FunctionSignature {nullptr, std::move(params), allocator->New(signature->ReturnType(), allocator)}, ir::ScriptFunctionFlags::ARROW}); - + ES2PANDA_ASSERT(func != nullptr); ArenaVector bodyStmts {allocator->Adapter()}; ArenaVector callArgs {allocator->Adapter()}; for (auto *p : func->Params()) { ir::Identifier *clone = p->AsETSParameterExpression()->Ident()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(clone != nullptr); if (clone->IsIdentifier() && (clone->IsReference(ScriptExtension::ETS)) && (clone->TypeAnnotation() != nullptr)) { clone->SetTsTypeAnnotation(nullptr); @@ -1185,7 +1434,7 @@ static bool IsFunctionOrMethodCall(checker::ETSChecker *checker, ir::CallExpress // Not skip if invoke pattern Union.() where field is of ETSArrowType if (callee->IsMemberExpression()) { auto me = callee->AsMemberExpression(); - ES2PANDA_ASSERT(me->TsType()); + ES2PANDA_ASSERT(me->TsType() != nullptr); if (me->Object()->TsType() != nullptr && checker->GetApparentType(me->Object()->TsType())->IsETSUnionType() && me->TsType()->IsETSMethodType()) { return true; @@ -1212,26 +1461,29 @@ static ir::AstNode *InsertInvokeCall(public_lib::Context *ctx, ir::CallExpressio auto *oldCallee = call->Callee(); auto *oldType = checker->GetApparentType(oldCallee->TsType()); + ES2PANDA_ASSERT(oldType != nullptr); size_t arity = call->Arguments().size(); auto *ifaceType = oldType->IsETSObjectType() ? oldType->AsETSObjectType() : oldType->AsETSFunctionType()->ArrowToFunctionalInterfaceDesiredArity(checker, arity); + ES2PANDA_ASSERT(ifaceType != nullptr); bool hasRestParam = (oldType->IsETSFunctionType() && oldType->AsETSFunctionType()->ArrowSignature()->HasRestParameter()) || call->Signature()->HasRestParameter(); util::StringView invokeMethodName = - util::UString {checker::FunctionalInterfaceInvokeName(arity, hasRestParam), allocator}.View(); + util::UString {checker->FunctionalInterfaceInvokeName(arity, hasRestParam), allocator}.View(); auto *prop = ifaceType->GetProperty(invokeMethodName, checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | checker::PropertySearchFlags::SEARCH_IN_INTERFACES); ES2PANDA_ASSERT(prop != nullptr); auto *invoke0Id = allocator->New(invokeMethodName, allocator); - ES2PANDA_ASSERT(invoke0Id); + ES2PANDA_ASSERT(invoke0Id != nullptr); invoke0Id->SetTsType(prop->TsType()); invoke0Id->SetVariable(prop); auto *newCallee = util::NodeAllocator::ForceSetParent( allocator, oldCallee, invoke0Id, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + ES2PANDA_ASSERT(newCallee != nullptr); newCallee->SetTsType(prop->TsType()); newCallee->SetObjectType(ifaceType); @@ -1252,7 +1504,7 @@ static ir::AstNode *InsertInvokeCall(public_lib::Context *ctx, ir::CallExpressio if (arg->IsSpreadElement()) { continue; } - Recheck(ctx->phaseManager, varBinder, checker, arg); + CheckLoweredNode(varBinder, checker, arg); } return call; @@ -1311,14 +1563,15 @@ static ir::AstNode *BuildLambdaClassWhenNeeded(public_lib::Context *ctx, ir::Ast // so it is correct to pass ETS extension here to isReference() if (id->IsReference(ScriptExtension::ETS) && id->TsType() != nullptr && id->TsType()->IsETSFunctionType() && !IsInCalleePosition(id) && !IsEnumFunctionCall(id) && IsValidFunctionDeclVar(var) && - !id->Variable()->HasFlag(varbinder::VariableFlags::DYNAMIC) && !IsOverloadedName(id)) { + !IsOverloadedName(id)) { return ConvertFunctionReference(ctx, id); } } if (node->IsMemberExpression()) { auto *mexpr = node->AsMemberExpression(); if (mexpr->Kind() == ir::MemberExpressionKind::PROPERTY_ACCESS && mexpr->TsType() != nullptr && - mexpr->TsType()->IsETSFunctionType() && mexpr->Object()->TsType()->IsETSObjectType()) { + mexpr->TsType()->IsETSFunctionType() && mexpr->Object()->TsType()->IsETSObjectType() && + mexpr->PropVar() != nullptr && !mexpr->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC)) { ES2PANDA_ASSERT(mexpr->Property()->IsIdentifier()); auto *var = mexpr->Object()->TsType()->AsETSObjectType()->GetProperty( mexpr->Property()->AsIdentifier()->Name(), diff --git a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp index 2e0b7f832828cc433c8c1ba42d5b2a46c36a4c2b..c57d29aa9c42cc26a8043da38705095c8a7b9e2e 100644 --- a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp +++ b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp @@ -71,7 +71,7 @@ ir::Expression *ObjectIndexLowering::ProcessIndexSetAccess(parser::ETSParser *pa memberExpression->Property(), assignmentExpression->Right()); setter = loweringResult; } - ES2PANDA_ASSERT(loweringResult != nullptr); + ES2PANDA_ASSERT(loweringResult != nullptr && setter != nullptr); loweringResult->SetParent(assignmentExpression->Parent()); loweringResult->SetRange(assignmentExpression->Range()); setter->AddModifier(ir::ModifierFlags::ARRAY_SETTER); diff --git a/ets2panda/compiler/lowering/ets/objectIterator.cpp b/ets2panda/compiler/lowering/ets/objectIterator.cpp index fa649a253b355362e9b22d1131806ce514227d1b..18a5c5c37345833e4a7af9494793c71439f7cb82 100644 --- a/ets2panda/compiler/lowering/ets/objectIterator.cpp +++ b/ets2panda/compiler/lowering/ets/objectIterator.cpp @@ -159,6 +159,7 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context loopVariableIdent = declaration->Declarators().at(0U)->Id()->AsIdentifier()->Clone(allocator, nullptr); } else if (left->IsIdentifier()) { loopVariableIdent = Gensym(allocator); + ES2PANDA_ASSERT(loopVariableIdent != nullptr); loopVariableIdent->SetName(left->AsIdentifier()->Name()); } else { ES2PANDA_UNREACHABLE(); @@ -167,7 +168,7 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context // Parse ArkTS code string and create corresponding AST nodes auto *const parser = ctx->parser->AsETSParser(); - ES2PANDA_ASSERT(parser != nullptr); + ES2PANDA_ASSERT(parser != nullptr && nextIdent != nullptr && iterIdent != nullptr); auto *const loweringResult = parser->CreateFormattedStatement( whileStatement, iterIdent, forOfStatement->Right(), nextIdent, iterIdent->Clone(allocator, nullptr), @@ -176,16 +177,17 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context loweringResult->SetParent(forOfStatement->Parent()); loweringResult->SetRange(forOfStatement->Range()); - TransferForOfLoopBody(forOfStatement->Body(), loweringResult->AsBlockStatement() - ->Statements()[WHILE_LOOP_POSITION] - ->AsWhileStatement() - ->Body() - ->AsBlockStatement()); + auto loweredWhile = loweringResult->AsBlockStatement()->Statements()[WHILE_LOOP_POSITION]->AsWhileStatement(); + auto whileBody = loweredWhile->Body()->AsBlockStatement(); + TransferForOfLoopBody(forOfStatement->Body(), whileBody); auto *const checker = ctx->GetChecker()->AsETSChecker(); ES2PANDA_ASSERT(checker != nullptr); CheckLoweredNode(varbinder, checker, loweringResult); + if (loweringResult->Parent()->IsLabelledStatement()) { + loweringResult->Parent()->AsLabelledStatement()->Ident()->Variable()->GetScope()->BindNode(loweringResult); + } return loweringResult; } diff --git a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp index b593f51c3ea2f5a501ea4eab9d648872a500e33a..0a17664868cd5e997a8ef6118da133af8e2287ca 100644 --- a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp @@ -192,6 +192,7 @@ static void GenerateNewStatements(public_lib::Context *ctx, ir::ObjectExpression // Generating: let : = new (); auto *genSymIdent = Gensym(allocator); auto *type = ctx->AllocNode(classType, allocator); + ES2PANDA_ASSERT(genSymIdent != nullptr && type != nullptr); ss << "let @@I" << addNode(genSymIdent) << ": @@T" << addNode(type) << " = new @@T" << addNode(type->Clone(allocator, nullptr)) << "();" << std::endl; @@ -225,7 +226,6 @@ static void GenerateNewStatements(public_lib::Context *ctx, ir::ObjectExpression if (isAnonymous && CheckReadonlyAndUpdateCtorArgs(keyIdent, value, ctorArgumentsMap)) { continue; } - ES2PANDA_ASSERT(genSymIdent != nullptr); ss << "@@I" << addNode(genSymIdent->Clone(allocator, nullptr)) << ".@@I" << addNode(keyIdent); if (value->IsBlockExpression()) { diff --git a/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp b/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp index 5da6f6914954c19332cd3fc27cf309ab85d9a929..f532742a386590a331b7657f6dc0912db5938325 100644 --- a/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp +++ b/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp @@ -13,10 +13,10 @@ * limitations under the License. */ +#include + #include "resizableArrayLowering.h" -#include #include "compiler/lowering/util.h" -#include "ir/ets/etsUnionType.h" namespace ark::es2panda::compiler { @@ -24,15 +24,22 @@ using AstNodePtr = ir::AstNode *; static ir::AstNode *ConvertToResizableArrayType(ir::TSArrayType *node, public_lib::Context *ctx, bool insideAnnotdecl) { + std::stringstream typeAnnotationSrc; + typeAnnotationSrc << (insideAnnotdecl ? "FixedArray" : (node->IsReadonlyType() ? "ReadonlyArray" : "Array")) << "<" + << node->ElementType()->DumpEtsSrc() << ">"; + auto *parser = ctx->parser->AsETSParser(); - ir::TypeNode *typeAnnotation = parser->CreateFormattedTypeAnnotation((insideAnnotdecl ? "FixedArray<" : "Array<") + - node->ElementType()->DumpEtsSrc() + ">"); + ir::TypeNode *typeAnnotation = parser->CreateFormattedTypeAnnotation(typeAnnotationSrc.str()); ES2PANDA_ASSERT(typeAnnotation != nullptr); typeAnnotation->SetAnnotations(node->Annotations()); typeAnnotation->SetParent(node->Parent()); typeAnnotation->SetRange(node->Range()); RefineSourceRanges(node); - typeAnnotation->AddModifier(node->Modifiers()); + auto modifier = node->Modifiers(); + if (node->IsReadonlyType()) { + modifier &= ~ir::ModifierFlags::READONLY_PARAMETER; + } + typeAnnotation->AddModifier(modifier); return typeAnnotation; } diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index 952da6e17e77bb3262b7b5d53183e18593c055f4..f65624403fc3729cdfc8f288d56c51e2771783cf 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -34,9 +34,13 @@ static ir::BlockExpression *CreateRestArgsBlockExpression(public_lib::Context *c ArenaVector blockStatements(allocator->Adapter()); const auto arraySymbol = Gensym(allocator); + ES2PANDA_ASSERT(arraySymbol != nullptr); const auto argumentSymbol = Gensym(allocator); + ES2PANDA_ASSERT(argumentSymbol != nullptr); const auto iteratorIndex = Gensym(allocator); + ES2PANDA_ASSERT(iteratorIndex != nullptr); const auto iteratorSymbol = Gensym(allocator); + ES2PANDA_ASSERT(iteratorSymbol != nullptr); const auto elementType = checker->GetElementTypeOfArray(spreadElement->Argument()->TsType()); auto *typeNode = allocator->New(elementType, allocator); blockStatements.push_back( @@ -51,7 +55,6 @@ static ir::BlockExpression *CreateRestArgsBlockExpression(public_lib::Context *c args.emplace_back(argumentSymbol->Clone(allocator, nullptr)); ss << "@@I3[@@I4] = @@I5;"; args.emplace_back(arraySymbol->Clone(allocator, nullptr)); - ES2PANDA_ASSERT(iteratorIndex != nullptr); args.emplace_back(iteratorIndex->Clone(allocator, nullptr)); args.emplace_back(iteratorSymbol->Clone(allocator, nullptr)); ss << "@@I6 = @@I7 + 1;"; @@ -116,6 +119,7 @@ static ir::Expression *CreateRestArgsArray(public_lib::Context *context, ArenaVe // ss << "Array.from<@@T4>(@@I5);"; // Now: // NOTE: refactor me! + ES2PANDA_ASSERT(genSymIdent != nullptr && genSymIdent2 != nullptr); ss << "let @@I1 : FixedArray<@@T2> = @@E3;"; ss << "let @@I4 : Array<@@T5> = new Array<@@T6>(@@I7.length);"; ss << "for (let i = 0; i < @@I8.length; ++i) { @@I9[i] = @@I10[i]}"; @@ -203,9 +207,7 @@ ir::CallExpression *RestArgsLowering::TransformCallExpressionWithRestArgs(ir::Ca public_lib::Context *context) { checker::Type *calleeType = callExpr->Callee()->TsType(); - if (calleeType == nullptr || calleeType->IsETSArrowType() || - (callExpr->Callee()->IsMemberExpression() && callExpr->Callee()->AsMemberExpression()->PropVar() != nullptr && - callExpr->Callee()->AsMemberExpression()->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC))) { + if (calleeType == nullptr || calleeType->IsETSArrowType() || callExpr->Signature()->Function()->IsDynamic()) { return callExpr; } diff --git a/ets2panda/compiler/lowering/ets/restTupleLowering.cpp b/ets2panda/compiler/lowering/ets/restTupleLowering.cpp index 14aff4b6162842269fd1bdc94c1ecb81d9f4eee3..d584a899fa689733b93f2db1a09c3ad8ac222032 100644 --- a/ets2panda/compiler/lowering/ets/restTupleLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restTupleLowering.cpp @@ -213,6 +213,7 @@ ir::ArrayExpression *CreateArrayExpression(public_lib::Context *ctx, const Arena for (auto tupleElementAnno : newRestParams) { auto &tupleElementName = tupleElementAnno->AsETSParameterExpression()->Ident()->AsIdentifier()->Name(); ir::Expression *arg = ctx->AllocNode(tupleElementName, allocator); + ES2PANDA_ASSERT(arg != nullptr); arg->SetParent(arrayExpr); elements.push_back(arg); } @@ -268,7 +269,9 @@ ir::ScriptFunction *CreateNewScriptFunction(public_lib::Context *ctx, ir::Script ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : scriptFunc->Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, newScriptFunc)->AsAnnotationUsage()); + auto *newAnnotationUsage = annotationUsage->Clone(allocator, newScriptFunc); + ES2PANDA_ASSERT(newAnnotationUsage != nullptr); + annotationUsages.push_back(newAnnotationUsage->AsAnnotationUsage()); } newScriptFunc->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index 416e61cd70cc1a7e495a3c02326c7aa44612bae5..fe71baaaf67590f856dc015f7b303a87fae37d15 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -87,6 +87,7 @@ static ir::Identifier *CreateNewArrayDeclareStatement(public_lib::Context *ctx, auto *const allocator = ctx->allocator; auto *const parser = ctx->parser->AsETSParser(); ir::Identifier *newArrayId = Gensym(allocator); + ES2PANDA_ASSERT(newArrayId != nullptr); checker::Type *arrayElementType = checker->GetElementTypeOfArray(array->TsType()); // NOTE: If arrayElementType is ETSUnionType(String|Int) or ETSObjectType(private constructor) or ..., we cannot @@ -335,6 +336,7 @@ static ir::BlockExpression *CreateLoweredExpressionForArray(public_lib::Context ir::Identifier *newArrayId = CreateNewArrayDeclareStatement(ctx, array, statements, newArrayLengthId); ES2PANDA_ASSERT(newArrayId != nullptr); ir::Identifier *newArrayIndexId = Gensym(allocator); + ES2PANDA_ASSERT(newArrayIndexId != nullptr); statements.emplace_back( parser->CreateFormattedStatement("let @@I1 = 0", newArrayIndexId->Clone(allocator, nullptr))); std::vector newArrayAndIndex {newArrayId->Clone(allocator, nullptr), diff --git a/ets2panda/compiler/lowering/ets/stringComparison.cpp b/ets2panda/compiler/lowering/ets/stringComparison.cpp index e25361a7102bac98a576822d2bf4b416c8ff4858..68d18c745e13857b8c481ae05cb54c014c1ffd4d 100644 --- a/ets2panda/compiler/lowering/ets/stringComparison.cpp +++ b/ets2panda/compiler/lowering/ets/stringComparison.cpp @@ -84,6 +84,7 @@ void StringComparisonLowering::ProcessBinaryExpression(ir::BinaryExpression *exp auto *zeroExpr = checker->AllocNode(lexer::Number(int32_t(0))); auto *const callee = checker->AllocNode("compareTo", checker->Allocator()); ES2PANDA_ASSERT(callee != nullptr); + ES2PANDA_ASSERT(checker->GlobalBuiltinETSStringType() != nullptr); auto *var = checker->GlobalBuiltinETSStringType()->GetProperty(callee->AsIdentifier()->Name(), checker::PropertySearchFlags::SEARCH_METHOD); callee->SetVariable(var); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp index 63ee3413895e9c4325faca5556212787c9c89769..88a4c1ab28c97163a0cbfac3cb8f5ec7499b8fbe 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -159,6 +159,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateTransformedClass(ir::ETSModule * { auto className = ns->Ident()->Name(); auto *ident = NodeAllocator::Alloc(allocator_, className, allocator_); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(ns->Ident()->Range()); auto *classDef = NodeAllocator::Alloc(allocator_, allocator_, ident, @@ -168,6 +169,8 @@ ir::ClassDeclaration *GlobalClassHandler::CreateTransformedClass(ir::ETSModule * classDef->SetRange(ns->Range()); classDef->AddModifier(ns->Modifiers()); auto *classDecl = NodeAllocator::Alloc(allocator_, classDef, allocator_); + ES2PANDA_ASSERT(classDecl != nullptr); + classDecl->SetRange(ns->Range()); classDecl->AddModifier(ns->Modifiers()); classDef->SetNamespaceTransformed(); ArenaVector annotations {allocator_->Adapter()}; @@ -177,6 +180,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateTransformedClass(ir::ETSModule * } classDef->SetAnnotations(std::move(annotations)); + classDecl->SetRange(ns->Range()); return classDecl; } @@ -427,6 +431,7 @@ ir::MethodDefinition *GlobalClassHandler::CreateGlobalMethod(const std::string_v const auto functionFlags = ir::ScriptFunctionFlags::NONE; auto functionModifiers = ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC; auto ident = NodeAllocator::Alloc(allocator_, name, allocator_); + ES2PANDA_ASSERT(ident != nullptr); auto body = NodeAllocator::ForceSetParent(allocator_, allocator_, std::move(statements)); auto funcSignature = ir::FunctionSignature(nullptr, ArenaVector(allocator_->Adapter()), nullptr); @@ -439,9 +444,12 @@ ir::MethodDefinition *GlobalClassHandler::CreateGlobalMethod(const std::string_v func->AddModifier(functionModifiers); auto *funcExpr = NodeAllocator::Alloc(allocator_, func); + auto *identClone = ident->Clone(allocator_, nullptr); + ES2PANDA_ASSERT(identClone != nullptr); auto *methodDef = NodeAllocator::Alloc(allocator_, ir::MethodDefinitionKind::METHOD, - ident->Clone(allocator_, nullptr)->AsExpression(), - funcExpr, functionModifiers, allocator_, false); + identClone->AsExpression(), funcExpr, + functionModifiers, allocator_, false); + ES2PANDA_ASSERT(methodDef != nullptr); auto minBound = lexer::SourcePosition(globalProgram_); auto maxBound = lexer::SourcePosition(globalProgram_); if (!body->Statements().empty()) { @@ -498,6 +506,7 @@ void GlobalClassHandler::AddInitCallToStaticBlock(ir::ClassDefinition *globalCla auto *blockBody = staticBlock->Function()->Body()->AsBlockStatement(); auto exprStmt = NodeAllocator::Alloc(allocator_, callExpr); + ES2PANDA_ASSERT(exprStmt != nullptr); exprStmt->SetParent(blockBody); blockBody->AddStatement(exprStmt); } @@ -598,6 +607,7 @@ ir::ClassStaticBlock *GlobalClassHandler::CreateStaticBlock(ir::ClassDefinition auto *funcExpr = NodeAllocator::Alloc(allocator_, func); auto *staticBlock = NodeAllocator::Alloc(allocator_, funcExpr, allocator_); + ES2PANDA_ASSERT(staticBlock != nullptr); staticBlock->AddModifier(ir::ModifierFlags::STATIC); staticBlock->SetRange({classDef->Start(), classDef->Start()}); return staticBlock; @@ -610,7 +620,10 @@ GlobalDeclTransformer::ResultT GlobalClassHandler::CollectProgramGlobalStatement auto globalDecl = GlobalDeclTransformer(allocator_, stmt, parser_); auto statements = globalDecl.TransformStatements(stmts); if (globalDecl.IsMultiInitializer() && stmt->IsETSModule() && stmt->AsETSModule()->IsNamespace()) { - parser_->LogError(diagnostic::MULTIPLE_STATIC_BLOCK, {}, statements.initializerBlocks[0][0]->Start()); + auto fristStaticBlock = + std::find_if(stmts.cbegin(), stmts.cend(), [](auto *prop) { return prop->IsClassStaticBlock(); }); + ES2PANDA_ASSERT(fristStaticBlock != stmts.cend()); + parser_->LogError(diagnostic::MULTIPLE_STATIC_BLOCK, {}, (*fristStaticBlock)->Start()); } if (stmt->IsETSModule() && !stmt->AsETSModule()->IsNamespace() && stmt->AsETSModule()->Program()->IsPackage()) { @@ -648,6 +661,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateGlobalClass(const parser::Progra const auto rangeToStartOfFile = lexer::SourceRange(lexer::SourcePosition(globalProgram), lexer::SourcePosition(globalProgram)); auto *ident = NodeAllocator::Alloc(allocator_, compiler::Signatures::ETS_GLOBAL, allocator_); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(rangeToStartOfFile); auto *classDef = NodeAllocator::Alloc(allocator_, allocator_, ident, ir::ClassDefinitionModifiers::GLOBAL, @@ -655,6 +669,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateGlobalClass(const parser::Progra ES2PANDA_ASSERT(classDef != nullptr); classDef->SetRange(rangeToStartOfFile); auto *classDecl = NodeAllocator::Alloc(allocator_, classDef, allocator_); + ES2PANDA_ASSERT(classDecl != nullptr); classDecl->SetRange(rangeToStartOfFile); return classDecl; diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp index a5abdb80a0c90ccb91bf45aa3d008e944b584258..9b66d0c095350becfbf42d379b229affad5d7266 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp @@ -75,10 +75,11 @@ void GlobalDeclTransformer::VisitFunctionDeclaration(ir::FunctionDeclaration *fu auto *method = util::NodeAllocator::ForceSetParent( allocator_, methodKind, funcDecl->Function()->Id()->Clone(allocator_, nullptr), funcExpr, funcDecl->Function()->Modifiers(), allocator_, false); + ES2PANDA_ASSERT(method != nullptr && method->Function() != nullptr); method->SetRange(funcDecl->Range()); method->Function()->SetAnnotations(funcDecl->Annotations()); - if (funcDecl->Function()->IsExported() && funcDecl->Function()->HasExportAlias()) { + if (funcDecl->Function()->HasExportAlias()) { method->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); } @@ -97,6 +98,7 @@ void GlobalDeclTransformer::VisitVariableDeclaration(ir::VariableDeclaration *va currentModule_->AsETSModule()->Program()->IsPackage(); auto *field = util::NodeAllocator::ForceSetParent( allocator_, id->Clone(allocator_, nullptr), declarator->Init(), typeAnn, modifiers, allocator_, false); + ES2PANDA_ASSERT(field != nullptr); field->SetInitInStaticBlock(needInitializeInStaticBlock); field->SetRange(declarator->Range()); @@ -104,13 +106,14 @@ void GlobalDeclTransformer::VisitVariableDeclaration(ir::VariableDeclaration *va ArenaVector propAnnotations(allocator_->Adapter()); for (auto *annotationUsage : varDecl->Annotations()) { ES2PANDA_ASSERT(annotationUsage != nullptr); - propAnnotations.push_back(annotationUsage->Clone(allocator_, field)->AsAnnotationUsage()); + auto annotationUsageClone = annotationUsage->Clone(allocator_, field); + ES2PANDA_ASSERT(annotationUsageClone != nullptr); + propAnnotations.push_back(annotationUsageClone->AsAnnotationUsage()); } field->SetAnnotations(std::move(propAnnotations)); } - if ((varDecl->IsExported() || declarator->IsExported()) && - (varDecl->HasExportAlias() || declarator->HasExportAlias())) { + if (varDecl->HasExportAlias() || declarator->HasExportAlias()) { field->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); } @@ -172,12 +175,14 @@ ir::Identifier *GlobalDeclTransformer::RefIdent(const util::StringView &name) ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassProperty *classProperty) { const auto initializer = classProperty->Value(); + ES2PANDA_ASSERT(classProperty->Id() != nullptr); if (classProperty->IsConst() || initializer == nullptr) { classProperty->SetStart(classProperty->Id()->Start()); return nullptr; } auto const ident = RefIdent(classProperty->Id()->Name()); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(classProperty->Id()->Range()); initializer->SetParent(nullptr); @@ -188,6 +193,7 @@ ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassPr assignmentExpression->SetTsType(initializer->TsType()); auto expressionStatement = util::NodeAllocator::Alloc(allocator_, assignmentExpression); + ES2PANDA_ASSERT(expressionStatement != nullptr); expressionStatement->SetRange(classProperty->Range()); classProperty->SetRange({ident->Start(), initializer->End()}); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp index c7b88afa1017bc1cd41586945356dc4ce37c6274..4030eca90871144e512b3f123c618d8fe790fc58 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp @@ -15,6 +15,7 @@ #include "compiler/lowering/ets/topLevelStmts/importExportDecls.h" #include "compiler/lowering/util.h" +#include "generated/diagnostic.h" #include "utils/arena_containers.h" namespace ark::es2panda::compiler { @@ -97,37 +98,33 @@ GlobalClassHandler::ModuleDependencies ImportExportDecls::HandleGlobalStmts(Aren void ImportExportDecls::PopulateAliasMap(const ir::ExportNamedDeclaration *decl, const util::StringView &path) { for (auto spec : decl->Specifiers()) { - if (!varbinder_->AddSelectiveExportAlias(path, spec->Local()->Name(), spec->Exported()->Name(), decl)) { - parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {spec->Local()->Name().Mutf8()}, - spec->Exported()->Start()); + if (!varbinder_->AddSelectiveExportAlias(parser_, path, spec->Local()->Name(), spec->Exported()->Name(), + decl)) { + parser_->LogError(diagnostic::CANNOT_EXPORT_DIFFERENT_OBJECTS_WITH_SAME_NAME, + {spec->Local()->Name().Mutf8()}, spec->Exported()->Start()); lastExportErrorPos_ = lexer::SourcePosition(); } } } -void ImportExportDecls::AddExportFlags(ir::AstNode *node, util::StringView originalFieldName, - lexer::SourcePosition startLoc, bool exportedWithAlias) +void ImportExportDecls::AddExportFlags(ir::AstNode *node, util::StringView originalFieldName, bool exportedWithAlias) { - if ((node->Modifiers() & ir::ModifierFlags::EXPORTED) != 0) { - // Note (oeotvos) Needs to be discussed, whether we would like to allow exporting the same program - // element using its original name and also an alias, like: export {test_func, test_func as foo}. - parser_->LogError(diagnostic::ALREADY_EXPORTED, {originalFieldName.Mutf8()}, startLoc); + if (exportedWithAlias) { + node->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); + return; } if (originalFieldName == exportDefaultName_) { node->AddModifier(ir::ModifierFlags::DEFAULT_EXPORT); } else { node->AddModifier(ir::ModifierFlags::EXPORT); } - if (exportedWithAlias) { - node->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); - } } void ImportExportDecls::PopulateAliasMap(const ir::TSTypeAliasDeclaration *decl, const util::StringView &path) { - if (!varbinder_->AddSelectiveExportAlias(path, decl->Id()->AsIdentifier()->Name(), + if (!varbinder_->AddSelectiveExportAlias(parser_, path, decl->Id()->AsIdentifier()->Name(), decl->Id()->AsIdentifier()->Name(), decl)) { - parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {decl->Id()->AsIdentifier()->Name().Mutf8()}, - lastExportErrorPos_); + parser_->LogError(diagnostic::CANNOT_EXPORT_DIFFERENT_OBJECTS_WITH_SAME_NAME, + {decl->Id()->AsIdentifier()->Name().Mutf8()}, lastExportErrorPos_); lastExportErrorPos_ = lexer::SourcePosition(); } } @@ -147,9 +144,9 @@ void ImportExportDecls::HandleSelectiveExportWithAlias(util::StringView original } if (variableDeclarator != nullptr) { - AddExportFlags(variableDeclarator, originalFieldName, startLoc, exportedWithAlias); + AddExportFlags(variableDeclarator, originalFieldName, exportedWithAlias); } else { - AddExportFlags(field, originalFieldName, startLoc, exportedWithAlias); + AddExportFlags(field, originalFieldName, exportedWithAlias); } } @@ -234,11 +231,7 @@ void ImportExportDecls::VisitExportNamedDeclaration(ir::ExportNamedDeclaration * } exportDefaultName_ = local->Name(); } - - if (!exportNameMap_.emplace(local->Name(), local->Start()).second) { - lastExportErrorPos_ = local->Start(); - parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {local->Name().Mutf8()}, lastExportErrorPos_); - } + exportNameMap_.emplace(local->Name(), local->Start()); } } diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h index c873e8ffdb4bd8411befc9c2e8fc98ed565c6b26..4d785eb815ad18cfe20ad4c148a41226019eb372 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h @@ -64,8 +64,7 @@ public: void HandleSimpleType(std::set &exportedStatements, ir::Statement *stmt, util::StringView name); void VerifySingleExportDefault(const ArenaVector &programs); - void AddExportFlags(ir::AstNode *node, util::StringView originalFieldName, lexer::SourcePosition startLoc, - bool exportedWithAlias); + void AddExportFlags(ir::AstNode *node, util::StringView originalFieldName, bool exportedWithAlias); void HandleSelectiveExportWithAlias(util::StringView originalFieldName, util::StringView exportName, lexer::SourcePosition startLoc); void PopulateAliasMap(const ir::ExportNamedDeclaration *decl, const util::StringView &path); diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index 0e5299b8229ce42fd61f03c60511f0142ff83851..2ad5b19d6968247440f6ae5859b1fe17543e5c82 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -13,6 +13,9 @@ * limitations under the License. */ +#include "compiler/lowering/ets/unboxLowering.h" + +#include "checker/types/type.h" #include "generated/tokenType.h" #include "ir/visitor/IterateAstVisitor.h" #include "checker/ETSchecker.h" @@ -20,12 +23,12 @@ #include "checker/types/typeFlag.h" #include "checker/types/globalTypesHolder.h" #include "compiler/lowering/util.h" - -#include "compiler/lowering/ets/unboxLowering.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::compiler { namespace { + struct UnboxContext { // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes,readability-identifier-naming) explicit UnboxContext(public_lib::Context *ctx) @@ -48,66 +51,35 @@ struct UnboxContext { // NOLINTNEXTLINE(readability-identifier-naming) char const *UNBOXER_METHOD_NAME = "unboxed"; -} // namespace -static bool IsRecursivelyUnboxedReference(checker::Type *t); - -static bool IsRecursivelyUnboxed(checker::Type *t) -{ - return t->IsETSPrimitiveType() || IsRecursivelyUnboxedReference(t); -} - -static checker::Type *GetArrayElementType(checker::Type *arrType) +bool AnyOfElementTypes(checker::Type *type, const std::function &isFunc) { - if (arrType->IsETSResizableArrayType()) { - return arrType->AsETSResizableArrayType()->ElementType(); - } - - if (arrType->IsETSArrayType()) { - return arrType->AsETSArrayType()->ElementType(); - } - return nullptr; + auto const anyOf = [&isFunc](ArenaVector const &list) { + auto const pred = [&isFunc](checker::Type *t) { return AnyOfElementTypes(t, isFunc); }; + return std::any_of(list.begin(), list.end(), pred); + }; + return (type->IsETSTupleType() && anyOf(type->AsETSTupleType()->GetTupleTypesList())) || + (type->IsETSArrayType() && isFunc(type->AsETSArrayType()->ElementType())) || + (type->IsETSUnionType() && anyOf(type->AsETSUnionType()->ConstituentTypes())) || + (type->IsETSObjectType() && anyOf(type->AsETSObjectType()->TypeArguments())); } -static bool IsRecursivelyUnboxedReference(checker::Type *t) +bool IsRecursivelyUnboxed(checker::Type *t) { - return (t->IsETSTupleType() && - std::any_of(t->AsETSTupleType()->GetTupleTypesList().begin(), - t->AsETSTupleType()->GetTupleTypesList().end(), IsRecursivelyUnboxedReference)) || - (t->IsETSArrayType() && IsRecursivelyUnboxed(GetArrayElementType(t))) || - (t->IsETSUnionType() && - std::any_of(t->AsETSUnionType()->ConstituentTypes().begin(), t->AsETSUnionType()->ConstituentTypes().end(), - IsRecursivelyUnboxedReference)) || - (t->IsETSObjectType() && - std::any_of(t->AsETSObjectType()->TypeArguments().begin(), t->AsETSObjectType()->TypeArguments().end(), - IsRecursivelyUnboxedReference)); + return t->IsETSPrimitiveType() || AnyOfElementTypes(t, IsRecursivelyUnboxed); } -static bool TypeIsBoxedPrimitive(checker::Type *tp) +bool TypeIsBoxedPrimitive(checker::Type *tp) { return tp->IsETSObjectType() && tp->AsETSObjectType()->IsBoxedPrimitive(); } -static bool IsUnboxingApplicableReference(checker::Type *t); - -static bool IsUnboxingApplicable(checker::Type *t) +bool IsUnboxingApplicable(checker::Type *t) { - return TypeIsBoxedPrimitive(t) || IsUnboxingApplicableReference(t); + return TypeIsBoxedPrimitive(t) || AnyOfElementTypes(t, IsUnboxingApplicable); } -static bool IsUnboxingApplicableReference(checker::Type *t) -{ - return (t->IsETSTupleType() && - std::any_of(t->AsETSTupleType()->GetTupleTypesList().begin(), - t->AsETSTupleType()->GetTupleTypesList().end(), IsUnboxingApplicableReference)) || - (t->IsETSArrayType() && IsUnboxingApplicable(GetArrayElementType(t))) || - (t->IsETSUnionType() && - std::any_of(t->AsETSUnionType()->ConstituentTypes().begin(), t->AsETSUnionType()->ConstituentTypes().end(), - IsUnboxingApplicableReference)) || - (t->IsETSObjectType() && - std::any_of(t->AsETSObjectType()->TypeArguments().begin(), t->AsETSObjectType()->TypeArguments().end(), - IsUnboxingApplicableReference)); -} +} // namespace using TypeIdStorage = std::vector; // Long recursion chains are unlikely, use vector static checker::Type *NormalizeType(UnboxContext *uctx, checker::Type *t, TypeIdStorage *alreadySeen = nullptr); @@ -268,6 +240,11 @@ static void NormalizeAllTypes(UnboxContext *uctx, ir::AstNode *ast) static void HandleScriptFunctionHeader(UnboxContext *uctx, ir::ScriptFunction *func) { + // dynamic function does not need to unbox + if (func->Language() == Language::Id::JS) { + return; + } + auto *sig = func->Signature(); if (sig == nullptr) { return; @@ -730,7 +707,7 @@ static void HandleForOfStatement(UnboxContext *uctx, ir::ForOfStatement *forOf) checker::Type *elemTp = nullptr; if (tp->IsETSArrayType()) { - elemTp = GetArrayElementType(tp); + elemTp = tp->AsETSArrayType()->ElementType(); } else if (tp->IsETSStringType()) { elemTp = uctx->checker->GlobalCharType(); } else { @@ -789,6 +766,11 @@ namespace { struct UnboxVisitor : public ir::visitor::EmptyAstVisitor { explicit UnboxVisitor(UnboxContext *uctx) : uctx_(uctx) {} + inline checker::Type *GetArrayElementType(checker::Type *arrType) + { + return uctx_->checker->GetElementTypeOfArray(arrType); + } + void VisitReturnStatement(ir::ReturnStatement *retStmt) override { ir::ScriptFunction *nearestScriptFunction = nullptr; diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index aba0545179c38049cc67eca93b8c66cf50fc1b2d..2b2bc2713fdbed47e05eae8118dd52a10b1ab2ee 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -19,11 +19,10 @@ #include "compiler/lowering/util.h" #include "varbinder/ETSBinder.h" #include "checker/ETSchecker.h" +#include "util/nameMangler.h" namespace ark::es2panda::compiler { -static constexpr std::string_view PREFIX = "$NamedAccessMeta-"; - static void ReplaceAll(std::string &str, std::string_view substr, std::string_view replacement) { for (size_t pos = str.find(substr, 0); pos != std::string::npos; pos = str.find(substr, pos)) { @@ -35,13 +34,10 @@ static void ReplaceAll(std::string &str, std::string_view substr, std::string_vi std::string GetAccessClassName(const checker::ETSUnionType *unionType) { std::stringstream ss; - ss << PREFIX; unionType->ToString(ss, false); - std::string res(ss.str()); - std::replace(res.begin(), res.end(), '.', '-'); - std::replace(res.begin(), res.end(), '|', '_'); - ReplaceAll(res, "[]", "[$]$"); - return res; + std::string newName = util::NameMangler::GetInstance()->CreateMangledNameForUnionProperty(ss.str()); + ReplaceAll(newName, "[]", "[$]$"); + return newName; } static ir::ClassDefinition *GetUnionAccessClass(public_lib::Context *ctx, varbinder::VarBinder *varbinder, @@ -57,6 +53,7 @@ static ir::ClassDefinition *GetUnionAccessClass(public_lib::Context *ctx, varbin util::UString unionFieldClassName(util::StringView(name), allocator); auto *ident = ctx->AllocNode(unionFieldClassName.View(), allocator); auto [decl, var] = varbinder->NewVarDecl(ident->Start(), ident->Name()); + ES2PANDA_ASSERT(ident != nullptr); ident->SetVariable(var); auto classCtx = varbinder::LexicalScope(varbinder); @@ -65,6 +62,7 @@ static ir::ClassDefinition *GetUnionAccessClass(public_lib::Context *ctx, varbin ES2PANDA_ASSERT(classDef != nullptr); classDef->SetScope(classCtx.GetScope()); auto *classDecl = ctx->AllocNode(classDef, allocator); + ES2PANDA_ASSERT(classDecl != nullptr); classDef->Scope()->BindNode(classDecl->Definition()); decl->BindNode(classDef); var->SetScope(classDef->Scope()); @@ -84,8 +82,9 @@ static std::tuple CreateNamedA { auto *allocator = ctx->Allocator(); auto *checker = ctx->GetChecker()->AsETSChecker(); - - auto unionType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType()))->AsETSUnionType(); + auto apparentType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType())); + ES2PANDA_ASSERT(apparentType != nullptr); + auto unionType = apparentType->AsETSUnionType(); auto *const accessClass = GetUnionAccessClass(ctx, varbinder, GetAccessClassName(unionType)); auto methodName = expr->TsType()->AsETSFunctionType()->Name(); @@ -104,7 +103,7 @@ static std::tuple CreateNamedA nullptr, ir::FunctionSignature(nullptr, std::move(params), returnTypeAnno), // CC-OFFNXT(G.FMT.02-CPP) project code style ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::PUBLIC}); - ES2PANDA_ASSERT(func != nullptr); + ES2PANDA_ASSERT(func != nullptr && methodIdent != nullptr); func->SetIdent(methodIdent->Clone(allocator, nullptr)); // Create the synthetic function node @@ -124,7 +123,7 @@ static std::tuple CreateNamedA auto boundCtx = varbinder::BoundContext(varbinder->AsETSBinder()->GetRecordTable(), accessClass, true); CheckLoweredNode(varbinder->AsETSBinder(), checker, method); } - + ES2PANDA_ASSERT(method->Id() != nullptr && method->TsType() != nullptr); return {method->Id()->Variable()->AsLocalVariable(), method->TsType()->AsETSFunctionType()->CallSignatures().front()}; } @@ -135,7 +134,9 @@ static varbinder::LocalVariable *CreateNamedAccessProperty(public_lib::Context * auto *const allocator = ctx->Allocator(); auto *checker = ctx->GetChecker()->AsETSChecker(); - auto unionType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType()))->AsETSUnionType(); + auto apparentType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType())); + ES2PANDA_ASSERT(apparentType != nullptr); + auto unionType = apparentType->AsETSUnionType(); auto *const accessClass = GetUnionAccessClass(ctx, varbinder, GetAccessClassName(unionType)); auto propName = expr->Property()->AsIdentifier()->Name(); auto fieldType = expr->TsType(); diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index bc06d4dca05f3330a9e819c17f7670afad16f645..4dd62cd22f43e0431bce0cac6462659346fa8501 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -135,7 +135,6 @@ std::vector GetETSPhaseList() new AnnotationCopyPostLowering, new AsyncMethodLowering, new DeclareOverloadLowering, - new OverloadMappingLowering, new EnumPostCheckLoweringPhase, new SpreadConstructionPhase, new RestArgsLowering, @@ -149,6 +148,7 @@ std::vector GetETSPhaseList() new RecordLowering, new ObjectIndexLowering, new ObjectIteratorLowering, + new OverloadMappingLowering, new LambdaConversionPhase, new UnionLowering, new ExpandBracketsPhase, diff --git a/ets2panda/compiler/lowering/phase.h b/ets2panda/compiler/lowering/phase.h index 63c3e493f413c60c1113510a05d91575cc0c8feb..eb35164bc088535f3875dcb61dc6e1f8f23da72d 100644 --- a/ets2panda/compiler/lowering/phase.h +++ b/ets2panda/compiler/lowering/phase.h @@ -145,6 +145,16 @@ public: curr_.minor = phaseId; } + void SetCurrentPhaseIdWithoutReCheck(int32_t phaseId) + { + if (phaseId == curr_.minor) { + return; + } + curr_.major = 0; + prev_ = {0, INVALID_PHASE_ID}; + curr_.minor = phaseId; + } + ArenaAllocator *Allocator() const { return allocator_; diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 780c1346a8de45da66b1ccd3040cffeef8875a04..d02274ff1f13745ccda4c8c013f8aaffb699c180 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -961,12 +961,6 @@ void InitScopesPhaseETS::VisitImportNamespaceSpecifier(ir::ImportNamespaceSpecif void InitScopesPhaseETS::VisitImportSpecifier(ir::ImportSpecifier *importSpec) { - if (importSpec->Parent()->IsETSImportDeclaration() && - importSpec->Parent()->AsETSImportDeclaration()->IsPureDynamic()) { - auto [decl, var] = VarBinder()->NewVarDecl(importSpec->Local()->Start(), - importSpec->Local()->Name(), importSpec); - var->AddFlag(varbinder::VariableFlags::INITIALIZED); - } Iterate(importSpec); } @@ -989,6 +983,7 @@ void InitScopesPhaseETS::DeclareClassMethod(ir::MethodDefinition *method) } const auto methodName = method->Id(); + ES2PANDA_ASSERT(methodName != nullptr); auto *const clsScope = VarBinder()->GetScope()->AsClassScope(); auto options = method->IsStatic() @@ -1029,8 +1024,9 @@ void InitScopesPhaseETS::MaybeAddOverload(ir::MethodDefinition *method, ir::Iden methodName->SetVariable(var); } for (auto *overload : method->Overloads()) { - ES2PANDA_ASSERT((overload->Function()->Flags() & ir::ScriptFunctionFlags::OVERLOAD) || - (overload->Function()->Flags() & ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD)); + ES2PANDA_ASSERT(overload->Id() != nullptr && + ((overload->Function()->Flags() & ir::ScriptFunctionFlags::OVERLOAD) || + (overload->Function()->Flags() & ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD))); overload->Id()->SetVariable(var); overload->SetParent(var->Declaration()->Node()); } @@ -1055,75 +1051,69 @@ void InitScopesPhaseETS::MaybeAddOverload(ir::MethodDefinition *method, ir::Iden void InitScopesPhaseETS::VisitOverloadDeclaration(ir::OverloadDeclaration *overload) { - auto *curScope = VarBinder()->GetScope(); + auto *const clsScope = VarBinder()->GetScope()->AsClassScope(); const auto overloadName = overload->Id(); - auto res = - curScope->Find(overloadName->Name(), overload->IsStatic() ? varbinder::ResolveBindingOptions::ALL_STATIC - : varbinder::ResolveBindingOptions::ALL_NON_STATIC); - if (res.variable != nullptr) { - VarBinder()->ThrowRedeclaration(overloadName->Start(), res.name, varbinder::DeclType::METHOD); - } + auto options = + (overload->IsStatic() || overload->IsConstructorOverloadDeclaration()) + ? varbinder::ResolveBindingOptions::STATIC_VARIABLES | varbinder::ResolveBindingOptions::STATIC_DECLARATION + : varbinder::ResolveBindingOptions::VARIABLES | varbinder::ResolveBindingOptions::DECLARATION; - auto result = curScope->FindLocal(overloadName->Name(), varbinder::ResolveBindingOptions::ALL_DECLARATION); - if (result != nullptr) { - VarBinder()->ThrowLocalRedeclaration(overloadName->Start(), result->Name()); + auto variable = clsScope->FindLocal(overloadName->Name(), options); + if (variable != nullptr) { + VarBinder()->ThrowRedeclaration(overloadName->Start(), overloadName->Name(), variable->Declaration()->Type()); } Iterate(overload); DeclareClassOverload(overload); } -varbinder::LocalScope *InitScopesPhaseETS::OverloadTargetScope(ir::OverloadDeclaration *overloadDef, +varbinder::LocalScope *InitScopesPhaseETS::OverloadTargetScope(ir::OverloadDeclaration *overloaddecl, varbinder::ClassScope *clsScope) { varbinder::LocalScope *targetScope {}; - if (overloadDef->IsConstructorOverloadDeclaration()) { - targetScope = clsScope->StaticMethodScope(); + if (overloaddecl->IsConstructorOverloadDeclaration()) { + targetScope = clsScope->StaticDeclScope(); - auto *found = targetScope->FindLocal(Signatures::CONSTRUCTOR_NAME, varbinder::ResolveBindingOptions::BINDINGS); + auto *found = clsScope->StaticMethodScope()->FindLocal(Signatures::CONSTRUCTOR_NAME, + varbinder::ResolveBindingOptions::BINDINGS); if (found == nullptr || - (!overloadDef->OverloadedList().empty() && overloadDef->OverloadedList().front()->IsIdentifier() && - overloadDef->OverloadedList().front()->AsIdentifier()->Name().Is(Signatures::CONSTRUCTOR_NAME))) { + (!overloaddecl->OverloadedList().empty() && overloaddecl->OverloadedList().front()->IsIdentifier() && + overloaddecl->OverloadedList().front()->AsIdentifier()->Name().Is(Signatures::CONSTRUCTOR_NAME))) { return targetScope; } ir::Identifier *anonyConstructor = Allocator()->New(Signatures::CONSTRUCTOR_NAME, Allocator()); - overloadDef->PushFront(anonyConstructor); - anonyConstructor->SetParent(overloadDef); + overloaddecl->PushFront(anonyConstructor); + anonyConstructor->SetParent(overloaddecl); } else { - targetScope = overloadDef->IsStatic() ? clsScope->StaticMethodScope() : clsScope->InstanceMethodScope(); + targetScope = overloaddecl->IsStatic() ? clsScope->StaticDeclScope() : clsScope->InstanceDeclScope(); } return targetScope; } -void InitScopesPhaseETS::DeclareClassOverload(ir::OverloadDeclaration *overloadDef) +void InitScopesPhaseETS::DeclareClassOverload(ir::OverloadDeclaration *overloaddecl) { ES2PANDA_ASSERT(VarBinder()->GetScope()->IsClassScope()); - const auto overloadName = overloadDef->Id(); + const auto overloadName = overloaddecl->Id(); auto *const clsScope = VarBinder()->GetScope()->AsClassScope(); - auto options = - overloadDef->IsStatic() - ? varbinder::ResolveBindingOptions::STATIC_VARIABLES | varbinder::ResolveBindingOptions::STATIC_DECLARATION - : varbinder::ResolveBindingOptions::VARIABLES | varbinder::ResolveBindingOptions::DECLARATION; - auto variable = clsScope->FindLocal(overloadName->Name(), options); - if (variable != nullptr) { - VarBinder()->ThrowRedeclaration(overloadName->Start(), overloadName->Name(), variable->Declaration()->Type()); - } - varbinder::LocalScope *targetScope = OverloadTargetScope(overloadDef, clsScope); - for (auto *methodName : overloadDef->OverloadedList()) { + varbinder::LocalScope *targetScope = OverloadTargetScope(overloaddecl, clsScope); + varbinder::LocalScope *serachMethodScope = + (overloaddecl->IsStatic() || overloaddecl->IsConstructorOverloadDeclaration()) + ? clsScope->StaticMethodScope() + : clsScope->InstanceMethodScope(); + + for (auto *methodName : overloaddecl->OverloadedList()) { if (!methodName->IsIdentifier()) { continue; } - auto *found = - targetScope->FindLocal(methodName->AsIdentifier()->Name(), varbinder::ResolveBindingOptions::BINDINGS); - + auto *found = serachMethodScope->FindLocal(methodName->AsIdentifier()->Name(), + varbinder::ResolveBindingOptions::BINDINGS); if (found == nullptr) { continue; } - if (!found->Declaration()->Node()->IsMethodDefinition()) { VarBinder()->ThrowError(methodName->Start(), diagnostic::OVERLOADED_NAME_MUST_FUNCTION); continue; @@ -1134,7 +1124,7 @@ void InitScopesPhaseETS::DeclareClassOverload(ir::OverloadDeclaration *overloadD auto classCtx = varbinder::LexicalScope::Enter(VarBinder(), targetScope); auto var = std::get<1>(VarBinder()->NewVarDecl(overloadName->Start(), Allocator(), - overloadName->Name(), overloadDef)); + overloadName->Name(), overloaddecl)); var->SetScope(clsScope); if (targetScope->HasFlag(varbinder::ScopeFlags::STATIC)) { var->AddFlag(varbinder::VariableFlags::STATIC); @@ -1210,6 +1200,7 @@ void InitScopesPhaseETS::VisitMethodDefinition(ir::MethodDefinition *method) auto *curScope = VarBinder()->GetScope(); const auto methodName = method->Id(); + ES2PANDA_ASSERT(methodName != nullptr); auto res = curScope->Find(methodName->Name(), method->IsStatic() ? varbinder::ResolveBindingOptions::ALL_STATIC : varbinder::ResolveBindingOptions::ALL_NON_STATIC); @@ -1261,6 +1252,7 @@ void InitScopesPhaseETS::VisitTSTypeParameter(ir::TSTypeParameter *typeParam) var->AddFlag(varbinder::VariableFlags::TYPE_PARAMETER); decl->BindNode(typeParam); CallNode(typeParam->Annotations()); + CallNode(typeParam->DefaultType()); } void InitScopesPhaseETS::VisitTSInterfaceDeclaration(ir::TSInterfaceDeclaration *interfaceDecl) diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.h b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.h index 75f98406d4f832a901e3e902d7bf4d758de11fa2..47799937df0a6e1da0916ffbdab3b1ee38a209a1 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.h +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.h @@ -344,8 +344,8 @@ private: void DeclareClassMethod(ir::MethodDefinition *method); void MaybeAddOverload(ir::MethodDefinition *method, ir::Identifier *methodName, varbinder::Variable *found, varbinder::ClassScope *clsScope, varbinder::LocalScope *targetScope); - void DeclareClassOverload(ir::OverloadDeclaration *overloadDef); - varbinder::LocalScope *OverloadTargetScope(ir::OverloadDeclaration *overloadDef, varbinder::ClassScope *clsScope); + void DeclareClassOverload(ir::OverloadDeclaration *overloaddecl); + varbinder::LocalScope *OverloadTargetScope(ir::OverloadDeclaration *overloaddecl, varbinder::ClassScope *clsScope); void VisitClassStaticBlock(ir::ClassStaticBlock *staticBlock) override; void VisitBlockExpression(ir::BlockExpression *blockExpr) override; diff --git a/ets2panda/compiler/lowering/util.cpp b/ets2panda/compiler/lowering/util.cpp index 865e9d1827b9d161c0c176f01eef75d344f621a1..bed24872a8f353c670ed4adc26e21d6ad623a8e3 100644 --- a/ets2panda/compiler/lowering/util.cpp +++ b/ets2panda/compiler/lowering/util.cpp @@ -20,6 +20,7 @@ #include "checker/checker.h" #include "checker/ETSAnalyzer.h" #include "checker/types/gradualType.h" +#include "parser/JsdocHelper.h" namespace ark::es2panda::compiler { @@ -336,6 +337,20 @@ ir::AstNode *DeclarationFromIdentifier(const ir::Identifier *node) return decl->Node(); } +// NOTE: used to get the license string from the input root node. +util::StringView GetLicenseFromRootNode(const ir::AstNode *node) +{ + std::unique_ptr jsdocGetter = std::make_unique(node); + return jsdocGetter->GetLicenseStringFromStart(); +} + +// NOTE: used to get the jsdoc string from the input node. +util::StringView JsdocStringFromDeclaration(const ir::AstNode *node) +{ + std::unique_ptr jsdocGetter = std::make_unique(node); + return jsdocGetter->GetJsdocBackward(); +} + // Note: run varbinder on the new node generated in lowering phases (without ClearTypesVariablesAndScopes) void BindLoweredNode(varbinder::ETSBinder *varBinder, ir::AstNode *node) { diff --git a/ets2panda/compiler/lowering/util.h b/ets2panda/compiler/lowering/util.h index 8f5202f4aa7d77287ecfdb1a4b06592f0c83a756..4e84d9429881c81ff5cf01391ee6e9d0918ed193 100644 --- a/ets2panda/compiler/lowering/util.h +++ b/ets2panda/compiler/lowering/util.h @@ -45,6 +45,9 @@ void Recheck(PhaseManager *phaseManager, varbinder::ETSBinder *varBinder, checke ir::AstNode *DeclarationFromIdentifier(const ir::Identifier *node); // NOTE: used to get the declaration name in Plugin API and LSP std::optional GetNameOfDeclaration(const ir::AstNode *node); +// NOTE: used to get the license string from the input root node. +util::StringView GetLicenseFromRootNode(const ir::AstNode *node); +util::StringView JsdocStringFromDeclaration(const ir::AstNode *node); // Note: run varbinder on the new node generated in lowering phases void BindLoweredNode(varbinder::ETSBinder *varBinder, ir::AstNode *node); diff --git a/ets2panda/compiler/scripts/signatures.yaml b/ets2panda/compiler/scripts/signatures.yaml index 15dfcdbfe96bd5c3900cd74d7e3162fbbc665e31..8a03d4889a385926f740d5d43e709ffe27f01e57 100644 --- a/ets2panda/compiler/scripts/signatures.yaml +++ b/ets2panda/compiler/scripts/signatures.yaml @@ -124,10 +124,6 @@ defines: ref: GENERIC_END - name: ctor ref: CONSTRUCTOR - - name: - ref: GETTER_BEGIN - - name: - ref: SETTER_BEGIN - name: param0 ref: CTOR_PARAM0 - name: param1 @@ -255,8 +251,6 @@ defines: ref: CLASS_INITIALIZE_METHOD - name: 'constructor' ref: CONSTRUCTOR_NAME - - name: 'gensym%%_constructor_overload_declaration' - ref: CONSTRUCTOR_OVERLOAD_DEFINITION_NAME packages: - name: 'std.core' @@ -962,54 +956,116 @@ signatures: return_type: PRIMITIVE_VOID ref: BUILTIN_STRING_BUILDER_CTOR + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_BOOLEAN] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_BOOLEAN + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_CHAR] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_CHAR + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_INT] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_INT + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_LONG] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_LONG + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_FLOAT] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_FLOAT + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [PRIMITIVE_DOUBLE] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_DOUBLE + #26986 - callee: BUILTIN_STRING_BUILDER method_name: append params: [BUILTIN_STRING] return_type: BUILTIN_STRING_BUILDER ref: BUILTIN_STRING_BUILDER_APPEND_BUILTIN_STRING + #26986 - callee: BUILTIN_STRING_BUILDER method_name: toString params: [] return_type: BUILTIN_STRING ref: BUILTIN_STRING_BUILDER_TO_STRING + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_BOOLEAN] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_BOOLEAN + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_CHAR] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_CHAR + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_SHORT] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_SHORT + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_BYTE] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_BYTE + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_INT] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_INT + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_LONG] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_LONG + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_FLOAT] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_FLOAT + + - callee: BUILTIN_STRING_BUILDER + method_name: toString + params: [PRIMITIVE_DOUBLE] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_TO_STRING_DOUBLE + + - callee: BUILTIN_STRING_BUILDER + method_name: concatStrings + params: [BUILTIN_STRING, BUILTIN_STRING] + return_type: BUILTIN_STRING + ref: BUILTIN_STRING_BUILDER_CONCAT_STRING + - callee: BUILTIN_BOOLEAN method_name: valueOf params: [PRIMITIVE_BOOLEAN] diff --git a/ets2panda/compiler/templates/isa.h.erb b/ets2panda/compiler/templates/isa.h.erb index 485bd37fdd5b93959574f46d3b409b1b9d77d0d3..87789468d6a2b3be303b102b63b620f2f57f4855 100644 --- a/ets2panda/compiler/templates/isa.h.erb +++ b/ets2panda/compiler/templates/isa.h.erb @@ -65,8 +65,7 @@ public: [[maybe_unused]] uint32_t totalRegs) const override { ins->opcode = pandasm::Opcode::INVALID; - ins->setLabel = true; - ins->label = id_; + ins->SetLabel(id_); } private: @@ -184,31 +183,22 @@ public: void Transform(pandasm::Ins *ins, [[maybe_unused]] ProgramElement *programElement, [[maybe_unused]] uint32_t totalRegs) const override { ins->opcode = pandasm::Opcode::<%= node_kind %>; -% if op_map['reg'].length != 0 - ins->regs.reserve(<%= op_map['reg'].length %>); -% end -% if op_map['imm'].length != 0 - ins->imms.reserve(<%= op_map['imm'].length %>); -% end -% if op_map['str'].length + op_map['lbl'].length != 0 - ins->ids.reserve(<%= op_map['str'].length + op_map['lbl'].length %>); -% end % for reg in op_map['reg'] - ins->regs.emplace_back(MapRegister(<%= reg %>.GetIndex(), totalRegs)); + ins->EmplaceReg(MapRegister(<%= reg %>.GetIndex(), totalRegs)); % end % for imm in op_map['imm'] - ins->imms.emplace_back(<%= imm %>); + ins->EmplaceImm(<%= imm %>); % end % if insn.properties.include? 'literalarray_id' and insn.properties.none? 'skip_literal_id_patch' programElement->LiteralBufferIns().push_back(ins); %end % for str in op_map['str'] std::string <%= str %>mutf8 = <%= str %>.Mutf8(); - ins->ids.emplace_back(<%= str %>mutf8); + ins->EmplaceID(<%= str %>mutf8); programElement->Strings().insert(std::move(<%= str %>mutf8)); % end % for lbl in op_map['lbl'] - ins->ids.emplace_back(<%= lbl %>->Id()); + ins->EmplaceID(<%= lbl %>->Id()); % end } diff --git a/ets2panda/declgen_ets2ts/BUILD.gn b/ets2panda/declgen_ets2ts/BUILD.gn index 8de1df605da2ef43c64b3e0efb64b7b443a2fcff..6fdca2dbfb45ed3f26ba8ca3421a2dc8248957aa 100644 --- a/ets2panda/declgen_ets2ts/BUILD.gn +++ b/ets2panda/declgen_ets2ts/BUILD.gn @@ -11,8 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") import("//build/ohos.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} ohos_executable("declgen_ets2ts") { sources = [ @@ -22,12 +28,18 @@ ohos_executable("declgen_ets2ts") { ] include_dirs = [ "$target_gen_dir" ] - - configs = [ - "$ark_root:ark_config", + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } + configs += [ "$ark_es2panda_root:libes2panda_public_config", "$ark_root/assembler:arkassembler_public_config", - "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libarkfile:arkfile_public_config", "$ark_root/libpandabase:arkbase_public_config", "$ark_root/bytecode_optimizer:bytecodeopt_public_config", "$ark_root/compiler:arkcompiler_public_config", diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index b37db2b236f96d3b8f9923b6765675a1381de2ff..ab4a847b342cf8594dc5702dbfc7aaf01126d882 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -17,6 +17,7 @@ #include "isolatedDeclgenChecker.h" #include "checker/types/ets/etsTupleType.h" +#include "compiler/lowering/phase.h" #include "generated/diagnostic.h" #include "ir/base/classProperty.h" #include "ir/base/methodDefinition.h" @@ -27,13 +28,11 @@ #include "ir/ets/etsUnionType.h" #include "ir/expressions/identifier.h" #include "ir/expressions/literals/numberLiteral.h" -#include "ir/module/importSpecifier.h" -#include "ir/statements/blockStatement.h" #include "ir/statements/classDeclaration.h" -#include "ir/ts/tsEnumMember.h" #include "ir/ts/tsInterfaceBody.h" #include "ir/ts/tsTypeAliasDeclaration.h" #include "ir/ts/tsTypeParameter.h" +#include "compiler/lowering/util.h" #define DEBUG_PRINT 0 @@ -52,8 +51,8 @@ bool TSDeclGen::Generate() return false; } CollectIndirectExportDependencies(); + CollectGlueCodeImportSet(); GenDeclarations(); - GenOtherDeclarations(); return true; } @@ -75,6 +74,68 @@ bool TSDeclGen::GenGlobalDescriptor() return true; } +void TSDeclGen::CollectGlueCodeImportSet() +{ + for (auto *globalStatement : program_->Ast()->Statements()) { + if (globalStatement->IsETSImportDeclaration()) { + auto importDeclaration = globalStatement->AsETSImportDeclaration(); + if (importDeclaration->IsPureDynamic()) { + return; + } + const auto &specifiers = importDeclaration->Specifiers(); + if (specifiers.empty()) { + return; + } + const auto specifierFirst = specifiers[0]; + if (importDeclaration->IsTypeKind()) { + continue; + } + if (specifierFirst->IsImportDefaultSpecifier()) { + CollectDefaultImport(specifierFirst); + } else if (specifierFirst->IsImportSpecifier()) { + CollectNamedImports(specifiers); + } + } + } +} + +void TSDeclGen::CollectDefaultImport(const ir::AstNode *specifier) +{ + auto importDefaultSpecifier = specifier->AsImportDefaultSpecifier(); + auto variable = importDefaultSpecifier->Local()->Variable(); + const auto local = importDefaultSpecifier->Local()->Name().Mutf8(); + bool isTypeDeclaration = false; + if (variable != nullptr && variable->Declaration() != nullptr && variable->Declaration()->Node() != nullptr) { + auto *node = variable->Declaration()->Node(); + isTypeDeclaration = node->IsTSTypeAliasDeclaration() || node->IsTSInterfaceDeclaration(); + } + if (!isTypeDeclaration) { + glueCodeImportSet_.insert(local); + } +} + +void TSDeclGen::CollectNamedImports(const ArenaVector &specifiers) +{ + if (specifiers.empty()) { + return; + } + for (auto *specifier : specifiers) { + if (!specifier->IsImportSpecifier()) { + continue; + } + auto importSpecifier = specifier->AsImportSpecifier(); + auto variable = importSpecifier->Imported()->Variable(); + bool isTypeDeclaration = false; + if (variable != nullptr && variable->Declaration() != nullptr && variable->Declaration()->Node() != nullptr) { + auto *node = variable->Declaration()->Node(); + isTypeDeclaration = node->IsTSTypeAliasDeclaration() || node->IsTSInterfaceDeclaration(); + } + if (!isTypeDeclaration) { + glueCodeImportSet_.insert(importSpecifier->Local()->Name().Mutf8()); + } + } +} + void TSDeclGen::CollectIndirectExportDependencies() { for (auto *stmt : program_->Ast()->Statements()) { @@ -82,6 +143,8 @@ void TSDeclGen::CollectIndirectExportDependencies() ProcessTypeAliasDependencies(stmt->AsTSTypeAliasDeclaration()); } else if (stmt->IsClassDeclaration()) { ProcessClassDependencies(stmt->AsClassDeclaration()); + } else if (stmt->IsTSInterfaceDeclaration()) { + ProcessInterfaceDependencies(stmt->AsTSInterfaceDeclaration()); } } } @@ -150,11 +213,12 @@ void TSDeclGen::ProcessClassDependencies(const ir::ClassDeclaration *classDecl) if (!classDef->IsExported() && !classDef->IsDefaultExported()) { return; } - state_.super = classDef->Super(); + state_.super = classDef->Super(); if (state_.super != nullptr) { AddSuperType(state_.super); } + if (classDef->TsType() != nullptr && classDef->TsType()->IsETSObjectType()) { ProcessInterfacesDependencies(classDef->TsType()->AsETSObjectType()->Interfaces()); } @@ -214,6 +278,57 @@ void TSDeclGen::ProcessClassMethodDependencies(const ir::MethodDefinition *metho AddSuperType(sig->ReturnType()); } +void TSDeclGen::ProcessInterfaceDependencies(const ir::TSInterfaceDeclaration *interfaceDecl) +{ + if (interfaceDecl->Id()->Name().Mutf8().find('#') != std::string::npos) { + return; + } + + if (!interfaceDecl->IsExported() && !interfaceDecl->IsExportedType()) { + return; + } + + if (interfaceDecl->TsType() != nullptr && interfaceDecl->TsType()->IsETSObjectType()) { + ProcessInterfacesDependencies(interfaceDecl->TsType()->AsETSObjectType()->Interfaces()); + } + + if (interfaceDecl->TypeParams() != nullptr) { + GenSeparated( + interfaceDecl->TypeParams()->Params(), + [this](ir::TSTypeParameter *param) { + if (param->Constraint() == nullptr) { + return; + } + AddSuperType(param->Constraint()); + }, + ""); + } + + ProcessInterfacePropDependencies(interfaceDecl); +} + +void TSDeclGen::ProcessInterfacePropDependencies(const ir::TSInterfaceDeclaration *interfaceDecl) +{ + for (const auto *prop : interfaceDecl->Body()->Body()) { + if (prop->IsMethodDefinition()) { + ProcessInterfaceMethodDependencies(prop->AsMethodDefinition()); + } + } +} + +void TSDeclGen::ProcessInterfaceMethodDependencies(const ir::MethodDefinition *methodDef) +{ + auto methDefFunc = methodDef->Function(); + if (methDefFunc == nullptr) { + return; + } + auto sig = methDefFunc->Signature(); + GenSeparated( + sig->Params(), [this](varbinder::LocalVariable *param) { AddSuperType(param->TsType()); }, ""); + + AddSuperType(sig->ReturnType()); +} + void TSDeclGen::AddSuperType(const ir::Expression *super) { if (super->TsType() == nullptr) { @@ -264,7 +379,10 @@ void TSDeclGen::GenDeclarations() for (auto *globalStatement : program_->Ast()->Statements()) { ResetState(); ResetClassNode(); - if (globalStatement->IsClassDeclaration()) { + const auto jsdoc = compiler::JsdocStringFromDeclaration(globalStatement); + if (jsdoc.Utf8().find(NON_INTEROP_FLAG) != std::string_view::npos) { + continue; + } else if (globalStatement->IsClassDeclaration()) { GenClassDeclaration(globalStatement->AsClassDeclaration()); } else if (globalStatement->IsTSInterfaceDeclaration()) { GenInterfaceDeclaration(globalStatement->AsTSInterfaceDeclaration()); @@ -276,17 +394,12 @@ void TSDeclGen::GenDeclarations() } } -void TSDeclGen::GenOtherDeclarations() +void TSDeclGen::GenExportNamedDeclarations() { - const std::string recordKey = "Record"; - const std::string recordStr = R"( -// generated for static Record -type Record = { - [P in K]: T; -}; -)"; - if (indirectDependencyObjects_.find(recordKey) != indirectDependencyObjects_.end()) { - OutDts(recordStr); + for (auto *globalStatement : program_->Ast()->Statements()) { + if (globalStatement->IsExportNamedDeclaration()) { + GenExportNamedDeclaration(globalStatement->AsExportNamedDeclaration()); + } } } @@ -299,6 +412,11 @@ void TSDeclGen::GenImportDeclarations() } } +void TSDeclGen::GenImportRecordDeclarations(const std::string &source) +{ + OutDts("import type { Record } from \"", source, "\";\n"); +} + template void TSDeclGen::GenSeparated(const T &container, const CB &cb, const char *separator, bool isReExport, bool isDtsExport) { @@ -366,14 +484,6 @@ void TSDeclGen::GenType(const checker::Type *checkerType) if (HandleBasicTypes(checkerType)) { return; } - if (checkerType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - OutDts("number"); - return; - } - if (checkerType->IsETSStringEnumType()) { - OutDts("string"); - return; - } if (checkerType->IsETSFunctionType()) { HandleFunctionType(checkerType); @@ -444,7 +554,7 @@ bool TSDeclGen::HandleETSSpecificTypes(const checker::Type *checkerType) GenTupleType(checkerType->AsETSTupleType()); return true; case checker::TypeFlag::ETS_ANY: - OutDts("any"); + OutDts("ESObject"); return true; default: LogError(diagnostic::UNSUPPORTED_TYPE, {GetDebugTypeName(checkerType)}); @@ -604,7 +714,7 @@ void TSDeclGen::ProcessFuncParameter(varbinder::LocalVariable *param) ProcessTypeAnnotationType(typeAnnotation, paramType); return; } - OutDts("any"); + OutDts("ESObject"); } void TSDeclGen::ProcessFuncParameters(const checker::Signature *sig) @@ -616,10 +726,12 @@ void TSDeclGen::GenFunctionType(const checker::ETSFunctionType *etsFunctionType, { const bool isConstructor = methodDef != nullptr ? methodDef->IsConstructor() : false; const bool isSetter = methodDef != nullptr ? methodDef->Kind() == ir::MethodDefinitionKind::SET : false; + const bool isStatic = methodDef != nullptr ? methodDef->IsStatic() : false; // CC-OFFNXT(G.FMT.14-CPP) project code style const auto *sig = GetFuncSignature(etsFunctionType, methodDef); + ES2PANDA_ASSERT(sig != nullptr); if (sig->HasFunction()) { - GenTypeParameters(sig->Function()->TypeParams()); + GenTypeParameters(sig->Function()->TypeParams(), isStatic, sig->Owner()->AsETSObjectType()); const auto *funcBody = sig->Function()->Body(); if (funcBody != nullptr && funcBody->IsBlockStatement() && !funcBody->AsBlockStatement()->Statements().empty()) { @@ -800,7 +912,8 @@ void TSDeclGen::HandleTypeArgument(checker::Type *arg, const std::string &typeSt if (typeStr == "Promise" && arg != nullptr && arg->HasTypeFlag(checker::TypeFlag::ETS_UNDEFINED)) { OutDts("void"); } else if (arg != nullptr) { - if (!state_.currentTypeAliasName.empty() && !arg->HasTypeFlag(checker::TypeFlag::ETS_TYPE_PARAMETER)) { + if (!state_.currentTypeAliasName.empty() && !arg->HasTypeFlag(checker::TypeFlag::ETS_TYPE_PARAMETER) && + (arg->IsETSObjectType() && !arg->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE))) { OutDts(state_.currentTypeAliasName); if (state_.currentTypeParams != nullptr) { importSet_.insert(state_.currentTypeParams->Params()[0]->Name()->Name().Mutf8()); @@ -822,7 +935,7 @@ void TSDeclGen::GenObjectType(const checker::ETSObjectType *objectType) std::string typeStr = objectType->Name().Mutf8(); if (objectType->Name().Empty()) { LogWarning(diagnostic::EMPTY_TYPE_NAME); - OutDts("any"); + OutDts("ESObject"); } else { if (typeStr == "Exception" || typeStr == "NullPointerError") { OutDts("Error"); @@ -845,7 +958,8 @@ void TSDeclGen::GenObjectType(const checker::ETSObjectType *objectType) OutDts(">"); } -void TSDeclGen::GenTypeParameters(const ir::TSTypeParameterDeclaration *typeParams) +void TSDeclGen::GenTypeParameters(const ir::TSTypeParameterDeclaration *typeParams, bool isStatic, + const checker::ETSObjectType *ownerObj) { if (typeParams != nullptr) { OutDts("<"); @@ -864,6 +978,21 @@ void TSDeclGen::GenTypeParameters(const ir::TSTypeParameterDeclaration *typePara } }); OutDts(">"); + return; + } + if (ownerObj == nullptr || !isStatic) { + return; + } + auto typeArguments = ownerObj->TypeArguments(); + if (!typeArguments.empty()) { + OutDts("<"); + for (auto arg : typeArguments) { + OutDts(arg->ToString()); + if (arg != typeArguments.back()) { + OutDts(","); + } + } + OutDts(">"); } } @@ -1005,6 +1134,7 @@ void TSDeclGen::GenAnnotationProperties(const ir::AnnotationUsage *anno) OutEndlDts(); for (auto *prop : properties) { ProcessIndent(); + ES2PANDA_ASSERT(prop->AsClassProperty()->Id() != nullptr); OutDts(prop->AsClassProperty()->Id()->Name()); OutDts(": "); if (prop->AsClassProperty()->Value() != nullptr) { @@ -1032,6 +1162,16 @@ void TSDeclGen::GenAnnotationPropertyValue(ir::Expression *propValue) } } +void TSDeclGen::GenExportNamedDeclaration(const ir::ExportNamedDeclaration *exportDeclaration) +{ + DebugPrint("GenExportNamedDeclaration"); + const auto &specifiers = exportDeclaration->Specifiers(); + if (specifiers.empty()) { + return; + } + GenNamedExports(exportDeclaration, specifiers); +} + void TSDeclGen::GenImportDeclaration(const ir::ETSImportDeclaration *importDeclaration) { DebugPrint("GenImportDeclaration"); @@ -1071,7 +1211,7 @@ void TSDeclGen::GenDefaultImport(const ir::AstNode *specifier, const std::string { auto importDefaultSpecifier = specifier->AsImportDefaultSpecifier(); auto variable = importDefaultSpecifier->Local()->Variable(); - const auto local = importDefaultSpecifier->Local()->Name(); + const auto local = importDefaultSpecifier->Local()->Name().Mutf8(); bool isTypeDeclaration = false; if (variable != nullptr && variable->Declaration() != nullptr && variable->Declaration()->Node() != nullptr) { auto *node = variable->Declaration()->Node(); @@ -1082,7 +1222,7 @@ void TSDeclGen::GenDefaultImport(const ir::AstNode *specifier, const std::string OutEndlTs(); } - if (importSet_.find(local.Mutf8()) == importSet_.end()) { + if (importSet_.find(local) == importSet_.end()) { return; } OutDts(isTypeKind ? "import type " : "import ", local, " from \"", source, "\";"); @@ -1145,6 +1285,47 @@ void TSDeclGen::GenDtsImportStatement(std::vector &specifiers, OutDts(" } from \"", source, "\";\n"); } +void TSDeclGen::GenNamedExports(const ir::ExportNamedDeclaration *exportDeclaration, + const ArenaVector &specifiers) +{ + auto exportSpecifiers = FilterValidExportSpecifiers(specifiers); + if (exportSpecifiers.empty()) { + return; + } + if ((exportDeclaration->Modifiers() & (ir::ModifierFlags::DEFAULT_EXPORT)) != 0U) { + const auto local = specifiers[0]->Local()->Name().Mutf8(); + importSet_.insert(local); + OutDts("export default ", local, ";\n"); + if (glueCodeImportSet_.find(local) != glueCodeImportSet_.end()) { + OutTs("export default ", local, ";\n"); + } + return; + } + + if ((exportDeclaration->Modifiers() & (ir::ModifierFlags::EXPORT_TYPE)) != 0U) { + OutDts("export type { "); + } else { + OutDts("export { "); + } + + GenSeparated( + exportSpecifiers, [this](ir::AstNode *specifier) { GenSingleNamedExport(specifier); }, ", "); + OutDts(" };\n"); + + if ((exportDeclaration->Modifiers() & (ir::ModifierFlags::EXPORT_TYPE)) != 0U) { + return; + } + auto guleCodeExportSpecifiers = FilterGlueCodeExportSpecifiers(exportSpecifiers); + if (guleCodeExportSpecifiers.empty()) { + return; + } + OutTs("export { "); + GenSeparated( + guleCodeExportSpecifiers, [this](ir::AstNode *specifier) { GenSingleNamedExport(specifier, true); }, ", ", true, + false); + OutTs(" };\n"); +} + void TSDeclGen::GenSingleNamedImport(ir::AstNode *specifier, const ir::ETSImportDeclaration *importDeclaration, bool isGlueCode) { @@ -1160,6 +1341,43 @@ void TSDeclGen::GenSingleNamedImport(ir::AstNode *specifier, const ir::ETSImport } } +void TSDeclGen::GenSingleNamedExport(ir::AstNode *specifier, bool isGlueCode) +{ + const auto local = specifier->AsExportSpecifier()->Local()->Name().Mutf8(); + const auto imported = specifier->AsExportSpecifier()->Exported()->Name().Mutf8(); + if (local != imported) { + importSet_.insert(imported); + isGlueCode ? OutTs(imported, " as ", local) : OutDts(imported, " as ", local); + } else { + importSet_.insert(imported); + isGlueCode ? OutTs(local) : OutDts(local); + } +} + +std::vector TSDeclGen::FilterValidExportSpecifiers(const ArenaVector &specifiers) +{ + std::vector exportSpecifiers; + for (auto specifier : specifiers) { + const auto local = specifier->AsExportSpecifier()->Local()->Name().Mutf8(); + if (exportSet_.find(local) == exportSet_.end()) { + exportSpecifiers.push_back(specifier); + } + } + return exportSpecifiers; +} + +std::vector TSDeclGen::FilterGlueCodeExportSpecifiers(const std::vector &specifiers) +{ + std::vector glueCodeExportSpecifiers; + for (auto specifier : specifiers) { + const auto local = specifier->AsExportSpecifier()->Local()->Name().Mutf8(); + if (glueCodeImportSet_.find(local) != glueCodeImportSet_.end()) { + glueCodeExportSpecifiers.push_back(specifier); + } + } + return glueCodeExportSpecifiers; +} + std::vector TSDeclGen::FilterValidImportSpecifiers(const ArenaVector &specifiers) { std::vector importSpecifiers; @@ -1318,6 +1536,13 @@ bool TSDeclGen::ProcessTSQualifiedName(const ir::ETSTypeReference *typeReference typeReference->Part()->Name()->AsTSQualifiedName()->Name() != nullptr) { const auto qualifiedName = typeReference->Part()->Name()->AsTSQualifiedName()->Name().Mutf8(); std::istringstream stream(qualifiedName); + std::string firstSegment; + if (std::getline(stream, firstSegment, '.') && stdlibNamespaceList_.count(firstSegment) != 0U) { + OutDts("ESObject"); + return true; + } + importSet_.insert(firstSegment); + indirectDependencyObjects_.insert(firstSegment); std::string segment; while (std::getline(stream, segment, '.')) { importSet_.insert(segment); @@ -1333,6 +1558,10 @@ void TSDeclGen::ProcessETSTypeReferenceType(const ir::ETSTypeReference *typeRefe { auto typePart = typeReference->Part(); auto partName = typePart->GetIdent()->Name().Mutf8(); + if (partName == "Type" || partName == "Function0") { + OutDts("ESObject"); + return; + } importSet_.insert(partName); if (typePart->TypeParams() != nullptr && typePart->TypeParams()->IsTSTypeParameterInstantiation()) { indirectDependencyObjects_.insert(partName); @@ -1383,7 +1612,7 @@ bool TSDeclGen::ProcessTypeAnnotationSpecificTypes(const checker::Type *checkerT OutDts(checkerType->ToString()); return true; case checker::TypeFlag::ETS_ANY: - OutDts("any"); + OutDts("ESObject"); return true; default: return false; @@ -1519,6 +1748,7 @@ void TSDeclGen::GenTypeAliasDeclaration(const ir::TSTypeAliasDeclaration *typeAl if (classNode_.isIndirect || state_.inNamespace || typeAlias->IsDefaultExported()) { OutDts("type ", name); } else { + exportSet_.insert(name); OutDts("export type ", name); } GenTypeParameters(typeAlias->TypeParams()); @@ -1527,6 +1757,7 @@ void TSDeclGen::GenTypeAliasDeclaration(const ir::TSTypeAliasDeclaration *typeAl OutDts(";"); OutEndlDts(); if (typeAlias->IsDefaultExported()) { + exportSet_.insert(name); OutDts("export default ", name, ";"); OutEndlDts(); } @@ -1572,9 +1803,19 @@ void TSDeclGen::GenInterfaceDeclaration(const ir::TSInterfaceDeclaration *interf if (classNode_.isIndirect) { OutDts(state_.isInterfaceInNamespace ? "interface " : "declare interface ", interfaceName); } else if (!interfaceDecl->IsDefaultExported()) { - OutDts(state_.isInterfaceInNamespace ? "interface " : "export declare interface ", interfaceName); + if (state_.isInterfaceInNamespace) { + OutDts("interface ", interfaceName); + } else { + exportSet_.insert(interfaceName); + OutDts("export declare interface ", interfaceName); + } } else { - OutDts(state_.isInterfaceInNamespace ? "interface " : "export default interface ", interfaceName); + if (state_.isInterfaceInNamespace) { + OutDts("interface ", interfaceName); + } else { + exportSet_.insert(interfaceName); + OutDts("export default interface ", interfaceName); + } } GenTypeParameters(interfaceDecl->TypeParams()); @@ -1603,8 +1844,6 @@ void TSDeclGen::ProcessInterfaceBody(const ir::TSInterfaceBody *body) for (auto *prop : body->Body()) { if (prop->IsMethodDefinition()) { ProcessInterfaceMethodDefinition(prop->AsMethodDefinition()); - } else if (prop->IsClassProperty()) { - GenPropDeclaration(prop->AsClassProperty()); } } } @@ -1656,6 +1895,14 @@ bool TSDeclGen::GenInterfaceProp(const ir::MethodDefinition *methodDef) OutDts("?"); } OutDts(": "); + if (methodDef->TsType()->IsETSFunctionType()) { + const auto *sig = GetFuncSignature(methodDef->TsType()->AsETSFunctionType(), methodDef); + ProcessFunctionReturnType(sig); + OutDts(";"); + OutEndlDts(); + return true; + } + ES2PANDA_ASSERT(methodDef->Function() != nullptr); GenType(methodDef->Function()->Signature()->ReturnType()); OutDts(";"); OutEndlDts(); @@ -1716,7 +1963,12 @@ void TSDeclGen::EmitDeclarationPrefix(const ir::ClassDefinition *classDef, const if (classDef->IsDefaultExported()) { OutDts(classNode_.indentLevel > 1 ? typeName : "declare " + typeName, className); } else if (classDef->IsExported() || declgenOptions_.exportAll) { - OutDts(classNode_.indentLevel > 1 ? typeName : "export declare " + typeName, className); + if (classNode_.indentLevel > 1) { + OutDts(typeName, className); + } else { + exportSet_.insert(std::string(className)); + OutDts("export declare " + typeName, className); + } } else { OutDts(classNode_.indentLevel > 1 ? typeName : "declare " + typeName, className); } @@ -1726,7 +1978,8 @@ void TSDeclGen::EmitClassDeclaration(const ir::ClassDefinition *classDef, const { if (classDef->IsNamespaceTransformed()) { EmitDeclarationPrefix(classDef, "namespace ", className); - OutTs("export namespace ", className, " {"); + classDef->IsDefaultExported() ? OutTs("namespace ", className, " {") + : OutTs("export namespace ", className, " {"); OutEndlTs(); } else if (classDef->IsEnumTransformed()) { EmitDeclarationPrefix(classDef, "enum ", className); @@ -1759,7 +2012,7 @@ void TSDeclGen::GenPartName(std::string &partName) } else if (partName == "Exception" || partName == "NullPointerError") { partName = "Error"; } else if (partName == "Any") { - partName = "any"; + partName = "ESObject"; } } @@ -1797,14 +2050,14 @@ void TSDeclGen::HandleClassDeclarationTypeInfo(const ir::ClassDefinition *classD HandleClassInherit(super); } - if (classDef->TsType() != nullptr && classDef->TsType()->IsETSObjectType() && - !classDef->TsType()->AsETSObjectType()->Interfaces().empty()) { + if (!classDef->Implements().empty()) { + OutDts(" implements "); + GenSeparated(classDef->Implements(), [this](ir::TSClassImplements *impl) { HandleClassInherit(impl->Expr()); }); + } else if (classDef->TsType() != nullptr && classDef->TsType()->IsETSObjectType() && + !classDef->TsType()->AsETSObjectType()->Interfaces().empty()) { OutDts(" implements "); const auto &interfaces = classDef->TsType()->AsETSObjectType()->Interfaces(); GenSeparated(interfaces, [this](checker::ETSObjectType *interface) { GenType(interface); }); - } else if (!classDef->Implements().empty()) { - OutDts(" implements "); - GenSeparated(classDef->Implements(), [this](ir::TSClassImplements *impl) { HandleClassInherit(impl->Expr()); }); } OutDts(" {"); @@ -1862,7 +2115,10 @@ void TSDeclGen::ProcessClassBody(const ir::ClassDefinition *classDef) state_.inClass = true; std::unordered_set processedMethods; for (const auto *prop : classDef->Body()) { - if (classDef->IsEnumTransformed()) { + const auto jsdoc = compiler::JsdocStringFromDeclaration(prop); + if (jsdoc.Utf8().find(NON_INTEROP_FLAG) != std::string_view::npos) { + continue; + } else if (classDef->IsEnumTransformed()) { if (prop->IsClassProperty()) { state_.inEnum = true; GenPropDeclaration(prop->AsClassProperty()); @@ -1950,8 +2206,13 @@ void TSDeclGen::GenClassDeclaration(const ir::ClassDeclaration *classDecl) } } if (classDef->IsDefaultExported()) { + exportSet_.insert(className); OutDts("export default ", className, ";"); OutEndlDts(); + if (classDef->IsNamespaceTransformed()) { + OutTs("export default ", className, ";"); + OutEndlTs(); + } } } @@ -1959,12 +2220,12 @@ bool TSDeclGen::ShouldSkipMethodDeclaration(const ir::MethodDefinition *methodDe { const auto methodIdent = GetKeyIdent(methodDef->Key()); const auto methodName = methodIdent->Name().Mutf8(); - if (methodName.find('#') != std::string::npos || methodName.find("$asyncimpl") != std::string::npos || + if (methodName.find('#') != std::string::npos || methodName.find("%%async-") != std::string::npos || (!state_.inGlobalClass && (methodName == compiler::Signatures::INIT_METHOD || methodName == compiler::Signatures::INITIALIZER_BLOCK_INIT))) { return true; } - if (methodDef->IsPrivate() && !methodDef->IsConstructor()) { + if (methodDef->IsPrivate() && (methodDef->IsConstructor() || state_.inInterface)) { return true; } if (methodName == compiler::Signatures::INIT_METHOD) { @@ -2006,7 +2267,10 @@ void TSDeclGen::GenMethodDeclaration(const ir::MethodDefinition *methodDef) return; } const auto methodIdent = GetKeyIdent(methodDef->Key()); - const auto methodName = methodIdent->Name().Mutf8(); + auto methodName = methodIdent->Name().Mutf8(); + if (methodName.compare("$_iterator") == 0) { + methodName = "[Symbol.iterator]"; + } if (GenMethodDeclarationPrefix(methodDef, methodIdent, methodName)) { return; } @@ -2016,6 +2280,7 @@ void TSDeclGen::GenMethodDeclaration(const ir::MethodDefinition *methodDef) OutEndlDts(); if (methodDef->IsDefaultExported()) { + exportSet_.insert(methodName); OutDts("export default ", methodName, ";"); OutEndlDts(); } @@ -2031,6 +2296,7 @@ bool TSDeclGen::GenMethodDeclarationPrefix(const ir::MethodDefinition *methodDef if (methodDef->IsDefaultExported()) { OutDts("declare function "); } else { + exportSet_.insert(methodName); OutDts("export declare function "); } } else { @@ -2047,6 +2313,7 @@ bool TSDeclGen::GenMethodDeclarationPrefix(const ir::MethodDefinition *methodDef } EmitMethodGlueCode(methodName, methodIdent); + ES2PANDA_ASSERT(methodDef->Function() != nullptr); if (methodDef->Function()->IsAbstract() && !state_.inInterface && !(methodDef->Parent()->IsTSInterfaceBody() || (methodDef->BaseOverloadMethod() != nullptr && @@ -2080,7 +2347,7 @@ void TSDeclGen::GenMethodSignature(const ir::MethodDefinition *methodDef, const if (methodDef->TsType() == nullptr) { LogWarning(diagnostic::UNTYPED_METHOD, {methodName}, methodIdent->Start()); - OutDts(": any"); + OutDts(": ESObject"); return; } if (methodDef->TsType()->IsETSFunctionType()) { @@ -2181,7 +2448,7 @@ void TSDeclGen::ProcessClassPropDeclaration(const ir::ClassProperty *classProp) OutDts(propName); OutDts(": "); if (!state_.inNamespace) { - classProp->IsStatic() ? OutDts("any") : GenType(classProp->TsType()); + classProp->IsStatic() ? OutDts("ESObject") : GenType(classProp->TsType()); } else { ProcessClassPropertyType(classProp); } @@ -2226,6 +2493,7 @@ void TSDeclGen::GenGlobalVarDeclaration(const ir::ClassProperty *globalVar) GenAnnotations(globalVar); + exportSet_.insert(varName); if (isDefaultExported) { OutDts(isConst ? "declare const " : "declare let ", varName, ": "); } else { @@ -2265,14 +2533,7 @@ bool GenerateTsDeclarations(checker::ETSChecker *checker, const ark::es2panda::p TSDeclGen declBuilder(checker, &isolatedDeclgenChecker, program); declBuilder.SetDeclgenOptions(declgenOptions); - if ((declBuilder.GetDeclgenOptions().outputDeclEts.empty() && !declBuilder.GetDeclgenOptions().outputEts.empty()) || - (!declBuilder.GetDeclgenOptions().outputDeclEts.empty() && declBuilder.GetDeclgenOptions().outputEts.empty())) { - checker->DiagnosticEngine().LogDiagnostic(diagnostic::GENERATE_DYNAMIC_DECLARATIONS, - util::DiagnosticMessageParams {}); - return false; - } - if (declBuilder.GetDeclgenOptions().outputDeclEts.empty() && declBuilder.GetDeclgenOptions().outputEts.empty()) { - checker->DiagnosticEngine().LogDiagnostic(diagnostic::MISSING_OUTPUT_FILE, util::DiagnosticMessageParams {""}); + if (!ValidateDeclgenOptions(declBuilder.GetDeclgenOptions(), checker)) { return false; } @@ -2286,28 +2547,65 @@ bool GenerateTsDeclarations(checker::ETSChecker *checker, const ark::es2panda::p declBuilder.ResetTsOutput(); declBuilder.ResetDtsOutput(); + auto afterCheckerId = compiler::GetPhaseManager()->CurrentPhaseId().minor; + int32_t firstPhaseId = -1; + compiler::GetPhaseManager()->SetCurrentPhaseIdWithoutReCheck(firstPhaseId); + declBuilder.GenExportNamedDeclarations(); + + std::string exportOutputEts = declBuilder.GetTsOutput(); + std::string exportOutputDEts = declBuilder.GetDtsOutput(); + + declBuilder.ResetTsOutput(); + declBuilder.ResetDtsOutput(); + + compiler::GetPhaseManager()->SetCurrentPhaseIdWithoutReCheck(afterCheckerId); declBuilder.GenImportDeclarations(); std::string importOutputEts = declBuilder.GetTsOutput(); std::string importOutputDEts = declBuilder.GetDtsOutput(); - std::string combineEts = importOutputEts + outputEts; - std::string combinedDEts = importOutputDEts + outputDEts; + std::string combineEts = importOutputEts + outputEts + exportOutputEts; + std::string combinedDEts = importOutputDEts + outputDEts + exportOutputDEts; + + if (!declBuilder.GetDeclgenOptions().recordFile.empty()) { + declBuilder.ResetDtsOutput(); + declBuilder.GenImportRecordDeclarations(declBuilder.GetDeclgenOptions().recordFile); + std::string recordImportOutputDEts = declBuilder.GetDtsOutput(); + combinedDEts = recordImportOutputDEts + combinedDEts; + } + + return WriteOutputFiles(declBuilder.GetDeclgenOptions(), combineEts, combinedDEts, checker); +} - if (!declBuilder.GetDeclgenOptions().outputDeclEts.empty()) { - auto outDtsPath = declBuilder.GetDeclgenOptions().outputDeclEts; - if (!WriteToFile(outDtsPath, combinedDEts, checker)) { +bool ValidateDeclgenOptions(const DeclgenOptions &options, checker::ETSChecker *checker) +{ + if ((options.outputDeclEts.empty() && !options.outputEts.empty()) || + (!options.outputDeclEts.empty() && options.outputEts.empty())) { + checker->DiagnosticEngine().LogDiagnostic(diagnostic::GENERATE_DYNAMIC_DECLARATIONS, + util::DiagnosticMessageParams {}); + return false; + } + if (options.outputDeclEts.empty() && options.outputEts.empty()) { + checker->DiagnosticEngine().LogDiagnostic(diagnostic::MISSING_OUTPUT_FILE, util::DiagnosticMessageParams {""}); + return false; + } + return true; +} + +bool WriteOutputFiles(const DeclgenOptions &options, const std::string &combinedEts, const std::string &combinedDEts, + checker::ETSChecker *checker) +{ + if (!options.outputDeclEts.empty()) { + if (!WriteToFile(options.outputDeclEts, combinedDEts, checker)) { return false; } } - if (!declBuilder.GetDeclgenOptions().outputEts.empty()) { - auto outTsPath = declBuilder.GetDeclgenOptions().outputEts; - if (!WriteToFile(outTsPath, combineEts, checker)) { + if (!options.outputEts.empty()) { + if (!WriteToFile(options.outputEts, combinedEts, checker)) { return false; } } - return true; } } // namespace ark::es2panda::declgen_ets2ts diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.h b/ets2panda/declgen_ets2ts/declgenEts2Ts.h index 94471dab3b11bf0c4893662444b3f65d517b41bd..6f868df50dca1621f15cdd045fe0c7ef0998ef66 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.h +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.h @@ -16,26 +16,33 @@ #ifndef ES2PANDA_DECLGEN_ETS2TS_H #define ES2PANDA_DECLGEN_ETS2TS_H -#include "parser/program/program.h" #include "checker/ETSchecker.h" +#include "compiler/lowering/phase.h" #include "libpandabase/os/file.h" #include "libpandabase/utils/arena_containers.h" +#include "parser/program/program.h" #include "util/options.h" #include "util/diagnosticEngine.h" #include "isolatedDeclgenChecker.h" namespace ark::es2panda::declgen_ets2ts { +constexpr const char *NON_INTEROP_FLAG = "@noninterop"; + struct DeclgenOptions { bool exportAll = false; bool isolated = false; std::string outputDeclEts; std::string outputEts; + std::string recordFile; }; // Consume program after checker stage and generate out_path typescript file with declarations bool GenerateTsDeclarations(checker::ETSChecker *checker, const ark::es2panda::parser::Program *program, const DeclgenOptions &declgenOptions); +bool ValidateDeclgenOptions(const DeclgenOptions &options, checker::ETSChecker *checker); +bool WriteOutputFiles(const DeclgenOptions &options, const std::string &combinedEts, const std::string &combinedDEts, + checker::ETSChecker *checker); class TSDeclGen { public: @@ -48,6 +55,8 @@ public: allocator_(SpaceType::SPACE_TYPE_COMPILER, nullptr, true), indirectDependencyObjects_(allocator_.Adapter()), importSet_(allocator_.Adapter()), + exportSet_(allocator_.Adapter()), + glueCodeImportSet_(allocator_.Adapter()), typeAliasMap_(allocator_.Adapter()), paramDefaultMap_(allocator_.Adapter()) { @@ -65,6 +74,8 @@ public: bool Generate(); void GenImportDeclarations(); + void GenExportNamedDeclarations(); + void GenImportRecordDeclarations(const std::string &source); std::string GetDtsOutput() const { @@ -121,6 +132,7 @@ private: std::vector FilterUnionTypes(const ArenaVector &originTypes); void GenImportDeclaration(const ir::ETSImportDeclaration *importDeclaration); + void GenExportNamedDeclaration(const ir::ExportNamedDeclaration *exportDeclaration); void GenNamespaceImport(const ir::AstNode *specifier, const std::string &source); void GenDefaultImport(const ir::AstNode *specifier, const std::string &source, bool isTypeKind = false); void GenNamedImports(const ir::ETSImportDeclaration *importDeclaration, @@ -129,8 +141,11 @@ private: const ir::ETSImportDeclaration *importDeclaration, bool isTypeKind = false); void GenTsImportStatement(std::vector &specifiers, const ir::ETSImportDeclaration *importDeclaration, bool isInterface = false); + void GenNamedExports(const ir::ExportNamedDeclaration *exportDeclaration, + const ArenaVector &specifiers); void GenSingleNamedImport(ir::AstNode *specifier, const ir::ETSImportDeclaration *importDeclaration, bool isGlueCode = false); + void GenSingleNamedExport(ir::AstNode *specifier, bool isGlueCode = false); void GenReExportDeclaration(const ir::ETSReExportDeclaration *reExportDeclaration); bool GenNamespaceReExportDeclaration(const ir::AstNode *specifier, const ir::ETSImportDeclaration *importDeclaration); @@ -167,7 +182,8 @@ private: void GenAnnotationProperties(const ir::AnnotationUsage *anno); void GenAnnotationPropertyValue(ir::Expression *value); - void GenTypeParameters(const ir::TSTypeParameterDeclaration *typeParams); + void GenTypeParameters(const ir::TSTypeParameterDeclaration *typeParams, bool isStatic = false, + const checker::ETSObjectType *ownerObj = nullptr); void GenExport(const ir::Identifier *symbol); void GenExport(const ir::Identifier *symbol, const std::string &alias); void GenDefaultExport(const ir::Identifier *symbol); @@ -189,6 +205,8 @@ private: void ProcessFuncParameters(const checker::Signature *sig); void ProcessClassPropertyType(const ir::ClassProperty *classProp); std::vector FilterValidImportSpecifiers(const ArenaVector &specifiers); + std::vector FilterValidExportSpecifiers(const ArenaVector &specifiers); + std::vector FilterGlueCodeExportSpecifiers(const std::vector &specifiers); std::string ReplaceETSGLOBAL(const std::string &typeName); std::string GetIndent() const; std::string RemoveModuleExtensionName(const std::string &filepath); @@ -196,19 +214,24 @@ private: void ProcessIndent(); bool GenGlobalDescriptor(); + void CollectGlueCodeImportSet(); + void CollectDefaultImport(const ir::AstNode *specifier); + void CollectNamedImports(const ArenaVector &specifiers); void CollectIndirectExportDependencies(); void ProcessTypeAliasDependencies(const ir::TSTypeAliasDeclaration *typeAliasDecl); void ProcessTypeAnnotationDependencies(const ir::TypeNode *typeAnnotation); void ProcessClassDependencies(const ir::ClassDeclaration *classDecl); void ProcessClassPropDependencies(const ir::ClassDefinition *classDef); void ProcessClassMethodDependencies(const ir::MethodDefinition *methodDef); + void ProcessInterfaceDependencies(const ir::TSInterfaceDeclaration *interfaceDecl); + void ProcessInterfacePropDependencies(const ir::TSInterfaceDeclaration *interfaceDecl); + void ProcessInterfaceMethodDependencies(const ir::MethodDefinition *methodDef); void ProcessETSTypeReferenceDependencies(const ir::ETSTypeReference *typeReference); void AddSuperType(const ir::Expression *super); void AddSuperType(const checker::Type *tsType); void ProcessInterfacesDependencies(const ArenaVector &interfaces); void AddObjectDependencies(const util::StringView &typeName, const std::string &alias = ""); void GenDeclarations(); - void GenOtherDeclarations(); void CloseClassBlock(const bool isDts); void EmitDeclarationPrefix(const ir::ClassDefinition *classDef, const std::string &typeName, @@ -230,7 +253,6 @@ private: void ProcessInterfaceMethodDefinition(const ir::MethodDefinition *methodDef); void ProcessMethodDefinition(const ir::MethodDefinition *methodDef, std::unordered_set &processedMethods); - void ProcessMethodsFromInterfaces(std::unordered_set &processedMethods, const ArenaVector &interfaces); @@ -305,6 +327,9 @@ private: "Observed", "ObjectLink", "Watch", "Track", "ObservedV2", "Trace", "ComponentV2", "Local", "Param", "Once", "Event", "Provider", "Consumer", "Monitor", "Computed", "Type"}; + const std::unordered_set stdlibNamespaceList_ = { + "StdProcess", "taskpool", "functions", "containers", "Intl", "GC", + "jsonx", "proxy", "unsafeMemory", "reflect", "StdDebug", "arktest"}; const std::set extensions_ = {".sts", ".ets", ".ts", ".js"}; std::stringstream outputDts_; @@ -316,6 +341,8 @@ private: ArenaAllocator allocator_; ArenaSet indirectDependencyObjects_; ArenaSet importSet_; + ArenaSet exportSet_; + ArenaSet glueCodeImportSet_; DeclgenOptions declgenOptions_ {}; std::string globalDesc_; ArenaMap typeAliasMap_; diff --git a/ets2panda/declgen_ets2ts/main.cpp b/ets2panda/declgen_ets2ts/main.cpp index a13937b367dffa3a1c49c3d7a97040eb9d6177c0..0ae19db13192d518db109bf52648c68efb5349b5 100644 --- a/ets2panda/declgen_ets2ts/main.cpp +++ b/ets2panda/declgen_ets2ts/main.cpp @@ -16,6 +16,7 @@ #include "public/es2panda_lib.h" #include "public/public.h" #include "declgenEts2Ts.h" +#include "ir/astNodeHistory.h" #include "isolatedDeclgenChecker.h" namespace ark::es2panda::declgen_ets2ts { @@ -91,8 +92,7 @@ static int Run(int argc, const char **argv) auto *cfgImpl = reinterpret_cast(cfg); auto parserInputCStr = cfgImpl->options->CStrParserInputContents().first; es2panda_Context *ctx = - impl->CreateContextFromString(cfg, parserInputCStr, cfgImpl->options->SourceFileName().c_str()); - + impl->CreateContextFromStringWithHistory(cfg, parserInputCStr, cfgImpl->options->SourceFileName().c_str()); auto *ctxImpl = reinterpret_cast(ctx); auto *checker = reinterpret_cast(ctxImpl->GetChecker()); diff --git a/ets2panda/docs/lowering-phases.md b/ets2panda/docs/lowering-phases.md index 392626e8408435fb42fa8f91749b55e71cc58fcd..d0b2445c898d5a10bb3a454934ec9c558a42c3d2 100644 --- a/ets2panda/docs/lowering-phases.md +++ b/ets2panda/docs/lowering-phases.md @@ -350,17 +350,17 @@ class C { public f(): int { let ll = 2; - let lam = new LambdaObject-C$lambda$invoke$0(this, ll); + let lam = new %%lambda-lambda_invoke-0(this, ll); return lam.invoke0(); } - public lambda$invoke$0(ll: int): int { + public lambda_invoke-0(ll: int): int { return (this.p + ll); } } -final class LambdaObject-C$lambda$invoke$0 implements Function0 { +final class %%lambda-lambda_invoke-0 implements Function0 { public $this: C; public ll: int; @@ -371,11 +371,11 @@ final class LambdaObject-C$lambda$invoke$0 implements Function0 { } public invoke0(): Object|null|undefined { - return this.$this.lambda$invoke$0(this.ll) as Object|null|undefined; + return this.$this.lambda_invoke-0(this.ll) as Object|null|undefined; } public $_invoke(): int { - return this.$this.lambda$invoke$0(this.ll); + return this.$this.lambda_invoke-0(this.ll); } } ``` diff --git a/ets2panda/driver/build_system/README.md b/ets2panda/driver/build_system/README.md index 414e8efc043ff59b3442d22236ee37d7897808f3..667ca25c5d897c40e3a10b307808eaeeda619e87 100644 --- a/ets2panda/driver/build_system/README.md +++ b/ets2panda/driver/build_system/README.md @@ -2,6 +2,11 @@ The build system is designed to compile ArkTS1.2 source files. It takes source files and build configurations as input, compiles the source files, invokes plugins for transformation, and generates a merged bytecode file. +## env +USE_KOALA_LIBARKTS - use libarkts from koala_mirror +USE_KOALA_UI_PLUGIN - use ui-plugin from koala_mirror +USE_KOALA_MEMO_PLUGIN - use memo-plugin from koala_mirror + ## How to Run The build system has two usage scenarios: diff --git a/ets2panda/driver/build_system/package.json b/ets2panda/driver/build_system/package.json index 91c43d2747fa94711b038dad2cdeae9c8a9f0dc4..9ba50d68693e8286b667f3a1fc36e98869731944 100644 --- a/ets2panda/driver/build_system/package.json +++ b/ets2panda/driver/build_system/package.json @@ -3,6 +3,9 @@ "version": "1.0.0", "description": "Compile ArkTS 2.0 source code into bytecode, encompassing UI transformations.", "private": true, + "engines": { + "node": ">=14.0.0" + }, "main": "dist/index.js", "scripts": { "clean": "rimraf dist", diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 09458f4971269722963a8822104dd740e6ec2056..22f7b927fff90b81bbc7eb611ceabaf3e6d5a6fd 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -30,16 +30,21 @@ import { ARKTSCONFIG_JSON_FILE, DEFAULT_WOKER_NUMS, DECL_ETS_SUFFIX, + DECL_TS_SUFFIX, + DEPENDENCY_INPUT_FILE, DEPENDENCY_JSON_FILE, LANGUAGE_VERSION, LINKER_INPUT_FILE, MERGED_ABC_FILE, - TS_SUFFIX, - DEPENDENCY_INPUT_FILE, + MERGED_INTERMEDIATE_FILE, + STATIC_RECORD_FILE, + STATIC_RECORD_FILE_CONTENT, + TS_SUFFIX } from '../pre_define'; import { changeDeclgenFileExtension, changeFileExtension, + createFileIfNotExists, ensurePathExists, getFileHash, isMac @@ -68,7 +73,10 @@ import { ModuleInfo, ES2PANDA_MODE } from '../types'; -import { ArkTSConfigGenerator } from './generate_arktsconfig'; +import { + ArkTSConfig, + ArkTSConfigGenerator +} from './generate_arktsconfig'; import { SetupClusterOptions } from '../types'; import { KitImportTransformer } from '../plugins/KitImportTransformer'; @@ -107,6 +115,7 @@ export abstract class BaseMode { public hasCleanWorker: boolean; public byteCodeHar: boolean; public es2pandaMode: number; + public skipDeclCheck: boolean; constructor(buildConfig: BuildConfig) { this.buildConfig = buildConfig; @@ -142,7 +151,8 @@ export abstract class BaseMode { this.isBuildConfigModified = buildConfig.isBuildConfigModified as boolean | undefined; this.hasCleanWorker = false; this.byteCodeHar = buildConfig.byteCodeHar as boolean; - this.es2pandaMode = buildConfig?.es2pandaMode ?? ES2PANDA_MODE.RUN; + this.es2pandaMode = buildConfig?.es2pandaMode ?? ES2PANDA_MODE.RUN_PARALLEL; + this.skipDeclCheck = buildConfig?.skipDeclCheck as boolean ?? true; } public declgen(fileInfo: CompileFileInfo): void { @@ -163,6 +173,18 @@ export abstract class BaseMode { const arkts: ArkTS = this.buildConfig.arkts; let errorStatus = false; try { + const staticRecordPath = path.join( + moduleInfo.declgenV1OutPath as string, + STATIC_RECORD_FILE + ) + const declEtsOutputDir = path.dirname(declEtsOutputPath); + const staticRecordRelativePath = changeFileExtension( + path.relative(declEtsOutputDir, staticRecordPath).replaceAll(/\\/g, '\/'), + "", + DECL_TS_SUFFIX + ); + createFileIfNotExists(staticRecordPath, STATIC_RECORD_FILE_CONTENT); + arktsGlobal.filePath = fileInfo.filePath; arktsGlobal.config = arkts.Config.create([ '_', @@ -172,16 +194,16 @@ export abstract class BaseMode { fileInfo.arktsConfigFile, fileInfo.filePath ]).peer; - arktsGlobal.compilerContext = arkts.Context.createFromString(source); + arktsGlobal.compilerContext = arkts.Context.createFromStringWithHistory(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, this.skipDeclCheck); let ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, this.skipDeclCheck); ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); @@ -191,7 +213,8 @@ export abstract class BaseMode { declEtsOutputPath, etsOutputPath, false, - false + false, + staticRecordRelativePath ); // Generate 1.0 declaration files & 1.0 glue code this.logger.printInfo('declaration files generated'); } catch (error) { @@ -250,7 +273,7 @@ export abstract class BaseMode { // if aliasConfig is set, transform aliasName@kit.xxx to default@ohos.xxx through the plugin this.logger.printInfo('Transforming import statements with alias config'); let transformAst = new KitImportTransformer(arkts, arktsGlobal.compilerContext.program, - this.buildConfig.buildSdkPath,this.buildConfig.aliasConfig).transform(ast); + this.buildConfig.buildSdkPath, this.buildConfig.aliasConfig).transform(ast); PluginDriver.getInstance().getPluginContext().setArkTSAst(transformAst); } else { PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); @@ -302,6 +325,10 @@ export abstract class BaseMode { } public compileMultiFiles(filePaths: string[], moduleInfo: ModuleInfo): void { + const intermediateFilePath = path.resolve(this.cacheDir, MERGED_INTERMEDIATE_FILE); + this.abcFiles.clear(); + this.abcFiles.add(intermediateFilePath); + let ets2pandaCmd: string[] = [ '_', '--extension', @@ -309,10 +336,10 @@ export abstract class BaseMode { '--arktsconfig', moduleInfo.arktsConfigFile, '--output', - path.resolve(this.outputDir, MERGED_ABC_FILE), + intermediateFilePath, '--simultaneous' ]; - ensurePathExists(path.resolve(this.outputDir, MERGED_ABC_FILE)); + ensurePathExists(intermediateFilePath); if (this.isDebug) { ets2pandaCmd.push('--debug-info'); } @@ -398,19 +425,6 @@ export abstract class BaseMode { const staticDepModules: Map = new Map(); this.collectDependencyModules(moduleInfo.packageName, moduleInfo, dynamicDepModules, staticDepModules); - if (moduleInfo.isMainModule) { - this.moduleInfos.forEach((module: ModuleInfo, packageName: string) => { - if (module.isMainModule) { - return; - } - this.collectDependencyModules(packageName, module, dynamicDepModules, staticDepModules); - }); - if (moduleInfo.language === LANGUAGE_VERSION.ARKTS_HYBRID) { - dynamicDepModules.set(moduleInfo.packageName, moduleInfo); - } - return [dynamicDepModules, staticDepModules]; - } - if (moduleInfo.dependencies) { moduleInfo.dependencies.forEach((packageName: string) => { let depModuleInfo: ModuleInfo | undefined = this.moduleInfos.get(packageName); @@ -445,10 +459,33 @@ export abstract class BaseMode { } protected generateArkTSConfigForModules(): void { + let taskList: ModuleInfo[] = []; this.moduleInfos.forEach((moduleInfo: ModuleInfo, moduleRootPath: string) => { + if (moduleInfo.dependenciesSet.size === 0) { + taskList.push(moduleInfo); + } + ArkTSConfigGenerator.getInstance(this.buildConfig, this.moduleInfos) - .writeArkTSConfigFile(moduleInfo, this.enableDeclgenEts2Ts, this.buildConfig); + .generateArkTSConfigFile(moduleInfo, this.enableDeclgenEts2Ts); }); + + while (taskList.length > 0) { + const task = taskList.pop(); + const arktsConfig = ArkTSConfigGenerator.getInstance().getArktsConfigPackageName(task!!.packageName) + task?.dependencies?.forEach(dependecyModule => { + arktsConfig?.mergeArktsConfig( + ArkTSConfigGenerator.getInstance().getArktsConfigPackageName(dependecyModule) + ); + }); + fs.writeFileSync(task!!.arktsConfigFile, JSON.stringify(arktsConfig!!.getCompilerOptions(), null, 2)) + task?.dependentSet.forEach((dependentTask) => { + const dependentModule = this.moduleInfos.get(dependentTask); + dependentModule?.dependenciesSet.delete(task.packageName); + if (dependentModule?.dependenciesSet.size === 0) { + taskList.push(dependentModule); + } + }); + } } private collectDepModuleInfos(): void { @@ -456,6 +493,14 @@ export abstract class BaseMode { let [dynamicDepModules, staticDepModules] = this.getDependentModules(moduleInfo); moduleInfo.dynamicDepModuleInfos = dynamicDepModules; moduleInfo.staticDepModuleInfos = staticDepModules; + + [...dynamicDepModules.keys(), ...staticDepModules.keys()].forEach(depName => { + moduleInfo.dependenciesSet.add(depName); + }); + moduleInfo.dependenciesSet.delete(moduleInfo.packageName); + moduleInfo.dependencies?.forEach(moduleName => { + this.moduleInfos.get(moduleName)?.dependentSet.add(moduleInfo.packageName); + }); }); } @@ -498,7 +543,9 @@ export abstract class BaseMode { declFilesPath: module.declFilesPath, dependencies: module.dependencies, byteCodeHar: module.byteCodeHar, - abcPath: module.abcPath + abcPath: module.abcPath, + dependenciesSet: new Set(module?.dependencies), + dependentSet: new Set(), }; this.moduleInfos.set(module.packageName, moduleInfo); }); @@ -509,21 +556,24 @@ export abstract class BaseMode { const mainModuleInfo = this.dependentModuleList.find((module: DependentModuleConfig) => module.packageName === this.packageName); return { isMainModule: this.hasMainModule, - packageName: this.packageName, - moduleRootPath: this.moduleRootPath, - moduleType: this.moduleType, + packageName: mainModuleInfo?.packageName ?? this.packageName, + moduleRootPath: mainModuleInfo?.modulePath ?? this.moduleRootPath, + moduleType: mainModuleInfo?.moduleType ?? this.moduleType, sourceRoots: this.sourceRoots, entryFile: '', arktsConfigFile: path.resolve(this.cacheDir, this.packageName, ARKTSCONFIG_JSON_FILE), dynamicDepModuleInfos: new Map(), staticDepModuleInfos: new Map(), compileFileInfos: [], - declgenV1OutPath: this.declgenV1OutPath, - declgenV2OutPath: this.declgenV2OutPath, - declgenBridgeCodePath: this.declgenBridgeCodePath, + declgenV1OutPath: mainModuleInfo?.declgenV1OutPath ?? this.declgenV1OutPath, + declgenV2OutPath: mainModuleInfo?.declgenV2OutPath ?? this.declgenV2OutPath, + declgenBridgeCodePath: mainModuleInfo?.declgenBridgeCodePath ?? this.declgenBridgeCodePath, byteCodeHar: this.byteCodeHar, language: mainModuleInfo?.language ?? LANGUAGE_VERSION.ARKTS_1_2, declFilesPath: mainModuleInfo?.declFilesPath, + dependentSet: new Set(), + dependenciesSet: new Set(mainModuleInfo?.dependencies), + dependencies: mainModuleInfo?.dependencies ?? [] }; } @@ -632,7 +682,7 @@ export abstract class BaseMode { } }); this.collectAbcFileFromByteCodeHar(); - + while (queue.length > 0) { const currentFile = queue.shift()!; processed.add(currentFile); @@ -694,10 +744,6 @@ export abstract class BaseMode { protected collectCompileFiles(): void { this.entryFiles.forEach((file: string) => { - // Skip the declaration files when compiling abc - if (file.endsWith(DECL_ETS_SUFFIX)) { - return; - } for (const [packageName, moduleInfo] of this.moduleInfos) { const relativePath = path.relative(moduleInfo.moduleRootPath, file); if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) { @@ -764,7 +810,6 @@ export abstract class BaseMode { protected generateModuleInfos(): void { this.collectModuleInfos(); this.generateArkTSConfigForModules(); - this.generatedependencyFileMap(); this.collectCompileFiles(); this.saveHashCache(); } @@ -806,6 +851,8 @@ export abstract class BaseMode { this.logger.printErrorAndExit(logData); } } + + this.mergeAbcFiles(); } // -- runParallell code begins -- @@ -881,7 +928,8 @@ export abstract class BaseMode { public async runParallel(): Promise { this.generateModuleInfos(); - if (!cluster.isPrimary) { + const isPrimary = cluster.isPrimary ?? cluster.isMaster; // Adapt to node-v14 + if (!isPrimary) { return; } @@ -907,7 +955,8 @@ export abstract class BaseMode { this.generateModuleInfos(); this.generateArkTSConfigForModules(); - if (!cluster.isPrimary) { + const isPrimary = cluster.isPrimary ?? cluster.isMaster; + if (!isPrimary) { return; } @@ -1023,8 +1072,8 @@ export abstract class BaseMode { if (clearExitListeners) { cluster.removeAllListeners('exit'); } - - cluster.setupPrimary({ + const setupFn = cluster.setupPrimary ?? cluster.setupMaster; // Adapt to node-v14 + setupFn({ exec: execPath, execArgv: execArgs, }); @@ -1513,4 +1562,4 @@ function createHash(str: string): string { // -- runConcurrent code ends -- -let finishedJob: string[] = []; \ No newline at end of file +let finishedJob: string[] = []; diff --git a/ets2panda/driver/build_system/src/build/declgen_worker.ts b/ets2panda/driver/build_system/src/build/declgen_worker.ts index 872eb49db1761b085a6db34df3b4e6f48249a49f..e25cdff91d5cae4ea0c394572c7d12827aaf852c 100644 --- a/ets2panda/driver/build_system/src/build/declgen_worker.ts +++ b/ets2panda/driver/build_system/src/build/declgen_worker.ts @@ -18,11 +18,19 @@ import { BuildConfig } from '../types'; import { Logger } from '../logger'; import * as fs from 'fs'; import * as path from 'path'; -import { changeFileExtension, ensurePathExists } from '../utils'; -import { - DECL_ETS_SUFFIX, - TS_SUFFIX, - KOALA_WRAPPER_PATH_FROM_SDK +import { + changeDeclgenFileExtension, + changeFileExtension, + createFileIfNotExists, + ensurePathExists +} from '../utils'; +import { + DECL_ETS_SUFFIX, + DECL_TS_SUFFIX, + KOALA_WRAPPER_PATH_FROM_SDK, + STATIC_RECORD_FILE, + STATIC_RECORD_FILE_CONTENT, + TS_SUFFIX } from '../pre_define'; import { PluginDriver, PluginHook } from '../plugins/plugins_driver'; @@ -56,17 +64,29 @@ process.on('message', (message: { moduleInfo.packageName, filePathFromModuleRoot ); - declEtsOutputPath = changeFileExtension(declEtsOutputPath, DECL_ETS_SUFFIX); + declEtsOutputPath = changeDeclgenFileExtension(declEtsOutputPath, DECL_ETS_SUFFIX); let etsOutputPath: string = path.join( moduleInfo.declgenBridgeCodePath as string, moduleInfo.packageName, filePathFromModuleRoot ); - etsOutputPath = changeFileExtension(etsOutputPath, TS_SUFFIX); + etsOutputPath = changeDeclgenFileExtension(etsOutputPath, TS_SUFFIX); ensurePathExists(declEtsOutputPath); ensurePathExists(etsOutputPath); + const staticRecordPath = path.join( + moduleInfo.declgenV1OutPath as string, + STATIC_RECORD_FILE + ) + const declEtsOutputDir = path.dirname(declEtsOutputPath); + const staticRecordRelativePath = changeFileExtension( + path.relative(declEtsOutputDir, staticRecordPath).replaceAll(/\\/g, '\/'), + "", + DECL_TS_SUFFIX + ); + createFileIfNotExists(staticRecordPath, STATIC_RECORD_FILE_CONTENT); + arktsGlobal.filePath = fileInfo.filePath; arktsGlobal.config = arkts.Config.create([ '_', @@ -76,16 +96,17 @@ process.on('message', (message: { fileInfo.arktsConfigFile, fileInfo.filePath ]).peer; - arktsGlobal.compilerContext = arkts.Context.createFromString(source); + arktsGlobal.compilerContext = arkts.Context.createFromStringWithHistory(source); pluginDriver.getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + const skipDeclCheck = buildConfig?.skipDeclCheck as boolean ?? true; - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, skipDeclCheck); let ast = arkts.EtsScript.fromContext(); pluginDriver.getPluginContext().setArkTSAst(ast); pluginDriver.runPluginHook(PluginHook.PARSED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, skipDeclCheck); ast = arkts.EtsScript.fromContext(); pluginDriver.getPluginContext().setArkTSAst(ast); @@ -95,7 +116,8 @@ process.on('message', (message: { declEtsOutputPath, etsOutputPath, false, - false + false, + staticRecordRelativePath ); // Generate 1.0 declaration files & 1.0 glue code logger.printInfo('declaration files generated'); diff --git a/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts b/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts index e61ae1794740e00586aa532f26259252a44aa655..c07e8c3afd06176736b6fe7605228e7304502d46 100644 --- a/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts +++ b/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts @@ -29,33 +29,103 @@ import { ensurePathExists, getInteropFilePathByApi, getOhmurlByApi, + hasEntry, isSubPathOf, safeRealpath, toUnixPath } from '../utils'; import { AliasConfig, + ArkTSConfigObject, BuildConfig, DependencyItem, DynamicFileContext, ModuleInfo, } from '../types'; import { + COMPONENT, + DYNAMIC_PREFIX, + KITS, LANGUAGE_VERSION, SYSTEM_SDK_PATH_FROM_SDK, sdkConfigPrefix, } from '../pre_define'; -interface ArkTSConfigObject { - compilerOptions: { - package: string, - baseUrl: string, - paths: Record; - entry?: string; - dependencies: Record; - useEmptyPackage?: boolean; +export class ArkTSConfig { + config: ArkTSConfigObject; + + constructor(moduleInfo: ModuleInfo) { + this.config = { + compilerOptions: { + package: moduleInfo.packageName, + baseUrl: path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0]), + paths: {}, + dependencies: {} + } + }; + } + + addPathMappings(mappings: Record): void { + const paths = this.config.compilerOptions.paths; + for (const [key, value] of Object.entries(mappings)) { + if (!paths[key]) { + paths[key] = value; + } else { + paths[key] = [...new Set([...paths[key], ...value])]; + } + } } -}; + + addDependency({ name, item }: { name: string; item: DependencyItem }): void { + const deps = this.config.compilerOptions.dependencies; + const existing = deps[name]; + + if (existing) { + const mergedAlias = Array.from(new Set([...(existing.alias ?? []), ...(item.alias ?? [])])); + deps[name] = { + ...existing, + ...item, + alias: mergedAlias + }; + } else { + deps[name] = item; + } + } + + addDependencies(deps: Record): void { + Object.entries(deps).forEach(([name, item]) => { + this.addDependency({ name, item }); + }); + } + + getCompilerOptions(): ArkTSConfigObject { + return this.config; + } + + getPackageName(): string { + return this.config.compilerOptions.package; + } + + getDependencies(): Record { + return this.config.compilerOptions.dependencies; + } + + getPathSection(): Record { + return this.config.compilerOptions.paths; + } + + setUseEmptyPackage(value: boolean = false): void { + this.config.compilerOptions.useEmptyPackage = value; + } + + mergeArktsConfig(source: ArkTSConfig | undefined): void { + if (!source) { + return; + } + this.addDependencies(source.getDependencies()); + this.addPathMappings(source.getPathSection()); + } +} export class ArkTSConfigGenerator { private static instance: ArkTSConfigGenerator | undefined; @@ -65,11 +135,14 @@ export class ArkTSConfigGenerator { private externalApiPaths: string[]; private moduleInfos: Map; - private pathSection: Record; + private buildConfig: BuildConfig; private logger: Logger; private aliasConfig: Map>; private dynamicSDKPaths: Set; + private systemPathSection: Record; + private systemDependenciesSection: Record; + private arktsconfigs: Map; private constructor(buildConfig: BuildConfig, moduleInfos: Map) { this.logger = Logger.getInstance(); @@ -80,11 +153,17 @@ export class ArkTSConfigGenerator { this.stdlibEscompatPath = path.resolve(realPandaStdlibPath, 'escompat'); this.systemSdkPath = path.resolve(realBuildSdkPath, SYSTEM_SDK_PATH_FROM_SDK); this.externalApiPaths = buildConfig.externalApiPaths; + this.buildConfig = buildConfig; this.moduleInfos = moduleInfos; - this.pathSection = {}; this.aliasConfig = buildConfig.aliasConfig; this.dynamicSDKPaths = buildConfig.interopSDKPaths; + + this.systemPathSection = {} + this.systemDependenciesSection = {}; + this.arktsconfigs = new Map(); + + this.initPathInfo(); } public static getInstance(buildConfig?: BuildConfig, moduleInfos?: Map): ArkTSConfigGenerator { @@ -101,7 +180,6 @@ export class ArkTSConfigGenerator { public static destroyInstance(): void { ArkTSConfigGenerator.instance = undefined; } - private generateSystemSdkPathSection(pathSection: Record): void { function traverse(currentDir: string, relativePath: string = '', isExcludedDir: boolean = false, allowedExtensions: string[] = ['.d.ets']): void { const items = fs.readdirSync(currentDir); @@ -145,60 +223,38 @@ export class ArkTSConfigGenerator { let kitsPath: string = path.resolve(this.systemSdkPath, 'kits'); fs.existsSync(kitsPath) ? traverse(kitsPath) : this.logger.printWarn(`sdk path ${kitsPath} not exist.`); } + pathSection.std = [this.stdlibStdPath]; + pathSection.escompat = [this.stdlibEscompatPath]; } - private getPathSection(moduleInfo: ModuleInfo): Record { - if (Object.keys(this.pathSection).length !== 0) { - return this.pathSection; - } - - this.pathSection.std = [this.stdlibStdPath]; - this.pathSection.escompat = [this.stdlibEscompatPath]; + private getPathSection(moduleInfo: ModuleInfo, arktsconfig: ArkTSConfig): void { + arktsconfig.addPathMappings(this.systemPathSection); - this.generateSystemSdkPathSection(this.pathSection); - - this.moduleInfos.forEach((moduleInfo: ModuleInfo, packageName: string) => { - if (moduleInfo.language !== LANGUAGE_VERSION.ARKTS_1_2 && moduleInfo.language !== LANGUAGE_VERSION.ARKTS_HYBRID) { - return; - } - if (!moduleInfo.entryFile) { - return; - } - this.handleEntryFile(moduleInfo); - }); - return this.pathSection; - } + if (moduleInfo.language === LANGUAGE_VERSION.ARKTS_HYBRID) { + this.getAllFilesToPathSection(moduleInfo, arktsconfig); + } - private handleEntryFile(moduleInfo: ModuleInfo): void { - try { - const stat = fs.statSync(moduleInfo.entryFile); - if (!stat.isFile()) { - return; - } - const entryFilePath = moduleInfo.entryFile; - const firstLine = fs.readFileSync(entryFilePath, 'utf-8').split('\n')[0]; - // If the file is an ArkTS 1.2 implementation, configure the path in pathSection. - if (moduleInfo.language === LANGUAGE_VERSION.ARKTS_1_2 || moduleInfo.language === LANGUAGE_VERSION.ARKTS_HYBRID && firstLine.includes('use static')) { - this.pathSection[moduleInfo.packageName] = [ - path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0]) - ]; - } - } catch (error) { - const logData: LogData = LogDataFactory.newInstance( - ErrorCode.BUILDSYSTEM_HANDLE_ENTRY_FILE, - `Error handle entry file for module ${moduleInfo.packageName}` - ); - this.logger.printError(logData); + if (!hasEntry(moduleInfo)) { + return; + } + + if (moduleInfo.language === LANGUAGE_VERSION.ARKTS_1_1) { + return; } + + arktsconfig.addPathMappings({ + [moduleInfo.packageName]: [moduleInfo.moduleRootPath] + }); } - + + private getOhmurl(file: string, moduleInfo: ModuleInfo): string { let unixFilePath: string = file.replace(/\\/g, '/'); let ohmurl: string = moduleInfo.packageName + '/' + unixFilePath; return changeFileExtension(ohmurl, ''); } - private getDependenciesSection(moduleInfo: ModuleInfo, dependenciesection: Record): void { + private getDependenciesSection(moduleInfo: ModuleInfo, arktsconfig: ArkTSConfig): void { let depModules: Map = moduleInfo.dynamicDepModuleInfos; depModules.forEach((depModuleInfo: ModuleInfo) => { @@ -207,28 +263,40 @@ export class ArkTSConfigGenerator { decl file not found on path ${depModuleInfo.declFilesPath}`); return; } - let declFilesObject = JSON.parse(fs.readFileSync(depModuleInfo.declFilesPath, 'utf-8')); - Object.keys(declFilesObject.files).forEach((file: string) => { - let ohmurl: string = this.getOhmurl(file, depModuleInfo); - dependenciesection[ohmurl] = { + + const declFilesObject = JSON.parse(fs.readFileSync(depModuleInfo.declFilesPath, 'utf-8')); + const files = declFilesObject.files; + + Object.keys(files).forEach((file: string) => { + const ohmurl: string = this.getOhmurl(file, depModuleInfo); + const depItem: DependencyItem = { language: 'js', - path: declFilesObject.files[file].declPath, - ohmUrl: declFilesObject.files[file].ohmUrl + path: files[file].declPath, + ohmUrl: files[file].ohmUrl }; - let absFilePath: string = path.resolve(depModuleInfo.moduleRootPath, file); - let entryFileWithoutExtension: string = changeFileExtension(depModuleInfo.entryFile, ''); + arktsconfig.addDependency({ + name: ohmurl, + item: depItem + }); + + const absFilePath: string = path.resolve(depModuleInfo.moduleRootPath, file); + const entryFileWithoutExtension: string = changeFileExtension(depModuleInfo.entryFile, ''); + if (absFilePath === entryFileWithoutExtension) { - dependenciesection[depModuleInfo.packageName] = dependenciesection[ohmurl]; + arktsconfig.addDependency({ + name: depModuleInfo.packageName, + item: depItem + }); } }); }); + arktsconfig.addDependencies(this.systemDependenciesSection); } - public writeArkTSConfigFile( + public generateArkTSConfigFile( moduleInfo: ModuleInfo, - enableDeclgenEts2Ts: boolean, - buildConfig: BuildConfig + enableDeclgenEts2Ts: boolean ): void { if (!moduleInfo.sourceRoots || moduleInfo.sourceRoots.length === 0) { const logData: LogData = LogDataFactory.newInstance( @@ -237,70 +305,34 @@ export class ArkTSConfigGenerator { ); this.logger.printErrorAndExit(logData); } - let pathSection = this.getPathSection(moduleInfo); + let arktsConfig: ArkTSConfig = new ArkTSConfig(moduleInfo); + this.arktsconfigs.set(moduleInfo.packageName, arktsConfig); + this.getPathSection(moduleInfo, arktsConfig); - this.getAllFilesToPathSectionForHybrid(moduleInfo, buildConfig); - let dependenciesection: Record = {}; if (!enableDeclgenEts2Ts) { - this.getDependenciesSection(moduleInfo, dependenciesection); - } - this.processAlias(moduleInfo, dependenciesection); - let baseUrl: string = path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0]); - if (buildConfig.paths) { - Object.entries(buildConfig.paths).map(([key, value]) => { - pathSection[key] = value - }); + this.getDependenciesSection(moduleInfo, arktsConfig); } - let arktsConfig: ArkTSConfigObject = { - compilerOptions: { - package: moduleInfo.packageName, - baseUrl: baseUrl, - paths: pathSection, - entry: moduleInfo.entryFile, - dependencies: dependenciesection - } - }; - if (moduleInfo.entryFile && moduleInfo.language === LANGUAGE_VERSION.ARKTS_HYBRID) { - const entryFilePath = moduleInfo.entryFile; - const stat = fs.statSync(entryFilePath); - if (fs.existsSync(entryFilePath) && stat.isFile()) { - const firstLine = fs.readFileSync(entryFilePath, 'utf-8').split('\n')[0]; - // If the entryFile is not an ArkTS 1.2 implementation, remove the entry property field. - if (!firstLine.includes('use static')) { - delete arktsConfig.compilerOptions.entry; - } - } - } + this.processAlias(arktsConfig); if (moduleInfo.frameworkMode) { - arktsConfig.compilerOptions.useEmptyPackage = moduleInfo.useEmptyPackage; + arktsConfig.setUseEmptyPackage(moduleInfo.useEmptyPackage); } ensurePathExists(moduleInfo.arktsConfigFile); - fs.writeFileSync(moduleInfo.arktsConfigFile, JSON.stringify(arktsConfig, null, 2), 'utf-8'); } - private processAlias(moduleInfo: ModuleInfo, dependencySection: Record): void { - this.dynamicSDKPaths.forEach(basePath => { - if (fs.existsSync(basePath)) { - this.traverseDependencies(basePath, '', false, dependencySection); - this.traverseDependencies(basePath, '', false, dependencySection,'dynamic/'); - } else { - this.logger.printWarn(`sdk path ${basePath} not exist.`); - } - }); - - const aliasForPkg: Map | undefined = this.aliasConfig?.get(moduleInfo.packageName); + private processAlias(arktsconfigs: ArkTSConfig): void { + const aliasForPkg: Map | undefined = this.aliasConfig?.get(arktsconfigs.getPackageName()); aliasForPkg?.forEach((aliasConfig, aliasName) => { - if(aliasConfig.isStatic){ + if (aliasConfig.isStatic) { return; } if (aliasConfig.originalAPIName.startsWith('@kit')) { - this.processStaticAlias(aliasName, aliasConfig); - }else{ - this.processDynamicAlias(aliasName, aliasConfig,dependencySection); + this.processStaticAlias(aliasName, aliasConfig, arktsconfigs); + } else { + this.processDynamicAlias(aliasName, aliasConfig, arktsconfigs); } }); } @@ -314,11 +346,11 @@ export class ArkTSConfigGenerator { ): void { const allowedExtensions = ['.d.ets']; const items = fs.readdirSync(currentDir); - + for (const item of items) { const itemPath = path.join(currentDir, item); const stat = fs.statSync(itemPath); - + if (stat.isFile()) { if (this.isAllowedExtension(item, allowedExtensions)) { this.processDynamicFile({ @@ -332,13 +364,13 @@ export class ArkTSConfigGenerator { } continue; } - + if (stat.isDirectory()) { const isRuntimeAPI = path.basename(currentDir) === 'arkui' && item === 'runtime-api'; const newRelativePath = isRuntimeAPI ? '' - : (relativePath ? `${relativePath}.${item}` : item); - + : (relativePath ? `${relativePath}/${item}` : item); + this.traverseDependencies( path.resolve(currentDir, item), newRelativePath, @@ -358,19 +390,19 @@ export class ArkTSConfigGenerator { const pattern = new RegExp(`^@(${sdkConfigPrefix})\\..+\\.d\\.ets$`, 'i'); return pattern.test(fileName); } - + private buildDynamicKey( baseName: string, relativePath: string, isExcludedDir: boolean, - prefix: string = '' + separator: string = '.' ): string { - return prefix + (isExcludedDir + return isExcludedDir ? baseName - : (relativePath ? `${relativePath}.${baseName}` : baseName) - ); + : (relativePath ? `${relativePath}${separator}${baseName}` : baseName); } + private processDynamicFile(ctx: DynamicFileContext): void { const { filePath, @@ -380,35 +412,50 @@ export class ArkTSConfigGenerator { dependencySection, prefix = '' } = ctx; - - if (!this.isValidAPIFile(fileName)) return; + let separator = '.' + if (!this.isValidAPIFile(fileName)) { + separator = '/' + } const baseName = path.basename(fileName, '.d.ets'); - const key = this.buildDynamicKey(baseName, relativePath, isExcludedDir, prefix); + const normalizedRelativePath = relativePath.replace(/\//g, separator); + const key = this.buildDynamicKey(baseName, normalizedRelativePath, isExcludedDir, separator); - dependencySection[key] = { + dependencySection[prefix + key] = { language: 'js', path: filePath, - ohmUrl: getOhmurlByApi(baseName) + ohmUrl: getOhmurlByApi(baseName), + alias: [key] }; } - - private processStaticAlias(aliasName: string, aliasConfig: AliasConfig) { - this.pathSection[aliasName] = [getInteropFilePathByApi(aliasConfig.originalAPIName, this.dynamicSDKPaths)]; + private processStaticAlias( + aliasName: string, + aliasConfig: AliasConfig, + arktsConfig: ArkTSConfig + ): void { + const declPath = getInteropFilePathByApi(aliasConfig.originalAPIName, this.dynamicSDKPaths); + if (!declPath) { + return; + } + + arktsConfig.addPathMappings({ + [aliasName]: [declPath] + }); } private processDynamicAlias( aliasName: string, aliasConfig: AliasConfig, - dependencySection: Record - ) { + arktsConfig: ArkTSConfig + ): void { const originalName = aliasConfig.originalAPIName; const declPath = getInteropFilePathByApi(originalName, this.dynamicSDKPaths); + if (declPath === '') { return; } - + if (!fs.existsSync(declPath)) { const logData: LogData = LogDataFactory.newInstance( ErrorCode.BUILDSYSTEM_INTEROP_SDK_NOT_FIND, @@ -417,43 +464,69 @@ export class ArkTSConfigGenerator { this.logger.printErrorAndExit(logData); } - const existing = dependencySection[originalName]; - - if (existing) { - existing.alias = Array.from(new Set([...(existing.alias ?? []), aliasName])); - } else { - dependencySection[originalName] = { + arktsConfig.addDependency({ + name: DYNAMIC_PREFIX + originalName, + item: { language: 'js', path: declPath, ohmUrl: getOhmurlByApi(originalName), alias: [aliasName] - }; - } + } + }); } - public getAllFilesToPathSectionForHybrid( + private getAllFilesToPathSection( moduleInfo: ModuleInfo, - buildConfig: BuildConfig + arktsConfig: ArkTSConfig ): void { - if (moduleInfo?.language !== LANGUAGE_VERSION.ARKTS_HYBRID) { - return; - } - const moduleRoot = toUnixPath(moduleInfo.moduleRootPath) + '/'; - for (const file of buildConfig.compileFiles) { + for (const file of this.buildConfig.compileFiles) { const unixFilePath = toUnixPath(file); if (!isSubPathOf(unixFilePath, moduleRoot)) { continue; } - let relativePath = unixFilePath.startsWith(moduleRoot) - ? unixFilePath.substring(moduleRoot.length) - : unixFilePath; - + let relativePath = unixFilePath.substring(moduleRoot.length); const keyWithoutExtension = relativePath.replace(/\.[^/.]+$/, ''); - this.pathSection[keyWithoutExtension] = [file]; + + const pathKey = `${moduleInfo.packageName}/${keyWithoutExtension}`; + arktsConfig.addPathMappings({ [pathKey]: [file] }); } - } + } + + private initPathInfo(): void { + this.generateSystemSdkPathSection(this.systemPathSection); + this.generateSystemSdkDependenciesSection(this.systemDependenciesSection); + if (this.buildConfig.paths) { + Object.entries(this.buildConfig.paths).map(([key, value]) => { + this.systemPathSection[key] = value + }); + } + } + + private generateSystemSdkDependenciesSection(dependenciesSection: Record): void { + this.dynamicSDKPaths.forEach(basePath => { + if(basePath.includes(KITS)){ + return; + } + if (!fs.existsSync(basePath)) { + const logData: LogData = LogDataFactory.newInstance( + ErrorCode.BUILDSYSTEM_ALIAS_MODULE_PATH_NOT_EXIST, + `alias module ${basePath} not exist.` + ); + this.logger.printErrorAndExit(logData); + } + if (basePath.includes(COMPONENT)) { + this.traverseDependencies(basePath, '', false, dependenciesSection, 'component/'); + } else { + this.traverseDependencies(basePath, '', false, dependenciesSection, DYNAMIC_PREFIX); + } + }); + } + + public getArktsConfigPackageName(packageName: string): ArkTSConfig | undefined { + return this.arktsconfigs.get(packageName); + } } diff --git a/ets2panda/driver/build_system/src/error_code.ts b/ets2panda/driver/build_system/src/error_code.ts index 85cb2ea42e2e11ee32316cf7d63141b0b3e85fcd..5301aeff7866e7c5cc14e81e1d0425dcc8f64407 100644 --- a/ets2panda/driver/build_system/src/error_code.ts +++ b/ets2panda/driver/build_system/src/error_code.ts @@ -41,5 +41,7 @@ export enum ErrorCode { BUILDSYSTEM_INTEROP_SDK_NOT_FIND = '11410020', BUILDSYSTEM_INIT_ALIAS_CONFIG_FAILED = '11410021', BUILDSYSTEM_PLUGIN_ALIAS_CONFIG_PARSING_FAIL = '11410022', - BUILDSYSTEM_ABC_FILE_NOT_EXIST_IN_BCHAR = '11410023' + BUILDSYSTEM_ABC_FILE_NOT_EXIST_IN_BCHAR = '11410023', + BUILDSYSTEM_ALIAS_MODULE_PATH_NOT_EXIST = '11410024', + BUILDSYSTEM_ENTRY_FILE_NOT_EXIST = "11410025" } diff --git a/ets2panda/driver/build_system/src/init/process_build_config.ts b/ets2panda/driver/build_system/src/init/process_build_config.ts index 9a98a3fd0029d7f5c53defcc6486b7027ab05fc7..769b18939ec00ac69c96c6c20aa454133bbc6bfe 100644 --- a/ets2panda/driver/build_system/src/init/process_build_config.ts +++ b/ets2panda/driver/build_system/src/init/process_build_config.ts @@ -23,6 +23,10 @@ import { } from '../utils'; import { PluginDriver } from '../plugins/plugins_driver'; import { + API, + ARKTS, + COMPONENT, + KITS, KOALA_WRAPPER_PATH_FROM_SDK, PANDA_SDK_PATH_FROM_SDK, PROJECT_BUILD_CONFIG_FILE @@ -103,7 +107,7 @@ function initPlatformSpecificConfig(buildConfig: BuildConfig): void { buildConfig.dependencyAnalyzerPath = path.join(pandaSdkPath, 'bin', 'dependency_analyzer'); } - if (!fs.existsSync(buildConfig.abcLinkerPath as string)) { + if (!buildConfig.enableDeclgenEts2Ts && !fs.existsSync(buildConfig.abcLinkerPath as string)) { const logData: LogData = LogDataFactory.newInstance( ErrorCode.BUILDSYSTEM_ARK_LINK_NOT_FOUND_FAIL, 'Ark_link not found in path.', @@ -113,7 +117,7 @@ function initPlatformSpecificConfig(buildConfig: BuildConfig): void { logger.printError(logData); } - if (!buildConfig.frameworkMode && !fs.existsSync(buildConfig.dependencyAnalyzerPath as string)) { + if (!buildConfig.frameworkMode && !buildConfig.enableDeclgenEts2Ts && !fs.existsSync(buildConfig.dependencyAnalyzerPath as string)) { const logData: LogData = LogDataFactory.newInstance( ErrorCode.BUILDSYSTEM_Dependency_Analyzer_NOT_FOUND_FAIL, 'Dependency_analyzer not found in path.', @@ -190,9 +194,28 @@ function initInteropSDKInfo(buildConfig: BuildConfig): void { : [path.resolve(buildConfig.buildSdkPath as string, "../ets1.1/build-tools/interop")]; for (const basePath of basePaths) { - const arktsPath = path.resolve(basePath, 'arkts'); - const apiPath = path.resolve(basePath, 'api'); - const kitsPath = path.resolve(basePath, 'kits'); + /** + * dynamic public api from 1.1 + */ + const arktsPath = path.resolve(basePath, ARKTS); + /** + * dynamic public api from 1.1 + */ + const apiPath = path.resolve(basePath, API); + /** + * a router file from 1.1, whicl will export * from manay api file + * and kit have not runtime_name,is alias for edit, + * and will be transformed before compile in 1.1 + */ + const kitsPath = path.resolve(basePath, KITS); + /** + * component is inner api for apiPath and artsPath + * bcs apiPath and artsPath is dynamic module, + * apiPath will depend component, we should also add component to dependenciesection, + * or it will fatal error + */ + const component = path.resolve(basePath, COMPONENT); + if (fs.existsSync(arktsPath)) { buildConfig.interopSDKPaths.add(arktsPath); @@ -203,6 +226,8 @@ function initInteropSDKInfo(buildConfig: BuildConfig): void { if (fs.existsSync(kitsPath)) { buildConfig.interopSDKPaths.add(kitsPath); } + if (fs.existsSync(component)) { + buildConfig.interopSDKPaths.add(component); + } } } - diff --git a/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts b/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts index 6d6f19b6af8ff9860e10d338a9731e558e686d82..e919acab331465870dd355c9484e8d09b3c9dc1f 100644 --- a/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts +++ b/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts @@ -22,7 +22,7 @@ import { LogDataFactory } from '../logger'; import { ErrorCode } from '../error_code'; -import { KIT_CONFIGS_PATH_FROM_SDK } from '../pre_define'; +import { DYNAMIC_PREFIX, KIT_CONFIGS_PATH_FROM_SDK } from '../pre_define'; export class KitImportTransformer { @@ -127,7 +127,7 @@ export class KitImportTransformer { continue; } - const sourcePath = 'default' + symbolEntry.source.replace(/\.d\.ts$/, ''); + const sourcePath = DYNAMIC_PREFIX + symbolEntry.source.replace(/\.d\.ts$/, ''); if (!grouped.has(sourcePath)) { grouped.set(sourcePath, []); } diff --git a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts index 67203f601dcc973398d5469c3ae58a5e26159fc7..9213df98d63bc2e8fc9a040064d974c048dd9902 100644 --- a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts +++ b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts @@ -21,6 +21,8 @@ import { import { BuildConfig } from '../types'; import { ErrorCode } from '../error_code'; import { FileManager } from './FileManager'; +import path from 'path' +import { MEMO_PLUGIN_PATH_FROM_SDK, UI_PLUGIN_PATH_FROM_SDK } from '../pre_define'; export enum PluginHook { NEW = 'afterNew', @@ -149,11 +151,28 @@ export class PluginDriver { PluginDriver.instance = undefined; } + private initKoalaPlugins(projectConfig: BuildConfig): void { + + const uiPluginPath = path.resolve(projectConfig.buildSdkPath, UI_PLUGIN_PATH_FROM_SDK); + const memoPluginPath = path.resolve(projectConfig.buildSdkPath, MEMO_PLUGIN_PATH_FROM_SDK); + + // TODO: need change in hvigor + if (process.env.USE_KOALA_UI_PLUGIN) { + projectConfig.plugins['ArkUI'] = uiPluginPath + } + + if (process.env.USE_KOALA_MEMO_PLUGIN) { + projectConfig.plugins['ArkUI-Memo'] = memoPluginPath + } + } + public initPlugins(projectConfig: BuildConfig): void { if (!projectConfig || !projectConfig.plugins) { return; } + this.initKoalaPlugins(projectConfig) + const pluginResults: RawPlugins[] = Object.entries(projectConfig.plugins).map(([key, value]) => { try { let pluginObject = require(value as string); diff --git a/ets2panda/driver/build_system/src/pre_define.ts b/ets2panda/driver/build_system/src/pre_define.ts index 3879de18ee97353a583f08448cd97cf22a7f0c05..10a3dc54191d25c2133bc76de730e01c03a599f8 100644 --- a/ets2panda/driver/build_system/src/pre_define.ts +++ b/ets2panda/driver/build_system/src/pre_define.ts @@ -14,13 +14,16 @@ */ export const ARKTSCONFIG_JSON_FILE: string = 'arktsconfig.json'; +export const MERGED_INTERMEDIATE_FILE: string = 'modules_intermediate.abc'; export const MERGED_ABC_FILE: string = 'modules_static.abc'; export const LINKER_INPUT_FILE: string = 'fileInfo.txt'; export const DEPENDENCY_INPUT_FILE: string = 'dependencyFileInfo.txt'; export const DEPENDENCY_JSON_FILE: string = 'dependency.json'; export const PROJECT_BUILD_CONFIG_FILE: string = 'projectionConfig.json'; +export const STATIC_RECORD_FILE: string = 'static.Record.d.ts'; export const DECL_ETS_SUFFIX: string = '.d.ets'; +export const DECL_TS_SUFFIX: string = '.d.ts'; export const ETS_SUFFIX: string = '.ets'; export const TS_SUFFIX: string = '.ts'; export const ABC_SUFFIX: string = '.abc'; @@ -33,7 +36,6 @@ export enum LANGUAGE_VERSION { export const PANDA_SDK_PATH_FROM_SDK: string = './build-tools/ets2panda'; export const SYSTEM_SDK_PATH_FROM_SDK: string = './'; -export const KOALA_WRAPPER_PATH_FROM_SDK: string = './build-tools/koala-wrapper/build/lib/es2panda'; export const KIT_CONFIGS_PATH_FROM_SDK: string = '../ets1.1/build-tools/ets-loader/kit_configs'; export const DEFAULT_WOKER_NUMS: number = 4; @@ -46,3 +48,20 @@ export const NATIVE_MODULE: Set = new Set( ['system.app', 'ohos.app', 'system.router', 'system.curves', 'ohos.curves', 'system.matrix4', 'ohos.matrix4']); export const ARKTS_MODULE_NAME: string = 'arkts'; + +export const KITS: string = 'kit'; +export const API: string = 'api'; +export const ARKTS:string = 'arkts'; +export const COMPONENT:string = 'component'; + +export const DYNAMIC_PREFIX:string = 'dynamic/'; + +export const STATIC_RECORD_FILE_CONTENT: string = `// generated for static Record +export type Record = { + [P in K]: T; +}; +`; +// Koala experimental variables +export const KOALA_WRAPPER_PATH_FROM_SDK: string = process.env.USE_KOALA_LIBARKTS ? './build-tools/ui2abc/libarkts/lib/libarkts.js' : './build-tools/koala-wrapper/build/lib/es2panda' +export const UI_PLUGIN_PATH_FROM_SDK: string = './build-tools/ui2abc/ui-plugin/lib/entry.js' +export const MEMO_PLUGIN_PATH_FROM_SDK: string = './build-tools/ui2abc/memo-plugin/lib/entry.js' diff --git a/ets2panda/driver/build_system/src/types.ts b/ets2panda/driver/build_system/src/types.ts index 6e69ccd0b1f5170b17febdc27bf98081e4aeb6ca..fc080bb5021d8e396395ec6fbbd282e5eac14445 100644 --- a/ets2panda/driver/build_system/src/types.ts +++ b/ets2panda/driver/build_system/src/types.ts @@ -74,6 +74,7 @@ export interface ArkTS { }; Context: { createFromString: Function; + createFromStringWithHistory: Function; }; EtsScript: { fromContext: Function; @@ -164,6 +165,7 @@ export interface DeclgenConfig { declgenV1OutPath?: string; declgenV2OutPath?: string; declgenBridgeCodePath?: string; + skipDeclCheck?: boolean; } export interface LoggerConfig { @@ -226,6 +228,9 @@ export interface ModuleInfo { frameworkMode?: boolean; useEmptyPackage?: boolean; byteCodeHar: boolean; + //for topological order merging + dependenciesSet:Set; + dependentSet:Set; } export type SetupClusterOptions = { @@ -312,4 +317,14 @@ export interface DependencyItem { path: string, ohmUrl: string, alias?:string[] -} \ No newline at end of file +} + +export interface ArkTSConfigObject { + compilerOptions: { + package: string, + baseUrl: string, + paths: Record; + dependencies: Record; + useEmptyPackage?: boolean; + } +}; diff --git a/ets2panda/driver/build_system/src/utils.ts b/ets2panda/driver/build_system/src/utils.ts index b87c6c462a6b77b92bb662fda5c4478bbf38f7ae..e3a7a2bc37bded3628572266173df97059b5cb17 100644 --- a/ets2panda/driver/build_system/src/utils.ts +++ b/ets2panda/driver/build_system/src/utils.ts @@ -30,6 +30,7 @@ import { LogDataFactory } from './logger'; import { ErrorCode } from './error_code'; +import { ModuleInfo, OHOS_MODULE_TYPE } from './types'; const WINDOWS: string = 'Windows_NT'; const LINUX: string = 'Linux'; @@ -48,7 +49,7 @@ export function isMac(): boolean { } export function changeFileExtension(file: string, targetExt: string, originExt = ''): string { - let currentExt = originExt.length === 0 ? path.extname(file) : originExt; + let currentExt = originExt.length === 0 ? getFileExtension(file) : originExt; let fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt)); return fileWithoutExt + targetExt; } @@ -148,3 +149,55 @@ export function isSubPathOf(targetPath: string, parentDir: string): boolean { const resolvedTarget = toUnixPath(path.resolve(targetPath)); return resolvedTarget === resolvedParent || resolvedTarget.startsWith(resolvedParent + '/'); } + +/** + * Get the full extension of a file, supporting composite extensions like '.d.ts', '.test.ts', '.d.ets', etc. + * @param filePath - File path or file name. + * @param knownCompositeExts - Optional list of known composite extensions to match against. + * @returns The full extension (e.g., '.d.ts'). Returns an empty string if no extension is found. + */ +export function getFileExtension( + filePath: string, + knownCompositeExts: string[] = ['.d.ts', '.test.ts', '.d.ets'] +): string { + const baseName = path.basename(filePath); + + // Match known composite extensions first + for (const ext of knownCompositeExts) { + if (baseName.endsWith(ext)) { + return ext; + } + } + + // Fallback to default behavior: return the last segment after the final dot + return path.extname(baseName); +} + +export function hasEntry(moduleInfo: ModuleInfo): boolean { + switch (moduleInfo.moduleType) { + case OHOS_MODULE_TYPE.SHARED: + case OHOS_MODULE_TYPE.HAR: + return true; + default: + return false; + } +} + +export function createFileIfNotExists(filePath: string, content: string): boolean { + try { + const normalizedPath = path.normalize(filePath); + if (fs.existsSync(normalizedPath)) { + return false; + } + + const dir = path.dirname(normalizedPath); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } + + fs.writeFileSync(normalizedPath, content, { encoding: 'utf-8' }); + return true; + } catch (error) { + return false; + } +} diff --git a/ets2panda/driver/dependency_analyzer/BUILD.gn b/ets2panda/driver/dependency_analyzer/BUILD.gn index 7adcfb1a6f565278fc786f55e57e84c7e7f4b833..0dedd66e582f20dc7cdbef64e224e50068f2b4fd 100644 --- a/ets2panda/driver/dependency_analyzer/BUILD.gn +++ b/ets2panda/driver/dependency_analyzer/BUILD.gn @@ -11,8 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") import("//build/ohos.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} ohos_executable("dependency_analyzer") { sources = [ @@ -20,16 +26,16 @@ ohos_executable("dependency_analyzer") { "main.cpp", ] - configs = [ - "$ark_root:ark_config", - "$ark_root/assembler:arkassembler_public_config", - "$ark_es2panda_root:libes2panda_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/bytecode_optimizer:bytecodeopt_public_config", - "$ark_root/compiler:arkcompiler_public_config", - "$ark_root/runtime:arkruntime_public_config", - ] + include_dirs = [ "$target_gen_dir" ] + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } + configs += [ "$ark_es2panda_root:libes2panda_public_config" ] deps = [ "$ark_es2panda_root:libes2panda_frontend_static", @@ -40,19 +46,23 @@ ohos_executable("dependency_analyzer") { deps += [ "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", "$ark_root/libpandabase:libarktsbase_package", - "$ark_root/libpandafile:libarktsfile_package", + "$ark_root/libarkfile:libarktsfile_package", ] } external_deps = [ + "runtime_core:assembler_headers", "runtime_core:libarktsassembler_package", "runtime_core:libarktsbase_package", "runtime_core:libarktsbytecodeopt_package", "runtime_core:libarktscompiler_package", "runtime_core:libarktsfile_package", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", sdk_libc_secshared_dep, ] + use_exceptions = true libs = platform_libs ldflags = platform_ldflags if (is_linux) { diff --git a/ets2panda/driver/dependency_analyzer/CMakeLists.txt b/ets2panda/driver/dependency_analyzer/CMakeLists.txt index 7801000201eee1982045bcaa89eb79ee4ab287b0..9a5380dd87a1bf96fbee1d80963793e378721a11 100644 --- a/ets2panda/driver/dependency_analyzer/CMakeLists.txt +++ b/ets2panda/driver/dependency_analyzer/CMakeLists.txt @@ -11,6 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") + set(DEP_ANALYZER_SRC dep_analyzer.cpp ) @@ -39,4 +41,4 @@ panda_target_compile_options(dependency_analyzer PRIVATE -Werror=shadow ) -panda_add_sanitizers(TARGET dependency_analyzer SANITIZERS ${PANDA_SANITIZERS_LIST}) \ No newline at end of file +panda_add_sanitizers(TARGET dependency_analyzer SANITIZERS ${PANDA_SANITIZERS_LIST}) diff --git a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp index e1101e2b0037ff38a6ab9cb79ec45a030dfd40cd..df3118e7b677a4a5fbbbc15407c44cd653c433e7 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp @@ -18,9 +18,9 @@ #include "checker/ETSchecker.h" #include "ir/statements/classDeclaration.h" #include "ir/expressions/identifier.h" -#include "libpandafile/class_data_accessor-inl.h" -#include "libpandafile/file-inl.h" -#include "libpandafile/method_data_accessor.h" +#include "libarkfile/class_data_accessor-inl.h" +#include "libarkfile/file-inl.h" +#include "libarkfile/method_data_accessor.h" #include "evaluate/helpers.h" #include "evaluate/debugInfoDeserialization/methodBuilder.h" diff --git a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp index a84486f5f567b7e080eeafcdeab88898375dce46..d9bfbbee6f9c2b2b9ed133b9b3ce1882845097c5 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp @@ -29,8 +29,8 @@ #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" -#include "libpandafile/class_data_accessor-inl.h" -#include "libpandafile/file-inl.h" +#include "libarkfile/class_data_accessor-inl.h" +#include "libarkfile/file-inl.h" namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h index fe5e9ac7d38d534a0d016ac881f0e619639ff43e..d2035a6d6d79c436158534a2b841586dd77cda8d 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h +++ b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h @@ -17,8 +17,8 @@ #define ES2PANDA_EVALUATE_DEBUG_INFO_DESERIALIZER_H #include "libpandabase/utils/arena_containers.h" -#include "libpandafile/debug_info_extractor.h" -#include "libpandafile/file.h" +#include "libarkfile/debug_info_extractor.h" +#include "libarkfile/file.h" namespace ark::es2panda::varbinder { class Variable; diff --git a/ets2panda/evaluate/debugInfoDeserialization/inheritanceResolution.cpp b/ets2panda/evaluate/debugInfoDeserialization/inheritanceResolution.cpp index 1e82b52cc2d5e04cd93bf2e04c5290e65de23305..586bbb08f060fe3cbb19494ece3293966e7163ad 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/inheritanceResolution.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/inheritanceResolution.cpp @@ -22,8 +22,8 @@ #include "evaluate/proxyProgramsCache.h" #include "evaluate/entityDeclarator-inl.h" -#include "libpandafile/class_data_accessor.h" -#include "libpandafile/file-inl.h" +#include "libarkfile/class_data_accessor.h" +#include "libarkfile/file-inl.h" namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp index a2326cba1b3554b7b0424dfd1197199cc751f662..574f543e1cccbe251c0156c9992baccd3085d9d3 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp @@ -15,9 +15,9 @@ #include "evaluate/debugInfoDeserialization/methodBuilder.h" #include "checker/ETSchecker.h" -#include "libpandafile/file-inl.h" -#include "libpandafile/method_data_accessor-inl.h" -#include "libpandafile/proto_data_accessor-inl.h" +#include "libarkfile/file-inl.h" +#include "libarkfile/method_data_accessor-inl.h" +#include "libarkfile/proto_data_accessor-inl.h" #include "evaluate/helpers.h" namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/debugInfoStorage.cpp b/ets2panda/evaluate/debugInfoStorage.cpp index 20163df7651cfe096002170d3259eedeb67bb862..b1f0f03d2931f24b11ad592d6bbc2a66023966cf 100644 --- a/ets2panda/evaluate/debugInfoStorage.cpp +++ b/ets2panda/evaluate/debugInfoStorage.cpp @@ -18,8 +18,8 @@ #include "generated/signatures.h" #include "evaluate/helpers.h" -#include "libpandafile/class_data_accessor-inl.h" -#include "libpandafile/file-inl.h" +#include "libarkfile/class_data_accessor-inl.h" +#include "libarkfile/file-inl.h" namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/debugInfoStorage.h b/ets2panda/evaluate/debugInfoStorage.h index 43966dca6b0ff74b13dc79db3d14776c48b1797d..bffdd2f8cc10e1682b6ff70ea34db4009f9adc9c 100644 --- a/ets2panda/evaluate/debugInfoStorage.h +++ b/ets2panda/evaluate/debugInfoStorage.h @@ -20,9 +20,9 @@ #include "evaluate/importExportTable.h" #include "util/ustring.h" -#include "libpandafile/debug_info_extractor.h" -#include "libpandafile/file.h" -#include "libpandafile/class_data_accessor.h" +#include "libarkfile/debug_info_extractor.h" +#include "libarkfile/file.h" +#include "libarkfile/class_data_accessor.h" #include #include diff --git a/ets2panda/evaluate/evaluateContext.h b/ets2panda/evaluate/evaluateContext.h index 848719954f6edb5ae62a15d6b74a3640109257e4..3365e558e198c929f7ccbdfdff407d9c416ab78b 100644 --- a/ets2panda/evaluate/evaluateContext.h +++ b/ets2panda/evaluate/evaluateContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -20,8 +20,8 @@ #include "util/options.h" #include "libpandabase/utils/arena_containers.h" -#include "libpandafile/debug_info_extractor.h" -#include "libpandafile/file.h" +#include "libarkfile/debug_info_extractor.h" +#include "libarkfile/file.h" #include #include diff --git a/ets2panda/evaluate/helpers.cpp b/ets2panda/evaluate/helpers.cpp index e41daa9022fdf3ae4d7e28f6a1c249b8192d03af..88a631b2f782a80548f9b7e16ad7cd09951a48f8 100644 --- a/ets2panda/evaluate/helpers.cpp +++ b/ets2panda/evaluate/helpers.cpp @@ -24,8 +24,8 @@ #include "ir/typeNode.h" #include "assembler/assembly-type.h" -#include "libpandafile/field_data_accessor-inl.h" -#include "libpandafile/file-inl.h" +#include "libarkfile/field_data_accessor-inl.h" +#include "libarkfile/file-inl.h" #include #include diff --git a/ets2panda/evaluate/helpers.h b/ets2panda/evaluate/helpers.h index dd4766d19c0d7b751bbaefa2e06dc22943ab0d34..5038bcc9ac87d1dd69e2695c24ae86cff9107b1f 100644 --- a/ets2panda/evaluate/helpers.h +++ b/ets2panda/evaluate/helpers.h @@ -21,11 +21,11 @@ #include "ir/astNodeFlags.h" #include "varbinder/ETSBinder.h" -#include "libpandafile/field_data_accessor.h" -#include "libpandafile/method_data_accessor.h" -#include "libpandafile/class_data_accessor.h" -#include "libpandafile/file.h" -#include "type.h" +#include "libarkfile/field_data_accessor.h" +#include "libarkfile/method_data_accessor.h" +#include "libarkfile/class_data_accessor.h" +#include "libarkfile/file.h" +#include #include #include diff --git a/ets2panda/ir/base/catchClause.cpp b/ets2panda/ir/base/catchClause.cpp index c4c120f155080943daee24380056624657f225c6..c11433d958f4954e280b5d414698c2ff1e6ec797 100644 --- a/ets2panda/ir/base/catchClause.cpp +++ b/ets2panda/ir/base/catchClause.cpp @@ -98,11 +98,13 @@ CatchClause::CatchClause(CatchClause const &other, ArenaAllocator *allocator) : { param_ = nullptr; body_ = nullptr; - if (other.param_ != nullptr && other.param_->Clone(allocator, this) != nullptr) { - param_ = other.param_->Clone(allocator, this)->AsExpression(); + auto *const cloneParam = other.param_ != nullptr ? other.param_->Clone(allocator, this) : nullptr; + auto *const cloneBody = other.body_ != nullptr ? other.body_->Clone(allocator, this) : nullptr; + if (cloneParam != nullptr) { + param_ = cloneParam->AsExpression(); } - if (other.body_ != nullptr && other.body_->Clone(allocator, this) != nullptr) { - body_ = other.body_->Clone(allocator, this)->AsBlockStatement(); + if (cloneBody != nullptr) { + body_ = cloneBody->AsBlockStatement(); } } diff --git a/ets2panda/ir/base/classDefinition.cpp b/ets2panda/ir/base/classDefinition.cpp index 5fe57979b3febc8c29b9a88686744169729a3a5f..1c322b198478f8bf58d2d5e00a9571339c1c7a17 100644 --- a/ets2panda/ir/base/classDefinition.cpp +++ b/ets2panda/ir/base/classDefinition.cpp @@ -498,7 +498,7 @@ void ClassDefinition::CopyTo(AstNode *other) const otherImpl->functionalReferenceReferencedMethod_ = functionalReferenceReferencedMethod_; otherImpl->exportedClasses_ = exportedClasses_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } std::atomic ClassDefinition::classCounter_ = 0; diff --git a/ets2panda/ir/base/classDefinition.h b/ets2panda/ir/base/classDefinition.h index a4017bf927da2426b4bb96be4b92be999ae2c6cd..869939f869b6296f3b52f8f3a93f4b4948e0a657 100644 --- a/ets2panda/ir/base/classDefinition.h +++ b/ets2panda/ir/base/classDefinition.h @@ -23,7 +23,6 @@ #include "ir/astNode.h" #include "ir/astNodeHistory.h" #include "ir/expressions/identifier.h" -#include "ir/jsDocAllowed.h" #include "ir/statements/annotationUsage.h" #include "ir/statements/classDeclaration.h" #include "util/language.h" @@ -72,7 +71,7 @@ struct enumbitops::IsAllowedType : namespace ark::es2panda::ir { -class ClassDefinition : public JsDocAllowed> { +class ClassDefinition : public AnnotationAllowed { public: ClassDefinition() = delete; ~ClassDefinition() override = default; @@ -85,9 +84,8 @@ public: ArenaVector &&implements, MethodDefinition *ctor, Expression *superClass, ArenaVector &&body, ClassDefinitionModifiers modifiers, ModifierFlags flags, Language lang) - : JsDocAllowed>(AstNodeType::CLASS_DEFINITION, flags, - ArenaVector(body.get_allocator()), - ArenaVector(body.get_allocator())), + : AnnotationAllowed(AstNodeType::CLASS_DEFINITION, flags, + ArenaVector(body.get_allocator())), ident_(ident), typeParams_(typeParams), superTypeParams_(superTypeParams), @@ -108,7 +106,7 @@ public: // CC-OFFNXT(G.FUN.01-CPP) solid logic explicit ClassDefinition(ArenaAllocator *allocator, Identifier *ident, ArenaVector &&body, ClassDefinitionModifiers modifiers, ModifierFlags flags, Language lang) - : JsDocAllowed>(AstNodeType::CLASS_DEFINITION, flags, allocator), + : AnnotationAllowed(AstNodeType::CLASS_DEFINITION, flags, allocator), ident_(ident), implements_(allocator->Adapter()), body_(std::move(body)), @@ -125,7 +123,7 @@ public: explicit ClassDefinition(ArenaAllocator *allocator, Identifier *ident, ClassDefinitionModifiers modifiers, ModifierFlags flags, Language lang) - : JsDocAllowed>(AstNodeType::CLASS_DEFINITION, flags, allocator), + : AnnotationAllowed(AstNodeType::CLASS_DEFINITION, flags, allocator), ident_(ident), implements_(allocator->Adapter()), body_(allocator->Adapter()), @@ -144,7 +142,7 @@ public: explicit ClassDefinition(ArenaAllocator *allocator, Identifier *ident, ArenaVector &&body, ClassDefinitionModifiers modifiers, ModifierFlags flags, Language lang, AstNodeHistory *history) - : JsDocAllowed>(AstNodeType::CLASS_DEFINITION, flags, allocator), + : AnnotationAllowed(AstNodeType::CLASS_DEFINITION, flags, allocator), ident_(ident), implements_(allocator->Adapter()), body_(std::move(body)), diff --git a/ets2panda/ir/base/classProperty.cpp b/ets2panda/ir/base/classProperty.cpp index 9fb04ee7152e4bcb2738ff9d67a9544d9659118d..8ed3426475a80bc8906eaf25266d0a3e5ab0c9cc 100644 --- a/ets2panda/ir/base/classProperty.cpp +++ b/ets2panda/ir/base/classProperty.cpp @@ -216,6 +216,10 @@ bool ClassProperty::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const return true; } + if (IsPrivate()) { + return true; + } + if (!compiler::HasGlobalClassParent(this)) { return false; } @@ -339,7 +343,7 @@ void ClassProperty::CopyTo(AstNode *other) const otherImpl->isDefault_ = isDefault_; otherImpl->needInitInStaticBlock_ = needInitInStaticBlock_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/classProperty.h b/ets2panda/ir/base/classProperty.h index ebdd968dc436bf1af9e9014d3820e7987e8b2575..539c0ccdce75093c4e8ff9fadc4e21dc3eee7e1e 100644 --- a/ets2panda/ir/base/classProperty.h +++ b/ets2panda/ir/base/classProperty.h @@ -19,7 +19,6 @@ #include "ir/base/classElement.h" #include "ir/statements/annotationUsage.h" #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" namespace ark::es2panda::checker { class ETSAnalyzer; @@ -29,7 +28,7 @@ namespace ark::es2panda::ir { class Expression; class TypeNode; -class ClassProperty : public JsDocAllowed> { +class ClassProperty : public AnnotationAllowed { public: ClassProperty() = delete; ~ClassProperty() override = default; @@ -39,8 +38,7 @@ public: // CC-OFFNXT(G.FUN.01-CPP) solid logic explicit ClassProperty(Expression *const key, Expression *const value, TypeNode *const typeAnnotation, ModifierFlags const modifiers, ArenaAllocator *const allocator, bool const isComputed) - : JsDocAllowed>(AstNodeType::CLASS_PROPERTY, key, value, modifiers, allocator, - isComputed), + : AnnotationAllowed(AstNodeType::CLASS_PROPERTY, key, value, modifiers, allocator, isComputed), typeAnnotation_(typeAnnotation) { } diff --git a/ets2panda/ir/base/methodDefinition.cpp b/ets2panda/ir/base/methodDefinition.cpp index d2ac48bf3d10ca8a0ef73724832cb06667c0647e..910743501f45374198d123beff879b5620750b80 100644 --- a/ets2panda/ir/base/methodDefinition.cpp +++ b/ets2panda/ir/base/methodDefinition.cpp @@ -203,7 +203,7 @@ void MethodDefinition::DumpModifierPrefix(ir::SrcDumper *dumper) const if (IsNative()) { dumper->Add("native "); } - if (IsAsync()) { + if (IsAsync() && !dumper->IsDeclgen()) { dumper->Add("async "); } if (IsOverride()) { @@ -301,7 +301,7 @@ bool MethodDefinition::FilterForDeclGen(ir::SrcDumper *dumper) const ES2PANDA_ASSERT(Id() != nullptr); auto name = Id()->Name().Mutf8(); - if (name.find("$asyncimpl") != std::string::npos || name == compiler::Signatures::INITIALIZER_BLOCK_INIT || + if (name.find("%%async") != std::string::npos || name == compiler::Signatures::INITIALIZER_BLOCK_INIT || name == compiler::Signatures::INIT_METHOD) { return true; } @@ -318,6 +318,10 @@ bool MethodDefinition::FilterForDeclGen(ir::SrcDumper *dumper) const return true; } + if (IsPrivate()) { + return true; + } + return false; } diff --git a/ets2panda/ir/base/scriptFunction.cpp b/ets2panda/ir/base/scriptFunction.cpp index ce9683e82c892bc220fbfd130e77dd9af6141cf3..77ef01fa453dbffd84f9169cf64f98ba13eaa96a 100644 --- a/ets2panda/ir/base/scriptFunction.cpp +++ b/ets2panda/ir/base/scriptFunction.cpp @@ -110,7 +110,7 @@ void ScriptFunction::SetValueReturnStatements(ReturnStatement *returnStatements, } ScriptFunction::ScriptFunction(ArenaAllocator *allocator, ScriptFunctionData &&data) - : JsDocAllowed>(AstNodeType::SCRIPT_FUNCTION, data.flags, allocator), + : AnnotationAllowed(AstNodeType::SCRIPT_FUNCTION, data.flags, allocator), irSignature_(std::move(data.signature)), body_(data.body), funcFlags_(data.funcFlags), @@ -132,7 +132,7 @@ ScriptFunction::ScriptFunction(ArenaAllocator *allocator, ScriptFunctionData &&d } ScriptFunction::ScriptFunction(ArenaAllocator *allocator, ScriptFunctionData &&data, AstNodeHistory *history) - : JsDocAllowed>(AstNodeType::SCRIPT_FUNCTION, data.flags, allocator), + : AnnotationAllowed(AstNodeType::SCRIPT_FUNCTION, data.flags, allocator), irSignature_(std::move(data.signature)), body_(data.body), funcFlags_(data.funcFlags), @@ -185,8 +185,11 @@ ScriptFunction *ScriptFunction::Clone(ArenaAllocator *allocator, AstNode *parent for (auto *param : Params()) { params.push_back(param->Clone(allocator, nullptr)->AsExpression()); } + AnnotationUsage *clonedAnnotationUsage; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, nullptr)->AsAnnotationUsage()); + clonedAnnotationUsage = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(clonedAnnotationUsage != nullptr); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } auto *res = util::NodeAllocator::ForceSetParent( allocator, allocator, @@ -280,6 +283,10 @@ void ScriptFunction::DumpCheckerTypeForDeclGen(ir::SrcDumper *dumper) const return; } + if (IsSetter()) { + return; + } + if (Signature() == nullptr) { return; } @@ -398,7 +405,7 @@ void ScriptFunction::CopyTo(AstNode *other) const otherImpl->lang_ = lang_; otherImpl->returnStatements_ = returnStatements_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/scriptFunction.h b/ets2panda/ir/base/scriptFunction.h index ebafe16d94ad2cbc8b7776bd95daf9278fa5284f..e0d169804baad3b3400207557bb1fd314112f795 100644 --- a/ets2panda/ir/base/scriptFunction.h +++ b/ets2panda/ir/base/scriptFunction.h @@ -18,7 +18,7 @@ #include "checker/types/signature.h" #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" +#include "ir/statements/annotationUsage.h" #include "ir/statements/returnStatement.h" #include "ir/astNode.h" #include "scriptFunctionSignature.h" @@ -37,7 +37,7 @@ class TypeNode; class AnnotationUsage; class FunctionSignature; -class ScriptFunction : public JsDocAllowed> { +class ScriptFunction : public AnnotationAllowed { public: // Need to reduce the number of constructor parameters to pass OHOS CI code check struct ScriptFunctionData { diff --git a/ets2panda/ir/brokenTypeNode.cpp b/ets2panda/ir/brokenTypeNode.cpp index 110222066dbaa978f61131669aba4f5c5f98cdc8..05ef63679f55f15117eaf0cf22f9f0ef00f2546b 100644 --- a/ets2panda/ir/brokenTypeNode.cpp +++ b/ets2panda/ir/brokenTypeNode.cpp @@ -72,6 +72,7 @@ checker::VerifiedType BrokenTypeNode::Check([[maybe_unused]] checker::ETSChecker BrokenTypeNode *BrokenTypeNode::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator); + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsImportDeclaration.h b/ets2panda/ir/ets/etsImportDeclaration.h index dc5d6d8094a6ac8e100e7117dcd0fa7e94be6512..598b06f9d8cfa4b630d580b32e7cc5c83361b5ca 100644 --- a/ets2panda/ir/ets/etsImportDeclaration.h +++ b/ets2panda/ir/ets/etsImportDeclaration.h @@ -74,7 +74,7 @@ public: bool IsPureDynamic() const { - return IsValid() && DeclPath().empty() && Language().IsDynamic(); + return IsValid() && !DeclPath().empty() && Language().IsDynamic(); } void SetAssemblerName(util::StringView assemblerName) diff --git a/ets2panda/ir/ets/etsModule.cpp b/ets2panda/ir/ets/etsModule.cpp index 7c8faf7945bc76872d70ef00a896e3a57b4fa9d6..6e14809184079ee207744719da5c15fc05ae746d 100644 --- a/ets2panda/ir/ets/etsModule.cpp +++ b/ets2panda/ir/ets/etsModule.cpp @@ -29,7 +29,7 @@ void ETSModule::Dump(ir::SrcDumper *dumper) const dumper->Add("export default "); } - if (IsDeclare()) { + if (IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { dumper->Add("declare "); } @@ -69,7 +69,7 @@ void ETSModule::CopyTo(AstNode *other) const otherImpl->program_ = program_; otherImpl->globalClass_ = globalClass_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ets/etsModule.h b/ets2panda/ir/ets/etsModule.h index cfa7c5a05d4260bedcc5386b2e0ccfe98a9ca74b..abc2a5eca1b40aa271e3706b1834926fbc9fe88c 100644 --- a/ets2panda/ir/ets/etsModule.h +++ b/ets2panda/ir/ets/etsModule.h @@ -18,7 +18,6 @@ #include "ir/statements/blockStatement.h" #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" #include "ir/expressions/identifier.h" #include "ir/srcDump.h" @@ -44,12 +43,12 @@ struct enumbitops::IsAllowedType : std::true_type namespace ark::es2panda::ir { -class ETSModule : public JsDocAllowed> { +class ETSModule : public AnnotationAllowed { public: // CC-OFFNXT(G.FUN.01-CPP) solid logic explicit ETSModule(ArenaAllocator *allocator, ArenaVector &&statementList, Identifier *ident, ModuleFlag flag, Language lang, parser::Program *program) - : JsDocAllowed>(allocator, std::move(statementList)), + : AnnotationAllowed(allocator, std::move(statementList)), ident_(ident), flag_(flag), lang_(lang), @@ -62,7 +61,7 @@ public: // CC-OFFNXT(G.FUN.01-CPP) solid logic explicit ETSModule(ArenaAllocator *allocator, ArenaVector &&statementList, Identifier *ident, ModuleFlag flag, Language lang, parser::Program *program, AstNodeHistory *history) - : JsDocAllowed>(allocator, std::move(statementList)), + : AnnotationAllowed(allocator, std::move(statementList)), ident_(ident), flag_(flag), lang_(lang), diff --git a/ets2panda/ir/ets/etsNeverType.cpp b/ets2panda/ir/ets/etsNeverType.cpp index 0c0cbe895a80b1aaa7489d3259192c3ae4ca8766..7b5041808f4564e17b25a24b63c79f1d3e405da4 100644 --- a/ets2panda/ir/ets/etsNeverType.cpp +++ b/ets2panda/ir/ets/etsNeverType.cpp @@ -68,7 +68,7 @@ checker::Type *ETSNeverType::GetType([[maybe_unused]] checker::ETSChecker *check ETSNeverType *ETSNeverType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); - ES2PANDA_ASSERT(clone); + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); @@ -77,7 +77,9 @@ ETSNeverType *ETSNeverType::Clone(ArenaAllocator *allocator, AstNode *parent) if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *const annotationClone = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(annotationClone != nullptr); + annotationUsages.push_back(annotationClone->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp index 00d68dbfce227015634242de8ed1f5c075127ae6..f184fe3987774bc5bec8b1755357a07c41e10fe6 100644 --- a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp +++ b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp @@ -41,8 +41,9 @@ void ETSNonNullishTypeNode::Dump(ir::SrcDumper *dumper) const for (auto *anno : Annotations()) { anno->Dump(dumper); } + dumper->Add("NonNullable<"); typeNode_->Dump(dumper); - dumper->Add("!"); + dumper->Add(">"); } void ETSNonNullishTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index 9292f3e75f83aac4f121c52248ae1457ad997c6f..c24523fe042736d16c5fe19f8b985c78bd0803e3 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -271,8 +271,16 @@ checker::VerifiedType ETSParameterExpression::Check(checker::ETSChecker *const c ETSParameterExpression *ETSParameterExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { - auto *const identOrSpread = Spread() != nullptr ? Spread()->Clone(allocator, nullptr)->AsAnnotatedExpression() - : Ident()->Clone(allocator, nullptr)->AsAnnotatedExpression(); + AnnotatedExpression *identOrSpread = nullptr; + if (Spread() != nullptr) { + auto spreadClone = Spread()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(spreadClone != nullptr); + identOrSpread = spreadClone->AsAnnotatedExpression(); + } else { + auto identClone = Ident()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(identClone != nullptr); + identOrSpread = identClone->AsAnnotatedExpression(); + } auto *const initializer = Initializer() != nullptr ? Initializer()->Clone(allocator, nullptr)->AsExpression() : nullptr; @@ -287,7 +295,7 @@ ETSParameterExpression *ETSParameterExpression::Clone(ArenaAllocator *const allo initializer->SetParent(clone); } - ES2PANDA_ASSERT(clone); + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); } @@ -297,7 +305,9 @@ ETSParameterExpression *ETSParameterExpression::Clone(ArenaAllocator *const allo if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *const annotationClone = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(annotationClone != nullptr); + annotationUsages.push_back(annotationClone->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ets/etsPrimitiveType.cpp b/ets2panda/ir/ets/etsPrimitiveType.cpp index cd4a16ccc6d3e51ff517a548cc3843069c2a46d0..8e538f9c65cb8ebd665d0c1966b41a7e3e5b27b9 100644 --- a/ets2panda/ir/ets/etsPrimitiveType.cpp +++ b/ets2panda/ir/ets/etsPrimitiveType.cpp @@ -154,6 +154,7 @@ checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::ETSChecker *c ETSPrimitiveType *ETSPrimitiveType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(GetPrimitiveType(), allocator); + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); @@ -162,8 +163,9 @@ ETSPrimitiveType *ETSPrimitiveType::Clone(ArenaAllocator *const allocator, AstNo if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *annotationClone = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(annotationClone != nullptr); + annotationUsages.push_back(annotationClone->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ets/etsTuple.cpp b/ets2panda/ir/ets/etsTuple.cpp index 968b28724997d3fd3745d3abf5324c2164c63bde..30962dd205fc0e18bd768770e03ad245b7d6243f 100644 --- a/ets2panda/ir/ets/etsTuple.cpp +++ b/ets2panda/ir/ets/etsTuple.cpp @@ -112,11 +112,19 @@ checker::Type *ETSTuple::GetType(checker::ETSChecker *const checker) ArenaVector typeList(checker->ProgramAllocator()->Adapter()); + bool isTypeError = false; for (auto *const typeAnnotation : GetTupleTypeAnnotationsList()) { auto *const checkedType = typeAnnotation->GetType(checker); + if (!isTypeError && checkedType->IsTypeError()) { + isTypeError = true; + } typeList.emplace_back(checkedType); } + if (isTypeError) { + return SetTsType(checker->GlobalTypeError()); + } + auto *tupleType = checker->ProgramAllocator()->New(checker, typeList); if (IsReadonlyType()) { @@ -131,7 +139,7 @@ checker::Type *ETSTuple::GetType(checker::ETSChecker *const checker) ETSTuple *ETSTuple::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator, size_); - ES2PANDA_ASSERT(clone); + ES2PANDA_ASSERT(clone != nullptr); clone->AddModifier(flags_); @@ -148,7 +156,9 @@ ETSTuple *ETSTuple::Clone(ArenaAllocator *const allocator, AstNode *const parent if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *const annotationClone = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(annotationClone != nullptr); + annotationUsages.push_back(annotationClone->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ets/etsTypeReference.cpp b/ets2panda/ir/ets/etsTypeReference.cpp index 5ad9abc912b061c3f5aa14cd625e6de80473ed3e..b8d7c80ee796ff494e09ab28c19f0f1be1cc69bc 100644 --- a/ets2panda/ir/ets/etsTypeReference.cpp +++ b/ets2panda/ir/ets/etsTypeReference.cpp @@ -64,6 +64,7 @@ ir::Identifier *ETSTypeReference::BaseName() const if (baseName->IsIdentifier()) { return baseName->AsIdentifier(); } + if (baseName->IsTSQualifiedName()) { ir::TSQualifiedName *iter = baseName->AsTSQualifiedName(); @@ -72,12 +73,23 @@ ir::Identifier *ETSTypeReference::BaseName() const } return iter->Left()->AsIdentifier(); } - ir::MemberExpression *iter = baseName->AsMemberExpression(); - while (iter->Property()->IsMemberExpression()) { - iter = iter->Property()->AsMemberExpression(); + if (baseName->IsMemberExpression()) { + ir::MemberExpression *iter = baseName->AsMemberExpression(); + + while (iter->Property()->IsMemberExpression()) { + iter = iter->Property()->AsMemberExpression(); + } + return iter->Property()->AsIdentifier(); } - return iter->Property()->AsIdentifier(); + + if (baseName->IsLiteral()) { + ES2PANDA_ASSERT(baseName->OriginalNode() != nullptr && baseName->OriginalNode()->IsIdentifier()); + return baseName->OriginalNode()->AsIdentifier(); + } + + ES2PANDA_UNREACHABLE(); + return nullptr; } void ETSTypeReference::Dump(ir::AstDumper *dumper) const @@ -126,8 +138,14 @@ checker::Type *ETSTypeReference::GetType(checker::ETSChecker *checker) ETSTypeReference *ETSTypeReference::Clone(ArenaAllocator *const allocator, AstNode *const parent) { - auto *const partClone = Part() != nullptr ? Part()->Clone(allocator, nullptr)->AsETSTypeReferencePart() : nullptr; + ETSTypeReferencePart *partClone = nullptr; + if (Part() != nullptr) { + auto *const clone = Part()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(clone != nullptr); + partClone = clone->AsETSTypeReferencePart(); + } auto *const clone = allocator->New(partClone, allocator); + ES2PANDA_ASSERT(clone != nullptr); if (partClone != nullptr) { partClone->SetParent(clone); @@ -142,7 +160,9 @@ ETSTypeReference *ETSTypeReference::Clone(ArenaAllocator *const allocator, AstNo if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *annotationClone = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(annotationClone != nullptr); + annotationUsages.push_back(annotationClone->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/expressions/arrowFunctionExpression.cpp b/ets2panda/ir/expressions/arrowFunctionExpression.cpp index 73168b0bd272ca90eb4cb2c934f26518fe534891..e4eb06013e78f7214c1d42d795655a2282c1a501 100644 --- a/ets2panda/ir/expressions/arrowFunctionExpression.cpp +++ b/ets2panda/ir/expressions/arrowFunctionExpression.cpp @@ -81,7 +81,7 @@ checker::VerifiedType ArrowFunctionExpression::Check(checker::ETSChecker *checke } ArrowFunctionExpression::ArrowFunctionExpression(ArrowFunctionExpression const &other, ArenaAllocator *const allocator) - : JsDocAllowed>(static_cast(other), allocator) + : AnnotationAllowed(static_cast(other), allocator) { ES2PANDA_ASSERT(other.func_->Clone(allocator, this)); func_ = other.func_->Clone(allocator, this)->AsScriptFunction(); diff --git a/ets2panda/ir/expressions/arrowFunctionExpression.h b/ets2panda/ir/expressions/arrowFunctionExpression.h index 4289712ab0c78cd085409837aee390c8ed9d5313..2550cc7e0dac82d24970f05ef9e826aaa79a199a 100644 --- a/ets2panda/ir/expressions/arrowFunctionExpression.h +++ b/ets2panda/ir/expressions/arrowFunctionExpression.h @@ -18,7 +18,6 @@ #include "ir/expression.h" #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" namespace ark::es2panda::compiler { class ETSCompiler; @@ -27,7 +26,7 @@ class ETSCompiler; namespace ark::es2panda::ir { class ScriptFunction; -class ArrowFunctionExpression : public JsDocAllowed> { +class ArrowFunctionExpression : public AnnotationAllowed { public: ArrowFunctionExpression() = delete; ~ArrowFunctionExpression() override = default; @@ -36,7 +35,7 @@ public: NO_MOVE_SEMANTIC(ArrowFunctionExpression); explicit ArrowFunctionExpression(ScriptFunction *const func, ArenaAllocator *const allocator) - : JsDocAllowed>(AstNodeType::ARROW_FUNCTION_EXPRESSION, allocator), func_(func) + : AnnotationAllowed(AstNodeType::ARROW_FUNCTION_EXPRESSION, allocator), func_(func) { } diff --git a/ets2panda/ir/expressions/callExpression.h b/ets2panda/ir/expressions/callExpression.h index 53e6a1a108987d0cbcb20784c69b94fa134d887c..36d3e3be58be85e68fc5f9559146d1e5b2633941 100644 --- a/ets2panda/ir/expressions/callExpression.h +++ b/ets2panda/ir/expressions/callExpression.h @@ -188,9 +188,6 @@ public: AstNode::CleanUp(); signature_ = nullptr; uncheckedType_ = nullptr; - if (IsTransformedFromTrailingCall()) { - RetrieveTrailingBlock(); - } } private: @@ -200,19 +197,6 @@ private: bool isBlockInNewLine {false}; }; - bool IsTransformedFromTrailingCall() - { - return !arguments_.empty() && arguments_.back()->IsArrowFunctionExpression() && - arguments_.back()->AsArrowFunctionExpression()->Function()->IsTrailingLambda(); - } - - void RetrieveTrailingBlock() - { - SetTrailingBlock(arguments_.back()->AsArrowFunctionExpression()->Function()->Body()->AsBlockStatement()); - trailingLambdaInfo_.isTrailingCall = false; - arguments_.pop_back(); - } - protected: // NOLINTBEGIN(misc-non-private-member-variables-in-classes) Expression *callee_; diff --git a/ets2panda/ir/expressions/dummyNode.cpp b/ets2panda/ir/expressions/dummyNode.cpp index 1f608b2f6fa9599c1d78a6c837b04f605df293e6..bf4b171b8f3b7acb2549a0dd8e722d4bfcdc2d9d 100644 --- a/ets2panda/ir/expressions/dummyNode.cpp +++ b/ets2panda/ir/expressions/dummyNode.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -35,7 +35,7 @@ void DummyNode::Dump(ir::AstDumper *dumper) const dumper->Add({{"type", "DummyNode"}, {"name", name_}, {"indexName", indexName_}, - {"returnType", returnType_->AsETSTypeReferencePart()->Name()->AsIdentifier()->Name()}}); + {"returnType", AstDumper::Optional(GetReturnTypeLiteral())}}); } void DummyNode::Dump(ir::SrcDumper *dumper) const diff --git a/ets2panda/ir/expressions/dummyNode.h b/ets2panda/ir/expressions/dummyNode.h index 2cc26c2559a46761941f557d77ae2f9415499220..5f6bf1037892fac28dd6e0279b4e6a574d09a9c8 100644 --- a/ets2panda/ir/expressions/dummyNode.h +++ b/ets2panda/ir/expressions/dummyNode.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -44,8 +44,13 @@ public: public: explicit DummyNode(util::StringView const name, util::StringView indexName, TypeNode *returnType, - DummyNodeFlag flag) - : AstNode(AstNodeType::DUMMYNODE), name_(name), indexName_(indexName), returnType_(returnType), flag_(flag) + DummyNodeFlag flag, TypeNode *indexTypeAnno = nullptr) + : AstNode(AstNodeType::DUMMYNODE), + name_(name), + indexName_(indexName), + returnType_(returnType), + indexTypeAnno_(indexTypeAnno), + flag_(flag) { } @@ -88,6 +93,11 @@ public: return name_; } + TypeNode *IndexTypeAnno() const + { + return indexTypeAnno_; + } + bool operator==(const DummyNode &node) const { return name_.Is(std::string(node.Name().Bytes())); @@ -111,6 +121,7 @@ private: util::StringView name_; util::StringView indexName_; TypeNode *returnType_; + TypeNode *indexTypeAnno_; DummyNodeFlag flag_ {DummyNodeFlag::NONE}; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/memberExpression.cpp b/ets2panda/ir/expressions/memberExpression.cpp index 6c0bc3f2ef5042855a853172920554c49e9a2da8..016e43c9e5d561f6d18a8326d0167ae20709b249 100644 --- a/ets2panda/ir/expressions/memberExpression.cpp +++ b/ets2panda/ir/expressions/memberExpression.cpp @@ -212,6 +212,14 @@ checker::Type *MemberExpression::TraverseUnionMember(checker::ETSChecker *checke return; } + if (memberType->IsETSMethodType() && memberType->AsETSFunctionType()->CallSignatures().size() > 1U) { + if (!Parent()->IsCallExpression() || Parent()->AsCallExpression()->Callee() != this) { + commonPropType = checker->GlobalTypeError(); + checker->LogError(diagnostic::OVERLOADED_METHOD_AS_VALUE, Start()); + return; + } + } + if (!commonPropType->IsETSMethodType() && !memberType->IsETSMethodType()) { if (!checker->IsTypeIdenticalTo(commonPropType, memberType)) { checker->LogError(diagnostic::MEMBER_TYPE_MISMATCH_ACROSS_UNION, {}, Start()); @@ -233,7 +241,12 @@ checker::Type *MemberExpression::TraverseUnionMember(checker::ETSChecker *checke ES2PANDA_ASSERT(apparent != nullptr); if (apparent->IsETSObjectType()) { SetObjectType(apparent->AsETSObjectType()); - addPropType(ResolveObjectMember(checker).first); + auto *memberType = ResolveObjectMember(checker).first; + if (memberType != nullptr && memberType->IsTypeError()) { + return checker->GlobalTypeError(); + } + + addPropType(memberType); } else { checker->LogError(diagnostic::UNION_MEMBER_ILLEGAL_TYPE, {unionType}, Start()); } diff --git a/ets2panda/ir/jsDocAllowed.h b/ets2panda/ir/jsDocAllowed.h deleted file mode 100644 index 626d7bf23d0324e4bfa91bf67939d330b636e9bb..0000000000000000000000000000000000000000 --- a/ets2panda/ir/jsDocAllowed.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 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. - */ - -#ifndef ES2PANDA_IR_JSDOC_ALLOWED_H -#define ES2PANDA_IR_JSDOC_ALLOWED_H - -#include "ir/astNode.h" -#include "ir/statement.h" - -namespace ark::es2panda::ir { - -struct JsDocRecord { - util::StringView name; // NOLINT(misc-non-private-member-variables-in-classes) - util::StringView param; // NOLINT(misc-non-private-member-variables-in-classes) - util::StringView comment; // NOLINT(misc-non-private-member-variables-in-classes) - - JsDocRecord(util::StringView initName, util::StringView initParam, util::StringView initComment) - : name(initName), param(initParam), comment(initComment) - { - } -}; - -using JsDocInfo = ArenaUnorderedMap; - -template -class JsDocAllowed : public T { -public: - JsDocAllowed() = delete; - ~JsDocAllowed() override = default; - - NO_COPY_OPERATOR(JsDocAllowed); - NO_MOVE_SEMANTIC(JsDocAllowed); - - [[nodiscard]] ArenaVector &JsDocInformation() noexcept - { - return jsDocInformation_; - } - - [[nodiscard]] const ArenaVector &JsDocInformation() const noexcept - { - return jsDocInformation_; - } - - void SetJsDocInformation(ArenaVector &&jsDocInformation) - { - jsDocInformation_ = std::move(jsDocInformation); - } - -protected: - explicit JsDocAllowed(Expression const &other, ArenaAllocator *allocator) - : T(other, allocator), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(ArenaAllocator *const allocator, AstNodeType const type, - ArenaVector &&annotations) - : T(type, std::move(annotations)), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(AstNodeType const type, ModifierFlags const flags, - ArenaVector &&annotations, ArenaVector &&jsDocInformation) - : T(type, flags, std::move(annotations)), jsDocInformation_(std::move(jsDocInformation)) - { - } - - explicit JsDocAllowed(AstNodeType const type, ArenaAllocator *const allocator) - : T(type, allocator), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(AstNodeType const type, ModifierFlags const flags, ArenaAllocator *const allocator) - : T(type, flags, allocator), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(AstNodeType const type, Expression *const key, Expression *const value, - ModifierFlags const modifiers, ArenaAllocator *const allocator, bool const isComputed) - : T(type, key, value, modifiers, allocator, isComputed), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(AstNodeType const type, TypeNode *typeAnnotation, - [[maybe_unused]] ArenaAllocator *const allocator) - : T(type, typeAnnotation), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(ArenaAllocator *const allocator, AstNodeType const type) - : T(type), jsDocInformation_(allocator->Adapter()) - { - } - - explicit JsDocAllowed(ArenaAllocator *allocator, ArenaVector &&statements) - : T(allocator, std::move(statements)), jsDocInformation_(allocator->Adapter()) - { - } - - JsDocAllowed(const JsDocAllowed &other) - : T(static_cast(other)), jsDocInformation_(other.jsDocInformation_) - { - } - - JsDocAllowed(JsDocAllowed const &other, ArenaAllocator *const allocator) - : T(static_cast(other)), jsDocInformation_(allocator->Adapter()) - { - } - - void CopyTo(AstNode *other) const override - { - auto otherImpl = static_cast *>(other); - otherImpl->jsDocInformation_ = jsDocInformation_; - T::CopyTo(other); - } - -private: - friend class SizeOfNodeTest; - ArenaVector jsDocInformation_; -}; -} // namespace ark::es2panda::ir - -#endif diff --git a/ets2panda/ir/module/exportSpecifier.cpp b/ets2panda/ir/module/exportSpecifier.cpp index 1133414d19f41eb489e3847f49e98fb98041246f..1c28d57fe53a0f57a6606771288018944388a220 100644 --- a/ets2panda/ir/module/exportSpecifier.cpp +++ b/ets2panda/ir/module/exportSpecifier.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -48,6 +48,12 @@ void ExportSpecifier::Dump(ir::AstDumper *dumper) const void ExportSpecifier::Dump(ir::SrcDumper *dumper) const { + if (GetConstantExpression() != nullptr) { + GetConstantExpression()->Dump(dumper); + dumper->Add("as default"); + return; + } + exported_->Dump(dumper); if (local_ != nullptr) { diff --git a/ets2panda/ir/statements/annotationDeclaration.cpp b/ets2panda/ir/statements/annotationDeclaration.cpp index f353444a467119200613d572cbd67fbcba968163..7b88482674bbafcf6f06c8758b981d2db1f84318 100644 --- a/ets2panda/ir/statements/annotationDeclaration.cpp +++ b/ets2panda/ir/statements/annotationDeclaration.cpp @@ -153,8 +153,7 @@ Identifier *AnnotationDeclaration::GetBaseName() const if (Expr()->IsIdentifier()) { return GetHistoryNodeAs()->expr_->AsIdentifier(); } - auto *part = Expr()->AsETSTypeReference()->Part(); - return part->Name()->AsTSQualifiedName()->Right(); + return expr_->AsETSTypeReference()->Part()->GetIdent(); } AnnotationDeclaration *AnnotationDeclaration::Construct(ArenaAllocator *allocator) { diff --git a/ets2panda/ir/statements/annotationUsage.cpp b/ets2panda/ir/statements/annotationUsage.cpp index 1183e94543c49daac4bee8fd86eabf07723fc836..2d22aed190e78bad6be6a27631fd2357ed62daaf 100644 --- a/ets2panda/ir/statements/annotationUsage.cpp +++ b/ets2panda/ir/statements/annotationUsage.cpp @@ -120,7 +120,6 @@ Identifier *AnnotationUsage::GetBaseName() const if (expr_->IsIdentifier()) { return expr_->AsIdentifier(); } - auto *part = expr_->AsETSTypeReference()->Part(); - return part->Name()->AsTSQualifiedName()->Right(); + return expr_->AsETSTypeReference()->Part()->GetIdent(); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/continueStatement.cpp b/ets2panda/ir/statements/continueStatement.cpp index 8b73763a7df2abd5019f0e0754a4a165038a69f4..ab35d97e73d831665c191f4fa47d44d332fa3222 100644 --- a/ets2panda/ir/statements/continueStatement.cpp +++ b/ets2panda/ir/statements/continueStatement.cpp @@ -46,7 +46,12 @@ void ContinueStatement::Dump(ir::AstDumper *dumper) const void ContinueStatement::Dump(ir::SrcDumper *dumper) const { - dumper->Add("continue;"); + dumper->Add("continue"); + if (Ident() != nullptr) { + dumper->Add(" "); + Ident()->Dump(dumper); + } + dumper->Add(";"); } void ContinueStatement::Compile(compiler::PandaGen *pg) const diff --git a/ets2panda/ir/statements/forOfStatement.cpp b/ets2panda/ir/statements/forOfStatement.cpp index 34147d4f7cad4068810abb8d0ee15b86fa33517d..62926980918b34847ac6a00cbb06d82a2c11a60a 100644 --- a/ets2panda/ir/statements/forOfStatement.cpp +++ b/ets2panda/ir/statements/forOfStatement.cpp @@ -229,6 +229,10 @@ bool ForOfStatement::CheckReturnTypeOfIteratorMethod(checker::ETSChecker *checke bool ForOfStatement::CheckIteratorInterfaceForObject(checker::ETSChecker *checker, checker::ETSObjectType *obj) { + if (obj->Name().Is(ITERATOR_INTERFACE_NAME)) { + return true; + } + for (auto *const it : obj->Interfaces()) { if (it->Name().Is(ITERATOR_INTERFACE_NAME)) { return true; diff --git a/ets2panda/ir/statements/forUpdateStatement.cpp b/ets2panda/ir/statements/forUpdateStatement.cpp index 912dd11f40e02c16def7bf72aa490607a2a316e2..cd0d2d53170af2dffb4c3e54d27d413d90e2b4de 100644 --- a/ets2panda/ir/statements/forUpdateStatement.cpp +++ b/ets2panda/ir/statements/forUpdateStatement.cpp @@ -127,9 +127,20 @@ checker::VerifiedType ForUpdateStatement::Check(checker::ETSChecker *checker) ForUpdateStatement *ForUpdateStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { - auto *const init = init_->Clone(allocator, nullptr); - auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); - auto *const update = update_->Clone(allocator, nullptr)->AsExpression(); + ir::AstNode *init = nullptr; + if (init_ != nullptr) { + init = init_->Clone(allocator, nullptr); + } + + ir::Expression *test = nullptr; + if (test_ != nullptr) { + test = test_->Clone(allocator, nullptr)->AsExpression(); + } + + ir::Expression *update = nullptr; + if (update_ != nullptr) { + update = update_->Clone(allocator, nullptr)->AsExpression(); + } auto *const body = body_->Clone(allocator, nullptr)->AsStatement(); auto *const clone = util::NodeAllocator::ForceSetParent(allocator, init, test, update, body); diff --git a/ets2panda/ir/statements/functionDeclaration.cpp b/ets2panda/ir/statements/functionDeclaration.cpp index be0f1341c4236c1f037cb58711cdfb5950c63bcd..96a4c9feba71a32459588122675f91dcb6a7e020 100644 --- a/ets2panda/ir/statements/functionDeclaration.cpp +++ b/ets2panda/ir/statements/functionDeclaration.cpp @@ -79,7 +79,12 @@ void FunctionDeclaration::Dump(ir::SrcDumper *dumper) const if (func->IsNative()) { dumper->Add("native "); } - if (func->IsDeclare()) { + if (IsExported()) { + dumper->Add("export "); + } else if (IsDefaultExported()) { + dumper->Add("export default "); + } + if (func->IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { dumper->Add("declare "); } if (func->IsAsyncFunc()) { @@ -124,7 +129,7 @@ void FunctionDeclaration::CopyTo(AstNode *other) const otherImpl->func_ = func_; otherImpl->isAnonymous_ = isAnonymous_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } void FunctionDeclaration::EmplaceDecorators(Decorator *decorators) diff --git a/ets2panda/ir/statements/functionDeclaration.h b/ets2panda/ir/statements/functionDeclaration.h index 25a69766e6442b306627baa746d5c9000a74a99d..264207ceba3cc3ecfaad3bc3185ee35972f171e0 100644 --- a/ets2panda/ir/statements/functionDeclaration.h +++ b/ets2panda/ir/statements/functionDeclaration.h @@ -17,7 +17,6 @@ #define ES2PANDA_IR_STATEMENT_FUNCTION_DECLARATION_H #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" #include "ir/statement.h" #include "ir/statements/annotationUsage.h" #include "ir/base/scriptFunction.h" @@ -26,12 +25,11 @@ namespace ark::es2panda::ir { class ScriptFunction; class AnnotationUsage; -class FunctionDeclaration : public JsDocAllowed> { +class FunctionDeclaration : public AnnotationAllowed { public: explicit FunctionDeclaration(ArenaAllocator *allocator, ScriptFunction *func, ArenaVector &&annotations, bool isAnonymous = false) - : JsDocAllowed>(allocator, AstNodeType::FUNCTION_DECLARATION, - std::move(annotations)), + : AnnotationAllowed(AstNodeType::FUNCTION_DECLARATION, std::move(annotations)), decorators_(allocator->Adapter()), func_(func), isAnonymous_(isAnonymous) @@ -43,7 +41,7 @@ public: } explicit FunctionDeclaration(ArenaAllocator *allocator, ScriptFunction *func, bool isAnonymous = false) - : JsDocAllowed>(AstNodeType::FUNCTION_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::FUNCTION_DECLARATION, allocator), decorators_(allocator->Adapter()), func_(func), isAnonymous_(isAnonymous) @@ -56,7 +54,7 @@ public: explicit FunctionDeclaration(ArenaAllocator *allocator, ScriptFunction *func, bool isAnonymous, AstNodeHistory *history) - : JsDocAllowed>(AstNodeType::FUNCTION_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::FUNCTION_DECLARATION, allocator), decorators_(allocator->Adapter()), func_(func), isAnonymous_(isAnonymous) diff --git a/ets2panda/ir/statements/switchCaseStatement.cpp b/ets2panda/ir/statements/switchCaseStatement.cpp index 77df9b94db3efa316d97a2390f82ff3d7a0257ea..848a7159844cd5647a02b450dde44cd46213ae45 100644 --- a/ets2panda/ir/statements/switchCaseStatement.cpp +++ b/ets2panda/ir/statements/switchCaseStatement.cpp @@ -146,7 +146,10 @@ void SwitchCaseStatement::CheckAndTestCase(checker::ETSChecker *checker, checker SwitchCaseStatement *SwitchCaseStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { - auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); + Expression *test = nullptr; + if (test_ != nullptr) { + test = test_->Clone(allocator, nullptr)->AsExpression(); + } ArenaVector consequent(allocator->Adapter()); for (auto *statement : consequent_) { diff --git a/ets2panda/ir/statements/tryStatement.cpp b/ets2panda/ir/statements/tryStatement.cpp index 82d74865c48fce0170ee8973f5dd46710dd83e83..acc5b4d085afe04bd1a49cb404958b038ad7b90d 100644 --- a/ets2panda/ir/statements/tryStatement.cpp +++ b/ets2panda/ir/statements/tryStatement.cpp @@ -125,7 +125,13 @@ TryStatement::TryStatement(TryStatement const &other, ArenaAllocator *allocator) finalizerInsertions_(allocator->Adapter()), finallyCanCompleteNormally_(other.finallyCanCompleteNormally_) { - block_ = other.block_ == nullptr ? nullptr : other.block_->Clone(allocator, this)->AsBlockStatement(); + if (other.block_ == nullptr) { + block_ = nullptr; + } else { + auto *blockClone = other.block_->Clone(allocator, this); + ES2PANDA_ASSERT(blockClone != nullptr); + block_ = blockClone->AsBlockStatement(); + } for (auto &cc : other.catchClauses_) { if (cc == nullptr) { catchClauses_.push_back(nullptr); diff --git a/ets2panda/ir/statements/variableDeclaration.cpp b/ets2panda/ir/statements/variableDeclaration.cpp index fd09dc88e4033f54c6dcfc5f62d8b2b99d89a181..0f752dec946c007df30b4468bb641f01dd2bce74 100644 --- a/ets2panda/ir/statements/variableDeclaration.cpp +++ b/ets2panda/ir/statements/variableDeclaration.cpp @@ -199,8 +199,7 @@ void VariableDeclaration::Dump(ir::SrcDumper *dumper) const VariableDeclaration::VariableDeclaration([[maybe_unused]] Tag const tag, VariableDeclaration const &other, ArenaAllocator *const allocator) - : JsDocAllowed>(static_cast> const &>(other), - allocator), + : AnnotationAllowed(static_cast const &>(other)), kind_(other.kind_), decorators_(allocator->Adapter()), declarators_(allocator->Adapter()) @@ -222,8 +221,7 @@ VariableDeclaration::VariableDeclaration([[maybe_unused]] Tag const tag, Variabl VariableDeclaration::VariableDeclaration([[maybe_unused]] Tag const tag, VariableDeclaration const &other, ArenaAllocator *const allocator, AstNodeHistory *history) - : JsDocAllowed>( - static_cast> const &>(other)), + : AnnotationAllowed(static_cast const &>(other)), kind_(other.kind_), decorators_(allocator->Adapter()), declarators_(allocator->Adapter()) @@ -290,7 +288,7 @@ void VariableDeclaration::CopyTo(AstNode *other) const otherImpl->decorators_ = decorators_; otherImpl->declarators_ = declarators_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/variableDeclaration.h b/ets2panda/ir/statements/variableDeclaration.h index cb3703b27dfa0ba9f5f2b21f31870225c77e6ee4..1e9a54a233b2a4fdc2075af81a0d66fa202c3bf6 100644 --- a/ets2panda/ir/statements/variableDeclaration.h +++ b/ets2panda/ir/statements/variableDeclaration.h @@ -17,7 +17,6 @@ #define ES2PANDA_IR_STATEMENT_VARIABLE_DECLARATION_H #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" #include "ir/statement.h" #include "ir/expressions/identifier.h" #include "ir/statements/annotationUsage.h" @@ -26,7 +25,7 @@ namespace ark::es2panda::ir { class VariableDeclarator; -class VariableDeclaration : public JsDocAllowed> { +class VariableDeclaration : public AnnotationAllowed { private: struct Tag {}; @@ -35,7 +34,7 @@ public: explicit VariableDeclaration(VariableDeclarationKind kind, ArenaAllocator *allocator, ArenaVector &&declarators) - : JsDocAllowed>(AstNodeType::VARIABLE_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::VARIABLE_DECLARATION, allocator), kind_(kind), decorators_(allocator->Adapter()), declarators_(std::move(declarators)) @@ -45,7 +44,7 @@ public: explicit VariableDeclaration(VariableDeclarationKind kind, ArenaAllocator *allocator, ArenaVector &&declarators, AstNodeHistory *history) - : JsDocAllowed>(AstNodeType::VARIABLE_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::VARIABLE_DECLARATION, allocator), kind_(kind), decorators_(allocator->Adapter()), declarators_(std::move(declarators)) diff --git a/ets2panda/ir/ts/tsArrayType.cpp b/ets2panda/ir/ts/tsArrayType.cpp index b5f988027e21799a7d763ce06a906d074e36f689..93a56fa2084f5ec91d28187c9bf354526845e15e 100644 --- a/ets2panda/ir/ts/tsArrayType.cpp +++ b/ets2panda/ir/ts/tsArrayType.cpp @@ -115,8 +115,10 @@ TSArrayType *TSArrayType::Clone(ArenaAllocator *const allocator, AstNode *const if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; + AnnotationUsage *clonedAnnotationUsage; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + clonedAnnotationUsage = annotationUsage->Clone(allocator, clone); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ts/tsEnumMember.h b/ets2panda/ir/ts/tsEnumMember.h index 566cbb1a9140a05d173152591e41d43324b65c31..32c9594331ff64c65366a552f81852261cf1e887 100644 --- a/ets2panda/ir/ts/tsEnumMember.h +++ b/ets2panda/ir/ts/tsEnumMember.h @@ -17,7 +17,6 @@ #define ES2PANDA_IR_TS_ENUM_MEMBER_H #include "ir/statement.h" -#include "ir/jsDocAllowed.h" namespace ark::es2panda::ir { class Expression; diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp index 4455a8b7764190e5cef66af761cd7fd5d742f193..7670586186185452ba8d1194c84739dc0163faa6 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp @@ -317,7 +317,7 @@ void TSInterfaceDeclaration::CopyTo(AstNode *other) const otherImpl->lang_ = lang_; otherImpl->anonClass_ = anonClass_; - JsDocAllowed>::CopyTo(other); + AnnotationAllowed::CopyTo(other); } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.h b/ets2panda/ir/ts/tsInterfaceDeclaration.h index 217a31c5b6d14e83abe76f1d3ccfbedf879f5934..327a692a5dbf403f7f4b91afe925374cadb6191f 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.h +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.h @@ -18,7 +18,8 @@ #include "varbinder/scope.h" #include "ir/annotationAllowed.h" -#include "ir/jsDocAllowed.h" +#include "ir/statement.h" +#include "ir/statements/annotationUsage.h" namespace ark::es2panda::varbinder { class Variable; @@ -30,7 +31,7 @@ class TSInterfaceBody; class TSInterfaceHeritage; class TSTypeParameterDeclaration; -class TSInterfaceDeclaration : public JsDocAllowed> { +class TSInterfaceDeclaration : public AnnotationAllowed { public: // NOLINTBEGIN(cppcoreguidelines-pro-type-member-init) struct ConstructorData { @@ -45,7 +46,7 @@ public: explicit TSInterfaceDeclaration(ArenaAllocator *allocator, ArenaVector &&extends, ConstructorData &&data) - : JsDocAllowed>(AstNodeType::TS_INTERFACE_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::TS_INTERFACE_DECLARATION, allocator), decorators_(allocator->Adapter()), id_(data.id), typeParams_(data.typeParams), @@ -63,7 +64,7 @@ public: explicit TSInterfaceDeclaration(ArenaAllocator *allocator, ArenaVector &&extends, ConstructorData &&data, AstNodeHistory *history) - : JsDocAllowed>(AstNodeType::TS_INTERFACE_DECLARATION, allocator), + : AnnotationAllowed(AstNodeType::TS_INTERFACE_DECLARATION, allocator), decorators_(allocator->Adapter()), id_(data.id), typeParams_(data.typeParams), diff --git a/ets2panda/ir/ts/tsThisType.cpp b/ets2panda/ir/ts/tsThisType.cpp index 03bcb6e6a2bf55dc9b49eb9485aca842b8f0a30f..1b49be750598aaeeaa48516938fc0b61b1dff07e 100644 --- a/ets2panda/ir/ts/tsThisType.cpp +++ b/ets2panda/ir/ts/tsThisType.cpp @@ -76,7 +76,7 @@ checker::Type *TSThisType::GetType([[maybe_unused]] checker::ETSChecker *checker TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator); - + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); } @@ -84,8 +84,9 @@ TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const pa if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone) != nullptr); - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *clonedAnnotationUsage = annotationUsage->Clone(allocator, clone); + ES2PANDA_ASSERT(clonedAnnotationUsage != nullptr); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ts/tsTupleType.cpp b/ets2panda/ir/ts/tsTupleType.cpp index 25f14ade82f72d5931bfe9502f0959f89638d253..3063931095d6fef0aebf163d67821f1d2240d558 100644 --- a/ets2panda/ir/ts/tsTupleType.cpp +++ b/ets2panda/ir/ts/tsTupleType.cpp @@ -89,6 +89,7 @@ checker::Type *GetNumberIndexType(ArenaVector numberIndexTypes, static void SetMemberVarType(checker::Type *memberType, varbinder::LocalVariable *memberVar) { + ES2PANDA_ASSERT(memberType != nullptr); memberType->SetVariable(memberVar); memberVar->SetTsType(memberType); } @@ -112,7 +113,7 @@ checker::Type *TSTupleType::GetType(checker::TSChecker *checker) auto *memberVar = varbinder::Scope::CreateVar(checker->Allocator(), memberIndex, varbinder::VariableFlags::PROPERTY, it); - + ES2PANDA_ASSERT(memberVar != nullptr); checker::ElementFlags memberFlag; if (it->IsTSNamedTupleMember()) { auto *namedMember = it->AsTSNamedTupleMember(); diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp index 75532d60154cff4050fefed4cab1dfcbdf7e5054..5f2276dd48a156d0b1ea24bfcf524fc934c8e0e0 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp @@ -195,7 +195,7 @@ void TSTypeAliasDeclaration::CopyTo(AstNode *other) const otherImpl->typeParams_ = typeParams_; otherImpl->typeParamTypes_ = typeParamTypes_; - JsDocAllowed::CopyTo(other); + AnnotatedStatement::CopyTo(other); } void TSTypeAliasDeclaration::EmplaceDecorators(Decorator *decorators) diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.h b/ets2panda/ir/ts/tsTypeAliasDeclaration.h index fb9b8c160da4f0438b402e9aa95afef5c3a9e4b8..44022d21aca11129f3ddb46ada9f6d9ae79188e5 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.h +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.h @@ -18,7 +18,6 @@ #include "ir/statement.h" #include "ir/typed.h" -#include "ir/jsDocAllowed.h" #include "ir/statements/annotationUsage.h" namespace ark::es2panda::varbinder { @@ -29,11 +28,11 @@ namespace ark::es2panda::ir { class Identifier; class TSTypeParameterDeclaration; -class TSTypeAliasDeclaration : public JsDocAllowed { +class TSTypeAliasDeclaration : public AnnotatedStatement { public: explicit TSTypeAliasDeclaration(ArenaAllocator *allocator, Identifier *id, TSTypeParameterDeclaration *typeParams, TypeNode *typeAnnotation) - : JsDocAllowed(AstNodeType::TS_TYPE_ALIAS_DECLARATION, typeAnnotation, allocator), + : AnnotatedStatement(AstNodeType::TS_TYPE_ALIAS_DECLARATION, typeAnnotation), decorators_(allocator->Adapter()), annotations_(allocator->Adapter()), id_(id), @@ -44,7 +43,7 @@ public: } explicit TSTypeAliasDeclaration(ArenaAllocator *allocator, Identifier *id) - : JsDocAllowed(allocator, AstNodeType::TS_TYPE_ALIAS_DECLARATION), + : AnnotatedStatement(AstNodeType::TS_TYPE_ALIAS_DECLARATION), decorators_(allocator->Adapter()), annotations_(allocator->Adapter()), id_(id), diff --git a/ets2panda/lexer/ETSLexer.cpp b/ets2panda/lexer/ETSLexer.cpp index 7bf139df18a5cf307e2ffdd5ba38a8dba71b78fe..58645e09fa9e7ebd9e002ed626567f1db84226bd 100644 --- a/ets2panda/lexer/ETSLexer.cpp +++ b/ets2panda/lexer/ETSLexer.cpp @@ -106,21 +106,17 @@ bool ETSLexer::CheckUtf16Compatible(char32_t cp) const void ETSLexer::ScanAsteriskPunctuator() { GetToken().type_ = TokenType::PUNCTUATOR_MULTIPLY; - auto cp = Iterator().Peek(); - if (cp == LEX_CHAR_EQUALS) { - GetToken().type_ = TokenType::PUNCTUATOR_MULTIPLY_EQUAL; - Iterator().Forward(1); - return; - } - Iterator().Backward(1); - if (!IsValidJsDocEnd(&cp)) { - Iterator().Forward(1); - return; + switch (Iterator().Peek()) { + case LEX_CHAR_EQUALS: { + GetToken().type_ = TokenType::PUNCTUATOR_MULTIPLY_EQUAL; + Iterator().Forward(1); + break; + } + default: { + break; + } } - Iterator().Forward(JS_DOC_END_SIZE + 1); - GetToken().type_ = TokenType::JS_DOC_END; - Pos().NextTokenLine() += 1; } void ETSLexer::ConvertNumber(NumberFlags const flags) diff --git a/ets2panda/lexer/lexer.cpp b/ets2panda/lexer/lexer.cpp index f8ed59e1e61c1852dc3a3282da0fa0414e3f7369..326dcaed3cb78d33e00515d55c68119fcf6676c0 100644 --- a/ets2panda/lexer/lexer.cpp +++ b/ets2panda/lexer/lexer.cpp @@ -17,8 +17,6 @@ #include "generated/keywords.h" -#include - namespace ark::es2panda::lexer { LexerPosition::LexerPosition(const util::StringView &source) : iterator_(source) {} @@ -122,6 +120,11 @@ LexerPosition Lexer::Save() const return pos_; } +void Lexer::Reset(size_t offset) +{ + pos_.iterator_.Reset(offset); +} + void Lexer::BackwardToken(TokenType type, size_t offset) { pos_.token_.type_ = type; @@ -136,12 +139,6 @@ void Lexer::ForwardToken(TokenType type, size_t offset) SkipWhiteSpaces(); } -void Lexer::ForwardToken(TokenType type) -{ - pos_.token_.type_ = type; - pos_.iterator_.Forward(1); -} - void Lexer::Rewind(const LexerPosition &pos) { pos_ = pos; @@ -152,11 +149,6 @@ char32_t Lexer::Lookahead() return Iterator().Peek(); } -size_t Lexer::GetIndex() -{ - return Iterator().Index(); -} - util::StringView Lexer::SourceView(const util::StringView::Iterator &begin, const util::StringView::Iterator &end) const { return SourceView(begin.Index(), end.Index()); @@ -977,20 +969,17 @@ void Lexer::ScanMinusPunctuator() void Lexer::ScanSlashPunctuator() { GetToken().type_ = TokenType::PUNCTUATOR_DIVIDE; - auto cp = Iterator().Peek(); - if (cp == LEX_CHAR_EQUALS) { - GetToken().type_ = TokenType::PUNCTUATOR_DIVIDE_EQUAL; - Iterator().Forward(1); - } - Iterator().Backward(1); - if (!IsValidJsDocStart(&cp)) { - Iterator().Forward(1); - return; + switch (Iterator().Peek()) { + case LEX_CHAR_EQUALS: { + GetToken().type_ = TokenType::PUNCTUATOR_DIVIDE_EQUAL; + Iterator().Forward(1); + break; + } + default: { + break; + } } - Iterator().Forward(JS_DOC_START_SIZE + 1); - GetToken().type_ = TokenType::JS_DOC_START; - pos_.nextTokenLine_ += 1; } void Lexer::ScanDotPunctuator(KeywordsUtil &kwu) @@ -1293,45 +1282,6 @@ bool Lexer::SkipWhiteSpacesHelperSlash(char32_t *cp) return false; } -bool Lexer::IsEnableParseJsdoc() const -{ - return parserContext_->IsEnableJsdocParse(); -} - -bool Lexer::IsValidJsDocStart(char32_t *cp) -{ - if (!IsEnableParseJsdoc()) { - return false; - } - - for (size_t idx = 0; idx < JS_DOC_START_SIZE; ++idx) { - Iterator().Forward(1); - *cp = Iterator().Peek(); - if (*cp != JS_DOC_START_LEX[idx]) { - Iterator().Backward(idx + 1); - return false; - } - } - - Iterator().Backward(JS_DOC_START_SIZE); - return true; -} - -bool Lexer::IsValidJsDocEnd(char32_t *cp) -{ - for (size_t idx = 0; idx < JS_DOC_END_SIZE; ++idx) { - Iterator().Forward(1); - *cp = Iterator().Peek(); - if (*cp != JS_DOC_END_LEX[idx]) { - Iterator().Backward(idx + 1); - return false; - } - } - - Iterator().Backward(JS_DOC_END_SIZE); - return true; -} - bool Lexer::SkipWhiteSpacesHelperDefault(const char32_t &cp) { if (cp < LEX_ASCII_MAX_BITS) { @@ -1390,10 +1340,6 @@ void Lexer::SkipWhiteSpaces() Iterator().Forward(1); continue; case LEX_CHAR_SLASH: - if ((GetContext()->Status() & parser::ParserStatus::ALLOW_JS_DOC_START) != 0 && - IsValidJsDocStart(&cp)) { - return; - } if (!SkipWhiteSpacesHelperSlash(&cp)) { return; } @@ -1786,15 +1732,6 @@ void Lexer::FinalizeTokenHelper(util::UString *str, const size_t &startPos, size } } -void Lexer::FinalizeJsDocInfoHelper(util::UString *str, const size_t &startPos, size_t escapeEnd) -{ - if ((GetToken().flags_ & TokenFlags::HAS_ESCAPE) != 0U) { - str->Append(SourceView(escapeEnd, Iterator().Index())); - } else { - str->Append(SourceView(startPos, Iterator().Index())); - } -} - LexerPosition &Lexer::Pos() { return pos_; diff --git a/ets2panda/lexer/lexer.h b/ets2panda/lexer/lexer.h index 47c03ba3d9d28a251ee8840da5965017c78df912..7acbfa17369fb88d578106e83cd11b26a48d1172 100644 --- a/ets2panda/lexer/lexer.h +++ b/ets2panda/lexer/lexer.h @@ -16,6 +16,8 @@ #ifndef ES2PANDA_PARSER_CORE_LEXER_H #define ES2PANDA_PARSER_CORE_LEXER_H +#include +#include #include "lexer/regexp/regexp.h" #include "lexer/token/letters.h" #include "lexer/token/token.h" @@ -124,7 +126,6 @@ public: // NOLINTNEXTLINE(google-default-arguments) virtual void NextToken(NextTokenFlags flags = NextTokenFlags::NONE); virtual void ScanAsteriskPunctuator(); - bool IsEnableParseJsdoc() const; Token &GetToken(); const Token &GetToken() const; @@ -151,11 +152,6 @@ public: return false; } - void SkipCp() - { - Iterator().SkipCp(); - } - util::DiagnosticEngine &DiagnosticEngine() { return diagnosticEngine_; @@ -173,9 +169,9 @@ public: LexerPosition Save() const; void Rewind(const LexerPosition &pos); + void Reset(size_t offset); void BackwardToken(TokenType type, size_t offset); void ForwardToken(TokenType type, size_t offset); - void ForwardToken(TokenType type); char32_t Lookahead(); bool CheckArrow(); @@ -188,7 +184,6 @@ public: bool HandleDoubleQuoteHelper(const char32_t &end, const char32_t &cp); void PrepareStringTokenHelper(); void FinalizeTokenHelper(util::UString *str, const size_t &startPos, size_t escapeEnd, bool finalize = true); - void FinalizeJsDocInfoHelper(util::UString *str, const size_t &startPos, size_t escapeEnd); template void ScanString(); @@ -239,13 +234,19 @@ public: bool outOfRange = false; if constexpr (!std::is_same_v) { - outOfRange = tmp < static_cast(std::numeric_limits::min()) || + outOfRange = tmp < static_cast(std::numeric_limits::denorm_min()) || tmp > static_cast(std::numeric_limits::max()); } + if constexpr (std::is_floating_point_v) { + outOfRange |= (tmp == std::numeric_limits::infinity()); + } else { + outOfRange |= (errno == ERANGE); + } + if (endPtr == str) { result = ConversionResult::INVALID_ARGUMENT; - } else if (errno == ERANGE || outOfRange) { + } else if (outOfRange) { result = ConversionResult::OUT_OF_RANGE; } else { result = ConversionResult::SUCCESS; @@ -262,8 +263,6 @@ public: return GetToken().Start(); } - size_t GetIndex(); - protected: void NextToken(Keywords *kws); ArenaAllocator *Allocator(); @@ -294,8 +293,6 @@ protected: util::StringView SourceView(const util::StringView::Iterator &begin, const util::StringView::Iterator &end) const; bool SkipWhiteSpacesHelperSlash(char32_t *cp); - bool IsValidJsDocStart(char32_t *cp); - bool IsValidJsDocEnd(char32_t *cp); bool SkipWhiteSpacesHelperDefault(const char32_t &cp); void SkipWhiteSpaces(); void SkipSingleLineComment(); @@ -379,10 +376,6 @@ private: util::StringView source_; LexerPosition pos_; util::DiagnosticEngine &diagnosticEngine_; - const parser::ParserContext *GetContext() - { - return parserContext_; - } }; class TemplateLiteralParserContext { diff --git a/ets2panda/lexer/regexp/regexp.h b/ets2panda/lexer/regexp/regexp.h index 445659c5573275ea31a8eb8b2bf376f1d8e2267f..42c11f4f1060f9f79dc1838bfab0dbdc0a748a76 100644 --- a/ets2panda/lexer/regexp/regexp.h +++ b/ets2panda/lexer/regexp/regexp.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -19,7 +19,7 @@ #include "util/enumbitops.h" #include "util/ustring.h" -#include "../../parser/parserImpl.h" +#include "parser/parserImpl.h" #include diff --git a/ets2panda/lexer/scripts/keywords.yaml b/ets2panda/lexer/scripts/keywords.yaml index 920a68e9e4b185c8a59cbae95660521066c7d254..800f183c3b0f40d6893a4360ae338b457934473b 100644 --- a/ets2panda/lexer/scripts/keywords.yaml +++ b/ets2panda/lexer/scripts/keywords.yaml @@ -68,9 +68,9 @@ keywords: - name: 'bigint' token: KEYW_BIGINT keyword_like: [ets, ts] - flags: [definable_type_name] + flags: [predefined_type] - - name: 'Bigint' + - name: 'BigInt' token: KEYW_BUILTIN_BIGINT keyword_like: [ets] flags: [predefined_type] @@ -79,7 +79,7 @@ keywords: token: KEYW_BOOLEAN keyword: [ets] keyword_like: [js, ts] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Boolean' token: KEYW_BUILTIN_BOOLEAN @@ -94,7 +94,7 @@ keywords: - name: 'byte' token: KEYW_BYTE keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Byte' token: KEYW_BUILTIN_BYTE @@ -114,7 +114,7 @@ keywords: - name: 'char' token: KEYW_CHAR keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Char' token: KEYW_BUILTIN_CHAR @@ -168,7 +168,7 @@ keywords: - name: 'double' token: KEYW_DOUBLE keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Double' token: KEYW_BUILTIN_DOUBLE @@ -229,7 +229,7 @@ keywords: - name: 'float' token: KEYW_FLOAT keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Float' token: KEYW_BUILTIN_FLOAT @@ -319,7 +319,7 @@ keywords: - name: 'int' token: KEYW_INT keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Int' token: KEYW_BUILTIN_INT @@ -350,7 +350,7 @@ keywords: - name: 'long' token: KEYW_LONG keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Long' token: KEYW_BUILTIN_LONG @@ -383,6 +383,11 @@ keywords: token: KEYW_NEW keyword: [as, js, ets, ts] + - name: "NonNullable" + token: KEYW_NON_NULLABLE + keyword_like: [ets] + flags: [reserved_type_name, definable_type_name] + - name: 'null' token: LITERAL_NULL keyword: [as, js, ets, ts] @@ -469,7 +474,7 @@ keywords: - name: 'short' token: KEYW_SHORT keyword: [ets] - flags: [reserved_type_name, definable_type_name] + flags: [reserved_type_name, predefined_type] - name: 'Short' token: KEYW_BUILTIN_SHORT @@ -483,7 +488,7 @@ keywords: - name: 'string' token: KEYW_STRING keyword_like: [ets, ts] - flags: [definable_type_name] + flags: [predefined_type] - name: 'String' token: KEYW_BUILTIN_STRING @@ -493,7 +498,7 @@ keywords: - name: 'struct' token: KEYW_STRUCT keyword_like: [ets] - flags: [definable_type_name] + flags: [reserved_type_name] - name: 'super' token: KEYW_SUPER @@ -531,8 +536,8 @@ keywords: - name: 'typeof' token: KEYW_TYPEOF - keyword: [js, ts] - keyword_like: [ets] + keyword: [js, ts, ets] + keyword_like: [] flags: [unary] - name: 'u8' @@ -579,7 +584,7 @@ keywords: - name: 'void' token: KEYW_VOID keyword: [as, ets, js, ts] - flags: [unary, reserved_type_name, definable_type_name] + flags: [unary, reserved_type_name, predefined_type] - name: 'while' token: KEYW_WHILE diff --git a/ets2panda/lexer/templates/token.inl.erb b/ets2panda/lexer/templates/token.inl.erb index 105251067d2a23e2f7174ae39e260cdcb3552a20..1b90b38032b33112105206f192d36a6b22b5572f 100644 --- a/ets2panda/lexer/templates/token.inl.erb +++ b/ets2panda/lexer/templates/token.inl.erb @@ -32,10 +32,6 @@ const char *TokenToString(TokenType type) // NOLINT(readability-function-size) return "string literal"; case TokenType::LITERAL_CHAR: return "char literal"; - case TokenType::JS_DOC_START: - return "/**"; - case TokenType::JS_DOC_END: - return "*/"; case TokenType::EOS: return "end of stream"; default: diff --git a/ets2panda/lexer/templates/tokenType.h.erb b/ets2panda/lexer/templates/tokenType.h.erb index a1f944cbecddc1471b43215a27249d6fd09d50c4..d02424b5827898fda81058e13267441bcc0a90da 100644 --- a/ets2panda/lexer/templates/tokenType.h.erb +++ b/ets2panda/lexer/templates/tokenType.h.erb @@ -34,8 +34,6 @@ enum class TokenType { % end <%= token.token %>, % end - JS_DOC_START, - JS_DOC_END, FIRST_PUNCTUATOR = <%= Tokens::tokens[0].token %>, FIRST_KEYW = <%= Keywords::keywords[0].token %> }; diff --git a/ets2panda/lexer/token/letters.h b/ets2panda/lexer/token/letters.h index e33d21b1142c67a38b63d43a501964425c39f4b7..e55574600d19a988d737c0a30155b6393291f578 100644 --- a/ets2panda/lexer/token/letters.h +++ b/ets2panda/lexer/token/letters.h @@ -156,13 +156,6 @@ inline constexpr char32_t LEX_UTF8_EXTRA_BYTE_MASK = 0xC0; inline constexpr char32_t LEX_CHAR_EOS = 0xFFFF; inline constexpr char32_t UNICODE_CODE_POINT_MAX = 0x10FFFF; inline constexpr char32_t UNICODE_INVALID_CP = UINT32_MAX; - -inline constexpr size_t JS_DOC_START_SIZE = 3; -inline constexpr size_t JS_DOC_END_SIZE = 2; -// NOLINTBEGIN(modernize-avoid-c-arrays) -inline constexpr char32_t JS_DOC_START_LEX[JS_DOC_START_SIZE] = {LEX_CHAR_ASTERISK, LEX_CHAR_ASTERISK, LEX_CHAR_LF}; -inline constexpr char32_t JS_DOC_END_LEX[JS_DOC_END_SIZE] = {LEX_CHAR_SLASH, LEX_CHAR_LF}; -// NOLINTEND(modernize-avoid-c-arrays) } // namespace ark::es2panda::lexer #endif diff --git a/ets2panda/linter/.gitignore b/ets2panda/linter/.gitignore index a84c3073e0abc2a9f5b74ed3b52cbc3f7084dbec..a9bcf7139e0c7bd0544a9b4a29435292ad9b21e8 100644 --- a/ets2panda/linter/.gitignore +++ b/ets2panda/linter/.gitignore @@ -3,6 +3,8 @@ bundle bundle-2.1.0.tgz dist node_modules +migration-results-statistics.json package-lock.json panda-tslinter-1.0.0.tgz -coverage/ \ No newline at end of file +coverage/ +test/local diff --git a/ets2panda/linter/arkanalyzer/src/Scene.ts b/ets2panda/linter/arkanalyzer/src/Scene.ts index cc41afcc09b4cf2ade58b3153885fc23c8b8ce55..1a594f52ac42ac5e636a0eb4a9eaf2d8a80acd2d 100644 --- a/ets2panda/linter/arkanalyzer/src/Scene.ts +++ b/ets2panda/linter/arkanalyzer/src/Scene.ts @@ -96,7 +96,7 @@ export class Scene { private options!: SceneOptions; private indexPathArray = ['Index.ets', 'Index.ts', 'Index.d.ets', 'Index.d.ts', 'index.ets', 'index.ts', 'index.d.ets', 'index.d.ts']; - private unhandledFilePaths: string[] = []; + private unhandledFilePaths: Set = new Set(); private unhandledSdkFilePaths: string[] = []; constructor() {} @@ -359,10 +359,10 @@ export class Scene { const arkFile: ArkFile = new ArkFile(FileUtils.getFileLanguage(file, this.fileLanguages)); arkFile.setScene(this); buildArkFileFromFile(file, this.realProjectDir, arkFile, this.projectName); - this.filesMap.set(arkFile.getFileSignature().toMapKey(), arkFile); + this.setFile(arkFile); } catch (error) { logger.error('Error parsing file:', file, error); - this.unhandledFilePaths.push(file); + this.unhandledFilePaths.add(file); return; } }); @@ -383,9 +383,11 @@ export class Scene { return; } const fileSignature = new FileSignature(this.getProjectName(), path.relative(this.getRealProjectDir(), projectFile)); - if (this.filesMap.has(fileSignature.toMapKey()) || this.isRepeatBuildFile(projectFile)) { + if (this.filesMap.has(fileSignature.toMapKey()) || this.isRepeatBuildFile(projectFile) || this.unhandledFilePaths.has(projectFile)) { return; } + // Here use unhandledFilePaths to temporarily store current file until add it to fileMaps to avoid recursively import issue. + this.unhandledFilePaths.add(projectFile); try { const arkFile = new ArkFile(FileUtils.getFileLanguage(projectFile, this.fileLanguages)); arkFile.setScene(this); @@ -396,16 +398,18 @@ export class Scene { break; } } - this.filesMap.set(arkFile.getFileSignature().toMapKey(), arkFile); const importInfos = arkFile.getImportInfos(); const repeatFroms: string[] = []; this.findDependencyFiles(importInfos, arkFile, repeatFroms); const exportInfos = arkFile.getExportInfos(); this.findDependencyFiles(exportInfos, arkFile, repeatFroms); + + // add currently file to files map after adding all its dependencies, and remove it from unhandledFilePaths + this.setFile(arkFile); + this.unhandledFilePaths.delete(projectFile); } catch (error) { logger.error('Error parsing file:', projectFile, error); - this.unhandledFilePaths.push(projectFile); return; } } @@ -446,28 +450,31 @@ export class Scene { } private parseFrom(from: string, arkFile: ArkFile): void { + // TODO: if there are more than one modules with the same name e.g. @lib1, here may got the wrong dependency + // It is better to loop all oh pkg with priority rather than the map key order. But it should be very complicated. + // Currently it is ok because it's with low probability and order error only affects type accuracy but has no other impact. if (/^@[a-z|\-]+?\/?/.test(from)) { for (const [ohPkgContentPath, ohPkgContent] of this.ohPkgContentMap) { - this.findDependenciesByOhPkg(ohPkgContentPath, ohPkgContent, from, arkFile); + this.findDependenciesByOhPkg(ohPkgContentPath, ohPkgContent, from); } } else if (/^([^@]*\/)([^\/]*)$/.test(from) || /^[\.\./|\.\.]+$/.test(from)) { this.findRelativeDependenciesByOhPkg(from, arkFile); } else if (/^[@a-zA-Z0-9]+(\/[a-zA-Z0-9]+)*$/.test(from)) { - this.findDependenciesByTsConfig(from, arkFile); + this.findDependenciesByTsConfig(from); } } - private findDependenciesByTsConfig(from: string, arkFile: ArkFile): void { + private findDependenciesByTsConfig(from: string): void { if (this.globalModule2PathMapping) { const paths: { [k: string]: string[] } = this.globalModule2PathMapping; - Object.keys(paths).forEach(key => this.parseTsConfigParms(paths, key, from, arkFile)); + Object.keys(paths).forEach(key => this.parseTsConfigParms(paths, key, from)); } } - private parseTsConfigParms(paths: { [k: string]: string[] }, key: string, from: string, arkFile: ArkFile): void { + private parseTsConfigParms(paths: { [k: string]: string[] }, key: string, from: string): void { const module2pathMapping = paths[key]; if (key.includes(ALL)) { - this.processFuzzyMapping(key, from, module2pathMapping, arkFile); + this.processFuzzyMapping(key, from, module2pathMapping); } else if (from.startsWith(key)) { let tail = from.substring(key.length, from.length); module2pathMapping.forEach(pathMapping => { @@ -475,12 +482,12 @@ export class Scene { if (this.baseUrl) { originPath = path.resolve(this.baseUrl, originPath); } - this.findDependenciesByRule(originPath, arkFile); + this.findDependenciesByRule(originPath); }); } } - private processFuzzyMapping(key: string, from: string, module2pathMapping: string[], arkFile: ArkFile): void { + private processFuzzyMapping(key: string, from: string, module2pathMapping: string[]): void { key = key.substring(0, key.indexOf(ALL) - 1); if (from.substring(0, key.indexOf(ALL) - 1) === key) { let tail = from.substring(key.indexOf(ALL) - 1, from.length); @@ -490,36 +497,36 @@ export class Scene { if (this.baseUrl) { originPath = path.join(this.baseUrl, originPath); } - this.findDependenciesByRule(originPath, arkFile); + this.findDependenciesByRule(originPath); }); } } - private findDependenciesByRule(originPath: string, arkFile: ArkFile): void { + private findDependenciesByRule(originPath: string): void { if ( - !this.findFilesByPathArray(originPath, this.indexPathArray, arkFile) && - !this.findFilesByExtNameArray(originPath, this.options.supportFileExts!, arkFile) + !this.findFilesByPathArray(originPath, this.indexPathArray) && + !this.findFilesByExtNameArray(originPath, this.options.supportFileExts!) ) { logger.trace(originPath + 'module mapperInfo is not found!'); } } - private findFilesByPathArray(originPath: string, pathArray: string[], arkFile: ArkFile): boolean { + private findFilesByPathArray(originPath: string, pathArray: string[]): boolean { for (const pathInfo of pathArray) { const curPath = path.join(originPath, pathInfo); if (fs.existsSync(curPath) && !this.isRepeatBuildFile(curPath)) { - this.addFileNode2DependencyGrap(curPath, arkFile); + this.addFileNode2DependencyGrap(curPath); return true; } } return false; } - private findFilesByExtNameArray(originPath: string, pathArray: string[], arkFile: ArkFile): boolean { + private findFilesByExtNameArray(originPath: string, pathArray: string[]): boolean { for (const pathInfo of pathArray) { const curPath = originPath + pathInfo; if (fs.existsSync(curPath) && !this.isRepeatBuildFile(curPath)) { - this.addFileNode2DependencyGrap(curPath, arkFile); + this.addFileNode2DependencyGrap(curPath); return true; } } @@ -540,10 +547,10 @@ export class Scene { let originPath = this.getOriginPath(from, arkFile); if (fs.existsSync(path.join(originPath, OH_PACKAGE_JSON5))) { for (const [ohPkgContentPath, ohPkgContent] of this.ohPkgContentMap) { - this.findDependenciesByOhPkg(ohPkgContentPath, ohPkgContent, from, arkFile); + this.findDependenciesByOhPkg(ohPkgContentPath, ohPkgContent, from); } } - this.findDependenciesByRule(originPath, arkFile); + this.findDependenciesByRule(originPath); } private findDependenciesByOhPkg( @@ -551,8 +558,7 @@ export class Scene { ohPkgContentInfo: { [k: string]: unknown; }, - from: string, - arkFile: ArkFile + from: string ): void { //module name @ohos/from const ohPkgContent: { [k: string]: unknown } | undefined = ohPkgContentInfo; @@ -562,21 +568,21 @@ export class Scene { if (ohPkgContent.main) { originPath = path.join(ohPkgContentPath.toString().replace(OH_PACKAGE_JSON5, ''), ohPkgContent.main.toString()); if (ohPkgContent.dependencies) { - this.getDependenciesMapping(ohPkgContent.dependencies, ohPkgContentPath, from, arkFile); + this.getDependenciesMapping(ohPkgContent.dependencies, ohPkgContentPath, from); } else if (ohPkgContent.devDependencies) { - this.getDependenciesMapping(ohPkgContent.devDependencies, ohPkgContentPath, from, arkFile); + this.getDependenciesMapping(ohPkgContent.devDependencies, ohPkgContentPath, from); } else if (ohPkgContent.dynamicDependencies) { // dynamicDependencies not support } - this.addFileNode2DependencyGrap(originPath, arkFile); + this.addFileNode2DependencyGrap(originPath); } - if (!this.findFilesByPathArray(originPath, this.indexPathArray, arkFile)) { + if (!this.findFilesByPathArray(originPath, this.indexPathArray)) { logger.trace(originPath + 'module mapperInfo is not found!'); } } } - private getDependenciesMapping(dependencies: object, ohPkgContentPath: string, from: string, arkFile: ArkFile): void { + private getDependenciesMapping(dependencies: object, ohPkgContentPath: string, from: string): void { for (let [moduleName, modulePath] of Object.entries(dependencies)) { logger.debug('dependencies:' + moduleName); if (modulePath.startsWith('file:')) { @@ -585,7 +591,7 @@ export class Scene { const innerOhpackagePath = path.join(ohPkgContentPath.replace(OH_PACKAGE_JSON5, ''), modulePath.toString(), OH_PACKAGE_JSON5); if (!this.ohPkgContentMap.has(innerOhpackagePath)) { const innerModuleOhPkgContent = fetchDependenciesFromFile(innerOhpackagePath); - this.findDependenciesByOhPkg(innerOhpackagePath, innerModuleOhPkgContent, from, arkFile); + this.findDependenciesByOhPkg(innerOhpackagePath, innerModuleOhPkgContent, from); } } } @@ -595,9 +601,8 @@ export class Scene { return path.resolve(parentPath, from); } - private addFileNode2DependencyGrap(filePath: string, arkFile: ArkFile): void { + private addFileNode2DependencyGrap(filePath: string): void { this.getDependencyFilesDeeply(filePath); - this.filesMap.set(arkFile.getFileSignature().toMapKey(), arkFile); } private buildSdk(sdkName: string, sdkPath: string): void { @@ -707,7 +712,7 @@ export class Scene { * @example * 1. get real project directory, such as: ```typescript - let projectDir = projectScene.getRealProjectDir(); + let projectDir = projectScene.getRealProjectDir(); ``` */ public getRealProjectDir(): string { @@ -761,7 +766,7 @@ export class Scene { * Returns the absolute file paths that cannot be handled currently. */ public getUnhandledFilePaths(): string[] { - return this.unhandledFilePaths; + return Array.from(this.unhandledFilePaths); } /* diff --git a/ets2panda/linter/arkanalyzer/src/core/base/Constant.ts b/ets2panda/linter/arkanalyzer/src/core/base/Constant.ts index cc7da1df70180d6a6d9b7df638fde0c7dedb7e7e..f6cd7dc0bf1d33e703f16686bbc99287f2863f1e 100644 --- a/ets2panda/linter/arkanalyzer/src/core/base/Constant.ts +++ b/ets2panda/linter/arkanalyzer/src/core/base/Constant.ts @@ -78,8 +78,8 @@ export class BooleanConstant extends Constant { } export class NumberConstant extends Constant { - constructor(value: number) { - super(value.toString(), NumberType.getInstance()); + constructor(value: string) { + super(value, NumberType.getInstance()); } } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts b/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts index 5ed77fbe20408949b807cf82f9d2b54df431cd93..c30a47b9685e4ab31bdac126deafd62e5aee6bd9 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts @@ -110,7 +110,10 @@ export class ArkIRTransformer { let index = 0; for (const methodParameter of this.declaringMethod.getParameters()) { const parameterRef = new ArkParameterRef(index, methodParameter.getType()); - stmts.push(new ArkAssignStmt(this.arkValueTransformer.addNewLocal(methodParameter.getName(), parameterRef.getType()), parameterRef)); + const stmt = new ArkAssignStmt(this.arkValueTransformer.addNewLocal(methodParameter.getName(), parameterRef.getType()), parameterRef); + const paramPosition = this.declaringMethod.getBodyBuilder()?.getParamsPositions().get(methodParameter.getName()) ?? FullPosition.DEFAULT; + stmt.setOperandOriginalPositions([paramPosition, FullPosition.DEFAULT]); + stmts.push(stmt); index++; } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts b/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts index a26b46ee66fc266a936d9a37abda91b06dfedc2e..cb83fff5901d5b74610d3a6e931112da6944d52c 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts @@ -1675,7 +1675,7 @@ export class ArkValueTransformer { let constant: Constant | null = null; switch (syntaxKind) { case ts.SyntaxKind.NumericLiteral: - constant = ValueUtil.getOrCreateNumberConst(parseFloat((literalNode as ts.NumericLiteral).text)); + constant = ValueUtil.getOrCreateNumberConst((literalNode as ts.NumericLiteral).getText(this.sourceFile)); break; case ts.SyntaxKind.BigIntLiteral: constant = ValueUtil.createBigIntConst(BigInt((literalNode as ts.BigIntLiteral).text.slice(0, -1))); diff --git a/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts b/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts index c670ead482c19720969b0afb7ca33035ab3fb9e1..9fd0a38200a833df66b5463a4156654f4f283c59 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts @@ -638,6 +638,12 @@ export class IRInference { baseType.getClassSignature().getClassName() === DEFAULT_ARK_CLASS_NAME || ((property instanceof ArkField || property instanceof ArkMethod) && property.isStatic()); signature = property instanceof ArkMethod ? property.getSignature().getDeclaringClassSignature() : baseType.getClassSignature(); + } else if (baseType instanceof ArrayType) { + const property = propertyAndType?.[0]; + if (property instanceof ArkField) { + return property.getSignature(); + } + return null; } else if (baseType instanceof AnnotationNamespaceType) { staticFlag = true; signature = baseType.getNamespaceSignature(); diff --git a/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts b/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts index a2a2b250674cb07043f273cae8c67ce6f403a228..b5854a3205aa3483eb2b4ec8e8ea9a054d65c2fd 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts @@ -300,7 +300,7 @@ export class TypeInference { } else if (use instanceof ArkInstanceFieldRef && fieldRef instanceof ArkArrayRef && stmt instanceof ArkAssignStmt) { const index = fieldRef.getIndex(); if (index instanceof Constant && index.getType() instanceof StringType) { - const local = arkMethod?.getBody()?.getLocals().get(index.getValue()); + const local = this.getLocalFromMethodBody(index.getValue(), arkMethod); if (local) { fieldRef.setIndex(local); } @@ -309,6 +309,22 @@ export class TypeInference { } } + private static getLocalFromMethodBody(name: string, arkMethod: ArkMethod): Local | null { + const local = arkMethod?.getBody()?.getLocals().get(name); + if (local) { + return local; + } + const globalRef = arkMethod?.getBody()?.getUsedGlobals()?.get(name); + if (globalRef === undefined || !(globalRef instanceof GlobalRef)) { + return null; + } + const ref = globalRef.getRef(); + if (ref !== null && ref instanceof Local) { + return ref; + } + return null; + } + public static parseArkExport2Type(arkExport: ArkExport | undefined | null): Type | null { if (!arkExport) { return null; @@ -693,6 +709,8 @@ export class TypeInference { return null; } propertyAndType = this.inferClassFieldType(declareClass, baseType, fieldName); + } else if (baseType instanceof ArrayType) { + propertyAndType = this.inferArrayFieldType(declareClass, fieldName); } else if (baseType instanceof AnnotationNamespaceType) { const namespace = declareClass.getDeclaringArkFile().getScene().getNamespace(baseType.getNamespaceSignature()); if (namespace) { @@ -739,6 +757,18 @@ export class TypeInference { return null; } + private static inferArrayFieldType(declareClass: ArkClass, fieldName: string): [ArkField, Type] | null { + const arrayClass = declareClass.getDeclaringArkFile().getScene().getSdkGlobal(Builtin.ARRAY); + if (arrayClass instanceof ArkClass) { + const property = ModelUtils.findPropertyInClass(fieldName, arrayClass); + if (property instanceof ArkField) { + return [property, property.getType()]; + } + return null; + } + return null; + } + /** * Find out the original object and type for a given base name. * It returns original type. diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts b/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts index 8a29e565b84e8db412f6ef951fca7c0046516794..fd33a451da8b10230640a43bd642442539c76f64 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts @@ -18,7 +18,7 @@ import { BigIntConstant, BooleanConstant, Constant, NullConstant, NumberConstant export const EMPTY_STRING = ''; export class ValueUtil { - private static readonly NumberConstantCache: Map = new Map(); + private static readonly NumberConstantCache: Map = new Map(); public static readonly EMPTY_STRING_CONSTANT = new StringConstant(EMPTY_STRING); /* @@ -29,11 +29,21 @@ export class ValueUtil { this.NumberConstantCache.clear(); } - public static getOrCreateNumberConst(n: number): Constant { - let constant = this.NumberConstantCache.get(n); + /* + * Get the number constant instance according to its value, and create a new one if didn't find. + * In order to distinguish 1, 1.0, 0x0001, here support to find with string instead of only number. + */ + public static getOrCreateNumberConst(n: number | string): Constant { + let nStr: string; + if (typeof n === 'number') { + nStr = n.toString(); + } else { + nStr = n; + } + let constant = this.NumberConstantCache.get(nStr); if (constant === undefined) { - constant = new NumberConstant(n); - this.NumberConstantCache.set(n, constant); + constant = new NumberConstant(nStr); + this.NumberConstantCache.set(nStr, constant); } return constant; } diff --git a/ets2panda/linter/arkanalyzer/src/core/graph/Cfg.ts b/ets2panda/linter/arkanalyzer/src/core/graph/Cfg.ts index 4ef2fadcaf347b848862c8e586dc20911828d8fb..62b9e3230a8dbe43fe011292b153a9f53bfcdb0e 100644 --- a/ets2panda/linter/arkanalyzer/src/core/graph/Cfg.ts +++ b/ets2panda/linter/arkanalyzer/src/core/graph/Cfg.ts @@ -22,6 +22,8 @@ import { BasicBlock } from './BasicBlock'; import Logger, { LOG_MODULE_TYPE } from '../../utils/logger'; import { ArkStaticInvokeExpr } from '../base/Expr'; import { Value } from '../base/Value'; +import { AbstractFieldRef } from '../base/Ref'; + const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'BasicBlock'); /** @@ -176,6 +178,14 @@ export class Cfg { return; } } + } else if (value instanceof AbstractFieldRef) { + // here is used for adding this stmt to array/tuple index local, such as a = arr[i] + for (const local of locals) { + if (local.getName() === value.getFieldName()) { + local.addUsedStmt(stmt); + return; + } + } } } diff --git a/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts b/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts index 789e940e89e7af354526b94655f8b339f45436b5..dd275f73247f4e6c56ab19710b54bc79478efcb8 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts @@ -532,9 +532,7 @@ export class ArkMethod extends ArkBaseModel implements ArkExport { } public getReturnStmt(): Stmt[] { - return this.getCfg()! - .getStmts() - .filter(stmt => stmt instanceof ArkReturnStmt); + return this.getCfg()?.getStmts().filter(stmt => stmt instanceof ArkReturnStmt) ?? []; } public setViewTree(viewTree: ViewTree): void { diff --git a/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkMethodBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkMethodBuilder.ts index cb00c3dff71d660b405974c57774b3914e7cb2ba..4dcc8b5216ed9ad2046713a6c326a0ab7a762641 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkMethodBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkMethodBuilder.ts @@ -43,6 +43,7 @@ import { ANONYMOUS_METHOD_PREFIX, CALL_SIGNATURE_NAME, DEFAULT_ARK_CLASS_NAME, D import { ArkSignatureBuilder } from './ArkSignatureBuilder'; import { IRUtils } from '../../common/IRUtils'; import { ArkErrorCode } from '../../common/ArkError'; +import { FullPosition } from '../../base/Position'; const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'ArkMethodBuilder'); @@ -98,7 +99,8 @@ export function buildArkMethodFromArkClass( // build methodDeclareSignatures and methodSignature as well as corresponding positions const methodName = buildMethodName(methodNode, declaringClass, sourceFile, declaringMethod); const methodParameters: MethodParameter[] = []; - buildParameters(methodNode.parameters, mtd, sourceFile).forEach(parameter => { + let paramsPosition: Map = new Map(); + buildParameters(methodNode.parameters, mtd, sourceFile, paramsPosition).forEach(parameter => { buildGenericType(parameter.getType(), mtd); methodParameters.push(parameter); }); @@ -114,6 +116,7 @@ export function buildArkMethodFromArkClass( mtd.setLine(line + 1); mtd.setColumn(character + 1); let bodyBuilder = new BodyBuilder(mtd.getSignature(), methodNode, mtd, sourceFile); + bodyBuilder.setParamsPositions(paramsPosition); mtd.setBodyBuilder(bodyBuilder); } else { mtd.setDeclareSignatures(methodSignature); diff --git a/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts index 8a6286bd30e384e17be1bae4bfbfd520df6bcbd1..6b3d2103230de6fb870dd4d3c9e88651e2b04548 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts @@ -25,6 +25,7 @@ import { ArkParameterRef, ArkStaticFieldRef, ClosureFieldRef, GlobalRef } from ' import { ArkAliasTypeDefineStmt, ArkAssignStmt, ArkInvokeStmt, ArkReturnStmt } from '../../base/Stmt'; import { AliasType, ArrayType, ClosureType, FunctionType, LexicalEnvType, Type, UnclearReferenceType, UnionType } from '../../base/Type'; import { AbstractInvokeExpr, ArkPtrInvokeExpr } from '../../base/Expr'; +import { FullPosition } from '../../base/Position'; type NestedMethodChain = { parent: ArkMethod; @@ -34,9 +35,11 @@ type NestedMethodChain = { export class BodyBuilder { private cfgBuilder: CfgBuilder; private globals?: Map; + private paramsPosition: Map; constructor(methodSignature: MethodSignature, sourceAstNode: ts.Node, declaringMethod: ArkMethod, sourceFile: ts.SourceFile) { this.cfgBuilder = new CfgBuilder(sourceAstNode, methodSignature.getMethodSubSignature().getMethodName(), declaringMethod, sourceFile); + this.paramsPosition = new Map(); } public build(): ArkBody | null { @@ -65,6 +68,14 @@ export class BodyBuilder { this.globals = globals; } + public getParamsPositions(): Map { + return this.paramsPosition; + } + + public setParamsPositions(paramsPosition: Map): void { + this.paramsPosition = paramsPosition; + } + /** * Find out all locals in the parent method which are used by the childrenChain, these locals are the closures of the root node of the childrenChain. * childrenChain contains all nested method from the root node of the childrenChain. diff --git a/ets2panda/linter/arkanalyzer/src/core/model/builder/builderUtils.ts b/ets2panda/linter/arkanalyzer/src/core/model/builder/builderUtils.ts index 7e5c218116d6583bbdbc6250544992cce55f5b01..b2e5dbf3f809a310a39998acb2bb5ee9ff3595c4 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/builder/builderUtils.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/builder/builderUtils.ts @@ -55,6 +55,7 @@ import { ArkSignatureBuilder } from './ArkSignatureBuilder'; import { ArkInstanceFieldRef } from '../../base/Ref'; import { Local } from '../../base/Local'; import { Value } from '../../base/Value'; +import { FullPosition } from '../../base/Position'; const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'builderUtils'); @@ -258,7 +259,8 @@ function buildArrayBindingPatternParam(methodParameter: MethodParameter, paramNa methodParameter.setArrayElements(elements); } -export function buildParameters(params: ts.NodeArray, arkInstance: ArkMethod | ArkField, sourceFile: ts.SourceFile): MethodParameter[] { +export function buildParameters(params: ts.NodeArray, arkInstance: ArkMethod | ArkField, sourceFile: ts.SourceFile, + paramsPosition: Map): MethodParameter[] { let parameters: MethodParameter[] = []; params.forEach(parameter => { let methodParameter = new MethodParameter(); @@ -266,10 +268,13 @@ export function buildParameters(params: ts.NodeArray, arkI // name if (ts.isIdentifier(parameter.name)) { methodParameter.setName(parameter.name.text); + paramsPosition.set(parameter.name.text, FullPosition.buildFromNode(parameter.name, sourceFile)); } else if (ts.isObjectBindingPattern(parameter.name)) { buildObjectBindingPatternParam(methodParameter, parameter.name); + paramsPosition.set('ObjectBindingPattern', FullPosition.buildFromNode(parameter.name, sourceFile)); } else if (ts.isArrayBindingPattern(parameter.name)) { buildArrayBindingPatternParam(methodParameter, parameter.name); + paramsPosition.set('ArrayBindingPattern', FullPosition.buildFromNode(parameter.name, sourceFile)); } else { logger.warn('Parameter name is not identifier, ObjectBindingPattern nor ArrayBindingPattern, please contact developers to support this!'); } diff --git a/ets2panda/linter/docs/rules-cn/recipe1.md b/ets2panda/linter/docs/rules-cn/recipe1.md new file mode 100644 index 0000000000000000000000000000000000000000..99588f7145f21fa19d30476bbcde24d3b8e9096a --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe1.md @@ -0,0 +1,23 @@ +## enum的key不能是字符串 + +**规则:**`arkts-identifiers-as-prop-names` + +**级别:error** + +ArkTS1.2不支持将字符串作为class、interface、enum等属性或元素的名称,需要使用标识符来表示。 + +**ArkTS1.1** + +```typescript +enum A{ + 'red' = '1' +} +``` + +**ArkTS1.2** + +```typescript +enum A{ + red = '1' +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe111.md b/ets2panda/linter/docs/rules-cn/recipe111.md new file mode 100644 index 0000000000000000000000000000000000000000..87225ec0561116f7da7019d005920c245ed1e859 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe111.md @@ -0,0 +1,27 @@ +## enum中不支持成员为不同类型数据 + +**规则:**`arkts-no-enum-mixed-types` + +**级别:error** + +enum用来表示一组离散的数据,使用浮点数据不符合enum的设计理念。使用浮点数据可能造成精度损失的问题。因此,ArkTS1.2中enum的值必须为整型数据。 + +**ArkTS1.1** + +```typescript +enum Size { + UP = 1.5, + MIDDLE = 1, + DOWN = 0.75 +} +``` + +**ArkTS1.2** + +```typescript +enum Size{ + UP = 1, + MIDDLE = 2, + DOWN = 3 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe134.md b/ets2panda/linter/docs/rules-cn/recipe134.md new file mode 100644 index 0000000000000000000000000000000000000000..2a35eec54b33cb3720c52a031af40cbbca6258ee --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe134.md @@ -0,0 +1,33 @@ +## 不支持确定赋值断言 + +**规则:**`arkts-no-definite-assignment` + +**级别:error** + +ArkTS1.2不支持确定赋值断言。改为在声明变量的同时为变量赋值。 + +**ArkTS1.1** + +```typescript +let x!: number // 提示:在使用前将x初始化 + +initialize(); + +function initialize() { + x = 10; +} + +console.log('x = ' + x); +``` + +**ArkTS1.2** + +```typescript +function initialize(): number { + return 10; +} + +let x: number = initialize(); + +console.log('x = ' + x); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe137.md b/ets2panda/linter/docs/rules-cn/recipe137.md new file mode 100644 index 0000000000000000000000000000000000000000..04cf67cf4283a014cab6baf212d9e224df91e0b1 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe137.md @@ -0,0 +1,29 @@ +## 不支持globalThis + +**规则:**`arkts-no-globalthis` + +**级别:error** + +由于ArkTS1.2不支持动态更改对象的布局,因此不支持全局作用域和globalThis。 + +**ArkTS1.1** + +```typescript +// 全局文件中 +var abc = 100; + +// 从上面引用'abc' +let x = globalThis.abc; +``` + +**ArkTS1.2** + +```typescript +// file1 +export let abc: number = 100; + +// file2 +import * as M from 'file1' + +let x = M.abc; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe139.md b/ets2panda/linter/docs/rules-cn/recipe139.md new file mode 100644 index 0000000000000000000000000000000000000000..a4fd6a5cef173eb58db292b41ae5406a95cdb7fc --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe139.md @@ -0,0 +1,81 @@ +## 不支持为函数增加属性 + +**规则:**`arkts-no-func-props` + +**级别:error** + +ArkTS1.2上不支持在函数上动态添加属性。 + +**ArkTS1.1** + +```typescript +function foo(path: string): void { + console.log(path) +} +foo.baz = 1 + +const obj = { + foo(path: string): void { + console.log(path); + } +}; +obj.foo.baz = 2; // 违反规则 + +function createLogger() { + function log(message: string) { + console.log(message); + } + log.level = "debug"; // 违反规则 + return log; +} + +const logger = createLogger(); +console.log(logger.level); + +function counter() { + counter.count = (counter.count || 0) + 1; // 违反规则 + return counter.count; +} +console.log(counter()); +``` + +**ArkTS1.2** + +```typescript +class T { + static foo(path: string): void { + console.log(path) + } + static bar: number = 1 +} + +class T { + static foo(path: string): void { + console.log(path); + } + + static baz: number = 2; +} +T.foo("example"); +console.log(T.baz); + +class Logger { + static level = "debug"; + + static log(message: string) { + console.log(message); + } +} +Logger.log("test"); +console.log(Logger.level); + +class Counter { + static count = 0; + + static increment() { + this.count += 1; + return this.count; + } +} +console.log(Counter.increment()); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe140.md b/ets2panda/linter/docs/rules-cn/recipe140.md new file mode 100644 index 0000000000000000000000000000000000000000..78fb062c4cbfcf5c2f20aab8cb505b863763b5d2 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe140.md @@ -0,0 +1,39 @@ +## 不支持Funcion.bind方法 + +**规则:**`arkts-no-func-bind` + +**级别:error** + +ArkTS不允许使用标准库函数Function.bind。标准库使用这些函数来显式设置被调用函数的this参数。 + +**ArkTS1.1** + +```typescript +class MyClass { + constructor(public name: string) {} + + greet() { + console.log(`Hello, my name is ${this.name}`); + } +} + +const instance = new MyClass("Alice"); +const boundGreet = instance.greet.bind(instance); // 违反规则,不允许使用 Function.bind +boundGreet(); +``` + +**ArkTS1.2** + +```typescript +class MyClass { + constructor(public name: string) {} + + greet() { + console.log(`Hello, my name is ${this.name}`); + } +} + +const instance = new MyClass("Alice"); +const boundGreet = () => instance.greet(); // 使用箭头函数 +boundGreet(); // Hello, my name is Alice +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe144.md b/ets2panda/linter/docs/rules-cn/recipe144.md new file mode 100644 index 0000000000000000000000000000000000000000..ae7a8b470b828f703eaf3084096e81cf65c89aa5 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe144.md @@ -0,0 +1,18 @@ +## 共享对象不添加装饰器@Sendable + +**规则:** arkts-limited-stdlib-no-sendable-decorator + +**级别:** error + +新增对象天然共享特性,不再依赖Sendable特性,无需添加@Sendable装饰器。 + +**ArkTS1.1** +```typescript +@Sendable +class A {} +``` + +**ArkTS1.2** +```typescript +class A {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe149.md b/ets2panda/linter/docs/rules-cn/recipe149.md new file mode 100644 index 0000000000000000000000000000000000000000..ff1733a50330fed88de373cc6a9b022d51064f80 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe149.md @@ -0,0 +1,30 @@ +## 不支持将类作为对象 + +**规则:**`arkts-no-classes-as-obj` + +**级别:error** + +在ArkTS中,class声明的是一个新的类型,不是一个值。因此,不支持将class用作对象(例如将class赋值给一个变量)。 + +**ArkTS1.1** + +```typescript +class MyClass { + constructor(public name: string) {} +} + +let obj = MyClass; // 违反规则 +``` + +**ArkTS1.2** + +```typescript +class MyClass { + constructor(name: string) {} +} + +// 需要通过反射来实现 +let className = "path.to.MyClass"; +let linker = Class.ofCaller()!.getLinker(); +let classType: ClassType | undefined = linker.getType(className) as ClassType; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe183.md b/ets2panda/linter/docs/rules-cn/recipe183.md new file mode 100644 index 0000000000000000000000000000000000000000..d9f84dcff099c784046eeb51266cbcad0d2532c8 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe183.md @@ -0,0 +1,71 @@ +## 对象字面量只包含属性不包含方法 + +**规则:**`arkts-obj-literal-props` + +**级别:error** + +ArkTS1.2中不支持在对象字面量中定义方法。因为静态语言中类的方法被所有实例所共享,无法通过对象字面量重新定义方法。 + +**ArkTS1.1** + +```typescript +class A { + foo: () => void = () => {} +} + +let a: A = { + foo() { // 违反规则 + console.log('hello') + } +} + +interface Person { + sayHello: () => void; +} + +let p: Person = { + sayHello() { // 违反规则,方法定义方式错误 + console.log('Hi'); + } +}; + +type Handler = { + foo(): void; +}; + +let handler: Handler = { + foo() { // 违反规则 + console.log("Executing handler"); + } +}; +``` + +**ArkTS1.2** + +```typescript +class A { + foo : () => void = () => {} +} + +let a: A = { + foo: () => { + console.log('hello') + } +} + +let p: Person = { + sayHello: () => { // 使用属性赋值方式 + console.log('Hi'); + } +}; + +type Handler = { + foo: () => void; +}; + +let handler: Handler = { + foo: () => { // 修正方法定义方式 + console.log("Executing handler"); + } +}; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe184.md b/ets2panda/linter/docs/rules-cn/recipe184.md new file mode 100644 index 0000000000000000000000000000000000000000..445b8e0a8b7788e1dc3b8c14fb5c386a12434a7c --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe184.md @@ -0,0 +1,29 @@ +## 不支持可选方法 + +**规则:**`arkts-optional-methods` + +**级别:error** + +ArkTS1.2中类的方法被所有类的实例所共享,增加可选方法的支持会增加开发者判断空值的成本,影响性能。 + +**ArkTS1.1** + +```typescript +interface InterfaceA { + aboutToDisappear?(): void +} +class ClassA { + aboutToDisappear?(): void {} +} +``` + +**ArkTS1.2** + +```typescript +interface InterfaceA { + aboutToDisappear?: () => void +} +class ClassA { + aboutToDisappear?: () => void = () => {} +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe189.md b/ets2panda/linter/docs/rules-cn/recipe189.md new file mode 100644 index 0000000000000000000000000000000000000000..4fcbbaa50387c4624eadfc921c98eb6e9f7c43be --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe189.md @@ -0,0 +1,58 @@ +## 数值类型语义变化 + +**规则:** `arkts-numeric-semantic` + +**级别:** error + +在ArkTS1.2中,为了获得更好的执行效率,整型数字字面量默认是int类型。 + +**ArkTS1.1** +```typescript +let n = 1; +console.log(n / 2) // output: 0.5 + +let arr = [1, 2, 3]; + +function multiply(x = 2, y = 3) { // 需要明确类型 + return x * y; +} + +function divide(x: number, y: number) { + return x / y; +} // 函数返回值 + +let num = Math.floor(4.8); // num 可能是 int +let value = parseInt("42"); // value 可能是 int + +function identity(value: T): T { + return value; +} +identity(42); // 42 可能推导为 int +``` + +**ArkTS1.2** +```typescript +let n: number = 1; +console.log(n / 2) // output: 0.5 + +let m = 1; +console.log(m / 2) // output: 0 + +let arr: number[] = [1, 2, 3]; + +function multiply(x: number = 2, y: number = 3): number { + return x * y; +} + +function divide(x: number, y: number): number { + return x / y; +} + +let num: number = Math.floor(4.8); +let value: number = parseInt("42"); + +function identity(value: T): T { + return value; +} +identity(42 as number); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe190.md b/ets2panda/linter/docs/rules-cn/recipe190.md new file mode 100644 index 0000000000000000000000000000000000000000..ff7b37e4608da281ade3f626870c7eaa5055ccf0 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe190.md @@ -0,0 +1,47 @@ +## 函数类型 + +**规则:**`arkts-incompatible-function-types` + +**级别:error** + +TypeScript允许对函数类型的变量进行更宽松的赋值,而在ArkTS1.2中,将对函数类型的赋值进行更严格的检查。函数类型转换时,参数遵循逆变(Contravariance)规则,返回类型遵循协变(Covariance)规则。 + +**ArkTS1.1** + +```typescript +type FuncType = (p: string) => void; +let f1: FuncType = + (p: string): number => { + return 0 + } +let f2: FuncType = (p: any): void => {}; + +class Animal {} +class Dog extends Animal {} +type FuncType = () => Animal; +let f: FuncType = (): Dog => new Dog(); // 在 TypeScript 允许,但在 ArkTS 可能不允许 + +type FuncType2 = (dog: Dog) => void; +let f: FuncType2 = (animal: Animal) => {}; // 违反规则 +``` + +**ArkTS1.2** + +```typescript +type FuncType = (p: string) => void +let f1: FuncType = + (p: string) => { + ((p: string): number => { + return 0 + })(p) + } +let f2: FuncType = (p: string): void => {}; + +class Animal {} +class Dog extends Animal {} +type FuncType = () => Animal; +let f: FuncType = (): Animal => new Animal();// 返回 `Animal` + +type FuncType2 = (dog: Dog) => void; +let f: FuncType = (dog: Dog) => {}; // 参数类型严格匹配 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe191.md b/ets2panda/linter/docs/rules-cn/recipe191.md new file mode 100644 index 0000000000000000000000000000000000000000..18ee7f34d3555c2cd5a948cb54dad86b22d64ec9 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe191.md @@ -0,0 +1,23 @@ +## 内存默认共享,不提供ASON + +**规则:** arkts-no-need-stdlib-ason + +**级别:** error + +新增对象天然共享特性,不再依赖Sendable特性,ASON.stringify()方法调用可直接更改为JSON.stringify(),且删除ArkTSUtils.前缀。 + +**ArkTS1.1** +```typescript +import { collections } from '@kit.ArkTS'; +import { ArkTSUtils } from '@kit.ArkTS'; +let arr = new collections.Array(1, 2, 3); +let str = ArkTSUtils.ASON.stringify(arr); +console.info(str); +``` + +**ArkTS1.2** +```typescript +let arr = new Array(1, 2, 3); +let str = JSON.stringify(arr); +console.info(str); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe192.md b/ets2panda/linter/docs/rules-cn/recipe192.md new file mode 100644 index 0000000000000000000000000000000000000000..64225cc939d8a5340ba4b0f2bf22f6aae0135ba4 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe192.md @@ -0,0 +1,41 @@ +## void类型只能用在返回类型的场景 + +**规则:** `arkts-limited-void-type` + +**级别:** error + +在ArkTS1.2中,void仅作为类型使用。void类型没有实体。 + +**ArkTS1.1** +```typescript +let s: void = foo(); +let t: void | number = foo(); + +function process(input: T): T { + return input; +} +let result = process(foo()); + +type VoidAlias = void; + +let { x }: { x: void } = { x: foo() }; + +function execute(callback: void) { + callback(); +} + +let x = fun() as void; +``` + +**ArkTS1.2** +```typescript +function foo(): void {} +foo(); + +function bar(): void {} + +function execute(callback: () => void) { + callback(); +} +fun(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe193.md b/ets2panda/linter/docs/rules-cn/recipe193.md new file mode 100644 index 0000000000000000000000000000000000000000..7b93aea7f578c8edc25625b2c26e706c18b8bfec --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe193.md @@ -0,0 +1,44 @@ +## 不支持void操作符 + +**规则:** `arkts-no-void-operator` + +**级别:** error + +在ArkTS1.2中,undefined作为关键字不能作为变量名称,因此不需要通过void操作符获取undefined。 + +**ArkTS1.1** +```typescript +let s = void 'hello'; +console.log(s); // output: undefined + +let a = 5; +let b = void (a + 1); + +function logValue(value: any) { + console.log(value); +} +logValue(void 'data'); + +let fn = () => void 0; +``` + +**ArkTS1.2** +```typescript +(() => { + 'hello' + return undefined; +})() + +let a = 5; +let b = (() => { + a + 1; + return undefined; +})(); // 替换为 IIFE + +logValue((() => { + 'data'; + return undefined; +})()); // 替换为 IIFE + +let fn = () => undefined; // 直接返回 `undefined` +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe198.md b/ets2panda/linter/docs/rules-cn/recipe198.md new file mode 100644 index 0000000000000000000000000000000000000000..792bff4731ad7946dd933dff1c676d27340ffba6 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe198.md @@ -0,0 +1,53 @@ +## 不支持类TS重载 + +**规则:**`arkts-no-ts-overload` + +**级别:error** + +ArkTS1.2不支持TS-like的重载,使用不同的函数体可以提高执行效率。 + +**ArkTS1.1** + +```typescript +function foo(): void +function foo(x: string): void +function foo(x?: string): void { // 违反规则 + /*body*/ +} + +function sum(x: number, y: number): number; +function sum(x: number, y: number, z: number): number; +function sum(x: number, y: number, z?: number): number { // 违反规则 + return z ? x + y + z : x + y; +} + +function foo(): string; +function foo(x: number): number; +function foo(x?: number): string | number { // 违反规则 + return x !== undefined ? x * 2 : "default"; +} +``` + +**ArkTS1.2** + +```typescript +function foo(x?: string): void { + /*body*/ +} + +function sumTwo(x: number, y: number): number { // 独立实现 + return x + y; +} + +function sumThree(x: number, y: number, z: number): number { // 独立实现 + return x + y + z; +} + +function fooString(): string { // 独立实现 + return "default"; +} + +function fooNumber(x: number): number { // 独立实现 + return x * 2; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe199.md b/ets2panda/linter/docs/rules-cn/recipe199.md new file mode 100644 index 0000000000000000000000000000000000000000..597435946366b65f4492e4aeec1900056431f8c7 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe199.md @@ -0,0 +1,19 @@ +## 原生容器默认共享,不需要Sendable容器 + +**规则:** arkts-no-need-stdlib-sendable-containers + +**级别:** error + +新增对象天然共享特性,不再依赖Sendable特性。可直接使用ArkTS1.2原生容器,删除collections.前缀。 + +**ArkTS1.1** +```typescript +import { collections } from '@kit.ArkTS'; + +let array = new collections.Array(); +``` + +**ArkTS1.2** +```typescript +let array = new Array(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe202.md b/ets2panda/linter/docs/rules-cn/recipe202.md new file mode 100644 index 0000000000000000000000000000000000000000..c7a7058673af3dc5a7b5bffd963f5d3ca07e99b8 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe202.md @@ -0,0 +1,61 @@ +## 限定使用字面量类型 + +**规则:** `arkts-limited-literal-types` + +**级别:** error + +ArkTS1.2不支持数字字面量类型,布尔字面量类型。 + +ArkTS1.2提供了更多细化的数值类型供开发者选择,更关注数值的范围而非某个特定的数字值,同时,为了更好的代码简洁性和避免引入歧义,不引入复杂的数值字面量类型语法。 + +**ArkTS1.1** +```typescript +let n1: 1 = 1; +let n2: 0.1 = 0.1; +let f: true = true; + +function getOne(): 1 { + return 1; +} +function isAvailable(): true { + return true; +} + +function setFlag(flag: true) { + console.log(flag); +} +function setPrecision(precision: 0.1) { + console.log(precision); +} + +interface Config { + readonly enable: true; + readonly threshold: 100; +} +``` + +**ArkTS1.2** +```typescript +let n1: int = 1; +let n2: number = 0.1; +let f: boolean = true; + +function getOne(): int { + return 1; +} +function isAvailable(): boolean { + return true; +} + +function setFlag(flag: boolean) { + console.log(flag); +} +function setPrecision(precision: number) { + console.log(precision); +} + +interface Config { + readonly enable: boolean; + readonly threshold: int; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe203.md b/ets2panda/linter/docs/rules-cn/recipe203.md new file mode 100644 index 0000000000000000000000000000000000000000..0c05d2115e305dcef92833a88b16f5a371358920 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe203.md @@ -0,0 +1,43 @@ +## 不支持指数操作符 + +**规则:**`arkts-no-exponent-op` + +**级别:error** + +ArkTS1.2不支持指数运算符(`**`和`**=`),采用语言基础库。 + +**ArkTS1.1** + +```typescript +let x = 2 ** 5; + +let y = 3; +y **= 4; // 违反规则 + +let result = (1 + 2) ** (3 * 2); // 违反规则 + +function power(base: number, exponent: number) { + return base ** exponent; // 违反规则 +} + +let values = [1, 2, 3]; +let squared = values.map(v => v ** 2); // 违反规则 +``` + +**ArkTS1.2** + +```typescript +let x = Math.pow(2, 5); + +let y = 3; +y = Math.pow(y, 4); // 直接使用 `Math.pow()` + +let result = Math.pow(1 + 2, 3 * 2); // 直接使用 `Math.pow()` + +function power(base: number, exponent: number) { + return Math.pow(base, exponent); // 使用 `Math.pow()` +} + +let values = [1, 2, 3]; +let squared = values.map(v => Math.pow(v, 2)); // 使用 `Math.pow()` +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe206.md b/ets2panda/linter/docs/rules-cn/recipe206.md new file mode 100644 index 0000000000000000000000000000000000000000..d9fc158b9410828d39572a61225d47941f51d642 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe206.md @@ -0,0 +1,27 @@ +## 不支持debugger + +**规则:**`arkts-no-debugger` + +**级别:error** + +1. 静态类型语言具备编译时检查和强类型约束,调试通常由IDE完成,已具备较强大的调试机制。 + +2. debugger会侵入式修改源码。 + +3. debugger语句会被优化,造成行为不一致。 + +**ArkTS1.1** + +```typescript +// ArkTS1.1 +// ... +debugger; +// ... +``` + +**ArkTS1.2** + +```typescript +// ArkTS1.2 移除debugger语句 +// ... +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe207.md b/ets2panda/linter/docs/rules-cn/recipe207.md new file mode 100644 index 0000000000000000000000000000000000000000..e0a78ca50c943f6a7f366f67fad0e9f448d365c9 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe207.md @@ -0,0 +1,54 @@ +## 不支持arguments对象 + +**规则:** `arkts-no-arguments-obj` + +**级别:** error + +ArkTS1.2对函数调用进行严格的参数检查,参数个数不符时编译报错,因此不需要在函数体内通过arguments机制获取参数。 + +**ArkTS1.1** +```typescript +function foo(u: string) { + console.log(arguments[0]); +} + +function bar(a: number, b?: number) { + if (arguments.length === 1) { + console.log("Only one argument passed"); + } +} + +function sum() { + let total = 0; + for (let i = 0; i < arguments.length; i++) { + total += arguments[i]; + } + return total; +} + +function test() { + console.log(arguments.callee); +} +``` + +**ArkTS1.2** +```typescript +function foo(u: string) { + console.log(u); +} + +function bar(a: number, b?: number) { + if (b === undefined) { + console.log("Only one argument passed"); + } +} + +function sum(...args: number[]) { + // 使用 `...rest` 替代 `arguments` + return args.reduce((acc, num) => acc + num, 0); +} + +function test() { + console.log(test); // 直接使用函数名 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe208.md b/ets2panda/linter/docs/rules-cn/recipe208.md new file mode 100644 index 0000000000000000000000000000000000000000..1d70fd916912ad5a940d20cd8e0aae68188acf19 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe208.md @@ -0,0 +1,52 @@ +## 不支持tagged templates + +**规则:**`arkts-no-tagged-templates` + +**级别:error** + +ArkTS1.2规范函数调用方式,支持字符串相加的用法,不支持Tagged templates(标签模板字符串)。 + +**ArkTS1.1** + +```typescript +function myTag(strings: TemplateStringsArray, value: string): string { + return strings[0] + value.toUpperCase() + strings[1]; +} + +const name = 'john'; +const result = myTag`Hello, ${name}!`; +console.log(result); + +function formatTag(strings: TemplateStringsArray, first: string, last: string): string { + return `${strings[0]}${first.toUpperCase()} ${last.toUpperCase()}${strings[1]}`; +} + +const firstName = 'john'; +const lastName = 'doe'; +const result = formatTag`Hello, ${firstName} ${lastName}!`; // 违反规则 +console.log(result); +``` + +**ArkTS1.2** + +```typescript +function myTagWithoutTemplate(strings: string, value: string): string { + return strings + value.toUpperCase(); +} + +const name = 'john'; + +const part1 = 'Hello, '; +const part2 = '!'; +const result = myTagWithoutTemplate(part1, name) + part2; +console.log(result); + +function formatWithoutTemplate(greeting: string, first: string, last: string, end: string): string { + return greeting + first.toUpperCase() + ' ' + last.toUpperCase() + end; +} + +const firstName = 'john'; +const lastName = 'doe'; +const result = formatWithoutTemplate('Hello, ', firstName, lastName, '!'); // 直接使用函数参数 +console.log(result); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe209.md b/ets2panda/linter/docs/rules-cn/recipe209.md new file mode 100644 index 0000000000000000000000000000000000000000..37e2107599fbeaab1a205a79ca175088b418adde --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe209.md @@ -0,0 +1,43 @@ +## 数组索引必须是整型数据 + +**规则:**`arkts-array-index-expr-type` + +**级别:error** + +ArkTS1.2支持数值类型的细化,为了实现数组更快的访问,数组索引表达式必须是整数类型。 + +**ArkTS1.1** + +```typescript +function foo (index: number) { + let array = [1, 2, 3] + let element = array[index] +} + +function getIndex(): number { + return Math.random() * 10; // 可能返回小数 +} + +let array = [1, 2, 3]; +for (let i: number = 0; i < array.length; i++) { // 违反规则 + console.log(array[i]); +} +``` + +**ArkTS1.2** + +```typescript +function foo (index: int) { + let array = [1, 2, 3] + let element = array[index] +} + +function getIndex(): int { + return Math.floor(Math.random() * 10); // 转换为 `int` +} + +let array = [1, 2, 3]; +for (let i: int = 0; i < array.length; i++) { // 改为 `int` + console.log(array[i]); +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe210.md b/ets2panda/linter/docs/rules-cn/recipe210.md new file mode 100644 index 0000000000000000000000000000000000000000..6d3b16fb3ad4f1b570f26860447240660c485b47 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe210.md @@ -0,0 +1,55 @@ +## 限定switch语句中case语句类型 + +**规则:**`arkts-switch-expr` + +**级别:error** + +ArkTS1.2的switch表达式类型只能为number,string,enum。 + +**ArkTS1.1** + +```typescript +const isTrue = true; +switch (isTrue) { + case true: // 违反规则 + console.log('It\'s true'); break; + case false: // 违反规则 + console.log('It\'s false'); break; +} + +const obj = { value: 1 }; +switch (obj) { // 违反规则 + case { value: 1 }: + console.log('Matched'); break; +} + +const arr = [1, 2, 3]; +switch (arr) { // 违反规则 + case [1, 2, 3]: + console.log('Matched'); break; +} +``` + +**ArkTS1.2** + +```typescript +const isTrue = 'true'; +switch (isTrue) { + case 'true': + console.log('It\'s true'); break; + case 'false': + console.log('It\'s false'); break; +} + +const objValue = 1; // 仅存储值 +switch (objValue) { + case 1: + console.log('Matched'); break; +} + +const arrValue = '1,2,3'; // 变成字符串 +switch (arrValue) { + case '1,2,3': + console.log('Matched'); break; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe211.md b/ets2panda/linter/docs/rules-cn/recipe211.md new file mode 100644 index 0000000000000000000000000000000000000000..a4dd6a5dd1562c24fcc405f0fbaba3eced183e90 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe211.md @@ -0,0 +1,58 @@ +## 不支持重复case语句 + +**规则:**`arkts-case-expr` + +**级别:error** + +ArkTS1.2不支持Switch语句的中case重复,便于提高代码可读性。 + +**ArkTS1.1** + +```typescript +const num = 1; +switch (num) { + case 1: + console.log('First match'); + case 1: + console.log('Second match'); + break; + default: + console.log('No match'); +} + +enum Status { + Active, + Inactive +} + +const state = Status.Active; +switch (state) { + case Status.Active: + console.log('User is active'); + break; + case Status.Active: // 违反规则 + console.log('Already active'); + break; +} +``` + +**ArkTS1.2** + +```typescript +const num = 1; +switch (num) { + case 1: + console.log('First match'); + console.log('Second match'); + break; + default: + console.log('No match'); +} + +switch (state) { + case Status.Active: + console.log('User is active'); + console.log('Already active'); // 代码合并 + break; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe212.md b/ets2panda/linter/docs/rules-cn/recipe212.md new file mode 100644 index 0000000000000000000000000000000000000000..d26122a052c8b95368bcbc1024849773cb2b7806 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe212.md @@ -0,0 +1,38 @@ +## 不支持通过负数访问数组 + +**规则:**`arkts-array-index-negative` + +**级别:error** + +ArkTS1.2不支持使用负整数访问数组元素。 + +**ArkTS1.1** + +```typescript +let an_array = [1, 2, 3]; +let element = an_array [-1]; +console.log(getElement(an_array, -1)); // 违反规则 +for (let i: int = -1; i < an_array.length; i++) { // 违反规则 + console.log(an_array[i]); +} + +function getElement(arr: number[], index: int) { + return arr[index]; // 可能接收负数索引 +} +``` + +**ArkTS1.2** + +```typescript +let an_array = [1, 2, 3]; +let element = an_array [1]; +console.log(getElement(an_array, 1)); // 传递非负索引 +for (let i: int = 0; i < an_array.length; i++) { // 仅允许非负索引 + console.log(an_array[i]); +} + +function getElement(arr: number[], index: int) { + if (index < 0) throw new Error("Index must be a non-negative integer"); + return arr[index]; // 仅允许非负整数 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe213.md b/ets2panda/linter/docs/rules-cn/recipe213.md new file mode 100644 index 0000000000000000000000000000000000000000..1dadbf87dd589c01c495b016c1f2ff7129244a93 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe213.md @@ -0,0 +1,27 @@ +## class的懒加载 + +**规则:**`arkts-class-lazy-import` + +**级别:error** + +ArkTS1.2的类在使用时进行加载或初始化,以提升启动性能,减少内存占用。 + +**ArkTS1.1** + +```typescript +class C { + static { + console.info('init'); // ArkTS1.2上不会立即执行 + } +} +``` + +**ArkTS1.2** + +```typescript +// ArkTS1.2 如果依赖没有被使用的class执行逻辑,那么将该段逻辑移出class +class C { + static {} +} +console.info('init'); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe214.md b/ets2panda/linter/docs/rules-cn/recipe214.md new file mode 100644 index 0000000000000000000000000000000000000000..7bac07e4ebcd1f0155f07e29a2f96c50177aa867 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe214.md @@ -0,0 +1,22 @@ +## 对象没有constructor + +**规则:**`arkts-obj-no-constructor` + +**级别:error** + +ArkTS1.2支持天然共享的能力,运行时需要确定类型信息。实现上不再基于原型的语言,而是基于class的语言。 + +**ArkTS1.1** + +```typescript +class A {} +let a = new A().constructor; // ArkTS1.2上编译错误 +``` + +**ArkTS1.2** + +```typescript +class A {} +let a = new A(); +let cls = Type.of(a); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe215.md b/ets2panda/linter/docs/rules-cn/recipe215.md new file mode 100644 index 0000000000000000000000000000000000000000..1a51e48fad0a477a526a5907e9f18eb011b079d1 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe215.md @@ -0,0 +1,23 @@ +## 增加数组越界运行时检查 + +**规则:**`arkts-runtime-array-check` + +**级别:error** + +为了保证类型安全,在访问数组元素时,ArkTS1.2会对索引的合法性进行校验。 + +**ArkTS1.1** + +```typescript +let a: number[] = [] +a[100] = 5; // 可能越界 +``` + +**ArkTS1.2** + +```typescript +let a: number[] = [] +if (100 < a.length) { + a[100] = 5 // a[100]的值为5 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe222.md b/ets2panda/linter/docs/rules-cn/recipe222.md new file mode 100644 index 0000000000000000000000000000000000000000..cf3695b207f7db017a664c00a369b9997c4af619 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe222.md @@ -0,0 +1,26 @@ +## 不支持副作用导入 + +**规则:**`arkts-no-side-effect-import` + +**级别:error** + +ArkTS1.2中模块加载默认支持懒加载,无法实现导入副作用的功能。 + +**ArkTS1.1** + +```typescript +// logger.ets +console.log("Logger initialized!"); + +// main.ets +import "./logger"; +console.log("Main program running..."); +``` + +**ArkTS1.2** + +```typescript +// main.ets +console.log("Logger initialized!"); +console.log("Main program running..."); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe232.md b/ets2panda/linter/docs/rules-cn/recipe232.md new file mode 100644 index 0000000000000000000000000000000000000000..7f5cec4a61c9d05f65f3dd087ba3dec7428dd193 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe232.md @@ -0,0 +1,23 @@ +## 不支持lazy关键字 + +**规则:**`arkts-no-lazy-import` + +**级别:error** + +ArkTS1.2支持默认懒加载,无需lazy关键字。 + +**ArkTS1.1** + +```typescript +import lazy { m } from 'module' +import lazy { a, b } from 'module1'; // 违反规则 +import { c } from 'module2'; +``` + +**ArkTS1.2** + +```typescript +import { m } from 'module' +import { a, b } from 'module1'; // 移除 lazy +import { c } from 'module2'; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe233.md b/ets2panda/linter/docs/rules-cn/recipe233.md new file mode 100644 index 0000000000000000000000000000000000000000..fe2047a3071a0a1ae48c76ae96e863ad81cd8b08 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe233.md @@ -0,0 +1,47 @@ +## 不支持动态import + +**规则:**`arkts-no-dynamic-import` + +**级别:error** + +ArkTS1.2中模块加载默认支持懒加载。 + +**ArkTS1.1** + +```typescript +function main(): void { + import('./file').then((m) => { + console.log(m.Data.name) + }) +} + +document.getElementById("btn")?.addEventListener("click", async () => { + const module = await import('./utils'); // 错误: 在ArkTS中动态`import()`是不支持的. + module.doSomething(); +}); + +function getModule() { + return import('./heavyModule') // 错误: 在ArkTS中动态`import()`是不支持的. + .then((m) => m.default); +} +``` + +**ArkTS1.2** + +```typescript +import { Data } from './file' +import { doSomething } from './utils'; // 静态import是可以的. +import heavyModule from './heavyModule'; // 静态import是可以的. + +function main(): void { + console.log(Data.name) +} + +document.getElementById("btn")?.addEventListener("click", () => { + doSomething(); +}); + +function getModule() { + return heavyModule; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe234.md b/ets2panda/linter/docs/rules-cn/recipe234.md new file mode 100644 index 0000000000000000000000000000000000000000..3547c5dfe63bb8ddfcbf6d88e53832c9d2976ce3 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe234.md @@ -0,0 +1,35 @@ +## 不支持TS装饰器 + +**规则:**`arkts-no-ts-decorators` + +**级别:error** + +ArkTS1.2中不支持将类作为对象,不能通过装饰器中对类做动态改变。 + +**ArkTS1.1** + +```typescript +function decorateKlass(target: Object) { + console.log("decorateKlass") +} + +@decorateKlass // 违反规则 +class Person { + age: number = 12 +} +``` + +**ArkTS1.2** + +```typescript +class Person { + age: number = 12 +} + +class PersonHelper { + static createPerson(): Person { + console.log("decorateKlass") + return new Person() + } +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe235.md b/ets2panda/linter/docs/rules-cn/recipe235.md new file mode 100644 index 0000000000000000000000000000000000000000..2f835382857962d944af75dcca57551d4853f08a --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe235.md @@ -0,0 +1,44 @@ +## 增强对联合类型属性访问的编译时检查 + +**规则:**`arkts-common-union-member-access` + +**级别:error** + +在ArkTS1.2中,对象的结构在编译时就确定了。为了避免访问联合类型后出现运行时错误,ArkTS1.2在编译时会对联合类型的同名属性进行编译检查,要求同名属性具有相同的类型。 + +**ArkTS1.1** + +```typescript +class A { + v: number = 1 +} + +class B { + u: string = '' +} + +function foo(a: A | B) { + console.log(a.v) // 违反规则 + console.log(a.u) // 违反规则 +} +``` + +**ArkTS1.2** + +```typescript +class A { + v: number = 1 +} + +class B { + u: string = '' +} + +function foo(a: A) { + console.log(a.v) +} + +function foo(a: B) { + console.log(a.u) +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe236.md b/ets2panda/linter/docs/rules-cn/recipe236.md new file mode 100644 index 0000000000000000000000000000000000000000..f36b1ae6fffca18d336a4b9c666f87a07aff2c1d --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe236.md @@ -0,0 +1,47 @@ +## 类实现接口时,不能用类方法替代对应interface属性 + +**规则:**`arkts-no-method-overriding-field` + +**级别:error** + +ArkTS1.2不支持structural type,属性和方法不能互相转换。 + +**ArkTS1.1** + +```typescript +interface Person { + cb: () => void +} + +class student implements Person{ + cb() {} +} + +interface Transformer { + transform: (value: T) => T; // 违反规则 +} + +class StringTransformer implements Transformer { + transform(value: string) { return value.toUpperCase(); } // 违反规则 +} +``` + +**ArkTS1.2** + +```typescript +interface Person { + cb(): void +} + +class student implements Person{ + cb() {} +} + +interface Transformer { + transform(value: T): T; // 变成方法 +} + +class StringTransformer implements Transformer { + transform(value: string) { return value.toUpperCase(); } // 正确 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe238.md b/ets2panda/linter/docs/rules-cn/recipe238.md new file mode 100644 index 0000000000000000000000000000000000000000..d4ef752cf76e940d483c75e890b6c0a6636676b2 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe238.md @@ -0,0 +1,57 @@ +## 类的静态属性需要有初始值 + +**规则:**`arkts-class-static-initialization` + +**级别:error** + +ArkTS1.2遵循null-safety,需要为属性赋上初始值。 + +**ArkTS1.1** + +```typescript +class B {} + +class A { + static b: B +} + +class A { + static count: number; // 违反规则,必须初始化 +} + +class A { + static config: { theme: string }; // 违反规则,必须初始化 +} + +class A { + static name: string; + + constructor() { + A.name = "default"; // 违反规则,静态属性必须在定义时初始化 + } +} +``` + +**ArkTS1.2** + +```typescript +class B {} + +class A { + static b? : B + static b: B | undefined = undefined +} + +class A { + static count: number = 0; // 提供初始值 +} + +class A { + static config: { theme: string } = { theme: "light" }; // 提供初始值 +} + +class A { + static name: string = "default"; // 在定义时初始化 +} + +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe239.md b/ets2panda/linter/docs/rules-cn/recipe239.md new file mode 100644 index 0000000000000000000000000000000000000000..b87215a02cdc0db58e20b19230c1f8784ba7fff3 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe239.md @@ -0,0 +1,28 @@ +## Task的function属性改名为taskFunction + +**规则:** arkts-change-taskpool-Task-to-taskFunction + +**级别:** error + +function在ArkTS1.2中为关键字,不能作为类属性(限定关键字(arkts-invalid-identifier))。 + +**ArkTS1.1** +```typescript +import { taskpool } from '@kit.ArkTS'; + +function testString(str: string) { + console.info(str); + +} +let task: taskpool.Task = new taskpool.Task(testString, "hello"); +let func = task.function; +``` + +**ArkTS1.2** +```typescript +let func1 = (str: string): string => { + return str; +}; +let task: taskpool.Task = new taskpool.Task(func1, "hello"); +let func = task.taskFunction; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe255.md b/ets2panda/linter/docs/rules-cn/recipe255.md new file mode 100644 index 0000000000000000000000000000000000000000..c131a1ce4c1d4f07a0c0277c2f505d78979b0ceb --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe255.md @@ -0,0 +1,85 @@ +## 禁止extends/implements表达式 + +**规则:**`arkts-no-extends-expression` + +**级别:error** + +ArkTS1.2中规范了类的继承,类不能作为对象来继承一个表达式。 + +**ArkTS1.1** + +```typescript +class A { + v: number = 0 +} + +let a = A; + +class B extends a { // 违反规则 + u: number = 0 +} + +function getBase() { + return class { + w: number = 0; + }; +} + +class B extends getBase() { // 违反规则 + u: number = 0; +} + +interface I { + w: number; +} + +let i = I; + +class B implements i { // 违反规则 + w: number = 0; +} + +class A { + v: number = 0; +} + +class B extends new A() { // 违反规则 + u: number = 0; +} +``` + +**ArkTS1.2** + +```typescript +class A { + v: number = 0 +} + +class B extends A { // 直接继承类 + u: number = 0 +} + +class Base { + w: number = 0; +} + +class B extends Base { // 直接继承类 + u: number = 0; +} + +interface I { + w: number; +} + +class B implements I { // 直接使用接口 + w: number = 0; +} + +class A { + v: number = 0; +} + +class B extends A { // 直接继承类 + u: number = 0; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe265.md b/ets2panda/linter/docs/rules-cn/recipe265.md new file mode 100644 index 0000000000000000000000000000000000000000..669645672ebd6f9631e4791b94170b5e927be67b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe265.md @@ -0,0 +1,33 @@ +### ArkTS1.2继承js的类 + +**规则:** arkts-interop-js2s-inherit-js-class + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export class A {} + +// file2.ets +import { A } from './file1'; +class B extends A {} +let b = new B(); +``` + +**ArkTS1.2** +```typescript +// file1.js +export class A {} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let A = mod.getProperty('A'); +let fixArr: FixedArray = []; +let esvalueCB = (argThis: ESValue, argNewTgt: ESValue, args: FixedArray, data?: ESValueCallbackData) => { + return ESValue.Undefined; +}; +let B: ESValue = ESValue.defineClass('B', esvalueCB, undefined, undefined, A); +let b = B.instantiate(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe266.md b/ets2panda/linter/docs/rules-cn/recipe266.md new file mode 100644 index 0000000000000000000000000000000000000000..a511d29f8d8eee09faca33f85bda0bd5348cb94a --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe266.md @@ -0,0 +1,36 @@ +### ArkTS1.2遍历js对象 + +**规则:** arkts-interop-js2s-traverse-js-instance + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { arr: [1, 2, 3] }; +// file2.ets +import { foo } from './file1'; +let arr = foo.arr; +let len = arr.length as number; +for (let i = 0; i < len; ++i) { + arr[i] as number; + arr[i] = 0; +} +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = { arr: [1, 2, 3] }; + +// file2.ets ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let arr = foo.getProerpty('arr'); +let len = arr.getProerpty('length').toNumber(); +for (let i = 0; i < len; ++i) { + arr.getProperty(i).toNumber(); + arr.setProperty(i, ESValue.wrap(0)); +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe268.md b/ets2panda/linter/docs/rules-cn/recipe268.md new file mode 100644 index 0000000000000000000000000000000000000000..05e25804452ed175bade60027ab334ab7ace82b4 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe268.md @@ -0,0 +1,30 @@ +### ArkTS1.2对js对象进行条件判断 + +**规则:** arkts-interop-js2s-condition-judgment + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { isGood: true }; + +// file2.ets +import { foo } from './file1'; + +if (foo.isGood) {} +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = { isGood: true }; + +// file2.ets +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); + +let isGood = foo.getProperty('isGood').toBoolean(); +if (isGood) {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe269.md b/ets2panda/linter/docs/rules-cn/recipe269.md new file mode 100644 index 0000000000000000000000000000000000000000..c819e89511fad3002d5574fbcd31183d52917d38 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe269.md @@ -0,0 +1,38 @@ +### js对ArkTS1.2对象进行展开语法 + +**规则:** arkts-interop-js2s-js-expand-static-instance + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export function foo(obj) { +let x = {...obj} // x会是{ a = 1; b = 2; c = 3 } +let {a, b, ...rest} = obj // a会是1, b会是2, rest会是{c: 3} + +// file2.ets +import {foo} from "./file1" +class X { a = 1; b = 2; c = 3 } +foo(new X()) + +// class interface Record +``` + +**ArkTS1.2** +```typescript +// file1.js +export function foo(obj) { +let x = {...obj} // x会是空对象{},因为静态对象没有自有属性 +// 解决方案:let x = {a: obj.a, b: obj.b, c: obj.c} +// 或者使用keys + Reflect.get +let {a, b, ...rest} = obj // a会是1,b会是2,rest会是空对象{},因为静态对象没有自有属性 +// 解决方案: let rest = {c: obj.c} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1') +let foo = mod.getProperty('foo') +class X { a = 1; b = 2; c = 3 } +foo.invoke(ESValue.wrap(new X())) +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe270.md b/ets2panda/linter/docs/rules-cn/recipe270.md new file mode 100644 index 0000000000000000000000000000000000000000..9c76a6f2580cffafa87539fee35dfbf9492c5679 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe270.md @@ -0,0 +1,42 @@ +### ArkTS1.2处理js非常规异常 + +**规则:** arkts-interop-js2s-js-exception + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export function foo() { + throw 123; +} + +// file2.ets +import { foo } from './file1'; + +try { + foo(); +} catch (e) { + console.log("result is " + (e as number)); //123 +} +``` + +**ArkTS1.2** +```typescript +// file1.js +export function foo() { + throw 123; +} + +// file2.ets +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); + +try { + foo.invoke(); +} catch (e) { + let err: ESValue = (e as ESError).getValue(); + err.toNumber(); // 123 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe274.md b/ets2panda/linter/docs/rules-cn/recipe274.md new file mode 100644 index 0000000000000000000000000000000000000000..afd9563e76409338cd948c1074f43a044d15912d --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe274.md @@ -0,0 +1,33 @@ +## 子类有参构造函数需要显式定义,且必须调用父类的构造函数 + +**规则:**`arkts-subclass-must-call-super-constructor-with-args` + +**级别:error** + +1. ArkTS1.1在运行时没有对函数调用的检查,同时利用arguments机制获取所有参数(ArkTS1.2上不支持这个特性)并传入父类构造函数。ArkTS1.2对函数参数的个数和类型会进行编译时检查,确保程序的安全和正确性,因此ArkTS1.2上不支持这种写法。 + +2. ArkTS1.2支持方法重载,构造函数可能有多个实现体,在ArkTS1.2上支持这个特性会造成子类继承父类时的二义性。 + +**ArkTS1.1** + +```typescript +class A { + constructor(a: number) {} +} +class B extends A {} // ArkTS1.2上编译报错 +let b = new B(123); +``` + +**ArkTS1.2** + +```typescript +class A { + constructor(a: number) {} +} +class B extends A { + constructor(a: number) { + super(a) + } +} +let b = new B(123); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe29.md b/ets2panda/linter/docs/rules-cn/recipe29.md new file mode 100644 index 0000000000000000000000000000000000000000..3861c5deedccc309a9bf476ba7289e57c0213ac6 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe29.md @@ -0,0 +1,37 @@ +## 不支持[]访问对象属性 + +**规则:**`arkts-no-props-by-index` + +**级别:error** + +在ArkTS1.2中,对象结构在编译时已确定。为避免运行时出现错误和更好地提升性能,在ArkTS1.2中不能使用[]的方式动态访问object类型对象的属性。 + +**ArkTS1.1** + +```typescript +function foo(u: object) { + u['key'] // 违反规则 +} + +const person = { name: "Alice", age: 30 }; +console.log(person['name']); // 违反规则 + +const data = JSON.parse('{ "name": "Alice" }'); +console.log(data['name']); // 违反规则 +``` + +**ArkTS1.2** + +```typescript +function foo(m: Map) { + m.get('key') // 使用 `Map` +} + +console.log(person.name); // 直接使用 `.` 访问 + +interface UserData { + name: string; +} +const data: UserData = JSON.parse('{ "name": "Alice" }'); +console.log(data.name); // 直接使用点访问符 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe30.md b/ets2panda/linter/docs/rules-cn/recipe30.md new file mode 100644 index 0000000000000000000000000000000000000000..809e77db21526580c4b0a54e90d2cd7464772eb7 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe30.md @@ -0,0 +1,96 @@ +## 不支持structural typing + +**规则:**`arkts-no-structural-typing` + +**级别:error** + +ArkTS1.2不支持structural typing,编译器无法比较两种类型的publicAPI并决定它们是否相同。使用其他机制,例如继承、接口或类型别名。 + +**ArkTS1.1** + +```typescript +// case1 +class A { + v: number = 0 +} + +class B { + v: number = 0 +} + +let a = new B() as A + +// case2 +class C { + u: T +} + +let b: C = new C() + +// case3 +class A { + u: number = 0 +} + +class B { + u: number = 0 +} + +(): A => { return new B() } + +class A { + v: number = 0 +} + +class B { + v: number = 0 +} +class C { + u: T; +} + +let b: C = new C(); // 违反规则 +``` + +**ArkTS1.2** + +```typescript +// case1 +class A { + v: number = 0 +} + +class B { + v: number = 0 +} + +let a = new B() + +// case2 +class C { + u: T +} + +let b: C = new C() + +// case3 +class A { + u: number = 0 +} + +class B { + u: number = 0 +} + +(): B => { return new B() } + +class A { + v: number = 0 +} + +class B { + v: number = 0 +} +let b: C = new C(); // 使用相同的泛型类型 + +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe300.md b/ets2panda/linter/docs/rules-cn/recipe300.md new file mode 100644 index 0000000000000000000000000000000000000000..71a8a5e419fd5646db5f6b157a56f78c4f637b69 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe300.md @@ -0,0 +1,50 @@ +## 不支持TS-like `Function`类型的调用方式 + +**规则:**`arkts-no-ts-like-function-call` + +**级别:error** + +ArkTS1.2会对函数类型进行更严格的编译器检查。函数返回类型需要严格定义来保证类型安全,因此不支持TS-like`Function`类型。 + +**ArkTS1.1** + +```typescript +let f: Function = () => {} // 违反规则 + +function run(fn: Function) { // 违反规则 + fn(); +} + +let fn: Function = (x: number) => x + 1; // 违反规则 + +class A { + func: Function = () => {}; // 违反规则 +} + +function getFunction(): Function { // 违反规则 + return () => {}; +} +``` + +**ArkTS1.2** + +```typescript +type F = () => R; +type F1 = (p: P) => R + +let f: F = () => {} + +function run(fn: () => void) { // 指定返回类型 + fn(); +} + +let fn: (x: number) => number = (x) => x + 1; // 明确参数类型 + +class A { + func: () => void = () => {}; // 明确类型 +} + +function getFunction(): () => void { // 明确返回类型 + return () => {}; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe302.md b/ets2panda/linter/docs/rules-cn/recipe302.md new file mode 100644 index 0000000000000000000000000000000000000000..1500874327688c104a2b2a5a50e74866bc4681a4 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe302.md @@ -0,0 +1,40 @@ +### ArkTS1.2Object内置方法作用在ArkTS1.1对象 + +**规则:** arkts-interop-d2s-static-object-on-dynamic-instance + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ets +export class X { + a = 1; +} + +// file2.ets +import { X } from 'file1'; +export function foo(prx: Object) { + Object.entries(prx); // [a, 1] + Object.keys(prx); // ["a"] + Object.values(prx); // [1] +} +foo(new X()); +``` + +**ArkTS1.2** +```typescript +// file1.ets ArkTS1.1 +export class X { + a = 1; +} + +// file2.ets ArkTS 1.2 +'use static' +import { X } from 'file1'; +export function foo(prx: Object) { + Object.entries(prx); // [a, 1] + Object.keys(prx); // ["a"] + Object.values(prx); // [1] +} +foo(new X()); // 编译报错 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe303.md b/ets2panda/linter/docs/rules-cn/recipe303.md new file mode 100644 index 0000000000000000000000000000000000000000..5b378e5dea4501adf69349a603a227ce349111c7 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe303.md @@ -0,0 +1,47 @@ +### ArkTS1.2Reflect内置方法作用在ArkTS1.1对象 + +**规则:** arkts-interop-d2s-static-reflect-on-dynamic-instance + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ets ArkTS1.1 +class X { + a: string = 'hello'; + getName() { + return this.a; + } +} + +// file2.ets ArkTS1.2 +'use static' +import { X } from './file1'; +export function foo(prx: Object) { + Reflect.get(prx, 'a'); // 'hello' + Reflect.set(prx, 'a', 'world'); // true + Reflect.ownKeys(prx); // ['a'] +} +foo(new X()); +``` + +**ArkTS1.2** +```typescript +// file1.ets ArkTS1.1 +class X { + a: string = 'hello'; + getName() { + return this.a; + } +} + +// file2.ets ArkTS1.2 +'use static' +import { X } from './file1'; +export function foo(prx: Object) { + Reflect.get(prx, 'a'); // 'hello' + Reflect.set(prx, 'a', 'world'); // true + Reflect.ownKeys(prx); // ['a'] +} +foo(new X()); // 编译报错 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe304.md b/ets2panda/linter/docs/rules-cn/recipe304.md new file mode 100644 index 0000000000000000000000000000000000000000..910d614ede6de60ba9dd7a8ea180c9c5bbff825b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe304.md @@ -0,0 +1,40 @@ +## namespace内方法不能重名 + +**规则:**`arkts-no-duplicate-function-name` + +**级别:error** + +由于ArkTS1.2中会将多个名称相同的namespace合并成一个namespace,所以namespace内方法不能重名,否则会导致冲突。 + +**ArkTS1.1** + +```typescript +namespace A { + export function foo() { // 错误:命名空间 'A' 中重复导出函数 'foo'. + console.log('test1'); + } +} + +namespace A { + export function foo() { // 错误:命名空间 'A' 中重复导出函数 'foo'. + console.log('test2'); + } +} + +``` + +**ArkTS1.2** + +```typescript +namespace A { + export function foo1() { // 重命名导出函数 + console.log('test1'); + } +} + +namespace A { + export function foo2() { + console.log('test2'); + } +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe306.md b/ets2panda/linter/docs/rules-cn/recipe306.md new file mode 100644 index 0000000000000000000000000000000000000000..afee2e00cfe5fdb919bf89c9bcd550468d2258ef --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe306.md @@ -0,0 +1,66 @@ +### ArkTS1.2访问TS独有类型的实体 + +**规则:** arkts-interop-ts2s-static-access-ts-type + +TS独有类型包括如下类型: +- any +- unknown +- symbol +- Function +- object literal (例如 {x: number, y: string}) +- mixing enum (例如 enum X {a = 0, b = '1'}) +- call signature (例如 {(arg: number): string}) +- constructor signature (例如 {new(): Object}) +- index signature (例如 {[index: number]: string}) +- intersection (例如 TypeA & TypeB) +- keyof (例如 interface X { props: keyof T}) +- typeof(例如 let p = {x: 1, y: ''}, let q: typeof p) +- indexed access type(例如 MyArray = [{ name: "Alice", age: 15 }] type Person = typeof MyArray[number]) +- conditional types (例如 type Swap = T extends A ? B : A) +- mapped types (例如 type A = {[K in keyof T]: T[K]}) +- template literal types (例如 type AB = "A" | "B", type AllLocaleIDs = `${AB}_id`) +- Pick +- Omit +- Exclude +- Extract +- NonNullable +- Parameters +- ConstructorParameters +- ReturnType +- InstanceType +- NoInfer +- ThisParameterType +- OmitThisParameter +- ThisType +- Uppercase +- Lowercase +- Capitalize +- Uncapitalize + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ts +export let obj: Symbol; + +// file2.ets +import { obj } from './file1'; +let val = obj.prop; +obj.prop = 1; +obj.foo(); +let item = obj[0]; +``` + +**ArkTS1.2** +```typescript +// file1.ts +export let obj: Symbol; +// 从ArkTS1.2看来,这个声明为 +// export let obj: ESValue + +// file2.ets ArkTS1.2 +'use static' +import { obj } from './file1'; +obj.setProperty('prop', ESValue.wrap(1)); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe307.md b/ets2panda/linter/docs/rules-cn/recipe307.md new file mode 100644 index 0000000000000000000000000000000000000000..99303cceeded609d8c62ae551bdd189806332b21 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe307.md @@ -0,0 +1,41 @@ +### ArkTS1.2处理TS非常规异常 + +**规则:** arkts-interop-ts2s-ts-exception + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ts +export function foo() { + throw 123; +} + +// file2.ets +import { foo } from './file1'; + +try { + foo(); +} catch (e) { + console.log("result is " + (e as number)); // 123 +} +``` + +**ArkTS1.2** +```typescript +// file1.ts +export function foo() { + throw 123; +} + +// file2.ets // ArkTS1.2 +'use static' +import { foo } from './file1'; + +try { + foo(); +} catch (e) { + let err: ESValue = (e as ESError).getValue(); + err.toNumber(); // 123 +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe317.md b/ets2panda/linter/docs/rules-cn/recipe317.md new file mode 100644 index 0000000000000000000000000000000000000000..ed695e7b175e3404eb81a6b992f792aa331cf0c1 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe317.md @@ -0,0 +1,21 @@ +## 共享模块不需要use shared修饰 + +**规则:** arkts-limited-stdlib-no-use-shared + +**级别:** error + +新增对象天然共享特性,无需添加use shared。 + +**ArkTS1.1** +```typescript +// test.ets +export let num = 1; +// shared.ets +'use shared' +export {num} from './test'; +``` + +**ArkTS1.2** +```typescript +export let num = 1; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe318.md b/ets2panda/linter/docs/rules-cn/recipe318.md new file mode 100644 index 0000000000000000000000000000000000000000..d202675128f8fba9dc91ea044ec0d90ed8df5f7c --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe318.md @@ -0,0 +1,19 @@ +## 共享函数不需要use concurrent修饰 + +**规则:** arkts-limited-stdlib-no-use-concurrent + +**级别:** error + +新增对象天然共享特性,无需添加use concurrent。 + +**ArkTS1.1** +```typescript +function func() { +'use concurrent' +} +``` + +**ArkTS1.2** +```typescript +function func() {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe319.md b/ets2panda/linter/docs/rules-cn/recipe319.md new file mode 100644 index 0000000000000000000000000000000000000000..b9ef4d7be95441c4a9f5b85c9ea4b481361e18aa --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe319.md @@ -0,0 +1,57 @@ +## 方法继承/实现参数遵循逆变原则,返回类型遵循协变原则 + +**规则:**`arkts-method-inherit-rule` + +**级别:error** + +ArkTS1.2子类方法覆写父类方法,参数类型须遵循逆变原则,可以通过编译时检查保证类型安全,将潜在的运行时错误提前到编译期,避免运行时失败,无需运行时检查,从而提高执行性能。 + +**逆变/协变:** 用来描述类型转换后的继承关系,如果A、B表示类型,f()表示类型转换,≤表示继承关系(A≤B表示A是由B派生出来的子类),则有: + +- f()为逆变时,当A≤B时有f(B)≤f(A)成立。 + +- f()为协变时,当A≤B时有f(A)≤f(B)成立。 + +**ArkTS1.1** + +```typescript +// ArkTS1.1 +class A { + a: number = 0; +} +class B { + b: number = 0; +} + +class Base { + foo(obj: A | B): void {} +} +class Derived extends Base { + override foo(obj: A): void { // 可以覆写父类方法,ArkTS1.2编译错误 + console.info(obj.a.toString()); + } +} +``` + +**ArkTS1.2** + +```typescript +// ArkTS1.2 +class A { + a: number = 0; +} +class B { + b: number = 0; +} + +class Base { + foo(obj: A | B): void {} +} +class Derived extends Base { + override foo(obj: A | B): void { + if (obj instanceof A) { + console.info(obj.a.toString()); + } + } +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe321.md b/ets2panda/linter/docs/rules-cn/recipe321.md new file mode 100644 index 0000000000000000000000000000000000000000..bd8047302c4139a3541034dfb53cddda71a1f322 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe321.md @@ -0,0 +1,24 @@ +## taskpool不需要import + +**规则:** arkts-limited-stdlib-no-import-concurrency + +**级别:** error + +taskpool实现基于ArkTS提供,不依赖其他模块,不再需要import。 + +**ArkTS1.1** +```typescript +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function test() {} + +taskpool.execute(test); +``` + +**ArkTS1.2** +```typescript +function test() {} + +taskpool.execute(test); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe322.md b/ets2panda/linter/docs/rules-cn/recipe322.md new file mode 100644 index 0000000000000000000000000000000000000000..05e36074f78dded9c886e51f9eda0fbc061b7988 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe322.md @@ -0,0 +1,18 @@ +## 不提供isConcurrent接口 + +**规则:** arkts-limited-stdlib-no-support-isConcurrent + +**级别:** error + +新增对象天然共享特性,所有函数都是共享的,不需要提供isConcurrent。 + +**ArkTS1.1** +```typescript +import { taskpool } from '@kit.ArkTS'; +@Concurrent +function test() {} +let result: Boolean = taskpool.isConcurrent(test); +``` + +**ArkTS1.2** +不支持isConcurrent接口。 diff --git a/ets2panda/linter/docs/rules-cn/recipe323.md b/ets2panda/linter/docs/rules-cn/recipe323.md new file mode 100644 index 0000000000000000000000000000000000000000..be425c289d49ad32f4bbaec36cbe0670dde5eff1 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe323.md @@ -0,0 +1,35 @@ +### ArkTS1.2导出js实体 + +**规则:** arkts-interop-js2s-export-js + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export function foo() {} +export class A {} + +// file2.ets +import { foo } from './file1'; +export { foo }; + +export { A } from './file1'; + +// 函数、类、变量、枚举 +``` + +**ArkTS1.2** +```typescript +// file1.js +export function foo() {} +export class A {} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let A = mod.getProperty('A'); + +export { foo, A }; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe325.md b/ets2panda/linter/docs/rules-cn/recipe325.md new file mode 100644 index 0000000000000000000000000000000000000000..74eefad55b4270e67585dc9c985c0a509cb9b84b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe325.md @@ -0,0 +1,23 @@ +## 默认参数必须放在必选参数之后 + +**规则:**`arkts-default-args-behind-required-args` + +**级别:error** + +默认参数放在必选参数之前没有意义,ArkTS1.1上调用该接口时仍须传递每个默认参数。 + +**ArkTS1.1** + +```typescript +function add(left: number = 0, right: number) { + return left + right; +} +``` + +**ArkTS1.2** + +```typescript +function add(left: number, right: number) { + return left + right; +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe326.md b/ets2panda/linter/docs/rules-cn/recipe326.md new file mode 100644 index 0000000000000000000000000000000000000000..fb658ad34e112f86a87d3f1e10d8ceb6056d6dec --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe326.md @@ -0,0 +1,56 @@ +### ArkTS1.1创建ArkTS1.2对象字面量 + +**规则:** arkts-interop-s2d-object-literal + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ets +export class X { + name: string = ''; + constructor(arg: string) { + this.name = arg; + } +} +export interface Y { + data: number; +} +export type MyRecord = Record; +export function foo(arg: X) {} +export function bar(arg: Y) {} + +// file2.ets +import { X, Y } from './file1'; +let x = { name: 'hello' }; +let y: Y = { data: 123 }; +foo({ name: 'world' }); +bar({ data: 456 }); +// 返回值 zoo(): X { return {..}} +// 嵌套场景 +interface Z { + x: X; +} +let z: Z = {x: { name: 'hello' }}; +``` + +**ArkTS1.2** +```typescript +// file1.ets ArkTS1.2 +'use static' +export class X { name: string = '' } +export interface Y { data: number } +export function foo(arg: X) { } +export function bar(arg: Y) { } +export function createY(d: number): Y { + let y: Y = { data: d } + return y +} + +// file2.ets ArkTS1.1 +import { X, Y, createY } from "./file1" +let x: X = new X("hello") +let y: Y = createY(123) +foo(new X("world")) +bar(createY(456)) +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe327.md b/ets2panda/linter/docs/rules-cn/recipe327.md new file mode 100644 index 0000000000000000000000000000000000000000..137301896d90742ecb270eb46dabceda3435b4c0 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe327.md @@ -0,0 +1,41 @@ +### ArkTS1.2创建ArkTS1.1具有二义性的对象字面量 + +**规则:** arkts-interop-d2s-object-literal-no-ambiguity + +**级别:** error + +当一个对象的类型被声明为联合类型,而右侧实际赋值的是一个类的实例时,会引发类型系统的二义性(对象可以是联合类型的任一类型,但实际运行时明确是一个类的实例,这种差异会导致类型检查或运行时的不确定性)。 + +**ArkTS1.1** +```typescript +// file1.ets +export class X { + name: string = ''; +} +export interface Y { + name: string; + age?: number; +} + +// file2.ets +import { X, Y } from './file1'; +let x: X | Y = { name: 'hello' }; +``` + +**ArkTS1.2** +```typescript +// file1.ets // 1.0 +export class X { + name: string = ''; +} +export interface Y { + name: string; + age?: number; +} + +// file2.ets // 1.2 +'use static' +import { X, Y } from './file1'; +let x: X | Y = { name: 'hello' }; //编译报错 +let x: X | Y = new X('hello'); // OK +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe328.md b/ets2panda/linter/docs/rules-cn/recipe328.md new file mode 100644 index 0000000000000000000000000000000000000000..58519c0b1482358a3c942c6793afc75c658f8821 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe328.md @@ -0,0 +1,34 @@ +### ArkTS1.2创建ArkTS1.1的没有无参构造函数的类的对象字面量 + +**规则:** arkts-interop-d2s-object-literal-no-args-constructor + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.ets +export class X { + name: string; + constructor(arg: string) { + this.name = arg; + } +} +// file2.ets +import { X } from './file1'; +let x = new X('hello'); +``` + +**ArkTS1.2** +```typescript +// file1.ets ArkTS1.1 +export class X { + name: string; + constructor(arg: string) { + this.name = arg; + } +} +// file2.ets ArkTS1.2 +'use static' +import { X } from './file1'; +let x: X = new X('hello') // 编译报错 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe329.md b/ets2panda/linter/docs/rules-cn/recipe329.md new file mode 100644 index 0000000000000000000000000000000000000000..375cbbb6f75b3e3133492c2c7d224a022f9f0a71 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe329.md @@ -0,0 +1,35 @@ +## Enum不可以通过索引访问成员 + +**规则:**`arkts-enum-no-props-by-index` + +**级别:error** + +1. ArkTS1.1上已对索引访问元素的语法做了限制,ArkTS1.2对枚举场景增强约束。具体内容请参考[不支持通过索引访问字段](typescript-to-arkts-migration-guide.md#不支持通过索引访问字段)。 + +2. ArkTS1.1上枚举是动态对象,ArkTS1.2是静态类型,枚举具有运行时类型。为获得更高的性能,对[]访问做了限制。 + +**ArkTS1.1** + +```typescript +enum TEST { + A, + B, + C +} + +TEST['A']; // ArkTS1.2上不支持这种语法 +TEST[0]; // ArkTS1.2上不支持这种语法 +``` + +**ArkTS1.2** + +```typescript +enum TEST { + A, + B, + C +} + +TEST.A; // 使用.操作符或者enum的值 +TEST.A.getName(); // 使用enum对应的方法获取enum的key +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe330.md b/ets2panda/linter/docs/rules-cn/recipe330.md new file mode 100644 index 0000000000000000000000000000000000000000..a5d8149d1674b8ec56c34fff40775d0aa17b986a --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe330.md @@ -0,0 +1,25 @@ +### ArkTS1.2导入js文件 + +**规则:** arkts-interop-js2s-import-js + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export function foo() {} + +// file2.ets +import { foo } from './file1'; +``` + +**ArkTS1.2** +```typescript +// file1.js +export function foo() {} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe331.md b/ets2panda/linter/docs/rules-cn/recipe331.md new file mode 100644 index 0000000000000000000000000000000000000000..c25c8d537d2eacd49ef2979da4c77c166b222d2b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe331.md @@ -0,0 +1,32 @@ +### ArkTS1.2调用js函数和传参 + +**规则:** arkts-interop-js2s-call-js-func + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export function foo() {} +export function bar(a) {} + +// file2.ets +import { foo, bar } from './file1'; +foo(); +bar(123); +``` + +**ArkTS1.2** +```typescript +// file1.js +export function foo() {} +export function bar(a) {} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let bar = mod.getProperty('bar'); +foo.invoke(); +bar.invoke(ESValue.wrap(123)); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe332.md b/ets2panda/linter/docs/rules-cn/recipe332.md new file mode 100644 index 0000000000000000000000000000000000000000..da8b232e283da1382e8473c51a3b68c002a0cfa0 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe332.md @@ -0,0 +1,28 @@ +### ArkTS1.2访问js属性 + +**规则:** arkts-interop-js2s-access-js-prop + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { name: '123' }; +// file2.ets +import { foo } from './file1'; +foo.name; +foo.name = '456'; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = {name: "123"} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1') +let foo = mod.getProperty('foo') +foo.getProperty('name') +foo.setProperty('name', ESValue.wrap("456")) +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe333.md b/ets2panda/linter/docs/rules-cn/recipe333.md new file mode 100644 index 0000000000000000000000000000000000000000..9b1da1e7467d65ff3fdbcb0a7cc792ca5b31658d --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe333.md @@ -0,0 +1,49 @@ +### ArkTS1.2转换js对象类型 + +**规则:** arkts-interop-js2s-convert-js-type + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo1 = { num: 123 }; +export let foo2 = { bool: true }; +export let foo3 = { str: '123' }; +export let foo4 = { big: 123n }; + +// file2.ets +import { foo } from './file1'; +let a: number = foo1.num as number; +let b: boolean = foo2.bool as boolean; +let c: string = foo3.str as string; +let d: bigint = foo4.big as bigint; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo1 = { num: 123 }; +export let foo2 = { bool: true }; +export let foo3 = { str: '123' }; +export let foo4 = { big: 123n }; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo1 = mod.getProperty('foo1'); +let num = foo1.getProperty('num'); +let a1: number = num.toNumber(); + +let foo2 = mod.getProperty('foo2'); +let bool = foo2.getProperty('bool'); +let a2: boolean = bool.toBoolean(); + +let foo3 = mod.getProperty('foo3'); +let str = foo3.getProperty('str'); +let a3: string = str.toString(); + +let foo4 = mod.getProperty('foo4'); +let big = foo4.getProperty('big'); +let a4: bigint = big.toBigInt(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe334.md b/ets2panda/linter/docs/rules-cn/recipe334.md new file mode 100644 index 0000000000000000000000000000000000000000..e713d8e4d5bd778e9ee9341bcbdd5b5feb52f666 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe334.md @@ -0,0 +1,29 @@ +### ArkTS1.2获取js对象类型 + +**规则:** arkts-interop-js2s-typeof-js-type + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { num: 123 }; + +// file2.ets +import { foo } from './file1'; +typeof foo.num; // 'number' +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = 123; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let num = foo.getProperty('num'); + +num.typeOf(); // 'number' +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe335.md b/ets2panda/linter/docs/rules-cn/recipe335.md new file mode 100644 index 0000000000000000000000000000000000000000..546ecc685bf33ecdd589cb1f4e55ec7ae5849ab8 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe335.md @@ -0,0 +1,37 @@ +### ArkTS1.2对js对象进行一元运算 + +**规则:** arkts-interop-js2s-unary-op + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { num: 0 }; +// file2.ets +import { foo } from './file1'; ++foo.num; +-foo.num; +!foo.num; +~foo.num; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = { num: 0 }; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let num = foo.getProperty('num'); +// +foo.num ++num.toNumber(); +// -foo.num +-num.toNumber(); +// !foo.num +!num.toNumber(); +// ~foo.num +~num.toNumber(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe336.md b/ets2panda/linter/docs/rules-cn/recipe336.md new file mode 100644 index 0000000000000000000000000000000000000000..c81548e27f860046072efb8eb30545984235ce43 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe336.md @@ -0,0 +1,41 @@ +### ArkTS1.2对js对象进行二元运算 + +**规则:** arkts-interop-js2s-binary-op + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { a: 1, b: 2 }; + +// file2.ets +import { foo } from './file1'; +let a = foo.a; +let b = foo.b; +a + b; +a - b; +a * b; +a / b; +a % b; +a ** b; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = { a: 1, b: 2 }; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let a = foo.getProperty('a').toNumber(); +let b = foo.getProperty('b').toNumber(); +a + b; +a - b; +a * b; +a / b; +a % b; +a ** b; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe337.md b/ets2panda/linter/docs/rules-cn/recipe337.md new file mode 100644 index 0000000000000000000000000000000000000000..125ac990e95cc73b35700949daab010a87c645bd --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe337.md @@ -0,0 +1,39 @@ +### ArkTS1.2对js数据进行比较 + +**规则:** arkts-interop-js2s-compare-js-data + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { a: 1, b: 2 }; + +// file2.ets +import { foo } from './file1'; +let a = foo.a; +let b = foo.b; +a > b; +a < b; +a >= b; +a <= b; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let a = 1; +export let b = 2; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let a = foo.getProperty('a').toNumber(); +let b = foo.getProperty('b').toNumber(); + +a > b; +a < b; +a >= b; +a <= b; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe338.md b/ets2panda/linter/docs/rules-cn/recipe338.md new file mode 100644 index 0000000000000000000000000000000000000000..7db945140c6d5d167b183229f6c2ff44008be2ac --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe338.md @@ -0,0 +1,39 @@ +### ArkTS1.2对js数据进行相等判断 + +**规则:** arkts-interop-js2s-equality-judgment + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +class A {} +export let a = new A(); +export let b = new A(); + +// file2.ets +import { a, b } from './file1'; +a == b; +a != b; +a === b; +a !== b; +``` + +**ArkTS1.2** +```typescript +// file1.js +class A {} +export let a = new A(); +export let b = new A(); + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let a = mod.getProperty('a'); +let b = mod.getProperty('b'); + +a.isEqualTo(b); +!a.isEqualTo(b); +a.isStrictlyEqualTo(b); +!a.isStrictlyEqualTo(b); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe339.md b/ets2panda/linter/docs/rules-cn/recipe339.md new file mode 100644 index 0000000000000000000000000000000000000000..929aadf9c2a260791f69f772730e1c5a25997451 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe339.md @@ -0,0 +1,30 @@ +### ArkTS1.2访问js索引 + +**规则:** arkts-interop-js2s-access-js-index + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { arr: [1, 2, 3] }; +// file2.ets +import { foo } from './file1'; +let arr = foo.arr; +arr[1]; +arr[3] = 4; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = [1, 2, 3]; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let arr = foo.getProperty('arr'); +arr.getProperty(1); +arr.setProperty(3, ESValue.wrap(4)); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe34.md b/ets2panda/linter/docs/rules-cn/recipe34.md new file mode 100644 index 0000000000000000000000000000000000000000..85ff8aa03dcd353d140ccf72949ad79536cdb36c --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe34.md @@ -0,0 +1,34 @@ +## 创建泛型实例需要类型实参 + +**规则:**`arkts-no-inferred-generic-params` + +**级别:error** + +ArkTS1.2中,创建泛型实例时需要类型实参。 + +**ArkTS1.1** + +```typescript +new Array() // 违反规则 + +new Map(); // 违反规则 + +class Box { + value: T; + constructor(value: T) { + this.value = value; + } +} + +let box = new Box(42); // 违反规则 +``` + +**ArkTS1.2** + +```typescript +new Array() // 指定类型 + +new Map(); // 显式指定键值类型 + +let box = new Box(42); // 明确指定类型 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe340.md b/ets2panda/linter/docs/rules-cn/recipe340.md new file mode 100644 index 0000000000000000000000000000000000000000..4aed1d919801b9b6ce1680c09f2de663eb8d7978 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe340.md @@ -0,0 +1,34 @@ +### ArkTS1.2 await js Promise对象 + +**规则:** arkts-interop-js2s-await-js-promise + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +async function foo(){} +export let p = foo() + +// file2.ets +import {p} from "./file1" +async function bar() { + await p.toPromise(); +} +``` + +**ArkTS1.2** +```typescript +// file1.js +async function foo(){} +export let p = foo() + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1') +let p = mod.getProperty('p') + +async function bar() { + await p.toPromise(); +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe341.md b/ets2panda/linter/docs/rules-cn/recipe341.md new file mode 100644 index 0000000000000000000000000000000000000000..15ba9c732fd1696b5590b5fd9b58882f3779459c --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe341.md @@ -0,0 +1,30 @@ +### ArkTS1.2实例化js对象 + +**规则:** arkts-interop-js2s-create-js-instance + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +class foo { + constructor(a) {} +} +// file2.ets +import { foo } from './file1'; +new foo(123); +``` + +**ArkTS1.2** +```typescript +// file1.js +class foo { + constructor(a) {} +} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +foo.instantiate(ESValue.wrap(123)); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe342.md b/ets2panda/linter/docs/rules-cn/recipe342.md new file mode 100644 index 0000000000000000000000000000000000000000..8c0b819f4e1f5250c8a8a766d10894f2b9ae295a --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe342.md @@ -0,0 +1,31 @@ +### ArkTS1.2调用js方法和传参 + +**规则:** arkts-interop-js2s-call-js-method + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +class Foo { + bar(a) {} +} +export let foo = new Foo(); +// file2.ets +import { foo } from './file1'; +foo.bar(123); +``` + +**ArkTS1.2** +```typescript +// file1.js +class Foo { + bar(a) {} +} + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +foo.invokeMethod('bar', ESValue.wrap(123)); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe343.md b/ets2panda/linter/docs/rules-cn/recipe343.md new file mode 100644 index 0000000000000000000000000000000000000000..513a10a46371df09a2de3ee792b547d03b179314 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe343.md @@ -0,0 +1,31 @@ +### ArkTS1.2判断js对象类型 + +**规则:** arkts-interop-js2s-instanceof-js-type + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export class Foo {} +export let foo = new Foo(); + +// file2.ets +import { Foo, foo } from './file1'; +foo instanceof Foo; +``` + +**ArkTS1.2** +```typescript +// file1.js +export class Foo {} +export let foo = new Foo(); + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let Foo = mod.getProperty('Foo'); +let foo = mod.getProperty('foo'); + +foo.isInstanceOf(Foo); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe344.md b/ets2panda/linter/docs/rules-cn/recipe344.md new file mode 100644 index 0000000000000000000000000000000000000000..1797cfc140be9267235b1de395404fc8a2f1349f --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe344.md @@ -0,0 +1,46 @@ +### ArkTS1.2对js对象自增自减 + +**规则:** arkts-interop-js2s-self-addtion-reduction + +**级别:** error + +**ArkTS1.1** +```typescript +// file1.js +export let foo = { num: 0 }; + +// file2.ets +import { foo } from './file1'; +let a: number = 0; +a = foo.num++; +a = ++foo.num; +a = foo.num--; +a = --foo.num; +``` + +**ArkTS1.2** +```typescript +// file1.js +export let foo = { num: 0 }; + +// file2.ets // ArkTS1.2 +'use static' +let mod = ESValue.load('./file1'); +let foo = mod.getProperty('foo'); +let a: number = 0; + +// a = foo.num++ +let num = foo.getProperty('num'); +let tmp: number = num.toNumber(); +a = tmp; +foo.setProperty('num', ESValue(tmp + 1)); + +// a = ++foo.num + +num = foo.getProperty('num'); +tmp = num.toNumber() + 1; +foo.setProperty('num', ESValue(tmp)); +a = tmp; + +// the cases "foo.num--" and "--foo.num" are similar +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe349.md b/ets2panda/linter/docs/rules-cn/recipe349.md new file mode 100644 index 0000000000000000000000000000000000000000..792ea62fea9afbb43aebaf87a54c14ded688c66b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe349.md @@ -0,0 +1,19 @@ +## 内存默认共享,不提供SharedArrayBuffer + +**规则:** arkts-no-need-stdlib-sharedArrayBuffer + +**级别:** error + +新增对象天然共享特性,ArrayBuffer默认共享,不需要SharedArrayBuffer。 + +**ArkTS1.1** +```typescript +let sab: SharedArrayBuffer = new SharedArrayBuffer(20); +let int32 = new Int32Array(sab); +``` + +**ArkTS1.2** +```typescript +let sab: ArrayBuffer = new ArrayBuffer(20); +let int32 = new Int32Array(sab); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe350.md b/ets2panda/linter/docs/rules-cn/recipe350.md new file mode 100644 index 0000000000000000000000000000000000000000..f28e758abddae553171cddcb30855d1e2ac177a5 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe350.md @@ -0,0 +1,55 @@ +## 移除taskpool setCloneList接口 + +**规则:** arkts-limited-stdlib-no-setCloneList + +**级别:** error + +内存默认共享,不需要提供setCloneList来拷贝传递对象。 + +**ArkTS1.1** +```typescript +import { taskpool } from '@kit.ArkTS'; + +@Sendable +class BaseClass { + public str: string = 'sendable: BaseClass'; +} + +@Concurrent +function testFunc(array: Array) { + let baseInstance = array[0]; + console.info('sendable: str1 is: ' + baseInstance.str); + return baseInstance.str; +} + +let baseInstance: BaseClass = new BaseClass(); +let array = new Array(); +array.push(baseInstance); +let task = new taskpool.Task(testFunc, array); +task.setCloneList(array); +taskpool.execute(task).then((res: Object):void => { + console.info('sendable: task res is: ' + res) +}); +``` + +**ArkTS1.2** +```typescript +class BaseClass { + public str: string = 'BaseClass'; +} + +function testFunc(array: Array) { + let baseInstance = array[0]; + console.info('str1 is: ' + baseInstance.str); + return baseInstance.str; +} + + +let baseInstance: BaseClass = new BaseClass(); +let array = new Array(); +array.push(baseInstance); +let task = new taskpool.Task(testFunc, array); +taskpool.execute(task).then((res: NullishType):void => { + console.info('task res is: ' + res) +}); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe351.md b/ets2panda/linter/docs/rules-cn/recipe351.md new file mode 100644 index 0000000000000000000000000000000000000000..bd95ad170bf09a2c8c853d24a2d72d2666db1e8f --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe351.md @@ -0,0 +1,68 @@ +## 移除taskpool setTransferList接口 + +**规则:** arkts-limited-stdlib-no-setTransferList + +**级别:** error + +内存默认共享,不需要提供setTransferList来跨线程传递ArrayBuffer对象。 + +**ArkTS1.1** +```typescript +import { taskpool } from '@kit.ArkTS'; + +@Concurrent +function testTransfer(arg1: ArrayBuffer, arg2: ArrayBuffer): number { + console.info('testTransfer arg1 byteLength: ' + arg1.byteLength); + console.info('testTransfer arg2 byteLength: ' + arg2.byteLength); + return 100; +} + +let buffer: ArrayBuffer = new ArrayBuffer(8); +let view: Uint8Array = new Uint8Array(buffer); +let buffer1: ArrayBuffer = new ArrayBuffer(16); +let view1: Uint8Array = new Uint8Array(buffer1); + +console.info('testTransfer view byteLength: ' + view.byteLength); +console.info('testTransfer view1 byteLength: ' + view1.byteLength); +// 执行结果为: +// testTransfer view byteLength: 8 +// testTransfer view1 byteLength: 16 + +let task: taskpool.Task = new taskpool.Task(testTransfer, view, view1); +task.setTransferList([view.buffer, view1.buffer]); +taskpool.execute(task).then((res: Object) => { + console.info('test result: ' + res); +}).catch((e: string) => { + console.error('test catch: ' + e); +}) +console.info('testTransfer view2 byteLength: ' + view.byteLength); +console.info('testTransfer view3 byteLength: ' + view1.byteLength); +// 经过transfer转移之后值为0,执行结果为: +// testTransfer view2 byteLength: 0 +// testTransfer view3 byteLength: 0 +``` + +**ArkTS1.2** +```typescript +function testTransfer(arg1: Uint8Array, arg2: Uint8Array): number { + console.info('testTransfer arg1 byteLength: ' + arg1.byteLength); + console.info('testTransfer arg2 byteLength: ' + arg2.byteLength); + return 100.0; +} + +let buffer: ArrayBuffer = new ArrayBuffer(8); +let view: Uint8Array = new Uint8Array(buffer); +let buffer1: ArrayBuffer = new ArrayBuffer(16); +let view1: Uint8Array = new Uint8Array(buffer1); + +let task: taskpool.Task = new taskpool.Task(testTransfer, view, view1); +taskpool.execute(task).then((res: NullishType):void => { + console.info('test result: ' + res); +}).catch((e: Error): void => { + console.error('test catch: ' + e); +}) +// 内存共享,此处可直接访问view,view1的内容,不需要使用setTransferList +// 执行结果为: +// testTransfer arg1 byteLength: 8 +// testTransfer arg2 byteLength: 16 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe355.md b/ets2panda/linter/docs/rules-cn/recipe355.md new file mode 100644 index 0000000000000000000000000000000000000000..ae7a8b470b828f703eaf3084096e81cf65c89aa5 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe355.md @@ -0,0 +1,18 @@ +## 共享对象不添加装饰器@Sendable + +**规则:** arkts-limited-stdlib-no-sendable-decorator + +**级别:** error + +新增对象天然共享特性,不再依赖Sendable特性,无需添加@Sendable装饰器。 + +**ArkTS1.1** +```typescript +@Sendable +class A {} +``` + +**ArkTS1.2** +```typescript +class A {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe356.md b/ets2panda/linter/docs/rules-cn/recipe356.md new file mode 100644 index 0000000000000000000000000000000000000000..453b81ec8d4c888300fbe863fedf4a429b8b9a28 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe356.md @@ -0,0 +1,18 @@ +## 共享函数不添加装饰器@Concurrent + +**规则:** arkts-limited-stdlib-no-concurrent-decorator + +**级别:** error + +新增对象天然共享特性,不再依赖Concurrent特性,无需添加@Concurrent装饰器。 + +**ArkTS1.1** +```typescript +@Concurrent +function func() {} +``` + +**ArkTS1.2** +```typescript +function func() {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe357.md b/ets2panda/linter/docs/rules-cn/recipe357.md new file mode 100644 index 0000000000000000000000000000000000000000..ab498bbf0bb557831d552f405d30d20e87a30edc --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe357.md @@ -0,0 +1,24 @@ +## 不支持Worker + +**规则:** arkts-no-need-stdlib-worker + +**级别:** error + +内存天然共享,不需要基于Actor模型实现ThreadWorker。使用ArkTS1.2提供的新线程api-EAWorker。 + +**ArkTS1.1** +```typescript +import { worker } from '@kit.ArkTS'; + +const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/Worker.ets') +``` + +**ArkTS1.2** +```typescript +let eaw = new EAWorker(); +eaw.run(():void => { + console.info('hello, eaworker!'); +}); + +eaw.join(); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe37.md b/ets2panda/linter/docs/rules-cn/recipe37.md new file mode 100644 index 0000000000000000000000000000000000000000..24a573c8b6a4c1ff201bbdcf4276facc18789f31 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe37.md @@ -0,0 +1,40 @@ +## 不支持正则表达式 + +**规则:**`arkts-no-regexp-literals` + +**级别:error** + +ArkTS1.2不支持正则表达式字面量。 + +**ArkTS1.1** + +```typescript +let regex: RegExp = /bc*d/; +let regex = /\d{2,4}-\w+/g; // 违反规则 +function matchPattern(str: string) { + return str.match(/hello\s+world/i); // 违反规则 +} + +let text = "Hello world!"; +let result = text.replace(/world/, "ArkTS"); // 违反规则 + +let items = "apple,banana, cherry".split(/\s*,\s*/); // 违反规则 +``` + +**ArkTS1.2** + +```typescript +let regex: RegExp = new RegExp('bc*d'); +let regex = new RegExp('\\d{2,4}-\\w+', 'g'); // 使用 `RegExp` 类 +function matchPattern(str: string) { + let regex = new RegExp('hello\\s+world', 'i'); // 使用 `RegExp` + return str.match(regex); +} + +let text = "Hello world!"; +let regex = new RegExp('world'); // 使用 `RegExp` 类 +let result = text.replace(regex, "ArkTS"); + +let regex = new RegExp('\\s*,\\s*'); // 使用 `RegExp` +let items = "apple,banana, cherry".split(regex); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe370.md b/ets2panda/linter/docs/rules-cn/recipe370.md new file mode 100644 index 0000000000000000000000000000000000000000..1e974f94fafb759dd5e57250e5948d461f0b1bb0 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe370.md @@ -0,0 +1,26 @@ +## 不支持空数组/稀疏数组 + +**规则:**`arkts-no-sparse-array` + +**级别:error** + +1. ArkTS1.2遵循静态类型,空数组需要能根据上下文推导出数组元素的类型,否则会有编译错误。 + +2. ArkTS1.2的数组是连续存储的,空位(如 [1, , , 2])会浪费内存。‌ + +3. ArkTS1.2遵循空值安全,无法使用默认undefined表示空缺。 + +**ArkTS1.1** + +```typescript +let a = []; // ArkTS1.2,编译错误,需要从上下文中推导数组类型 +let b = [1, , , 2]; // 不支持数组中的空位 +b[1]; // undefined +``` + +**ArkTS1.2** + +```typescript +let a: number[] = []; // 支持,ArkTS1.2上可以从上下文推导出类型 +let b = [1, undefined, undefined, 2]; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe371.md b/ets2panda/linter/docs/rules-cn/recipe371.md new file mode 100644 index 0000000000000000000000000000000000000000..35094b1d9578581007d2075e7a22b4cfc5582d0f --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe371.md @@ -0,0 +1,25 @@ +## enum的元素不能作为类型 + +**规则:**`arkts-no-enum-prop-as-type` + +**级别:error** + +ArkTS1.1上的枚举是编译时概念,在运行时仍是普通对象。ArkTS1.2遵循静态类型,需要在运行时为enum提供类型。因此,ArkTS1.2上枚举的每个元素是枚举类的实例(在运行时才确定),无法成为编译时的静态类型信息。这与ArkTS1.2整体类型设计上不支持实例类型相违背。 + +**ArkTS1.1** + +```typescript +enum A { E = 'A' } +function foo(a: A.E) {} +``` + +**ArkTS1.2** + +```typescript +enum A { E = 'A' } +function foo(a: 'A') {} + +// ... +enum A { E = 'A' } +function foo(a: A) {} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe372.md b/ets2panda/linter/docs/rules-cn/recipe372.md new file mode 100644 index 0000000000000000000000000000000000000000..3e966558830bc3f948313cc9cbea64bc523a7000 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe372.md @@ -0,0 +1,41 @@ +## 不支持编译阶段根据PromiseSettledResult的status值确定其实际类型 + +**规则:** arkts-not-support-PromiseSettledResult-smartcast + +**级别:** error + +arkts1.2中不支持对类的成员变量进行智能转换(智能类型差异arkts-no-ts-like-smart-type)。 + +**智能转换:** 编译器会在某些场景下(如instanceof、null检查、上下文推导等)识别出对象的具体类型,自动将变量转换为相应类型,而无需手动转换。 + +**ArkTS1.1** +```typescript +let f1 = Promise.resolve('fulfilled 1'); +Promise.allSettled([f1]) + .then((results: PromiseSettledResult[]) => { + results.forEach((result: PromiseSettledResult) => { + if (result.status === 'fulfilled') { + console.log(`${result.value} `); + } else { + console.log(`${result.reason.message} `); + } + }); + }) +``` + +**ArkTS1.2** +```typescript +let f1 = Promise.resolve('fulfilled 1'); +Promise.allSettled([f1]) + .then((results: PromiseSettledResult[]) => { + results.forEach((result: PromiseSettledResult) => { + if (result.status === 'fulfilled') { + let result1 = result as PromiseFulfilledResult; + console.log(result1.value); + } else { + let result1 = result as PromiseRejectedResult; + console.log(result1.reason.message); + } + }); + }) +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe373.md b/ets2panda/linter/docs/rules-cn/recipe373.md new file mode 100644 index 0000000000000000000000000000000000000000..581e9430b1c4f002a84d8c676c47cf1cae3b1fad --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe373.md @@ -0,0 +1,39 @@ +## 数组/元组类型在继承关系中遵循不变性原则 + +**规则:**`arkts-array-type-immutable` + +**级别:error** + +ArkTS1.2上数组在继承关系中遵循不变性原则,可以通过编译时检查保证类型安全,将潜在的运行时错误提前到编译期,避免运行时失败,从而提高执行性能。 + +**ArkTS1.1** + +```typescript +class A { + a: number = 0; +} + +class B { + b: number = 0; +} + +// ArkTS1.1 +let arr1: A[] = [new A()]; +let arr2: (A | B)[] = arr1; // ArkTS1.2编译错误 +``` + +**ArkTS1.2** + +```typescript +class A { + a: number = 0; +} + +class B { + b: number = 0; +} + +// ArkTS1.2 +let arr1: [ A | B ] = [new A()]; +let arr2: [ A | B ] = arr1; // 需要相同类型的元组 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe374.md b/ets2panda/linter/docs/rules-cn/recipe374.md new file mode 100644 index 0000000000000000000000000000000000000000..32d237362a7193c2a06f6fc675cc6c3d821a0276 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe374.md @@ -0,0 +1,27 @@ +## new Number/Boolean/String不再是"object"类型 + +**规则:**`arkts-primitive-type-normalization` + +**级别:error** + +1. 在ArkTS1.2中primitive type和boxed type是相同的类型,这样可以提高语言一致性和性能。 + 比较Number/Boolean/String时比较的是值而不是对象。 + +2. 在ArkTS1.1上,boxed类型通过new创建。在获取其类型、比较boxed类型对象时会产生意外行为,这是因为对象比较时是通过引用进行比较,而不是值。通常直接使用primitive + type性能更高效,内存占用更少(相比之下对象会占用更多内存)。 + +**ArkTS1.1** + +```typescript +typeof new Number(1) // 结果: "object" +new Number(1) == new Number(1);  //结果: false +if (new Boolean(false)) {} // 在if语句中new Boolean(false)为true +``` + +**ArkTS1.2** + +```typescript +typeof new Number(1)// 结果: "number" +new Number(1) == new Number(1);  //结果: true +if (new Boolean(false)) {} // 在if语句中new Boolean(false)为false +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe375.md b/ets2panda/linter/docs/rules-cn/recipe375.md new file mode 100644 index 0000000000000000000000000000000000000000..f3453ed62789eb250942286056ae085e02be233f --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe375.md @@ -0,0 +1,31 @@ +## catch语句中是error类型 + +**规则:**`arkts-no-ts-like-catch-type` + +**级别:error** + +在ArkTS1.1上catch语句中的e是any类型。因此,编译器不会对catch语句中的异常进行编译时类型检查。当ArkTS1.1上限制throw时,只能抛出Error类型。 + +在ArkTS1.2的静态模式中,类型必须明确,同时需考虑与ArkTS1.1的兼容性。对于catch(e)的语法,默认e为Error类型。 + +**ArkTS1.1** + +```typescript +try { + throw new Error(); +} catch(e) { // e是any类型 + e.message; // ArkTS1.1编译通过,运行正常 + e.prop; // ArkTS1.1编译通过,输出undefined +} +``` + +**ArkTS1.2** + +```typescript +try { + throw new Error(); +} catch(e:Error) { // e是Error类型 + e.message; // ArkTS1.2编译通过,运行正常 + e.prop; // ArkTS1.2编译错误,需要将e转换成需要处理的异常类型,例如:(e as SomeError).prop +} +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe376.md b/ets2panda/linter/docs/rules-cn/recipe376.md new file mode 100644 index 0000000000000000000000000000000000000000..40ad96807f5efbd4b1f4ef3b6986b492c0cfe931 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe376.md @@ -0,0 +1,29 @@ +## 数值类型和bigint类型的比较 + +**规则:**`arkts-numeric-bigint-compare` + +**级别:error** + + 当前暂不支持数值类型和bigint类型的比较,迁移工具将提示开发者修改源码,不提供自动修复能力。 + +**ArkTS1.1** + +```typescript +let n1: number = 123; +let n2: bigint = 456n; + +n1 <= n2; // 编译通过 +n1 == n2; // 编译失败 +n1 >= n2; // 编译通过 +``` + +**ArkTS1.2** + +```typescript +let n1: number = 123; +let n2: bigint = 456n; + +BigInt(n1) <= n2; +BigInt(n1) == n2; +BigInt(n1) >= n2; +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe377.md b/ets2panda/linter/docs/rules-cn/recipe377.md new file mode 100644 index 0000000000000000000000000000000000000000..8e6437bb920f871a8a686701987c9c7385a07ad1 --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe377.md @@ -0,0 +1,23 @@ +## 非十进制bigint字面量 + +**规则:**`arkts-only-support-decimal-bigint-literal` + +**级别:error** + + 当前暂不支持非十进制bigint字面量,通过迁移工具提示开发者修改源码,不提供自动修复能力。 + +**ArkTS1.1** + +```typescript +let a1: bigint = 0xBAD3n; // 十六进制字面量,ArkTS1.2暂不支持 +let a2: bigint = 0o777n; // 八进制字面量,ArkTS1.2暂不支持 +let a3: bigint = 0b101n; // 二进制字面量,ArkTS1.2暂不支持 +``` + +**ArkTS1.2** + +```typescript +let a1: bigint = BigInt(0xBAD3); +let a2: bigint = BigInt(0o777); +let a3: bigint = BigInt(0b101); +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe378.md b/ets2panda/linter/docs/rules-cn/recipe378.md new file mode 100644 index 0000000000000000000000000000000000000000..529097ba0f970f10434b461071bffb93f39efd5b --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe378.md @@ -0,0 +1,25 @@ +## 不支持逻辑赋值运算 + +**规则:**`arkts-unsupport-operator` + +**级别:error** + +1. 当前暂不支持&&=, ||=, ??=逻辑赋值运算符,通过迁移工具提示开发者修改源码,不提供自动修复能力。 + +**ArkTS1.1** + +```typescript +let a = 1; +a &&= 2; // 结果: 2,ArkTS1.2暂不支持 +a ||= 3; // 结果: 2,ArkTS1.2暂不支持 +a ??= 4; // 结果: 2,ArkTS1.2暂不支持 +``` + +**ArkTS1.2** + +```typescript +let a = 1; +a = a && 2; // 结果: 2 +a = a || 3; // 结果: 2 +a = a ?? 4; // 结果: 2 +``` diff --git a/ets2panda/linter/docs/rules-cn/recipe382.md b/ets2panda/linter/docs/rules-cn/recipe382.md new file mode 100644 index 0000000000000000000000000000000000000000..f39e4f8c8ebde25d56e98a336026d23088cd37aa --- /dev/null +++ b/ets2panda/linter/docs/rules-cn/recipe382.md @@ -0,0 +1,25 @@ +## Promise\构造器中只支持使用resolve(undefined) + +**规则:** arkts-promise-with-void-type-need-undefined-as-resolve-arg + +**级别:** error + +ArkTS1.2中void不能作为变量类型声明;作为泛型时,在类实例化时会自动转换为undefined。 +**ArkTS1.1** +```typescript +let p1 = new Promise((resolve, reject) => { + resolve(); +}) +let p2 = new Promise((resolve, reject) => { + setTimeout(resolve, 10); +}) +``` + +**ArkTS1.2** +```typescript +let p1 = new Promise((resolve, reject) => { + resolve(); +}) +let p2 = new Promise((resolve, reject) => { + setTimeout(() => {resolve(undefined)}, 10); +}) \ No newline at end of file diff --git a/ets2panda/linter/homecheck/ruleSet.json b/ets2panda/linter/homecheck/ruleSet.json index 1dcacfee1bcf344047eee95418f60fcb9edb9689..ebfa295c23f4c49f226ceace6b2a339524873da8 100644 --- a/ets2panda/linter/homecheck/ruleSet.json +++ b/ets2panda/linter/homecheck/ruleSet.json @@ -210,6 +210,7 @@ "@migration/interop-boxed-type-check": 1, "@migration/interop-js-modify-property": 1, "@migration/arkts-interop-s2d-object-literal": 1, - "@migration/arkts-interop-s2d-dynamic-call-builtin-api-not-in-static": 1 + "@migration/arkts-interop-s2d-dynamic-call-builtin-api-not-in-static": 1, + "@migration/arkts-numeric-semantic": 1 } } \ No newline at end of file diff --git a/ets2panda/linter/homecheck/scripts/install_arkanalyzer.sh b/ets2panda/linter/homecheck/scripts/install_arkanalyzer.sh new file mode 100644 index 0000000000000000000000000000000000000000..282d190c670e4295438767188c996c864deea436 --- /dev/null +++ b/ets2panda/linter/homecheck/scripts/install_arkanalyzer.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright (c) 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. +# + +set -x + +# install and pack dependency arkanalyzer +cd ../arkanalyzer +npm install + +cp package.json package.json.bak + +sed -i '/postinstall/d' package.json +npm pack + +TAR_FILE=$(find . -maxdepth 1 -name "arkanalyzer-*.tgz" -print0) +cd ../homecheck +npm install ../arkanalyzer/$TAR_FILE + +# revert the project files +mv ../arkanalyzer/package.json.bak ../arkanalyzer/package.json +rm ../arkanalyzer/$TAR_FILE diff --git a/ets2panda/linter/homecheck/scripts/run_ci_ut.sh b/ets2panda/linter/homecheck/scripts/run_ci_ut.sh new file mode 100644 index 0000000000000000000000000000000000000000..56f455f87bfec03844eb6ea991bb9669ff4b7d15 --- /dev/null +++ b/ets2panda/linter/homecheck/scripts/run_ci_ut.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# Copyright (c) 2024 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. +# + +set -x + +if [ -z "${ROOT_DIR+x}" ]; then + export ROOT_DIR=$(pwd) + echo "ROOT_DIR was not set. Initialized to $ROOT_DIR" +else + echo "ROOT_DIR is already set to $ROOT_DIR" +fi + +NODE_VERSION=v22.3.0 +NODE_HOME=$ROOT_DIR/pre_scripts/node-$NODE_VERSION-linux-x64 +NODE_URL=https://gitee.com/muya318/pre_scripts/raw/master/node-v22.3.0-linux-x64.tar.gz +NODE_BIN=node-v22.3.0-linux-x64.tar.gz + +prepare_nodejs() { + echo "### preparing nodejs" + if [ ! -d "$NODE_HOME" ]; then + cd $ROOT_DIR/pre_scripts + tar -xf $NODE_BIN + chmod 777 $NODE_HOME/bin/* + cd - + export PATH=$NODE_HOME/bin:$PATH + fi + npm config set registry=https://repo.huaweicloud.com/repository/npm/ + npm config set strict-ssl false + echo "###nodejs env ready" +} + +git clone https://gitee.com/muya318/pre_scripts.git + +prepare_nodejs + +pwd +cd $ROOT_DIR + +node -v +npm -v + +npm install +npm run test + +if [ $? -ne 0 ]; then + echo "************* Unit test failed *************" + exit 1 +fi + +echo "************* Unit test success *************" + +npm pack +if [ $? -ne 0 ]; then + echo "************* Npm pack failed *************" + exit 1 +fi +echo "************* Npm pack success *************" + +exit 0 \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts index 03ccd7a3c8c5b0156e3b9d26c26735ac14221581..07ab293ad11c4b8aa8e964e4911ef8029bec96e2 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts @@ -191,6 +191,9 @@ export class CustomBuilderCheck implements BaseChecker { const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const sourceFile = AstTreeUtils.getASTNode(arkFile.getName(), arkFile.getCode()); const range = FixUtils.getRangeWithAst(sourceFile, fixPosition); + if (range === null) { + return null; + } ruleFix.range = range; const originalText = FixUtils.getSourceWithRange(sourceFile, range); if (originalText !== null) { diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts index 4a15f6af6a981db97dcc499e167d5a5bcce39434..140b4e81e349c9258aa046ba8f27d1e58e1d3788 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts @@ -29,6 +29,10 @@ import { ArkNamespace, PrimitiveType, UnclearReferenceType, + AnyType, + UnionType, + NullType, + UndefinedType, } from 'arkanalyzer/lib'; import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { BaseChecker, BaseMetaData } from '../BaseChecker'; @@ -93,7 +97,7 @@ export class InteropAssignCheck implements BaseChecker { } } - private checkPassToFunction(target: ArkMethod, scene: Scene) { + private checkPassToFunction(target: ArkMethod, scene: Scene): void { const callsites = this.cg.getInvokeStmtByMethod(target.getSignature()); callsites .filter(cs => cs.getCfg().getDeclaringMethod().getLanguage() === Language.ARKTS1_1) @@ -101,11 +105,15 @@ export class InteropAssignCheck implements BaseChecker { let hasTargetArg = false; const invoke = cs.getInvokeExpr()!; const csMethod = cs.getCfg().getDeclaringMethod(); - invoke.getArgs().forEach(arg => { + invoke.getArgs().forEach((arg, argIdx) => { const argTy = arg.getType(); if (argTy instanceof PrimitiveType || this.isBoxedType(argTy)) { return; } + const paramTy = invoke.getMethodSignature().getMethodSubSignature().getParameterTypes()[argIdx]; + if (this.isAnyType(paramTy) || this.isESObjectType(paramTy)) { + return; + } const argTyLang = this.getTypeDefinedLang(argTy, scene) ?? csMethod?.getLanguage() ?? Language.UNKNOWN; if (argTyLang === Language.ARKTS1_1) { hasTargetArg = true; @@ -126,13 +134,35 @@ export class InteropAssignCheck implements BaseChecker { }); } + private isAnyType(ty: Type): boolean { + return ty instanceof AnyType || (ty instanceof UnclearReferenceType && ty.getName() === 'Any'); + } + + private isESObjectType(ty: Type): boolean { + if (!(ty instanceof UnionType)) { + return false; + } + const types = ty.getTypes(); + if (types.length !== 3) { + return false; + } + const isObjectTy = (type: Type): boolean => { + return type instanceof ClassType && type.getClassSignature().getClassName() === 'Object'; + }; + return ( + types.find(ty => ty instanceof NullType) !== undefined && + types.find(ty => ty instanceof UndefinedType) !== undefined && + types.find(ty => isObjectTy(ty)) !== undefined + ); + } + private isBoxedType(checkType: Type): boolean { const unclear = checkType instanceof UnclearReferenceType && BOXED_SET.has(checkType.getName()); const cls = checkType instanceof ClassType && BOXED_SET.has(checkType.getClassSignature().getClassName()); return unclear || cls; } - private checkAssignToField(target: ArkMethod, scene: Scene) { + private checkAssignToField(target: ArkMethod, scene: Scene): void { const assigns: Stmt[] = this.collectAssignToObjectField(target, scene); if (assigns.length > 0) { DVFGHelper.buildSingleDVFG(target, scene); diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts index 71d73b3b28c0a6a21270d02bcf504d1b70311ede..d6f08df82416c10d75ea6fef50e25a4df5d46cb6 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts @@ -123,7 +123,7 @@ export class InteropBackwardDFACheck implements BaseChecker { } }; - private collectImportedVar(importVarMap: Map, file: ArkFile, scene: Scene) { + private collectImportedVar(importVarMap: Map, file: ArkFile, scene: Scene): void { file.getImportInfos().forEach(importInfo => { const exportInfo = importInfo.getLazyExportInfo(); if (exportInfo === null) { @@ -142,7 +142,7 @@ export class InteropBackwardDFACheck implements BaseChecker { }); } - private collectTopLevelVar(topLevelVarMap: Map, file: ArkFile, scene: Scene) { + private collectTopLevelVar(topLevelVarMap: Map, file: ArkFile, scene: Scene): void { const defaultMethod = file.getDefaultClass().getDefaultArkMethod(); if (defaultMethod) { DVFGHelper.buildSingleDVFG(defaultMethod, scene); @@ -219,7 +219,7 @@ export class InteropBackwardDFACheck implements BaseChecker { } } - private reportIssue(objDefInfo: ObjDefInfo, apiLang: Language, isReflect: boolean) { + private reportIssue(objDefInfo: ObjDefInfo, apiLang: Language, isReflect: boolean): void { const problemStmt = objDefInfo.problemStmt; const problemStmtMtd = problemStmt.getCfg().getDeclaringMethod(); const problemStmtLang = problemStmtMtd?.getLanguage(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts index 16ea7584bcb4d8889287c3486c4da61c259c7eca..0be4d71d8c7b373e28a44314ac4610866633da75 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts @@ -280,7 +280,7 @@ export class InteropJSModifyPropertyCheck implements BaseChecker { return Language.UNKNOWN; } - private reportIssue(problemStmt: Stmt) { + private reportIssue(problemStmt: Stmt): void { const line = problemStmt.getOriginPositionInfo().getLineNo(); const column = problemStmt.getOriginPositionInfo().getColNo(); const problem = 'Interop'; diff --git a/ets2panda/linter/homecheck/src/checker/migration/NumericSemanticCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/NumericSemanticCheck.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac65482d33939b594aab409f20972004a8a52621 --- /dev/null +++ b/ets2panda/linter/homecheck/src/checker/migration/NumericSemanticCheck.ts @@ -0,0 +1,1430 @@ +/* + * Copyright (c) 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 { + AbstractExpr, + AbstractFieldRef, + AbstractInvokeExpr, + AbstractRef, + AnyType, + ArkAssignStmt, + ArkField, + ArkIfStmt, + ArkInstanceFieldRef, + ArkInvokeStmt, + ArkMethod, + ArkNormalBinopExpr, + ArkParameterRef, + ArkUnopExpr, + ArrayType, + CallGraph, + ClassSignature, + ClosureFieldRef, + CONSTRUCTOR_NAME, + DVFGBuilder, + LexicalEnvType, + Local, + MethodSignature, + NamespaceSignature, + NormalBinaryOperator, + NullType, + Scene, + Stmt, + TEMP_LOCAL_PREFIX, + Type, + UnaryOperator, + UndefinedType, + UnionType, + UnknownType, + Value, +} from 'arkanalyzer/lib'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; +import { BaseChecker, BaseMetaData } from '../BaseChecker'; +import { Defects, MatcherCallback, Rule, RuleFix, Utils } from '../../Index'; +import { IssueReport } from '../../model/Defects'; +import { DVFG, DVFGNode } from 'arkanalyzer/lib/VFG/DVFG'; +import { CALL_DEPTH_LIMIT, getGlobalLocalsInDefaultMethod, getLineAndColumn, GlobalCallGraphHelper } from './Utils'; +import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; +import { NullConstant, NumberConstant, UndefinedConstant } from 'arkanalyzer/lib/core/base/Constant'; +import { AliasType, ArkArrayRef, ArkClass, ArkFile, ArkReturnStmt, AstTreeUtils, NumberType, UnclearReferenceType } from 'arkanalyzer'; +import { FixUtils } from '../../utils/common/FixUtils'; +import { Sdk } from 'arkanalyzer/lib/Config'; +import fs from 'fs'; +import path from 'path'; +import { ModifierType } from 'arkanalyzer/lib/core/model/ArkBaseModel'; +import { WarnInfo } from '../../utils/common/Utils'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'NumericSemanticCheck'); +const gMetaData: BaseMetaData = { + severity: 1, + ruleDocPath: '', + description: '', +}; + +const OhosSdkName = 'ohosSdk'; +const HmsSdkName = 'hmsSdk'; +const Ets1DirName = 'ets1.1'; +const Ets2DirName = 'ets1.2'; + +enum NumberCategory { + int = 'integer', + long = 'long', +} + +enum RuleCategory { + SDKIntType = 'sdk-api-num2int', +} + +enum IssueReason { + OnlyUsedAsIntLong = 'only-used-as-int-or-long', + UsedWithOtherType = 'not-only-used-as-int-or-long', + CannotFindAll = 'cannot-find-all', + RelatedWithNonETS2 = 'related-with-non-ets2', + Other = 'other', +} + +interface RuleOptions { + ets2Sdks?: Sdk[]; +} + +export class NumericSemanticCheck implements BaseChecker { + readonly metaData: BaseMetaData = gMetaData; + public rule: Rule; + public defects: Defects[] = []; + public issues: IssueReport[] = []; + private scene: Scene; + private ets2Sdks?: Sdk[]; + private ets2SdkScene?: Scene; + private fileGlobalLocals: Map = new Map(); + private readonly intTypeName = 'int'; + private readonly longTypeName = 'long'; + private cg: CallGraph; + private dvfg: DVFG; + private dvfgBuilder: DVFGBuilder; + private visited: Set = new Set(); + private callDepth = 0; + private classFieldRes: Map = new Map(); + + public registerMatchers(): MatcherCallback[] { + const matchBuildCb: MatcherCallback = { + matcher: undefined, + callback: this.check, + }; + return [matchBuildCb]; + } + + public check = (scene: Scene): void => { + this.scene = scene; + + // 为ets2的SDK单独生成scene,用于sdk检查时进行匹配使用,单独scene可以避免与源码的scene进行干扰 + let ets2Sdks = (this.rule.option[0] as RuleOptions | undefined)?.ets2Sdks ?? this.getEts2SdksWithRelativePath(); + if (ets2Sdks && ets2Sdks.length > 0) { + this.ets2Sdks = ets2Sdks; + this.ets2SdkScene = Utils.generateSceneForEts2SDK(ets2Sdks); + } + + this.cg = GlobalCallGraphHelper.getCGInstance(scene); + + this.dvfg = new DVFG(this.cg); + this.dvfgBuilder = new DVFGBuilder(this.dvfg, scene); + + for (let arkFile of scene.getFiles()) { + // 此规则仅对arkts1.2进行检查,仅对要将arkts1.1迁移到arkts1.2的文件进行number转int的检查和自动修复 + if (arkFile.getLanguage() !== Language.ARKTS1_2) { + continue; + } + const defaultMethod = arkFile.getDefaultClass().getDefaultArkMethod(); + if (defaultMethod) { + this.dvfgBuilder.buildForSingleMethod(defaultMethod); + this.fileGlobalLocals = getGlobalLocalsInDefaultMethod(defaultMethod); + } + for (let clazz of arkFile.getClasses()) { + this.processClass(clazz); + } + for (let namespace of arkFile.getAllNamespacesUnderThisFile()) { + for (let clazz of namespace.getClasses()) { + this.processClass(clazz); + } + } + } + }; + + private getEts2SdksWithRelativePath(): Sdk[] | null { + const ets1OhosSdk = this.scene.getProjectSdkMap().get(OhosSdkName); + const ets1HmsSdk = this.scene.getProjectSdkMap().get(HmsSdkName); + let sdks: Sdk[] = []; + if (ets1OhosSdk !== undefined) { + const sdkPath = ets1OhosSdk.path; + if (sdkPath.includes(Ets1DirName)) { + const ets2SdkPath = sdkPath.replace(Ets1DirName, Ets2DirName); + if (fs.existsSync(ets2SdkPath)) { + sdks.push({ name: OhosSdkName, path: ets2SdkPath, moduleName: ets1OhosSdk.moduleName }); + } + } + } + if (ets1HmsSdk !== undefined) { + const sdkPath = ets1HmsSdk.path; + if (sdkPath.includes(Ets1DirName)) { + const ets2SdkPath = sdkPath.replace(Ets1DirName, Ets2DirName); + if (fs.existsSync(ets2SdkPath)) { + sdks.push({ name: HmsSdkName, path: ets2SdkPath, moduleName: ets1HmsSdk.moduleName }); + } + } + } + if (sdks.length > 0) { + return sdks; + } + return null; + } + + public processClass(arkClass: ArkClass): void { + this.classFieldRes = new Map(); + // 查找全部method,包含constructor、%instInit,%statInit等 + for (let mtd of arkClass.getMethods(true)) { + this.processArkMethod(mtd); + } + } + + public processArkMethod(target: ArkMethod): void { + const stmts = target.getBody()?.getCfg().getStmts() ?? []; + // 场景1:需要检查的sdk调用语句,该stmt为sink点 + for (const stmt of stmts) { + try { + this.checkSdkArgsInStmt(stmt); + } catch (e) { + logger.error(`Error when check sdk called in stmt: ${stmt.toString()}, method: ${target.getSignature().toString()}, error: ${e}`); + } + } + } + + private checkSdkArgsInStmt(stmt: Stmt): void { + // res用于存放检查过程中所有找到的Local变量,记录这些变量是否均仅当做int使用,若是则可以设置成int类型,跨函数场景下可能包含其他method中的Local变量 + const res = new Map(); + this.callDepth = 0; + const intArgs = this.getSDKIntLongArgs(stmt); + if (intArgs === null || intArgs.size === 0) { + return; + } + + for (const [arg, category] of intArgs) { + const issueReason = this.checkValueOnlyUsedAsIntLong(stmt, arg, res, category); + if (issueReason !== IssueReason.OnlyUsedAsIntLong) { + this.addIssueReport(RuleCategory.SDKIntType, category, issueReason, true, stmt, arg); + } + } + res.forEach(([issueReason, numberCategory], local) => { + if (local.getName().startsWith(TEMP_LOCAL_PREFIX)) { + if (issueReason === IssueReason.OnlyUsedAsIntLong) { + this.addIssueReportOnClassField(local, RuleCategory.SDKIntType, numberCategory, stmt); + } + return; + } + const declaringStmt = local.getDeclaringStmt(); + if (declaringStmt !== null && issueReason === IssueReason.OnlyUsedAsIntLong) { + this.addIssueReport(RuleCategory.SDKIntType, numberCategory, issueReason, true, declaringStmt, local, undefined, stmt); + } + }); + } + + private addIssueReportOnClassField(local: Local, ruleCategory: RuleCategory, numberCategory: NumberCategory, usedStmt: Stmt): void { + const declaringStmt = local.getDeclaringStmt(); + if (!declaringStmt || !(declaringStmt instanceof ArkAssignStmt)) { + return; + } + const rightOp = declaringStmt.getRightOp(); + if (!(rightOp instanceof AbstractFieldRef)) { + return; + } + const declaringSig = rightOp.getFieldSignature().getDeclaringSignature(); + if (declaringSig instanceof NamespaceSignature) { + return; + } + if (declaringSig.toString() !== declaringStmt.getCfg().getDeclaringMethod().getDeclaringArkClass().getSignature().toString()) { + return; + } + const declaringClass = this.scene.getClass(declaringSig); + if (declaringClass === null) { + return; + } + const field = declaringClass.getField(rightOp.getFieldSignature()); + if (field === null) { + return; + } + this.addIssueReport(ruleCategory, numberCategory, IssueReason.OnlyUsedAsIntLong, true, undefined, undefined, field, usedStmt); + } + + private isMethodFromSDK(method: ArkMethod): boolean { + const projectName = method.getDeclaringArkFile().getProjectName(); + return projectName === OhosSdkName || projectName === HmsSdkName; + } + + // 语句为sdk的调用且形参有int或long类型,找出所有int类型形参的实参 + private getSDKIntLongArgs(stmt: Stmt): Map | null { + let invokeExpr: AbstractInvokeExpr; + if (stmt instanceof ArkAssignStmt) { + const rightOp = stmt.getRightOp(); + if (rightOp instanceof AbstractInvokeExpr) { + invokeExpr = rightOp; + } else { + return null; + } + } else if (stmt instanceof ArkInvokeStmt) { + invokeExpr = stmt.getInvokeExpr(); + } else { + return null; + } + const callMethod = this.scene.getMethod(invokeExpr.getMethodSignature()); + if (callMethod === null || !this.isMethodFromSDK(callMethod)) { + return null; + } + + const args = invokeExpr.getArgs(); + let containNumberArg = false; + for (const arg of args) { + if (arg instanceof Local || arg instanceof NumberConstant) { + const argType = arg.getType(); + if (this.isTypeWithNumberType(argType) || argType instanceof AnyType) { + containNumberArg = true; + break; + } + if (argType instanceof UnionType && this.containsType(argType.getTypes(), NumberType.getInstance())) { + containNumberArg = true; + break; + } + } + } + if (!containNumberArg) { + return null; + } + + const res: Map = new Map(); + // 根据找到的对应arkts1.1中的SDK接口匹配到对应在arkts1.2中的SDK接口 + const Ets2SdkSignature = this.getEts2SdkSignatureWithEts1Method(callMethod, args); + if (Ets2SdkSignature === null) { + return null; + } + Ets2SdkSignature.getMethodSubSignature() + .getParameters() + .forEach((param, index) => { + if (this.isIntType(param.getType())) { + res.set(args[index], NumberCategory.int); + } else if (this.isLongType(param.getType())) { + res.set(args[index], NumberCategory.long); + } + }); + if (res.size === 0) { + return null; + } + return res; + } + + private getMatchedSignature(ets1SDK: ArkMethod, args: Value[]): MethodSignature | null { + const declareSigs = ets1SDK.getDeclareSignatures(); + if (declareSigs === null) { + return null; + } + if (declareSigs.length === 1) { + return declareSigs[0]; + } + + let ets1SigMatched: MethodSignature | null = null; + for (const sig of declareSigs) { + const params = sig.getMethodSubSignature().getParameters(); + let matched = true; + for (let i = 0; i < args.length; i++) { + const argType = args[i].getType(); + const paramType = params[i].getType(); + if (argType === paramType) { + continue; + } + if (argType instanceof AnyType) { + continue; + } + if (!(argType instanceof UnionType) || !this.containsType(argType.getTypes(), paramType)) { + matched = false; + break; + } + } + if (matched) { + ets1SigMatched = sig; + break; + } + } + return ets1SigMatched; + } + + private containsType(types: Type[], targetType: Type): boolean { + for (const t of types) { + if (t === targetType) { + return true; + } + } + return false; + } + + private matchEts1NumberEts2IntLongMethodSig(ets2Sigs: MethodSignature[], ets1Sig: MethodSignature): MethodSignature | null { + let intSDKMatched: MethodSignature | null = null; + const ets1Params = ets1Sig.getMethodSubSignature().getParameters(); + for (const ets2Sig of ets2Sigs) { + let isInt = false; + let isLong = false; + const ets2Params = ets2Sig.getMethodSubSignature().getParameters(); + if (ets2Params.length !== ets1Params.length) { + continue; + } + for (let i = 0; i < ets1Params.length; i++) { + const ets2ParamType = ets2Params[i].getType(); + const ets1ParamType = ets1Params[i].getType(); + if (ets2ParamType === ets1ParamType) { + continue; + } + if (this.isIntType(ets2ParamType) && ets1ParamType instanceof NumberType) { + isInt = true; + continue; + } + if (this.isLongType(ets2ParamType) && ets1ParamType instanceof NumberType) { + isLong = true; + continue; + } + isInt = false; + isLong = false; + } + if (isLong) { + return ets2Sig; + } + if (isInt) { + intSDKMatched = ets2Sig; + } + } + return intSDKMatched; + } + + private getEts2SdkSignatureWithEts1Method(ets1SDK: ArkMethod, args: Value[], exactMatch: boolean = true): MethodSignature | null { + const ets2Sdks = this.ets2Sdks; + if (ets2Sdks === undefined || ets2Sdks.length === 0) { + return null; + } + + const ets1SigMatched = this.getMatchedSignature(ets1SDK, args); + if (ets1SigMatched === null) { + return null; + } + + const ets1SdkFileName = ets1SDK.getDeclaringArkFile().getName(); + const ets2SdkFiles = this.ets2SdkScene?.getSdkArkFiles().filter(f => { + for (const sdk of ets2Sdks) { + if (fs.existsSync(path.join(sdk.path, ets1SdkFileName)) && f.getName() === ets1SdkFileName) { + return true; + } + const newEts2SdkFileName = ets1SdkFileName.replace('.d.ts', '.d.ets'); + if (fs.existsSync(path.join(sdk.path, newEts2SdkFileName)) && f.getName() === newEts2SdkFileName) { + return true; + } + } + return false; + }); + if (ets2SdkFiles === undefined || ets2SdkFiles.length === 0) { + return null; + } + + for (const file of ets2SdkFiles) { + const ets2SdkMethod = this.getEts2SdkWithEts1SdkInfo(file, ets1SDK); + if (!ets2SdkMethod) { + continue; + } + const declareSigs = ets2SdkMethod.getDeclareSignatures(); + if (declareSigs === null) { + return null; + } + if (!exactMatch && declareSigs.length === 1) { + return declareSigs[0]; + } + return this.matchEts1NumberEts2IntLongMethodSig(declareSigs, ets1SigMatched); + } + return null; + } + + private getEts2SdkWithEts1SdkInfo(ets2File: ArkFile, ets1SDK: ArkMethod): ArkMethod | null { + const ets1Class = ets1SDK.getDeclaringArkClass(); + const ets1Namespace = ets1Class.getDeclaringArkNamespace(); + if (ets1Namespace === undefined) { + return ets2File.getClassWithName(ets1Class.getName())?.getMethodWithName(ets1SDK.getName()) ?? null; + } + return ets2File.getNamespaceWithName(ets1Namespace.getName())?.getClassWithName(ets1Class.getName())?.getMethodWithName(ets1SDK.getName()) ?? null; + } + + // 判断类型是否为int,当前ArkAnalyzer对于int的表示应该是name为int的AliasType或UnclearReferenceType + private isIntType(checkType: Type): boolean { + if (checkType instanceof AliasType || checkType instanceof UnclearReferenceType) { + if (checkType.getName() === this.intTypeName) { + return true; + } + } + return false; + } + + // 判断类型是否为ilong,当前ArkAnalyzer对于long的表示应该是name为long的AliasType或UnclearReferenceType + private isLongType(checkType: Type): boolean { + if (checkType instanceof AliasType || checkType instanceof UnclearReferenceType) { + if (checkType.getName() === this.longTypeName) { + return true; + } + } + return false; + } + + // 此处value作为函数入参、数组下标、a/b,因为三地址码原则的限制,只可能是Local和NumberConstant类型,其他value的类型均不可能存在 + private checkValueOnlyUsedAsIntLong( + stmt: Stmt, + value: Value, + hasChecked: Map, + numberCategory: NumberCategory + ): IssueReason { + if (stmt.getCfg().getDeclaringMethod().getLanguage() !== Language.ARKTS1_2) { + return IssueReason.RelatedWithNonETS2; + } + if (value instanceof NumberConstant) { + if (this.isNumberConstantWithDecimalPoint(value)) { + return IssueReason.UsedWithOtherType; + } + return IssueReason.OnlyUsedAsIntLong; + } + if (value instanceof UndefinedConstant || value instanceof NullConstant) { + // 对于用null或undefined赋值的场景,认为未进行初始化,还需其他赋值语句进行检查 + return IssueReason.OnlyUsedAsIntLong; + } + if (value instanceof Local) { + return this.isLocalOnlyUsedAsIntLong(stmt, value, hasChecked, numberCategory); + } + if (value instanceof AbstractExpr) { + return this.isAbstractExprOnlyUsedAsIntLong(stmt, value, hasChecked, numberCategory); + } + if (value instanceof AbstractRef) { + return this.isAbstractRefOnlyUsedAsIntLong(stmt, value, hasChecked, numberCategory); + } + logger.error(`Need to handle new value type: ${value.getType().getTypeString()}`); + return IssueReason.Other; + } + + private isNumberConstantWithDecimalPoint(constant: NumberConstant): boolean { + return constant.getValue().includes('.'); + } + + private isTypeWithNumberType(localType: Type): boolean { + if (localType instanceof NumberType) { + return true; + } + if (localType instanceof UnionType) { + for (const t of localType.getTypes()) { + if (t instanceof NumberType || t instanceof UndefinedType || t instanceof NullType) { + continue; + } + return false; + } + return true; + } + return false; + } + + private isLocalOnlyUsedAsIntLong( + stmt: Stmt, + local: Local, + hasChecked: Map, + numberCategory: NumberCategory + ): IssueReason { + // hasChecked map中已有此local,若原先为int,现在为long则使用long替换,其余情况不改动,直接返回,避免死循环 + const currentInfo = hasChecked.get(local); + if (currentInfo) { + if (currentInfo[1] === NumberCategory.int && numberCategory === NumberCategory.long) { + hasChecked.set(local, [IssueReason.OnlyUsedAsIntLong, NumberCategory.long]); + } + return IssueReason.OnlyUsedAsIntLong; + } + // 先将value加入map中,默认设置成false,避免后续递归查找阶段出现死循环,最后再根据查找结果绝对是否重新设置成true + hasChecked.set(local, [IssueReason.Other, numberCategory]); + + // 正常情况不会走到此分支,除非类型为any、联合类型等复杂类型,保守处理返回false,不转int + // 对于联合类型仅包含number和null、undefined,可以认为是OK的 + const localType = local.getType(); + if (!this.isTypeWithNumberType(localType)) { + if (localType instanceof UnknownType) { + hasChecked.set(local, [IssueReason.CannotFindAll, numberCategory]); + return IssueReason.CannotFindAll; + } + logger.error(`Local type is not number, local: ${local.getName()}, local type: ${local.getType().getTypeString()}`); + hasChecked.set(local, [IssueReason.UsedWithOtherType, numberCategory]); + return IssueReason.UsedWithOtherType; + } + + let checkStmts: Stmt[] = []; + const declaringStmt = local.getDeclaringStmt(); + if (declaringStmt === null) { + // 无定义语句的local可能来自于import,需要根据import信息查找其原始local + const newLocal = this.getLocalFromGlobal(local) ?? this.getLocalFromImportInfo(local, hasChecked, numberCategory); + if (newLocal === null) { + // local非来自于import,确实是缺少定义语句,或者是从非1.2文件import,直接返回false,因为就算是能确认local仅当做int使用,也找不到定义语句去修改类型注解为int,所以后续检查都没有意义 + logger.error(`Missing declaring stmt, local: ${local.getName()}`); + return hasChecked.get(local)![0]; + } + const declaringStmt = newLocal.getDeclaringStmt(); + if (declaringStmt === null) { + // local变量未找到定义语句,直接返回false,因为就算是能确认local仅当做int使用,也找不到定义语句去修改类型注解为int,所以后续检查都没有意义 + logger.error(`Missing declaring stmt, local: ${local.getName()}`); + hasChecked.set(local, [IssueReason.Other, numberCategory]); + return IssueReason.Other; + } + hasChecked.delete(local); + return this.isLocalOnlyUsedAsIntLong(declaringStmt, newLocal, hasChecked, numberCategory); + } + checkStmts.push(declaringStmt); + local.getUsedStmts().forEach(s => { + if (s !== stmt) { + checkStmts.push(s); + } + }); + // usedStmts中不会记录local为leftOp的stmt,此处需要补充 + declaringStmt + .getCfg() + .getStmts() + .forEach(s => { + if (s === declaringStmt || !(s instanceof ArkAssignStmt) || s.getLeftOp() !== local) { + return; + } + checkStmts.push(s); + }); + + for (const s of checkStmts) { + if (s instanceof ArkAssignStmt && s.getLeftOp() === local) { + const checkRightOp = this.checkValueOnlyUsedAsIntLong(s, s.getRightOp(), hasChecked, numberCategory); + if (checkRightOp !== IssueReason.OnlyUsedAsIntLong) { + return checkRightOp; + } + continue; + } + // 当前检查的local位于赋值语句的右边,若参与除法运算则看做double类型使用,若作为SDK入参依据SDK定义,其余运算、赋值等处理不会影响其自身从int -> number,所以不处理 + if (s instanceof ArkAssignStmt && s.getLeftOp() !== local) { + const rightOp = s.getRightOp(); + if (rightOp instanceof ArkNormalBinopExpr && rightOp.getOperator() === NormalBinaryOperator.Division) { + hasChecked.set(local, [IssueReason.UsedWithOtherType, numberCategory]); + return IssueReason.UsedWithOtherType; + } + if (rightOp instanceof AbstractInvokeExpr) { + const res = this.checkLocalUsedAsSDKArg(rightOp, local, hasChecked); + if (res === null) { + continue; + } + hasChecked.set(local, res); + return res[0]; + } + continue; + } + if (s instanceof ArkInvokeStmt) { + // 函数调用语句,local作为实参或base,除作为SDK入参之外,其余场景不会影响其值的变化,不会导致int被重新赋值为number使用 + const res = this.checkLocalUsedAsSDKArg(s.getInvokeExpr(), local, hasChecked); + if (res === null) { + continue; + } + hasChecked.set(local, res); + return res[0]; + } + if (s instanceof ArkReturnStmt) { + // return语句,local作为返回值,不会影响其值的变化,不会导致int被重新赋值为number使用 + continue; + } + if (s instanceof ArkIfStmt) { + // 条件判断语句,local作为condition expr的op1或op2,进行二元条件判断,不会影响其值的变化,不会导致int被重新赋值为number使用 + continue; + } + logger.error(`Need to check new type of stmt: ${s.toString()}, method: ${s.getCfg().getDeclaringMethod().getSignature().toString()}`); + return IssueReason.Other; + } + hasChecked.set(local, [IssueReason.OnlyUsedAsIntLong, numberCategory]); + return IssueReason.OnlyUsedAsIntLong; + } + + // 判断local是否是SDK invoke expr的入参,且其类型是int或long,否则返回null + private checkLocalUsedAsSDKArg( + expr: AbstractInvokeExpr, + local: Local, + hasChecked: Map + ): [IssueReason, NumberCategory] | null { + const method = this.scene.getMethod(expr.getMethodSignature()); + if (method === null) { + logger.error(`Failed to find method: ${expr.getMethodSignature().toString()}`); + return null; + } + const args = expr.getArgs(); + if (this.isMethodFromSDK(method)) { + const ets2SDKSig = this.getEts2SdkSignatureWithEts1Method(method, args, true); + if (ets2SDKSig === null) { + return null; + } + const argIndex = expr.getArgs().indexOf(local); + if (argIndex < 0 || argIndex >= expr.getArgs().length) { + return null; + } + const params = ets2SDKSig.getMethodSubSignature().getParameters(); + const currLocal = hasChecked.get(local); + if (this.isIntType(params[argIndex].getType())) { + if (currLocal === undefined) { + return [IssueReason.OnlyUsedAsIntLong, NumberCategory.int]; + } + if (currLocal[1] === NumberCategory.long) { + return [IssueReason.OnlyUsedAsIntLong, NumberCategory.long]; + } + return [IssueReason.OnlyUsedAsIntLong, NumberCategory.int]; + } + if (this.isLongType(params[argIndex].getType())) { + return [IssueReason.OnlyUsedAsIntLong, NumberCategory.long]; + } + } + return null; + } + + private getLocalFromGlobal(local: Local): Local | null { + const globalLocal = this.fileGlobalLocals.get(local.getName()); + if (globalLocal === undefined) { + return null; + } + return globalLocal; + } + + private getLocalFromImportInfo(local: Local, hasChecked: Map, numberCategory: NumberCategory): Local | null { + const usedStmts = local.getUsedStmts(); + if (usedStmts.length < 1) { + return null; + } + const importInfo = usedStmts[0].getCfg().getDeclaringMethod().getDeclaringArkFile().getImportInfoBy(local.getName()); + if (importInfo === undefined) { + return null; + } + const exportInfo = importInfo.getLazyExportInfo(); + if (exportInfo === null) { + return null; + } + if (exportInfo.getLanguage() !== Language.ARKTS1_2) { + hasChecked.set(local, [IssueReason.RelatedWithNonETS2, numberCategory]); + return null; + } + const exportLocal = importInfo.getLazyExportInfo()?.getArkExport(); + if (exportLocal === null || exportLocal === undefined) { + return null; + } + if (exportLocal instanceof Local) { + return exportLocal; + } + return null; + } + + private isAbstractExprOnlyUsedAsIntLong( + stmt: Stmt, + expr: AbstractExpr, + hasChecked: Map, + numberCategory: NumberCategory + ): IssueReason { + if (expr instanceof ArkNormalBinopExpr) { + if (expr.getOperator() === NormalBinaryOperator.Division) { + return IssueReason.UsedWithOtherType; + } + const isOp1Int = this.checkValueOnlyUsedAsIntLong(stmt, expr.getOp1(), hasChecked, numberCategory); + const isOp2Int = this.checkValueOnlyUsedAsIntLong(stmt, expr.getOp2(), hasChecked, numberCategory); + if (isOp1Int === IssueReason.OnlyUsedAsIntLong && isOp2Int === IssueReason.OnlyUsedAsIntLong) { + return IssueReason.OnlyUsedAsIntLong; + } + if (isOp1Int === IssueReason.UsedWithOtherType || isOp2Int === IssueReason.UsedWithOtherType) { + return IssueReason.UsedWithOtherType; + } + if (isOp1Int === IssueReason.RelatedWithNonETS2 || isOp2Int === IssueReason.RelatedWithNonETS2) { + return IssueReason.RelatedWithNonETS2; + } + if (isOp1Int === IssueReason.CannotFindAll || isOp2Int === IssueReason.CannotFindAll) { + return IssueReason.CannotFindAll; + } + return IssueReason.Other; + } + if (expr instanceof AbstractInvokeExpr) { + const method = this.scene.getMethod(expr.getMethodSignature()); + if (method === null) { + logger.error(`Failed to find method: ${expr.getMethodSignature().toString()}`); + return IssueReason.Other; + } + if (this.isMethodFromSDK(method)) { + const ets2SDKSig = this.getEts2SdkSignatureWithEts1Method(method, expr.getArgs(), false); + if (ets2SDKSig === null) { + return IssueReason.RelatedWithNonETS2; + } + if (this.isIntType(ets2SDKSig.getType()) || this.isLongType(ets2SDKSig.getType())) { + return IssueReason.OnlyUsedAsIntLong; + } + return IssueReason.UsedWithOtherType; + } + if (method.getLanguage() !== Language.ARKTS1_2) { + return IssueReason.RelatedWithNonETS2; + } + const returnStmt = method.getReturnStmt(); + for (const s of returnStmt) { + if (!(s instanceof ArkReturnStmt)) { + continue; + } + const res = this.checkValueOnlyUsedAsIntLong(s, s.getOp(), hasChecked, numberCategory); + if (res !== IssueReason.OnlyUsedAsIntLong) { + return res; + } + } + return IssueReason.OnlyUsedAsIntLong; + } + if (expr instanceof ArkUnopExpr) { + if (expr.getOperator() === UnaryOperator.Neg || expr.getOperator() === UnaryOperator.BitwiseNot) { + return this.checkValueOnlyUsedAsIntLong(stmt, expr.getOp(), hasChecked, numberCategory); + } + logger.error(`Need to handle new type of unary operator: ${expr.getOperator().toString()}`); + return IssueReason.Other; + } + // 剩余的expr的类型不应该出现在这里,如果出现了表示有场景未考虑到,打印日志记录,进行补充 + logger.error(`Need to handle new type of expr: ${expr.toString()}`); + return IssueReason.Other; + } + + private isAbstractRefOnlyUsedAsIntLong( + stmt: Stmt, + ref: AbstractRef, + hasChecked: Map, + numberCategory: NumberCategory + ): IssueReason { + if (ref instanceof ArkArrayRef) { + // 使用数组中某元素进行赋值的场景很复杂,需要判断index的具体值,需要判断数组中的队应元素的全部使用场景,当前不做检查,直接返回false + return IssueReason.CannotFindAll; + } + if (ref instanceof AbstractFieldRef) { + return this.checkFieldRef(ref, stmt.getCfg().getDeclaringMethod().getDeclaringArkClass().getSignature(), numberCategory); + } + if (ref instanceof ArkParameterRef) { + return this.checkAllArgsOfParameter(stmt, hasChecked, numberCategory); + } + if (ref instanceof ClosureFieldRef) { + return this.checkClosureFieldRef(ref, hasChecked, numberCategory); + } + // 其他ref类型经分析不应该出现在此处,若存在输出日志,通过分析日志信息进行补充处理,包括:ArkCaughtExceptionRef, GlobalRef, ArkThisRef + logger.error(`Need to check new type of ref in stmt: ${stmt.toString()}`); + return IssueReason.Other; + } + + private checkFieldRef(ref: AbstractRef, currentClassSig: ClassSignature, numberCategory: NumberCategory): IssueReason { + const refType = ref.getType(); + if (!(ref instanceof AbstractFieldRef)) { + if (!this.isTypeWithNumberType(refType)) { + if (refType instanceof UnknownType) { + return IssueReason.CannotFindAll; + } + return IssueReason.UsedWithOtherType; + } + // 此处若想充分解析,需要在整个项目中找到该field的所有使用到的地方,效率很低,且很容易找漏,当前不做检查,直接返回false + return IssueReason.CannotFindAll; + } + const fieldBase = ref.getFieldSignature().getDeclaringSignature(); + if (fieldBase instanceof NamespaceSignature) { + return IssueReason.CannotFindAll; + } + const baseClass = this.scene.getClass(fieldBase); + if (baseClass === null) { + return IssueReason.CannotFindAll; + } + if (baseClass.getLanguage() !== Language.ARKTS1_2) { + return IssueReason.RelatedWithNonETS2; + } + if (baseClass.getSignature().toString() !== currentClassSig.toString()) { + return IssueReason.CannotFindAll; + } + const field = baseClass.getField(ref.getFieldSignature()); + if (field === null) { + return IssueReason.CannotFindAll; + } + const fieldName = field.getName(); + const existRes = this.classFieldRes.get(fieldName); + if (existRes !== undefined) { + return existRes[0]; + } + if (!this.isTypeWithNumberType(refType)) { + if (refType instanceof UnknownType) { + const res = IssueReason.CannotFindAll; + this.classFieldRes.set(fieldName, [res, numberCategory]); + return res; + } + const res = IssueReason.UsedWithOtherType; + this.classFieldRes.set(fieldName, [res, numberCategory]); + return res; + } + if (field.containsModifier(ModifierType.READONLY)) { + // 先写入默认值,避免后续查找时出现死循环,得到结果后再进行替换 + this.classFieldRes.set(fieldName, [IssueReason.OnlyUsedAsIntLong, numberCategory]); + const res = this.checkReadonlyFieldInitializer(field, baseClass, numberCategory); + this.classFieldRes.set(fieldName, [res, numberCategory]); + return res; + } + if (field.containsModifier(ModifierType.PRIVATE)) { + this.classFieldRes.set(fieldName, [IssueReason.OnlyUsedAsIntLong, numberCategory]); + const res = this.checkPrivateField(field, baseClass, numberCategory); + this.classFieldRes.set(fieldName, [res, numberCategory]); + return res; + } + // 此处若想充分解析,需要在整个项目中找到该field的所有使用到的地方,效率很低,且很容易找漏,当前不做检查,直接返回false + const res = IssueReason.CannotFindAll; + this.classFieldRes.set(fieldName, [res, numberCategory]); + return res; + } + + private checkReadonlyFieldInitializer(field: ArkField, baseClass: ArkClass, numberCategory: NumberCategory): IssueReason { + const constructorMethod = baseClass.getMethodWithName(CONSTRUCTOR_NAME); + if (constructorMethod === null) { + return IssueReason.CannotFindAll; + } + const res = + this.checkReadonlyFieldInitInMethod(field, constructorMethod, numberCategory) ?? + this.checkReadonlyFieldInitInMethod(field, baseClass.getStaticInitMethod(), numberCategory) ?? + this.checkReadonlyFieldInitInMethod(field, baseClass.getInstanceInitMethod(), numberCategory); + + if (res === null) { + return IssueReason.CannotFindAll; + } + return res; + } + + private checkReadonlyFieldInitInMethod(field: ArkField, method: ArkMethod, numberCategory: NumberCategory): IssueReason | null { + const stmts = method.getCfg()?.getStmts(); + if (stmts === undefined) { + return null; + } + for (const stmt of stmts) { + if (!(stmt instanceof ArkAssignStmt)) { + continue; + } + const leftOp = stmt.getLeftOp(); + if (!(leftOp instanceof AbstractFieldRef)) { + continue; + } + if (leftOp.getFieldName() === field.getName()) { + return this.checkValueOnlyUsedAsIntLong(stmt, stmt.getRightOp(), new Map(), numberCategory); + } + } + return null; + } + + private checkPrivateField(field: ArkField, baseClass: ArkClass, numberCategory: NumberCategory): IssueReason { + if (this.fieldWithSetter(field, baseClass)) { + return IssueReason.CannotFindAll; + } + const methods = baseClass.getMethods(true); + for (const method of methods) { + if (method.getName().startsWith('Set-') || method.getName().startsWith('Get-')) { + continue; + } + const stmts = method.getCfg()?.getStmts(); + if (stmts === undefined) { + continue; + } + for (const stmt of stmts) { + const res = this.checkFieldUsedInStmt(field, stmt, numberCategory); + if (res === null) { + continue; + } + if (res !== IssueReason.OnlyUsedAsIntLong) { + return res; + } + } + } + return IssueReason.OnlyUsedAsIntLong; + } + + // 当前仅查找当前field的fieldRef在左边与fieldRef在右边的场景,其余均不检查,认为cannot find all + private checkFieldUsedInStmt(field: ArkField, stmt: Stmt, numberCategory: NumberCategory): IssueReason | null { + if (stmt instanceof ArkAssignStmt) { + const leftOp = stmt.getLeftOp(); + const rightOp = stmt.getRightOp(); + if (leftOp instanceof AbstractFieldRef) { + if (this.isFieldRefMatchArkField(leftOp, field)) { + return this.checkValueOnlyUsedAsIntLong(stmt, rightOp, new Map(), numberCategory); + } + return null; + } + if (rightOp instanceof AbstractFieldRef) { + if (this.isFieldRefMatchArkField(rightOp, field)) { + if (leftOp instanceof Local && leftOp.getName().startsWith(TEMP_LOCAL_PREFIX)) { + return this.checkTempLocalAssignByFieldRef(leftOp); + } + return IssueReason.OnlyUsedAsIntLong; + } + return null; + } + } + const usedFieldRef = stmt.getFieldRef(); + if (usedFieldRef === undefined) { + return null; + } + if (this.isFieldRefMatchArkField(usedFieldRef, field)) { + return IssueReason.CannotFindAll; + } + return null; + } + + // 此处只判断临时变量是否作为1.2 SDK的入参使用,且该参数的类型为int,则返回Used as int,其他情况均返回cannot find all + private checkTempLocalAssignByFieldRef(tempLocal: Local): IssueReason { + // fieldRef赋值的临时变量,应该有且只有1处usedStmt + const usedStmts = tempLocal.getUsedStmts(); + if (usedStmts.length !== 1) { + return IssueReason.CannotFindAll; + } + const usedStmt = usedStmts[0]; + if (usedStmt instanceof ArkInvokeStmt) { + return this.checkFieldRefUsedInSDKArgs(tempLocal, usedStmt.getInvokeExpr()); + } + if (usedStmt instanceof ArkAssignStmt) { + const rightOp = usedStmt.getRightOp(); + if (rightOp instanceof AbstractInvokeExpr) { + return this.checkFieldRefUsedInSDKArgs(tempLocal, rightOp); + } + return IssueReason.CannotFindAll; + } + return IssueReason.CannotFindAll; + } + + private checkFieldRefUsedInSDKArgs(tempLocal: Local, invokeExpr: AbstractInvokeExpr): IssueReason { + const method = this.scene.getMethod(invokeExpr.getMethodSignature()); + if (method === null) { + return IssueReason.CannotFindAll; + } + const argIndex = invokeExpr.getArgs().indexOf(tempLocal); + if (argIndex < 0 || argIndex >= invokeExpr.getArgs().length) { + return IssueReason.CannotFindAll; + } + if (this.isMethodFromSDK(method)) { + const ets2SDKSig = this.getEts2SdkSignatureWithEts1Method(method, invokeExpr.getArgs()); + if (ets2SDKSig) { + const paramType = ets2SDKSig.getMethodSubSignature().getParameters()[argIndex].getType(); + if (this.isIntType(paramType) || this.isLongType(paramType)) { + return IssueReason.OnlyUsedAsIntLong; + } + } + } + return IssueReason.CannotFindAll; + } + + private isFieldRefMatchArkField(fieldRef: AbstractFieldRef, field: ArkField): boolean { + const refDeclaringSig = fieldRef.getFieldSignature().getDeclaringSignature(); + if (refDeclaringSig instanceof NamespaceSignature) { + return false; + } + if (refDeclaringSig.toString() !== field.getDeclaringArkClass().getSignature().toString()) { + return false; + } + return fieldRef.getFieldName() === field.getName(); + } + + private fieldWithSetter(field: ArkField, baseClass: ArkClass): boolean { + const methods = baseClass.getMethods(); + for (const method of methods) { + if (!method.getName().startsWith('Set-')) { + continue; + } + const stmts = method.getCfg()?.getStmts(); + if (stmts === undefined) { + continue; + } + for (const stmt of stmts) { + if (!(stmt instanceof ArkAssignStmt)) { + continue; + } + const leftOp = stmt.getLeftOp(); + if (!(leftOp instanceof AbstractFieldRef)) { + continue; + } + if (field.getName() === leftOp.getFieldName()) { + return true; + } + } + } + return false; + } + + private checkAllArgsOfParameter(stmt: Stmt, hasChecked: Map, numberCategory: NumberCategory): IssueReason { + let checkAll = { value: true }; + let visited: Set = new Set(); + const result = this.checkFromStmt(stmt, hasChecked, numberCategory, checkAll, visited); + if (!checkAll.value) { + return IssueReason.CannotFindAll; + } + return result; + } + + private checkClosureFieldRef( + closureRef: ClosureFieldRef, + hasChecked: Map, + numberCategory: NumberCategory + ): IssueReason { + const closureBase = closureRef.getBase(); + const baseType = closureBase.getType(); + if (!(baseType instanceof LexicalEnvType)) { + // 此场景应该不可能出现,如果出现说明IR解析错误 + logger.error(`ClosureRef base must be LexicalEnvType, but here is ${baseType.getTypeString()}`); + return IssueReason.Other; + } + const outerLocal = baseType.getClosures().filter(local => local.getName() === closureRef.getFieldName()); + if (outerLocal.length !== 1) { + logger.error('Failed to find the local from outer method of the closure local.'); + return IssueReason.Other; + } + const declaringStmt = outerLocal[0].getDeclaringStmt(); + if (declaringStmt === null) { + logger.error('Failed to find the declaring stmt of the local from outer method of the closure local.'); + return IssueReason.Other; + } + return this.isLocalOnlyUsedAsIntLong(declaringStmt, outerLocal[0], hasChecked, numberCategory); + } + + private checkFromStmt( + stmt: Stmt, + hasChecked: Map, + numberCategory: NumberCategory, + checkAll: { value: boolean }, + visited: Set + ): IssueReason { + const method = stmt.getCfg().getDeclaringMethod(); + if (!this.visited.has(method)) { + this.dvfgBuilder.buildForSingleMethod(method); + this.visited.add(method); + } + + const node = this.dvfg.getOrNewDVFGNode(stmt); + let workList: DVFGNode[] = [node]; + while (workList.length > 0) { + const current = workList.shift()!; + const currentStmt = current.getStmt(); + if (visited.has(currentStmt)) { + continue; + } + visited.add(currentStmt); + + const paramRef = this.isFromParameter(currentStmt); + if (paramRef) { + const paramIdx = paramRef.getIndex(); + const callsites = this.cg.getInvokeStmtByMethod(currentStmt.getCfg().getDeclaringMethod().getSignature()); + this.processCallsites(callsites); + const argMap = this.collectCallSiteArgs(paramIdx, callsites); + this.callDepth++; + if (this.callDepth > CALL_DEPTH_LIMIT) { + checkAll.value = false; + return IssueReason.CannotFindAll; + } + for (const [callSite, arg] of argMap) { + const res = this.checkValueOnlyUsedAsIntLong(callSite, arg, hasChecked, numberCategory); + if (res !== IssueReason.OnlyUsedAsIntLong) { + return res; + } + } + return IssueReason.OnlyUsedAsIntLong; + } + } + return IssueReason.Other; + } + + private processCallsites(callsites: Stmt[]): void { + callsites.forEach(cs => { + const declaringMtd = cs.getCfg().getDeclaringMethod(); + if (!this.visited.has(declaringMtd)) { + this.dvfgBuilder.buildForSingleMethod(declaringMtd); + this.visited.add(declaringMtd); + } + }); + } + + private isFromParameter(stmt: Stmt): ArkParameterRef | undefined { + if (!(stmt instanceof ArkAssignStmt)) { + return undefined; + } + const rightOp = stmt.getRightOp(); + if (rightOp instanceof ArkParameterRef) { + return rightOp; + } + return undefined; + } + + private collectCallSiteArgs(argIdx: number, callsites: Stmt[]): Map { + const argMap = new Map(); + callsites.forEach(callsite => { + argMap.set(callsite, callsite.getInvokeExpr()!.getArg(argIdx)); + }); + return argMap; + } + + private addIssueReport( + ruleCategory: RuleCategory, + numberCategory: NumberCategory, + reason: IssueReason, + couldAutofix: boolean, + issueStmt?: Stmt, + value?: Value, + field?: ArkField, + usedStmt?: Stmt + ): void { + const severity = this.rule.alert ?? this.metaData.severity; + let warnInfo: WarnInfo; + if (field === undefined) { + if (issueStmt && value) { + warnInfo = getLineAndColumn(issueStmt, value, true); + } else { + logger.error('Missing stmt or value when adding issue.'); + return; + } + } else { + warnInfo = { + line: field.getOriginPosition().getLineNo(), + startCol: field.getOriginPosition().getColNo(), + endCol: field.getOriginPosition().getColNo(), + filePath: field.getDeclaringArkClass().getDeclaringArkFile().getFilePath(), + }; + } + let problem: string; + let desc: string; + if (ruleCategory === RuleCategory.SDKIntType) { + problem = 'SDKIntType-' + reason; + if (reason === IssueReason.OnlyUsedAsIntLong) { + if (usedStmt) { + desc = `It has relationship with the arg of SDK API in ${this.getUsedStmtDesc(usedStmt, issueStmt)} and only used as ${numberCategory}, should be defined as ${numberCategory} (${ruleCategory})`; + } else { + logger.error('Missing used stmt when getting issue description'); + return; + } + } else { + desc = `The arg of SDK API should be ${numberCategory} here (${ruleCategory})`; + } + } else { + logger.error(`Have not support rule ${ruleCategory} yet.`); + return; + } + + let defects = new Defects( + warnInfo.line, + warnInfo.startCol, + warnInfo.endCol, + problem, + desc, + severity, + this.rule.ruleId, + warnInfo.filePath, + this.metaData.ruleDocPath, + true, + false, + couldAutofix + ); + + if (couldAutofix) { + const autofix = this.generateRuleFix(warnInfo, reason, numberCategory, issueStmt, value, field); + if (autofix === null) { + defects.fixable = false; + this.issues.push(new IssueReport(defects, undefined)); + } else { + this.issues.push(new IssueReport(defects, autofix)); + } + } else { + this.issues.push(new IssueReport(defects, undefined)); + } + } + + private getUsedStmtDesc(usedStmt: Stmt, issueStmt?: Stmt): string { + const issueFile = issueStmt?.getCfg().getDeclaringMethod().getDeclaringArkFile(); + const usedFile = usedStmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); + const line = usedStmt.getOriginPositionInfo().getLineNo(); + if (issueFile && issueFile !== usedFile) { + return `${path.normalize(usedFile.getName())}: ${line}`; + } + return `line ${line}`; + } + + private generateRuleFix( + warnInfo: WarnInfo, + issueReason: IssueReason, + numberCategory: NumberCategory, + stmt?: Stmt, + value?: Value, + field?: ArkField + ): RuleFix | null { + let arkFile: ArkFile; + if (field) { + arkFile = field.getDeclaringArkClass().getDeclaringArkFile(); + } else if (stmt) { + arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); + } else { + logger.error('Missing both issue stmt and field when generating auto fix info.'); + return null; + } + const sourceFile = AstTreeUtils.getASTNode(arkFile.getName(), arkFile.getCode()); + if (field) { + // warnInfo中对于field的endCol与startCol一样,均为filed首列位置,包含修饰符位置,这里autofix采用整行替换方式进行 + const range = FixUtils.getLineRangeWithStartCol(sourceFile, warnInfo.line, warnInfo.startCol); + if (range === null) { + logger.error('Failed to getting range info of issue file when generating auto fix info.'); + return null; + } + const valueString = FixUtils.getSourceWithRange(sourceFile, range); + if (valueString === null) { + logger.error('Failed to getting text of the fix range info when generating auto fix info.'); + return null; + } + const fixedText = this.generateFixedTextForFieldDefine(valueString, numberCategory); + if (fixedText === null) { + logger.error('Failed to get fix text when generating auto fix info.'); + return null; + } + const ruleFix = new RuleFix(); + ruleFix.range = range; + ruleFix.text = fixedText; + return ruleFix; + } + + if (issueReason === IssueReason.OnlyUsedAsIntLong) { + // warnInfo中对于变量声明语句的位置信息只包括变量名,不包括变量声明时的类型注解位置,此处获取变量名后到行尾的字符串信息,替换‘: number’ 或增加 ‘: int’ + const range = FixUtils.getLineRangeWithStartCol(sourceFile, warnInfo.line, warnInfo.endCol); + if (range === null) { + logger.error('Failed to getting range info of issue file when generating auto fix info.'); + return null; + } + const valueString = FixUtils.getSourceWithRange(sourceFile, range); + if (valueString === null) { + logger.error('Failed to getting text of the fix range info when generating auto fix info.'); + return null; + } + const fixedText = this.generateFixedTextForVariableDefine(valueString, numberCategory); + if (fixedText === null) { + logger.error('Failed to get fix text when generating auto fix info.'); + return null; + } + const ruleFix = new RuleFix(); + ruleFix.range = range; + ruleFix.text = fixedText; + return ruleFix; + } + // 强转场景,获取到对应位置信息,在其后添加'.toInt()'或'.toLong()' + let endLine = warnInfo.line; + if (warnInfo.endLine !== undefined) { + endLine = warnInfo.endLine; + } + const range = FixUtils.getRangeWithAst(sourceFile, { + startLine: warnInfo.line, + startCol: warnInfo.startCol, + endLine: endLine, + endCol: warnInfo.endCol, + }); + if (range === null) { + logger.error('Failed to getting range info of issue file when generating auto fix info.'); + return null; + } + const valueString = FixUtils.getSourceWithRange(sourceFile, range); + if (valueString === null) { + logger.error('Failed to getting text of the fix range info when generating auto fix info.'); + return null; + } + const ruleFix = new RuleFix(); + ruleFix.range = range; + if (value === undefined) { + logger.error('Missing issue SDK arg when generating auto fix info.'); + return null; + } + let transStr: string; + if (numberCategory === NumberCategory.int) { + transStr = '.toInt()'; + } else if (numberCategory === NumberCategory.long) { + transStr = '.toLong()'; + } else { + logger.error(`Have not support number category ${numberCategory} yet.`); + return null; + } + if (value instanceof Local) { + if (!value.getName().startsWith(TEMP_LOCAL_PREFIX)) { + ruleFix.text = `${valueString}${transStr}`; + return ruleFix; + } + const declaringStmt = value.getDeclaringStmt(); + if (declaringStmt === null) { + ruleFix.text = `(${valueString})${transStr}`; + return ruleFix; + } + if (declaringStmt instanceof ArkAssignStmt) { + const rightOp = declaringStmt.getRightOp(); + if (rightOp instanceof AbstractInvokeExpr || rightOp instanceof AbstractFieldRef || rightOp instanceof ArkArrayRef) { + ruleFix.text = `${valueString}${transStr}`; + return ruleFix; + } + ruleFix.text = `(${valueString})${transStr}`; + return ruleFix; + } + logger.error('Temp local declaring stmt must be assign stmt.'); + return null; + } else { + ruleFix.text = `(${valueString})${transStr}`; + return ruleFix; + } + } + + private generateFixedTextForFieldDefine(originalText: string, numberCategory: NumberCategory): string | null { + // 对于类属性private a: number 或 private a, originalText为private开始到行尾的内容,需要替换为private a: int + let newTypeStr: string; + if (numberCategory === NumberCategory.int) { + newTypeStr = this.intTypeName; + } else if (numberCategory === NumberCategory.long) { + newTypeStr = this.longTypeName; + } else { + logger.error(`Have not support number category ${numberCategory} yet.`); + return null; + } + let match = originalText.match(/^([^=;]+:[^=;]+)([\s\S]*)$/); + if (match !== null && match.length > 2) { + return match[1].replace('number', newTypeStr) + match[2]; + } + // 对于private a = 123,originalText为private开始到行尾的内容,需要替换为private a: int = 123 + match = originalText.match(/^([^=;]+)([\s\S]*)$/); + if (match !== null && match.length > 2) { + return `${match[1].trimEnd()}: ${newTypeStr} ${match[2]}`; + } + return null; + } + + private generateFixedTextForVariableDefine(originalText: string, numberCategory: NumberCategory): string | null { + // 对于let a = xxx, originalText为' = xxx,',需要替换成': int = xxx' + // 对于let a: number | null = xxx, originalText为': number | null = xxx,',需要替换成': int | null = xxx' + // 对于foo(a: number, b: string)场景, originalText为‘: number, b: string)’,需要替换为foo(a: int, b: string) + // 场景1:变量或类属性定义或函数入参,无类型注解的场景,直接在originalText前面添加': int' + let newTypeStr: string; + if (numberCategory === NumberCategory.int) { + newTypeStr = this.intTypeName; + } else if (numberCategory === NumberCategory.long) { + newTypeStr = this.longTypeName; + } else { + logger.error(`Have not support number category ${numberCategory} yet.`); + return null; + } + if (!originalText.trimStart().startsWith(':')) { + if (originalText.startsWith(';') || originalText.startsWith(FixUtils.getTextEof(originalText))) { + return `: ${newTypeStr}${originalText}`; + } + return `: ${newTypeStr} ${originalText.trimStart()}`; + } + // 场景2:变量或类属性定义或函数入参,有类型注解的场景 + const match = originalText.match(/^(\s*:[^,)=;]+)([\s\S]*)$/); + if (match === null || match.length < 3) { + return null; + } + const newAnnotation = match[1].replace('number', newTypeStr); + return newAnnotation + match[2]; + } +} diff --git a/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts index f0c756eeed65cc84bb277074184935aa415a0b5a..80bf82743066d807cae69c9eb67854bf1f9bc249 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts @@ -69,14 +69,23 @@ export class ObjectLiteralCheck implements BaseChecker { for (let arkFile of scene.getFiles()) { const topLevelVarMap: Map = new Map(); this.collectImportedVar(topLevelVarMap, arkFile, scene); - this.collectTopLevelVar(topLevelVarMap, arkFile, scene); + this.collectTopLevelVar(topLevelVarMap, arkFile.getDefaultClass(), scene); - const handleClass = (cls: ArkClass): void => { - cls.getMethods().forEach(m => this.processArkMethod(m, topLevelVarMap, scene)); + const handleClass = (cls: ArkClass, localTopLevelVar: Map | undefined = undefined): void => { + if (!localTopLevelVar) { + cls.getMethods().forEach(m => this.processArkMethod(m, topLevelVarMap, scene)); + } else { + topLevelVarMap.forEach((v, k) => localTopLevelVar.set(k, v)); + cls.getMethods().forEach(m => this.processArkMethod(m, localTopLevelVar, scene)); + } }; arkFile.getClasses().forEach(cls => handleClass(cls)); - arkFile.getAllNamespacesUnderThisFile().forEach(n => n.getClasses().forEach(cls => handleClass(cls))); + arkFile.getAllNamespacesUnderThisFile().forEach(n => { + const localTopLevelVar: Map = new Map(); + this.collectTopLevelVar(localTopLevelVar, n.getDefaultClass(), scene); + n.getClasses().forEach(cls => handleClass(cls, localTopLevelVar)); + }); } }; @@ -106,7 +115,7 @@ export class ObjectLiteralCheck implements BaseChecker { } } - private collectImportedVar(importVarMap: Map, file: ArkFile, scene: Scene) { + private collectImportedVar(importVarMap: Map, file: ArkFile, scene: Scene): void { file.getImportInfos().forEach(importInfo => { const exportInfo = importInfo.getLazyExportInfo(); if (exportInfo === null) { @@ -125,8 +134,8 @@ export class ObjectLiteralCheck implements BaseChecker { }); } - private collectTopLevelVar(topLevelVarMap: Map, file: ArkFile, scene: Scene) { - const defaultMethod = file.getDefaultClass().getDefaultArkMethod(); + private collectTopLevelVar(topLevelVarMap: Map, defaultClass: ArkClass, scene: Scene): void { + const defaultMethod = defaultClass.getDefaultArkMethod(); if (!defaultMethod) { return; } @@ -136,11 +145,16 @@ export class ObjectLiteralCheck implements BaseChecker { if (!(stmt instanceof ArkAssignStmt)) { continue; } + let name = undefined; const leftOp = stmt.getLeftOp(); - if (!(leftOp instanceof Local)) { + if (leftOp instanceof Local) { + name = leftOp.getName(); + } else if (leftOp instanceof ArkInstanceFieldRef && leftOp.getBase() instanceof Local) { + name = `${leftOp.getBase().getName()}.${leftOp.getFieldSignature().getFieldName()}`; + } + if (!name) { continue; } - const name = leftOp.getName(); if (name.startsWith('%') || name === 'this') { continue; } @@ -174,23 +188,20 @@ export class ObjectLiteralCheck implements BaseChecker { res.push(currentStmt); continue; } + const gvName = this.checkIfIsTopLevelVar(currentStmt); + if (gvName) { + const globalDefs = topLevelVarMap.get(gvName); + globalDefs?.forEach(d => { + worklist.push(DVFGHelper.getOrNewDVFGNode(d, scene)); + }); + } const isClsField = this.isClassField(currentStmt, scene); if (isClsField) { isClsField.forEach(d => worklist.push(DVFGHelper.getOrNewDVFGNode(d, scene))); - continue; } const isArrayField = this.isArrayField(currentStmt, topLevelVarMap); if (isArrayField) { isArrayField.forEach(d => worklist.push(DVFGHelper.getOrNewDVFGNode(d, scene))); - continue; - } - const gv = this.checkIfIsTopLevelVar(currentStmt); - if (gv) { - const globalDefs = topLevelVarMap.get(gv.getName()); - globalDefs?.forEach(d => { - worklist.push(DVFGHelper.getOrNewDVFGNode(d, scene)); - }); - continue; } const callsite = this.cg.getCallSiteByStmt(currentStmt); callsite.forEach(cs => { @@ -215,20 +226,23 @@ export class ObjectLiteralCheck implements BaseChecker { } } - private checkIfIsTopLevelVar(stmt: Stmt): Local | undefined { + private checkIfIsTopLevelVar(stmt: Stmt): string | undefined { if (!(stmt instanceof ArkAssignStmt)) { return undefined; } const rightOp = stmt.getRightOp(); if (rightOp instanceof Local && !rightOp.getDeclaringStmt()) { - return rightOp; + return rightOp.getName(); + } + if (rightOp instanceof ArkInstanceFieldRef && rightOp.getBase() instanceof Local) { + return `${rightOp.getBase().getName()}.${rightOp.getFieldSignature().getFieldName()}`; } if (!(rightOp instanceof ArkInstanceOfExpr)) { return undefined; } const obj = rightOp.getOp(); if (obj instanceof Local && !obj.getDeclaringStmt()) { - return obj; + return obj.getName(); } return undefined; } @@ -266,9 +280,6 @@ export class ObjectLiteralCheck implements BaseChecker { if (!(clsField instanceof AbstractFieldRef)) { return undefined; } - if (clsField instanceof ArkInstanceFieldRef && clsField.getBase().getName() !== 'this') { - return undefined; - } const fieldSig = clsField.getFieldSignature(); const clsSig = fieldSig.getDeclaringSignature(); if (!(clsSig instanceof ClassSignature)) { @@ -360,7 +371,10 @@ export class ObjectLiteralCheck implements BaseChecker { const problem = 'ObjectLiteral'; let desc = `${this.metaData.description} (${this.rule.ruleId.replace('@migration/', '')})`; if (!checkAll) { - desc = `Can not check when function call chain depth exceeds ${CALL_DEPTH_LIMIT}, please check it manually (${this.rule.ruleId.replace('@migration/', '')})`; + desc = `Can not check when function call chain depth exceeds ${CALL_DEPTH_LIMIT}, please check it manually (${this.rule.ruleId.replace( + '@migration/', + '' + )})`; } let defects = new Defects( warnInfo.line, diff --git a/ets2panda/linter/homecheck/src/checker/migration/Utils.ts b/ets2panda/linter/homecheck/src/checker/migration/Utils.ts index 02f114bd0f9d453a33f779834c19a9159a462b57..a0b77df3ebc6cb43645c1bd20279a3ea6b06b906 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/Utils.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/Utils.ts @@ -143,15 +143,20 @@ export function getLanguageStr(language: Language): string { return targetLan; } -export function getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { +export function getLineAndColumn(stmt: Stmt, operand: Value, exactEndInfo: boolean = false): WarnInfo { const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); const line = originPosition.getFirstLine(); const startCol = originPosition.getFirstCol(); - const endCol = startCol; - return { line, startCol, endCol, filePath: originPath }; + if (exactEndInfo) { + const endLine = originPosition.getLastLine(); + const endCol = originPosition.getLastCol(); + return { line, startCol, endLine: endLine, endCol: endCol, filePath: originPath }; + } else { + return { line, startCol, endCol: startCol, filePath: originPath }; + } } else { logger.debug('ArkFile or operand position is null.'); } @@ -177,3 +182,23 @@ export function getGlobalsDefineInDefaultMethod(defaultMethod: ArkMethod): Map { + const globals: Map = new Map(); + const stmts = defaultMethod.getBody()?.getCfg().getStmts() ?? []; + for (const stmt of stmts) { + if (!(stmt instanceof ArkAssignStmt)) { + continue; + } + const leftOp = stmt.getLeftOp(); + if (!(leftOp instanceof Local)) { + continue; + } + const name = leftOp.getName(); + if (name.startsWith('%') || name === 'this') { + continue; + } + globals.set(leftOp.getName(), leftOp); + } + return globals; +} diff --git a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchClass.ts b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchClass.ts index 1e1565a7c11baa8e3724136b4dbf4440a6161f89..d80c6a094fab957fe2c4b7be98d074762bf7371a 100644 --- a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchClass.ts +++ b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchClass.ts @@ -15,6 +15,9 @@ import { ArkClass, ArkFile } from 'arkanalyzer'; import { ClassMatcher, isMatchedFile, isMatchedNamespace, isMatchedClass } from '../Matchers'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'matchClass'); export function matchClass(arkFiles: ArkFile[], matcher: ClassMatcher, callback: Function): void { for (let arkFile of arkFiles) { @@ -34,7 +37,11 @@ export function matchClass(arkFiles: ArkFile[], matcher: ClassMatcher, callback: function matchClassProcess(matcher: ClassMatcher, classes: ArkClass[], callback: Function): void { for (const arkClass of classes) { if (isMatchedClass(arkClass, [matcher])) { - callback(arkClass); + try { + callback(arkClass); + } catch (error) { + logger.error('Error in class callback: ', error); + } } } } diff --git a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFields.ts b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFields.ts index f42fd5d7031c4764bedf8cb9a7d68bfc4606cf79..359b3aa728d27cc546f518af8c26b154c2cae642 100644 --- a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFields.ts +++ b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFields.ts @@ -15,7 +15,9 @@ import { ArkClass, ArkFile } from 'arkanalyzer'; import { isMatchedFile, isMatchedNamespace, isMatchedClass, FieldMatcher, isMatchedField } from '../Matchers'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'matchFields'); export function matchFields(arkFiles: ArkFile[], matcher: FieldMatcher, callback: Function): void { for (let arkFile of arkFiles) { @@ -26,20 +28,22 @@ export function matchFields(arkFiles: ArkFile[], matcher: FieldMatcher, callback if (matcher.namespace && !isMatchedNamespace(ns, matcher.namespace)) { continue; } - matchFieldsInClasses(matcher, ns.getClasses(), callback); + ns.getClasses().forEach(cls => matchFieldsInClass(matcher, cls, callback)); } - matchFieldsInClasses(matcher, arkFile.getClasses(), callback); + arkFile.getClasses().forEach(cls => matchFieldsInClass(matcher, cls, callback)); } } -function matchFieldsInClasses(matcher: FieldMatcher, classes: ArkClass[], callback: Function): void { - for (const arkClass of classes) { - if (matcher.class && !isMatchedClass(arkClass, matcher.class)) { - continue; - } - for (const arkField of arkClass.getFields()) { - if (isMatchedField(arkField, [matcher])) { +function matchFieldsInClass(matcher: FieldMatcher, arkClass: ArkClass, callback: Function): void { + if (matcher.class && !isMatchedClass(arkClass, matcher.class)) { + return; + } + for (const arkField of arkClass.getFields()) { + if (isMatchedField(arkField, [matcher])) { + try { callback(arkField); + } catch (error) { + logger.error('Error in field callback: ', error); } } } diff --git a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFiles.ts b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFiles.ts index 560fa54470b8a7becc532bc7b8d19410ad9aad55..522c96873f2e64174b1500b8d7199accf5d1ae15 100644 --- a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFiles.ts +++ b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchFiles.ts @@ -15,11 +15,18 @@ import { ArkFile } from 'arkanalyzer'; import { FileMatcher, isMatchedFile } from '../Matchers'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'matchFiles'); export function matchFiles(arkFiles: ArkFile[], matcher: FileMatcher, callback: Function): void { for (let arkFile of arkFiles) { if (isMatchedFile(arkFile, [matcher])) { - callback(arkFile); + try { + callback(arkFile); + } catch (error) { + logger.error('Error in file callback: ', error); + } } } } \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchNameSpaces.ts b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchNameSpaces.ts index 82b42d2ad657e52a7fed48627ea98a31605c8321..3e14f4ff98e131a9f5325d38dd298cf4baf5de1c 100644 --- a/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchNameSpaces.ts +++ b/ets2panda/linter/homecheck/src/matcher/matcherAdapter/matchNameSpaces.ts @@ -15,6 +15,10 @@ import { ArkFile } from 'arkanalyzer'; import { NamespaceMatcher, isMatchedFile, isMatchedNamespace } from '../Matchers'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; +import { ArkNamespace } from 'arkanalyzer/lib'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'matchNameSpaces'); export function matchNameSpaces(arkFiles: ArkFile[], matcher: NamespaceMatcher, callback: Function): void { for (let arkFile of arkFiles) { @@ -22,9 +26,17 @@ export function matchNameSpaces(arkFiles: ArkFile[], matcher: NamespaceMatcher, continue; } for (const ns of arkFile.getAllNamespacesUnderThisFile()) { - if (isMatchedNamespace(ns, [matcher])) { - callback(ns); - } + matchNamespace(ns, matcher, callback); + } + } +} + +function matchNamespace(ns: ArkNamespace, matcher: NamespaceMatcher, callback: Function): void { + if (isMatchedNamespace(ns, [matcher])) { + try { + callback(ns); + } catch (error) { + logger.error('Error in namespace callback: ', error); } } } \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/model/File2Check.ts b/ets2panda/linter/homecheck/src/model/File2Check.ts index ecfc86270a7f9738fe6afd6ca45319a27f073504..f34f7e142014c745c4a44a142d450f6c92b2aeac 100644 --- a/ets2panda/linter/homecheck/src/model/File2Check.ts +++ b/ets2panda/linter/homecheck/src/model/File2Check.ts @@ -105,8 +105,12 @@ export class File2Check { } public async checkDisable(): Promise { - const fileLineList = await FileUtils.readLinesFromFile(this.arkFile.getFilePath()); - this.issues = await filterDisableIssue(fileLineList, this.issues, this.arkFile.getFilePath()); + try { + const fileLineList = await FileUtils.readLinesFromFile(this.arkFile.getFilePath()); + this.issues = await filterDisableIssue(fileLineList, this.issues, this.arkFile.getFilePath()); + } catch (e) { + logger.error(e); + } } public async run(): Promise { diff --git a/ets2panda/linter/homecheck/src/model/Project2Check.ts b/ets2panda/linter/homecheck/src/model/Project2Check.ts index 3e9c1bf9ed811aeca8b3a79474ba520156a057d6..47bd6995466e10f5274f5b3149c8975186817832 100644 --- a/ets2panda/linter/homecheck/src/model/Project2Check.ts +++ b/ets2panda/linter/homecheck/src/model/Project2Check.ts @@ -85,40 +85,34 @@ export class Project2Check { } public async emitCheck(): Promise { - await Promise.all(Array.from(this.enabledRuleCheckerMap.values()).map(checker => { - try { - this.processSceneCallbacks(); - this.flMatcherMap.forEach((callback, matcher) => { - matchFiles(this.arkFiles, matcher, callback); - }); - this.nsMatcherMap.forEach((callback, matcher) => { - matchNameSpaces(this.arkFiles, matcher, callback); - }); - this.clsMatcherMap.forEach((callback, matcher) => { - matchClass(this.arkFiles, matcher, callback); - }); - this.mtdMatcherMap.forEach((callback, matcher) => { - matchMethods(this.arkFiles, matcher, callback); - }); - this.fieldMatcherMap.forEach((callback, matcher) => { - matchFields(this.arkFiles, matcher, callback); - }); - } catch (error) { - logger.error(`Checker ${checker.rule.ruleId} error: `, error); - } - })); + this.processSceneCallbacks(); + this.flMatcherMap.forEach((callback, matcher) => { + matchFiles(this.arkFiles, matcher, callback); + }); + this.nsMatcherMap.forEach((callback, matcher) => { + matchNameSpaces(this.arkFiles, matcher, callback); + }); + this.clsMatcherMap.forEach((callback, matcher) => { + matchClass(this.arkFiles, matcher, callback); + }); + this.mtdMatcherMap.forEach((callback, matcher) => { + matchMethods(this.arkFiles, matcher, callback); + }); + this.fieldMatcherMap.forEach((callback, matcher) => { + matchFields(this.arkFiles, matcher, callback); + }); } private processSceneCallbacks(): void { - try { - this.sceneCallBacks.forEach((callback) => { - if (this.arkFiles.length !== 0) { + this.sceneCallBacks.forEach((callback) => { + if (this.arkFiles.length !== 0) { + try { callback(this.arkFiles[0].getScene()); + } catch (error) { + logger.error(`Error in scene callback: `, error); } - }); - } catch (error) { - logger.error(`Error in scene callbacks: `, error); - } + } + }); } public collectIssues(): void { @@ -167,10 +161,14 @@ export class Project2Check { if (!fs.existsSync(filePath)) { continue; } - const fileLineList = await FileUtils.readLinesFromFile(filePath); - const filtedResult = await filterDisableIssue(fileLineList, [issue], filePath); - if (filtedResult.length > 0) { - filtedIssues = filtedIssues.concat(filtedResult[0]); + try { + const fileLineList = await FileUtils.readLinesFromFile(filePath); + const filtedResult = await filterDisableIssue(fileLineList, [issue], filePath); + if (filtedResult.length > 0) { + filtedIssues = filtedIssues.concat(filtedResult[0]); + } + } catch (e) { + logger.error(e); } } this.issues = filtedIssues; @@ -182,4 +180,4 @@ export class Project2Check { this.collectIssues(); await this.checkDisable(); } -} \ No newline at end of file +} diff --git a/ets2panda/linter/homecheck/src/utils/common/CheckEntry.ts b/ets2panda/linter/homecheck/src/utils/common/CheckEntry.ts index b8a14fa1bd730f7211f967f3af6e2d63ac2d7df5..cb365aed60e80e063ba681c826fbe964ac4f1c4c 100644 --- a/ets2panda/linter/homecheck/src/utils/common/CheckEntry.ts +++ b/ets2panda/linter/homecheck/src/utils/common/CheckEntry.ts @@ -269,9 +269,7 @@ function buildScene(fileList: string[], checkEntry: CheckEntry): boolean { checkEntry.scene.buildSceneFromFiles(sceneConfig); logger.info('Build scene completed.'); checkEntry.scene.inferTypes(); - logger.info('No.1 Infer types completed.'); - checkEntry.scene.inferTypes(); - logger.info('No.2 Infer types completed.'); + logger.info('Infer types completed.'); } catch (error) { logger.error('Build scene or infer types error: ', error); return false; diff --git a/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts b/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts index 9e43517c0f45412bcb8917da2dbedb2011e8908b..87e4b92bb2bd28ca80bc668668c37d9ff2045a0b 100644 --- a/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts +++ b/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts @@ -29,6 +29,7 @@ import { InteropJSModifyPropertyCheck } from '../../checker/migration/InteropJSM import { NoTSLikeAsCheck } from '../../checker/migration/NoTSLikeAsCheck'; import { InteropS2DObjectLiteralCheck } from '../../checker/migration/InteropS2DObjectLiteralsCheck'; import { InteropDeprecatedBuiltInAPICheck } from '../../checker/migration/InteropDeprecatedBuiltInAPICheck'; +import { NumericSemanticCheck } from '../../checker/migration/NumericSemanticCheck'; const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'CheckerIndex'); @@ -51,6 +52,7 @@ export const projectRules = { '@migration/interop-dynamic-object-literals': InteropObjectLiteralCheck, '@migration/arkts-no-ts-like-as': NoTSLikeAsCheck, '@migration/arkts-interop-s2d-dynamic-call-builtin-api-not-in-static': InteropDeprecatedBuiltInAPICheck, + '@migration/arkts-numeric-semantic': NumericSemanticCheck, }; // 新增文件级的checker,需要在此处注册 diff --git a/ets2panda/linter/homecheck/src/utils/common/Disable.ts b/ets2panda/linter/homecheck/src/utils/common/Disable.ts index e8f86a26181832606afabbf6b5748401fd0220e1..a33205ff20ae64f978186253320995756b2b4308 100644 --- a/ets2panda/linter/homecheck/src/utils/common/Disable.ts +++ b/ets2panda/linter/homecheck/src/utils/common/Disable.ts @@ -17,6 +17,9 @@ import * as fs from 'fs'; import path from 'path'; import { IssueReport } from '../../model/Defects'; import { FileUtils } from '../../Index'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'Disable'); export const DisableText = { FILE_DISABLE_TEXT: '\/* homecheck-disable *\/', @@ -25,23 +28,27 @@ export const DisableText = { export async function filterDisableIssue(lineList: string[], issues: IssueReport[], filePath: string): Promise { let filtedIssues: IssueReport[] = []; - for (const issue of issues) { - // @migration/arkui-data-observation规则的自动修复是在定义处,存在跨文件场景 - const actualFilePath = path.normalize(issue.defect.mergeKey.split('%')[0]); - if (path.normalize(actualFilePath) !== path.normalize(filePath)) { - if (!fs.existsSync(actualFilePath)) { + try { + for (const issue of issues) { + // @migration/arkui-data-observation规则的自动修复是在定义处,存在跨文件场景 + const actualFilePath = path.normalize(issue.defect.mergeKey.split('%')[0]); + if (path.normalize(actualFilePath) !== path.normalize(filePath)) { + if (!fs.existsSync(actualFilePath)) { + continue; + } + lineList = await FileUtils.readLinesFromFile(actualFilePath); + } + // 有些特殊规则允许返回行列号为0 + if (issue.defect.reportLine < 0 || issue.defect.reportLine - 1 > lineList.length) { continue; } - lineList = await FileUtils.readLinesFromFile(actualFilePath); - } - // 有些特殊规则允许返回行列号为0 - if (issue.defect.reportLine < 0 || issue.defect.reportLine - 1 > lineList.length) { - continue; - } - const text = lineList[issue.defect.reportLine - 2]; - if (!isDisableIssue(text, issue.defect.ruleId)) { - filtedIssues.push(issue); + const text = lineList[issue.defect.reportLine - 2]; + if (!isDisableIssue(text, issue.defect.ruleId)) { + filtedIssues.push(issue); + } } + } catch (e) { + logger.error(e); } return filtedIssues; } diff --git a/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts b/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts index f17425f284605ab9f4cd9738a2ec9fc9c72121ba..a69df56e6afb4c77b4338e97aefb530e8d505f6f 100644 --- a/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts +++ b/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts @@ -67,12 +67,16 @@ export class FileUtils { let result: string[] = []; for (const filePath of fileList) { if (!ignoreGlob?.matchGlob(filePath) && fileGlob.matchGlob(filePath)) { - // 读取file文件内容首行,若为屏蔽行则跳过 - const firstLineText = await this.readLinesFromFile(filePath, 1); - if (firstLineText.includes(DisableText.FILE_DISABLE_TEXT)) { - continue; + try { + // 读取file文件内容首行,若为屏蔽行则跳过 + const firstLineText = await this.readLinesFromFile(filePath, 1); + if (firstLineText.includes(DisableText.FILE_DISABLE_TEXT)) { + continue; + } + result.push(filePath); + } catch (e) { + logger.error(e); } - result.push(filePath); } } return result; @@ -310,4 +314,4 @@ export class FileUtils { export enum WriteFileMode { OVERWRITE, APPEND -} +} \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/utils/common/FixUtils.ts b/ets2panda/linter/homecheck/src/utils/common/FixUtils.ts index 3dc2fc66733fdae58cb1bfce65f1c6f142202226..3ed7f79a2561d7ad1835ab680058b72b5649b652 100644 --- a/ets2panda/linter/homecheck/src/utils/common/FixUtils.ts +++ b/ets2panda/linter/homecheck/src/utils/common/FixUtils.ts @@ -62,7 +62,10 @@ export class FixUtils { } // 根据输入的代码片段的起始、结束行列号信息,计算此代码片段在该文件中的起始偏移量、结束偏移量数据 - public static getRangeWithAst(sourceFile: ts.SourceFile, fixPosition: FixPosition): Range { + public static getRangeWithAst(sourceFile: ts.SourceFile, fixPosition: FixPosition): Range | null { + if (fixPosition.startLine < 1 || fixPosition.startCol < 1 || fixPosition.endLine < 1 || fixPosition.endCol < 1) { + return null; + } const startNumber = ts.getPositionOfLineAndCharacter(sourceFile, fixPosition.startLine - 1, fixPosition.startCol - 1); const endNumber = ts.getPositionOfLineAndCharacter(sourceFile, fixPosition.endLine - 1, fixPosition.endCol - 1); return [startNumber, endNumber]; @@ -89,6 +92,19 @@ export class FixUtils { return [startPos, endPos]; } + public static getLineRangeWithStartCol(sourceFile: ts.SourceFile, lineNumber: number, startCol: number): Range | null { + const lineRange = this.getLineRange(sourceFile, lineNumber); + if (lineRange === null) { + return null; + } + const newStartPos = lineRange[0] + startCol - 1; + const endPos = lineRange[1]; + if (newStartPos <= endPos) { + return [newStartPos, endPos]; + } + return null; + } + // 根据给定的起始、结束偏移量数据,获取此段代码片段的源码字符串,位置信息不合法则返回null public static getSourceWithRange(sourceFile: ts.SourceFile, range: Range): string | null { const start = range[0]; diff --git a/ets2panda/linter/homecheck/src/utils/common/ScopeHelper.ts b/ets2panda/linter/homecheck/src/utils/common/ScopeHelper.ts index 4c481600dd009dad67fafa8ca5b435c070501d5d..461709e972e03af3f9ed3dbbd348a40167003a21 100644 --- a/ets2panda/linter/homecheck/src/utils/common/ScopeHelper.ts +++ b/ets2panda/linter/homecheck/src/utils/common/ScopeHelper.ts @@ -226,7 +226,7 @@ export class ScopeHelper { const succStmts = succBlock.getStmts(); if (succStmts.length > 0 && this.gTernaryConditionLines.has(succStmts[0].getOriginPositionInfo().getLineNo())) { return true; - } else if (predBlocks.length === 1 && this.gTernaryConditionLines.has(predBlocks?.[0].getStmts()?.at(-1)?.getOriginPositionInfo().getLineNo() ?? 0)) { + } else if (predBlocks.length === 1 && this.gTernaryConditionLines.has(predBlocks[0].getTail()?.getOriginPositionInfo().getLineNo() ?? 0)) { return true; } else { return false; diff --git a/ets2panda/linter/homecheck/src/utils/common/Utils.ts b/ets2panda/linter/homecheck/src/utils/common/Utils.ts index 3dcd8e695dd64f97ac29613b27d93040d7bcabc1..ec11b8d08669664c6cb3377e7c7f3e45437c79fa 100644 --- a/ets2panda/linter/homecheck/src/utils/common/Utils.ts +++ b/ets2panda/linter/homecheck/src/utils/common/Utils.ts @@ -14,6 +14,8 @@ */ import Logger, { LOG_LEVEL, LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { Command, OptionValues } from 'commander'; +import {SceneConfig, Sdk} from "arkanalyzer/lib/Config"; +import {Scene} from "arkanalyzer"; const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'Utils'); @@ -84,11 +86,22 @@ export class Utils { } return colA - colB; } + + public static generateSceneForEts2SDK(sdks: Sdk[]): Scene { + const sceneConfig: SceneConfig = new SceneConfig(); + sceneConfig.buildConfig('ets2SDK', '', sdks); + sceneConfig.getOptions().enableBuiltIn = false; + + const scene = new Scene(); + scene.buildSceneFromProjectDir(sceneConfig); + return scene; + } } export type WarnInfo = { line: number, startCol: number, + endLine?: number, endCol: number, - filePath: string + filePath: string, }; diff --git a/ets2panda/linter/package.json b/ets2panda/linter/package.json index 79b9616cacddffea520e2f4b40a491ba4737a2cf..0db61d9e690e81bfb3983d6627a147f86b7c035b 100644 --- a/ets2panda/linter/package.json +++ b/ets2panda/linter/package.json @@ -4,7 +4,7 @@ "main": "dist/tslinter.js", "bin": "bin/tslinter.js", "files": [ - "dist/*","rule-config.json" + "dist/*","rule-config.json","docs/rules-cn/*" ], "private": true, "license": "Apache-2.0", @@ -20,11 +20,12 @@ "pack:linter": "rimraf bundle && mkdir bundle && npm pack && mv panda-tslinter-*.tgz bundle", "pretest": " npm run fix", "test": "npm run test_all && npm run test_ts_import_ets", - "test_all": "npm run testrunner -- -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin", + "test_all": "npm run testrunner -- -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin,test/deprecatedapi", "test_main": "npm run testrunner -- -d test/main", "test_ohmurl": "npm run testrunner -- -d test/ohmurl", "test_interop": "npm run testrunner -- -d test/interop", "test_sdk": "npm run testrunner -- -d test/sdkwhite", + "test_deprecatedapi": "npm run testrunner -- -d test/deprecatedapi", "test_concurrent": "npm run testrunner -- -d test/concurrent", "test_rules": "npm run testrunner -- -d test/rules", "test_regression": "npm run testrunner -- -d test/regression", @@ -36,7 +37,7 @@ "test_ts_import_ets": "npm run testrunner -- -d test/ts_import_ets/ts --sdk --interop-mode", "test_migration": "npm run testrunner -- -d test/migration", "testrunner": "npm run compile && node build/testRunner/TestRunner.js", - "update-tests": "node scripts/update-test-results.mjs test/main test/rules test/regression test/extended_features test/ts_import_ets/ts test/migration test/ohmurl test/interop test/sdkwhite test/concurrent test/builtin", + "update-tests": "node scripts/update-test-results.mjs test/main test/rules test/regression test/extended_features test/ts_import_ets/ts test/migration test/ohmurl test/interop test/sdkwhite test/concurrent test/builtin test/deprecatedapi", "eslint-check": "npx eslint .", "eslint-fix": "npm run eslint-check -- --fix", "prettier-fix": "npx prettier --write .", @@ -44,7 +45,7 @@ "coverage": "npm run coverage-prepare && npm run coverage-instrument && npm run coverage-test && npm run coverage-collect && npm run coverage-report", "coverage-prepare": "npm run build && node scripts/testRunner/coverage_prepare.js", "coverage-instrument": "nyc --compact false instrument build coverage/build_instrument", - "coverage-test": "node coverage/build_instrument/testRunner/TestRunner.js -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin", + "coverage-test": "node coverage/build_instrument/testRunner/TestRunner.js -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin,test/deprecatedapi", "coverage-collect": "node scripts/testRunner/coverage_collect.js", "coverage-report": "node scripts/testRunner/coverage_report.js" }, diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 52426d571d9f7901042e4bf516026a5951cae8c9..cb6e60231607695fbcf308bb8f8c57ef2febaf09 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -11,9 +11,12 @@ "arkts-no-globalthis", "arkts-no-func-props", "arkts-no-func-bind", + "arkts-no-function-return-this", "arkts-limited-stdlib", + "arkts-no-class-add-super-prop-with-readonly", "arkts-no-classes-as-obj", "arkts-obj-literal-props", + "arkts-obj-literal-key-type", "arkts-optional-methods", "arkts-numeric-semantic", "arkts-incompatible-function-types", @@ -41,6 +44,7 @@ "arkts-no-tuples-arrays", "arkts-class-static-initialization", "arkts-invalid-identifier", + "arkts-no-import-json-file", "arkts-no-extends-expression", "arkts-no-ts-like-function-call", "arkts-method-inherit-rule", @@ -59,6 +63,7 @@ "arkts-only-support-decimal-bigint-literal", "arkts-unsupport-operator", "arkts-no-duplicate-function-name", + "arkts-require-func-arg-type", "arkts-subclass-must-call-super-constructor-with-args" ], "interop": [ @@ -92,7 +97,8 @@ "arkts-interop-js2s-call-js-method", "arkts-interop-js2s-instanceof-js-type", "arkts-interop-js2s-self-addtion-reduction", - "arkts-promise-with-void-type-need-undefined-as-resolve-arg" + "arkts-promise-with-void-type-need-undefined-as-resolve-arg", + "arkts-class-same-type-prop-with-super" ], "ArkUI": [ "arkui-no-!!-bidirectional-data-binding", @@ -115,7 +121,13 @@ "arkui-prop-need-call-method-for-deep-copy", "arkui-no-localbuilder-decorator", "arkui-statestyles-block-need-arrow-func", - "arkui-repeat-disable-default-virtualscroll" + "arkui-repeat-disable-default-virtualscroll", + "arkui-wrappedbuilder-require-arrow-func-generic", + "arkui-wrapbuilder-require-arrow-func-generic", + "arkui-no-deprecated-api", + "arkui-buildernode-generic-no-tuple", + "arkui-buildernode-update-no-literal", + "arkui-buildernode-no-nestingbuildersupported" ], "builtin": [ "arkts-builtin-thisArgs", @@ -135,7 +147,9 @@ "sdk-constructor-funcs", "sdk-no-literal-as-property-name", "sdk-no-decl-with-duplicate-name", - "sdk-type-query" + "sdk-type-query", + "sdk-ability-asynchronous-lifecycle", + "sdk-ability-lifecycle-monitor" ], "concurrent": [ "arkts-no-need-stdlib-ason", @@ -149,4 +163,4 @@ "arkts-limited-stdlib-no-concurrent-decorator", "arkts-no-need-stdlib-worker" ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/scripts/install-ohos-typescript-and-homecheck.mjs b/ets2panda/linter/scripts/install-ohos-typescript-and-homecheck.mjs index 5fc2c55baa1b709e4f9ad0ecaa6c50ee2c265aea..d4271589fe49d4c84f4a1a3d416fad99a9d68f93 100644 --- a/ets2panda/linter/scripts/install-ohos-typescript-and-homecheck.mjs +++ b/ets2panda/linter/scripts/install-ohos-typescript-and-homecheck.mjs @@ -90,7 +90,7 @@ function getTypescript(detectedOS) { fs.mkdirSync(third_party); } - let branch = process.env.TYPESCRIPT_BRANCH ?? 'OpenHarmony_feature_20250328' + let branch = process.env.TYPESCRIPT_BRANCH ?? 'master' if (detectedOS === 'Linux' || detectedOS === 'macOS') { let timeToWait = 5000 diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index 88efd14adff73ec3ff74a2b8c02210b524b9ded4..5da3f8192939beb3e21d5102cae3f331c915c06b 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -206,57 +206,56 @@ function formCommandLineOptions(parsedCmd: ParsedCommand): CommandLineOptions { } function processRuleConfig(commandLineOptions: CommandLineOptions, options: OptionValues): void { - const configureRulePath = getConfigureRulePath(options); - const configuredRulesMap = getRulesFromConfig(configureRulePath); - const arkTSRulesMap = extractRuleTags(cookBookTag); - commandLineOptions.linterOptions.ruleConfigTags = getConfiguredRuleTags(arkTSRulesMap, configuredRulesMap); + const configureRulePath = getConfigureRulePath(options); + const configuredRulesMap = getRulesFromConfig(configureRulePath); + const arkTSRulesMap = extractRuleTags(cookBookTag); + commandLineOptions.linterOptions.ruleConfigTags = getConfiguredRuleTags(arkTSRulesMap, configuredRulesMap); } -function getConfigureRulePath(options: OptionValues) : string { - if (!options.ruleConfig) { - return getDefaultConfigurePath(); - } else { - const stats = fs.statSync(path.normalize(options.ruleConfig)); - if (!stats.isFile()) { - Logger.error(`The file at ${options.ruleConfigPath} path does not exist! +function getConfigureRulePath(options: OptionValues): string { + if (!options.ruleConfig) { + return getDefaultConfigurePath(); + } + const stats = fs.statSync(path.normalize(options.ruleConfig)); + if (!stats.isFile()) { + Logger.error(`The file at ${options.ruleConfigPath} path does not exist! And will use the default configure rule`); - return getDefaultConfigurePath(); - } else { - return options.ruleConfig; - } - } + return getDefaultConfigurePath(); + } + return options.ruleConfig; } -function getDefaultConfigurePath() : string { +function getDefaultConfigurePath(): string { const defaultConfigPath = path.join(process.cwd(), 'rule-config.json'); try { fs.accessSync(defaultConfigPath, fs.constants.F_OK); } catch (error: any) { if (error.code === 'ENOENT') { - Logger.error(`The default rule configuration file does not exist, please add the file named rule-config.json in the migration-helper folder!`); + Logger.error( + 'The default rule configuration file does not exist, please add the file named rule-config.json in the migration-helper folder!' + ); process.exit(1); } } return defaultConfigPath; } - function processAutofixRuleConfig(commandLineOptions: CommandLineOptions, options: OptionValues): void { - if (options.ruleConfig) { - return; - } - const autofixConfigureRulePath = options.autofixRuleConfig; - if (!autofixConfigureRulePath || autofixConfigureRulePath.length === 0) { - return; - } - const stats = fs.statSync(path.normalize(options.autofixRuleConfig)); - if (!stats.isFile()) { - Logger.error(`The file at ${options.autofixRuleConfig} path does not exist!`); - return; - } - const configuredRulesMap = getRulesFromConfig(autofixConfigureRulePath); - const arkTSRulesMap = extractRuleTags(cookBookTag); - commandLineOptions.linterOptions.autofixRuleConfigTags = getConfiguredRuleTags(arkTSRulesMap, configuredRulesMap); + if (options.ruleConfig) { + return; + } + const autofixConfigureRulePath = options.autofixRuleConfig; + if (!autofixConfigureRulePath || autofixConfigureRulePath.length === 0) { + return; + } + const stats = fs.statSync(path.normalize(options.autofixRuleConfig)); + if (!stats.isFile()) { + Logger.error(`The file at ${options.autofixRuleConfig} path does not exist!`); + return; + } + const configuredRulesMap = getRulesFromConfig(autofixConfigureRulePath); + const arkTSRulesMap = extractRuleTags(cookBookTag); + commandLineOptions.linterOptions.autofixRuleConfigTags = getConfiguredRuleTags(arkTSRulesMap, configuredRulesMap); } function createCommand(): Command { @@ -342,11 +341,11 @@ function processResponseFiles(parsedCmd: ParsedCommand): void { const rspFiles = parsedCmd.args.responseFiles; for (const rspFile of rspFiles) { try { - const rspArgs = fs - .readFileSync(rspFile) - .toString() - .split('\n') - .filter((e) => { + const rspArgs = fs. + readFileSync(rspFile). + toString(). + split('\n'). + filter((e) => { return e.trimEnd(); }); const cmdArgs = ['dummy', 'dummy']; diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index d94ca192177f4f481714eef8d4acf822e3510c6d..3d57443dac78dc01f25c86b8ad02f1ef30322461 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -17,14 +17,14 @@ export const cookBookMsg: string[] = []; export const cookBookTag: string[] = []; /** - * @note If the value contains multiple parentheses groups, + * @note If the value contains multiple parentheses groups, * the rule name must be placed in the last group. - * - * @example + * + * @example * // Correct (rule name in last parentheses): * 'cookBookTag[352] = "1.2 Void conflict...(sdk-ability-asynchronous-lifecycle)"' - * -*/ + * + */ cookBookTag[1] = 'Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)'; @@ -102,8 +102,8 @@ cookBookTag[71] = 'The comma operator "," is supported only in "for" loops (arkt cookBookTag[72] = ''; cookBookTag[73] = ''; cookBookTag[74] = 'Destructuring variable declarations are not supported (arkts-no-destruct-decls)'; -cookBookTag[75] = ''; -cookBookTag[76] = ''; +cookBookTag[75] = 'Use string-literal keys with Record (arkts-obj-literal-key-type)'; +cookBookTag[76] = 'Type of parameter must be defined explicitly (arkts-require-func-arg-type)'; cookBookTag[77] = ''; cookBookTag[78] = ''; cookBookTag[79] = 'Type annotation in catch clause is not supported (arkts-no-types-in-catch)'; @@ -171,14 +171,15 @@ cookBookTag[137] = '"globalThis" is not supported (arkts-no-globalthis)'; cookBookTag[138] = 'Some of utility types are not supported (arkts-no-utility-types)'; cookBookTag[139] = 'Declaring properties on functions is not supported (arkts-no-func-props)'; cookBookTag[140] = '\'Function.bind\' is not supported (arkts-no-func-bind)'; -cookBookTag[141] = ''; +cookBookTag[141] = 'Function("return this") is not supported (arkts-no-function-return-this)'; cookBookTag[142] = '"as const" assertions are not supported (arkts-no-as-const)'; cookBookTag[143] = 'Import assertions are not supported (arkts-no-import-assertions)'; cookBookTag[144] = 'Usage of standard library is restricted (arkts-limited-stdlib)'; cookBookTag[145] = 'Strict type checking is enforced (arkts-strict-typing)'; cookBookTag[146] = 'Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)'; cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (arkts-no-ts-deps)'; -cookBookTag[148] = ''; +cookBookTag[148] = + 'Overriding with "readonly" field is not allowed when base field is not "readonly" (arkts-no-class-add-super-prop-with-readonly)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; cookBookTag[151] = 'Usage of \'ESValue\' type is restricted (arkts-limited-esobj)'; @@ -250,8 +251,7 @@ cookBookTag[206] = '"debugger" is not supported (arkts-no-debugger)'; cookBookTag[207] = 'Special arguments object inside functions are not supported (arkts-no-arguments-obj)'; cookBookTag[208] = 'Tagged templates are not supported (arkts-no-tagged-templates)'; cookBookTag[209] = 'The index expression must be of a numeric type (arkts-array-index-expr-type)'; -cookBookTag[210] = - 'The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)'; +cookBookTag[210] = 'The switch expression type must be of type number, string or enum (arkts-switch-expr)'; cookBookTag[211] = 'No two case constant expressions have identical values.(arkts-case-expr)'; cookBookTag[212] = 'The index expression must be zero or positive value.(arkts-array-index-negative)'; cookBookTag[213] = 'Class cannot have static codeblocks. (arkts-class-lazy-import)'; @@ -266,6 +266,7 @@ cookBookTag[236] = 'Method can\'t override filed in interface implemented (arkts cookBookTag[237] = 'Array and tuple are different type(arkts-no-tuples-arrays)'; cookBookTag[238] = 'The static property has no initializer (arkts-class-static-initialization)'; cookBookTag[239] = 'This keyword cannot be used as identifiers (arkts-invalid-identifier)'; +cookBookTag[245] = 'JSON files cannot be imported (arkts-no-import-json-file)'; cookBookTag[251] = '"!!" for bidirectional data binding is not supported (arkui-no-!!-bidirectional-data-binding)'; cookBookTag[252] = '"$$" for bidirectional data binding is not supported (arkui-no-$$-bidirectional-data-binding)'; cookBookTag[253] = '"${variable}" for decorator binding is not supported (arkui-link-decorator-passing)'; @@ -282,6 +283,8 @@ cookBookTag[261] = cookBookTag[262] = 'The makeObserved function is not supported (arkui-no-makeobserved-function)'; cookBookTag[263] = 'The "@Provide" annotation does not support dynamic parameters (arkui-provide-annotation-parameters)'; +cookBookTag[264] = + 'The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)'; cookBookTag[265] = 'Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)'; cookBookTag[266] = 'Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)'; cookBookTag[267] = 'Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)'; @@ -373,6 +376,14 @@ cookBookTag[358] = cookBookTag[359] = '"@LocalBuilder" Decorator is not supported (arkui-no-localbuilder-decorator)'; cookBookTag[360] = '"Repeat" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)'; +cookBookTag[361] = + 'When using "WrappedBuilder", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)'; +cookBookTag[362] = + 'When using "wrapBuilder", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)'; +cookBookTag[363] = 'The generic of "BuilderNode" does not accept tuple (arkui-buildernode-generic-no-tuple)'; +cookBookTag[364] = + 'The "update" interface of "BuilderNode" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new "BuilderNode", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)'; +cookBookTag[365] = 'Property "nestingBuilderSupported" is not supported (arkui-buildernode-no-nestingbuildersupported)'; cookBookTag[370] = 'Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)'; cookBookTag[371] = 'Enum elements cannot be types in ArkTS1.2 (arkts-no-enum-prop-as-type)'; cookBookTag[372] = 'Smart type differences (arkts-no-ts-like-smart-type)'; @@ -387,6 +398,7 @@ cookBookTag[381] = 'The code block passed to stateStyles needs to be an arrow function (arkui-statestyles-block-need-arrow-func)'; cookBookTag[382] = 'Promiseconstructor only supports using resolve (undefined) (arkts-promise-with-void-type-need-undefined-as-resolve-arg)'; +cookBookTag[399] = 'ArkUI deprecated api check (arkui-no-deprecated-api)'; for (let i = 0; i <= cookBookTag.length; i++) { cookBookMsg[i] = ''; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index f67ac33cb405aca2cdade5ada614980da4b1c1d9..a862704a0c1a67da760d3d9f051eb45eaa45bf5f 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -64,6 +64,8 @@ faultsAttrs[FaultID.InOperator] = new FaultAttributes(66); faultsAttrs[FaultID.DestructuringAssignment] = new FaultAttributes(69); faultsAttrs[FaultID.CommaOperator] = new FaultAttributes(71); faultsAttrs[FaultID.DestructuringDeclaration] = new FaultAttributes(74); +faultsAttrs[FaultID.ObjectLiteralKeyType] = new FaultAttributes(75); +faultsAttrs[FaultID.ParameterType] = new FaultAttributes(76); faultsAttrs[FaultID.CatchWithUnsupportedType] = new FaultAttributes(79); faultsAttrs[FaultID.ForInStatement] = new FaultAttributes(80); faultsAttrs[FaultID.MappedType] = new FaultAttributes(83); @@ -100,11 +102,13 @@ faultsAttrs[FaultID.UtilityType] = new FaultAttributes(138); faultsAttrs[FaultID.PropertyDeclOnFunction] = new FaultAttributes(139); faultsAttrs[FaultID.FunctionBind] = new FaultAttributes(140, ProblemSeverity.WARNING); faultsAttrs[FaultID.FunctionBindError] = new FaultAttributes(140); +faultsAttrs[FaultID.NoFunctionReturnThis] = new FaultAttributes(141); faultsAttrs[FaultID.ConstAssertion] = new FaultAttributes(142); faultsAttrs[FaultID.ImportAssertion] = new FaultAttributes(143); faultsAttrs[FaultID.LimitedStdLibApi] = new FaultAttributes(144); faultsAttrs[FaultID.StrictDiagnostic] = new FaultAttributes(145); faultsAttrs[FaultID.ErrorSuppression] = new FaultAttributes(146); +faultsAttrs[FaultID.NoClassSuperPropReadonly] = new FaultAttributes(148); faultsAttrs[FaultID.ClassAsObject] = new FaultAttributes(149, ProblemSeverity.WARNING); faultsAttrs[FaultID.ClassAsObjectError] = new FaultAttributes(149); faultsAttrs[FaultID.ImportAfterStatement] = new FaultAttributes(150); @@ -174,6 +178,7 @@ faultsAttrs[FaultID.MethodOverridingField] = new FaultAttributes(236); faultsAttrs[FaultID.NoTuplesArrays] = new FaultAttributes(237); faultsAttrs[FaultID.ClassstaticInitialization] = new FaultAttributes(238); faultsAttrs[FaultID.InvalidIdentifier] = new FaultAttributes(239); +faultsAttrs[FaultID.NoImportJsonFile] = new FaultAttributes(245); faultsAttrs[FaultID.DoubleExclaBindingNotSupported] = new FaultAttributes(251); faultsAttrs[FaultID.DoubleDollarBindingNotSupported] = new FaultAttributes(252); faultsAttrs[FaultID.DollarBindingNotSupported] = new FaultAttributes(253); @@ -187,6 +192,7 @@ faultsAttrs[FaultID.EntryAnnotation] = new FaultAttributes(260); faultsAttrs[FaultID.SdkAbilityLifecycleMonitor] = new FaultAttributes(261); faultsAttrs[FaultID.MakeObservedIsNotSupported] = new FaultAttributes(262); faultsAttrs[FaultID.ProvideAnnotation] = new FaultAttributes(263); +faultsAttrs[FaultID.FieldTypeMismatch] = new FaultAttributes(264); faultsAttrs[FaultID.InteropJsObjectInheritance] = new FaultAttributes(265); faultsAttrs[FaultID.InteropJsObjectTraverseJsInstance] = new FaultAttributes(266); faultsAttrs[FaultID.InteropJsObjectCallStaticFunc] = new FaultAttributes(267, ProblemSeverity.WARNING); @@ -257,6 +263,11 @@ faultsAttrs[FaultID.NoNeedStdlibWorker] = new FaultAttributes(357); faultsAttrs[FaultID.BuiltinGetOwnPropertyNames] = new FaultAttributes(358); faultsAttrs[FaultID.LocalBuilderDecoratorNotSupported] = new FaultAttributes(359); faultsAttrs[FaultID.RepeatDisableVirtualScroll] = new FaultAttributes(360); +faultsAttrs[FaultID.WrappedBuilderGenericNeedArrowFunc] = new FaultAttributes(361); +faultsAttrs[FaultID.WrapBuilderGenericNeedArrowFunc] = new FaultAttributes(362); +faultsAttrs[FaultID.BuilderNodeGenericNoTuple] = new FaultAttributes(363); +faultsAttrs[FaultID.BuilderNodeUpdateNoLiteral] = new FaultAttributes(364); +faultsAttrs[FaultID.BuilderNodeNoNestingBuilderSupported] = new FaultAttributes(365); faultsAttrs[FaultID.NosparseArray] = new FaultAttributes(370); faultsAttrs[FaultID.NoEnumPropAsType] = new FaultAttributes(371); faultsAttrs[FaultID.NoTsLikeSmartType] = new FaultAttributes(372); @@ -268,3 +279,4 @@ faultsAttrs[FaultID.NondecimalBigint] = new FaultAttributes(377); faultsAttrs[FaultID.UnsupportOperator] = new FaultAttributes(378); faultsAttrs[FaultID.StateStylesBlockNeedArrowFunc] = new FaultAttributes(381); faultsAttrs[FaultID.PromiseVoidNeedResolveArg] = new FaultAttributes(382); +faultsAttrs[FaultID.NoDeprecatedApi] = new FaultAttributes(399); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 33cb74aca333d02802159e6e128a1f2ca4e21833..93a31cd080ed89812acd9ae2bcd38e709cb5b654 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -38,8 +38,10 @@ faultDesc[FaultID.UnknownType] = '"unknown" type'; faultDesc[FaultID.ForInStatement] = '"for-In" statements'; faultDesc[FaultID.InOperator] = '"in" operations'; faultDesc[FaultID.FunctionExpression] = 'function expressions'; +faultDesc[FaultID.ParameterType] = 'parameter type'; faultDesc[FaultID.IntersectionType] = 'intersection types and type literals'; faultDesc[FaultID.ObjectTypeLiteral] = 'Object type literals'; +faultDesc[FaultID.ObjectLiteralKeyType] = 'Object literal key types'; faultDesc[FaultID.CommaOperator] = 'comma operator'; faultDesc[FaultID.LimitedReturnTypeInference] = 'Functions with limited return type inference'; faultDesc[FaultID.ClassExpression] = 'Class expressions'; @@ -59,6 +61,7 @@ faultDesc[FaultID.PrivateIdentifier] = 'Private identifiers (with "#" prefix)'; faultDesc[FaultID.LocalFunction] = 'Local function declarations'; faultDesc[FaultID.ConditionalType] = 'Conditional type'; faultDesc[FaultID.MappedType] = 'Mapped type'; +faultDesc[FaultID.NoClassSuperPropReadonly] = 'Readonly property overrides non-readonly parent property'; faultDesc[FaultID.NamespaceAsObject] = 'Namespaces used as objects'; faultDesc[FaultID.ClassAsObject] = faultDesc[FaultID.ClassAsObjectError] = 'Class used as object'; faultDesc[FaultID.NonDeclarationInNamespace] = 'Non-declaration statements in namespaces'; @@ -92,6 +95,7 @@ faultDesc[FaultID.UtilityType] = 'Standard Utility types'; faultDesc[FaultID.PropertyDeclOnFunction] = 'Property declaration on function'; faultDesc[FaultID.FunctionApplyCall] = 'Invoking methods of function objects'; faultDesc[FaultID.FunctionBind] = faultDesc[FaultID.FunctionBindError] = 'Invoking methods of function objects'; +faultDesc[FaultID.NoFunctionReturnThis] = 'no function return this'; faultDesc[FaultID.ConstAssertion] = '"as const" assertion'; faultDesc[FaultID.ImportAssertion] = 'Import assertion'; faultDesc[FaultID.SpreadOperator] = 'Spread operation'; @@ -169,6 +173,7 @@ faultDesc[FaultID.ClassstaticInitialization] = 'The static properties of a class faultDesc[FaultID.AvoidUnionTypes] = 'Union types'; faultDesc[FaultID.TaggedTemplates] = 'Tagged template'; faultDesc[FaultID.InvalidIdentifier] = 'Invalid identifiers'; +faultDesc[FaultID.NoImportJsonFile] = 'No import JSON file'; faultDesc[FaultID.ExtendsExpression] = 'Extends Expression'; faultDesc[FaultID.NumericSemantics] = 'Numeric semantics'; faultDesc[FaultID.AnimatableExtendDecoratorTransform] = '"@AnimatableExtend" decorator'; @@ -191,6 +196,7 @@ faultDesc[FaultID.EntryAnnotation] = '"@Entry" decorator parameter'; faultDesc[FaultID.SdkAbilityLifecycleMonitor] = 'UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback'; faultDesc[FaultID.ProvideAnnotation] = '"@Provide" decorator parameter'; +faultDesc[FaultID.FieldTypeMismatch] = 'Mismatch field types'; faultDesc[FaultID.InteropJsObjectInheritance] = 'Interop JS class inheritance'; faultDesc[FaultID.InteropJsObjectTraverseJsInstance] = 'Interop JS object traverse usage'; faultDesc[FaultID.InteropJsObjectCallStaticFunc] = 'Interop JS function usage'; @@ -257,3 +263,9 @@ faultDesc[FaultID.PropNeedCallMethodForDeepCopy] = 'Deep copy needs to call the faultDesc[FaultID.StateStylesBlockNeedArrowFunc] = 'StateStyles needs arrow function block'; faultDesc[FaultID.PromiseVoidNeedResolveArg] = 'Promiseconstructor only supports using resolve (undefined)'; faultDesc[FaultID.RepeatDisableVirtualScroll] = '"Repeat" disable default "virtualScroll"'; +faultDesc[FaultID.WrappedBuilderGenericNeedArrowFunc] = 'Generic of "WrappedBuilder" does not support parameter list'; +faultDesc[FaultID.WrapBuilderGenericNeedArrowFunc] = 'Generic of "wrappBuilder" does not support parameter list'; +faultDesc[FaultID.NoDeprecatedApi] = 'ArkUI deprecated api check'; +faultDesc[FaultID.BuilderNodeGenericNoTuple] = 'Generic of "BuilderNode" does not support tuple"'; +faultDesc[FaultID.BuilderNodeUpdateNoLiteral] = '"update" interface of "BuilderNode" cannot pass an object literal'; +faultDesc[FaultID.BuilderNodeNoNestingBuilderSupported] = '"nestingBuilderSupported" is not supported'; diff --git a/ets2panda/linter/src/lib/LinterInputInfo.ts b/ets2panda/linter/src/lib/LinterInputInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..1cfe8f05ff1c4fe5f7a25a8ba3ccd2ee2e963627 --- /dev/null +++ b/ets2panda/linter/src/lib/LinterInputInfo.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 type * as ts from 'typescript'; +import type { LinterOptions } from './LinterOptions'; +import type { MigrationInfo } from './progress/MigrationInfo'; +import type { CmdProgressInfo } from './progress/CmdProgressInfo'; + +export interface LinterInputInfo { + tsProgram: ts.Program; + srcFiles: ts.SourceFile[]; + options: LinterOptions; + tscStrictDiagnostics: Map; + migrationInfo?: MigrationInfo; + cmdProgressInfo: CmdProgressInfo; +} diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 113f67fd1b84bf1bbd8fde2f7733734dc7c5fdd6..3696ab689847981cb15187c1ebe1df7d86d73555 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -53,6 +53,7 @@ import { LibraryTypeCallDiagnosticChecker } from './utils/functions/LibraryTypeC import { mergeArrayMaps } from './utils/functions/MergeArrayMaps'; import { clearPathHelperCache, pathContainsDirectory } from './utils/functions/PathHelper'; import { processSyncErr } from './utils/functions/ProcessWrite'; +import type { LinterInputInfo } from './LinterInputInfo'; function prepareInputFilesList(cmdOptions: CommandLineOptions): string[] { let inputFiles = cmdOptions.inputFiles.map((x) => { @@ -141,12 +142,8 @@ function lintFiles( tscStrictDiagnostics: Map, migrationInfo?: MigrationInfo ): LintRunResult { - const projectStats: ProjectStatistics = new ProjectStatistics(); - const problemsInfos: Map = new Map(); - TypeScriptLinter.initGlobals(); InteropTypescriptLinter.initGlobals(); - let fileCount: number = 0; const cmdProgressBar = new FixedLineProgressBar(); const cmdProgressInfo: CmdProgressInfo = { cmdProgressBar: cmdProgressBar, @@ -155,8 +152,31 @@ function lintFiles( options: options }; - process.stderr.write('\n'); - preProcessCmdProgressBar(cmdProgressInfo); + if (options.ideInteractive) { + process.stderr.write('\n'); + preProcessCmdProgressBar(cmdProgressInfo); + } + const linterInputInfo: LinterInputInfo = { + tsProgram: tsProgram, + srcFiles: srcFiles, + options: options, + tscStrictDiagnostics: tscStrictDiagnostics, + migrationInfo: migrationInfo, + cmdProgressInfo: cmdProgressInfo + }; + + const lintResult = executeLinter(linterInputInfo); + if (options.ideInteractive) { + postProcessCmdProgressBar(cmdProgressInfo); + } + return lintResult; +} + +function executeLinter(linterInputInfo: LinterInputInfo): LintRunResult { + const { tsProgram, srcFiles, options, tscStrictDiagnostics, migrationInfo, cmdProgressInfo } = linterInputInfo; + const projectStats: ProjectStatistics = new ProjectStatistics(); + const problemsInfos: Map = new Map(); + let fileCount: number = 0; for (const srcFile of srcFiles) { const linter: BaseTypeScriptLinter = !options.interopCheckMode ? new TypeScriptLinter(tsProgram.getTypeChecker(), options, srcFile, tscStrictDiagnostics) : @@ -167,21 +187,18 @@ function lintFiles( problemsInfos.set(path.normalize(srcFile.fileName), [...problems]); projectStats.fileStats.push(linter.fileStats); fileCount += 1; - processCmdProgressBar(cmdProgressInfo, fileCount); if (options.ideInteractive) { + processCmdProgressBar(cmdProgressInfo, fileCount); processIdeProgressBar( { migrationInfo: migrationInfo, currentSrcFile: srcFile, srcFiles: srcFiles, options: options }, fileCount ); } } - - postProcessCmdProgressBar(cmdProgressInfo); - return { hasErrors: projectStats.hasError(), - problemsInfos, - projectStats + problemsInfos: problemsInfos, + projectStats: projectStats }; } diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index 9225ec1dce5d60894eac5a3e69d95b4742c289f0..649892bfc7c64b686f49ff1aae5d4c283b0ff335 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -37,6 +37,7 @@ export enum FaultID { FunctionExpression, IntersectionType, ObjectTypeLiteral, + ObjectLiteralKeyType, CommaOperator, LimitedReturnTypeInference, ClassExpression, @@ -57,6 +58,7 @@ export enum FaultID { ConditionalType, MappedType, NamespaceAsObject, + NoClassSuperPropReadonly, ClassAsObject, ClassAsObjectError, NonDeclarationInNamespace, @@ -78,6 +80,7 @@ export enum FaultID { ImportAssignment, GenericCallNoTypeArgs, ParameterProperties, + ParameterType, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, @@ -93,6 +96,7 @@ export enum FaultID { FunctionApplyCall, FunctionBind, FunctionBindError, + NoFunctionReturnThis, ConstAssertion, ImportAssertion, SpreadOperator, @@ -169,6 +173,7 @@ export enum FaultID { TaggedTemplates, IncompationbleFunctionType, InvalidIdentifier, + NoImportJsonFile, ExtendsExpression, NumericSemantics, AnimatableExtendDecoratorTransform, @@ -186,6 +191,7 @@ export enum FaultID { EntryAnnotation, SdkAbilityLifecycleMonitor, ProvideAnnotation, + FieldTypeMismatch, UseSharedDeprecated, UseConcurrentDeprecated, MethodInheritRule, @@ -257,6 +263,12 @@ export enum FaultID { StateStylesBlockNeedArrowFunc, PromiseVoidNeedResolveArg, RepeatDisableVirtualScroll, + WrappedBuilderGenericNeedArrowFunc, + WrapBuilderGenericNeedArrowFunc, + NoDeprecatedApi, + BuilderNodeGenericNoTuple, + BuilderNodeUpdateNoLiteral, + BuilderNodeNoNestingBuilderSupported, // this should always be last enum LAST_ID } diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index dcb878796da2ccf96777761fc6bffc612e965492..e58892c5304b12d882aa65c1a7e5728daf368fb5 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -21,8 +21,11 @@ import type { Autofix } from './autofixes/Autofixer'; import { Autofixer } from './autofixes/Autofixer'; import { PROMISE_METHODS, SYMBOL, SYMBOL_CONSTRUCTOR, TsUtils } from './utils/TsUtils'; import { FUNCTION_HAS_NO_RETURN_ERROR_CODE } from './utils/consts/FunctionHasNoReturnErrorCode'; -import { LIMITED_STANDARD_UTILITY_TYPES } from './utils/consts/LimitedStandardUtilityTypes'; -import { LIKE_FUNCTION, LIKE_FUNCTION_CONSTRUCTOR } from './utils/consts/LikeFunction'; +import { + LIMITED_STANDARD_UTILITY_TYPES, + LIMITED_STANDARD_UTILITY_TYPES2 +} from './utils/consts/LimitedStandardUtilityTypes'; +import { LIKE_FUNCTION, LIKE_FUNCTION_CONSTRUCTOR, FORBIDDEN_FUNCTION_BODY } from './utils/consts/LikeFunction'; import { METHOD_DECLARATION } from './utils/consts/MethodDeclaration'; import { METHOD_SIGNATURE } from './utils/consts/MethodSignature'; import { OPTIONAL_METHOD } from './utils/consts/OptionalMethod'; @@ -55,7 +58,7 @@ import { } from './utils/consts/SendableAPI'; import { DEFAULT_COMPATIBLE_SDK_VERSION, DEFAULT_COMPATIBLE_SDK_VERSION_STAGE } from './utils/consts/VersionInfo'; import { TYPED_ARRAYS } from './utils/consts/TypedArrays'; -import { BUILTIN_CONSTRUCTORS } from './utils/consts/BuiltinWhiteList'; +import { BUILTIN_CONSTRUCTORS, COLLECTION_METHODS, COLLECTION_TYPES } from './utils/consts/BuiltinWhiteList'; import { forEachNodeInSubtree } from './utils/functions/ForEachNodeInSubtree'; import { hasPredecessor } from './utils/functions/HasPredecessor'; import { isStdLibrarySymbol, isStdLibraryType } from './utils/functions/IsStdLibrary'; @@ -84,7 +87,12 @@ import { BUILTIN_GENERIC_CONSTRUCTORS } from './utils/consts/BuiltinGenericConst import { DEFAULT_DECORATOR_WHITE_LIST } from './utils/consts/DefaultDecoratorWhitelist'; import { INVALID_IDENTIFIER_KEYWORDS } from './utils/consts/InValidIndentifierKeywords'; import { WORKER_MODULES, WORKER_TEXT } from './utils/consts/WorkerAPI'; -import { COLLECTIONS_TEXT, COLLECTIONS_MODULES } from './utils/consts/CollectionsAPI'; +import { + COLLECTIONS_TEXT, + COLLECTIONS_MODULES, + BIT_VECTOR, + ARKTS_COLLECTIONS_MODULE +} from './utils/consts/CollectionsAPI'; import { ASON_TEXT, ASON_MODULES, ARKTS_UTILS_TEXT, JSON_TEXT, ASON_WHITE_SET } from './utils/consts/ArkTSUtilsAPI'; import { interanlFunction } from './utils/consts/InternalFunction'; import { ETS_PART, PATH_SEPARATOR } from './utils/consts/OhmUrl'; @@ -98,14 +106,17 @@ import { ENTRY_DECORATOR_NAME, PROVIDE_DECORATOR_NAME, PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME, - ARKUI_PACKAGE_NAME, + ARKUI_MODULE, MAKE_OBSERVED, - ARKUI_STATE_MANAGEMENT, + STATE_MANAGEMENT_MODULE, PropDecoratorName, PropFunctionName, StorageTypeName, customLayoutFunctionName, - VIRTUAL_SCROLL_IDENTIFIER + VIRTUAL_SCROLL_IDENTIFIER, + BUILDERNODE_D_TS, + BuilderNodeFunctionName, + NESTING_BUILDER_SUPPORTED } from './utils/consts/ArkuiConstants'; import { arkuiImportList } from './utils/consts/ArkuiImportList'; import type { IdentifierAndArguments, ForbidenAPICheckResult } from './utils/consts/InteropAPI'; @@ -116,12 +127,14 @@ import { REFLECT_LITERAL, REFLECT_PROPERTIES } from './utils/consts/InteropAPI'; -import { EXTNAME_TS, EXTNAME_D_TS, EXTNAME_JS } from './utils/consts/ExtensionName'; +import { EXTNAME_TS, EXTNAME_D_TS, EXTNAME_JS, EXTNAME_JSON } from './utils/consts/ExtensionName'; import { ARKTS_IGNORE_DIRS_OH_MODULES } from './utils/consts/ArktsIgnorePaths'; import type { ApiInfo, ApiListItem } from './utils/consts/SdkWhitelist'; import { ApiList, SdkProblem, SdkNameInfo } from './utils/consts/SdkWhitelist'; import * as apiWhiteList from './data/SdkWhitelist.json'; import * as builtinWhiteList from './data/BuiltinList.json'; +import * as deprecatedApiList from './data/DeprecatedApiList.json'; +import { DEPRECATE_CHECK_KEY, DEPRECATE_UNNAMED } from './utils/consts/DeprecateWhiteList'; import { BuiltinProblem, SYMBOL_ITERATOR, @@ -154,13 +167,14 @@ import { ON_DISCONNECT, PROMISE, SERVICE_EXTENSION_ABILITY, - VOID + VOID, + ABILITY_LIFECYCLE_SDK } from './utils/consts/AsyncLifecycleSDK'; import { ERROR_PROP_LIST } from './utils/consts/ErrorProp'; import { D_ETS, D_TS } from './utils/consts/TsSuffix'; import { arkTsBuiltInTypeName } from './utils/consts/ArkuiImportList'; import { ERROR_TASKPOOL_PROP_LIST } from './utils/consts/ErrorProp'; -import { COMMON_UNION_MEMBER_ACCESS_WHITELIST} from './utils/consts/ArktsWhiteApiPaths'; +import { COMMON_UNION_MEMBER_ACCESS_WHITELIST } from './utils/consts/ArktsWhiteApiPaths'; import type { BaseClassConstructorInfo, ConstructorParameter, ExtendedIdentifierInfo } from './utils/consts/Types'; import { ExtendedIdentifierType } from './utils/consts/Types'; import { STRING_ERROR_LITERAL } from './utils/consts/Literals'; @@ -183,6 +197,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { static pathMap: Map>; static indexedTypeSet: Set; static globalApiInfo: Map>; + static deprecatedApiInfo: Set; static symbotIterSet: Set; static missingAttributeSet: Set; static literalAsPropertyNameTypeSet: Set; @@ -195,12 +210,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { TypeScriptLinter.nameSpaceFunctionCache = new Map>(); TypeScriptLinter.pathMap = new Map>(); TypeScriptLinter.globalApiInfo = new Map>(); + TypeScriptLinter.deprecatedApiInfo = new Set(); TypeScriptLinter.funcMap = new Map>>(); TypeScriptLinter.symbotIterSet = new Set(); TypeScriptLinter.missingAttributeSet = new Set(); TypeScriptLinter.initSdkWhitelist(); TypeScriptLinter.initSdkBuiltinInfo(); TypeScriptLinter.initBuiltinlist(); + TypeScriptLinter.initDeprecatedApiList(); } initSdkInfo(): void { @@ -320,6 +337,15 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private static initDeprecatedApiList(): void { + const list: ApiList = new ApiList(deprecatedApiList); + if (list?.api_list?.length > 0) { + for (const item of list.api_list) { + this.deprecatedApiInfo.add(item); + } + } + } + private static addOrUpdateData(map: Map>, path: string, data: ApiInfo): void { let apiInfos = map.get(path); if (!apiInfos) { @@ -605,6 +631,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const objectLiteralType = this.tsTypeChecker.getContextualType(objectLiteralExpr); + if (objectLiteralType && this.options.arkts2) { + this.isObjectLiteralKeyTypeValid(objectLiteralExpr, objectLiteralType); + } + if (objectLiteralType && this.tsUtils.typeContainsSendableClassOrInterface(objectLiteralType)) { this.incrementCounters(node, FaultID.SendableObjectInitialization); } else if ( @@ -629,7 +659,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return ( ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop) && - (ts.isCallExpression(objLitExpr.parent) || ts.isNewExpression(objLitExpr.parent)) + (ts.isCallExpression(objLitExpr.parent) || ts.isNewExpression(objLitExpr.parent)) ); } @@ -651,13 +681,45 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } for (const prop of invalidProps) { - const autofix = ts.isShorthandPropertyAssignment(prop) ? - this.autofixer?.fixShorthandPropertyAssignment(prop) : - objLiteralAutofix; - this.incrementCounters(prop, FaultID.ObjectLiteralProperty, autofix); + if (objectLiteralType) { + const typeDecl = TsUtils.getDeclaration(objectLiteralType.getSymbol()); + if (typeDecl && ts.isInterfaceDeclaration(typeDecl) && ts.isMethodDeclaration(prop)) { + continue; + } + } + if (ts.isShorthandPropertyAssignment(prop)) { + if (this.checkShorthandInObjectLiteral(prop, objectLiteralType)) { + const autofix = this.autofixer?.fixShorthandPropertyAssignment(prop); + this.incrementCounters(prop, FaultID.ObjectLiteralProperty, autofix); + } + } else { + this.incrementCounters(prop, FaultID.ObjectLiteralProperty, objLiteralAutofix); + } } } + private checkShorthandInObjectLiteral(prop: ts.ShorthandPropertyAssignment, type: ts.Type | undefined): boolean { + if (!type) { + return true; + } + const propName = prop.name.text; + const expectedProp = type.getProperty(propName); + if (!expectedProp) { + return false; + } + const expectedPropType = this.tsTypeChecker.getTypeOfSymbolAtLocation(expectedProp, prop.name); + const symbol = this.tsTypeChecker.getSymbolAtLocation(prop.name); + const varDecl = symbol?.valueDeclaration; + if (!varDecl) { + return false; + } + const actualType = this.tsTypeChecker.getTypeAtLocation(varDecl); + if (!this.isTypeAssignable(actualType, expectedPropType)) { + return true; + } + return false; + } + private handleArrayLiteralExpression(node: ts.Node): void { /* @@ -692,12 +754,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { * check that array literal consists of inferrable types * e.g. there is no element which is untyped object literals */ - const isPromiseCallExpression = TypeScriptLinter.checkPromiseCallExpression(parent); + const isCallExpression = this.checkMethodCallForSparseArray(parent); const isTypedArrayOrBuiltInConstructor = TypeScriptLinter.checkTypedArrayOrBuiltInConstructor(parent); if (this.options.arkts2 && arrayElementIsEmpty) { if (!arrayLitType) { this.incrementCounters(node, FaultID.NosparseArray); - } else if (isPromiseCallExpression || isTypedArrayOrBuiltInConstructor) { + } else if (isCallExpression || isTypedArrayOrBuiltInConstructor) { this.incrementCounters(arrayLitNode, FaultID.NosparseArray); } } @@ -727,25 +789,49 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private static checkTypedArrayOrBuiltInConstructor(parent: ts.Node): boolean { - if (ts.isNewExpression(parent)) { - const newExpr = parent as ts.NewExpression; - const typeName = newExpr.expression.getText(); + if (!ts.isNewExpression(parent)) { + return false; + } + const newExpr = parent; + const typeName = newExpr.expression.getText(); + + return TYPED_ARRAYS.includes(typeName) || BUILTIN_CONSTRUCTORS.includes(typeName); + } - return TYPED_ARRAYS.includes(typeName) || BUILTIN_CONSTRUCTORS.includes(typeName); + private checkMethodCallForSparseArray(parent: ts.Node): boolean { + if (!ts.isCallExpression(parent)) { + return false; + } + + const callExpr = parent; + const promiseMethodName = TypeScriptLinter.getPromiseMethodName(callExpr.expression); + if (promiseMethodName && PROMISE_METHODS.has(promiseMethodName)) { + return true; } + + const collectionMethodName = this.getCollectionMethodName(callExpr.expression); + if (collectionMethodName && COLLECTION_METHODS.has(collectionMethodName)) { + return true; + } + return false; } - private static checkPromiseCallExpression(parent: ts.Node): boolean { - if (ts.isCallExpression(parent)) { - const callExpr = parent; - const methodName = TypeScriptLinter.getPromiseMethodName(callExpr.expression); - if (methodName && PROMISE_METHODS.has(methodName)) { - return true; + private getCollectionMethodName(node: ts.Expression): string | undefined { + if (!ts.isPropertyAccessExpression(node)) { + return undefined; + } + + const expr = node.expression; + if (ts.isIdentifier(expr) || ts.isPropertyAccessExpression(expr)) { + const type = this.tsTypeChecker.getTypeAtLocation(expr); + const typeName = type.symbol?.getName(); + if (typeName && COLLECTION_TYPES.has(typeName)) { + return node.name.text; } - return false; } - return false; + + return undefined; } private static getPromiseMethodName(node: ts.Expression): string | undefined { @@ -1115,7 +1201,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (this.options.arkts2) { const importClause = importDeclNode.importClause; if (!importClause || !importClause.name && !importClause.namedBindings) { - this.incrementCounters(node, FaultID.NoSideEffectImport); + const autofix = this.autofixer?.fixSideEffectImport(importDeclNode); + this.incrementCounters(node, FaultID.NoSideEffectImport, autofix); } else { this.updateDataSdkJsonInfo(importDeclNode, importClause); } @@ -1147,6 +1234,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkStdLibConcurrencyImport(importDeclNode); this.handleInterOpImportJs(importDeclNode); this.checkForDeprecatedModules(node); + this.checkImportJsonFile(importDeclNode); } private checkForDeprecatedModules(node: ts.Node): void { @@ -1245,30 +1333,25 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private handlePropertyAccessExpression(node: ts.Node): void { - this.handleMakeObserved(node as ts.PropertyAccessExpression); - this.handleStateStyles(node as ts.PropertyAccessExpression); - this.handleDoubleDollar(node); - this.handleQuotedHyphenPropsDeprecated(node as ts.PropertyAccessExpression); - this.handleSdkTypeQuery(node as ts.PropertyAccessExpression); - this.checkUnionTypes(node as ts.PropertyAccessExpression); - this.handleLimitedVoidTypeFromSdkOnPropertyAccessExpression(node as ts.PropertyAccessExpression); - this.checkDepricatedIsConcurrent(node as ts.PropertyAccessExpression); - this.propertyAccessExpressionForBuiltin(node as ts.PropertyAccessExpression); - this.checkConstrutorAccess(node as ts.PropertyAccessExpression); - this.handleTaskPoolDeprecatedUsages(node as ts.PropertyAccessExpression); - this.handleNoTuplesArraysForPropertyAccessExpression(node as ts.PropertyAccessExpression); - this.handleUnsafeOptionalCallComparison(node as ts.PropertyAccessExpression); - if (ts.isCallExpression(node.parent) && node === node.parent.expression) { + const propertyAccessNode = node as ts.PropertyAccessExpression; + this.handlePropertyAccessExpressionForUI(propertyAccessNode); + this.handleQuotedHyphenPropsDeprecated(propertyAccessNode); + this.handleSdkTypeQuery(propertyAccessNode); + this.checkUnionTypes(propertyAccessNode); + this.handleLimitedVoidTypeFromSdkOnPropertyAccessExpression(propertyAccessNode); + this.checkDepricatedIsConcurrent(propertyAccessNode); + this.propertyAccessExpressionForBuiltin(propertyAccessNode); + this.checkConstrutorAccess(propertyAccessNode); + this.handleTaskPoolDeprecatedUsages(propertyAccessNode); + this.handleNoTuplesArraysForPropertyAccessExpression(propertyAccessNode); + this.handleUnsafeOptionalCallComparison(propertyAccessNode); + this.handleNoDeprecatedApi(node as ts.PropertyAccessExpression); + if (ts.isCallExpression(propertyAccessNode.parent) && propertyAccessNode === propertyAccessNode.parent.expression) { return; } - const propertyAccessNode = node as ts.PropertyAccessExpression; const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode); const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); const baseExprType = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - this.handleTsInterop(propertyAccessNode, () => { - const type = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - this.checkUsageOfTsTypes(type, propertyAccessNode.expression); - }); this.propertyAccessExpressionForInterop(propertyAccessNode); if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); @@ -1289,6 +1372,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.fixJsImportPropertyAccessExpression(node); } + private handlePropertyAccessExpressionForUI(node: ts.PropertyAccessExpression): void { + this.handleMakeObserved(node); + this.handleStateStyles(node); + this.handleDoubleDollar(node); + this.handlePropertyAccessExprForBuilderNode(node); + } + private checkSymbolAPI(node: ts.PropertyAccessExpression, exprSym: ts.Symbol | undefined): void { if ( !this.options.arkts2 && @@ -1435,12 +1525,195 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { TsUtils.isAnyType(baseType) || TsUtils.isUnknownType(baseType) || this.tsUtils.isStdFunctionType(baseType) || - typeString === 'symbol' + typeString === 'symbol' || + this.isMixedEnum(baseType) || + this.isSpecialType(baseType, node) || + this.isStdUtilityTools(node) ) { this.incrementCounters(node, FaultID.InteropDirectAccessToTSTypes); } } + private isSpecialType(baseType: ts.Type, node: ts.Node): boolean { + const baseTypeStr = this.tsTypeChecker.typeToString(baseType); + if (TypeScriptLinter.extractKeyofFromString(baseTypeStr)) { + return true; + } + let symbol = baseType.getSymbol(); + if (!symbol) { + symbol = this.tsUtils.trueSymbolAtLocation(node); + } + const decl = TsUtils.getDeclaration(symbol); + if (!decl) { + return false; + } + if ( + ts.isTypeAliasDeclaration(decl) && this.checkSpecialTypeNode(decl.type, true) || + this.checkSpecialTypeNode(decl, true) + ) { + return true; + } + + if (this.isObjectLiteralExpression(decl)) { + return true; + } + + if (ts.isFunctionLike(decl)) { + if (decl.type && this.checkIsTypeLiteral(decl.type)) { + return true; + } + const isObjectLiteralExpression = decl.parameters.some((param) => { + return param.type && this.checkIsTypeLiteral(param.type); + }); + if (isObjectLiteralExpression) { + return true; + } + if (TypeScriptLinter.hasObjectLiteralReturn(decl as ts.FunctionLikeDeclaration)) { + return true; + } + } + + return false; + } + + private isMixedEnum(type: ts.Type): boolean { + const symbol = type.getSymbol(); + if (!symbol) { + return false; + } + + const declarations = symbol.getDeclarations(); + if (!declarations) { + return false; + } + + for (const decl of declarations) { + if (ts.isEnumDeclaration(decl)) { + const initializerTypes = new Set(); + + for (const member of decl.members) { + if (member.initializer) { + const memberType = this.tsTypeChecker.getTypeAtLocation(member.initializer); + const baseTypeStr = this.tsTypeChecker.typeToString( + this.tsTypeChecker.getBaseTypeOfLiteralType(memberType) + ); + initializerTypes.add(baseTypeStr); + } + } + + if (initializerTypes.size > 1) { + return true; + } + } + } + + return false; + } + + private isStdUtilityTools(node: ts.Node): boolean { + const symbol = this.tsUtils.trueSymbolAtLocation(node); + const decl = TsUtils.getDeclaration(symbol); + if (!decl) { + return false; + } + let isStdUtilityType = false; + const utils = this.tsUtils; + function traverse(node: ts.Node): void { + if (isStdUtilityType) { + return; + } + if (ts.isTypeReferenceNode(node) || ts.isExpressionWithTypeArguments(node)) { + let typeName = ''; + if (ts.isTypeReferenceNode(node)) { + typeName = utils.entityNameToString(node.typeName); + } else { + typeName = node.expression.getText(); + } + isStdUtilityType = !!( + LIMITED_STANDARD_UTILITY_TYPES2.includes(typeName) && + node.typeArguments && + node.typeArguments.length > 0 + ); + } + node.forEachChild(traverse); + } + traverse(decl); + return isStdUtilityType; + } + + private checkIsTypeLiteral(node: ts.Node): boolean { + if (ts.isUnionTypeNode(node) || ts.isIntersectionTypeNode(node)) { + return node.types.some((typeNode) => { + return this.checkIsTypeLiteralWithTypeNodes(typeNode); + }); + } + + return this.checkIsTypeLiteralWithTypeNodes(node); + } + + private checkIsTypeLiteralWithTypeNodes(node: ts.Node): boolean { + if (ts.isTypeLiteralNode(node) && node.members.length > 0) { + return true; + } + + if (ts.isTypeReferenceNode(node) && node.typeName) { + const typeDecl = this.tsUtils.getDeclarationNode(node.typeName); + return ( + typeDecl !== undefined && ts.isTypeAliasDeclaration(typeDecl) && this.checkSpecialTypeNode(typeDecl.type, false) + ); + } + + return false; + } + + private checkSpecialTypeNode(typeNode: ts.Node, isNeedCheckIsTypeLiteral: boolean): boolean { + let specialType = + ts.isIndexedAccessTypeNode(typeNode) || + ts.isConditionalTypeNode(typeNode) || + ts.isFunctionTypeNode(typeNode) || + ts.isMappedTypeNode(typeNode) || + ts.isTemplateLiteralTypeNode(typeNode); + if (isNeedCheckIsTypeLiteral) { + specialType ||= this.checkIsTypeLiteral(typeNode); + } + return specialType; + } + + private isObjectLiteralExpression(decl: ts.Node): boolean { + const isVariableWithInitializer = + ts.isVariableDeclaration(decl) && decl.initializer && ts.isObjectLiteralExpression(decl.initializer); + + const isVariableWithTypeLiteral = ts.isVariableDeclaration(decl) && decl.type && this.checkIsTypeLiteral(decl.type); + const isObjectLiteralExpression = + ts.isObjectLiteralExpression(decl) || + this.checkIsTypeLiteral(decl) || + isVariableWithInitializer || + isVariableWithTypeLiteral; + return !!isObjectLiteralExpression; + } + + private static hasObjectLiteralReturn(funcNode: ts.FunctionLikeDeclaration): boolean { + let found = false; + function visit(node: ts.Node): void { + if (found) { + return; + } + + if (ts.isReturnStatement(node) && node.expression && ts.isObjectLiteralExpression(node.expression)) { + found = true; + return; + } + + ts.forEachChild(node, visit); + } + visit(funcNode); + return found; + } + + private static extractKeyofFromString(typeString: string): boolean { + return (/\bkeyof\b/).test(typeString); + } + checkUnionTypes(propertyAccessNode: ts.PropertyAccessExpression): void { if (!this.options.arkts2) { return; @@ -1534,18 +1807,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); if (node.type && node.initializer) { this.checkAssignmentMatching(node, this.tsTypeChecker.getTypeAtLocation(node.type), node.initializer, true); - this.checkFunctionTypeCompatible(node.type, node.initializer); } this.handleDeclarationInferredType(node); this.handleDefiniteAssignmentAssertion(node); this.handleSendableClassProperty(node); - this.checkAssignmentNumericSemanticslyPro(node); + this.checkNumericSemanticsForProperty(node); this.handleInvalidIdentifier(node); this.handleStructPropertyDecl(node); this.handlePropertyDeclarationForProp(node); this.handleSdkGlobalApi(node); this.handleObjectLiteralAssignmentToClass(node); - this.handleNumericPublicStatic(node); } private handleSendableClassProperty(node: ts.PropertyDeclaration): void { @@ -1572,6 +1843,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handlePropertyAssignmentForProp(node); this.handleQuotedHyphenPropsDeprecated(node); + this.handleNoDeprecatedApi(node); const propName = node.name; if (!propName || !(ts.isNumericLiteral(propName) || this.options.arkts2 && ts.isStringLiteral(propName))) { return; @@ -1813,6 +2085,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleMissingReturnType(arrowFunc); } } + if (!ts.isBlock(arrowFunc.body)) { + const contextRetType = this.tsTypeChecker.getContextualType(arrowFunc.body); + if (contextRetType) { + this.checkAssignmentMatching(arrowFunc.body, contextRetType, arrowFunc.body, true); + } + } this.checkDefaultParamBeforeRequired(arrowFunc); this.handleLimitedVoidFunction(arrowFunc); } @@ -1820,8 +2098,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleFunctionDeclaration(node: ts.Node): void { // early exit via exception if cancellation was requested this.options.cancellationToken?.throwIfCancellationRequested(); - const tsFunctionDeclaration = node as ts.FunctionDeclaration; + if (!tsFunctionDeclaration.type) { this.handleMissingReturnType(tsFunctionDeclaration); } @@ -1831,6 +2109,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (tsFunctionDeclaration.body) { this.reportThisKeywordsInScope(tsFunctionDeclaration.body); } + if (this.options.arkts2) { + this.handleParamType(tsFunctionDeclaration); + } const funcDeclParent = tsFunctionDeclaration.parent; if (!ts.isSourceFile(funcDeclParent) && !ts.isModuleBlock(funcDeclParent)) { const autofix = this.autofixer?.fixNestedFunction(tsFunctionDeclaration); @@ -1840,29 +2121,42 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.GeneratorFunction); } if (TsUtils.hasSendableDecoratorFunctionOverload(tsFunctionDeclaration)) { - if (!this.isSendableDecoratorValid(tsFunctionDeclaration)) { - return; - } - TsUtils.getNonSendableDecorators(tsFunctionDeclaration)?.forEach((decorator) => { - this.incrementCounters(decorator, FaultID.SendableFunctionDecorator); - }); - if (!TsUtils.hasSendableDecorator(tsFunctionDeclaration)) { - const autofix = this.autofixer?.addSendableDecorator(tsFunctionDeclaration); - this.incrementCounters(tsFunctionDeclaration, FaultID.SendableFunctionOverloadDecorator, autofix); - } - this.scanCapturedVarsInSendableScope( - tsFunctionDeclaration, - tsFunctionDeclaration, - FaultID.SendableFunctionImportedVariables - ); + this.processSendableDecoratorFunctionOverload(tsFunctionDeclaration); } this.handleTSOverload(tsFunctionDeclaration); - this.checkAssignmentNumericSemanticsFuntion(tsFunctionDeclaration); + this.checkNumericSemanticsForFunction(tsFunctionDeclaration); this.handleInvalidIdentifier(tsFunctionDeclaration); this.checkDefaultParamBeforeRequired(tsFunctionDeclaration); this.handleLimitedVoidFunction(tsFunctionDeclaration); } + private processSendableDecoratorFunctionOverload(tsFunctionDeclaration: ts.FunctionDeclaration): void { + if (!this.isSendableDecoratorValid(tsFunctionDeclaration)) { + return; + } + TsUtils.getNonSendableDecorators(tsFunctionDeclaration)?.forEach((decorator) => { + this.incrementCounters(decorator, FaultID.SendableFunctionDecorator); + }); + if (!TsUtils.hasSendableDecorator(tsFunctionDeclaration)) { + const autofix = this.autofixer?.addSendableDecorator(tsFunctionDeclaration); + this.incrementCounters(tsFunctionDeclaration, FaultID.SendableFunctionOverloadDecorator, autofix); + } + this.scanCapturedVarsInSendableScope( + tsFunctionDeclaration, + tsFunctionDeclaration, + FaultID.SendableFunctionImportedVariables + ); + } + + private handleParamType(decl: ts.FunctionLikeDeclaration): void { + for (const param of decl.parameters) { + if (param.type) { + continue; + } + this.incrementCounters(param, FaultID.ParameterType); + } + } + private handleMissingReturnType( funcLikeDecl: ts.FunctionLikeDeclaration | ts.MethodSignature ): [boolean, ts.TypeNode | undefined] { @@ -2068,7 +2362,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkUsageOfTsTypes(leftOperandType, tsBinaryExpr); }); this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - this.checkFunctionTypeCompatible(typeNode, tsRhsExpr); this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); this.handleSdkGlobalApi(tsBinaryExpr); break; @@ -2089,36 +2382,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleAssignmentNotsLikeSmartType(tsBinaryExpr); } - private handleNumericPublicStatic(node: ts.PropertyDeclaration): void { - if (!this.options.arkts2) { - return; - } - if (node.type) { - return; - } - const modifiers = ts.getModifiers(node); - const isTargetProperty = !!modifiers?.length; - if (!isTargetProperty) { - return; - } - if (node.initializer) { - if (ts.isBinaryExpression(node.initializer) && this.isNumericExpression(node.initializer)) { - const autofix = this.autofixer?.fixNumericPublicStatic(node); - this.incrementCounters(node, FaultID.NumericSemantics, autofix); - } - } - } - - private isNumericExpression(node: ts.Node): boolean { - if (ts.isNumericLiteral(node)) { - return true; - } - if (!ts.isBinaryExpression(node)) { - return false; - } - return this.isNumericExpression(node.left) && this.isNumericExpression(node.right); - } - private checkInterOpImportJsDataCompare(expr: ts.BinaryExpression): void { if (!this.useStatic || !this.options.arkts2 || !TypeScriptLinter.isComparisonOperator(expr.operatorToken.kind)) { return; @@ -2258,7 +2521,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkAssignmentNumericSemanticsly(node: ts.VariableDeclaration): void { + private checkNumericSemanticsForVariable(node: ts.VariableDeclaration): void { if (!this.options.arkts2) { return; } @@ -2287,57 +2550,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.tsTypeChecker.typeToString(type); - const isEnum = this.isNumericEnumType(type); - if (TsUtils.isNumberLike(type, typeText, isEnum)) { - const autofix = this.autofixer?.fixVariableDeclaration(node, isEnum); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(node, type); this.incrementCounters(node, FaultID.NumericSemantics, autofix); } } - private isEnumType(type: ts.Type): boolean { - if (type.flags & ts.TypeFlags.Enum) { - return true; - } - - if (type.symbol?.flags & ts.SymbolFlags.Enum) { - return true; - } - - if (type.flags & ts.TypeFlags.EnumLiteral) { - return true; - } - - if (type.isUnion()) { - return type.types.some((t) => { - return this.isEnumType(t); - }); - } - return false; - } - - private isNumericEnumType(type: ts.Type): boolean { - if (!this.isEnumType(type)) { - return false; - } - const declarations = type.symbol?.getDeclarations() || []; - const enumMemberDecl = declarations.find(ts.isEnumMember); - if (enumMemberDecl) { - const value = this.tsTypeChecker.getConstantValue(enumMemberDecl); - return typeof value === STRINGLITERAL_NUMBER; - } - - const enumDecl = declarations.find(ts.isEnumDeclaration); - if (enumDecl) { - return enumDecl.members.every((member) => { - const memberType = this.tsTypeChecker.getTypeAtLocation(member.name); - return (memberType.flags & ts.TypeFlags.NumberLike) !== 0; - }); - } - return false; - } - - private checkAssignmentNumericSemanticsFuntion(node: ts.FunctionDeclaration): void { + private checkNumericSemanticsForFunction(node: ts.FunctionDeclaration): void { if (!this.options.arkts2) { return; } @@ -2351,9 +2570,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, param.name); - const typeText = this.tsTypeChecker.typeToString(type); - if (typeText === STRINGLITERAL_NUMBER) { - const autofix = this.autofixer?.fixParameter(param); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(param, type); if (autofix) { this.incrementCounters(node, FaultID.NumericSemantics, autofix); } @@ -2376,7 +2594,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkAssignmentNumericSemanticslyPro(node: ts.PropertyDeclaration): void { + private checkNumericSemanticsForProperty(node: ts.PropertyDeclaration): void { if (!this.options.arkts2) { return; } @@ -2390,27 +2608,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const isNumberArray = ts.isArrayLiteralExpression(initializer) && TypeScriptLinter.isNumberArray(initializer); const isNumber = !isNumberArray && TypeScriptLinter.isNumericInitializer(initializer); - const sym = this.tsTypeChecker.getSymbolAtLocation(name); - if (!sym) { + if (!isNumber && !isNumberArray) { return; } - if (!isNumber && !isNumberArray) { + const sym = this.tsTypeChecker.getSymbolAtLocation(name); + if (!sym) { return; } - const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.tsTypeChecker.typeToString(type); - const typeFlags = type.flags; - if (isNumber && (typeText === STRINGLITERAL_NUMBER || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0)) { - const autofix = this.autofixer?.fixPropertyDeclaration(node); - this.incrementCounters(node, FaultID.NumericSemantics, autofix); - } - this.checkAssignmentNumericSemanticsArray(node, isNumberArray); - } - checkAssignmentNumericSemanticsArray(node: ts.PropertyDeclaration, isNumberArray: boolean): void { - if (isNumberArray) { - const autofix = this.autofixer?.fixPropertyDeclarationNumericSemanticsArray(node); + const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(node, type); this.incrementCounters(node, FaultID.NumericSemantics, autofix); } } @@ -2426,6 +2635,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ) { return true; } + if ( + ts.isBinaryExpression(node) && + TypeScriptLinter.isNumericInitializer(node.left) && + TypeScriptLinter.isNumericInitializer(node.right) + ) { + return true; + } return false; } @@ -2513,6 +2729,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private isObjectLiteralKeyTypeValid(objectLiteral: ts.ObjectLiteralExpression, contextualType: ts.Type): void { + if (!this.tsUtils.isStdRecordType(contextualType)) { + return; + } + objectLiteral.properties.forEach((prop: ts.ObjectLiteralElementLike): void => { + if (ts.isPropertyAssignment(prop)) { + if (!this.tsUtils.isValidRecordObjectLiteralKey(prop.name)) { + this.incrementCounters(prop, FaultID.ObjectLiteralKeyType); + } + } + }); + } + private handleVariableDeclaration(node: ts.Node): void { const tsVarDecl = node as ts.VariableDeclaration; this.handleVariableDeclarationForProp(tsVarDecl); @@ -2532,20 +2761,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.tsTypeChecker.getTypeAtLocation(tsVarDecl.type), tsVarDecl.initializer ); - this.checkFunctionTypeCompatible(tsVarDecl.type, tsVarDecl.initializer); } this.handleEsValueDeclaration(tsVarDecl); this.handleDeclarationInferredType(tsVarDecl); this.handleDefiniteAssignmentAssertion(tsVarDecl); this.handleLimitedVoidType(tsVarDecl); this.handleInvalidIdentifier(tsVarDecl); - this.checkAssignmentNumericSemanticsly(tsVarDecl); + this.checkNumericSemanticsForVariable(tsVarDecl); this.checkTypeFromSdk(tsVarDecl.type); this.handleObjectLiteralforUnionTypeInterop(tsVarDecl); this.handleObjectLiteralAssignmentToClass(tsVarDecl); this.handleObjectLiteralAssignment(tsVarDecl); this.handlePropertyDescriptorInScenarios(tsVarDecl); this.handleSdkGlobalApi(tsVarDecl); + this.handleNoDeprecatedApi(tsVarDecl); } private checkTypeFromSdk(type: ts.TypeNode | undefined): void { @@ -2663,23 +2892,309 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (this.options.arkts2 && tsCatch.variableDeclaration?.name) { const varDeclName = tsCatch.variableDeclaration?.name.getText(); tsCatch.block.statements.forEach((statement) => { - this.checkTsLikeCatchType(statement, varDeclName); + this.checkTsLikeCatchType(statement, varDeclName, undefined); }); } } - private checkTsLikeCatchType(node: ts.Node, variableDeclarationName: string): void { + private checkTsLikeCatchType( + node: ts.Node, + variableDeclarationName: string, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): void { if (!node) { return; } - for (const child of node.getChildren()) { - if (ts.isPropertyAccessExpression(child)) { - if (child.expression.getText() === variableDeclarationName && !ERROR_PROP_LIST.has(child.name.getText())) { - this.incrementCounters(child, FaultID.TsLikeCatchType); - } - } - this.checkTsLikeCatchType(child, variableDeclarationName); + const hasChecked = this.hasCheckedTsLikeCatchTypeInIfStatement(node, variableDeclarationName, typeNode); + if (hasChecked) { + return; + } + const hasCheckedInConditionalExpr = this.hasCheckedTsLikeCatchTypeInConditionalExpression( + node, + variableDeclarationName, + typeNode + ); + if (hasCheckedInConditionalExpr) { + return; + } + this.checkTsLikeCatchTypeForAsExpr(node, variableDeclarationName); + + for (const child of node.getChildren()) { + if (ts.isPropertyAccessExpression(child)) { + this.checkTsLikeCatchTypeForPropAccessExpr(child, variableDeclarationName, typeNode); + + if ( + ts.isParenthesizedExpression(child.expression) && + ts.isAsExpression(child.expression.expression) && + child.expression.expression.expression.getText() === variableDeclarationName + ) { + this.checkTsLikeCatchTypePropForAsExpression(child, child.expression.expression); + } + } + this.checkTsLikeCatchType(child, variableDeclarationName, typeNode); + } + } + + private hasCheckedTsLikeCatchTypeInIfStatement( + node: ts.Node, + variableDeclarationName: string, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): boolean { + const checkSubStatement = (node: ts.IfStatement, declaration: ts.ClassDeclaration): void => { + if (!this.isErrorOrInheritError(declaration)) { + this.incrementCounters(node.expression, FaultID.TsLikeCatchType); + } else { + this.checkTsLikeCatchType(node.thenStatement, variableDeclarationName, declaration); + } + const elseStatement = node.elseStatement; + if (elseStatement) { + this.checkTsLikeCatchType(elseStatement, variableDeclarationName, typeNode); + } + }; + + if ( + ts.isIfStatement(node) && + ts.isBinaryExpression(node.expression) && + node.expression.operatorToken.kind === ts.SyntaxKind.InstanceOfKeyword && + node.expression.left.getText() === variableDeclarationName + ) { + const rightSym = this.tsTypeChecker.getSymbolAtLocation(node.expression.right); + const decl = rightSym?.declarations?.[0]; + if (decl && ts.isClassDeclaration(decl)) { + checkSubStatement(node, decl); + return true; + } + if (decl && ts.isImportSpecifier(decl)) { + const symbol = this.getSymbolByImportSpecifier(decl); + const declaration = symbol?.declarations?.[0]; + if (declaration && ts.isClassDeclaration(declaration)) { + checkSubStatement(node, declaration); + return true; + } + } + } + return false; + } + + private hasCheckedTsLikeCatchTypeInConditionalExpression( + node: ts.Node, + variableDeclarationName: string, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): boolean { + if ( + ts.isConditionalExpression(node) && + ts.isBinaryExpression(node.condition) && + node.condition.operatorToken.kind === ts.SyntaxKind.InstanceOfKeyword && + node.condition.left.getText() === variableDeclarationName + ) { + const rightSym = this.tsTypeChecker.getSymbolAtLocation(node.condition.right); + const decl = rightSym?.declarations?.[0]; + if (decl && ts.isClassDeclaration(decl)) { + this.checkTsLikeCatchTypeInConditionalExprSubStatement(node, decl, variableDeclarationName, typeNode); + return true; + } else if (decl && ts.isImportSpecifier(decl)) { + const symbol = this.getSymbolByImportSpecifier(decl); + const declaration = symbol?.declarations?.[0]; + if (declaration && ts.isClassDeclaration(declaration)) { + this.checkTsLikeCatchTypeInConditionalExprSubStatement(node, declaration, variableDeclarationName, typeNode); + return true; + } + } + } + return false; + } + + private checkTsLikeCatchTypeInConditionalExprSubStatement( + node: ts.ConditionalExpression, + declarationType: ts.ClassDeclaration, + variableDeclarationName: string, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): void { + const checkWhenFalseExpr = ( + whenFalse: ts.Node, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): void => { + if (ts.isPropertyAccessExpression(whenFalse) && whenFalse.expression.getText() === variableDeclarationName) { + if (!typeNode) { + if (!ERROR_PROP_LIST.has(whenFalse.name.getText())) { + this.incrementCounters(whenFalse, FaultID.TsLikeCatchType); + } + } else { + const isValidErrorPropAccess = this.isValidErrorPropAccess(whenFalse, typeNode); + if (!isValidErrorPropAccess) { + this.incrementCounters(whenFalse, FaultID.TsLikeCatchType); + } + } + } else { + this.checkTsLikeCatchType(whenFalse, variableDeclarationName, typeNode); + } + }; + + if (!this.isErrorOrInheritError(declarationType)) { + this.incrementCounters(node.condition, FaultID.TsLikeCatchType); + checkWhenFalseExpr(node.whenFalse, typeNode); + } else { + if ( + ts.isPropertyAccessExpression(node.whenTrue) && + node.whenTrue.expression.getText() === variableDeclarationName + ) { + const whenTrue: ts.PropertyAccessExpression = node.whenTrue; + const isValidErrorPropAccess = this.isValidErrorPropAccess(whenTrue, declarationType); + if (!isValidErrorPropAccess) { + this.incrementCounters(whenTrue, FaultID.TsLikeCatchType); + } + } else { + this.checkTsLikeCatchType(node.whenTrue, variableDeclarationName, declarationType); + } + checkWhenFalseExpr(node.whenFalse, typeNode); + } + } + + private checkTsLikeCatchTypeForAsExpr(node: ts.Node, variableDeclarationName: string): void { + if (!ts.isAsExpression(node) || node.expression.getText() !== variableDeclarationName) { + return; + } + const asExprTypeNode = node.type; + if (!asExprTypeNode || !ts.isTypeReferenceNode(asExprTypeNode)) { + return; + } + const checkReport = (node: ts.AsExpression, declaration: ts.ClassDeclaration | ts.InterfaceDeclaration): void => { + if (!this.isErrorOrInheritError(declaration)) { + this.incrementCounters(node, FaultID.TsLikeCatchType); + } + }; + + const checkImportSpecifier = (decl: ts.ImportSpecifier): void => { + const symbol = this.getSymbolByImportSpecifier(decl); + const declaration = symbol?.declarations?.[0]; + if (declaration && (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration))) { + checkReport(node, declaration); + } + }; + const typeName = asExprTypeNode.typeName; + const sym = this.tsTypeChecker.getSymbolAtLocation(typeName); + const decl = sym?.declarations?.[0]; + if (decl && (ts.isClassDeclaration(decl) || ts.isInterfaceDeclaration(decl))) { + checkReport(node, decl); + } else if (decl && ts.isImportSpecifier(decl)) { + checkImportSpecifier(decl); + } + } + + private checkTsLikeCatchTypeHasPropInType( + propAccessExpr: ts.PropertyAccessExpression, + decl: ts.ClassDeclaration | ts.InterfaceDeclaration + ): void { + if (!decl) { + return; + } + if (this.isErrorOrInheritError(decl)) { + const isValidErrorPropAccess = this.isValidErrorPropAccess(propAccessExpr, decl); + if (!isValidErrorPropAccess) { + this.incrementCounters(propAccessExpr, FaultID.TsLikeCatchType); + } + } + } + + private checkTsLikeCatchTypeForPropAccessExpr( + propAccessExpr: ts.PropertyAccessExpression, + variableDeclarationName: string, + typeNode: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): void { + const checkProp = (): void => { + if (!typeNode) { + if (!ERROR_PROP_LIST.has(propAccessExpr.name.getText())) { + this.incrementCounters(propAccessExpr, FaultID.TsLikeCatchType); + } + } else { + const isValidErrorPropAccess = this.isValidErrorPropAccess(propAccessExpr, typeNode); + if (!isValidErrorPropAccess) { + this.incrementCounters(propAccessExpr, FaultID.TsLikeCatchType); + } + } + }; + + if (propAccessExpr.expression.getText() === variableDeclarationName) { + checkProp(); + return; + } + + const sym = this.tsTypeChecker.getSymbolAtLocation(propAccessExpr.expression); + const decl = sym?.declarations?.[0]; + if (decl && ts.isVariableDeclaration(decl) && decl.initializer) { + if (decl.initializer.getText() === variableDeclarationName) { + checkProp(); + return; + } + if (ts.isAsExpression(decl.initializer) && decl.initializer.expression.getText() === variableDeclarationName) { + this.checkTsLikeCatchTypePropForAsExpression(propAccessExpr, decl.initializer); + } + } + } + + private checkTsLikeCatchTypePropForAsExpression( + propAccessExpr: ts.PropertyAccessExpression, + asExpr: ts.AsExpression + ): void { + const asExprTypeNode = asExpr.type; + if (asExprTypeNode && ts.isTypeReferenceNode(asExprTypeNode)) { + const typeName = asExprTypeNode.typeName; + const sym = this.tsTypeChecker.getSymbolAtLocation(typeName); + const decl = sym?.declarations?.[0]; + if (decl && (ts.isClassDeclaration(decl) || ts.isInterfaceDeclaration(decl))) { + this.checkTsLikeCatchTypeHasPropInType(propAccessExpr, decl); + } else if (decl && ts.isImportSpecifier(decl)) { + const symbol = this.getSymbolByImportSpecifier(decl); + const declaration = symbol?.declarations?.[0]; + if (declaration && (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration))) { + this.checkTsLikeCatchTypeHasPropInType(propAccessExpr, declaration); + } + } + } + } + + private isErrorOrInheritError(declaration: ts.ClassDeclaration | ts.InterfaceDeclaration): boolean { + const type = this.tsTypeChecker.getTypeAtLocation(declaration); + return this.tsUtils.isOrDerivedFrom(type, this.tsUtils.isStdErrorType); + } + + private isValidErrorPropAccess( + propertyAccessExpr: ts.PropertyAccessExpression, + decl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + ): boolean { + void this; + let containsMember = false; + decl?.members.forEach((member) => { + if (member.name?.getText() === propertyAccessExpr.name.getText()) { + containsMember = true; + } + }); + return containsMember || ERROR_PROP_LIST.has(propertyAccessExpr.name.getText()); + } + + private getSymbolByImportSpecifier(declaration: ts.ImportSpecifier): ts.Symbol | undefined { + if (!declaration?.parent?.parent) { + return undefined; + } + if (!ts.isImportClause(declaration.parent.parent)) { + return undefined; + } + const importClause = declaration.parent.parent; + const namedBindings = importClause.namedBindings; + let symbol: ts.Symbol | undefined; + if (namedBindings) { + if (ts.isNamedImports(namedBindings) && namedBindings.elements?.length > 0) { + for (let i = 0; i < namedBindings.elements.length; i++) { + if (namedBindings.elements[i].name.getText() === declaration.name.getText()) { + symbol = this.tsUtils.trueSymbolAtLocation(namedBindings.elements[i].name); + break; + } + } + } else if (ts.isNamespaceImport(namedBindings)) { + symbol = this.tsUtils.trueSymbolAtLocation(namedBindings.name); + } } + return symbol; } private handleClassExtends(tsClassDecl: ts.ClassDeclaration): void { @@ -3231,6 +3746,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } } + if (this.options.arkts2) { + this.handleParamType(tsMethodDecl); + } if (tsMethodDecl.body && isStatic) { this.reportThisKeywordsInScope(tsMethodDecl.body); } @@ -3258,6 +3776,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkGlobalApi(tsMethodDecl); this.handleLimitedVoidFunction(tsMethodDecl); this.checkVoidLifecycleReturn(tsMethodDecl); + this.handleNoDeprecatedApi(tsMethodDecl); } private handleLimitedVoidFunction(node: ts.FunctionLikeDeclaration): void { @@ -3307,39 +3826,101 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isClassDeclaration(classDecl)) { return; } - - const isStatic = node.modifiers?.some(mod => { - return mod.kind === ts.SyntaxKind.StaticKeyword; - }) || false; + this.checkIncompatibleFunctionTypes(node); + const isStatic = + node.modifiers?.some((mod) => { + return mod.kind === ts.SyntaxKind.StaticKeyword; + }) || false; const classType: ts.Type | undefined = this.getClassType(classDecl, isStatic); const allBaseTypes = classType && this.getAllBaseTypes(classType, classDecl, isStatic); if (!allBaseTypes || allBaseTypes.length === 0) { return; } const methodName = node.name.text; + if (allBaseTypes && allBaseTypes.length > 0) { + this.checkMethodType(allBaseTypes, methodName, node, isStatic); + } + } + + private checkMethodType(allBaseTypes: ts.Type[], methodName: string, node: ts.MethodDeclaration, isStatic: boolean = false): void { for (const baseType of allBaseTypes) { - const baseMethod = baseType.getProperty(methodName); + let baseMethod: ts.Symbol | undefined; + if (isStatic) { + const constructorType = this.tsTypeChecker.getTypeOfSymbolAtLocation(baseType.getSymbol()!, node); + baseMethod = constructorType.getProperty(methodName) || + baseType.getSymbol()?.members?.get(ts.escapeLeadingUnderscores(methodName)); + } else { + baseMethod = baseType.getProperty(methodName); + } if (!baseMethod) { continue; } - - const baseMethodDecl = baseMethod.declarations?.find((d) => { - return (ts.isMethodDeclaration(d) || ts.isMethodSignature(d)) && - this.isDeclarationInType(d, baseType, isStatic); - }) as ts.MethodDeclaration | ts.MethodSignature; + const baseMethodDecl = baseMethod.declarations?.find(d => + (ts.isMethodDeclaration(d) || ts.isMethodSignature(d)) && + this.isSameDeclarationType(d.parent, baseType, isStatic) + ) as ts.MethodDeclaration | ts.MethodSignature; if (!baseMethodDecl) { continue; } this.checkMethodParameters(node, baseMethodDecl); + this.checkMethodReturnType(node, baseMethodDecl); break; } } - private getClassType( classDecl: ts.ClassDeclaration, isStatic?: boolean): ts.Type | undefined { + private isSameDeclarationType(decl: ts.Node, type: ts.Type, isStatic: boolean): boolean { + if (isStatic && ts.isClassDeclaration(decl)) { + const staticType = this.tsTypeChecker.getTypeAtLocation(decl); + return this.isSameType(staticType, type); + } + return this.tsTypeChecker.getTypeAtLocation(decl) === type; + } + + private checkIncompatibleFunctionTypes(method: ts.MethodDeclaration): void { + const declaredReturnType = this.getActualReturnType(method); + if (!declaredReturnType) { + return; + } + const returnStatements = this.collectReturnStatements(method); + const declaredReturnTypeStr = this.tsTypeChecker.typeToString(declaredReturnType); + for (const returnStmt of returnStatements) { + if (!returnStmt.expression) { + continue; + } + const actualReturnType = this.tsTypeChecker.getTypeAtLocation(returnStmt.expression); + const actualReturnTypeStr = this.tsTypeChecker.typeToString(actualReturnType); + if (declaredReturnTypeStr === actualReturnTypeStr) { + return; + } + if (actualReturnType.flags & ts.TypeFlags.Any || declaredReturnType.flags & ts.TypeFlags.Any) { + return; + } + if (this.isSubtypeByBaseTypesList(actualReturnType, declaredReturnType)) { + this.incrementCounters(returnStmt.expression, FaultID.IncompationbleFunctionType); + return; + } + } + } + + private collectReturnStatements(node: ts.Node): ts.ReturnStatement[] { + const result: ts.ReturnStatement[] = []; + + ts.forEachChild(node, (child) => { + if (ts.isReturnStatement(child)) { + result.push(child); + } else { + result.push(...this.collectReturnStatements(child)); + } + }); + + return result; + } + + private getClassType(classDecl: ts.ClassDeclaration, isStatic?: boolean): ts.Type | undefined { let classType: ts.Type; if (isStatic) { @@ -3359,7 +3940,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!declParent) { return false; } - + let declParentType: ts.Type; if (isStatic && ts.isClassDeclaration(declParent)) { if (!declParent.symbol) { @@ -3369,7 +3950,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } else { declParentType = this.tsTypeChecker.getTypeAtLocation(declParent); } - + return this.isSameType(declParentType, type); } @@ -3400,27 +3981,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return true; } - + return this.tsTypeChecker.typeToString(type1) === this.tsTypeChecker.typeToString(type2); } private getAllBaseTypes(type: ts.Type, classDecl: ts.ClassDeclaration, isStatic?: boolean): ts.Type[] | undefined { if (isStatic) { - const baseTypes: ts.Type[] = []; - if (!classDecl.heritageClauses) { - return baseTypes; - } - for (const clause of classDecl.heritageClauses) { - if (clause.token !== ts.SyntaxKind.ExtendsKeyword) { - continue; - } - for (const typeNode of clause.types) { - const baseType = this.tsTypeChecker.getTypeAtLocation(typeNode); - baseTypes.push(baseType); - } - } - - return baseTypes; + return this.getStaticAllBaseTypes(classDecl); } const baseClasses = type.getBaseTypes() || []; @@ -3432,6 +3999,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!classDecl.heritageClauses) { return resolvedBaseClasses; } + const interfaces: ts.Type[] = []; for (const clause of classDecl.heritageClauses) { if (clause.token !== ts.SyntaxKind.ImplementsKeyword) { @@ -3450,7 +4018,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); } } - return [...resolvedBaseClasses, ...interfaces]; + return [...resolvedBaseClasses, ...interfaces]; + } + + private getStaticAllBaseTypes(classDecl: ts.ClassDeclaration): ts.Type[] | undefined { + const baseTypes: ts.Type[] = []; + if (!classDecl.heritageClauses) { + return baseTypes; + } + + for (const clause of classDecl.heritageClauses) { + if (clause.token !== ts.SyntaxKind.ExtendsKeyword) { + continue; + } + + for (const typeNode of clause.types) { + const baseType = this.tsTypeChecker.getTypeAtLocation(typeNode); + baseTypes.push(baseType); + + const baseDecl = baseType.getSymbol()?.declarations?.[0]; + if (baseDecl && ts.isClassDeclaration(baseDecl)) { + const staticBaseType = this.tsTypeChecker.getTypeAtLocation(baseDecl); + const staticBaseTypes = this.getAllBaseTypes(staticBaseType, baseDecl, true) || []; + baseTypes.push(...staticBaseTypes); + } + } + } + return baseTypes; } /** @@ -3475,6 +4069,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const baseParamType = this.tsTypeChecker.getTypeAtLocation(baseParams[i]); const derivedParamType = this.tsTypeChecker.getTypeAtLocation(derivedParams[i]); + if (baseParamType.flags & ts.TypeFlags.TypeParameter) { + if (!(derivedParamType.flags & ts.TypeFlags.TypeParameter)) { + continue; + } + } + if (!this.isTypeSameOrWider(baseParamType, derivedParamType)) { this.incrementCounters(derivedParams[i], FaultID.MethodInheritRule); } @@ -3489,6 +4089,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { derivedMethod: ts.MethodDeclaration, baseMethod: ts.MethodDeclaration | ts.MethodSignature ): void { + if(this.shouldSkipTypeParameterCheck(derivedMethod, baseMethod)) { + return; + } const baseMethodType = this.getActualReturnType(baseMethod); const derivedMethodType = this.getActualReturnType(derivedMethod); const baseMethodTypeIsVoid = TypeScriptLinter.checkMethodTypeIsVoidOrAny(baseMethodType, true); @@ -3531,6 +4134,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private shouldSkipTypeParameterCheck( + derivedMethod: ts.MethodDeclaration, + baseMethod: ts.MethodDeclaration | ts.MethodSignature + ): boolean { + const baseMethodType = this.getActualReturnType(baseMethod); + const derivedMethodType = this.getActualReturnType(derivedMethod); + + if (baseMethodType && (baseMethodType.flags & ts.TypeFlags.TypeParameter)) { + if (derivedMethodType && !(derivedMethodType.flags & ts.TypeFlags.TypeParameter)) { + return true; + } + } + return false; + } + private static checkMethodTypeIsVoidOrAny( methodType: ts.Type | undefined, isVoidOrAny: boolean, @@ -3565,6 +4183,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private isTypeSameOrWider(baseType: ts.Type, derivedType: ts.Type): boolean { + if (this.tsTypeChecker.typeToString(baseType) === this.tsTypeChecker.typeToString(derivedType)) { + return true; + } + if (derivedType.flags & ts.TypeFlags.Any) { return true; } @@ -3630,19 +4252,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { // Check if a type string has an equivalent primitive/wrapper type in a set private static areWrapperAndPrimitiveTypesEqual(typeStr: string, typeSet: Set): boolean { - const typePairs = [ - ['String', 'string'], - ['Number', 'number'], - ['Boolean', 'boolean'] - ]; + const typePairs = [ + ['String', 'string'], + ['Number', 'number'], + ['Boolean', 'boolean'] + ]; - for (const [wrapper, primitive] of typePairs) { - if ((typeStr === wrapper && typeSet.has(primitive)) || - (typeStr === primitive && typeSet.has(wrapper))) { - return true; - } + for (const [wrapper, primitive] of typePairs) { + if (typeStr === wrapper && typeSet.has(primitive) || typeStr === primitive && typeSet.has(wrapper)) { + return true; } - return false; + } + return false; } private isDerivedTypeAssignable(derivedType: ts.Type, baseType: ts.Type): boolean { @@ -3661,7 +4282,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const baseTypeNode = baseDeclarations[0]; const derivedTypeNode = derivedDeclarations[0]; - if (ts.isClassDeclaration(baseTypeNode) && ts.isClassDeclaration(derivedTypeNode)) { + if ( + baseTypeNode && + derivedTypeNode && + ts.isClassDeclaration(baseTypeNode) && + ts.isClassDeclaration(derivedTypeNode) + ) { const baseTypes = this.tsTypeChecker.getTypeAtLocation(derivedTypeNode).getBaseTypes(); const baseTypesExtends = baseTypes?.some((t) => { return t === baseType; @@ -3676,29 +4302,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { // Converts union types into an array of type strings for easy comparison. private flattenUnionTypes(type: ts.Type): string[] { - if (type.isUnion()) { - return type.types.map((t) => { - return TypeScriptLinter.normalizeTypeString(this.tsTypeChecker.typeToString(t)); - }); - } - return [TypeScriptLinter.normalizeTypeString(this.tsTypeChecker.typeToString(type))]; + if (type.isUnion()) { + return type.types.map((t) => { + return TypeScriptLinter.normalizeTypeString(this.tsTypeChecker.typeToString(t)); + }); + } + return [TypeScriptLinter.normalizeTypeString(this.tsTypeChecker.typeToString(type))]; } // Normalize type string to handle primitive wrapper types consistently private static normalizeTypeString(typeStr: string): string { - // Handle all primitive wrapper types - const wrapperToPrimitive: Record = { - 'String': 'string', - 'Number': 'number', - 'Boolean': 'boolean' - }; + // Handle all primitive wrapper types + const wrapperToPrimitive: Record = { + String: 'string', + Number: 'number', + Boolean: 'boolean' + }; - // Replace wrapper types with their primitive counterparts - let normalized = typeStr; - for (const [wrapper, primitive] of Object.entries(wrapperToPrimitive)) { - normalized = normalized.replace(new RegExp(wrapper, 'g'), primitive); - } - return normalized; + // Replace wrapper types with their primitive counterparts + let normalized = typeStr; + for (const [wrapper, primitive] of Object.entries(wrapperToPrimitive)) { + normalized = normalized.replace(new RegExp(wrapper, 'g'), primitive); + } + return normalized; } private checkClassImplementsMethod(classDecl: ts.ClassDeclaration, methodName: string): boolean { @@ -3793,15 +4419,15 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isIdentifier(node)) { return; } + this.checkCollectionsSymbol(node); this.handleInterfaceImport(node); this.checkAsonSymbol(node); const tsIdentifier = node; this.handleTsInterop(tsIdentifier, () => { const parent = tsIdentifier.parent; - if (ts.isPropertyAccessExpression(parent) || ts.isImportSpecifier(parent)) { + if (ts.isImportSpecifier(parent)) { return; } - const type = this.tsTypeChecker.getTypeAtLocation(tsIdentifier); this.checkUsageOfTsTypes(type, tsIdentifier); }); @@ -3811,31 +4437,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const isArkTs2 = this.options.arkts2; - const isGlobalThis = tsIdentifier.text === 'globalThis'; + const isNewArkTS = this.options.arkts2; + if (isNewArkTS) { + this.checkWorkerSymbol(tsIdentSym, node); + this.checkConcurrencySymbol(tsIdentSym, node); + } + const isGlobalThis = tsIdentifier.text === 'globalThis'; if ( isGlobalThis && (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 ) { - this.handleGlobalThisCase(tsIdentifier, isArkTs2); + this.handleGlobalThisCase(tsIdentifier, isNewArkTS); } else { - if (isArkTs2) { + if (isNewArkTS) { this.checkLimitedStdlibApi(tsIdentifier, tsIdentSym); } this.handleRestrictedValues(tsIdentifier, tsIdentSym); } - if (isArkTs2 && this.tsTypeChecker.isArgumentsSymbol(tsIdentSym)) { + if (isNewArkTS && this.tsTypeChecker.isArgumentsSymbol(tsIdentSym)) { this.incrementCounters(node, FaultID.ArgumentsObject); } - - if (isArkTs2) { - this.checkWorkerSymbol(tsIdentSym, node); - this.checkCollectionsSymbol(tsIdentSym, node); - this.checkConcurrencySymbol(tsIdentSym, node); - } } private handlePropertyDescriptorInScenarios(node: ts.Node): void { @@ -4085,7 +4709,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.tsUtils.isOrDerivedFrom(type, this.tsUtils.isStdRecordType) || this.tsUtils.isOrDerivedFrom(type, this.tsUtils.isStringType) || !this.options.arkts2 && - (this.tsUtils.isOrDerivedFrom(type, this.tsUtils.isStdMapType) || TsUtils.isIntrinsicObjectType(type)) || + (this.tsUtils.isOrDerivedFrom(type, this.tsUtils.isStdMapType) || TsUtils.isIntrinsicObjectType(type)) || TsUtils.isEnumType(type) || // we allow EsObject here beacuse it is reported later using FaultId.EsObjectType TsUtils.isEsValueType(typeNode) @@ -4431,9 +5055,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } if (ts.isAsExpression(initializer) || ts.isTypeAssertionExpression(initializer)) { - const typeNode = ts.isAsExpression(initializer) - ? initializer.type - : initializer.type; + const typeNode = ts.isAsExpression(initializer) ? initializer.type : initializer.type; if (typeNode.kind === ts.SyntaxKind.NumberKeyword) { this.incrementCounters(enumMember, FaultID.EnumMemberNonConstInit); @@ -4537,7 +5159,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } if (ts.isCallExpression(tsCallExpr) && tsCallExpr.expression.kind === ts.SyntaxKind.SuperKeyword) { - return; + return; } const node = ts.isCallExpression(tsCallExpr) ? tsCallExpr.expression : tsCallExpr.typeName; const constructorType = this.tsTypeChecker.getTypeAtLocation(node); @@ -4613,11 +5235,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkGlobalApi(tsCallExpr); this.handleObjectLiteralAssignmentToClass(tsCallExpr); this.checkRestrictedAPICall(tsCallExpr); + this.handleNoDeprecatedApi(tsCallExpr); + this.handleFunctionReturnThisCall(tsCallExpr); } private handleCallExpressionForUI(node: ts.CallExpression): void { this.handleStateStyles(node); this.handleCallExpressionForRepeat(node); + this.handleNodeForWrappedBuilder(node); } handleNoTsLikeFunctionCall(callExpr: ts.CallExpression): void { @@ -4642,7 +5267,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } else { const autofix = this.autofixer?.fixNoTsLikeFunctionCall(callExpr); this.incrementCounters(expression, FaultID.ExplicitFunctionType, autofix); - } + } } private handleAppStorageCallExpression(tsCallExpr: ts.CallExpression): void { @@ -4690,7 +5315,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { })(); if (isNumberGeneric && !isNumberReturnType) { - const autofix = this.autofixer?.fixAppStorageCallExpression(tsCallExpr); + const autofix = this.autofixer?.fixAppStorageCallExpression(varDecl); this.incrementCounters(tsCallExpr, FaultID.NumericSemantics, autofix); } } @@ -4947,7 +5572,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const providedTypeArgs = callLikeExpr.typeArguments; const startTypeArg = providedTypeArgs?.length ?? 0; let shouldReportError = startTypeArg !== resolvedTypeArgs.length; - if (this.options.arkts2 && callLikeExpr.kind === ts.SyntaxKind.NewExpression) { + const shouldCheck = this.shouldCheckGenericCallExpression(callLikeExpr as ts.CallExpression); + if ( + this.options.arkts2 && + (ts.isNewExpression(callLikeExpr) || ts.isCallExpression(callLikeExpr) && shouldCheck) + ) { shouldReportError = this.shouldReportGenericTypeArgsError( callLikeExpr, resolvedTypeArgs, @@ -4964,15 +5593,78 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkForUnknownTypeInNonArkTS2( - callLikeExpr: ts.CallExpression | ts.NewExpression | ts.ExpressionWithTypeArguments, - resolvedTypeArgs: ts.NodeArray, - startTypeArg: number - ): void { - for (let i = startTypeArg; i < resolvedTypeArgs.length; ++i) { - const typeNode = resolvedTypeArgs[i]; - - /* + private shouldCheckGenericCallExpression(callExpr: ts.CallExpression): boolean { + const signature = this.tsTypeChecker.getResolvedSignature(callExpr); + if (!signature?.declaration) { + return false; + } + const typeParamsSafeToInfer = this.areTypeParametersReturnTypeOnly(signature.declaration); + if (!typeParamsSafeToInfer) { + return false; + } + return TypeScriptLinter.isInStrictTypeContext(callExpr); + } + + private areTypeParametersReturnTypeOnly(decl: ts.SignatureDeclaration | ts.JSDocSignature): boolean { + if (!decl.typeParameters?.length) { + return false; + } + + const typeParamNames = new Set( + decl.typeParameters.map((tp) => { + return tp.name.getText(); + }) + ); + let affectsParams = false; + + decl.parameters.forEach((param) => { + if (param.type && this.containsTypeParameters(param.type, typeParamNames)) { + affectsParams = true; + } + }); + + return !affectsParams; + } + + private containsTypeParameters(node: ts.Node, typeParamNames: Set): boolean { + let found = false; + ts.forEachChild(node, (child) => { + if (ts.isIdentifier(child) && typeParamNames.has(child.text)) { + found = true; + } + if (!found) { + found = this.containsTypeParameters(child, typeParamNames); + } + }); + return found; + } + + private static isInStrictTypeContext(callExpr: ts.CallExpression): boolean { + const parent = callExpr.parent; + + if ((ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && parent.type) { + return true; + } + + if (ts.isAsExpression(parent) || ts.isTypeAssertionExpression(parent)) { + return true; + } + + if (ts.isCallExpression(parent.parent) && parent.parent.typeArguments) { + return true; + } + return false; + } + + private checkForUnknownTypeInNonArkTS2( + callLikeExpr: ts.CallExpression | ts.NewExpression | ts.ExpressionWithTypeArguments, + resolvedTypeArgs: ts.NodeArray, + startTypeArg: number + ): void { + for (let i = startTypeArg; i < resolvedTypeArgs.length; ++i) { + const typeNode = resolvedTypeArgs[i]; + + /* * if compiler infers 'unknown' type there are 2 possible cases: * 1. Compiler unable to infer type from arguments and use 'unknown' * 2. Compiler infer 'unknown' from arguments @@ -4980,7 +5672,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { * in ArkTS and already have separate check for it. */ if (typeNode.kind === ts.SyntaxKind.UnknownKeyword) { - this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs); + const autofix = ts.isCallExpression(callLikeExpr) ? + this.autofixer?.fixGenericCallNoTypeArgsForUnknown(callLikeExpr) : + undefined; + this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs, autofix); break; } } @@ -5067,6 +5762,77 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private handleFunctionReturnThisCall(node: ts.CallExpression | ts.NewExpression): void { + if (!this.options.arkts2) { + return; + } + const args = node.arguments; + const isUnsafeCallee = this.checkUnsafeFunctionCalleeName(node.expression); + if (!isUnsafeCallee) { + return; + } + if (!args) { + return; + } + if (args.length === 0) { + return; + } + const isForbidden = this.isForbiddenBodyArgument(args[0]); + if (isForbidden) { + this.incrementCounters(node, FaultID.NoFunctionReturnThis); + } + } + + private isForbiddenBodyArgument(arg: ts.Expression): boolean { + if ((ts.isStringLiteral(arg) || ts.isNoSubstitutionTemplateLiteral(arg)) && arg.text === FORBIDDEN_FUNCTION_BODY) { + return true; + } + + if (ts.isIdentifier(arg)) { + const symbol = this.tsTypeChecker.getSymbolAtLocation(arg); + const decl = symbol?.valueDeclaration; + + if ( + decl && + ts.isVariableDeclaration(decl) && + decl.initializer && + ts.isStringLiteral(decl.initializer) && + decl.initializer.text === FORBIDDEN_FUNCTION_BODY + ) { + return true; + } + } + + return false; + } + + private checkUnsafeFunctionCalleeName(expr: ts.Expression): boolean { + if (ts.isIdentifier(expr) && expr.text === LIKE_FUNCTION) { + return true; + } + + if (ts.isParenthesizedExpression(expr)) { + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isPropertyAccessExpression(expr)) { + if (expr.name.text === LIKE_FUNCTION) { + return true; + } + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isCallExpression(expr)) { + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isBinaryExpression(expr) && expr.operatorToken.kind === ts.SyntaxKind.CommaToken) { + return this.checkUnsafeFunctionCalleeName(expr.right); + } + + return false; + } + private handleStructIdentAndUndefinedInArgs( tsCallOrNewExpr: ts.CallExpression | ts.NewExpression, callSignature: ts.Signature @@ -5278,11 +6044,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleNewExpression(node: ts.Node): void { const tsNewExpr = node as ts.NewExpression; - + this.handleNodeForWrappedBuilder(tsNewExpr); this.checkForInterfaceInitialization(tsNewExpr); this.handleSharedArrayBuffer(tsNewExpr); this.handleSdkGlobalApi(tsNewExpr); this.checkCreatingPrimitiveTypes(tsNewExpr); + this.handleNoDeprecatedApi(tsNewExpr); + this.handleNodeForBuilderNode(tsNewExpr); if (this.options.advancedClassChecks || this.options.arkts2) { const calleeExpr = tsNewExpr.expression; @@ -5311,6 +6079,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSendableGenericTypes(tsNewExpr); this.handleInstantiatedJsObject(tsNewExpr, sym); this.handlePromiseNeedVoidResolve(tsNewExpr); + this.handleFunctionReturnThisCall(tsNewExpr); } handlePromiseNeedVoidResolve(newExpr: ts.NewExpression): void { @@ -5656,12 +6425,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleTypeReference(node: ts.Node): void { const typeRef = node as ts.TypeReferenceNode; - this.handleBuiltinCtorCallSignature(typeRef); this.handleSharedArrayBuffer(typeRef); this.handleSdkGlobalApi(typeRef); - this.handleSdkConstructorIface(typeRef); + this.handleNodeForWrappedBuilder(typeRef); + this.handleNoDeprecatedApi(typeRef); + this.handleNodeForBuilderNode(typeRef); const isESValue = TsUtils.isEsValueType(typeRef); const isPossiblyValidContext = TsUtils.isEsValuePossiblyAllowed(typeRef); @@ -6334,6 +7104,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } this.handleStructuralTyping(contextNode, lhsType, rhsType, rhsExpr, isStrict); + this.checkFunctionalTypeCompatibility(lhsType, rhsType, rhsExpr); } private handleStructuralTyping( @@ -6440,7 +7211,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if ( this.compatibleSdkVersion > SENDBALE_FUNCTION_START_VERSION || this.compatibleSdkVersion === SENDBALE_FUNCTION_START_VERSION && - !SENDABLE_FUNCTION_UNSUPPORTED_STAGES_IN_API12.includes(this.compatibleSdkVersionStage) + !SENDABLE_FUNCTION_UNSUPPORTED_STAGES_IN_API12.includes(this.compatibleSdkVersionStage) ) { return true; } @@ -6646,7 +7417,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private validateSwitchExpression(switchStatement: ts.SwitchStatement): void { const expr = switchStatement.expression; const nodeType = this.tsTypeChecker.getTypeAtLocation(expr); - const { isLiteralInitialized, isFloatLiteral, hasExplicitTypeAnnotation } = this.getDeclarationInfo(expr); + const { isLiteralInitialized, hasExplicitTypeAnnotation } = this.getDeclarationInfo(expr); const isUnionType = (nodeType.flags & ts.TypeFlags.Union) !== 0; @@ -6654,10 +7425,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const typeText = this.tsTypeChecker.typeToString(t); return Boolean( t.flags & ts.TypeFlags.StringLike || - typeText === 'String' || - t.flags & ts.TypeFlags.NumberLike && (/^\d+$/).test(typeText) || - isLiteralInitialized && !hasExplicitTypeAnnotation && !isFloatLiteral || - t.flags & ts.TypeFlags.EnumLike + typeText === 'String' || + typeText === 'number' || + t.flags & ts.TypeFlags.NumberLike && (/^\d+$/).test(typeText) || + isLiteralInitialized && !hasExplicitTypeAnnotation || + t.flags & ts.TypeFlags.EnumLike ); }; @@ -6675,14 +7447,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private getDeclarationInfo(expression: ts.Expression): { isLiteralInitialized: boolean; - isFloatLiteral: boolean; hasExplicitTypeAnnotation: boolean; } { const symbol = this.tsTypeChecker.getSymbolAtLocation(expression); const declaration = symbol?.valueDeclaration; if (!declaration || !ts.isVariableDeclaration(declaration)) { - return { isLiteralInitialized: false, isFloatLiteral: false, hasExplicitTypeAnnotation: false }; + return { isLiteralInitialized: false, hasExplicitTypeAnnotation: false }; } const hasExplicitTypeAnnotation = !!declaration.type; @@ -6690,30 +7461,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return { isLiteralInitialized: initializerInfo.isLiteralInitialized, - isFloatLiteral: initializerInfo.isFloatLiteral, hasExplicitTypeAnnotation }; } private static getInitializerInfo(initializer?: ts.Expression): { isLiteralInitialized: boolean; - isFloatLiteral: boolean; } { if (!initializer) { - return { isLiteralInitialized: false, isFloatLiteral: false }; + return { isLiteralInitialized: false }; } const isLiteralInitialized = ts.isNumericLiteral(initializer) || ts.isStringLiteral(initializer); - let isFloatLiteral = false; - if (ts.isNumericLiteral(initializer)) { - const literalText = initializer.getText(); - if (!(/^0[xX]/).test(literalText)) { - isFloatLiteral = (/\.|e[-+]|\dE[-+]/i).test(literalText); - } - } - - return { isLiteralInitialized, isFloatLiteral }; + return { isLiteralInitialized }; } private findDuplicateCases(switchStatement: ts.SwitchStatement): ts.CaseClause[] { @@ -6929,9 +7690,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if ( this.tsUtils.isOrDerivedFrom(lhsType, this.tsUtils.isArray) && - this.tsUtils.isOrDerivedFrom(rhsType, TsUtils.isTuple) || + this.tsUtils.isOrDerivedFrom(rhsType, TsUtils.isTuple) || this.tsUtils.isOrDerivedFrom(rhsType, this.tsUtils.isArray) && - this.tsUtils.isOrDerivedFrom(lhsType, TsUtils.isTuple) + this.tsUtils.isOrDerivedFrom(lhsType, TsUtils.isTuple) ) { this.incrementCounters(node, FaultID.NoTuplesArrays); } @@ -6949,37 +7710,93 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + isExprReturnedFromAsyncFunction(rhsExpr: ts.Expression | undefined, lhsType: ts.Type): ts.Type | undefined { + void this; + if (!rhsExpr) { + return undefined; + } + + const enclosingFunction = ts.findAncestor(rhsExpr, ts.isFunctionLike); + const isReturnExpr = ts.isReturnStatement(rhsExpr.parent) || ts.isArrowFunction(rhsExpr.parent); + if (!enclosingFunction) { + return undefined; + } + if (!isReturnExpr) { + return undefined; + } + + if (!TsUtils.hasModifier(enclosingFunction.modifiers, ts.SyntaxKind.AsyncKeyword)) { + return undefined; + } + + const lhsPromiseLikeType = lhsType.isUnion() && lhsType.types.find(TsUtils.isStdPromiseLikeType); + if (!lhsPromiseLikeType) { + return undefined; + } + + if (!TsUtils.isTypeReference(lhsPromiseLikeType) || !lhsPromiseLikeType.typeArguments?.length) { + return undefined; + } + return lhsPromiseLikeType.typeArguments[0]; + } + private handleArrayTypeImmutable(node: ts.Node, lhsType: ts.Type, rhsType: ts.Type, rhsExpr?: ts.Expression): void { if (!this.options.arkts2) { return; } - const isArray = - this.tsUtils.isOrDerivedFrom(lhsType, this.tsUtils.isArray) && - this.tsUtils.isOrDerivedFrom(rhsType, this.tsUtils.isArray); + + const possibleLhsType = this.isExprReturnedFromAsyncFunction(rhsExpr, lhsType); + if (possibleLhsType) { + lhsType = possibleLhsType; + } + + const isArray = this.tsUtils.isArray(lhsType) && this.tsUtils.isArray(rhsType); const isTuple = this.tsUtils.isOrDerivedFrom(lhsType, TsUtils.isTuple) && this.tsUtils.isOrDerivedFrom(rhsType, TsUtils.isTuple); if (!((isArray || isTuple) && lhsType !== rhsType)) { return; } - const rhsTypeStr = this.tsTypeChecker.typeToString(rhsType); let lhsTypeStr = this.tsTypeChecker.typeToString(lhsType); if (rhsExpr && (this.isNullOrEmptyArray(rhsExpr) || ts.isArrayLiteralExpression(rhsExpr))) { return; } - if (ts.isAsExpression(node) && ts.isArrayLiteralExpression(node.expression)) { - node.expression.elements.forEach((elem) => { - if (elem.kind === ts.SyntaxKind.FalseKeyword || elem.kind === ts.SyntaxKind.TrueKeyword) { - lhsTypeStr = rhsTypeStr.replace(elem.getText(), 'boolean'); - } - }); + const possibleLhsTypeStr = this.checkLhsTypeString(node, rhsTypeStr); + if (possibleLhsTypeStr) { + lhsTypeStr = possibleLhsTypeStr; } + if (lhsTypeStr !== rhsTypeStr) { this.incrementCounters(node, FaultID.ArrayTypeImmutable); } } + private checkLhsTypeString(node: ts.Node, rhsTypeStr: string): string | undefined { + void this; + if (!ts.isAsExpression(node) || !ts.isArrayLiteralExpression(node.expression)) { + return undefined; + } + let lhsTypeStr: string | undefined; + node.expression.elements.forEach((elem) => { + if (elem.kind === ts.SyntaxKind.FalseKeyword || elem.kind === ts.SyntaxKind.TrueKeyword) { + lhsTypeStr = rhsTypeStr.replace(elem.getText(), 'boolean'); + } + }); + + return lhsTypeStr; + } + + private isSubtypeByBaseTypesList(baseType: ts.Type, actualType: ts.Type): boolean { + if (this.isTypeAssignable(actualType, baseType)) { + return true; + } + const actualBaseTypes = actualType.getBaseTypes() || []; + return actualBaseTypes.some((base) => { + return this.isSubtypeByBaseTypesList(baseType, base); + }); + } + private isNullOrEmptyArray(expr: ts.Expression): boolean { if (ts.isNewExpression(expr)) { const constructorSym = this.tsTypeChecker.getSymbolAtLocation(expr.expression); @@ -7071,17 +7888,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const autofix = this.autofixer?.fixCustomBidirectionalBinding(originalExpr, currentParam, customParam); + const decl = this.tsUtils.getDeclarationNode(currentParam); + if (!decl || !ts.isPropertyDeclaration(decl)) { + return; + } + + const autofix = this.autofixer?.fixCustomBidirectionalBinding(originalExpr, decl.type, currentParam, customParam); this.incrementCounters(firstExpr, FaultID.DoubleExclaBindingNotSupported, autofix); } - private handleDoubleDollar(node: ts.Node): void { + private handleDoubleDollar(node: ts.PropertyAccessExpression): void { if (!this.options.arkts2) { return; } if ( - ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === DOUBLE_DOLLAR_IDENTIFIER + THIS_IDENTIFIER ) { @@ -7202,8 +8023,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.TaggedTemplates); } - private checkFunctionTypeCompatible(lhsTypeNode: ts.TypeNode | undefined, rhsExpr: ts.Expression): void { - if (this.options.arkts2 && lhsTypeNode && this.tsUtils.isIncompatibleFunctionals(lhsTypeNode, rhsExpr)) { + private checkFunctionalTypeCompatibility(lhsType: ts.Type, rhsType: ts.Type, rhsExpr: ts.Expression): void { + if (this.options.arkts2 && !this.tsUtils.areCompatibleFunctionalTypes(lhsType, rhsType)) { this.incrementCounters(rhsExpr, FaultID.IncompationbleFunctionType); } } @@ -7294,9 +8115,65 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } else if (ts.isIdentifier(expr)) { this.fixJsImportExtendsClass(node.parent, expr); } + if (ts.isIdentifier(expr)) { + this.handleNoDeprecatedApi(expr); + } }); this.handleMissingSuperCallInExtendedClass(node); + this.handleFieldTypesMatchingBetweenDerivedAndBaseClass(node); + this.checkReadonlyOverridesFromBase(node); + } + } + + private checkReadonlyOverridesFromBase(node: ts.HeritageClause): void { + if (!this.options.arkts2) { + return; + } + if (node.token !== ts.SyntaxKind.ExtendsKeyword) { + return; + } + const childClass = node.parent; + const baseTypeNode = node.types[0]; + if (!ts.isClassDeclaration(childClass) || !baseTypeNode) { + return; + } + const baseType = this.tsTypeChecker.getTypeAtLocation(baseTypeNode); + if (!baseType) { + return; + } + const baseProps = baseType.getProperties(); + this.validateReadonlyOverrides(childClass, baseProps); + } + + private validateReadonlyOverrides(childClass: ts.ClassDeclaration, baseProps: ts.Symbol[]): void { + for (const member of childClass.members) { + if (!ts.isPropertyDeclaration(member) || !member.name) { + continue; + } + const isDerivedReadonly = TsUtils.hasModifier(member.modifiers, ts.SyntaxKind.ReadonlyKeyword); + if (!isDerivedReadonly) { + continue; + } + const memberName = ts.isIdentifier(member.name) ? member.name.text : undefined; + if (!memberName) { + continue; + } + const baseProp = baseProps.find((p) => { + return p.name === memberName; + }); + if (!baseProp) { + continue; + } + + const baseDecl = baseProp.valueDeclaration; + if (!baseDecl || !ts.isPropertyDeclaration(baseDecl)) { + continue; + } + const isBaseReadonly = TsUtils.hasModifier(baseDecl.modifiers, ts.SyntaxKind.ReadonlyKeyword); + if (!isBaseReadonly) { + this.incrementCounters(member, FaultID.NoClassSuperPropReadonly); + } } } @@ -7392,29 +8269,62 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkCollectionsSymbol(symbol: ts.Symbol, node: ts.Node): void { + private checkCollectionsForPropAccess(node: ts.Node, ident: ts.Node): void { + if (!ts.isIdentifier(ident)) { + return; + } + const importBitVectorAutofix = this.checkBitVector(ident); + const replace = this.autofixer?.replaceNode(node, ident.getText()); + let autofix: Autofix[] | undefined = []; + + if (replace) { + autofix = replace; + } + + if (importBitVectorAutofix) { + autofix.push(importBitVectorAutofix); + } + + if (autofix.length === 0) { + autofix = undefined; + } + + this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + } + + private checkCollectionsSymbol(node: ts.Node): void { + if (!this.options.arkts2) { + return; + } + const cb = (): void => { const parent = node.parent; if (!parent) { return; } + if (ts.isPropertyAccessExpression(parent)) { - const autofix = this.autofixer?.replaceNode(parent, parent.name.text); - this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + this.checkCollectionsForPropAccess(parent, parent.name); + + return; } if (ts.isQualifiedName(parent)) { - const autofix = this.autofixer?.replaceNode(parent, parent.right.text); - this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + this.checkCollectionsForPropAccess(parent, parent.right); + + return; } if (ts.isImportSpecifier(parent) && ts.isIdentifier(node)) { + if (parent.propertyName && node.text === parent.propertyName.text) { + return; + } const autofix = this.autofixer?.removeImport(node, parent); this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); } }; - this.checkSymbolAndExecute(symbol, COLLECTIONS_TEXT, COLLECTIONS_MODULES, cb); + this.checkNodeForUsage(node, COLLECTIONS_TEXT, COLLECTIONS_MODULES, cb); } private checkWorkerSymbol(symbol: ts.Symbol, node: ts.Node): void { @@ -7432,7 +8342,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } if (parent.name.text === ARKTSUTILS_LOCKS_MEMBER) { - this.incrementCounters(node, FaultID.LimitedStdLibNoImportConcurrency); + const autofix = this.autofixer?.fixConcurrencyLock(parent); + this.incrementCounters(node, FaultID.LimitedStdLibNoImportConcurrency, autofix); } }; @@ -7445,6 +8356,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const decl = TsUtils.getDeclaration(symbol); if (!decl) { + cb(); return; } @@ -7460,6 +8372,77 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private checkNodeForUsage(node: ts.Node, symbolName: string, modules: string[], cb: () => void): void { + const symbol = this.tsUtils.trueSymbolAtLocation(node); + if (symbol) { + this.checkSymbolAndExecute(symbol, symbolName, modules, cb); + + return; + } + + if (node.getText() === symbolName) { + cb(); + } + } + + private checkBitVector(ident: ts.Identifier): Autofix | undefined { + if (!this.isBitVector(ident)) { + return undefined; + } + + let lastImportDeclaration: ts.Node | undefined; + let bitVectorImported: boolean = false; + for (const node of this.sourceFile.statements) { + if (!ts.isImportDeclaration(node)) { + continue; + } + lastImportDeclaration = node; + + if (this.checkImportDeclarationForBitVector(node)) { + bitVectorImported = true; + } + } + + if (bitVectorImported) { + return undefined; + } + + return this.autofixer?.importBitVector(ident, lastImportDeclaration); + } + + private isBitVector(ident: ts.Identifier): boolean { + void this; + + return ident.text === BIT_VECTOR; + } + + private checkImportDeclarationForBitVector(node: ts.ImportDeclaration): boolean { + const importSpecifier = node.moduleSpecifier; + if (!ts.isStringLiteral(importSpecifier)) { + return false; + } + const importSpecifierText = importSpecifier.text; + + const importClause = node.importClause; + if (!importClause) { + return false; + } + + const namedBindings = importClause.namedBindings; + if (!namedBindings || !ts.isNamedImports(namedBindings)) { + return false; + } + + let bitVectorImported = false; + for (const specifier of namedBindings.elements) { + if (this.isBitVector(specifier.name) && importSpecifierText === ARKTS_COLLECTIONS_MODULE) { + bitVectorImported = true; + } + } + + return bitVectorImported; + } + interfacesNeedToAlarm: ts.Identifier[] = []; interfacesNeedToImport: Set = new Set(); interfacesAlreadyImported: Set = new Set(); @@ -9007,19 +9990,49 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private isApplicationContext(node: ts.CallExpression): boolean { - void this; - const left = (node.expression as ts.PropertyAccessExpression).expression; - return ts.isIdentifier(left) && left.text === 'applicationContext'; - } - - private handleForOfJsArray(node: ts.ForOfStatement): void { - if (!this.options.arkts2 || !this.useStatic) { - return; + const expr = node.expression as ts.PropertyAccessExpression; + if (!ts.isIdentifier(expr.expression)) { + return false; } + const type = this.tsTypeChecker.getTypeAtLocation(expr.expression); + const symbol = type.getSymbol(); + return symbol ? this.checkApplicationContextSymbol(symbol) : false; + } - const expr = node.expression; - if (!ts.isIdentifier(expr) || !this.tsUtils.isPossiblyImportedFromJS(expr)) { - return; + private checkApplicationContextSymbol(symbol: ts.Symbol): boolean { + void this; + if (symbol.getName() === 'default') { + const declarations = symbol.getDeclarations() || []; + for (const decl of declarations) { + if ( + ts.isClassDeclaration(decl) && + decl.name?.getText() === ABILITY_LIFECYCLE_SDK && + decl.getSourceFile().fileName.endsWith(`${ABILITY_LIFECYCLE_SDK}${EXTNAME_D_TS}`) + ) { + return true; + } + } + return false; + } + const symbolName = symbol.getName(); + const hasValidName = symbolName === ABILITY_LIFECYCLE_SDK; + if (hasValidName) { + const declarations = symbol.getDeclarations() || []; + return declarations.some((decl) => { + return decl.getSourceFile().fileName.endsWith(`${ABILITY_LIFECYCLE_SDK}${EXTNAME_D_TS}`); + }); + } + return false; + } + + private handleForOfJsArray(node: ts.ForOfStatement): void { + if (!this.options.arkts2 || !this.useStatic) { + return; + } + + const expr = node.expression; + if (!ts.isIdentifier(expr) || !this.tsUtils.isPossiblyImportedFromJS(expr)) { + return; } const exprType = this.tsTypeChecker.getTypeAtLocation(expr); @@ -9028,7 +10041,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - this.incrementCounters(node, FaultID.InteropJsObjectTraverseJsInstance); + const autofix = this.autofixer?.applyForOfJsArrayFix(node); + this.incrementCounters(node, FaultID.InteropJsObjectTraverseJsInstance, autofix); } private checkStdLibConcurrencyImport(importDeclaration: ts.ImportDeclaration): void { @@ -9073,6 +10087,126 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + /** + * Checks that each field in a subclass matches the type of the same-named field + * in its base class. If the subclass field's type is not assignable to the + * base class field type, emit a diagnostic. + */ + private handleFieldTypesMatchingBetweenDerivedAndBaseClass(node: ts.HeritageClause): void { + // Only process "extends" clauses + if (node.token !== ts.SyntaxKind.ExtendsKeyword) { + return; + } + const derivedClass = node.parent; + if (!ts.isClassDeclaration(derivedClass)) { + return; + } + + // Locate the base class declaration + const baseExpr = node.types[0]?.expression; + if (!ts.isIdentifier(baseExpr)) { + return; + } + const baseSym = this.tsUtils.trueSymbolAtLocation(baseExpr); + const baseClassDecl = baseSym?.declarations?.find(ts.isClassDeclaration); + if (!baseClassDecl) { + return; + } + + // Compare each property in the derived class against the base class + for (const member of derivedClass.members) { + if (!ts.isPropertyDeclaration(member) || !ts.isIdentifier(member.name) || !member.type) { + continue; + } + const propName = member.name.text; + // Find the first declaration of this property in the base-class chain + const baseProp = this.findPropertyDeclarationInBaseChain(baseClassDecl, propName); + if (!baseProp) { + continue; + } + + // Get the types + const derivedType = this.tsTypeChecker.getTypeAtLocation(member.type); + const baseType = this.tsTypeChecker.getTypeAtLocation(baseProp.type!); + + // If the derived type is not assignable to the base type, report + if (!this.isFieldTypeMatchingBetweenDerivedAndBaseClass(derivedType, baseType)) { + this.incrementCounters(member.name, FaultID.FieldTypeMismatch); + } + } + } + + /** + * Returns true if the union type members of subclass field's type + * exactly match those of the base class field's type (order-insensitive). + * So `number|string` ↔ `string|number` passes, but `number` ↔ `number|string` fails. + */ + private isFieldTypeMatchingBetweenDerivedAndBaseClass(derivedType: ts.Type, baseType: ts.Type): boolean { + // Split union type strings into trimmed member names + const derivedNames = this.tsTypeChecker. + typeToString(derivedType). + split('|'). + map((s) => { + return s.trim(); + }); + const baseNames = this.tsTypeChecker. + typeToString(baseType). + split('|'). + map((s) => { + return s.trim(); + }); + + // Only match if both unions contain exactly the same members + if (derivedNames.length !== baseNames.length) { + return false; + } + return ( + derivedNames.every((name) => { + return baseNames.includes(name); + }) && + baseNames.every((name) => { + return derivedNames.includes(name); + }) + ); + } + + /** + * Recursively searches base classes to find a property declaration + * with the given name and a type annotation. + */ + private findPropertyDeclarationInBaseChain( + classDecl: ts.ClassDeclaration, + propName: string + ): ts.PropertyDeclaration | undefined { + let current: ts.ClassDeclaration | undefined = classDecl; + while (current) { + // Look for the property in this class + const member = current.members.find((m) => { + return ts.isPropertyDeclaration(m) && ts.isIdentifier(m.name) && m.name.text === propName && !!m.type; + }) as ts.PropertyDeclaration | undefined; + if (member) { + return member; + } + + // Move to the next base class if it exists + const extendsClause = current.heritageClauses?.find((c) => { + return c.token === ts.SyntaxKind.ExtendsKeyword; + }); + if (!extendsClause) { + break; + } + const baseExpr = extendsClause.types[0]?.expression; + if (!ts.isIdentifier(baseExpr)) { + break; + } + + const sym = this.tsUtils.trueSymbolAtLocation(baseExpr); + const decl = sym?.declarations?.find(ts.isClassDeclaration); + current = decl; + } + return undefined; + } + /** * Checks for missing super() call in child classes that extend a parent class * with parameterized constructors. If parent class only has parameterized constructors @@ -9141,21 +10275,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { for (const [idx, param] of ctorParams.entries()) { const argument = superCall.arguments[idx]; - if (!param.isOptional && !argument) { - matches[idx] = false; + if (!this.checkParameter(param, argument, matches, idx)) { continue outer; } - - if (!argument && param.isOptional) { - matches[idx] = true; - continue; - } - if (argument !== undefined) { - matches[idx] = this.checkIfArgumentAndParamMatches(param, argument); - if (!matches[idx]) { - continue outer; - } - } } if ( @@ -9171,6 +10293,51 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(classDecl, FaultID.MissingSuperCall); } + private checkParameter( + param: ConstructorParameter, + argument: ts.Expression | undefined, + matches: boolean[], + idx: number + ): boolean { + if (!param.isOptional && !argument) { + matches[idx] = false; + return false; + } + + if (!argument && param.isOptional) { + matches[idx] = true; + return true; + } + + if (argument !== undefined) { + if (this.isEnumArgument(argument)) { + matches[idx] = true; + return true; + } + matches[idx] = this.checkIfArgumentAndParamMatches(param, argument); + return matches[idx]; + } + return true; + } + + private isEnumArgument(argument: ts.Expression): boolean { + if (!ts.isPropertyAccessExpression(argument)) { + return false; + } + + const leftSide = argument.expression; + const symbol = this.tsTypeChecker?.getSymbolAtLocation(leftSide); + + return ( + symbol?.declarations?.some((decl) => { + return ( + ts.isEnumDeclaration(decl) || + ts.isVariableDeclaration(decl) && decl.initializer && ts.isEnumDeclaration(decl.initializer) + ); + }) ?? false + ); + } + private checkIfArgumentAndParamMatches(param: ConstructorParameter, argument: ts.Expression): boolean { const typeNode = this.tsTypeChecker.getTypeAtLocation(argument); const typeString = this.tsTypeChecker.typeToString(typeNode); @@ -9360,27 +10527,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const symbolToUse = defaultSymbol || symbol; if (symbolToUse) { - this.tryAutoFixInterOpImportJs(importDecl, importClause, symbolToUse, defaultSymbol); + this.tryAutoFixInterOpImportJs(importDecl, symbolToUse); } } - private tryAutoFixInterOpImportJs( - importDecl: ts.ImportDeclaration, - importClause: ts.ImportClause, - symbolToUse: ts.Symbol, - defaultSymbol?: ts.Symbol - ): void { + private tryAutoFixInterOpImportJs(importDecl: ts.ImportDeclaration, symbolToUse: ts.Symbol): void { const declaration = symbolToUse.declarations?.[0]; if (declaration) { const sourceFile = declaration.getSourceFile(); if (sourceFile.fileName.endsWith(EXTNAME_JS)) { - const autofix = this.autofixer?.fixInterOpImportJs( - importDecl, - importClause, - TsUtils.removeOrReplaceQuotes(importDecl.moduleSpecifier.getText(this.sourceFile), false), - defaultSymbol - ); - this.incrementCounters(importDecl, FaultID.InterOpImportJs, autofix); + this.incrementCounters(importDecl, FaultID.InterOpImportJs); } } } @@ -9473,7 +10629,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } for (const declaration of symbol.declarations ?? []) { - if (!this.tsUtils.isArkts12File(declaration.getSourceFile())) { + if (!this.tsUtils.isArkts12File(declaration.getSourceFile()) && !isStdLibrarySymbol(symbol)) { return true; } } @@ -9868,9 +11024,32 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (ts.isStringLiteral(indexExpr) || ts.isNumericLiteral(indexExpr)) { return true; } - const type = this.tsTypeChecker.getTypeAtLocation(indexExpr); - const typeString = this.tsTypeChecker.typeToString(type); - return typeString === 'number' || typeString === 'string'; + const indexType = this.tsTypeChecker.getTypeAtLocation(indexExpr); + const typeString = this.tsTypeChecker.typeToString(indexType); + if (typeString === 'number' || typeString === 'string') { + return true; + } + const baseExprSym = this.tsUtils.trueSymbolAtLocation(node.expression); + if (indexType.isUnion()) { + return indexType.types.some((t) => { + return this.isInvalidEnumMemberType(t, baseExprSym); + }); + } + return this.isInvalidEnumMemberType(indexType, baseExprSym); + } + + private isInvalidEnumMemberType(indexType: ts.Type, baseExprSym: ts.Symbol | undefined): boolean { + const indexSym = indexType.getSymbol(); + if (!indexSym) { + return false; + } + return !indexSym.declarations?.some((decl) => { + if (decl && ts.isEnumDeclaration(decl.parent) && ts.isEnumMember(decl)) { + const enumDeclSym = this.tsUtils.trueSymbolAtLocation(decl.parent.name); + return enumDeclSym === baseExprSym; + } + return false; + }); } private handleMakeObserved(node: ts.PropertyAccessExpression): void { @@ -9899,7 +11078,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isStringLiteral(moduleSpecifier)) { return; } - if (moduleSpecifier.text !== ARKUI_PACKAGE_NAME && moduleSpecifier.text !== ARKUI_STATE_MANAGEMENT) { + if (moduleSpecifier.text !== ARKUI_MODULE && moduleSpecifier.text !== STATE_MANAGEMENT_MODULE) { return; } @@ -9911,23 +11090,24 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const decorators = ts.getDecorators(node); - if (!decorators || decorators.length === 0) { + const decorator = ts.getDecorators(node)?.[0]; + if (!decorator) { return; } - let decoratorName: string | undefined; - if (ts.isIdentifier(decorators[0].expression)) { - decoratorName = decorators[0].expression.getText(); - } else if (ts.isCallExpression(decorators[0].expression) && ts.isIdentifier(decorators[0].expression.expression)) { - decoratorName = decorators[0].expression.expression.getText(); + let identifier: ts.Identifier | undefined; + if (ts.isIdentifier(decorator.expression)) { + identifier = decorator.expression; + } else if (ts.isCallExpression(decorator.expression) && ts.isIdentifier(decorator.expression.expression)) { + identifier = decorator.expression.expression; } - if (!decoratorName) { + if (!identifier) { return; } - const autofix = this.autofixer?.fixPropDecorator(decorators[0], decoratorName); + const decoratorName = identifier.getText(); + const autofix = this.autofixer?.fixPropDecorator(identifier, decoratorName); switch (decoratorName) { case PropDecoratorName.Prop: this.incrementCounters(node, FaultID.PropDecoratorNotSupported, autofix); @@ -10155,6 +11335,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2) { return; } + + if (ts.isIdentifier(tsCallExpr.expression)) { + const funcName = tsCallExpr.expression.text; + if (funcName === 'setTimeout') { + return; + } + } + const isContinue = ts.isCallExpression(tsCallExpr) && ts.isIdentifier(tsCallExpr.expression) && @@ -10177,26 +11365,30 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const expectedType = parameterTypes[index]; let expectedUnionType: string[] = []; if (expectedType.includes('|')) { - expectedUnionType = expectedType.split('|').map((item) => { - return item.trim(); + expectedUnionType = expectedType.split('|').map((item) => { + return item.trim(); }); } - const actualSym = this.tsTypeChecker.getSymbolAtLocation(arg); - const decl = TsUtils.getDeclaration(actualSym); - if (decl && ts.isParameter(decl) && decl.type) { - const actualType = this.tsTypeChecker.getTypeFromTypeNode(decl.type); - const actualTypeName = this.tsTypeChecker.typeToString(actualType); - if (expectedUnionType.length > 0) { - if (!expectedUnionType.includes(actualTypeName)) { - this.incrementCounters(arg, FaultID.NoTsLikeSmartType); - } - return; - } - if (actualTypeName !== expectedType) { + this.checkParameterTypeCompatibility(arg, expectedUnionType, expectedType); + }); + } + + private checkParameterTypeCompatibility(arg: ts.Expression, expectedUnionType: string[], expectedType: string): void { + const actualSym = this.tsTypeChecker.getSymbolAtLocation(arg); + const decl = TsUtils.getDeclaration(actualSym); + if (decl && ts.isParameter(decl) && decl.type) { + const actualType = this.tsTypeChecker.getTypeFromTypeNode(decl.type); + const actualTypeName = this.tsTypeChecker.typeToString(actualType); + if (expectedUnionType.length > 0) { + if (!expectedUnionType.includes(actualTypeName)) { this.incrementCounters(arg, FaultID.NoTsLikeSmartType); } + return; } - }); + if (actualTypeName !== expectedType) { + this.incrementCounters(arg, FaultID.NoTsLikeSmartType); + } + } } private handleNotsLikeSmartTypeOnAsExpression(tsAsExpr: ts.AsExpression): void { @@ -10302,23 +11494,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { staticProps: Map, instanceProps: Map ): void { - body.forEachChild((node) => { + forEachNodeInSubtree(body, (node) => { if (!ts.isReturnStatement(node) || !node.expression) { return; } + const getPropertyAccess = (expr: ts.Expression): ts.PropertyAccessExpression | undefined => { + if (ts.isPropertyAccessExpression(expr)) { + return expr; + } - const isStaticPropertyAccess = (node: ts.Expression, className: string): boolean => { - return ( - ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === className - ); + if (ts.isCallExpression(expr) && ts.isPropertyAccessExpression(expr.expression)) { + return expr.expression; + } + + return undefined; + }; + + const isStaticPropertyAccess = (expr: ts.PropertyAccessExpression, className: string): boolean => { + return ts.isIdentifier(expr.expression) && expr.expression.text === className; }; + const isInstancePropertyAccess = (node: ts.Expression): boolean => { return ts.isPropertyAccessExpression(node) && node.expression.kind === ts.SyntaxKind.ThisKeyword; }; - if (className && isStaticPropertyAccess(node.expression, className)) { - this.checkPropertyAccess(node, node.expression as ts.PropertyAccessExpression, staticProps, methodReturnType); - return; + const propExp = getPropertyAccess(node.expression); + if (className && propExp && isStaticPropertyAccess(propExp, className)) { + this.checkPropertyAccess(node, propExp, staticProps, methodReturnType); } if (isInstancePropertyAccess(node.expression)) { @@ -10376,11 +11578,34 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private isExactlySameType(type1: ts.Type, type2: ts.Type): boolean { if (type2.getCallSignatures().length > 0) { const returnType = TsUtils.getFunctionReturnType(type2); - return returnType ? - this.tsTypeChecker.typeToString(type1) === this.tsTypeChecker.typeToString(returnType) : - false; + return returnType ? this.isExactlySameType(type1, returnType) : false; } - return this.tsTypeChecker.typeToString(type1) === this.tsTypeChecker.typeToString(type2); + + const type1String = this.tsTypeChecker.typeToString(type1); + const type2String = this.tsTypeChecker.typeToString(type2); + if (type1String === type2String) { + return true; + } + + if (this.checkBaseTypes(type1, type2) || this.checkBaseTypes(type2, type1)) { + return true; + } + return type1String === type2String; + } + + private checkBaseTypes(type1: ts.Type, type2: ts.Type): boolean { + const isClassType = + (type1.getFlags() & ts.TypeFlags.Object) !== 0 && + ((type1 as ts.ObjectType).objectFlags & ts.ObjectFlags.Class) !== 0; + if (isClassType) { + const baseTypes = (type1 as any).getBaseTypes?.() || []; + for (const baseType of baseTypes) { + if (this.isExactlySameType(baseType, type2)) { + return true; + } + } + } + return false; } private handleNumericBigintCompare(node: ts.BinaryExpression): void { @@ -10984,12 +12209,26 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return ts.isCallExpression(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node); } + private isConcatArray(accessedNode: ts.Node): boolean { + if (!ts.isIdentifier(accessedNode)) { + return false; + } + const decl = this.tsUtils.getDeclarationNode(accessedNode); + if (!decl) { + return false; + } + + const type = this.tsTypeChecker.getTypeAtLocation(decl); + return TsUtils.isConcatArrayType(type); + } + private getArrayAccessInfo(expr: ts.ElementAccessExpression): false | ArrayAccess { if (!ts.isIdentifier(expr.expression)) { return false; } const baseType = this.tsTypeChecker.getTypeAtLocation(expr.expression); - if (!this.tsUtils.isArray(baseType)) { + + if (!this.tsUtils.isArray(baseType) && !this.isConcatArray(expr.expression)) { return false; } const accessArgument = expr.argumentExpression; @@ -11005,9 +12244,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return ( (argType.flags & ts.TypeFlags.NumberLike) !== 0 || argType.isUnionOrIntersection() && - argType.types.some((t) => { - return t.flags & ts.TypeFlags.NumberLike; - }) + argType.types.some((t) => { + return t.flags & ts.TypeFlags.NumberLike; + }) ); }; @@ -11269,7 +12508,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - const ifStatement = accessExpr.parent.parent.parent as ts.IfStatement; + const ifStatement = accessExpr.parent.parent.parent; if (!ts.isBinaryExpression(ifStatement.expression)) { return false; @@ -11484,8 +12723,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { parent = parent.parent; } if (!parent) { - return false - }; + return false; + } const forStmt = parent; @@ -11494,12 +12733,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const condition = forStmt.condition; - const isStandardLoop = ( + const isStandardLoop = (condition.operatorToken.kind === ts.SyntaxKind.LessThanToken || condition.operatorToken.kind === ts.SyntaxKind.LessThanEqualsToken) && ts.isPropertyAccessExpression(condition.right) && - condition.right.name.text === LENGTH_IDENTIFIER - ); + condition.right.name.text === LENGTH_IDENTIFIER; if (!isStandardLoop) { return false; @@ -11526,9 +12764,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } + private checkArrayModifications(node: ts.Node, arrayName: string): boolean { let hasModification = false; - ts.forEachChild(node, child => { + ts.forEachChild(node, (child) => { if (TypeScriptLinter.isArrayModification(child, arrayName)) { hasModification = true; } @@ -11541,11 +12780,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private checkIndexModifications(node: ts.Node, indexVar: string): boolean { let hasModification = false; - ts.forEachChild(node, child => { - if (ts.isBinaryExpression(child) && + ts.forEachChild(node, (child) => { + if ( + ts.isBinaryExpression(child) && child.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isIdentifier(child.left) && - child.left.text === indexVar) { + child.left.text === indexVar + ) { hasModification = true; } if (!hasModification) { @@ -11557,11 +12798,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private checkOutOfBoundAccess(node: ts.Node, arrayName: string): boolean { let hasOutOfBound = false; - ts.forEachChild(node, child => { - if (ts.isElementAccessExpression(child) && + ts.forEachChild(node, (child) => { + if ( + ts.isElementAccessExpression(child) && ts.isIdentifier(child.expression) && child.expression.text === arrayName && - ts.isNumericLiteral(child.argumentExpression)) { + ts.isNumericLiteral(child.argumentExpression) + ) { hasOutOfBound = true; } if (!hasOutOfBound) { @@ -11570,6 +12813,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); return hasOutOfBound; } + private handleCallExpressionForRepeat(node: ts.CallExpression): void { if (!this.options.arkts2) { return; @@ -11591,4 +12835,652 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const autofix = this.autofixer?.fixRepeat(stmt); this.incrementCounters(node, FaultID.RepeatDisableVirtualScroll, autofix); } + + private handleNodeForWrappedBuilder(node: ts.TypeReferenceNode | ts.NewExpression | ts.CallExpression): void { + if (!this.options.arkts2) { + return; + } + + const identifier = ts.isTypeReferenceNode(node) ? node.typeName : node.expression; + if (this.isDeclarationInSameFile(identifier)) { + return; + } + + switch (identifier.getText()) { + case CustomInterfaceName.WrappedBuilder: + this.incrementCounters(node, FaultID.WrappedBuilderGenericNeedArrowFunc); + break; + case CustomInterfaceName.wrapBuilder: { + const args = node.typeArguments; + if (args && args.length > 0 && ts.isTupleTypeNode(args[0])) { + this.incrementCounters(node, FaultID.WrapBuilderGenericNeedArrowFunc); + } + break; + } + default: + } + } + + private checkImportJsonFile(node: ts.ImportDeclaration): void { + if (!this.options.arkts2) { + return; + } + + const moduleSpecifier = node.moduleSpecifier; + + if (!ts.isStringLiteral(moduleSpecifier)) { + return; + } + + const importPath = moduleSpecifier.text; + + if (importPath.endsWith(EXTNAME_JSON)) { + this.incrementCounters(moduleSpecifier, FaultID.NoImportJsonFile); + } + } + + private handleNoDeprecatedApi( + node: + | ts.TypeReferenceNode + | ts.NewExpression + | ts.VariableDeclaration + | ts.PropertyDeclaration + | ts.ParameterDeclaration + | ts.CallExpression + | ts.BinaryExpression + | ts.ExpressionWithTypeArguments + | ts.Identifier + | ts.MethodDeclaration + | ts.PropertyAssignment + | ts.PropertyAccessExpression + ): void { + if (!this.options.arkts2) { + return; + } + switch (node.kind) { + case ts.SyntaxKind.TypeReference: + this.checkTypeReferenceForDeprecatedApi(node); + break; + case ts.SyntaxKind.Identifier: + this.checkHeritageClauseForDeprecatedApi(node); + break; + case ts.SyntaxKind.PropertyDeclaration: + this.checkPropertyDeclarationForDeprecatedApi(node); + break; + case ts.SyntaxKind.Parameter: + case ts.SyntaxKind.VariableDeclaration: + this.checkDeclarationForDeprecatedApi(node); + break; + case ts.SyntaxKind.MethodDeclaration: + this.checkMethodDeclarationForDeprecatedApi(node); + break; + case ts.SyntaxKind.PropertyAssignment: + this.checkPropertyAssignmentForDeprecatedApi(node); + break; + case ts.SyntaxKind.NewExpression: + case ts.SyntaxKind.CallExpression: + case ts.SyntaxKind.BinaryExpression: + case ts.SyntaxKind.PropertyAccessExpression: + this.handleNoDeprecatedApiForExpression(node); + break; + default: + } + } + + handleNoDeprecatedApiForExpression( + node: ts.NewExpression | ts.CallExpression | ts.BinaryExpression | ts.PropertyAccessExpression + ): void { + switch (node.kind) { + case ts.SyntaxKind.NewExpression: + this.checkNewExpressionForDeprecatedApi(node); + break; + case ts.SyntaxKind.CallExpression: + this.checkCallExpressionForDeprecatedApi(node); + break; + case ts.SyntaxKind.BinaryExpression: + this.checkBinaryExpressionForDeprecatedApi(node); + break; + case ts.SyntaxKind.PropertyAccessExpression: + this.checkPropertyAccessExpressionForDeprecatedApi(node); + break; + default: + } + } + + private checkTypeReferenceForDeprecatedApi(node: ts.TypeReferenceNode): void { + let typeName = node.typeName; + if (ts.isQualifiedName(node.typeName)) { + typeName = node.typeName.right; + } + const decl = this.tsUtils.getDeclarationNode(typeName); + if (decl && (ts.isInterfaceDeclaration(decl) || ts.isClassDeclaration(decl))) { + let parentName = decl.name ? decl.name.text : 'unnamed'; + if (ts.isQualifiedName(node.typeName)) { + parentName = node.typeName.getText(); + } + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + parentName, + undefined, + undefined, + path.basename(decl.getSourceFile().fileName + '') + ); + this.processApiNodeDeprecatedApi(typeName.getText(), typeName, deprecatedApiCheckMap); + } + } + + private checkNewExpressionForDeprecatedApi(node: ts.NewExpression): void { + const expression = node.expression; + if (ts.isIdentifier(expression)) { + const decl = this.tsUtils.getDeclarationNode(expression); + if (decl && ts.isClassDeclaration(decl)) { + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + decl.name?.text + '', + undefined, + undefined, + path.basename(decl.getSourceFile().fileName + '') + ); + this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap); + } + } + } + + private checkHeritageClauseForDeprecatedApi(node: ts.Identifier): void { + const decl = this.tsUtils.getDeclarationNode(node); + if (decl && ts.isInterfaceDeclaration(decl)) { + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + decl.name.text, + undefined, + undefined, + path.basename(decl.getSourceFile().fileName + '') + ); + this.processApiNodeDeprecatedApi(node.getText(), node, deprecatedApiCheckMap); + } + } + + private checkDeclarationForDeprecatedApi( + node: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration + ): void { + const expression = node.initializer; + const getParaExcute = (expression: ts.Expression): void => { + if (expression && ts.isIdentifier(expression)) { + const funSymbol = this.tsUtils.trueSymbolAtLocation(expression); + const decl = TsUtils.getDeclaration(funSymbol); + const parName = this.tsUtils.getParentSymbolName(funSymbol); + if (decl && (ts.isFunctionLike(decl) || ts.isVariableDeclaration(decl))) { + const returnType = decl.type?.getText(); + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + parName === undefined ? DEPRECATE_UNNAMED : parName + '', + undefined, + returnType, + path.basename(decl.getSourceFile().fileName) + ); + this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap); + } + } + }; + + if (expression && ts.isIdentifier(expression)) { + getParaExcute(expression); + } else if (expression && ts.isObjectLiteralExpression(expression)) { + const properties = expression.properties; + for (const prop of properties) { + const propExpression = ts.isPropertyAssignment(prop) && prop.initializer; + if (propExpression && ts.isIdentifier(propExpression)) { + getParaExcute(propExpression); + } + } + } + } + + private checkCallExpressionForDeprecatedApi(node: ts.CallExpression): void { + let name: ts.Identifier | undefined; + if (ts.isIdentifier(node.expression)) { + name = node.expression; + } else if (ts.isPropertyAccessExpression(node.expression)) { + name = ts.isIdentifier(node.expression.name) ? node.expression.name : undefined; + } + if (!name) { + return; + } + let funSymbol = this.tsUtils.trueSymbolAtLocation(name); + if (!funSymbol && ts.isPropertyAccessExpression(node.expression)) { + funSymbol = this.tsTypeChecker.getSymbolAtLocation(node.expression.expression); + } + const decl = TsUtils.getDeclaration(funSymbol); + const parName = this.tsUtils.getParentSymbolName(funSymbol); + if (decl && (ts.isFunctionLike(decl) || ts.isVariableDeclaration(decl))) { + const returnType = decl.type?.getText() === undefined ? 'any' : decl.type?.getText() + ''; + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + parName === undefined ? DEPRECATE_UNNAMED : parName + '', + ts.isFunctionLike(decl) ? decl.parameters : undefined, + returnType, + path.basename(decl.getSourceFile().fileName) + ); + this.reportDeprecatedApi(node, name, deprecatedApiCheckMap); + } + this.checkSpecialApiForDeprecatedApi(node, name, decl); + } + + private reportDeprecatedApi( + node: ts.CallExpression, + name: ts.Identifier, + deprecatedApiCheckMap?: Map> + ): void { + const isMatched = this.isMatchedDeprecatedApi(name.text, deprecatedApiCheckMap); + if (isMatched) { + const autofix = this.autofixer?.fixDeprecatedApiForCallExpression(node); + if (autofix) { + this.interfacesNeedToImport.add('getUIContext'); + } + this.incrementCounters(name, FaultID.NoDeprecatedApi, autofix); + } + } + + private checkSpecialApiForDeprecatedApi( + node: ts.CallExpression, + name: ts.Identifier, + decl: ts.Declaration | undefined + ): void { + if (('mask' === name.getText() || 'clip' === name.getText()) && node.arguments.length === 1) { + const types = ['CircleAttribute', 'EllipseAttribute', ' PathAttribute', 'RectAttribute']; + const arg = node.arguments[0]; + const argType = this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(arg)); + if (types.includes(argType)) { + if (name.getText() === 'clip') { + const typeMapping = { + CircleAttribute: 'CircleShape', + EllipseAttribute: 'EllipseShape', + PathAttribute: 'PathShape', + RectAttribute: 'RectShape' + } as const; + + if (argType in typeMapping) { + this.interfacesNeedToImport.add(typeMapping[argType as keyof typeof typeMapping]); + } + + const autofix = this.autofixer?.fixSpecialDeprecatedApiForCallExpression(node, name); + this.incrementCounters(name, FaultID.NoDeprecatedApi, autofix); + return; + } + this.incrementCounters(name, FaultID.NoDeprecatedApi); + return; + } + } + if (decl?.parent && ts.isClassDeclaration(decl.parent) && 'onScroll' === name.getText()) { + let parentName = ''; + decl.parent.heritageClauses?.forEach((clause) => { + clause.types.forEach((type) => { + if (ts.isExpressionWithTypeArguments(type)) { + parentName = type.expression.getText(); + } + }); + }); + if (parentName === 'ScrollableCommonMethod') { + this.incrementCounters(name, FaultID.NoDeprecatedApi); + } + } + } + + private checkBinaryExpressionForDeprecatedApi(node: ts.BinaryExpression): void { + const expression = node.right; + if (ts.isIdentifier(expression)) { + this.processApiNodeDeprecatedApi(expression.text, expression); + } + } + + private checkMethodDeclarationForDeprecatedApi(node: ts.MethodDeclaration): void { + const expression = node.name; + if (!ts.isIdentifier(expression)) { + return; + } + if ( + (expression.getText() === 'onLayout' || expression.getText() === 'onMeasure') && + node.type?.getText() === 'void' && + node.parent && + ts.isStructDeclaration(node.parent) + ) { + const argsType = ['LayoutChild[]', 'ConstraintSizeOptions']; + const parameters = node.parameters; + if (parameters && parameters.length === 2) { + let paramMatch = true; + for (let i = 0; i < parameters.length; i++) { + if (this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(parameters[i])) !== argsType[i]) { + paramMatch = false; + break; + } + } + if (paramMatch) { + this.incrementCounters(expression, FaultID.NoDeprecatedApi); + return; + } + } + } + this.processApiNodeDeprecatedApi(expression.text, expression); + } + + private checkPropertyAssignmentForDeprecatedApi(node: ts.PropertyAssignment): void { + const expression = node.name; + const contextualType = this.tsTypeChecker.getContextualType(node.parent); + if (contextualType) { + this.processApiNodeDeprecatedApi( + expression.getText(), + expression, + TypeScriptLinter.getPropertyTypeForPropertyAssignment(node, contextualType) + ); + } + } + + private checkPropertyAccessExpressionForDeprecatedApi(node: ts.PropertyAccessExpression): void { + node.forEachChild((expression) => { + if (!ts.isIdentifier(expression)) { + return; + } + const funSymbol = this.tsUtils.trueSymbolAtLocation(expression); + const decl = TsUtils.getDeclaration(funSymbol); + let parName = this.tsUtils.getParentSymbolName(funSymbol); + if ( + decl && + (ts.isPropertyDeclaration(decl) || + ts.isPropertySignature(decl) || + ts.isEnumMember(decl) || + ts.isEnumDeclaration(decl)) && + decl.parent + ) { + let returnType: string | undefined = this.tsTypeChecker.typeToString( + this.tsTypeChecker.getTypeAtLocation(decl) + ); + if (ts.isPropertySignature(decl) && decl.type) { + returnType = decl.type.getText(); + } else if (ts.isEnumMember(decl)) { + returnType = TypeScriptLinter.getReturnTypeForEnumMember(decl); + } else if (!parName && ts.isEnumDeclaration(decl)) { + parName = decl.name.text; + returnType = undefined; + } + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + parName === undefined ? DEPRECATE_UNNAMED : parName + '', + undefined, + returnType, + path.basename(decl.getSourceFile().fileName) + ); + this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap); + } + }); + } + + private checkPropertyDeclarationForDeprecatedApi(node: ts.PropertyDeclaration): void { + const expression = node.name; + if (ts.isIdentifier(expression)) { + this.processApiNodeDeprecatedApi(expression.text, expression); + } + } + + private processApiNodeDeprecatedApi( + apiName: string, + errorNode: ts.Node, + deprecatedApiCheckMap?: Map>, + autofix?: Autofix[] + ): void { + const matchedApi = this.isMatchedDeprecatedApi(apiName, deprecatedApiCheckMap); + if (matchedApi) { + this.incrementCounters(errorNode, FaultID.NoDeprecatedApi, autofix); + } + } + + private isMatchedDeprecatedApi( + apiName: string, + deprecatedApiCheckMap?: Map> + ): boolean { + void this; + const setApiListItem = TypeScriptLinter.deprecatedApiInfo; + if (!setApiListItem || !deprecatedApiCheckMap) { + return false; + } + const apiNamesArr = [...setApiListItem]; + const matchedApi = apiNamesArr.some((apiInfoItem) => { + if (apiInfoItem.api_info.parent_api?.length <= 0) { + return false; + } + let isSameApi = apiInfoItem.api_info.api_name === apiName; + isSameApi &&= + apiInfoItem.api_info.parent_api[0].api_name === deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARENT_NAME); + isSameApi &&= + this.normalizeTypeString(apiInfoItem.api_info.method_return_type) === + this.normalizeTypeString(deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.RETURN_TYPE)); + const api_func_args = apiInfoItem.api_info.api_func_args; + const params = deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARAM_SET); + if (api_func_args && params) { + const isParametersEqual = TypeScriptLinter.areParametersEqualForDeprecated( + api_func_args, + params as ts.NodeArray + ); + isSameApi &&= isParametersEqual; + } + const fileName = deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.FILE_NAME) + ''; + const isSameFile = fileName.endsWith(path.basename(apiInfoItem.file_path)); + return isSameFile && isSameApi; + }); + return matchedApi; + } + + private static getPropertyTypeForPropertyAssignment( + propertyAssignment: ts.PropertyAssignment, + contextualType: ts.Type + ): Map> | undefined { + const propertyName = propertyAssignment.name.getText(); + if (contextualType.isUnion()) { + for (const type of contextualType.types) { + const deprecatedApiCheckMap = TypeScriptLinter.getPropertyInfoByContextualType(type, propertyName); + if (deprecatedApiCheckMap) { + return deprecatedApiCheckMap; + } + } + } + return TypeScriptLinter.getPropertyInfoByContextualType(contextualType, propertyName); + } + + private static getPropertyInfoByContextualType( + type: ts.Type, + propertyName: string + ): Map> | undefined { + const propertySymbol = type.getProperty(propertyName); + if (!propertySymbol) { + return undefined; + } + const propertyDecl = TsUtils.getDeclaration(propertySymbol); + let deprecatedApiCheckMap = new Map>(); + if (propertyDecl && ts.isPropertySignature(propertyDecl) && propertyDecl.type) { + deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + type.getSymbol()?.name + '', + undefined, + propertyDecl.type.getText(), + path.basename(propertyDecl.getSourceFile().fileName + '') + ); + } + return deprecatedApiCheckMap; + } + + private static updateDeprecatedApiCheckMap( + parentName: string, + parames: ts.NodeArray | undefined, + returnType: string | undefined, + fileName: string + ): Map> { + const deprecatedApiCheckMap = new Map>(); + deprecatedApiCheckMap.set(DEPRECATE_CHECK_KEY.PARENT_NAME, parentName); + if (parames) { + deprecatedApiCheckMap.set(DEPRECATE_CHECK_KEY.PARAM_SET, parames); + } + if (returnType) { + deprecatedApiCheckMap.set(DEPRECATE_CHECK_KEY.RETURN_TYPE, returnType); + } + deprecatedApiCheckMap.set(DEPRECATE_CHECK_KEY.FILE_NAME, fileName); + return deprecatedApiCheckMap; + } + + private static getReturnTypeForEnumMember(node: ts.EnumMember): string { + const enumDecl = node.parent; + if (!enumDecl?.members || enumDecl.members.length === 0) { + return ''; + } + for (let i = 0; i < enumDecl.members.length; i++) { + if (enumDecl.members[i].name.getText() === node.name.getText()) { + return i + ''; + } + } + return ''; + } + + private normalizeTypeString( + typeStr: string | ts.NodeArray | undefined + ): string | ts.NodeArray | undefined { + void this; + if (typeof typeStr === 'string') { + return typeStr.replace(/\s+/g, ''); + } + return typeStr; + } + + private static areParametersEqualForDeprecated( + sdkFuncArgs: { name: string; type: string }[], + memberParams: ts.NodeArray + ): boolean { + const apiParamCout = sdkFuncArgs.length; + const memberParamCout = memberParams.length; + if (apiParamCout > memberParamCout && sdkFuncArgs[memberParamCout]) { + return false; + } + for (let i = 0; i < apiParamCout; i++) { + const typeName = memberParams[i]?.type?.getText(); + const newtypeName = typeName?.replace(/\s+/g, ''); + const sdkArgName = sdkFuncArgs[i].type.replace(/\s+/g, ''); + if (newtypeName !== sdkArgName) { + return false; + } + } + return true; + } + + private handleNodeForBuilderNode(node: ts.TypeReferenceNode | ts.NewExpression): void { + if (!this.options.arkts2) { + return; + } + + const identifier = ts.isTypeReferenceNode(node) ? node.typeName : node.expression; + if ( + identifier.getText() !== CustomInterfaceName.BuilderNode || + !this.isDeclInTargetFile(identifier, BUILDERNODE_D_TS) + ) { + return; + } + + const firstArg = node.typeArguments?.[0]; + if (firstArg && ts.isTupleTypeNode(firstArg)) { + this.incrementCounters(node, FaultID.BuilderNodeGenericNoTuple); + } + } + + private isDeclInTargetFile(node: ts.Node, targetFile: string): boolean { + const decl = this.tsUtils.getDeclarationNode(node); + const file = decl?.getSourceFile(); + if (file !== undefined) { + const fileName = path.basename(file.fileName); + if (fileName !== targetFile) { + return false; + } + } + + return true; + } + + private handlePropertyAccessExprForBuilderNode(node: ts.PropertyAccessExpression): void { + if (!this.options.arkts2) { + return; + } + + const identifier = node.name; + if (!ts.isIdentifier(identifier) || !this.isDeclInTargetFile(identifier, BUILDERNODE_D_TS)) { + return; + } + + const name = identifier.getText(); + const callExpr = ts.findAncestor(node, ts.isCallExpression); + if (!callExpr) { + return; + } + + switch (name) { + case BuilderNodeFunctionName.Update: + if (callExpr.arguments.length !== 0 && this.checkArgumentIsLiteral(callExpr.arguments[0])) { + this.incrementCounters(callExpr, FaultID.BuilderNodeUpdateNoLiteral); + } + break; + case BuilderNodeFunctionName.Build: { + const hasTargetParam = callExpr.arguments.filter(ts.isObjectLiteralExpression).some((literal) => { + return literal.properties.some((prop) => { + return prop.name?.getText() === NESTING_BUILDER_SUPPORTED; + }); + }); + if (hasTargetParam) { + this.incrementCounters(callExpr, FaultID.BuilderNodeNoNestingBuilderSupported); + } + break; + } + default: + } + } + + private checkArgumentIsLiteral(node: ts.Node): boolean { + switch (node.kind) { + case ts.SyntaxKind.ObjectLiteralExpression: + return true; + case ts.SyntaxKind.Identifier: + return this.checkIdentifierIsLiteral(node as ts.Identifier); + case ts.SyntaxKind.ConditionalExpression: + return this.checkConditionalExprIsLiteral(node as ts.ConditionalExpression); + case ts.SyntaxKind.CallExpression: + return this.checkCallExprIsLiteral(node as ts.CallExpression); + default: + return false; + } + } + + private checkIdentifierIsLiteral(node: ts.Identifier): boolean { + const decl = this.tsUtils.getDeclarationNode(node); + const initalizer = decl && ts.isVariableDeclaration(decl) ? decl.initializer : undefined; + if (!initalizer) { + return false; + } + return this.checkArgumentIsLiteral(initalizer); + } + + private checkConditionalExprIsLiteral(node: ts.ConditionalExpression): boolean { + return this.checkArgumentIsLiteral(node.whenTrue) || this.checkArgumentIsLiteral(node.whenFalse); + } + + private checkCallExprIsLiteral(node: ts.CallExpression): boolean { + const callExpr = node; + let identifier: ts.Identifier | undefined; + if (ts.isIdentifier(callExpr.expression)) { + identifier = callExpr.expression; + } else if (ts.isPropertyAccessExpression(callExpr.expression) && ts.isIdentifier(callExpr.expression.name)) { + identifier = callExpr.expression.name; + } + + if (!identifier) { + return false; + } + const funcDecl = this.tsUtils.getDeclarationNode(identifier); + const body = + funcDecl && (ts.isFunctionDeclaration(funcDecl) || ts.isMethodDeclaration(funcDecl)) ? funcDecl.body : undefined; + if (!body) { + return false; + } + for (const stmt of body.statements) { + if (ts.isReturnStatement(stmt) && stmt.expression) { + return this.checkArgumentIsLiteral(stmt.expression); + } + } + return false; + } } diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 375831c9a731489a8201edb6e69f1b31f35ffb47..dd3096cc61e605dc85be56b3389eefe6687626a4 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -56,7 +56,6 @@ export const cookBookRefToFixTitle: Map = new Map([ [282, '"@StorageProp" transform to "@StoragePropRef"'], [283, '"@LocalStorageProp" transform to "@LocalStoragePropRef"'], [300, 'Replace calling method of the TS-like `Function` type'], - [330, 'Convert import named objects from JS to ESValue'], [332, 'Using the ESValue interface to access properties'], [334, 'Call typeOf function'], [335, 'Call toNumber function to convert'], diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index bca8d8304e2313dc8a46587c66d274ce8cc7f519..9d3a0c173263c77c4b9b4d2f709c5b90b174b933 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -20,8 +20,8 @@ import { NameGenerator } from '../utils/functions/NameGenerator'; import { isAssignmentOperator } from '../utils/functions/isAssignmentOperator'; import { SymbolCache } from './SymbolCache'; import { SENDABLE_DECORATOR } from '../utils/consts/SendableAPI'; +import { ARKTSUTILS_LOCKS_MEMBER } from '../utils/consts/LimitedStdAPI'; import { DEFAULT_MODULE_NAME, PATH_SEPARATOR, SRC_AND_MAIN } from '../utils/consts/OhmUrl'; -import { STRINGLITERAL_NUMBER, STRINGLITERAL_NUMBER_ARRAY } from '../utils/consts/StringLiteral'; import { DOUBLE_DOLLAR_IDENTIFIER, THIS_IDENTIFIER, @@ -30,7 +30,7 @@ import { COMMON_METHOD_IDENTIFIER, APPLY_STYLES_IDENTIFIER, CustomInterfaceName, - ARKUI_PACKAGE_NAME, + ARKUI_MODULE, VALUE_IDENTIFIER, INDENT_STEP, ENTRY_DECORATOR_NAME, @@ -47,7 +47,6 @@ import { import { ES_VALUE } from '../utils/consts/ESObject'; import type { IncrementDecrementNodeInfo } from '../utils/consts/InteropAPI'; import { - LOAD, GET_PROPERTY, SET_PROPERTY, ARE_EQUAL, @@ -61,7 +60,10 @@ import { LENGTH, IS_INSTANCE_OF } from '../utils/consts/InteropAPI'; -import { ESLIB_SHAREDARRAYBUFFER } from '../utils/consts/ConcurrentAPI'; +import path from 'node:path'; +import { isStdLibrarySymbol } from '../utils/functions/IsStdLibrary'; +import { propertyAccessReplacements, identifierReplacements } from '../utils/consts/DeprecatedApi'; +import { ARKTS_COLLECTIONS_MODULE, BIT_VECTOR } from '../utils/consts/CollectionsAPI'; const UNDEFINED_NAME = 'undefined'; @@ -981,11 +983,11 @@ export class Autofixer { const propertyChain: string[] = [propertyName]; let current: ts.Node = node; - + while (current.parent && ts.isElementAccessExpression(current.parent)) { const parentArg = current.parent.argumentExpression; if (ts.isStringLiteral(parentArg)) { - propertyChain.push(parentArg.text); + propertyChain.push(parentArg.text); } current = current.parent; } @@ -2039,7 +2041,7 @@ export class Autofixer { !objectLiteralExpr.parent.type ) { const text = ': ' + newInterfaceName; - const pos = Autofixer.getDeclarationTypePositionForObjectLiteral(objectLiteralExpr.parent); + const pos = Autofixer.getDeclarationTypePosition(objectLiteralExpr.parent); return { start: pos, end: pos, replacementText: text }; } @@ -2055,7 +2057,7 @@ export class Autofixer { return { start: objectLiteralExpr.getStart(), end: objectLiteralExpr.getEnd(), replacementText: text }; } - private static getDeclarationTypePositionForObjectLiteral( + private static getDeclarationTypePosition( decl: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration ): number { if (ts.isPropertyDeclaration(decl)) { @@ -2468,17 +2470,15 @@ export class Autofixer { const prev = allSpecifiers[specIndex - 1]; start = prev.getEnd(); } - fixes.push({ - start: start, - end: end, - replacementText: '' - }); + fixes.push({ start: start, end: end, replacementText: '' }); } const alias = specToRemove.name; - const original = specToRemove.propertyName ?? specToRemove.name; - const replacements = this.replaceIdentifierUsages(alias, original.getText()); - fixes.push(...replacements); + const original = specToRemove.propertyName; + if (original) { + const replacements = this.replaceIdentifierUsages(alias, original.getText()); + fixes.push(...replacements); + } return fixes; } @@ -2789,6 +2789,7 @@ export class Autofixer { fixCustomBidirectionalBinding( originalExpr: ts.ObjectLiteralExpression, + type: ts.TypeNode | undefined, currentParam: ts.Identifier, customParam: ts.Identifier ): Autofix[] | undefined { @@ -2809,14 +2810,7 @@ export class Autofixer { ], true ); - const parameter = ts.factory.createParameterDeclaration( - undefined, - undefined, - value, - undefined, - undefined, - undefined - ); + const parameter = ts.factory.createParameterDeclaration(undefined, undefined, value, undefined, type, undefined); const arrowFunc = ts.factory.createArrowFunction( undefined, undefined, @@ -3379,63 +3373,21 @@ export class Autofixer { return this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile); } - fixVariableDeclaration(node: ts.VariableDeclaration, isEnum: boolean): Autofix[] | undefined { - const initializer = node.initializer; - const name = node.name; - const sym = this.typeChecker.getSymbolAtLocation(name); - if (!sym || !initializer) { - return undefined; - } - ts.setCommentRange(initializer, { pos: -1, end: -1 }); - - const type = this.typeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.typeChecker.typeToString(type); - const typeFlags = type.flags; - - if (!TsUtils.isNumberLike(type, typeText, isEnum)) { - return undefined; - } - - let typeNode: ts.TypeNode; - if (typeText === STRINGLITERAL_NUMBER || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0 || isEnum) { - typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - } else if (typeText === STRINGLITERAL_NUMBER_ARRAY) { - typeNode = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)); - } else { - return undefined; - } - - const newVarDecl = ts.factory.createVariableDeclaration(name, undefined, typeNode, initializer); - const parent = node.parent; - if (!ts.isVariableDeclarationList(parent)) { - return undefined; - } - const text = this.printer.printNode(ts.EmitHint.Unspecified, newVarDecl, node.getSourceFile()); - return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; + fixNumericSemanticsForDeclaration( + node: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration, + type: ts.Type + ): Autofix[] | undefined { + const typeNode = this.getTypeForNumericSemantics(type); + const text = ': ' + this.printer.printNode(ts.EmitHint.Unspecified, typeNode, node.getSourceFile()); + const pos = Autofixer.getDeclarationTypePosition(node); + return [{ start: pos, end: pos, replacementText: text }]; } - fixPropertyDeclarationNumericSemanticsArray(node: ts.PropertyDeclaration): Autofix[] { - const newProperty = ts.factory.createPropertyDeclaration( - node.modifiers, - node.name, - undefined, - ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)), - node.initializer - ); - - const replacementText = this.nonCommentPrinter.printNode( - ts.EmitHint.Unspecified, - newProperty, - node.getSourceFile() - ); - - return [ - { - start: node.getStart(), - end: node.getEnd(), - replacementText: replacementText - } - ]; + private getTypeForNumericSemantics(type: ts.Type): ts.TypeNode { + if (this.utils.isGenericArrayType(type)) { + return ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)); + } + return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); } /** @@ -3469,10 +3421,127 @@ export class Autofixer { return undefined; } - const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, replacement, expression.getSourceFile()); + const replacementText = this.nonCommentPrinter.printNode( + ts.EmitHint.Unspecified, + replacement, + expression.getSourceFile() + ); return [{ start: expression.getStart(), end: expression.getEnd(), replacementText }]; } + /** + * Convert a JS-imported `for...of` over an array into an indexed `for` loop. + * + * @param forOf - The `ForOfStatement` node to transform. + */ + applyForOfJsArrayFix(forOf: ts.ForOfStatement): Autofix[] | undefined { + const loopDecl = (forOf.initializer as ts.VariableDeclarationList).declarations[0]; + const elementName = (loopDecl.name as ts.Identifier).text; + + const indexName = TsUtils.generateUniqueName(this.tmpVariableNameGenerator, forOf.getSourceFile()) ?? '_i'; + + const fixes: Autofix[] = []; + fixes.push(this.buildForOfHeaderFix(forOf, indexName)); + fixes.push(...this.buildForOfBodyFixes(forOf, elementName, indexName)); + return fixes.length > 0 ? fixes : undefined; + } + + /** + * Build an Autofix for replacing the for-of loop header. + */ + private buildForOfHeaderFix(forOf: ts.ForOfStatement, indexName: string): Autofix { + const arrText = forOf.expression.getText(); + + const initializer = ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier(indexName), + undefined, + undefined, + ts.factory.createNumericLiteral('0') + ) + ], + ts.NodeFlags.Let + ); + + // condition: i < arr.getProperty('length').toNumber() + const condition = ts.factory.createBinaryExpression( + ts.factory.createIdentifier(indexName), + ts.SyntaxKind.LessThanToken, + ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(arrText), + ts.factory.createIdentifier(GET_PROPERTY) + ), + undefined, + [ts.factory.createStringLiteral(LENGTH, true)] + ), + ts.factory.createIdentifier('toNumber') + ), + undefined, + [] + ) + ); + + const incrementor = ts.factory.createPrefixUnaryExpression( + ts.SyntaxKind.PlusPlusToken, + ts.factory.createIdentifier(indexName) + ); + + return this.createReplacementTextForOfHeader(forOf, initializer, condition, incrementor); + } + + private createReplacementTextForOfHeader( + forOf: ts.ForOfStatement, + initializer: ts.VariableDeclarationList, + condition: ts.BinaryExpression, + incrementor: ts.PrefixUnaryExpression + ): Autofix { + // Render just the "(initializer; condition; incrementor)" text: + const replacementText = [ + this.printer.printNode(ts.EmitHint.Unspecified, initializer, forOf.getSourceFile()), + '; ', + this.printer.printNode(ts.EmitHint.Unspecified, condition, forOf.getSourceFile()), + '; ', + this.printer.printNode(ts.EmitHint.Unspecified, incrementor, forOf.getSourceFile()) + ].join(''); + + return { start: forOf.initializer.getStart(), end: forOf.expression.getEnd(), replacementText }; + } + + /** + * Build fixes for replacing loop-variable references inside the for-of body. + */ + private buildForOfBodyFixes(forOf: ts.ForOfStatement, elementName: string, indexName: string): Autofix[] { + const fixes: Autofix[] = []; + const arrExpr = forOf.expression; + + const visit = (node: ts.Node): void => { + if (ts.isIdentifier(node) && node.text === elementName) { + const callExpr = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(arrExpr.getText()), + ts.factory.createIdentifier(GET_PROPERTY) + ), + undefined, + [ts.factory.createIdentifier(indexName)] + ); + + // Print and append proper conversion suffix + const printed = this.printer.printNode(ts.EmitHint.Unspecified, callExpr, forOf.getSourceFile()); + const replacementText = printed + this.utils.findTypeOfNodeForConversion(node); + + fixes.push({ start: node.getStart(), end: node.getEnd(), replacementText }); + } + ts.forEachChild(node, visit); + }; + + visit(forOf.statement); + return fixes; + } + fixInteropInstantiateExpression( express: ts.NewExpression, args: ts.NodeArray | undefined @@ -3506,56 +3575,6 @@ export class Autofixer { return undefined; } - fixParameter(param: ts.ParameterDeclaration): Autofix[] { - const newParam = ts.factory.createParameterDeclaration( - param.modifiers, - param.dotDotDotToken, - param.name, - param.questionToken, - ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - param.initializer - ); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newParam, param.getSourceFile()); - return [ - { - start: param.getStart(), - end: param.getEnd(), - replacementText: text - } - ]; - } - - fixPropertyDeclaration(node: ts.PropertyDeclaration): Autofix[] | undefined { - const initializer = node.initializer; - if (initializer === undefined) { - return undefined; - } - const propType = this.typeChecker.getTypeAtLocation(node); - let propTypeNode: ts.TypeNode; - if (propType.flags & ts.TypeFlags.NumberLike) { - propTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - } else { - const inferredTypeNode = this.typeChecker.typeToTypeNode(propType, undefined, ts.NodeBuilderFlags.None); - - if (!inferredTypeNode || !this.utils.isSupportedType(inferredTypeNode)) { - return undefined; - } - propTypeNode = inferredTypeNode; - } - - const questionOrExclamationToken = node.questionToken ?? node.exclamationToken ?? undefined; - const newPropDecl = ts.factory.createPropertyDeclaration( - node.modifiers, - node.name, - questionOrExclamationToken, - propTypeNode, - initializer - ); - - const text = this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, newPropDecl, node.getSourceFile()); - return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; - } - fixFunctionDeclarationly( callExpr: ts.CallExpression, resolvedTypeArgs: ts.NodeArray @@ -3677,7 +3696,7 @@ export class Autofixer { const importDeclaration = ts.factory.createImportDeclaration( undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(importSpecifiers)), - ts.factory.createStringLiteral(ARKUI_PACKAGE_NAME, true), + ts.factory.createStringLiteral(ARKUI_MODULE, true), undefined ); @@ -4056,137 +4075,79 @@ export class Autofixer { return [{ replacementText, start, end }]; } - /** - * Replace each loop‐variable reference (e.g. `element`) with - * `array.getProperty(i)` plus appropriate conversion. - * - * @param identifier The Identifier node of the loop variable usage. - * @param arrayName The name of the array being iterated. - */ - fixInteropArrayElementUsage(identifier: ts.Identifier, arrayName: string): Autofix { - // arr.getProperty(i) - const callExpr = ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createIdentifier(arrayName), - ts.factory.createIdentifier(GET_PROPERTY) - ), - undefined, - [ts.factory.createIdentifier('i')] - ); - - // Print and append proper conversion suffix - const printed = this.printer.printNode(ts.EmitHint.Unspecified, callExpr, identifier.getSourceFile()); - const replacementText = printed + this.utils.findTypeOfNodeForConversion(identifier); - - return { replacementText, start: identifier.getStart(), end: identifier.getEnd() }; - } - - fixSharedArrayBufferConstructor(node: ts.NewExpression): Autofix[] | undefined { - void this; - - // Ensure it's a constructor call to SharedArrayBuffer - if (!ts.isIdentifier(node.expression) || node.expression.text !== ESLIB_SHAREDARRAYBUFFER) { + fixConcurrencyLock(locksProp: ts.PropertyAccessExpression): Autofix[] | undefined { + // 1) Ensure the next property is `.AsyncLock` + const asyncLockProp = locksProp.parent; + if (!ts.isPropertyAccessExpression(asyncLockProp)) { return undefined; } - // Construct replacement - const replacementText = 'ArrayBuffer'; + const className = asyncLockProp.name.getText(); - return [{ replacementText, start: node.expression.getStart(), end: node.expression.getEnd() }]; - } + // 2a) Handle static method calls on AsyncLock (e.g. AsyncLock.request, AsyncLock.acquire, etc.) + const methodProp = asyncLockProp.parent; + if (ts.isPropertyAccessExpression(methodProp)) { + const methodName = methodProp.name.getText(); + const callExpr = methodProp.parent; + if (!ts.isCallExpression(callExpr)) { + return undefined; + } - fixSharedArrayBufferTypeReference(node: ts.TypeReferenceNode): Autofix[] | undefined { - void this; + const fixes: Autofix[] = []; + // Type fix for variable declaration, if necessary + const varDecl = Autofixer.findParentVariableDeclaration(callExpr); + const typeFix = varDecl ? this.buildConcurrencyLockTypeFix(varDecl, className) : undefined; + if (typeFix) { + fixes.push(typeFix); + } - if (!ts.isIdentifier(node.typeName) || node.typeName.text !== ESLIB_SHAREDARRAYBUFFER) { - return undefined; + // build AsyncLock.(...) + const fixCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(className), + ts.factory.createIdentifier(methodName) + ), + undefined, + callExpr.arguments + ); + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, fixCall, callExpr.getSourceFile()); + fixes.push({ start: callExpr.getStart(), end: callExpr.getEnd(), replacementText }); + return fixes; } - const replacementText = 'ArrayBuffer'; - - return [{ replacementText, start: node.getStart(), end: node.getEnd() }]; + // 2b) Handle `new ArkTSUtils.locks.AsyncLock()` + const newExpr = asyncLockProp.parent; + if (!ts.isNewExpression(newExpr)) { + return undefined; + } + // build `new AsyncLock()` + const replacement = ts.factory.createNewExpression(ts.factory.createIdentifier(className), undefined, []); + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, replacement, newExpr.getSourceFile()); + return [{ start: newExpr.getStart(), end: newExpr.getEnd(), replacementText }]; } /** - * Converts a `for...of` over an interop array into - * an index-based `for` loop using `getProperty("length")`. - * - * @param node The `ForOfStatement` node to fix. - * @returns A single Autofix for the loop header replacement. + * If the variable declaration has a qualified type `*.locks.ClassName`, build a fix to simplify it to `ClassName`. */ - fixInteropArrayForOf(node: ts.ForOfStatement): Autofix { - const iterableName = node.expression.getText(); + private buildConcurrencyLockTypeFix(varDecl: ts.VariableDeclaration, className: string): Autofix | undefined { + const typeNode = varDecl.type; - const initializer = ts.factory.createVariableDeclarationList( - [ - ts.factory.createVariableDeclaration( - ts.factory.createIdentifier('i'), - undefined, - undefined, - ts.factory.createNumericLiteral('0') - ) - ], - ts.NodeFlags.Let - ); - - const lengthAccess = ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createIdentifier(iterableName), - ts.factory.createIdentifier(GET_PROPERTY) - ), - undefined, - [ts.factory.createStringLiteral(LENGTH)] - ); - const condition = ts.factory.createBinaryExpression( - ts.factory.createIdentifier('i'), - ts.SyntaxKind.LessThanToken, - lengthAccess - ); - - const incrementor = ts.factory.createPrefixUnaryExpression( - ts.SyntaxKind.PlusPlusToken, - ts.factory.createIdentifier('i') - ); - - // Render just the "(initializer; condition; incrementor)" text: - const headerText = [ - this.printer.printNode(ts.EmitHint.Unspecified, initializer, node.getSourceFile()), - '; ', - this.printer.printNode(ts.EmitHint.Unspecified, condition, node.getSourceFile()), - '; ', - this.printer.printNode(ts.EmitHint.Unspecified, incrementor, node.getSourceFile()) - ].join(''); - - // Only replace from the start of the initializer to the end of the 'of' expression - const start = node.initializer.getStart(); - const end = node.expression.getEnd(); - - return { start, end, replacementText: headerText }; - } - - fixAppStorageCallExpression(callExpr: ts.CallExpression): Autofix[] | undefined { - const varDecl = Autofixer.findParentVariableDeclaration(callExpr); - if (!varDecl || varDecl.type) { + if (!typeNode || !ts.isTypeReferenceNode(typeNode) || !ts.isQualifiedName(typeNode.typeName)) { return undefined; } - const updatedVarDecl = ts.factory.updateVariableDeclaration( - varDecl, - varDecl.name, - undefined, - ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - varDecl.initializer - ); + const qn = typeNode.typeName; + const left = qn.left; + const right = qn.right; - const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, updatedVarDecl, varDecl.getSourceFile()); + // ensure it's of form *.locks.ClassName + if (ts.isQualifiedName(left) && left.right.text === ARKTSUTILS_LOCKS_MEMBER && right.text === className) { + const simple = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(className), undefined); + const text = this.printer.printNode(ts.EmitHint.Unspecified, simple, varDecl.getSourceFile()); + return { start: typeNode.getStart(), end: typeNode.getEnd(), replacementText: text }; + } - return [ - { - replacementText, - start: varDecl.getStart(), - end: varDecl.getEnd() - } - ]; + return undefined; } private static findParentVariableDeclaration(node: ts.Node): ts.VariableDeclaration | undefined { @@ -4199,66 +4160,11 @@ export class Autofixer { return undefined; } - private static createVariableForInteropImport( - interopProperty: string, - symbolName: string, - propertyName: string - ): ts.VariableStatement { - const newVarDecl = ts.factory.createVariableStatement( - undefined, - ts.factory.createVariableDeclarationList( - [ - ts.factory.createVariableDeclaration( - ts.factory.createIdentifier(symbolName), - undefined, - undefined, - this.createVariableInitialForInteropImport(propertyName, interopProperty) - ) - ], - ts.NodeFlags.Let - ) - ); - return newVarDecl; - } - - private static createVariableInitialForInteropImport(propertyName: string, interopProperty: string): ts.Expression { - const initializer = ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createIdentifier(ES_VALUE), - ts.factory.createIdentifier(LOAD) - ), - undefined, - [ts.factory.createStringLiteral(interopProperty)] - ), - ts.factory.createIdentifier(GET_PROPERTY) - ), - undefined, - [ts.factory.createStringLiteral(propertyName)] - ); - return initializer; - } - - private static getOriginalNameAtSymbol(symbolName: string, symbol?: ts.Symbol): string { - if (symbol) { - const originalDeclaration = symbol.declarations?.[0]; - let originalName = ''; - if (originalDeclaration) { - const isReturnNameOnSomeCase = - ts.isFunctionDeclaration(originalDeclaration) || - ts.isClassDeclaration(originalDeclaration) || - ts.isInterfaceDeclaration(originalDeclaration) || - ts.isEnumDeclaration(originalDeclaration); - if (isReturnNameOnSomeCase) { - originalName = originalDeclaration.name?.text || symbolName; - } else if (ts.isVariableDeclaration(originalDeclaration)) { - originalName = originalDeclaration.name.getText(); - } - } - return originalName; - } - return ''; + fixAppStorageCallExpression(varDecl: ts.VariableDeclaration): Autofix[] | undefined { + const typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); + const text = ': ' + this.printer.printNode(ts.EmitHint.Unspecified, typeNode, varDecl.getSourceFile()); + const pos = Autofixer.getDeclarationTypePosition(varDecl); + return [{ start: pos, end: pos, replacementText: text }]; } private fixInterOpImportJsProcessNode(node: ts.Node): string | undefined { @@ -4309,108 +4215,6 @@ export class Autofixer { return undefined; } - fixInterOpImportJs( - importDecl: ts.ImportDeclaration, - importClause: ts.ImportClause, - moduleSpecifier: string, - defaultSymbol?: ts.Symbol - ): Autofix[] | undefined { - let statements: string[] = []; - if (importClause.name) { - const symbolName = importClause.name.text; - const originalName = Autofixer.getOriginalNameAtSymbol(symbolName, defaultSymbol); - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - originalName, - statements - ); - } - const namedBindings = importClause.namedBindings; - if (namedBindings) { - statements = this.getStatementForInterOpImportJsOnNamedBindings( - namedBindings, - importDecl, - moduleSpecifier, - statements - ); - } - if (statements.length <= 0) { - return undefined; - } - let lastImportEnd = this.lastImportEndMap.get(this.sourceFile.fileName); - if (!lastImportEnd) { - lastImportEnd = this.getLastImportEnd(); - this.lastImportEndMap.set(this.sourceFile.fileName, lastImportEnd); - } - return [ - { start: importDecl.getStart(), end: importDecl.getEnd(), replacementText: '' }, - { - start: lastImportEnd, - end: lastImportEnd, - replacementText: statements.join(this.getNewLine()) + this.getNewLine() - } - ]; - } - - private getStatementForInterOpImportJsOnNamedBindings( - namedBindings: ts.NamedImportBindings, - importDecl: ts.ImportDeclaration, - moduleSpecifier: string, - statements: string[] - ): string[] { - if (ts.isNamespaceImport(namedBindings)) { - const symbolName = namedBindings.name.text; - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - symbolName, - statements - ); - } - if (ts.isNamedImports(namedBindings)) { - namedBindings.elements.map((element) => { - const symbolName = element.name.text; - const originalName = element.propertyName ? element.propertyName.text : symbolName; - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - originalName, - statements - ); - return statements; - }); - } - return statements; - } - - private constructAndSaveimportDecl2Arrays( - importDecl: ts.ImportDeclaration, - moduleSpecifier: string, - symbolName: string, - originalName: string | undefined, - statements: string[] - ): string[] { - const propertyName = originalName || symbolName; - const newVarDecl = Autofixer.createVariableForInteropImport(moduleSpecifier, symbolName, propertyName); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newVarDecl, importDecl.getSourceFile()); - statements.push(TsUtils.removeOrReplaceQuotes(text, true)); - return statements; - } - - private getLastImportEnd(): number { - let lastImportEnd = 0; - this.sourceFile.statements.forEach((statement) => { - if (ts.isImportDeclaration(statement)) { - lastImportEnd = statement.getEnd(); - } - }); - return lastImportEnd; - } - fixInteropPropertyAccessExpression(express: ts.PropertyAccessExpression): Autofix[] | undefined { let text: string = ''; const statements = ts.factory.createCallExpression( @@ -4642,7 +4446,7 @@ export class Autofixer { fixImportClause(tsImportClause: ts.ImportClause): Autofix[] { void this; - const replacementText = tsImportClause.getText().replace(/\blazy\b\s*/, ""); + const replacementText = tsImportClause.getText().replace(/\blazy\b\s*/, ''); return [{ start: tsImportClause.getStart(), end: tsImportClause.getEnd(), replacementText }]; } @@ -4657,6 +4461,21 @@ export class Autofixer { return undefined; } + createInteropPropertyAccess(exp: ts.Expression): string { + let text: string; + if (!ts.isPropertyAccessExpression(exp)) { + text = exp.getText(); + return text; + } + const statements = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(exp.expression, ts.factory.createIdentifier(GET_PROPERTY)), + undefined, + [ts.factory.createStringLiteral(exp.name.getText())] + ); + text = this.printer.printNode(ts.EmitHint.Unspecified, statements, exp.getSourceFile()); + return text; + } + replaceInteropEqualityOperator( tsBinaryExpr: ts.BinaryExpression, binaryOperator: ts.BinaryOperator @@ -4667,14 +4486,20 @@ export class Autofixer { } const tsLhsExpr = tsBinaryExpr.left; + const left = this.createInteropPropertyAccess(tsLhsExpr); const tsRhsExpr = tsBinaryExpr.right; + const right = this.createInteropPropertyAccess(tsRhsExpr); + if (!left || !right) { + return undefined; + } + const callExpression = ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression( - ts.factory.createIdentifier(tsLhsExpr.getText()), + ts.factory.createIdentifier(left), ts.factory.createIdentifier(info.functionName) ), undefined, - [ts.factory.createIdentifier(tsRhsExpr.getText())] + [ts.factory.createIdentifier(right)] ); let text = this.printer.printNode(ts.EmitHint.Unspecified, callExpression, tsBinaryExpr.getSourceFile()); @@ -4861,20 +4686,44 @@ export class Autofixer { const statements = fn.body.statements; const lastExpr = statements.length > 0 ? statements[statements.length - 1] : undefined; if (hasReturn && lastExpr && !ts.isReturnStatement(lastExpr) || !hasReturn) { - const lastBrace = fn.body.getEnd() - 1; + const text = this.createUndefinedReturnStatement(fn, lastExpr); fixes.push({ - start: lastBrace, - end: lastBrace, - replacementText: '\nreturn undefined;\n' + start: lastExpr ? lastExpr.getEnd() : fn.body.getEnd() - 1, + end: lastExpr ? lastExpr.getEnd() : fn.body.getEnd() - 1, + replacementText: text }); } } } - return fixes; } - private fixGenericCallNoTypeArgsWithContextualType(node: ts.NewExpression): Autofix[] | undefined { + private createUndefinedReturnStatement(fn: ts.FunctionLikeDeclaration, lastExpr: ts.Statement | undefined): string { + const returnStatement = ts.factory.createReturnStatement(ts.factory.createIdentifier(UNDEFINED_NAME)); + if (lastExpr) { + const startPos = lastExpr.getStart(); + const lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(startPos); + const indent = lineAndCharacter.character; + return ( + this.getNewLine() + + ' '.repeat(indent) + + this.printer.printNode(ts.EmitHint.Unspecified, returnStatement, fn.getSourceFile()) + ); + } + const lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(fn.getStart()); + const indent = lineAndCharacter.character + INDENT_STEP; + return ( + this.getNewLine() + + ' '.repeat(indent) + + this.printer.printNode(ts.EmitHint.Unspecified, returnStatement, fn.getSourceFile()) + + this.getNewLine() + + ' '.repeat(lineAndCharacter.character) + ); + } + + private fixGenericCallNoTypeArgsWithContextualType( + node: ts.NewExpression | ts.CallExpression + ): Autofix[] | undefined { const contextualType = this.typeChecker.getContextualType(node); if (!contextualType) { return undefined; @@ -4890,70 +4739,277 @@ export class Autofixer { return this.generateGenericTypeArgumentsAutofix(node, reference); } - fixGenericCallNoTypeArgs(node: ts.NewExpression): Autofix[] | undefined { + fixGenericCallNoTypeArgs(node: ts.NewExpression | ts.CallExpression): Autofix[] | undefined { const typeNode = this.getTypeNodeForNewExpression(node); if (!typeNode) { return this.fixGenericCallNoTypeArgsWithContextualType(node); } + let nodeExpressionText = node.expression.getText(); + if (ts.isCallExpression(node)) { + const returnTypeText = this.getReturnTypeFromMethodDeclaration(node); + if (!returnTypeText) { + return undefined; + } + nodeExpressionText = returnTypeText; + } if (ts.isUnionTypeNode(typeNode)) { - return this.fixGenericCallNoTypeArgsForUnionType(node, typeNode); + return this.fixGenericCallNoTypeArgsForUnionType(node, typeNode, nodeExpressionText); } if (ts.isArrayTypeNode(typeNode)) { return this.fixGenericCallNoTypeArgsForArrayType(node, typeNode); } - if (!ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== node.expression.getText()) { + if (!ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== nodeExpressionText) { return undefined; } const srcFile = node.getSourceFile(); - const typeArgsText = `<${typeNode.typeArguments?. - map((arg) => { - return this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, arg, srcFile); - }). - join(', ')}>`; - // Insert the type arguments immediately after the constructor name + const typeArgsText = this.printGenericCallTypeArgs(srcFile, typeNode.typeArguments); + if (!typeArgsText) { + return undefined; + } const insertPos = node.expression.getEnd(); return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; } + fixGenericCallNoTypeArgsForUnknown(node: ts.CallExpression): Autofix[] | undefined { + if (ts.isPropertyAccessExpression(node.parent)) { + const insertPos = node.expression.getEnd(); + return [{ start: insertPos, end: insertPos, replacementText: '' }]; + } + + const typeNode = this.getTypeNodeForNewExpression(node); + if (!typeNode) { + return undefined; + } + + const nodeExpressionText = ts.isVariableDeclaration(node.parent) ? + this.getReturnTypeFromMethodDeclaration(node) ?? node.expression.getText() : + node.expression.getText(); + + if (ts.isUnionTypeNode(typeNode)) { + const targetTypeRef = typeNode.types.find((t): t is ts.TypeReferenceNode => { + return ts.isTypeReferenceNode(t) && t.typeName.getText() === nodeExpressionText; + }); + if (!targetTypeRef) { + return undefined; + } + return this.createFixWithTypeArgs(node, targetTypeRef.typeArguments); + } + + if (ts.isTypeReferenceNode(typeNode) && typeNode.typeName.getText() === nodeExpressionText) { + return this.createFixWithTypeArgs(node, typeNode.typeArguments); + } + + return undefined; + } + + private createFixWithTypeArgs( + node: ts.CallExpression, + typeArguments: ts.NodeArray | undefined + ): Autofix[] | undefined { + const typeArgsText = this.printGenericCallTypeArgs(node.getSourceFile(), typeArguments); + return typeArgsText ? + [ + { + start: node.expression.getEnd(), + end: node.expression.getEnd(), + replacementText: typeArgsText + } + ] : + undefined; + } + + getReturnTypeFromMethodDeclaration(node: ts.CallExpression): string | undefined { + if (ts.isPropertyAccessExpression(node.expression)) { + const propertyAccess = node.expression; + const methodName = propertyAccess.name.text; + const receiver = propertyAccess.expression; + const receiverType = this.typeChecker.getTypeAtLocation(receiver); + const methodSymbol = this.typeChecker.getPropertyOfType(receiverType, methodName); + + if (!methodSymbol) { + return undefined; + } + const methodDecl = methodSymbol.declarations?.[0] as ts.MethodSignature; + if (!methodDecl.type || !ts.isTypeReferenceNode(methodDecl.type) && !ts.isUnionTypeNode(methodDecl.type)) { + return undefined; + } + if (ts.isTypeReferenceNode(methodDecl.type)) { + return methodDecl.type.typeName.getText(); + } + if (ts.isUnionTypeNode(methodDecl.type)) { + const typeNode = this.getTypeNodeForNewExpression(node); + if (!typeNode) { + return undefined; + } + const targetTypeName = this.getTargetTypeName(typeNode, methodDecl.type); + + if (ts.isUnionTypeNode(typeNode)) { + return targetTypeName; + } + const targetTypeNode = methodDecl.type.types.find((type) => { + return ts.isTypeReferenceNode(type) && type.typeName.getText() === targetTypeName; + }) as ts.TypeReferenceNode; + if (!targetTypeNode) { + return undefined; + } + return targetTypeNode.typeName.getText(); + } + } + return undefined; + } + + private getTargetTypeName(typeNode: ts.TypeNode, methodDeclType: ts.UnionTypeNode): string | undefined { + if (ts.isTypeReferenceNode(typeNode)) { + return typeNode.typeName.getText(); + } + + if (!ts.isUnionTypeNode(typeNode)) { + return undefined; + } + + const hasGenericType = methodDeclType.types.some((type) => { + return this.isGenericTypeParameter(type); + }); + const typeNames = new Set(typeNode.types.map(Autofixer.getTypeName).filter(Boolean)); + + const candidateNames = hasGenericType ? + typeNode.types.map(Autofixer.getTypeName) : + methodDeclType.types.map(Autofixer.getTypeName); + const targetTypeName = candidateNames.find((name) => { + return name && name !== 'undefined' && (hasGenericType || typeNames.has(name)); + }); + return targetTypeName; + } + + private isGenericTypeParameter(type: ts.TypeNode): boolean { + const getType = this.typeChecker.getTypeFromTypeNode(type); + return getType.isTypeParameter(); + } + + private static getTypeName(type: ts.TypeNode): string { + if (ts.isTypeReferenceNode(type)) { + return type.typeName.getText(); + } + if (ts.isLiteralTypeNode(type)) { + return type.literal.getText(); + } + const typeNameMap = { + [ts.SyntaxKind.StringKeyword]: 'string', + [ts.SyntaxKind.NumberKeyword]: 'number', + [ts.SyntaxKind.BooleanKeyword]: 'boolean', + [ts.SyntaxKind.UndefinedKeyword]: 'undefined', + [ts.SyntaxKind.NullKeyword]: 'null' + }; + return typeNameMap[type.kind] || ''; + } + private fixGenericCallNoTypeArgsForArrayType( - node: ts.NewExpression, + node: ts.NewExpression | ts.CallExpression, arrayTypeNode: ts.ArrayTypeNode ): Autofix[] | undefined { const elementTypeNode = arrayTypeNode.elementType; const srcFile = node.getSourceFile(); - const typeArgsText = `<${this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, elementTypeNode, srcFile)}>`; + const typeArgsText = this.printGenericCallTypeArgs(srcFile, elementTypeNode); + if (!typeArgsText) { + return undefined; + } const insertPos = node.expression.getEnd(); return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; } private fixGenericCallNoTypeArgsForUnionType( - node: ts.NewExpression, - unionType: ts.UnionTypeNode + node: ts.NewExpression | ts.CallExpression, + unionType: ts.UnionTypeNode, + nodeExpressionText: string ): Autofix[] | undefined { const matchingTypes = unionType.types.filter((type) => { - return ts.isTypeReferenceNode(type) && type.typeName.getText() === node.expression.getText(); - }) as ts.TypeReferenceNode[]; + return Autofixer.getTypeName(type) === nodeExpressionText; + }); if (matchingTypes.length === 1) { const matchingType = matchingTypes[0]; - if (matchingType.typeArguments) { - const srcFile = node.getSourceFile(); - const typeArgsText = `<${matchingType.typeArguments. - map((arg) => { - return this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, arg, srcFile); - }). - join(', ')}>`; - + if (ts.isTypeReferenceNode(matchingType)) { + if (matchingType.typeArguments) { + const srcFile = node.getSourceFile(); + const typeArgsText = this.printGenericCallTypeArgs(srcFile, matchingType.typeArguments); + if (!typeArgsText) { + return undefined; + } + const insertPos = node.expression.getEnd(); + return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; + } + } else { const insertPos = node.expression.getEnd(); - return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; + return [{ start: insertPos, end: insertPos, replacementText: `<${nodeExpressionText}>` }]; } } return undefined; } + private printGenericCallTypeArgs( + sourceFile: ts.SourceFile, + typeArg: ts.TypeNode | readonly ts.Node[] | undefined + ): string | undefined { + if (Array.isArray(typeArg)) { + if ( + typeArg.some((arg) => { + return !this.isTypeArgumentAccessible(sourceFile, arg as ts.TypeNode); + }) + ) { + return undefined; + } + return `<${typeArg. + map((arg) => { + return this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, arg, sourceFile); + }). + join(', ')}>`; + } + if (!typeArg || !this.isTypeArgumentAccessible(sourceFile, typeArg as ts.TypeNode)) { + return undefined; + } + + return `<${this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, typeArg as ts.TypeNode, sourceFile)}>`; + } + + private isTypeArgumentAccessible(sourceFile: ts.SourceFile, arg: ts.TypeNode): boolean { + const type = this.typeChecker.getTypeFromTypeNode(arg); + const symbol = type.symbol || type.aliasSymbol; + const decl = TsUtils.getDeclaration(symbol); + const fileName = decl?.getSourceFile().fileName; + const isStdLib = isStdLibrarySymbol(symbol); + const isMatchPathOnSourceAndDecl = decl && path.normalize(sourceFile.fileName) === path.normalize(fileName!); + if (!decl || isMatchPathOnSourceAndDecl || isStdLib) { + return true; + } + let result = false; + ts.forEachChild(sourceFile, (node) => { + if (ts.isImportDeclaration(node)) { + if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) { + node.importClause.namedBindings.elements.some((element) => { + result = this.isTypeArgImport(arg, element.name, symbol); + return result; + }); + } + if (node.importClause?.name) { + result = this.isTypeArgImport(arg, node.importClause.name, symbol); + } + } + return result; + }); + return result; + } + + private isTypeArgImport(arg: ts.Node, importName: ts.Identifier, typeArgSym: ts.Symbol): boolean { + if (arg.getText() !== importName.text) { + return false; + } + const importSym = this.utils.trueSymbolAtLocation(importName); + return importSym === typeArgSym; + } + private generateGenericTypeArgumentsAutofix( - node: ts.NewExpression, + node: ts.NewExpression | ts.CallExpression, typeArgs: ts.TypeReferenceNode[] ): Autofix[] | undefined { const srcFile = node.getSourceFile(); @@ -4970,11 +5026,10 @@ export class Autofixer { if (hasAnyType) { return undefined; } - const typeArgsText = `<${typeArgs?. - map((arg) => { - return this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, arg, srcFile); - }). - join(', ')}>`; + const typeArgsText = this.printGenericCallTypeArgs(srcFile, typeArgs); + if (!typeArgsText) { + return undefined; + } return [{ start: identifier.getEnd(), end: identifier.getEnd(), replacementText: typeArgsText }]; } @@ -4986,7 +5041,7 @@ export class Autofixer { return []; } - private getTypeNodeForNewExpression(node: ts.NewExpression): ts.TypeNode | undefined { + private getTypeNodeForNewExpression(node: ts.NewExpression | ts.CallExpression): ts.TypeNode | undefined { if (ts.isVariableDeclaration(node.parent) || ts.isPropertyDeclaration(node.parent)) { return node.parent.type; } else if (ts.isBinaryExpression(node.parent)) { @@ -5141,36 +5196,42 @@ export class Autofixer { ]; } - fixPropDecorator(node: ts.Decorator, decoratorName: string): Autofix[] { - const newDecorator = ts.factory.createDecorator( - ts.factory.createIdentifier(decoratorName + NEW_PROP_DECORATOR_SUFFIX) - ); + fixPropDecorator(node: ts.Identifier, decoratorName: string): Autofix[] { + const newDecorator = ts.factory.createIdentifier(decoratorName + NEW_PROP_DECORATOR_SUFFIX); const text = this.printer.printNode(ts.EmitHint.Unspecified, newDecorator, node.getSourceFile()); return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; } - fixNumericPublicStatic(node: ts.PropertyDeclaration): Autofix[] | undefined { - if (!node?.name || node.type) { - return undefined - }; - const typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - const modifiers = ts.getModifiers(node) || []; - const updatedProperty = ts.factory.updatePropertyDeclaration( - node, - modifiers, - node.name, - node.questionToken, - typeNode, - node.initializer + importBitVector(node: ts.Node, lastImportDeclaration: ts.Node | undefined): Autofix | undefined { + const importDeclaration = ts.factory.createImportDeclaration( + undefined, + ts.factory.createImportClause( + false, + undefined, + ts.factory.createNamedImports([ + ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(BIT_VECTOR)) + ]) + ), + ts.factory.createStringLiteral(ARKTS_COLLECTIONS_MODULE), + undefined ); + // find the last import statement; - const newText = this.printer.printNode(ts.EmitHint.Unspecified, updatedProperty, node.getSourceFile()); - return [{ - start: node.getStart(), - end: node.getEnd(), - replacementText: newText - }]; + let replacementText: string = this.nonCommentPrinter.printNode( + ts.EmitHint.Unspecified, + importDeclaration, + node.getSourceFile() + ); + let start: number = 0; + let end: number = 0; + + if (lastImportDeclaration) { + start = end = lastImportDeclaration.getEnd(); + replacementText = this.getNewLine() + replacementText + this.getNewLine(); + } + + return { start, end, replacementText }; } fixRepeat(stmt: ts.ExpressionStatement): Autofix[] { @@ -5206,4 +5267,111 @@ export class Autofixer { this.printer.printNode(ts.EmitHint.Unspecified, newExpr, stmt.getSourceFile()); return [{ start: stmt.getEnd(), end: stmt.getEnd(), replacementText: text }]; } + + fixDeprecatedApiForCallExpression(callExpr: ts.CallExpression): Autofix[] | undefined { + const createUIContextAccess = (methodName: string): ts.Node => { + return ts.factory.createPropertyAccessExpression( + ts.factory.createCallExpression(ts.factory.createIdentifier('getUIContext'), undefined, []), + ts.factory.createIdentifier(methodName) + ); + }; + + if (ts.isPropertyAccessExpression(callExpr.expression)) { + const fullName = `${callExpr.expression.expression.getText()}.${callExpr.expression.name.getText()}`; + const methodName = propertyAccessReplacements.get(fullName); + if (methodName) { + const newExpression = createUIContextAccess(methodName); + const newText = this.printer.printNode(ts.EmitHint.Unspecified, newExpression, callExpr.getSourceFile()); + return [ + { + start: callExpr.expression.getStart(), + end: callExpr.expression.getEnd(), + replacementText: newText + } + ]; + } + } + + if (ts.isIdentifier(callExpr.expression)) { + const identifierText = callExpr.expression.getText(); + const methodName = identifierReplacements.get(identifierText); + + if (methodName) { + const newExpression = createUIContextAccess(methodName); + const newText = this.printer.printNode(ts.EmitHint.Unspecified, newExpression, callExpr.getSourceFile()); + return [ + { + start: callExpr.expression.getStart(), + end: callExpr.expression.getEnd(), + replacementText: newText + } + ]; + } + } + + return undefined; + } + + fixSpecialDeprecatedApiForCallExpression(callExpr: ts.CallExpression, name: ts.Identifier): Autofix[] | undefined { + if (name.getText() !== 'clip' || !ts.isNewExpression(callExpr.arguments[0])) { + return undefined; + } + + const shapeMap = { + Circle: 'CircleShape', + Path: 'PathShape', + Ellipse: 'EllipseShape', + Rect: 'RectShape' + } as const; + + const argsExpr = callExpr.arguments[0].arguments; + const constructorName = callExpr.arguments[0].expression.getText(); + + if ( + ts.isPropertyAccessExpression(callExpr.expression) && + callExpr.expression.name.text === 'clip' && + constructorName in shapeMap + ) { + const shapeType = shapeMap[constructorName as keyof typeof shapeMap]; + const newExpression = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + callExpr.expression.expression, + ts.factory.createIdentifier('clipShape') + ), + undefined, + [ts.factory.createNewExpression(ts.factory.createIdentifier(shapeType), undefined, argsExpr)] + ); + + const newText = this.printer.printNode(ts.EmitHint.Unspecified, newExpression, callExpr.getSourceFile()); + return [ + { + start: callExpr.getStart(), + end: callExpr.getEnd(), + replacementText: newText + } + ]; + } + + return undefined; + } + + fixSideEffectImport(importDeclNode: ts.ImportDeclaration): Autofix[] { + const initModuleCall = ts.factory.createCallExpression(ts.factory.createIdentifier('initModule'), undefined, [ + importDeclNode.moduleSpecifier + ]); + const expressionStatement = ts.factory.createExpressionStatement(initModuleCall); + const replacedText = this.printer.printNode( + ts.EmitHint.Unspecified, + expressionStatement, + importDeclNode.getSourceFile() + ); + + return [ + { + start: importDeclNode.getStart(), + end: importDeclNode.getEnd(), + replacementText: replacedText + } + ]; + } } diff --git a/ets2panda/linter/src/lib/data/BuiltinList.json b/ets2panda/linter/src/lib/data/BuiltinList.json index 3ba53f2cbb312d567c6bdc3b9c58df079844fb3e..659a25bbd5685ce492cb3ced9ae386ead5fdd5ab 100644 --- a/ets2panda/linter/src/lib/data/BuiltinList.json +++ b/ets2panda/linter/src/lib/data/BuiltinList.json @@ -4626,6 +4626,1175 @@ }, "import_path": [], "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "iterable", + "type": "Iterable | ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "U[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "U[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2020.bigint.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => bigint", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "BigInt64ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "BigInt64Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2020.bigint.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => bigint", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "BigUint64ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "BigUint64Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Float32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Float32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Float32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Float32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Float64ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Float64Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Float64ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Float64Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int16ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int16Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int16ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int16Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int8ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int8Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Int8ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Int8Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint8ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint8Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint8ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint8Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint16ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint16Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint16ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint16Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint32ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint32Array", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "Iterable", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint8ClampedArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint8ClampedArray", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arrayLike", + "type": "ArrayLike", + "is_optional": false, + "has_default": false + }, + { + "name": "mapfn", + "type": "(v: T, k: number) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Uint8ClampedArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "Uint8ClampedArray", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "find", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(this: void, value: T, index: number, obj: T[]) => value is S", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "S | undefined", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "find", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(value: T, index: number, obj: T[]) => unknown", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "T | undefined", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "map", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "callbackfn", + "type": "(value: T, index: number, array: T[]) => U", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "U[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "filter", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "callbackfn", + "type": "(value: T, index: number, array: T[]) => value is S", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "S[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "find", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(this: void, value: T, index: number, obj: readonly T[]) => value is S", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ReadonlyArray", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "S | undefined", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "find", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(value: T, index: number, obj: readonly T[]) => unknown", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ReadonlyArray", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "T | undefined", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1, + "problem": "ThisArg", + "api_name": "findIndex", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(value: T, index: number, obj: readonly T[]) => unknown", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ReadonlyArray", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "number", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2021.promise.d.ts", + "api_info": { + "line": 1, + "problem": "BuiltinNoCtorFunc", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "AggregateErrorConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 43, + "problem": "ThisArg", + "api_name": "findIndex", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "predicate", + "type": "(value: T, index: number, obj: T[]) => unknown", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "number", + "code_kind": 173 + }, + "import_path": [], + "is_global": true } ] } \ No newline at end of file diff --git a/ets2panda/linter/src/lib/data/DeprecatedApiList.json b/ets2panda/linter/src/lib/data/DeprecatedApiList.json new file mode 100644 index 0000000000000000000000000000000000000000..2c05b55d141c4d13401df081b8b3b3d82312a892 --- /dev/null +++ b/ets2panda/linter/src/lib/data/DeprecatedApiList.json @@ -0,0 +1,10369 @@ +{ + "api_list": [ + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "clip", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "opacity", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "type", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "TransitionType" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.curves.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "cubicBezier", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "curves", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "x1", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "y1", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "x2", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "y2", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "string" + }, + "import_path": [ + "@ohos.curves", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "rotate", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "RotateOptions" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "scale", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "ScaleOptions" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "translate", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "TranslateOptions" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigation.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "toolBar", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigationAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "object | CustomBuilder", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigationAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigation.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "subTitle", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigationAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigationAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "px2lpx", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "lpx2px", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "px2fp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "fp2px", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "px2vp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "vp2px", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getContext", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "component", + "type": "Object", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "Context" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/xcomponent.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "setXComponentSurfaceSize", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentController", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{\n surfaceWidth: number;\n surfaceHeight: number;\n }", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/text_input.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onEditChanged", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "TextInputAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(isEditing: boolean) => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "TextInputAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenY", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TouchObject", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenX", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "TouchObject", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenY", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "MouseEvent", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenX", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "MouseEvent", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenY", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ClickEvent", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenX", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ClickEvent", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/image_animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "preDecode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ImageAnimatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ImageAnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/text_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "TextPickerDialog", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "TextPickerDialogOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/text_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onCancel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "TextPickerAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "() => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "TextPickerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/text_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onAccept", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "TextPickerAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(value: string, index: number) => void", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "TextPickerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/date_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DatePickerDialog", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "DatePickerDialogOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/date_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onChange", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DatePickerDialogOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "DatePickerResult", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(value: DatePickerResult) => void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/date_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onAccept", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DatePickerDialogOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "DatePickerResult", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(value: DatePickerResult) => void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/date_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onChange", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DatePickerAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(value: DatePickerResult)", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "DatePickerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/lazy_for_each.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDataChanged", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DataChangeListener", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "index", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/lazy_for_each.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDataDeleted", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DataChangeListener", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "index", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/lazy_for_each.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDataMoved", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DataChangeListener", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "from", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "to", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/lazy_for_each.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDataAdded", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DataChangeListener", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "index", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.arkui.UIContext.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showActionMenu", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PromptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "promptAction.ActionMenuOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "promptAction.ActionMenuSuccessResponse", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.UIContext", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/action_sheet.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ActionSheet", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "ActionSheetOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/alert_dialog.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AlertDialog", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "AlertDialogParamWithConfirm | AlertDialogParamWithButtons | AlertDialogParamWithOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/refresh.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "offset", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RefreshOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number | string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Center", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "Edge", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Middle", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "Edge", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "5" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.arkui.componentSnapshot.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createFromBuilder", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "componentSnapshot", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "builder", + "type": "CustomBuilder", + "is_optional": false, + "has_default": false + }, + { + "name": "delay", + "type": "number", + "is_optional": true, + "has_default": false + }, + { + "name": "checkImageStatus", + "type": "boolean", + "is_optional": true, + "has_default": false + }, + { + "name": "options", + "type": "SnapshotOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.arkui.componentSnapshot", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.componentSnapshot.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createFromBuilder", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "componentSnapshot", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "builder", + "type": "CustomBuilder", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + }, + { + "name": "delay", + "type": "number", + "is_optional": true, + "has_default": false + }, + { + "name": "checkImageStatus", + "type": "boolean", + "is_optional": true, + "has_default": false + }, + { + "name": "options", + "type": "SnapshotOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.componentSnapshot", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.componentSnapshot.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "get", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "componentSnapshot", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "id", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "options", + "type": "SnapshotOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.arkui.componentSnapshot", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.componentSnapshot.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "get", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "componentSnapshot", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "id", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + }, + { + "name": "options", + "type": "SnapshotOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.componentSnapshot", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.measure.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "measureTextSize", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "MeasureText", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "MeasureOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SizeOptions" + }, + "import_path": [ + "@ohos.measure", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.measure.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "measureText", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "MeasureText", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "MeasureOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number" + }, + "import_path": [ + "@ohos.measure", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.dragController.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getDragPreview", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "dragController", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "DragPreview" + }, + "import_path": [ + "@ohos.arkui.dragController", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.dragController.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createDragAction", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "dragController", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "customArray", + "type": "Array", + "is_optional": false, + "has_default": false + }, + { + "name": "dragInfo", + "type": "DragInfo", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "DragAction" + }, + "import_path": [ + "@ohos.arkui.dragController", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.dragController.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "executeDrag", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "dragController", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "custom", + "type": "CustomBuilder | DragItemInfo", + "is_optional": false, + "has_default": false + }, + { + "name": "dragInfo", + "type": "DragInfo", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.arkui.dragController", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.dragController.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "executeDrag", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "dragController", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "custom", + "type": "CustomBuilder | DragItemInfo", + "is_optional": false, + "has_default": false + }, + { + "name": "dragInfo", + "type": "DragInfo", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.dragController", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getShared", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "LocalStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "LocalStorage" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.arkui.inspector.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createComponentObserver", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "inspector", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "id", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ComponentObserver" + }, + "import_path": [ + "@ohos.arkui.inspector", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "create", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Animator", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "AnimatorOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorResult" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.mediaquery.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "matchMediaSync", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "mediaquery", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "condition", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "MediaQueryListener" + }, + "import_path": [ + "@ohos.mediaquery", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.font.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getFontByName", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "font", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "fontName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "FontInfo" + }, + "import_path": [ + "@ohos.font", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.font.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getSystemFontList", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "font", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Array" + }, + "import_path": [ + "@ohos.font", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.font.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "registerFont", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "font", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "FontOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.font", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushNamedRoute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "NamedRouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getParams", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Object" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "hideAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "EnableAlertOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getStateByUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "url", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Array" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getStateByIndex", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "index", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "RouterState | undefined" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getState", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "RouterState" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getLength", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "string" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "clear", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "back", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "index", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "params", + "type": "Object", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "back", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replaceUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "mode", + "type": "RouterMode", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "pushUrl", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/time_picker.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "TimePickerDialog", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "TimePickerDialogOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "animateTo", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "AnimateParam", + "is_optional": false, + "has_default": false + }, + { + "name": "event", + "type": "() => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showActionMenu", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ActionMenuOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showActionMenu", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ActionMenuOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "closeCustomDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "dialogId", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "openCustomDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "CustomDialogOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowDialogOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowDialogOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.promptAction.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showToast", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "promptAction", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowToastOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.promptAction", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.arkui.componentUtils.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getRectangleById", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "componentUtils", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "id", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ComponentInfo" + }, + "import_path": [ + "@ohos.arkui.componentUtils", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "layout", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "childLayoutInfo", + "type": "LayoutInfo", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "position", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "Position" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "borderInfo", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "LayoutBorderInfo" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "position", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "Position" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "measure", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "childConstraint", + "type": "ConstraintSizeOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "id", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constraint", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "ConstraintSizeOptions" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "name", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constraint", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "ConstraintSizeOptions" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "margin", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutBorderInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "Margin" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "useSizeType", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{\n xs?: number | { span: number; offset: number; };\n sm?: number | { span: number; offset: number; };\n md?: number | { span: number; offset: number; };\n lg?: number | { span: number; offset: number; };\n }", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "padding", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutBorderInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "Padding" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "borderWidth", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "LayoutBorderInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "EdgeWidths" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "mask", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute | ProgressMask", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onMeasure", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CustomComponent", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "children", + "type": "Array", + "is_optional": false, + "has_default": false + }, + { + "name": "constraint", + "type": "ConstraintSizeOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onLayout", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CustomComponent", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "children", + "type": "Array", + "is_optional": false, + "has_default": false + }, + { + "name": "constraint", + "type": "ConstraintSizeOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "placementOnTop", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "PopupOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onScroll", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ScrollableCommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(scrollOffset: number)", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "touchable", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "maskColor", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "CustomPopupOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Color | string | Resource | number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getX", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DragEvent", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getY", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DragEvent", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "LayoutChild", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "LayoutChild", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "LayoutInfo", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "LayoutInfo", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "LayoutBorderInfo", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "LayoutBorderInfo", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "TransitionOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "TransitionOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "gridOffset", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "gridSpan", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "CommonMethod", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "indicatorStyle", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "SwiperAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "IndicatorStyle", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "SwiperAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "IndicatorStyle", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "color", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "ResourceColor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "right", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Length" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "left", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Length" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AUTO_LINEAR", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SwiperDisplayMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AutoLinear", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SwiperDisplayMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "selectedColor", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "ResourceColor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "mask", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "bottom", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Length" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "size", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Length" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Stretch", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SwiperDisplayMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/swiper.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "top", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "IndicatorStyle", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Length" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/scroll.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "scrollPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Scroller", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{ next: boolean; direction: Axis }", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/scroll.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Free", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "ScrollDirection", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/scroll.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onScrollEnd", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ScrollAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "() => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "ScrollAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/scroll.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onScroll", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ScrollAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(xOffset: number, yOffset: number) => void", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ScrollAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/ui_extension_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onResult", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "UIExtensionComponentAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "import('../api/@ohos.base').Callback<{\n\n code: number;\n\n want: import('../api/@ohos.app.ability.Want').default;\n\n }>", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "UIExtensionComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/ui_extension_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onRelease", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "UIExtensionComponentAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "import('../api/@ohos.base').Callback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "UIExtensionComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/slider.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "minLabel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "SliderAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SliderAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/slider.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "maxLabel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "SliderAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SliderAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list_item.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ListItemAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListItemInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "ListItemAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list_item.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "sticky", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListItemAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "Sticky", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ListItemAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list_item.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "editable", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListItemAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean | EditMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ListItemAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list_item.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Sticky", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "Sticky", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list_item.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "EditMode", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "EditMode", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.arkui.advanced.ChipGroup.d.ets", + "api_info": { + "line": 1, + "problem": "", + "api_name": "suffixIcon", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ChipGroupItemOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "IconOptions" + }, + "import_path": [ + "@ohos.arkui.advanced.ChipGroup" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouterInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "NavRouterAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouter", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "NavRouterInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "mode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavRouterAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "mode", + "type": "NavRouteMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavRouterAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onStateChange", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavRouterAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(isActivated: boolean) => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "NavRouterAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouterAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "NavRouterAttribute", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "REPLACE", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavRouteMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PUSH", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavRouteMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PUSH_WITH_RECREATE", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavRouteMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouteMode", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "NavRouteMode", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouterAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavRouterInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "RouteInfo", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavRouterAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouterAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavRouterInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "NavRouterAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavRouterInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "NavRouterInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "param", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouteInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "unknown" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "name", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouteInfo", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/nav_router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "RouteInfo", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "RouteInfo", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigatorInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Navigator", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "NavigatorInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "params", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "object", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "target", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "type", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "NavigationType", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "active", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigatorAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "NavigatorAttribute", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigatorAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigatorAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "NavigatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{ target: string; type: NavigationType }", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "NavigatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigatorInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "NavigatorInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Replace", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavigationType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Back", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavigationType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Push", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "NavigationType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/navigator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NavigationType", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "NavigationType", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SizeType", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainer", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "GridContainerInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainerInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "GridContainerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainerInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "GridContainerInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainerOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "GridContainerOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainerAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "GridContainerAttribute", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "index", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "prompt.ShowDialogSuccessResponse", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ParamsInterface", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string]: Object;\n}" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/matrix2d.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "rotate", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Matrix2D", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "rx", + "type": "number", + "is_optional": true, + "has_default": false + }, + { + "name": "ry", + "type": "number", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "Matrix2D" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/matrix2d.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "multiply", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Matrix2D", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "other", + "type": "Matrix2D", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "Matrix2D" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onScroll", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(scrollOffset: number)", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ListAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/xcomponent.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "XComponentAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{ id: string; type: string; libraryname: string; controller: XComponentController }", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "XComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "COMPONENT", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "XComponentType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/arkui/XComponentNode.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "changeRenderType", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentNode", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "type", + "type": "NodeRenderType", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [ + "@ohos.arkui.node", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/arkui/XComponentNode.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDestroy", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentNode", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.node", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/arkui/XComponentNode.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onCreate", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentNode", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "Object", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.arkui.node", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/arkui/XComponentNode.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constructor", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "XComponentNode", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "uiContext", + "type": "UIContext", + "is_optional": false, + "has_default": false + }, + { + "name": "options", + "type": "RenderOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "id", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "type", + "type": "XComponentType", + "is_optional": false, + "has_default": false + }, + { + "name": "libraryName", + "type": "string", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "string)" + }, + "import_path": [ + "@ohos.arkui.node", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/arkui/XComponentNode.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "XComponentNode", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "XComponentNode", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.arkui.node", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GetShared", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "LocalStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "LocalStorage" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "CROSS_DEVICE", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "CopyOptions", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "BackRouterOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "BackRouterOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SetAndLink", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "defaultValue", + "type": "T", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SubscribedAbstractProperty" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Link", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AbilityComponentInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "AbilityComponentInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AbilityComponent", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "AbilityComponentInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.app.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "requestFullWindow", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "App", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RequestFullWindowOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.app", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "enableAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "EnableAlertBeforeBackPageOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SM", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowDialogOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/list.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onItemDelete", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(index: number)", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "ListAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Baseline", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "Edge", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "sizeType", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "GridContainerOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "SizeType" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "DeleteProp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PersistentStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "key", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/menu.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "fontSize", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "MenuAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "Length", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "MenuAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "invert", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Button", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "prompt.Button", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "shortName", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "buttons", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "prompt.ShowDialogOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "[Button, Button?, Button?]" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showActionMenu", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ActionMenuOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ActionMenuSuccessResponse", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "prompt.ActionMenuSuccessResponse", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showActionMenu", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ActionMenuOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Promise" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AbilityComponentAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AbilityComponentInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "{want: import('../api/@ohos.app.ability.Want').default}", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AbilityComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getLength", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ActionMenuOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "prompt.ActionMenuOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getParams", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "ParamsInterface" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "RouterOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "RouterOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onConnect", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AbilityComponentAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "()", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AbilityComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "cancel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DisableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "errMsg", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(errMsg: string) => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "enableAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "EnableAlertOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Set", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "newValue", + "type": "T", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "params", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "BackRouterOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Object" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.curves.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "steps", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "curves", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "count", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "end", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "string" + }, + "import_path": [ + "@ohos.curves", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/gridItem.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "forceRebuild", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "GridItemAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "GridItemAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Keys", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "IterableIterator" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "bottom", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string | number" + }, + "import_path": [ + "@system.prompt" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "staticClear", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "LG", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "4" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Has", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "scale", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ScaleOption", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showDialog", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowDialogOptions", + "is_optional": false, + "has_default": false + }, + { + "name": "callback", + "type": "AsyncCallback", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "duration", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number" + }, + "import_path": [ + "@system.prompt" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "transformPoint", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "[number, number]", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "[number, number]" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "message", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@system.prompt" + ], + "is_global": false + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "uri", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ShowDialogOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "ShowDialogOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "message", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createAnimator", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Animator", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "AnimatorOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorResult" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SetAndProp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "defaultValue", + "type": "S", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SubscribedAbstractProperty" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/progress.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "style", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ProgressOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "ProgressStyle" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "index", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ActionMenuSuccessResponse", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SetOrCreate", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "newValue", + "type": "T", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getState", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "RouterState" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "columns", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "GridContainerOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number | \"auto\"" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "cancel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "errMsg", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(errMsg: string) => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "complete", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "() => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "buttons", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ActionMenuOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "[Button, Button?, Button?, Button?, Button?, Button?]" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "color", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "Button", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PersistProp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PersistentStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "key", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "defaultValue", + "type": "T", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/list.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "editMode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ListAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "ListAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replace", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "path", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouterState", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.curves.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "spring", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "curves", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "velocity", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "mass", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "stiffness", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "damping", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "string" + }, + "import_path": [ + "@ohos.curves", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "RouterState", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "RouterState", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "MD", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "abilityName", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AbilityComponentAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "AbilityComponentAttribute", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "params", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouterOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "Object" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "name", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouterState", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "title", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowDialogOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "prompt", + "api_type": "NamespaceDeclaration", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "NamespaceDeclaration" + } + ], + "code_kind": 237, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "success", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "errMsg", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(errMsg: string) => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "DisableAlertBeforeBackPageOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "DisableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Auto", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ShowToastOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.prompt" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onDisconnect", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AbilityComponentAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "() => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AbilityComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "push", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ShowDialogSuccessResponse", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "ShowDialogSuccessResponse", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Prop", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "back", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "BackRouterOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "update", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorResult", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "AnimatorOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "combine", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "Matrix4Transit", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/alphabet_indexer.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onSelected", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AlphabetIndexerAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(index: number) => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AlphabetIndexerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showToast", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "prompt", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ShowToastOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "disableAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "disableAlertBeforeBackPage", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "DisableAlertBeforeBackPageOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "EnvProp", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Environment", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "key", + "type": "string", + "is_optional": false, + "has_default": false + }, + { + "name": "value", + "type": "S", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "IsMutable", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "XS", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "SizeType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "complete", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DisableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "() => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "duration", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Get", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "T | undefined" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Keys", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PersistentStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Array" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "index", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouterState", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "number" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "text", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "prompt.Button", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/ability_component.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AbilityComponentInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "AbilityComponentAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "rotate", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RotateOption", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "success", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "DisableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "errMsg", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(errMsg: string) => void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "margin", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "GridContainerOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number | string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "GridContainerAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "GridContainerInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "GridContainerOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "GridContainerAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PersistProps", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PersistentStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "properties", + "type": "{\n key: string;\n defaultValue: any;\n }[]", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "bottom", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string | number" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Keys", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Environment", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Array" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "copy", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "title", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "prompt.ActionMenuOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid_container.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "gutter", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "GridContainerOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number | string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "deviceId", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "EnvProps", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Environment", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "props", + "type": "{\n key: string;\n defaultValue: any;\n }[]", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Clear", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "replace", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "clear", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "Router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "void" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "uri", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "BackRouterOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/rect.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "RectInStance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "RectAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.curves.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "init", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "curves", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "curve", + "type": "Curve", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "string" + }, + "import_path": [ + "@ohos.curves", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.app.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "screenOnVisible", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "App", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "ScreenOnVisibleOptions", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.app", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Delete", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "propName", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "boolean" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/common_ts_ets_api.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Size", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AppStorage", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "number" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "bundleName", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "message", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "ShowDialogOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "string" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.matrix4.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "translate", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "matrix4", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "TranslateOption", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "Matrix4Transit" + }, + "import_path": [ + "@ohos.matrix4", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ShowToastOptions", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "prompt.ShowToastOptions", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@ohos.prompt", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "push", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "router", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "options", + "type": "RouterOptions", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@ohos.router", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Router", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "Router", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "uri", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RouterOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/@system.router.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "message", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "EnableAlertBeforeBackPageOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "string" + }, + "import_path": [ + "@system.router" + ], + "is_global": false + }, + { + "file_path": "api/bundle/elementName.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ElementName", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "ElementName", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "elementName" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Mini", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelMode", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "PanelMode", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Half", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Full", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelMode", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/inspector.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getInspectorNodes", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "object" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onrepeat", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorResult", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "() => void" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "oncancel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorResult", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "() => void" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onfinish", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorResult", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [], + "method_return_type": "() => void" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@ohos.animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onframe", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorResult", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "progress", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "(progress: number) => void" + }, + "import_path": [ + "@ohos.animator", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/grid.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onScroll", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "GridAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(scrollOffset: number)", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "GridAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onChange", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(width: number)", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Panel", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "PanelInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onHeightChange", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "callback", + "type": "(value: number)", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showCloseIcon", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "backgroundMask", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "color", + "type": "ResourceColor", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "show", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "miniHeight", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number | string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "halfHeight", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number | string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "fullHeight", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number | string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "customHeight", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "Dimension | PanelHeight", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "dragBar", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "type", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "PanelType", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "mode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "PanelMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "PanelAttribute", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "PanelInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "show", + "type": "boolean", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "PanelAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "PanelInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "WRAP_CONTENT", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelHeight", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelHeight", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "PanelHeight", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "CUSTOM", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Temporary", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "2" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Foldable", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "1" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Minibar", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "PanelType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "0" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/panel.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "PanelType", + "api_type": "EnumDeclaration", + "parent_api": [ + { + "api_name": "PanelType", + "api_type": "" + } + ], + "code_kind": 241, + "api_optional": false + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/refresh.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "friction", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "RefreshOptions", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": true, + "method_return_type": "number | string" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/common/full/global.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createLocalParticleAbility", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "name", + "type": "string", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/common/lite/global.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "createLocalParticleAbility", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "name", + "type": "string", + "is_optional": true, + "has_default": false + } + ], + "method_return_type": "any" + }, + "import_path": [ + "global" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/inspector.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "getInspectorNodeById", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "id", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "object" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AnimatorAttribute", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "string", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AnimatorAttribute", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "playMode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "PlayMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AnimatorInterface", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "duration", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "motion", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "SpringMotion | FrictionMotion | ScrollMotion", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "delay", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onRepeat", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "()", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "state", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "AnimationStatus", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "iterations", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onPause", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "()", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onStart\n\n", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "()", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "curve\n", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorInterface", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "Curve", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "Animator", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "AnimatorInterface" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "AnimatorInstance", + "api_type": "PropertySignature", + "parent_api": [ + { + "api_name": "unnamed", + "api_type": "" + } + ], + "code_kind": 156, + "api_optional": false, + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onFinish", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "() => void", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onCancel", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "()", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "fillMode", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "FillMode", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "onFrame", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "AnimatorAttribute", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "event", + "type": "(value: number)", + "is_optional": false, + "has_default": true + } + ], + "method_return_type": "AnimatorAttribute" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constructor", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "ScrollMotion", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "position", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "velocity", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "min", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "max", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "prop", + "type": "SpringProp", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SpringProp)" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constructor", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "SpringMotion", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "start", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "end", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "velocity", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "prop", + "type": "SpringProp", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "SpringProp)" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SpringProp", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "SpringProp", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constructor", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "FrictionMotion", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "friction", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "position", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "velocity", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number)" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts\n", + "api_info": { + "line": 1, + "problem": "", + "api_name": "FrictionMotion", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "FrictionMotion", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "SpringMotion", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "ScrollMotion", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "ScrollMotion", + "api_type": "ClassDeclaration", + "parent_api": [ + { + "api_name": "ScrollMotion", + "api_type": "ClassDeclaration" + } + ], + "code_kind": 239, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@internal/component/ets/animator.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "constructor", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "SpringProp", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "mass", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "stiffness", + "type": "number", + "is_optional": false, + "has_default": false + }, + { + "name": "damping", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "number)" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "api/@system.prompt.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "showToast", + "api_type": "InterfaceDeclaration", + "parent_api": [ + { + "api_name": "Prompt", + "api_type": "" + } + ], + "code_kind": 240, + "api_optional": false, + "method_return_type": "" + }, + "import_path": [ + "@system.prompt" + ], + "is_global": false + }, + { + "file_path": "api/@system.app.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "setImageRawDataCacheSize", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "App", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.app", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.app.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "setImageCacheCount", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "App", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.app", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@system.app.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "setImageFileCacheSize", + "api_type": "MethodSignature", + "parent_api": [ + { + "api_name": "App", + "api_type": "" + } + ], + "code_kind": 173, + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "number", + "is_optional": false, + "has_default": false + } + ], + "method_return_type": "void" + }, + "import_path": [ + "@system.app", + "@kit.ArkUI" + ], + "is_global": false + }, + { + "file_path": "api/@internal/component/ets/enums.d.ts", + "api_info": { + "line": 1, + "problem": "", + "api_name": "NODE", + "api_type": "EnumMember", + "parent_api": [ + { + "api_name": "XComponentType", + "api_type": "" + } + ], + "code_kind": 242, + "api_optional": false, + "method_return_type": "3" + }, + "import_path": [], + "is_global": true + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts index 1dbd42bcd144fda4da05f40797f7fb77ed3b410f..cbe8c04e23c9a22e7096dc694535d1b8df47d34c 100644 --- a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts +++ b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts @@ -119,7 +119,7 @@ export function generateReportFileSync(reportName: string, reportData: any, repo fs.mkdirSync(path.dirname(reportFilePath), { recursive: true }); fs.writeFileSync(reportFilePath, JSON.stringify(reportData, null, 2)); } catch (error) { - Logger.error(`Error generating report file:${error}`); + Logger.error(`Error generating report file:${error}`); } } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 7625adfd50722d85f357c1a3b252eb4e2421df1c..738928269d0a778b945d0e0c0b9c49f2cf55b3c8 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -46,7 +46,7 @@ import { ETS } from './consts/TsSuffix'; import { STRINGLITERAL_NUMBER, STRINGLITERAL_NUMBER_ARRAY } from './consts/StringLiteral'; import { ETS_MODULE, PATH_SEPARATOR, VALID_OHM_COMPONENTS_MODULE_PATH } from './consts/OhmUrl'; import { EXTNAME_ETS, EXTNAME_JS, EXTNAME_D_ETS } from './consts/ExtensionName'; -import { STRING_ERROR_LITERAL } from './consts/Literals'; +import { CONCAT_ARRAY, STRING_ERROR_LITERAL } from './consts/Literals'; export const PROMISE_METHODS = new Set(['all', 'race', 'any', 'resolve', 'allSettled']); export const SYMBOL = 'Symbol'; @@ -115,12 +115,23 @@ export class TsUtils { return false; } - static isEnumType(tsType: ts.Type): boolean { + static isEnumType(tsType: ts.Type, checkUnion?: boolean): boolean { // when type equals `typeof `, only symbol contains information about it's type. const isEnumSymbol = tsType.symbol && this.isEnum(tsType.symbol); // otherwise, we should analyze flags of the type itself const isEnumType = !!(tsType.flags & ts.TypeFlags.Enum) || !!(tsType.flags & ts.TypeFlags.EnumLiteral); - return isEnumSymbol || isEnumType; + + if (isEnumSymbol || isEnumType) { + return true; + } + + if (checkUnion && tsType.isUnion()) { + return tsType.types.some((t) => { + return TsUtils.isEnumType(t); + }); + } + + return false; } static isEnum(tsSymbol: ts.Symbol): boolean { @@ -334,7 +345,7 @@ export class TsUtils { TsUtils.isTypeReference(tsType) && tsType.typeArguments?.length === 1 && tsType.target.typeParameters?.length === 1 && - tsType.getSymbol()?.getName() === 'ConcatArray' + tsType.getSymbol()?.getName() === CONCAT_ARRAY ); } @@ -787,7 +798,7 @@ export class TsUtils { return false; } // #14569: Check for Function type. - if (this.areCompatibleFunctionals(lhsType, rhsType)) { + if (this.skipStructuralTypingCheckForFunctionals(lhsType, rhsType)) { return false; } if (rhsType.isUnion() || lhsType.isUnion()) { @@ -1361,13 +1372,18 @@ export class TsUtils { parentSymbolCache = new Map(); - getParentSymbolName(symbol: ts.Symbol): string | undefined { + getParentSymbolName(symbol: ts.Symbol | undefined): string | undefined { + if (!symbol) { + return undefined; + } const cached = this.parentSymbolCache.get(symbol); if (cached) { return cached; } - const name = this.tsTypeChecker.getFullyQualifiedName(symbol); + const fullName = this.tsTypeChecker.getFullyQualifiedName(symbol); + const match = fullName.match(/['"](.*)['"]\.(.*)/); + const name = match ? match[2] : fullName; const dotPosition = name.lastIndexOf('.'); const result = dotPosition === -1 ? undefined : name.substring(0, dotPosition); this.parentSymbolCache.set(symbol, result); @@ -2035,115 +2051,59 @@ export class TsUtils { return type; } - private areCompatibleFunctionals(lhsType: ts.Type, rhsType: ts.Type): boolean { + private skipStructuralTypingCheckForFunctionals(lhsType: ts.Type, rhsType: ts.Type): boolean { return ( (this.isStdFunctionType(lhsType) || TsUtils.isFunctionalType(lhsType)) && (this.isStdFunctionType(rhsType) || TsUtils.isFunctionalType(rhsType)) ); } - isIncompatibleFunctionals(lhsTypeNode: ts.TypeNode, rhsExpr: ts.Expression): boolean { - if (ts.isUnionTypeNode(lhsTypeNode)) { - for (let i = 0; i < lhsTypeNode.types.length; i++) { - if (!this.isIncompatibleFunctional(lhsTypeNode.types[i], rhsExpr)) { - return false; + areCompatibleFunctionalTypes(lhsType: ts.Type, rhsType: ts.Type): boolean { + if (lhsType.isUnion()) { + for (let i = 0; i < lhsType.types.length; i++) { + if (this.areCompatibleFunctionalTypes(lhsType.types[i], rhsType)) { + return true; } } - return true; + return false; } - return this.isIncompatibleFunctional(lhsTypeNode, rhsExpr); - } - private isIncompatibleFunctional(lhsTypeNode: ts.TypeNode, rhsExpr: ts.Expression): boolean { - const lhsType = this.tsTypeChecker.getTypeAtLocation(lhsTypeNode); - const rhsType = this.tsTypeChecker.getTypeAtLocation(rhsExpr); - const lhsParams = this.getLhsFunctionParameters(lhsTypeNode); - const rhsParams = this.getRhsFunctionParameters(rhsExpr); + const lhsSignature = TsUtils.getFunctionalTypeSignature(lhsType); + const rhsSignature = TsUtils.getFunctionalTypeSignature(rhsType); + if (!lhsSignature || !rhsSignature) { + return true; + } - if (lhsParams !== rhsParams) { + if (lhsSignature.parameters.length < rhsSignature.parameters.length) { return false; } - if (TsUtils.isFunctionalType(lhsType)) { - const lhsFunctionReturnType = this.getFunctionType(lhsTypeNode); - const rhsReturnType = this.getReturnTypeFromExpression(rhsType); - if (lhsFunctionReturnType && rhsReturnType) { - return TsUtils.isVoidType(lhsFunctionReturnType) && !TsUtils.isVoidType(rhsReturnType); - } + const lhsReturnType = lhsSignature.getReturnType(); + const rhsReturnType = rhsSignature.getReturnType(); + if (lhsReturnType && rhsReturnType) { + return !(TsUtils.isVoidType(lhsReturnType) && !TsUtils.isVoidType(rhsReturnType)); } - return false; + + return true; } static isVoidType(tsType: ts.Type): boolean { return (tsType.getFlags() & ts.TypeFlags.Void) !== 0; } - private getRhsFunctionParameters(expr: ts.Expression): number { - const type = this.tsTypeChecker.getTypeAtLocation(expr); - const signatures = this.tsTypeChecker.getSignaturesOfType(type, ts.SignatureKind.Call); - if (signatures.length > 0) { - const signature = signatures[0]; - return signature.parameters.length; - } - return 0; - } - - private getLhsFunctionParameters(typeNode: ts.TypeNode): number { - let current: ts.TypeNode = typeNode; - while (ts.isTypeReferenceNode(current)) { - const symbol = this.tsTypeChecker.getSymbolAtLocation(current.typeName); - if (!symbol) { - break; - } - - const declaration = symbol.declarations?.[0]; - if (!declaration || !ts.isTypeAliasDeclaration(declaration)) { - break; - } - - current = declaration.type; - } - if (ts.isFunctionTypeNode(current)) { - return current.parameters.length; - } - return 0; - } - - private getFunctionType(typeNode: ts.TypeNode): ts.Type | undefined { - let current: ts.TypeNode = typeNode; - while (ts.isTypeReferenceNode(current)) { - const symbol = this.tsTypeChecker.getSymbolAtLocation(current.typeName); - if (!symbol) { - break; - } - - const declaration = symbol.declarations?.[0]; - if (!declaration || !ts.isTypeAliasDeclaration(declaration)) { - break; - } - - current = declaration.type; - } - if (ts.isFunctionTypeNode(current)) { - return this.tsTypeChecker.getTypeAtLocation(current.type); - } - return undefined; + static isFunctionalType(type: ts.Type): boolean { + const callSigns = type.getCallSignatures(); + return callSigns && callSigns.length > 0; } - private getReturnTypeFromExpression(type: ts.Type): ts.Type | undefined { - const signatures = this.tsTypeChecker.getSignaturesOfType(type, ts.SignatureKind.Call); - if (signatures.length > 0) { - const returnType = this.tsTypeChecker.getReturnTypeOfSignature(signatures[0]); - return returnType; + static getFunctionalTypeSignature(type: ts.Type): ts.Signature | undefined { + const callSigns = type.getCallSignatures(); + if (callSigns.length > 0) { + return callSigns[0]; } return undefined; } - static isFunctionalType(type: ts.Type): boolean { - const callSigns = type.getCallSignatures(); - return callSigns && callSigns.length > 0; - } - static getFunctionReturnType(type: ts.Type): ts.Type | null { const signatures = type.getCallSignatures(); if (signatures.length === 0) { @@ -3504,17 +3464,39 @@ export class TsUtils { } } - static isNumberLike(type: ts.Type, typeText: string, isEnum: boolean): boolean { + isNumberLike(type: ts.Type): boolean { const typeFlags = type.flags; + const typeText = this.tsTypeChecker.typeToString(type); const isNumberLike = typeText === STRINGLITERAL_NUMBER || typeText === STRINGLITERAL_NUMBER_ARRAY || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0 || - isEnum; + this.isNumericEnumType(type); return isNumberLike; } + isNumericEnumType(type: ts.Type): boolean { + if (!TsUtils.isEnumType(type, true)) { + return false; + } + const declarations = type.symbol?.getDeclarations() || []; + const enumMemberDecl = declarations.find(ts.isEnumMember); + if (enumMemberDecl) { + const value = this.tsTypeChecker.getConstantValue(enumMemberDecl); + return typeof value === STRINGLITERAL_NUMBER; + } + + const enumDecl = declarations.find(ts.isEnumDeclaration); + if (enumDecl) { + return enumDecl.members.every((member) => { + const memberType = this.tsTypeChecker.getTypeAtLocation(member.name); + return (memberType.flags & ts.TypeFlags.NumberLike) !== 0; + }); + } + return false; + } + static getModuleName(node: ts.Node): string | undefined { const currentFilePath = node.getSourceFile().fileName; if (!currentFilePath.includes('src')) { diff --git a/ets2panda/linter/src/lib/utils/consts/ArktsWhiteApiPaths.ts b/ets2panda/linter/src/lib/utils/consts/ArktsWhiteApiPaths.ts index 113c4bdd7992092735bc166f897822ce1132c74c..c945fcd33c43ea75cf3dc6385861979004e8f531 100755 --- a/ets2panda/linter/src/lib/utils/consts/ArktsWhiteApiPaths.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArktsWhiteApiPaths.ts @@ -14,4 +14,4 @@ */ export const ARKTS_WHITE_API_PATH_TEXTSTYLE = 'component/styled_string.d.ts'; -export const COMMON_UNION_MEMBER_ACCESS_WHITELIST = new Set(['ArrayBufferLike', 'IteratorResult']); \ No newline at end of file +export const COMMON_UNION_MEMBER_ACCESS_WHITELIST = new Set(['ArrayBufferLike', 'IteratorResult']); diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index 22e7943117e3c7488d2ca2a88ba0ec0b833004e9..40063205dac9d0f9b4ed214aec4b8922450b3a67 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -20,11 +20,9 @@ export const INSTANCE_IDENTIFIER = 'instance'; export const COMMON_METHOD_IDENTIFIER = 'CommonMethod'; export const APPLY_STYLES_IDENTIFIER = 'applyStyles'; export const STATE_STYLES = 'stateStyles'; -export const ARKUI_PACKAGE_NAME = '@kit.ArkUI'; export const VALUE_IDENTIFIER = 'value'; export const INDENT_STEP = 2; export const MAKE_OBSERVED = 'makeObserved'; -export const ARKUI_STATE_MANAGEMENT = '@ohos.arkui.StateManagement'; export const NEW_PROP_DECORATOR_SUFFIX = 'Ref'; export enum CustomInterfaceName { @@ -36,7 +34,10 @@ export enum CustomInterfaceName { Observed = 'Observed', CustomLayout = 'CustomLayout', CustomStyles = 'CustomStyles', - Repeat = 'Repeat' + Repeat = 'Repeat', + WrappedBuilder = 'WrappedBuilder', + wrapBuilder = 'wrapBuilder', + BuilderNode = 'BuilderNode' } export enum StorageTypeName { @@ -55,6 +56,11 @@ export enum PropFunctionName { SetAndProp = 'setAndProp' } +export enum BuilderNodeFunctionName { + Build = 'build', + Update = 'update' +} + export const observedDecoratorName: Set = new Set([ 'State', 'Prop', @@ -92,3 +98,9 @@ export const PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME = 'allowOverride'; export const VIRTUAL_SCROLL_IDENTIFIER = 'virtualScroll'; export const DISABLE_VIRTUAL_SCROLL_IDENTIFIER = 'disableVirtualScroll'; + +export const ARKUI_MODULE = '@kit.ArkUI'; +export const STATE_MANAGEMENT_MODULE = '@ohos.arkui.StateManagement'; + +export const BUILDERNODE_D_TS = 'BuilderNode.d.ts'; +export const NESTING_BUILDER_SUPPORTED = 'nestingBuilderSupported'; diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts index f8ab0145c549c24f4e0c3526f3aa45adf7e98afc..f95f5d338f6a74f4e4c750f916f458696f96dfc3 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts @@ -497,6 +497,8 @@ export const arkuiImportList: Set = new Set([ 'GestureRecognizerState', 'GestureStyle', 'GestureType', + 'getInspectorByKey', + 'getInspectorTree', 'GetItemMainSizeByIndex', 'GradientDirection', 'Grid', @@ -1256,6 +1258,9 @@ export const arkuiImportList: Set = new Set([ 'SelectionMenuOptionsExt', 'SelectionOptions', 'Sendable', + 'sendKeyEvent', + 'sendMouseEvent', + 'sendTouchEvent', 'Serializer', 'ShadowOptions', 'ShadowStyle', @@ -1612,7 +1617,9 @@ export const arkuiImportList: Set = new Set([ 'px2vp', 'setAppBgColor', 'sharedTransitionOptions', - 'vp2px' + 'vp2px', + '$r', + '$rawfile' ]); export const arkTsBuiltInTypeName: Set = new Set([ diff --git a/ets2panda/linter/src/lib/utils/consts/AsyncLifecycleSDK.ts b/ets2panda/linter/src/lib/utils/consts/AsyncLifecycleSDK.ts index b589d85b4fee72146258cba77e3403245fa0355e..64ef7604190a31f48916e6272ee8a9778a70fbcb 100644 --- a/ets2panda/linter/src/lib/utils/consts/AsyncLifecycleSDK.ts +++ b/ets2panda/linter/src/lib/utils/consts/AsyncLifecycleSDK.ts @@ -29,3 +29,5 @@ export const ASYNC_LIFECYCLE_SDK_LIST = new Set([ 'AutoFillExtensionAbility', 'ServiceExtensionAbility' ]); + +export const ABILITY_LIFECYCLE_SDK = 'ApplicationContext'; diff --git a/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts b/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts index a4912892800883dfaeacebb40af6034e8c9ab398..297b5fba00b1328a2e454f5989ebef0765b9fa2f 100644 --- a/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts +++ b/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts @@ -46,9 +46,8 @@ export const BUILTIN_DISABLE_CALLSIGNATURE = [ 'URIError' ]; -export const BUILTIN_CONSTRUCTORS = [ - 'Boolean', - 'Number', - 'Object', - 'String' -]; \ No newline at end of file +export const BUILTIN_CONSTRUCTORS = ['Boolean', 'Number', 'Object', 'String']; + +export const COLLECTION_TYPES = new Set(['Map', 'Set', 'WeakMap', 'WeakSet']); + +export const COLLECTION_METHODS = new Set(['add', 'delete', 'get', 'has', 'set']); diff --git a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts index a7c1698e3ba00a285e16df6ee6b1c418f3832d4b..331a36bb29639f47336a980fbe78db1f32e6ab0f 100644 --- a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts @@ -14,4 +14,6 @@ */ export const COLLECTIONS_TEXT = 'collections'; +export const ARKTS_COLLECTIONS_MODULE = '@arkts.collections'; +export const BIT_VECTOR = 'BitVector'; export const COLLECTIONS_MODULES = ['@arkts.collections', '@kit.ArkTS']; diff --git a/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts b/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cdf0e2aba745f88fd8d53e26ef0bca335c0141e --- /dev/null +++ b/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +export enum DeprecateProblem { + NoDeprecatedApi = 'NoDeprecatedApi' +} + +export enum DEPRECATE_CHECK_KEY { + PARENT_NAME = 'parentName', + PARAM_SET = 'parameters', + RETURN_TYPE = 'returnType', + FILE_NAME = 'fileName' +} + +export const DEPRECATE_UNNAMED = 'unnamed'; diff --git a/ets2panda/linter/src/lib/utils/consts/DeprecatedApi.ts b/ets2panda/linter/src/lib/utils/consts/DeprecatedApi.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc29b7df097199267fe022f3c6eff8ce51b8c7ff --- /dev/null +++ b/ets2panda/linter/src/lib/utils/consts/DeprecatedApi.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 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. + */ + +export const propertyAccessReplacements = new Map([ + ['TextPickerDialog.show', 'showTextPickerDialog'], + ['DatePickerDialog.show', 'showDatePickerDialog'], + ['ActionSheet.show', 'showActionSheet'], + ['AlertDialog.show', 'showAlertDialog'], + ['componentSnapshot.createFromBuilder', 'getComponentSnapshot().createFromBuilder'], + ['componentSnapshot.get', 'getComponentSnapshot().get'], + ['MeasureText.measureTextSize', 'createMeasureText.measureTextSize'], + ['MeasureText.measureText', 'createMeasureText.measureText'], + ['dragController.getDragPreview', 'createDragController.getDragPreview'], + ['dragController.createDragAction', 'createDragController.createDragAction'], + ['dragController.executeDrag', 'createDragController.executeDrag'], + ['LocalStorage.getShared', 'getSharedLocalStorage'], + ['inspector.createComponentObserver', 'createInspector.createComponentObserver'], + ['Animator.create', 'createAnimator'], + ['mediaquery.matchMediaSync', 'createMediaQuery.matchMediaSync'], + ['componentUtils.getRectangleById', 'getComponentUtils().getRectangleById'], + ['promptAction.showToast', 'getPromptAction.showToast'], + ['promptAction.showDialog', 'getPromptAction.showDialog'], + ['promptAction.openCustomDialog', 'getPromptAction.openCustomDialog'], + ['promptAction.closeCustomDialog', 'getPromptAction.closeCustomDialog'], + ['promptAction.showActionMenu', 'getPromptAction.showActionMenu'], + ['TimePickerDialog.show', 'showTimePickerDialog'], + ['router.pushUrl', 'getRouter.pushUrl'], + ['router.replaceUrl', 'getRouter.replaceUrl'], + ['router.back', 'getRouter.back'], + ['router.clear', 'getRouter.clear'], + ['router.getLength', 'getRouter.getLength'], + ['router.getState', 'getRouter.getState'], + ['router.getStateByIndex', 'getRouter.getStateByIndex'], + ['router.getStateByUrl', 'getRouter.getStateByUrl'], + ['router.showAlertBeforeBackPage', 'getRouter.showAlertBeforeBackPage'], + ['router.hideAlertBeforeBackPage', 'getRouter.hideAlertBeforeBackPage'], + ['router.getParams', 'getRouter.getParams'], + ['router.pushNamedRoute', 'getRouter.pushNamedRoute'], + ['router.replaceNamedRoute', 'getRouter.replaceNamedRoute'], + ['font.registerFont', 'createFont.registerFont'], + ['font.getSystemFontList', 'createFont.getSystemFontList'], + ['font.getFontByName', 'createFont.getFontByName'] +]); + +export const identifierReplacements = new Map([ + ['px2lpx', 'px2lpx'], + ['lpx2px', 'lpx2px'], + ['px2fp', 'px2fp'], + ['fp2px', 'fp2px'], + ['px2vp', 'px2vp'], + ['vp2px', 'vp2px'], + ['getContext', 'getHostContext'], + ['animateTo', 'animateTo'] +]); diff --git a/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts b/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts index 198e45afb177dd2cd24d452d985aed11f79571af..de0c40e18679dc734fa930fe89e9eab30f724314 100644 --- a/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts +++ b/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts @@ -33,5 +33,6 @@ export const EXTENDED_BASE_TYPES = new Map([ ['ReadonlyArray', ['ConcatArray']], ['Array', ['ReadonlyArray']], ['Map', ['ReadonlyMap']], - ['Set', ['ReadonlySet']] + ['Set', ['ReadonlySet']], + ['Promise', ['PromiseLike']] ]); diff --git a/ets2panda/linter/src/lib/utils/consts/ExtensionName.ts b/ets2panda/linter/src/lib/utils/consts/ExtensionName.ts index 23a5b243cecb14e9f4a26b13f65dd0d435a8f926..efd5c03d9ad6dfa139e965704378a1a34b395c3d 100644 --- a/ets2panda/linter/src/lib/utils/consts/ExtensionName.ts +++ b/ets2panda/linter/src/lib/utils/consts/ExtensionName.ts @@ -22,3 +22,4 @@ export const EXTNAME_MJS: string = '.mjs'; export const EXTNAME_CJS: string = '.cjs'; export const EXTNAME_D_TS: string = '.d.ts'; export const EXTNAME_D_ETS: string = '.d.ets'; +export const EXTNAME_JSON: string = '.json'; diff --git a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts index afd7fcc08737fc52d29b37f99fa38852b6417450..6d4e230d392679d3c8957979217b92d8b85130ea 100644 --- a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts @@ -66,7 +66,6 @@ export const OBJECT_LITERAL = 'Object'; export const REFLECT_LITERAL = 'Reflect'; export const NONE = 'none'; export type ForbidenAPICheckResult = 'Object' | 'Reflect' | 'none'; -export const LOAD = 'load'; export const GET_PROPERTY = 'getProperty'; export const SET_PROPERTY = 'setProperty'; export const TO_NUMBER = 'toNumber'; diff --git a/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts b/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts index 38a013ece2d59a515c1962bb37e7041da0a0fa43..1367fd24f22ecab951f3b1b37807b5cdc45644a0 100755 --- a/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts +++ b/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts @@ -16,3 +16,5 @@ export const LIKE_FUNCTION = 'Function'; export const LIKE_FUNCTION_CONSTRUCTOR = 'FunctionConstructor'; + +export const FORBIDDEN_FUNCTION_BODY = 'return this'; diff --git a/ets2panda/linter/src/lib/utils/consts/LimitedStandardUtilityTypes.ts b/ets2panda/linter/src/lib/utils/consts/LimitedStandardUtilityTypes.ts index 04f651d08023de840edbffdca60cdda456b7a534..fe772501207fdd19343441d3dd08b248eb152a5f 100644 --- a/ets2panda/linter/src/lib/utils/consts/LimitedStandardUtilityTypes.ts +++ b/ets2panda/linter/src/lib/utils/consts/LimitedStandardUtilityTypes.ts @@ -32,3 +32,24 @@ export const LIMITED_STANDARD_UTILITY_TYPES = [ 'Pick', 'Awaited' ]; + +export const LIMITED_STANDARD_UTILITY_TYPES2 = [ + 'Uncapitalize', + 'Capitalize', + 'Lowercase', + 'Uppercase', + 'ThisType', + 'OmitThisParameter', + 'ThisParameterType', + 'InstanceType', + 'ReturnType', + 'ConstructorParameters', + 'Parameters', + 'NonNullable', + 'Extract', + 'Exclude', + 'Omit', + 'Pick', + 'Awaited', + 'NoInfer' +]; diff --git a/ets2panda/linter/src/lib/utils/consts/Literals.ts b/ets2panda/linter/src/lib/utils/consts/Literals.ts index 4b543492615e2d214376244cdfcf0408aad1243b..df8054e34348c8645cc37d7dc6a08177220de87c 100644 --- a/ets2panda/linter/src/lib/utils/consts/Literals.ts +++ b/ets2panda/linter/src/lib/utils/consts/Literals.ts @@ -14,3 +14,4 @@ */ export const STRING_ERROR_LITERAL = 'Error'; +export const CONCAT_ARRAY = 'ConcatArray'; diff --git a/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json index 79538ccf9be3b4529be2e9e2784427a3101e063a..971a2bc65f74c58502743a89075ad9c35f5df3f4 100644 --- a/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json +++ b/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json @@ -124,26 +124,6 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, - { - "line": 27, - "column": 3, - "endLine": 27, - "endColumn": 35, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 3, - "endLine": 28, - "endColumn": 32, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 26, "column": 9, @@ -154,6 +134,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 8, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 37, "column": 1, @@ -244,26 +234,6 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, - { - "line": 48, - "column": 5, - "endLine": 48, - "endColumn": 41, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 49, - "column": 5, - "endLine": 49, - "endColumn": 34, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 47, "column": 12, @@ -274,6 +244,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 49, + "column": 9, + "endLine": 49, + "endColumn": 10, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 57, "column": 11, @@ -325,4 +305,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets similarity index 87% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets rename to ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets index 3ad92e086593e36f51eb220f7bc29da6b358615f..d94d1d8c0ea0922836c9ad26a7a4557e79a06d6f 100644 --- a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets +++ b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets @@ -15,6 +15,6 @@ import { ArkTSUtils } from '../main/oh_modules/@kit.ArkTS'; -let lock1 = new ArkTSUtils.locks.AsyncLock(); +let lock1 = new ArkTSUtils.locks.AsyncLock(); -let lock2 = new ArkTSUtils.locks.AsyncLock(); \ No newline at end of file +let lock2 = new ArkTSUtils.locks.AsyncLock(); diff --git a/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.args.json b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..6958168fef2a70000342107f7d5f2b5805c14fae --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.arkts2.json similarity index 100% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.arkts2.json rename to ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.arkts2.json diff --git a/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.autofix.json b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..34839afbd9029ddd99fd0f2652974291a529d949 --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.autofix.json @@ -0,0 +1,60 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 28, + "endLine": 18, + "endColumn": 33, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 678, + "end": 710, + "replacementText": "new AsyncLock()", + "line": 18, + "column": 28, + "endLine": 18, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 33, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 725, + "end": 757, + "replacementText": "new AsyncLock()", + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.json b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.json similarity index 100% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.json rename to ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.json diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.ets b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.ets similarity index 87% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.ets rename to ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.ets index c8cd4f5b4806bbcd647d69ba06a3b5ca59ef0ae9..e4b1c6ec60c6b0097a737fb1418e2df476444fcb 100644 --- a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.ets +++ b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + import { ArkTSUtils } from '../main/oh_modules/@kit.ArkTS'; -let lock1 = new ArkTSUtils.locks.AsyncLock(); +let lock1 = new AsyncLock(); -let lock2 = new ArkTSUtils.locks.AsyncLock(); \ No newline at end of file +let lock2 = new AsyncLock(); diff --git a/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.json b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..7b88b28ed4bfd2b54b406dc7702583e2fede470e --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_arktsutils_locks_asynclock.ets.migrate.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 28, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 17, + "endLine": 18, + "endColumn": 26, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 28, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 17, + "endLine": 20, + "endColumn": 26, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/Back.ets b/ets2panda/linter/test/deprecatedapi/Back.ets new file mode 100755 index 0000000000000000000000000000000000000000..9f52ca72486548b68cc1538a40cdd998d6cb1e6b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Back.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 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 { NavigationType } from './sdk/api/navigator' + +@Entry +@Component +struct Index { + build() { + Column() { + Navigator() { + Text('Back') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Back) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Back.ets.args.json b/ets2panda/linter/test/deprecatedapi/Back.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Back.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Back.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/Back.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..953309bf5169e6ad6b14c20ac3c2c1908eb1c06c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Back.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 21, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 9, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 21, + "endLine": 31, + "endColumn": 30, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Back.ets.json b/ets2panda/linter/test/deprecatedapi/Back.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Back.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Baseline.ets b/ets2panda/linter/test/deprecatedapi/Baseline.ets new file mode 100755 index 0000000000000000000000000000000000000000..8890bc6380cf7b18a961f26f2ebfef1280c9e0c9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Baseline.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 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 { Edge } from './sdk/api/enums'; + +@Entry +@Component +struct ScrollExample { + scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item: number) => { + Text(item.toString()) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, (item: string) => item) + }.width('100%') + } + .onScrollStop(() => { + const side1 = Edge.Baseline; + console.info('Scroll Stop'); + }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Baseline.ets.args.json b/ets2panda/linter/test/deprecatedapi/Baseline.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Baseline.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Baseline.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/Baseline.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..650f2fd5a3ed574766f993b337bc1be8df51b3ac --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Baseline.ets.arkts2.json @@ -0,0 +1,288 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 28, + "endLine": 21, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 31, + "endLine": 21, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 34, + "endLine": 21, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 37, + "endLine": 21, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 40, + "endLine": 21, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 43, + "endLine": 21, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 46, + "endLine": 21, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 49, + "endLine": 21, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 52, + "endLine": 21, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 55, + "endLine": 21, + "endColumn": 56, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 23, + "endLine": 30, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 29, + "endLine": 32, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 25, + "endLine": 33, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 30, + "endLine": 35, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 15, + "endLine": 40, + "endColumn": 36, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Stack\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 27, + "endLine": 24, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Alignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroll\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 13, + "endLine": 28, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 26, + "endLine": 34, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Baseline.ets.json b/ets2panda/linter/test/deprecatedapi/Baseline.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..a8df15b58dcdfae228f6576c7342da649e364ff0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Baseline.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 40, + "column": 15, + "endLine": 40, + "endColumn": 36, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/COMPONENT.ets b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets new file mode 100755 index 0000000000000000000000000000000000000000..04819456ce65d079caf6bdb63471e3ab80fb70b4 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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 { XComponentType } from './sdk/api/enums'; + +@Entry +@Component +struct Index { + @State isLock: boolean = true; + @State xc_width: number = 500; + @State xc_height: number = 700; + myXComponentController: XComponentController = new MyXComponentController(); + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { + XComponent({ + id: "XComponent", + type: XComponentType.COMPONENT, + controller: this.myXComponentController + }) + .onLoad(() => { + let surfaceRotation: SurfaceRotationOptions = { lock: this.isLock }; + this.myXComponentController.setXComponentSurfaceRotation(surfaceRotation); + console.log("getXComponentSurfaceRotation lock = " + + this.myXComponentController.getXComponentSurfaceRotation().lock); + }) + .width(this.xc_width) + .height(this.xc_height) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.args.json b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..a9c568265546411206e4dfae773a694d86bd76e3 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.arkts2.json @@ -0,0 +1,188 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 29, + "endLine": 21, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 30, + "endLine": 22, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 54, + "endLine": 23, + "endColumn": 76, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 30, + "endLine": 29, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponentController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 23, + "endLine": 26, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 37, + "endLine": 26, + "endColumn": 43, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 57, + "endLine": 26, + "endColumn": 66, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 91, + "endLine": 26, + "endColumn": 100, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 32, + "endLine": 33, + "endColumn": 54, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SurfaceRotationOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.json b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/COMPONENT.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets new file mode 100755 index 0000000000000000000000000000000000000000..24c939c273c158b902a870cd139a590c06ba19fd --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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 { CopyOptions } from './sdk/api/enums'; + +@Component +struct child { + @Link customPopup: boolean + build() { + Column({ space: 10 }) { + Text('CROSS_DEVICE') + .copyOption(CopyOptions.CROSS_DEVICE) + .borderWidth(1) + .gesture(LongPressGesture({ repeat: true }) + .onActionEnd((event: GestureEvent) => { + this.customPopup = !this.customPopup + }) + ) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.args.json b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..04f3aa0ea098609e6898b02581a2f186ed37ccf0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 21, + "endLine": 21, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 22, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Link\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 18, + "endLine": 25, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LongPressGesture\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 32, + "endLine": 26, + "endColumn": 44, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GestureEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.json b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/CROSS_DEVICE.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/DeleteProp.ets b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets new file mode 100755 index 0000000000000000000000000000000000000000..b5530beaf728f7870fffc6551318609e1a584d24 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 { PersistentStorage } from './sdk/api/common_ts_ets_api'; + +PersistentStorage.DeleteProp('data1') \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.args.json b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.json b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/DeleteProp.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..20a4233eb7cd7f491bf2b9b1f335c204fbbe3f5c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; + +class L{ + enableAlertBeforeBackPage() { + router.enableAlertBeforeBackPage({ + message: 'Message Info', + success: ()=> { + console.log('success'); + }, + cancel: ()=> { + console.log('cancel'); + } + }); + } +} +export default new L() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ad1e3864f573f4b56f2a05dbed170ca5c1ce596b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.json b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/EnableAlertBeforeBackPageOptions_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Link.ets b/ets2panda/linter/test/deprecatedapi/Link.ets new file mode 100755 index 0000000000000000000000000000000000000000..9f9a1cbd126972e8bea6af5b01d3ef1a17a57432 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Link.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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 { AppStorage } from './sdk/api/common_ts_ets_api'; + +AppStorage.setOrCreate('PropA', 47); +let link1: SubscribedAbstractProperty = AppStorage.Link('PropA'); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Link.ets.args.json b/ets2panda/linter/test/deprecatedapi/Link.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Link.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.autofix.json b/ets2panda/linter/test/deprecatedapi/Link.ets.arkts2.json old mode 100644 new mode 100755 similarity index 66% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.autofix.json rename to ets2panda/linter/test/deprecatedapi/Link.ets.arkts2.json index 31d218b8f0a1b62832a120b6cc681c9648010be7..b0b238ec95a62d4a0f8d19a87ed0962353affc6d --- a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.autofix.json +++ b/ets2panda/linter/test/deprecatedapi/Link.ets.arkts2.json @@ -15,23 +15,23 @@ ], "result": [ { - "line": 18, - "column": 28, - "endLine": 18, - "endColumn": 33, - "problem": "LimitedStdLibNoImportConcurrency", + "line": 17, + "column": 33, + "endLine": 17, + "endColumn": 35, + "problem": "NumericSemantics", "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 20, - "column": 28, - "endLine": 20, - "endColumn": 33, - "problem": "LimitedStdLibNoImportConcurrency", + "line": 18, + "column": 12, + "endLine": 18, + "endColumn": 38, + "problem": "UIInterfaceImport", "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/deprecatedapi/Link.ets.json b/ets2panda/linter/test/deprecatedapi/Link.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Link.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/NavigationType.ets b/ets2panda/linter/test/deprecatedapi/NavigationType.ets new file mode 100755 index 0000000000000000000000000000000000000000..8c497641465f3e2c0a335541fc21fd7f7e2601f2 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/NavigationType.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 { NavigationType } from './sdk/api/navigator' + +@Entry +@Component +struct Index { + build() { + Column() { + Navigator() { + Text('Replace') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Replace) + + Navigator() { + Text('Back') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Back) + + Navigator() { + Text('Push') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Push) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/NavigationType.ets.args.json b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/NavigationType.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..2300ab1d15da4194629a39513b17e1ae81d1f554 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.arkts2.json @@ -0,0 +1,148 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 21, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 21, + "endLine": 31, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 21, + "endLine": 38, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 9, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 7, + "endLine": 36, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 9, + "endLine": 37, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 21, + "endLine": 45, + "endColumn": 30, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/NavigationType.ets.json b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/NavigationType.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Push.ets b/ets2panda/linter/test/deprecatedapi/Push.ets new file mode 100755 index 0000000000000000000000000000000000000000..a357e4445ba5d249538943287e3f0469d8487de7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Push.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 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 { NavigationType } from './sdk/api/navigator' + +@Entry +@Component +struct Index { + build() { + Column() { + Navigator() { + Text('Push') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Push) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Push.ets.args.json b/ets2panda/linter/test/deprecatedapi/Push.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Push.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Push.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/Push.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..953309bf5169e6ad6b14c20ac3c2c1908eb1c06c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Push.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 21, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 9, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 21, + "endLine": 31, + "endColumn": 30, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Push.ets.json b/ets2panda/linter/test/deprecatedapi/Push.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Push.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Replace.ets b/ets2panda/linter/test/deprecatedapi/Replace.ets new file mode 100755 index 0000000000000000000000000000000000000000..c6ce7e7b51f477daabfe098c838ca3023c7c392b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Replace.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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 { NavigationType } from './sdk/api/navigator' + +@Entry +@Component +struct Index { + build() { + Column() { + Navigator() { + Text('Replace') + .fontSize(20) + } + .target('pages/NewPage') + .type(NavigationType.Replace) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Replace.ets.args.json b/ets2panda/linter/test/deprecatedapi/Replace.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Replace.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Replace.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/Replace.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..bab7d6fb70a529ad701e4e16c0660102bd3bb5b7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Replace.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 25, + "column": 21, + "endLine": 25, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 21, + "endLine": 32, + "endColumn": 30, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/Replace.ets.json b/ets2panda/linter/test/deprecatedapi/Replace.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/Replace.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SM.ets b/ets2panda/linter/test/deprecatedapi/SM.ets new file mode 100755 index 0000000000000000000000000000000000000000..22de541ee10f5e8cba362bf35afc4716630c77f3 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SM.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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 { SizeType } from './sdk/api/grid_container' + +@Entry +@Component +struct GridContainerExample { + @State sizeType: SizeType = SizeType.XS + + build() { + Column({ space: 5 }) { + Row() { + Button('SM').onClick(() => { this.sizeType = SizeType.SM }) + } + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SM.ets.args.json b/ets2panda/linter/test/deprecatedapi/SM.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SM.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SM.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/SM.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..a381e90b98512a535a240680a4059c168153952a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SM.ets.arkts2.json @@ -0,0 +1,128 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 40, + "endLine": 20, + "endColumn": 42, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 54, + "endLine": 25, + "endColumn": 62, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 63, + "endLine": 25, + "endColumn": 65, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SM.ets.json b/ets2panda/linter/test/deprecatedapi/SM.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SM.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SetAndLink.ets b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets new file mode 100755 index 0000000000000000000000000000000000000000..ebd4cd5e167d7897e9c515cf87f073f5cc9208b4 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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 { AppStorage } from './sdk/api/common_ts_ets_api'; + +AppStorage.setOrCreate('PropA', 47); +let link1: SubscribedAbstractProperty = AppStorage.SetAndLink('PropB', 49); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.args.json b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..7bebb6545e227eecf4d1d11d09070f6ed11046f5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 33, + "endLine": 17, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 80, + "endLine": 18, + "endColumn": 82, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 12, + "endLine": 18, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.json b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/SetAndLink.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/UIContext.ets b/ets2panda/linter/test/deprecatedapi/UIContext.ets new file mode 100644 index 0000000000000000000000000000000000000000..66787ce456766cb84a27199d83383127d5e55846 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/UIContext.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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 { promptAction } from '@kit.ArkUI'; + +try { + promptAction.showActionMenu({ //error + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + }, + { + text: 'item2', + color: '#000000' + }, + ] + }, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; + } + console.info('showActionMenu success callback, click button: ' + data.index); + }) +} catch (error) { +}; \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/UIContext.ets.json b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..f4da0d367fdfbd6f4e505b708458717c452dfaec --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 12, + "endLine": 31, + "endColumn": 16, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ability_component.ets b/ets2panda/linter/test/deprecatedapi/ability_component.ets new file mode 100755 index 0000000000000000000000000000000000000000..ecc3810d1d6bbc601cc76255b9bfce5e63c2e873 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ability_component.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct MyComponent { + + build() { + Column() { + AbilityComponent({ // error + want: { + bundleName: '', + abilityName: '' + }, + }) + .onConnect(() => { // error + console.log('AbilityComponent connect') + }) + .onDisconnect(() => { // error + console.log('AbilityComponent disconnect') + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ability_component.ets.args.json b/ets2panda/linter/test/deprecatedapi/ability_component.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ability_component.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ability_component.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ability_component.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..977dd1e5910ac382c5f52afa86e5a96aeb1207ed --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ability_component.ets.arkts2.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 23, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AbilityComponent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ability_component.ets.json b/ets2panda/linter/test/deprecatedapi/ability_component.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ability_component.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/action_sheet.ets b/ets2panda/linter/test/deprecatedapi/action_sheet.ets new file mode 100644 index 0000000000000000000000000000000000000000..57437a6e3d5d6149576407570b1fa0a40490b1b2 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/action_sheet.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 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 { ActionSheet } from './sdk/api/action_sheet' + +@Entry +@Component +struct ActionSheetExample { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button('Click to Show ActionSheet') + .onClick(() => { + ActionSheet.show({ //error + title: 'ActionSheet title', + subtitle: 'ActionSheet subtitle', + message: 'message', + autoCancel: true, + confirm: { + defaultFocus: true, + value: 'Confirm button', + action: () => { + console.info('Get Alert Dialog handled'); + } + }, + cancel: () => { + console.info('actionSheet canceled'); + }, + onWillDismiss: (dismissDialogAction: DismissDialogAction) => { + console.info("reason=" + JSON.stringify(dismissDialogAction.reason)) + console.info("dialog onWillDismiss"); + if (dismissDialogAction.reason === DismissReason.PRESS_BACK) { + dismissDialogAction.dismiss(); + } + if (dismissDialogAction.reason === DismissReason.TOUCH_OUTSIDE) { + dismissDialogAction.dismiss(); + } + }, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -10 }, + sheets: [ + { + title: 'apples', + action: () => { + console.info('apples'); + } + }, + { + title: 'bananas', + action: () => { + console.info('bananas'); + } + }, + { + title: 'pears', + action: () => { + console.info('pears'); + } + } + ] + }) + }) + }.width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/action_sheet.ets.args.json b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0a473b82ffb81180a3e65d250e5cac74b321d38a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json @@ -0,0 +1,168 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 25, + "column": 23, + "endLine": 25, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 27, + "endLine": 51, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 35, + "endLine": 51, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 23, + "endLine": 22, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 37, + "endLine": 22, + "endColumn": 43, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 57, + "endLine": 22, + "endColumn": 66, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 91, + "endLine": 22, + "endColumn": 100, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 50, + "endLine": 40, + "endColumn": 69, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DismissDialogAction\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 50, + "endLine": 43, + "endColumn": 63, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DismissReason\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 50, + "endLine": 46, + "endColumn": 63, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DismissReason\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 24, + "endLine": 50, + "endColumn": 39, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DialogAlignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/action_sheet.ets.json b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alert_dialog.ets b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6e0d243ff92f1138cb248463d47beacfa91bc32 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 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 { AlertDialog } from './sdk/api/alert_dialog' + +@Entry +@Component +struct AlertDialogExample { + build() { + Column({ space: 5 }) { + Button('AlertDialog Set Duration') + .onClick(() => { + AlertDialog.show( //error + { + title: 'AlertDialog 1', + message: 'Set Animation Duration open 3 second, close 100ms', + autoCancel: true, + alignment: DialogAlignment.Top, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + transition: TransitionEffect.asymmetric(TransitionEffect.OPACITY + .animation({ duration: 3000, curve: Curve.Sharp }) + .combine(TransitionEffect.scale({ x: 1.5, y: 1.5 }).animation({ duration: 3000, curve: Curve.Sharp })), + TransitionEffect.OPACITY.animation({ duration: 100, curve: Curve.Smooth }) + .combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }) + .animation({ duration: 100, curve: Curve.Smooth }))), + confirm: { + value: 'button', + action: () => { + console.info('Button-clicking callback'); + } + }, + cancel: () => { + console.info('Closed callbacks'); + } + } + ) + }) + .backgroundColor(0x317aff).height("88px") + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.args.json b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..4d05639b3c65bd4eda00b2b9d5347bb0b43d7a5b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.arkts2.json @@ -0,0 +1,258 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 23, + "endLine": 25, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 29, + "endLine": 31, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 37, + "endLine": 31, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 26, + "endLine": 32, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 40, + "endLine": 34, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 91, + "endLine": 35, + "endColumn": 95, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 64, + "endLine": 36, + "endColumn": 67, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 44, + "endLine": 38, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 35, + "endLine": 52, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 26, + "endLine": 30, + "endColumn": 41, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DialogAlignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 27, + "endLine": 33, + "endColumn": 43, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 55, + "endLine": 33, + "endColumn": 71, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 53, + "endLine": 34, + "endColumn": 58, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 26, + "endLine": 35, + "endColumn": 42, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 104, + "endLine": 35, + "endColumn": 109, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 17, + "endLine": 36, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 76, + "endLine": 36, + "endColumn": 81, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 28, + "endLine": 37, + "endColumn": 44, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 56, + "endLine": 38, + "endColumn": 61, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.json b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alert_dialog.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets new file mode 100755 index 0000000000000000000000000000000000000000..7d19ba33f67fa6a36ebeebcdec5fd931d43e56ce --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets @@ -0,0 +1,138 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct AlphabetIndexerSample { + private arrayA: string[] = ['安']; + private arrayB: string[] = ['卜', '白', '包', '毕', '丙']; + private arrayC: string[] = ['曹', '成', '陈', '催']; + private arrayL: string[] = ['刘', '李', '楼', '梁', '雷', '吕', '柳', '卢']; + private value: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', + 'V', 'W', 'X', 'Y', 'Z']; + @State customBlurStyle: BlurStyle = BlurStyle.NONE; + + + build() { + Stack({ alignContent: Alignment.Start }) { + Row() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arrayA, (item: string) => { + ListItem() { + Text(item) + .width('80%') + .height('5%') + .fontSize(30) + .textAlign(TextAlign.Center) + } + }, (item: string) => item) + + + ForEach(this.arrayB, (item: string) => { + ListItem() { + Text(item) + .width('80%') + .height('5%') + .fontSize(30) + .textAlign(TextAlign.Center) + } + }, (item: string) => item) + + + ForEach(this.arrayC, (item: string) => { + ListItem() { + Text(item) + .width('80%') + .height('5%') + .fontSize(30) + .textAlign(TextAlign.Center) + } + }, (item: string) => item) + + + ForEach(this.arrayL, (item: string) => { + ListItem() { + Text(item) + .width('80%') + .height('5%') + .fontSize(30) + .textAlign(TextAlign.Center) + } + }, (item: string) => item) + } + .width('30%') + .height('100%') + + + Column() { + Column() { + Text('切换模糊材质: ') + .fontSize(24) + .fontColor(0xcccccc) + .width('100%') + Button('COMPONENT_REGULAR') + .margin('5vp') + .width(200) + .onClick(() => { + this.customBlurStyle = BlurStyle.COMPONENT_REGULAR; + }) + Button('BACKGROUND_THIN') + .margin('5vp') + .width(200) + .onClick(() => { + this.customBlurStyle = BlurStyle.BACKGROUND_THIN; + }) + }.height('20%') + + + Column() { + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .usingPopup(true) + .alignStyle(IndexerAlign.Left) + .popupItemBorderRadius(24) + .itemBorderRadius(14) + .popupBackgroundBlurStyle(this.customBlurStyle) + .popupTitleBackground(0xCCCCCC) + .onSelected((index: number) => { // error + console.info(this.value[index] + ' Selected!'); + }) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA; + } else if (this.value[index] == 'B') { + return this.arrayB; + } else if (this.value[index] == 'C') { + return this.arrayC; + } else if (this.value[index] == 'L') { + return this.arrayL; + } else { + return []; + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected:' + index); + }) + } + .height('80%') + } + .width('70%') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.args.json b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..d2e38450182b0b142ac12d0cf4d031db500ccc79 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.args.json @@ -0,0 +1,20 @@ + +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..0abecc7d648aaa648aa182cf20e269722e6c0629 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.arkts2.json @@ -0,0 +1,548 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 33, + "column": 23, + "endLine": 33, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 41, + "endLine": 33, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 27, + "endLine": 39, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 27, + "endLine": 50, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 27, + "endLine": 61, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 27, + "endLine": 72, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 25, + "endLine": 84, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 22, + "endLine": 89, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 22, + "endLine": 95, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 65, + "endLine": 103, + "endColumn": 66, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 38, + "endLine": 106, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 33, + "endLine": 107, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 41, + "endLine": 111, + "endColumn": 46, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 32, + "endLine": 114, + "endColumn": 37, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 39, + "endLine": 116, + "endColumn": 44, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 39, + "endLine": 118, + "endColumn": 44, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 39, + "endLine": 120, + "endColumn": 44, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 26, + "endLine": 123, + "endColumn": 28, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 4, + "endLine": 27, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 27, + "endLine": 27, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BlurStyle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 39, + "endLine": 27, + "endColumn": 48, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BlurStyle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Stack\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 27, + "endLine": 31, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Alignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 9, + "endLine": 33, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 11, + "endLine": 34, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 13, + "endLine": 35, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 15, + "endLine": 36, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 28, + "endLine": 40, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 13, + "endLine": 46, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 15, + "endLine": 47, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 28, + "endLine": 51, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 11, + "endLine": 56, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 13, + "endLine": 57, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 15, + "endLine": 58, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 28, + "endLine": 62, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 11, + "endLine": 67, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 13, + "endLine": 68, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 15, + "endLine": 69, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 28, + "endLine": 73, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 9, + "endLine": 81, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 11, + "endLine": 82, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 13, + "endLine": 83, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 13, + "endLine": 87, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 40, + "endLine": 91, + "endColumn": 49, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BlurStyle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 13, + "endLine": 93, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 40, + "endLine": 97, + "endColumn": 49, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BlurStyle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 11, + "endLine": 102, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AlphabetIndexer\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 27, + "endLine": 105, + "endColumn": 39, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IndexerAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.json b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/alphabet_indexer.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animator.ets b/ets2panda/linter/test/deprecatedapi/animator.ets new file mode 100644 index 0000000000000000000000000000000000000000..8368d9d9b986ba7839752fd00e49dfecb30846be --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animator.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 { Animator as animator, AnimatorOptions } from './sdk/api/@ohos.animator'; + +let options: AnimatorOptions = { + duration: 1500, + easing: "friction", + delay: 0, + fill: "forwards", + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0 +}; +animator.create(options); //error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animator.ets.args.json b/ets2panda/linter/test/deprecatedapi/animator.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animator.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animator.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/animator.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..acaa0c56007b96460e67da01e543ce745daa180f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animator.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 13, + "endLine": 19, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 10, + "endLine": 21, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 15, + "endLine": 24, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 10, + "endLine": 28, + "endColumn": 16, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Animator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animator.ets.json b/ets2panda/linter/test/deprecatedapi/animator.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animator.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..1d8f620a9d0b0fe97a1d6ed4763cb98e634b3992 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 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 Animator as animator, AnimatorResult from './sdk/api/@ohos.animator'; + +let AnimatorResult: AnimatorResult | undefined = animator.create(options) + +AnimatorResult.onrepeat = () => { //error + console.info("onrepeat callback") +} + +AnimatorResult.oncancel = () => { //error + console.info("oncancel callback") +} + +AnimatorResult.onfinish = () => { //error + console.info("onfinish callback") +} + +AnimatorResult.onframe = (value) => { //error + console.info("onframe callback") +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..438dabb8d35905e8f6d4fd111334d1f2eafdb706 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 20, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)", + "severity": "ERROR" + }, + { + "line": 15, + "column": 21, + "endLine": 15, + "endColumn": 45, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 27, + "endLine": 31, + "endColumn": 32, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.json b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..438dabb8d35905e8f6d4fd111334d1f2eafdb706 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/animatorResultOnrepeat_api.ets.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 20, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)", + "severity": "ERROR" + }, + { + "line": 15, + "column": 21, + "endLine": 15, + "endColumn": 45, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 27, + "endLine": 31, + "endColumn": 32, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..2e73b25e23b8270c012594790da8814435209ae4 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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 { AppStorage } from './sdk/api/common_ts_ets_api'; + +AppStorage.SetOrCreate('PropA', 47); +let res: boolean = AppStorage.IsMutable('simpleProp'); //error + +let value: number = AppStorage.Get('PropA') as number; //error + +let res: boolean = AppStorage.Clear(); //error + +let value: boolean = AppStorage.Delete('PropA') as boolean; //error + +let value: number = AppStorage.Size(); //error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..891eb9509c4b250bbf93436010f834933bbc42d5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 33, + "endLine": 17, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 31, + "endLine": 18, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 44, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 32, + "endLine": 20, + "endColumn": 35, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 31, + "endLine": 22, + "endColumn": 36, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 33, + "endLine": 24, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 32, + "endLine": 26, + "endColumn": 36, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.json b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..7ed0caf1a2f6f232f435c3d378399b021f0bc117 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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 App from './sdk/api/@system.app'; +import { GridContainerInterface } from './sdk/api/grid_container'; + +export default class Req { + requestFullWindow() { + App.screenOnVisible({ + }); + } +} + +GridContainerInterface.GridContainerAttribute \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.json b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.arkts2.json old mode 100644 new mode 100755 similarity index 66% rename from ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.json rename to ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.arkts2.json index 31d218b8f0a1b62832a120b6cc681c9648010be7..ab3b8aff134d2166a37a1dbd982dfa6ac5c34a80 --- a/ets2panda/linter/test/concurrent/ no_support_arktsutils_locks_asynclock.ets.migrate.json +++ b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.arkts2.json @@ -15,23 +15,23 @@ ], "result": [ { - "line": 18, - "column": 28, - "endLine": 18, - "endColumn": 33, - "problem": "LimitedStdLibNoImportConcurrency", + "line": 20, + "column": 9, + "endLine": 20, + "endColumn": 24, + "problem": "NoDeprecatedApi", "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", "severity": "ERROR" }, { - "line": 20, - "column": 28, - "endLine": 20, - "endColumn": 33, - "problem": "LimitedStdLibNoImportConcurrency", + "line": 25, + "column": 24, + "endLine": 25, + "endColumn": 46, + "problem": "UIInterfaceImport", "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "rule": "The ArkUI interface \"GridContainerAttribute\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.json b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/appscreenOnVisible_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..0a37728e9f10164a45fd3a1f232fc03003351f47 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; + +class H{ + backToDetail() { + router.back({uri:'pages/detail/detail'}); + } +} +export default new H() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.json b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/backRouterOptionsUri_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/buttons.ets b/ets2panda/linter/test/deprecatedapi/buttons.ets new file mode 100755 index 0000000000000000000000000000000000000000..80574cbd32e3aab0e1e00a93eb10f1fcfda551d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/buttons.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 prompt from './sdk/api/@ohos.prompt' + + +prompt.showDialog({ + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + }, + { + text: 'button2', + color: '#000000' + } + ] +}, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; + } + console.info('showDialog success callback, click button: ' + data.index); +}); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/buttons.ets.args.json b/ets2panda/linter/test/deprecatedapi/buttons.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/buttons.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/buttons.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/buttons.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..30ea0fb4ec6c620e25e414e862fa3fbc88bf1fde --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/buttons.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 8, + "endLine": 18, + "endColumn": 18, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 3, + "endLine": 19, + "endColumn": 8, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 3, + "endLine": 20, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/buttons.ets.json b/ets2panda/linter/test/deprecatedapi/buttons.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..9f3ebadfbb714381766f4118f21e74e2c7d6b08f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/buttons.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..ee4e8bf889eb1098e1b0f60174cb2bda7737f710 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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 {ChipGroupItemOptions} from './sdk/api/ChipGroup'; + +@Entry +struct Index { + build() { + Column() { + ChipGroup({ + items: [ + { + prefixIcon: { src: $r('app.media.icon') }, + label: { text: "操作块1" }, + .suffixIcon: { src: $r('sys.media.ohos_ic_public_cut') }, //error + allowClose: false + } + ] + }) + } + } +} +class Test implements ChipGroupItemOptions{ + suffixIcon?: IconOptions | undefined; + get(){ + return this.suffixIcon; + } + set(suffixIcon?: IconOptions | undefined){ + suffixIcon = { src: $r('sys.media.ohos_ic_public_cut') }; + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..667d91d76ded29c2264848d9ce8089452797bddf --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 6, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 32, + "endLine": 24, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 33, + "endLine": 26, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IconOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 20, + "endLine": 39, + "endColumn": 31, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IconOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 25, + "endLine": 40, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.json b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..0c1bacf603e53b76a2d38202ed721c276cadb32b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 6, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets b/ets2panda/linter/test/deprecatedapi/common.ets new file mode 100644 index 0000000000000000000000000000000000000000..12386489df3d9b137e4a9ad5ec6fea637093ff0b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct ClipExample { + build() { + Column({ space: 15 }) { + Row() { + Image($r('app.media.testImg')) + .clip(new Circle({})) //error + + Button() + .transition({ + type: TransitionType.Insert, //error + opacity: 0, //error + translate: {x: 1}, //error + scale: {x: 1}, //error + rotate: {angle: 1} //error + }) + .onClick(() => { + let context: Context = getContext(this); //error + console.info("CacheDir:" + context.cacheDir); + }) + + Button('Touch').height(40).width(100) + .onTouch((event?: TouchEvent) => { + if (event) { + event.touches[0].screenX; //error + event.touches[0].screenY; //error + } + }) + .onClick((event?: ClickEvent) => { + if (event) { + event.screenX; //error + event.screenY; //error + } + }) + .onMouse((event: MouseEvent):void => { + if (event) { + event.screenX; //error + event.screenY; //error + } + }) + } + .borderRadius(20) + } + .width('100%') + .margin({ top: 15 }) + } +} + + +px2lpx(200); //error +lpx2px(200); //error +px2fp(200); //error +fp2px(200); //error +px2vp(200); //error +vp2px(200); //error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets.args.json b/ets2panda/linter/test/deprecatedapi/common.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1dc330e4e7defbd806a9b74001f9ded0f5204afe --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json @@ -0,0 +1,448 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 27, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 22, + "endLine": 28, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 28, + "endLine": 29, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 24, + "endLine": 30, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 29, + "endLine": 31, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 26, + "endLine": 38, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 36, + "endLine": 38, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 13, + "endLine": 41, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 13, + "endLine": 41, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 13, + "endLine": 48, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 21, + "endLine": 58, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 20, + "endLine": 61, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 8, + "endLine": 66, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 8, + "endLine": 67, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 7, + "endLine": 68, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 7, + "endLine": 69, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 7, + "endLine": 70, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 7, + "endLine": 71, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 7, + "endLine": 21, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 9, + "endLine": 22, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Circle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 19, + "endLine": 27, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 26, + "endLine": 34, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Context\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 36, + "endLine": 34, + "endColumn": 46, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"getContext\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 3, + "endLine": 38, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 27, + "endLine": 39, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TouchEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ClickEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 26, + "endLine": 51, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"MouseEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 1, + "endLine": 66, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2lpx\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 1, + "endLine": 67, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"lpx2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2fp\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"fp2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2vp\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"vp2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets.json b/ets2panda/linter/test/deprecatedapi/common.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..f24a1d0316bb093ee66951a8bdb172ca061aaa1c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 41, + "column": 13, + "endLine": 41, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets b/ets2panda/linter/test/deprecatedapi/common_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..142187d98c3c3307470165b08f711769c3d6b42a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets @@ -0,0 +1,139 @@ +/* + * Copyright (c) 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 {DragEvent,CustomPopupOptions} from './sdk/api/common'; +import {LayoutInfo,LayoutChild,LayoutBorderInfo,TransitionOptions} from './sdk/api/common'; + +function get(aa:number){ + const globalEvent : DragEvent = {} + return globalEvent.getX();//error +} +function onMeasure(selfLayoutInfo: LayoutInfo, borderInfo: Array, children: Array){//error + selfLayoutInfo as LayoutInfo;//error + typeof (borderInfo[0] as LayoutBorderInfo);//error +} + +class Test implements LayoutChild{//error + set(child:LayoutChild){//error + return child as LayoutInfo;//error + } +} +class Test2 extends Test implements LayoutBorderInfo,TransitionOptions{ //error + private layoutInfo: LayoutInfo|undefined = undefined;//error + get(option:Map){//error + option.set('',{}); + } +} + +@Entry +@Component +struct Example { + @State uri: string = ""; + @State blockArr: string[] = []; + @State handlePopup: boolean = false; + @State customPopup: boolean = false; + udKey: string = ''; + globalEvent : DragEvent = {} + + @State handlePopup: boolean = false + private scroller: Scroller = new Scroller(); + + aboutToAppear(): void { + animateTo({ // error + duration: 2000, + curve: Curve.EaseOut, + iterations: 3, + playMode: PlayMode.Normal, + onFinish: () => { + console.info('play end'); + } + }, () => { + }); + } + + onLayout(children: LayoutChild[], constraint: ConstraintSizeOptions): void {// error *2 + let layoutChild: LayoutChild = children[0];// error + layoutChild.constraint; // error + layoutChild.position; // error + layoutChild.name; // error + layoutChild.id; // error + layoutChild.borderInfo.borderWidth; // error *2 + layoutChild.borderInfo.padding; // error *2 + layoutChild.borderInfo.margin; // error *2 + layoutChild.layout({ position: { x: 0, y: 0 }, constraint: constraint }); // error *3 + layoutChild.measure(constraint); // error + } + + onMeasure(children: LayoutChild[], constraint: ConstraintSizeOptions): void {// error *2 + } + + // Popup builder + @Builder popupBuilder() { + Row({ space: 2 }) { + }.width(100).height(50).padding(5) + } + build() { + Column() { + Text('Image drag and drop') + .fontSize('30dp') + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Image($r('app.media.startIcon')) + .width(100) + .height(100) + .border({ width: 1 }) + .draggable(true) + .onDragStart((event:DragEvent) => { + typeof event.getX(); //error + (event as DragEvent).getY(); //error + console.log('',event.getY()); //error + }) + } + .margin({ bottom: this.globalEvent.getY() }) //error + Row() { + Column(){ + } + .border({width: 1}) + .height('90%') + .width('100%') + .onDrop((event?: DragEvent, extraParams?: string) => { + console.log("enter onDrop") + const x = event?.getX(); //error + const y = event?.getY(); //error + }, {disableDataPrefetch: true}) + } + .height("50%") + .width("90%") + .border({ width: 1 }) + + Button('PopupOptions') + .bindPopup(this.handlePopup, { + message: 'This is a popup with PopupOptions', + placementOnTop: true// error + }) + .useSizeType({}) // error + + List({ space: 10, scroller: this.scroller }) + .onScroll((xOffset: number, scrollState: ScrollState): void => { // error + }) + .width('100%') + .height(90) + .touchable(true)// error + .mask(new CircleAttribute()) // error + } + } + onLayout(children: Array//error + , constraint: ConstraintSizeOptions) { + children[0].borderInfo as LayoutBorderInfo;//error + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/common_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1f361a5a2763cdee61e3028b9c71ff02ac3d9527 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json @@ -0,0 +1,888 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 1, + "endLine": 21, + "endColumn": 2, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 23, + "endLine": 19, + "endColumn": 32, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 22, + "endLine": 20, + "endColumn": 26, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 36, + "endLine": 22, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 66, + "endLine": 22, + "endColumn": 82, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 101, + "endLine": 22, + "endColumn": 112, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 11, + "endLine": 24, + "endColumn": 24, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 28, + "endLine": 24, + "endColumn": 44, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 23, + "endLine": 27, + "endColumn": 34, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 13, + "endLine": 28, + "endColumn": 24, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 21, + "endLine": 29, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 38, + "endLine": 32, + "endColumn": 54, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 55, + "endLine": 32, + "endColumn": 72, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 23, + "endLine": 33, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 25, + "endLine": 34, + "endColumn": 42, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 17, + "endLine": 47, + "endColumn": 26, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 36, + "endLine": 50, + "endColumn": 44, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 17, + "endLine": 54, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 19, + "endLine": 56, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 3, + "endLine": 76, + "endColumn": 4, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 3, + "endLine": 65, + "endColumn": 11, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 22, + "endLine": 65, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 22, + "endLine": 66, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 36, + "endLine": 66, + "endColumn": 47, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 17, + "endLine": 68, + "endColumn": 25, + "problem": "SdkTypeQuery", + "suggest": "", + "rule": "Using typeof as a type is not allowed in this API (sdk-type-query)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 41, + "endLine": 74, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 47, + "endLine": 74, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 3, + "endLine": 78, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 23, + "endLine": 78, + "endColumn": 34, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 18, + "endLine": 83, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 13, + "endLine": 84, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 25, + "endLine": 84, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 37, + "endLine": 84, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 18, + "endLine": 92, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 19, + "endLine": 93, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 28, + "endLine": 94, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 31, + "endLine": 96, + "endColumn": 40, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 26, + "endLine": 97, + "endColumn": 30, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 34, + "endLine": 98, + "endColumn": 38, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 23, + "endLine": 98, + "endColumn": 32, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 34, + "endLine": 99, + "endColumn": 38, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 42, + "endLine": 102, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 25, + "endLine": 106, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 26, + "endLine": 109, + "endColumn": 35, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 28, + "endLine": 111, + "endColumn": 32, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 28, + "endLine": 112, + "endColumn": 32, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 24, + "endLine": 117, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 21, + "endLine": 126, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 15, + "endLine": 130, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 17, + "endLine": 132, + "endColumn": 32, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 3, + "endLine": 138, + "endColumn": 4, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 28, + "endLine": 135, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 5, + "endLine": 137, + "endColumn": 16, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 31, + "endLine": 137, + "endColumn": 47, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 2, + "endLine": 39, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 4, + "endLine": 42, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 4, + "endLine": 43, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 4, + "endLine": 44, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 4, + "endLine": 45, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 21, + "endLine": 50, + "endColumn": 29, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 36, + "endLine": 50, + "endColumn": 44, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 5, + "endLine": 53, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"animateTo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 14, + "endLine": 55, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 17, + "endLine": 57, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"PlayMode\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 49, + "endLine": 65, + "endColumn": 70, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 50, + "endLine": 78, + "endColumn": 71, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 4, + "endLine": 82, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 5, + "endLine": 87, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 7, + "endLine": 88, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 7, + "endLine": 90, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 25, + "endLine": 90, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 39, + "endLine": 90, + "endColumn": 42, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 56, + "endLine": 90, + "endColumn": 65, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 90, + "endLine": 90, + "endColumn": 99, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 9, + "endLine": 91, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 9, + "endLine": 104, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 7, + "endLine": 119, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 7, + "endLine": 126, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 127, + "column": 48, + "endLine": 127, + "endColumn": 59, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ScrollState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 17, + "endLine": 132, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"CircleAttribute\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 19, + "endLine": 136, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets.json b/ets2panda/linter/test/deprecatedapi/common_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a4c1c4ff4d4739c640830e81a8598fabc5a7799 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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 { LocalStorage } from './sdk/api/common_ts_ets_api' + +@Entry +@Component +struct SharedLocalStorage { + localStorage = LocalStorage.getShared(); //error + + build() { + Row() { + Column() { + Button("Change Local Storage to 47") + .onClick(() => { + this.localStorage?.setOrCreate("propA", 47); + }) + Button("Get Local Storage") + .onClick(() => { + console.info(`localStorage: ${this.localStorage?.get("propA")}`); + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..01ccb75666b2a19dd85e9c98c300c653459d6d00 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 31, + "endLine": 21, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 53, + "endLine": 28, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets new file mode 100755 index 0000000000000000000000000000000000000000..6ee8fd02c0f8587c74494aa39a3425d2a0d199f9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ +AppStorage.Set("username", "John"); // error +console.log(AppStorage.get("username")); +let keys: IterableIterator = AppStorage.Keys(); // error +let simple = AppStorage.staticClear(); // error +AppStorage.setOrCreate('simpleProp', 121); +AppStorage.Has('simpleProp'); // error +AppStorage.setOrCreate('PropA', 47); +let prop: SubscribedAbstractProperty = AppStorage.SetAndProp('PropB', 49); // error +AppStorage.SetOrCreate('PropA', 47); // error +PersistentStorage.PersistProp('aProp', 47); // error +AppStorage.Prop("username"); // error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.args.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..c7ff7c846d95459a0dfae61ca9a09c70f8ec6ba9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.arkts2.json @@ -0,0 +1,198 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 38, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 38, + "endLine": 19, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 33, + "endLine": 21, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 79, + "endLine": 22, + "endColumn": 81, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 40, + "endLine": 24, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 13, + "endLine": 16, + "endColumn": 23, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 38, + "endLine": 17, + "endColumn": 48, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 14, + "endLine": 18, + "endColumn": 24, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 48, + "endLine": 22, + "endColumn": 58, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"PersistentStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.json b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..fd824bf65e41784d02f355f28af1be96f899cff6 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common_ts_ets_api1.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 38, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets new file mode 100644 index 0000000000000000000000000000000000000000..f049f9273b5d0087410dfed77e2d334a8e6363c6 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 { componentSnapshot } from '@kit.ArkUI'; + +@Entry +@Component +struct SnapshotExample { + @Builder + RandomBuilder() { + Flex() { + Text('Test menu') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + } + .width(100) + } + + build() { + Column() { + Button("click to generate UI snapshot") + .onClick(() => { + componentSnapshot.get("root", () => {}); //error + componentSnapshot.get("root"); //error + componentSnapshot.createFromBuilder(() => { this.RandomBuilder()}, () => {}); //error + componentSnapshot.createFromBuilder(() => { this.RandomBuilder()}); //error + }).margin(10) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..ab200aca98a0c25e5488380a88ae795e2ec6c751 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json @@ -0,0 +1,158 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 25, + "column": 19, + "endLine": 25, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 16, + "endLine": 26, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 12, + "endLine": 30, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 19, + "endLine": 41, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 20, + "endLine": 28, + "endColumn": 29, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 7, + "endLine": 35, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 17, + "endLine": 45, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"HorizontalAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.json b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curves.ets b/ets2panda/linter/test/deprecatedapi/curves.ets new file mode 100644 index 0000000000000000000000000000000000000000..c13a0cfce6ce35e2f8432a6072c35b669ee7a339 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curves.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 { curves } from '@kit.ArkUI'; +curves.cubicBezier(0.1, 0.0, 0.1, 1.0);//error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curves.ets.args.json b/ets2panda/linter/test/deprecatedapi/curves.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curves.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curves.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/curves.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curves.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curves.ets.json b/ets2panda/linter/test/deprecatedapi/curves.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curves.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..db08bd6b30d3280d2403d9130ccee0b113294424 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 { curves } from './sdk/api/@ohos.curves'; + +curves.init() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..0a1fb129d6c53deb03dc937329239d8e0ce9a082 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 8, + "endLine": 17, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.json b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curvesInit_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/custom_api.ets b/ets2panda/linter/test/deprecatedapi/custom_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..a809862de1c8de194898de44a4cdb19bdf2ee43b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/custom_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {PanelType} from './sdk/api/panel' + +@@Entry +@Component +struct WrapContentPanelExample { + @State isVisible: boolean = true + build() { + Column() { + Panel(this.isVisible) + .type(PanelType.CUSTOM) // error + } + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/custom_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/custom_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/custom_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/custom_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/custom_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..a57cc4ca007a717c3187339280a457e970aa2ea2 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/custom_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 2, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 29, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/custom_api.ets.json b/ets2panda/linter/test/deprecatedapi/custom_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/custom_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets b/ets2panda/linter/test/deprecatedapi/date_picker.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5937657163f4357e9fde0b64e18341613a4df22 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct DatePickerExample { + private selectedDate: Date = new Date('2021-08-08'); + + build() { + Column() { + Button("DatePickerDialog") + .margin(20) + .onClick(() => { + DatePickerDialog.show({ //error + onAccept: () => {}, //error + onChange: () => {} //error + }) //error + }) + + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + }).onChange(() => {}) //error + + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3c31119d9f80feda224ca75460f2c13228f98f0d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 11, + "endLine": 26, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DatePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DatePicker\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets.json b/ets2panda/linter/test/deprecatedapi/date_picker.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..700f35d0a8ebde2205298181290849e340c266e0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 { componentUtils } from '@kit.ArkUI'; + +@Entry +@Component +struct CommonUtilsExample { + + aboutToAppear(): void { + let modePosition:componentUtils.ComponentInfo = componentUtils.getRectangleById("onClick"); // error + } + + build() { + Column() { + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..ce2955ca55158612f1e3169e24143b3a5dbe5d9f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets new file mode 100755 index 0000000000000000000000000000000000000000..032b04c32363fe08f8df02c4705fd799bf1bae5c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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 {font} from './sdk/api/@ohos.font'; + +@Entry +@Component +struct FontExample { + fontInfo2: font.FontInfo = font.getFontByName(''); // error + fontList: Array = new Array(); + + aboutToAppear(): void { + font.registerFont({ // error + familyName: 'mediumRawFile', + familySrc: $rawfile('font/medium.ttf') + }) + } + + build() { + Column() { + Button("getFontByName") + .onClick(() => { + this.fontInfo2 = font.getFontByName(''); // error + }) + Button("getSystemFontList") + .onClick(() => { + this.fontList = font.getSystemFontList(); // error + }) + Button("registerFont") + .onClick(() => { + font.registerFont({familyName: 'mediumRawFile', familySrc: $rawfile('font/medium.ttf')}); // error + }) + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..00497d02618ba04db6d78378728574529f588c2e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json @@ -0,0 +1,148 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 35, + "endLine": 20, + "endColumn": 48, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 33, + "endLine": 34, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 32, + "endLine": 38, + "endColumn": 49, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 16, + "endLine": 42, + "endColumn": 28, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 18, + "endLine": 26, + "endColumn": 26, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$rawfile\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 7, + "endLine": 36, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 70, + "endLine": 42, + "endColumn": 78, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$rawfile\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets new file mode 100644 index 0000000000000000000000000000000000000000..c17f35ce66bb70e7ba37b08cea768898ed7c2c60 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets @@ -0,0 +1,85 @@ +/* + * Copyright (c) 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 { promptAction } from '@kit.ArkUI'; + +@Entry +@Component +struct PromptActionExample { + + aboutToAppear(): void { + promptAction.showToast({ // error + message: 'Hello World', + duration: 2000 + }); + + promptAction.showDialog({ // error + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + } + ], + }); + + promptAction.showDialog({ // error + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + } + ] + }, (err, data) => { + }); + + promptAction.showActionMenu({ // error + title: 'showActionMenu Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + } + ] + }); + + promptAction.showActionMenu({ // error + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + } + ] + }, (err, data) => { + }) + + promptAction.closeCustomDialog(1); // error + promptAction.openCustomDialog({ // error + builder: () => { + }, + onWillDismiss: (dismissDialogAction: DismissDialogAction) => { + } + }); + } + + build() { + Column() { + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..33af06e3141b27c854edfb247704eea48773abab --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json @@ -0,0 +1,118 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 25, + "column": 17, + "endLine": 25, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 9, + "endLine": 69, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 14, + "endLine": 69, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 44, + "endLine": 76, + "endColumn": 63, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DismissDialogAction\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 5, + "endLine": 82, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..2a8b234e1c72a6ed4e9026a89bb9cff0395f7b29 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 9, + "endLine": 69, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 14, + "endLine": 69, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets new file mode 100755 index 0000000000000000000000000000000000000000..a5ca89df3c1e3abe7068bdc00a3b5b4857045b7a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets @@ -0,0 +1,147 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; + +class L{ + enableAlertBeforeBackPage() { + router.enableAlertBeforeBackPage({ //error + message: 'Message Info', + success: ()=> { + console.log('success'); + }, + cancel: ()=> { + console.log('cancel'); + } + }); + } +} + +class RouterParams { + data1: string; + + constructor(str: string) { + this.data1 = str; + } +} + +@Entry +@Component +struct RouterExample { + + aboutToAppear(): void { + router.replaceNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }); + + router.replaceNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, (err) => { + }); + + router.replaceNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, router.RouterMode.Standard); + + router.replaceNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, router.RouterMode.Standard, (err) => { + }); + + router.pushNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }); + + router.pushNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, (err) => { + }) + + router.pushNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, router.RouterMode.Standard); + + router.pushNamedRoute({ // error + name: 'myPage', + params: new RouterParams('message') + }, router.RouterMode.Standard, (err) => { + }) + + let obj = router.getParams(); // error + router.hideAlertBeforeBackPage(); // error + router.showAlertBeforeBackPage({ // error + message: 'Message Info' + }); + let options: Array = router.getStateByUrl('pages/index'); // error + let options1: router.RouterState | undefined = router.getStateByIndex(1); // error + let page = router.getState(); // error + let length = router.getLength(); // error + router.clear(); // error + router.back({ url: 'pages/detail' }); // error + router.back(1); // error + router.back(1, { info: 'From Home' }); // error + router.replaceUrl({ // error + url: 'pages/detail', + params: new RouterParams('message') + }); + router.replaceUrl({ // error + url: 'pages/detail', + params: new RouterParams('message') + }, (err) => { + }); + router.replaceUrl({ // error + url: 'pages/detail', + params: new RouterParams('message') + }, router.RouterMode.Standard); + router.replaceUrl({ // error + url: 'pages/detail', + params: new RouterParams('message') + }, router.RouterMode.Standard, (err) => { + }); + + router.pushUrl({ // error + url: 'pages/routerpage2', + params: {name: 'message', age: 1} + }); + + router.pushUrl({ // error + url: 'pages/routerpage2', + params: new RouterParams('message') + }, (err) => { + }); + + router.pushUrl({ // error + url: 'pages/routerpage2', + params: new RouterParams('message') + }, router.RouterMode.Standard); + + router.pushUrl({ // error + url: 'pages/routerpage2', + params: new RouterParams('message') + }, router.RouterMode.Standard, (err) => { + }) + } + + build() { + Column() { + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..5c30d621504123bc221f2da8fbce675bbb584ba2 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.arkts2.json @@ -0,0 +1,218 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 37, + "endLine": 63, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 9, + "endLine": 74, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 37, + "endLine": 85, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 9, + "endLine": 88, + "endColumn": 33, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 75, + "endLine": 94, + "endColumn": 76, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 9, + "endLine": 95, + "endColumn": 33, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 9, + "endLine": 96, + "endColumn": 36, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 12, + "endLine": 97, + "endColumn": 17, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 17, + "endLine": 99, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 17, + "endLine": 100, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 9, + "endLine": 108, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 37, + "endLine": 117, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 122, + "column": 38, + "endLine": 122, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 9, + "endLine": 128, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 37, + "endLine": 139, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 2, + "endLine": 39, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 5, + "endLine": 144, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..405836ab2912121892e0fb2a3e8d3c6c3a5cc33a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_router.ets.json @@ -0,0 +1,128 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 37, + "endLine": 63, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 9, + "endLine": 74, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 37, + "endLine": 85, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 9, + "endLine": 88, + "endColumn": 33, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 9, + "endLine": 95, + "endColumn": 33, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 9, + "endLine": 96, + "endColumn": 36, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 9, + "endLine": 108, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 37, + "endLine": 117, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 9, + "endLine": 128, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 37, + "endLine": 139, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1b1f0869618702f12dedc302fc2521d6b64bfba --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct TimePickerDialogExample { + + aboutToAppear(): void { + TimePickerDialog.show(); + TimePickerDialog.show({useMilitaryTime: true}); + } + + build() { + Column() { + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1af038e5b70c2a49a22760284383fc43921a23fa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TimePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TimePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets b/ets2panda/linter/test/deprecatedapi/dragController.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fc9a633b8f5fa605d424013d8d018e370a35257 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 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 { dragController } from "@kit.ArkUI"; +import { image } from '@kit.ImageKit'; + +@Entry +@Component +struct DragControllerPage { + @State pixmap: image.PixelMap | null = null + + @Builder + DraggingBuilder() { + Column() { + Text("DraggingBuilder") + .fontColor(Color.White) + .fontSize(12) + } + .width(100) + .height(100) + .backgroundColor(Color.Blue) + } + + @Builder + CustomDragView() { + Column() { + Text('Drag Me') + .fontSize(18) + .fontColor(Color.Black) + } + .width(100) + .height(50) + .backgroundColor(Color.White) + } + + private customBuilders: Array = [this.CustomDragView]; + + build() { + Column() { + Button('drag') + .margin(10) + .onDragEnter(() => { + dragController.getDragPreview(); //error + }) + .onTouch((event?: TouchEvent) => { + if (event) { + let dragInfo: dragController.DragInfo = { + pointerId: 0, + extraParams: '' + } + dragController.createDragAction(this.customBuilders, dragInfo); //error + + dragController.executeDrag(() => { //error + this.DraggingBuilder() + }, dragInfo, (err, eve) => { + }); + + dragController.executeDrag(() => { //error + this.DraggingBuilder() + }, dragInfo); + } + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..353facd04ad8d3e162743403e88474a6e2766a0b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json @@ -0,0 +1,308 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 19, + "endLine": 29, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 12, + "endLine": 31, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 13, + "endLine": 32, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 19, + "endLine": 40, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 12, + "endLine": 43, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 13, + "endLine": 44, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 46, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 17, + "endLine": 53, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 26, + "endLine": 60, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 27, + "endLine": 67, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 32, + "endLine": 67, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 4, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 20, + "endLine": 28, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 22, + "endLine": 33, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 4, + "endLine": 36, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 20, + "endLine": 41, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 22, + "endLine": 45, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 46, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"CustomBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 49, + "endLine": 48, + "endColumn": 61, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DragItemInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 5, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 7, + "endLine": 52, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 27, + "endLine": 57, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TouchEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..fcedf465955a961dd6523968783383316d82dc8d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 67, + "column": 27, + "endLine": 67, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 32, + "endLine": 67, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets b/ets2panda/linter/test/deprecatedapi/enums.ets new file mode 100644 index 0000000000000000000000000000000000000000..5135fbb18e7bfe30d4ae3a8ea9e5073841ceea14 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct ScrollExample { + scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item: number) => { + Text(item.toString()) + }, (item: string) => item) + }.width('100%') + } + + Button('back Center') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Center); //error + }) + .margin({ top: 160, left: 20 }) + Button('back Middle') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Middle); //error + }) + .margin({ top: 210, left: 20 }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets.args.json b/ets2panda/linter/test/deprecatedapi/enums.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..7be47bbee3b08773bf7e42d846b2c7547e1b8afe --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json @@ -0,0 +1,308 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 28, + "endLine": 19, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 34, + "endLine": 20, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 37, + "endLine": 20, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 40, + "endLine": 20, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 43, + "endLine": 20, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 46, + "endLine": 20, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 49, + "endLine": 20, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 52, + "endLine": 20, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 55, + "endLine": 20, + "endColumn": 56, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 24, + "endLine": 37, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 35, + "endLine": 37, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 24, + "endLine": 43, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 35, + "endLine": 43, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 13, + "endLine": 19, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 28, + "endLine": 19, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Stack\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Alignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroll\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 11, + "endLine": 26, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 13, + "endLine": 27, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 36, + "endLine": 35, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Edge\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 7, + "endLine": 38, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 36, + "endLine": 41, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Edge\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets.json b/ets2panda/linter/test/deprecatedapi/enums.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..ee528bd4ad87e66b108e3c889aebbfdf68f15e6b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 { Environment } from './sdk/api/common_ts_ets_api'; + +Environment.EnvProp('accessibilityEnabled', 'default'); //error + +let keys: Array = Environment.Keys(); //error + +Environment.EnvProps([{ key: 'accessibilityEnabled', defaultValue: 'default' }, { //error + key: 'languageCode', + defaultValue: 'en' +}, { key: 'prop', defaultValue: 'hhhh' }]); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..55aa23cb17ccc8da1522a8bbe65c63451179533f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 13, + "endLine": 17, + "endColumn": 20, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 39, + "endLine": 19, + "endColumn": 43, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 13, + "endLine": 21, + "endColumn": 21, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.json b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/environmentEnvProp_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/foldable_api.ets b/ets2panda/linter/test/deprecatedapi/foldable_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..de997623bfe14662921cfc3b36af43970da77aa0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/foldable_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {PanelType} from './sdk/api/panel' + +@@Entry +@Component +struct WrapContentPanelExample { + @State isVisible: boolean = true + build() { + Column() { + Panel(this.isVisible) + .type(PanelType.Foldable) // error + } + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/foldable_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/foldable_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..9ecb29181d94fbbfb051715976d110dbef378032 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 2, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/foldable_api.ets.json b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/foldable_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/getLength.ets b/ets2panda/linter/test/deprecatedapi/getLength.ets new file mode 100755 index 0000000000000000000000000000000000000000..897957626a7ff0726cf67c071a5af131c6252b9a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getLength.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; +class J{ + getLength() { + let size = router.getLength(); + console.log('pages stack size = ' + size); + } +} +export default new J() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getLength.ets.args.json b/ets2panda/linter/test/deprecatedapi/getLength.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getLength.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getLength.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/getLength.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..7c08a340f938a9098f617645e5ea936ae70eee66 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getLength.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 9, + "endLine": 18, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getLength.ets.json b/ets2panda/linter/test/deprecatedapi/getLength.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7c08a340f938a9098f617645e5ea936ae70eee66 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getLength.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 9, + "endLine": 18, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getParams.ets b/ets2panda/linter/test/deprecatedapi/getParams.ets new file mode 100755 index 0000000000000000000000000000000000000000..69c220cec56f9833f9311cd2ab6e0a2070edb83c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getParams.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; + +let params: Object = router.getParams(); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getParams.ets.args.json b/ets2panda/linter/test/deprecatedapi/getParams.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getParams.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getParams.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/getParams.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getParams.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/getParams.ets.json b/ets2panda/linter/test/deprecatedapi/getParams.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/getParams.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..30d8bc150c9293466f938406ac7fb7fa9d9445cc --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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 { GridAttribute } from './sdk/api/grid'; + +@Entry +@Component +struct GridExample { + @State scrollPos: number = 0; + @State scrollStatus: string = 'IDLE'; + + build() { + Grid() { + ForEach([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], () => { + }) + } + .columnsTemplate('1fr 1fr 1fr') + .onScroll((offset, state) => { + this.scrollPos = offset; + this.scrollStatus = ScrollState[state]; + }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..950e9a126ec0c90eb54a6e9c89b696c92a865cd5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.arkts2.json @@ -0,0 +1,218 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 30, + "endLine": 20, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 16, + "endLine": 25, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 19, + "endLine": 25, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 22, + "endLine": 25, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 28, + "endLine": 25, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 31, + "endLine": 25, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 34, + "endLine": 25, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 37, + "endLine": 25, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 40, + "endLine": 25, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 43, + "endLine": 25, + "endColumn": 45, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 24, + "endLine": 29, + "endColumn": 29, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Grid\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 27, + "endLine": 31, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ScrollState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.json b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..847ccb380cc335698340e7cbb59584979693d731 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridAttributeonScroll_api.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 24, + "endLine": 29, + "endColumn": 29, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..57cca2901b5103e23c4bfa5329be23599edc1a41 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {GridContainerOptions} from './sdk/api/grid_container'; + +@Entry +@Component +struct GridContainerExample { + @State sizeType: SizeType = SizeType.XS + + build() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + }.width('90%') + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..7ad3a1e285f33b3badf1babf3bb10f1d64c2f654 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.arkts2.json @@ -0,0 +1,128 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 32, + "endLine": 24, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 69, + "endLine": 24, + "endColumn": 71, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 81, + "endLine": 24, + "endColumn": 83, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 20, + "endLine": 20, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 39, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 20, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GridContainer\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.json b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridContainerOptionsMargin_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridItem.ets b/ets2panda/linter/test/deprecatedapi/gridItem.ets new file mode 100755 index 0000000000000000000000000000000000000000..d99fe0cef1170522a0a0c0a91f64e9a5d1328900 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridItem.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 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. + */ +@Entry +@Component +struct GridItemExample { + build() { + Column() { + Grid() { + GridItem() + .width('100%') + .height('100%') + .forceRebuild(false); // error + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .rowsTemplate('1fr 1fr 1fr 1fr 1fr') + .width('90%').height(300) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridItem.ets.args.json b/ets2panda/linter/test/deprecatedapi/gridItem.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..aa0b62d6c8953d91487fe6b2039ac56853c4c1a1 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridItem.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridItem.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/gridItem.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..761a8db473d89daaa8cff5d464654a8f8fb68114 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridItem.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 28, + "column": 28, + "endLine": 28, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 35, + "endLine": 29, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 15, + "column": 2, + "endLine": 15, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 7, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Grid\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 9, + "endLine": 21, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GridItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/gridItem.ets.json b/ets2panda/linter/test/deprecatedapi/gridItem.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/gridItem.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/grid_container.ets b/ets2panda/linter/test/deprecatedapi/grid_container.ets new file mode 100755 index 0000000000000000000000000000000000000000..c8d95d26ecd8ccffa7096c5ab7aee865a0767ce5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/grid_container.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct GridContainerExample { + @State sizeType: SizeType = SizeType.MD // error + private options: GridContainerOptions = { + columns: 12, // error + sizeType: this.sizeType, // error + gutter: 10, // error + margin: 20 // error + } + + build() { + Column({ space: 5 }) { + GridContainer({ + columns: 12, + sizeType: this.sizeType, + gutter: 10, + margin: 20 + }) { + Row() { + Text('1') + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.width('90%') + + GridContainer(this.options) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.width('90%') + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG // error + }).backgroundColor(0x317aff) + Button('Auto') + .onClick(() => { + this.sizeType = SizeType.Auto // error + }).backgroundColor(0x317aff) + } + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/grid_container.ets.args.json b/ets2panda/linter/test/deprecatedapi/grid_container.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/grid_container.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/grid_container.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/grid_container.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..903415585d97d6bb272b756bfe2395e83374ec18 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/grid_container.ets.arkts2.json @@ -0,0 +1,418 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 14, + "endLine": 21, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 13, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 21, + "endLine": 28, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 18, + "endLine": 30, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 17, + "endLine": 32, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 17, + "endLine": 33, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 21, + "endLine": 37, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 38, + "endLine": 45, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 27, + "endLine": 46, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 38, + "endLine": 46, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 27, + "endLine": 47, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 38, + "endLine": 47, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 27, + "endLine": 48, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 38, + "endLine": 48, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 21, + "endLine": 50, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 66, + "endLine": 54, + "endColumn": 67, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 35, + "endLine": 65, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 20, + "endLine": 19, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 31, + "endLine": 19, + "endColumn": 39, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 20, + "endLine": 20, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GridContainerOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 5, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 20, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GridContainer\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 9, + "endLine": 35, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 61, + "endLine": 37, + "endColumn": 70, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 7, + "endLine": 41, + "endColumn": 20, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GridContainer\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 9, + "endLine": 42, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 11, + "endLine": 43, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 61, + "endLine": 50, + "endColumn": 70, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 7, + "endLine": 54, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 7, + "endLine": 55, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 9, + "endLine": 56, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 29, + "endLine": 58, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 9, + "endLine": 60, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 29, + "endLine": 62, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/grid_container.ets.json b/ets2panda/linter/test/deprecatedapi/grid_container.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/grid_container.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets b/ets2panda/linter/test/deprecatedapi/image_animator.ets new file mode 100644 index 0000000000000000000000000000000000000000..91114d198fdc7292bc40661bd436d38dc289dcec --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct ImageAnimatorExample { + + build() { + Column({ space: 10 }) { + ImageAnimator() + .preDecode(0) //error + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json b/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..5dba08427fc25db0e2685528623ab4dd5c785369 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 21, + "endLine": 21, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 20, + "endLine": 23, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 20, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ImageAnimator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets.json b/ets2panda/linter/test/deprecatedapi/image_animator.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/inspector.ets b/ets2panda/linter/test/deprecatedapi/inspector.ets new file mode 100644 index 0000000000000000000000000000000000000000..d041d776c5bda0f085360fae3310bf56223a3791 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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 inspector from '@ohos.arkui.inspector' + +@Entry +@Component +struct ImageExample { + build() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Row({ space: 5 }) { + Image($r('app.media.app_icon')) + .width(110) + .height(110) + .border({ width: 1 }) + .id('IMAGE_ID') + } + } + }.height(320).width(360).padding({ right: 10, top: 10 }) + } + + listener:inspector.ComponentObserver = inspector.createComponentObserver('IMAGE_ID') //error + + aboutToAppear() { + let onLayoutComplete:()=>void=():void=>{} + let onDrawComplete:()=>void=():void=>{} + let FuncLayout = onLayoutComplete // bind current js instance + let FuncDraw = onDrawComplete // bind current js instance + + this.listener.on('layout', FuncLayout) + this.listener.on('draw', FuncDraw) + } +} diff --git a/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json b/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..e0f8c248c3d021a37f4d975a415f65f7d9676c03 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json @@ -0,0 +1,198 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 22, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 20, + "endLine": 26, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 21, + "endLine": 27, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 30, + "endLine": 28, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 14, + "endLine": 32, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 47, + "endLine": 32, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 56, + "endLine": 32, + "endColumn": 58, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 25, + "endLine": 23, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 39, + "endLine": 23, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 59, + "endLine": 23, + "endColumn": 68, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 11, + "endLine": 25, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 17, + "endLine": 25, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/inspector.ets.json b/ets2panda/linter/test/deprecatedapi/inspector.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbc16f834896d3f31bfaf1f5acb400c6ce15f134 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets @@ -0,0 +1,121 @@ +/* + * Copyright (c) 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. + */ + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: string[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return this.originDataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index); //error + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index); //error + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDeleted(index); //error + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMoved(from, to); //error + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct MyComponent { + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i <= 20; i++) { + this.data.pushData(`Hello ${i}`); + } + } + + build() { + List({ space: 3 }) { + LazyForEach(this.data, (item: string) => { + ListItem() { + Row() { + Text(item).fontSize(50) + .onAppear(() => { + console.info(`appear: ${item}`); + }) + }.margin({ left: 10, right: 10 }) + } + }, (item: string) => item) + }.cachedCount(5) + } +} diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d1068b2c6c902dc7da3ae85965b941d3d3f0aeea --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json @@ -0,0 +1,298 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 12, + "endLine": 21, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 33, + "endLine": 25, + "endColumn": 38, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 44, + "endLine": 29, + "endColumn": 45, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 16, + "endLine": 37, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 34, + "endLine": 39, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 27, + "endLine": 82, + "endColumn": 32, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 34, + "endLine": 86, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 48, + "endLine": 92, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 14, + "endLine": 102, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 18, + "endLine": 102, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 26, + "endLine": 102, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 19, + "endLine": 108, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 33, + "endLine": 112, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 28, + "endLine": 116, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 39, + "endLine": 116, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 19, + "endLine": 119, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 34, + "endLine": 16, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IDataSource\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 22, + "endLine": 17, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 40, + "endLine": 28, + "endColumn": 58, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 42, + "endLine": 35, + "endColumn": 60, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 2, + "endLine": 97, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 5, + "endLine": 108, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 7, + "endLine": 109, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LazyForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 11, + "endLine": 111, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 13, + "endLine": 112, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.json b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/list.ets b/ets2panda/linter/test/deprecatedapi/list.ets new file mode 100755 index 0000000000000000000000000000000000000000..914b230b1038672dd3b919a7297d3c2e4bc91e23 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/list.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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. + */ +@Entry +@Component +struct ListExample { + build() { + Column() { + List({ space: 20, initialIndex: 0 }) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ + strokeWidth: 2, + color: 0xFFFFFF, + startMargin: 20, + endMargin: 20 + }) + .edgeEffect(EdgeEffect.Spring) + .editMode(false)// error + .width('90%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/list.ets.args.json b/ets2panda/linter/test/deprecatedapi/list.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/list.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/list.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/list.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..6ee23a6d2fb42a822efeabdc59557f924dd242f0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/list.ets.arkts2.json @@ -0,0 +1,148 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 39, + "endLine": 20, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 24, + "endLine": 25, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 24, + "endLine": 27, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 22, + "endLine": 28, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 21, + "endLine": 37, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 15, + "column": 2, + "endLine": 15, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 7, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 24, + "endLine": 21, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Axis\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 20, + "endLine": 22, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BarState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 21, + "endLine": 30, + "endColumn": 31, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"EdgeEffect\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/list.ets.json b/ets2panda/linter/test/deprecatedapi/list.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/list.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/listitem_api.ets b/ets2panda/linter/test/deprecatedapi/listitem_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..1972648696c11df05dd8656018ac78a130f90425 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/listitem_api.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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 {ListItemAttribute,Sticky,EditMode} from './sdk/api/list_item'; + +@Entry +@Component +struct ListItemExample { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + build() { + Column() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() + .sticky(Sticky.Normal) //error + .editable(true) //error + .editable(EditMode.Deletable); //error + }, (item: string) => item) + }.width('90%') + .scrollBar(BarState.Off) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/listitem_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/listitem_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..433328bd56852b5b57d3b62f4a4ded28c9a5ddd8 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.arkts2.json @@ -0,0 +1,228 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 34, + "endLine": 20, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 37, + "endLine": 20, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 40, + "endLine": 20, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 43, + "endLine": 20, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 46, + "endLine": 20, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 49, + "endLine": 20, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 52, + "endLine": 20, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 55, + "endLine": 20, + "endColumn": 56, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 21, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 39, + "endLine": 24, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 21, + "endLine": 27, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 11, + "endLine": 26, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 18, + "endLine": 32, + "endColumn": 26, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BarState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/listitem_api.ets.json b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/listitem_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..28fe3c5414db15869bc5519c5280b4b52e994c83 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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 { matrix4 } from './sdk/api/@ohos.matrix4'; + +@Entry +@Component +struct Test { + private matrix1 = matrix4.rotate({ // error + x: 1, + y: 1, + z: 2, + angle: 30 + }); + private matrix1 = matrix4.copy(); // error + + private matrix1 = matrix4.translate({ x: 100 }); // error + + build() { + Column() { + }.width("100%").margin({ top: 50 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..c2f4de7b044ee3f6425ae1d459c1fa275eb00391 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.arkts2.json @@ -0,0 +1,138 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 29, + "endLine": 20, + "endColumn": 35, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 10, + "endLine": 21, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 10, + "endLine": 22, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 14, + "endLine": 24, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 29, + "endLine": 26, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 29, + "endLine": 28, + "endColumn": 38, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 44, + "endLine": 28, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 35, + "endLine": 32, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.json b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/matrix4Rotate_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/measure.ets b/ets2panda/linter/test/deprecatedapi/measure.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcde2d53ca6739444a392bba783d8e41f98e976c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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 { MeasureText } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + textSize: SizeOptions = MeasureText.measureTextSize({ //error + textContent: "Hello World", + fontSize: '50px' + }); + @State textWidth: number = MeasureText.measureText({ //error + textContent: "Hello World", + fontSize: '50px' + }); + + build() { + Row() { + Column() { + Text(`The width of 'Hello World': ${this.textSize.width}`) + Text(`The width of 'Hello World': ${this.textWidth}`) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/measure.ets.args.json b/ets2panda/linter/test/deprecatedapi/measure.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..a52ce66124292611d03e23134bd8d79db201d134 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 13, + "endLine": 21, + "endColumn": 24, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 4, + "endLine": 25, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 9, + "endLine": 33, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 9, + "endLine": 34, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/measure.ets.json b/ets2panda/linter/test/deprecatedapi/measure.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/mediaquery.ets b/ets2panda/linter/test/deprecatedapi/mediaquery.ets new file mode 100644 index 0000000000000000000000000000000000000000..be7cc2c88613b133dfc05e9890b53441db9753e8 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 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 { mediaquery } from '@kit.ArkUI'; + +@Entry +@Component +struct MediaQueryExample { + @State color: string = '#DB7093' + @State text: string = 'Portrait' + listener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync('(orientation: landscape)'); //error + + onPortrait(mediaQueryResult:mediaquery.MediaQueryResult) { + if (mediaQueryResult.matches) { + this.color = '#FFD700' + this.text = 'Landscape' + } else { + this.color = '#DB7093' + this.text = 'Portrait' + } + } + + aboutToAppear() { + let portraitFunc = (mediaQueryResult: mediaquery.MediaQueryResult): void => this.onPortrait(mediaQueryResult) + this.listener.on('change', portraitFunc); + } + + + aboutToDisappear() { + this.listener.off('change'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(this.text).fontSize(24).fontColor(this.color) + } + .width('100%').height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/mediaquery.ets.args.json b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..da87e06462d7ba4ac3d6d827f41c71376652f0a7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json @@ -0,0 +1,128 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 47, + "column": 32, + "endLine": 47, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 23, + "endLine": 46, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 37, + "endLine": 46, + "endColumn": 43, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 57, + "endLine": 46, + "endColumn": 66, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 91, + "endLine": 46, + "endColumn": 100, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/mediaquery.ets.json b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/minibar_api.ets b/ets2panda/linter/test/deprecatedapi/minibar_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..2429a98b61a670558e1574a9d6d7eac4027e23e9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/minibar_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {PanelType} from './sdk/api/panel' + +@@Entry +@Component +struct WrapContentPanelExample { + @State isVisible: boolean = true + build() { + Column() { + Panel(this.isVisible) + .type(PanelType.Minibar) // error + } + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/minibar_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/minibar_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..54931525a0ddd30f0a0e2c2ae2d1a8f9808892e3 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 2, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 30, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/minibar_api.ets.json b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/minibar_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/navigation.ets b/ets2panda/linter/test/deprecatedapi/navigation.ets new file mode 100644 index 0000000000000000000000000000000000000000..244b22cd1a50d17b88f5a13a767e280d082c89e3 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct NavigationExample { + build() { + Column({ space: 15 }) { + Row() { + Navigation() + .subTitle("test") //error + .toolBar() //error + } + .borderRadius(20) + } + .width('100%') + .margin({ top: 15 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigation.ets.args.json b/ets2panda/linter/test/deprecatedapi/navigation.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3fe72f3f5a600ecead4a4dc985397f74e927b46e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 21, + "endLine": 26, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 20, + "endLine": 29, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 7, + "endLine": 21, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 9, + "endLine": 22, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigation\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigation.ets.json b/ets2panda/linter/test/deprecatedapi/navigation.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigator_api.ets b/ets2panda/linter/test/deprecatedapi/navigator_api.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0a513452e0eb4c7c487eb2d86857aea0a56ce98 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigator_api.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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 {NavigatorInstance,Navigator,NavigatorAttribute} from './sdk/api/navigator'; + +function aa(tt:NavigatorAttribute){//error + const a = new NavigatorAttribute() //error + typeof a.active(false);//error + return a as NavigatorAttribute;//error +} +@Entry +@Component +struct NavigatorExample { + @State active: boolean = false; + @State name: NameObject = { name: 'news' }; + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Start, + justifyContent: FlexAlign.SpaceBetween + }) { + Navigator({//error + target: 'pages/container/navigator/Detail', + type: NavigationType.Push + }).onClick(()=>{ + const attr = new NavigatorAttribute(); //error + attr.target('111')//error + }).params(new TextObject(this.name)) + NavigatorInstance.active(false);//error + }.height(150).width(350).padding(35); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigator_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/navigator_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..274a9bddd0a1f9191655a3ba261e592ebff23cb9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.arkts2.json @@ -0,0 +1,238 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 16, + "endLine": 17, + "endColumn": 34, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 18, + "endLine": 18, + "endColumn": 36, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 18, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 15, + "endLine": 20, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 7, + "endLine": 34, + "endColumn": 16, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 26, + "endLine": 38, + "endColumn": 44, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 14, + "endLine": 39, + "endColumn": 20, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 21, + "endLine": 40, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 25, + "endLine": 41, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 14, + "endLine": 42, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 25, + "endLine": 42, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 38, + "endLine": 42, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 2, + "endLine": 22, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 2, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 4, + "endLine": 25, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 4, + "endLine": 26, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 18, + "endLine": 30, + "endColumn": 31, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 32, + "endLine": 30, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 19, + "endLine": 31, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 23, + "endLine": 32, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 15, + "endLine": 36, + "endColumn": 29, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"NavigationType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigator_api.ets.json b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigator_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navrouter_api.ets b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3f483241757f946564e1f0cac33e32f1f6ca87c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 {NavRouterInstance,NavRouter,NavRouterAttribute} from './sdk/api/nav_router'; +import {NavRouteMode,NavRouterInterface,RouteInfo} from './sdk/api/nav_router'; + +@Entry +@Component +struct NavRouterExample { + @State isActiveWLAN: boolean = false + @State isActiveBluetooth: boolean = false + + build() { + Navigation() { + NavRouter() //error + .mode(NavRouteMode.PUSH_WITH_RECREATE) //error*3 + NavRouter({name:'',param:undefined}) //error *3 + .mode(NavRouteMode.PUSH_WITH_RECREATE) //error*3 + .onStateChange((isActivated: boolean) => { //error + console.log(NavRouteMode.REPLACE+'') //error*2 + const attr = new NavRouterAttribute(); //error + attr.mode(NavRouteMode.PUSH); //error*3 + }) + NavRouterInstance.mode(NavRouteMode.REPLACE) //error*3 + } + } +} +class Test implements NavRouterInterface {//error + public (): NavRouterAttribute;//error + public (value: RouteInfo): NavRouterAttribute;//error *2 + public (value?: RouteInfo): NavRouterAttribute|void {//error*2 + const attribute: NavRouterAttribute|undefined = undefined;//error + } +} +interface Demo extends NavRouterInterface{//error +} diff --git a/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..bbfdaf93fa58ed13e4e485222fdb3018bd1a809d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.arkts2.json @@ -0,0 +1,428 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 14, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 7, + "endLine": 26, + "endColumn": 16, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 15, + "endLine": 27, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 28, + "endLine": 27, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 10, + "endLine": 30, + "endColumn": 23, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 10, + "endLine": 29, + "endColumn": 14, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 16, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 18, + "endLine": 28, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 26, + "endLine": 28, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 15, + "endLine": 29, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 28, + "endLine": 29, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 35, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 36, + "endLine": 31, + "endColumn": 43, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 28, + "endLine": 32, + "endColumn": 46, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 16, + "endLine": 33, + "endColumn": 20, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 21, + "endLine": 33, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 34, + "endLine": 33, + "endColumn": 38, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 25, + "endLine": 35, + "endColumn": 29, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 30, + "endLine": 35, + "endColumn": 42, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 43, + "endLine": 35, + "endColumn": 50, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 3, + "endLine": 40, + "endColumn": 9, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 3, + "endLine": 40, + "endColumn": 33, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 14, + "endLine": 40, + "endColumn": 32, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 3, + "endLine": 41, + "endColumn": 9, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 3, + "endLine": 41, + "endColumn": 49, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 18, + "endLine": 41, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 30, + "endLine": 41, + "endColumn": 48, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 3, + "endLine": 42, + "endColumn": 9, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 3, + "endLine": 44, + "endColumn": 4, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 31, + "endLine": 42, + "endColumn": 54, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 19, + "endLine": 42, + "endColumn": 28, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 50, + "endLine": 42, + "endColumn": 54, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 31, + "endLine": 42, + "endColumn": 49, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 22, + "endLine": 43, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 24, + "endLine": 46, + "endColumn": 42, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigation\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.json b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navrouter_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/node_api.ets b/ets2panda/linter/test/deprecatedapi/node_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..5e1932af73e10d644a935daf8142e3bcd77da2ce --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/node_api.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 {XComponentType} from './sdk/api/enums' +@Entry +@Component +struct XComponentNodeExample { + build() { + Column() { + XComponent(XComponentType.NODE) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/node_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/node_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/node_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/node_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/node_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..e2ed9c2a93b7bcf0b68f02b1f142c3305662a9a1 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/node_api.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 33, + "endLine": 21, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 7, + "endLine": 21, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/node_api.ets.json b/ets2panda/linter/test/deprecatedapi/node_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/node_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets new file mode 100755 index 0000000000000000000000000000000000000000..30544f0142a52e321e37147d8c58fbb7eae60ead --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 { Animator as animator, AnimatorOptions, AnimatorResult } from '@kit.ArkUI'; + +let options: AnimatorOptions = { + duration: 1500, + easing: "friction", + delay: 0, + fill: "forwards", + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, +}; +this.animator = animator.createAnimator(options); // error +let animatorResult: AnimatorResult = animator.create(options); +animatorResult.update(options); // error diff --git a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.args.json b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..23bca9ca73b8c91083d1bdf04febefef58902c18 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 13, + "endLine": 19, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 10, + "endLine": 21, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 15, + "endLine": 24, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 31, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Animator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.json b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_curves.ets b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets new file mode 100755 index 0000000000000000000000000000000000000000..4b8d21ca2c510d663890861a144a9d9d6f2cfce3 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 { curves } from '@kit.ArkUI'; + +class AnimationHelper { + steps() { + curves.steps(9, true); // error + } +} + +curves.spring(10, 1, 228, 30) // error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.args.json b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..cc2a63ae42f614da0232380e5636ad5de820f77f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 18, + "endLine": 19, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 15, + "endLine": 23, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 19, + "endLine": 23, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 22, + "endLine": 23, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.json b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_curves.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets new file mode 100755 index 0000000000000000000000000000000000000000..f5b77dfb5b28a5869dd2791fdf978b15be9e0e8a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 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 { matrix4 } from '@kit.ArkUI'; + +@Entry +@Component +struct Test { + private matrix1 = matrix4 + .scale({ + // error + x: 2, + y: 3, + z: 4, + centerX: 50, + centerY: 50 + }); + private originPoint: number[] = [50, 50]; + private transformPoint = matrix4.transformPoint([this.originPoint[0], this.originPoint[1]]); // error + private matrix2 = matrix4.identity().scale({ x: 2 }); + + build() { + Column() { + Text('Test') + .width("40%") + .height(100) + .transform(this.matrix1) + Text(`矩阵变换后的坐标:[${this.transformPoint}]`) + .fontSize(16) + .margin({ top: 100 }) + Text("test") + .transform(matrix4.combine(this.matrix2))// error + .width("40%") + .height(100) + .margin({ top: 50 }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.args.json b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..c3cf76ae53bf4d3ce63ea49c4c17ed5da474169e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.arkts2.json @@ -0,0 +1,238 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 3, + "endLine": 29, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 10, + "endLine": 26, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 16, + "endLine": 27, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 16, + "endLine": 28, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 36, + "endLine": 30, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 40, + "endLine": 30, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 3, + "endLine": 31, + "endColumn": 95, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 3, + "endLine": 32, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 51, + "endLine": 32, + "endColumn": 52, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 19, + "endLine": 41, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 24, + "endLine": 42, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 17, + "endLine": 46, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 24, + "endLine": 47, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 5, + "endLine": 35, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 7, + "endLine": 36, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 7, + "endLine": 43, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.json b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..336c0150b8a3f1496c3d317b9aaa4d7598c75242 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_matrix4.ets.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 3, + "endLine": 29, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 3, + "endLine": 31, + "endColumn": 95, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 3, + "endLine": 32, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets new file mode 100755 index 0000000000000000000000000000000000000000..dd82bbcdc35a7483e68edae1991675110ffb3dfd --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets @@ -0,0 +1,130 @@ +/* + * Copyright (c) 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 prompt from '@ohos.prompt'; + +const toastOptions: prompt.ShowToastOptions = { + message: 'Message Info', //error + duration: 2000 +}; + +prompt.showDialog(toastOptions)//error + .then(data => { + console.info('showDialog success, click button: ' + data.index); + }) + .catch((err: Error) => { + console.info('showDialog error: ' + err); + }) + +const dialogOptions: prompt.ShowDialogOptions = { // error + title: 'Title Info', + message: 'Message Info' +}; + +prompt.showDialog(dialogOptions)// error + .then(data => { + console.info('showDialog success'); + }) + +prompt.showDialog({ + title: 'showDialog Title Info', // error + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + }, + { + text: 'button2', + color: '#000000' + } + ] +}, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; + } + console.info('showDialog success callback, click button: ' + data.index); // error +}); +prompt.showActionMenu({ + title: 'Title Info', + buttons: [// error + { + text: 'button1', + color: '#000000' + }, + { + text: 'button2', + color: '#000000' + } + ], +}) + .then(data => { + console.info('showActionMenu success, click button: ' + data.index); + }) + .catch((err: Error) => { + console.info('showActionMenu error: ' + err); + }) + +const button: prompt.Button = { + text: 'test', + color: 'red' // error +}; + +prompt.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [button], +}) + .then(data => { + console.info('showDialog success, click button: ' + data.index); + }) + .catch((err: Error) => { + console.info('showDialog error: ' + err); + }) + +prompt.showToast({ // error + message: 'Message Info', + duration: 2000 +}); + +let response: Promise = prompt.showDialog({ // error + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + }, + { + text: 'button2', + color: '#000000' + } + ], +}) + .then(data => { + console.info('showDialog success, click button: ' + data.index); + return data; + }) + .catch((err: Error) => { + console.info('showDialog error: ' + err); + throw err; + }); + +prompt.showToast({ // error + message: 'Message Info', + duration: 2000 +}); + diff --git a/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.args.json b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..a77d3677c30d54dad1b9c7c1fb444ca86e2873b6 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.arkts2.json @@ -0,0 +1,128 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 9, + "endLine": 37, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 10, + "endLine": 54, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 9, + "endLine": 74, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 9, + "endLine": 91, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 13, + "endLine": 100, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 9, + "endLine": 120, + "endColumn": 4, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 9, + "endLine": 117, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 13, + "endLine": 128, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.json b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..642f794c6c14c1c3e865b2e2ca66083f1b4f93e7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_prompt.ets.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 9, + "endLine": 37, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 10, + "endLine": 54, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 9, + "endLine": 74, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 9, + "endLine": 91, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 9, + "endLine": 120, + "endColumn": 4, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 9, + "endLine": 117, + "endColumn": 13, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_router.ets b/ets2panda/linter/test/deprecatedapi/ohos_router.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae611f9ff3fd531d665d86b222a9b1c635f40421 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_router.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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 router from '@ohos.router'; + +router.enableAlertBeforeBackPage({ // error + message: 'Message Info' +}); + +class routerParams { + data1: string; + + constructor(str: string) { + this.data1 = str; + } +} + +router.replace({ // error + url: 'pages/detail', + params: new routerParams('message') +}); + +router.disableAlertBeforeBackPage(); // error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_router.ets.args.json b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/ohos_router.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_router.ets.json b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/ohos_router.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..bf817a2f4843d7eef5ce101db9799348ea58f9c6 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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 {PanelMode} from './sdk/api/panel'; + +@Entry +@Component +struct PanelExample { + @State show: boolean = false + + build() { + Column() { + Panel(this.show) { + Column() { + } + } + .mode(PanelMode.Mini) //error + Panel(this.show) { + Column() { + } + } + .mode(PanelMode.Half) //error + Panel(this.show) { + Column() { + } + } + .mode(PanelMode.Full) //error + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..14b1f5d64ed0337c3e6cf82d87d38534c143dd7d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.arkts2.json @@ -0,0 +1,178 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 28, + "column": 13, + "endLine": 28, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 13, + "endLine": 33, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 23, + "endLine": 33, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 13, + "endLine": 38, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 23, + "endLine": 38, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 7, + "endLine": 34, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 9, + "endLine": 35, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.json b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/panelModePanelMode_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..a15ecce3cf2b761577d6397d9089a1d2af58e15e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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 { PersistentStorage } from './sdk/api/common_ts_ets_api'; + +PersistentStorage.PersistProps([{ key: 'highScore', defaultValue: '0' }, { key: 'wightScore', defaultValue: '1' }]); //error +PersistentStorage.Keys(); //error \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..61e8ea37dee70895b1bd001f176eee32fac878c5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.arkts2.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 19, + "endLine": 17, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 19, + "endLine": 18, + "endColumn": 23, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.json b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/persistentStoragePersistProps_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/progress.ets b/ets2panda/linter/test/deprecatedapi/progress.ets new file mode 100755 index 0000000000000000000000000000000000000000..523cdab0b9967e71bed8105324fb99506d3a6a8a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/progress.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct ProgressExample { + private gradientColor: LinearGradient = new LinearGradient([{ color: Color.Yellow, offset: 0.5 }, + { color: Color.Orange, offset: 1.0 }]) + private progress: ProgressOptions = { + value: 70, + total: 100, + type: ProgressType.Ring, + style: ProgressStyle.Linear // error + }; + + build() { + Column({ space: 15 }) { + Text('Gradient Color').fontSize(9).fontColor(0xCCCCCC).width('90%') + Progress(this.progress) + .width(100).style({ strokeWidth: 20 }) + .color(this.gradientColor) + }.width('100%').padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/progress.ets.args.json b/ets2panda/linter/test/deprecatedapi/progress.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/progress.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..474b79dc90ca81532da347bba409e01c285b7862 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 26, + "endLine": 19, + "endColumn": 40, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 47, + "endLine": 19, + "endColumn": 61, + "problem": "DuplicateDeclNameFromSdk", + "suggest": "", + "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 47, + "endLine": 19, + "endColumn": 61, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 12, + "endLine": 22, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 12, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 21, + "endLine": 29, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 39, + "endLine": 30, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 16, + "endLine": 32, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 42, + "endLine": 32, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 36, + "endLine": 34, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 26, + "endLine": 19, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LinearGradient\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 47, + "endLine": 19, + "endColumn": 61, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LinearGradient\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 72, + "endLine": 19, + "endColumn": 77, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 14, + "endLine": 20, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 21, + "endLine": 21, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ProgressOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 37, + "endLine": 21, + "endColumn": 49, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ProgressType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 11, + "endLine": 24, + "endColumn": 23, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ProgressType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 12, + "endLine": 25, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ProgressStyle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 7, + "endLine": 30, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Progress\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/progress.ets.json b/ets2panda/linter/test/deprecatedapi/progress.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/progress.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/prompts_api.ets b/ets2panda/linter/test/deprecatedapi/prompts_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..c6f549d289635b8e3271dbdc7553da18cb93b824 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/prompts_api.ets @@ -0,0 +1,73 @@ +/* + * Copyright (c) 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 prompt from './sdk/api/@ohos.prompt' + +prompt.showToast({ + message: 'www', + duration: 2000, + bottom: 20, +}); + +prompt.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + }, + ], +}) + +prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + }, + { + text: 'item2', + color: '#000000' + }, + ] +}, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; + } + console.info('showActionMenu success callback, click button: ' + data.index); +}) + +prompt.showDialog({ + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000' + }, + { + text: 'button2', + color: '#000000' + } + ] +}, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; + } + console.info('showDialog success callback, click button: ' + data.index); +}); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/prompts_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/prompts_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..948a10579177affdf4176c29dd822e8b021bebd9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 8, + "endLine": 17, + "endColumn": 17, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 3, + "endLine": 19, + "endColumn": 11, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 13, + "endLine": 19, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 3, + "endLine": 20, + "endColumn": 9, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 11, + "endLine": 20, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 8, + "endLine": 23, + "endColumn": 18, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 8, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 8, + "endLine": 34, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 7, + "endLine": 43, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 10, + "endLine": 46, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 8, + "endLine": 54, + "endColumn": 18, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 3, + "endLine": 55, + "endColumn": 8, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 3, + "endLine": 56, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 7, + "endLine": 60, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 7, + "endLine": 64, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 10, + "endLine": 67, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/prompts_api.ets.json b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..bf8516a85b5a1242ca48f44d05087ec3ee41f55c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/prompts_api.ets.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 10, + "endLine": 46, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 10, + "endLine": 67, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets b/ets2panda/linter/test/deprecatedapi/refresh.ets new file mode 100644 index 0000000000000000000000000000000000000000..f58c225b7c6e748e4cf0ac5c7b53abbe59c409f5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct RefreshExample { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, offset: 1 }) { //error + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()); + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json b/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..9a3dd460846c069c65f1b3e56256bb73acce6543 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 26, + "column": 29, + "endLine": 26, + "endColumn": 48, + "problem": "DoubleDollarBindingNotSupported", + "suggest": "", + "rule": "\"$$\" for bidirectional data binding is not supported (arkui-no-$$-bidirectional-data-binding)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 58, + "endLine": 26, + "endColumn": 59, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 27, + "endLine": 33, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 25, + "endLine": 34, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 31, + "endLine": 36, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 22, + "endLine": 51, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 7, + "endLine": 26, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Refresh\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 13, + "endLine": 29, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 15, + "endLine": 30, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 28, + "endLine": 35, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 24, + "endLine": 46, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 20, + "endLine": 47, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BarState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 38, + "endLine": 52, + "endColumn": 51, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RefreshStatus\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets.json b/ets2panda/linter/test/deprecatedapi/refresh.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..542dae4405efc784596a00e80d41e97e2be54f43 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 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 Router from './sdk/api/@system.router'; + +class Z{ + disableAlertBeforeBackPage() { + Router.disableAlertBeforeBackPage({ + success: () => { + console.log('success'); + }, + cancel: () => { + console.log('cancel'); + }, + complete: () => { + console.log('cancel'); + } + }); + } +} +export default new Z() + +class C{ + replacePage() { + Router.replace({ + uri: 'pages/detail/detail', + params: { + data1: 'message' + } + }); + } +} +export default new C() + +class I{ + clearPage() { + Router.clear(); + } +} +export default new I() + +Router \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..09884303b52f5cf0de482cc38402cd9032d67284 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 38, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 7, + "endLine": 20, + "endColumn": 14, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 7, + "endLine": 26, + "endColumn": 15, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 12, + "endLine": 36, + "endColumn": 19, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 7, + "endLine": 37, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 7, + "endLine": 38, + "endColumn": 13, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 12, + "endLine": 48, + "endColumn": 17, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 1, + "endLine": 53, + "endColumn": 7, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.json b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..bc846022c12b599c5a2bb361e32514e403fa3d3d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerDisableAlertBeforeBackPage_api.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 53, + "column": 1, + "endLine": 53, + "endColumn": 7, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..0a37728e9f10164a45fd3a1f232fc03003351f47 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 router from './sdk/api/@system.router'; + +class H{ + backToDetail() { + router.back({uri:'pages/detail/detail'}); + } +} +export default new H() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.json b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerOptionsUri_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerPush_api.ets b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..e8b1028e9481c37aa5c25a1a42b54ca6116c1c78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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 { router } from './sdk/api/@ohos.router'; + +class innerParams { + data3: number[]; + + constructor(tuple: number[]) { + this.data3 = tuple; + } +} + +class routerParams { + data1: string; + data2: innerParams; + + constructor(str: string, tuple: number[]) { + this.data1 = str; + this.data2 = new innerParams(tuple); + } +} + +router.push({ + url: 'pages/routerpage2', + params: new routerParams('message', [123, 456, 789]) +}); \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..f0f575da71d5248e1158365366f8cf6f4df24e44 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.arkts2.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 35, + "column": 8, + "endLine": 35, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 40, + "endLine": 37, + "endColumn": 43, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 45, + "endLine": 37, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 50, + "endLine": 37, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.json b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerPush_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..8bc04f1c264c776d0ee6e858b77dce9d0c025b20 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 RouterState from './sdk/api/@system.router'; + +class K{ + getState() { + let page = RouterState.getState().index; + } +} +export default new K() \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..bd4e05e281364c8da7fbd022427d8660f057aefa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.json b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..bd4e05e281364c8da7fbd022427d8660f057aefa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/routerStateIndex_api.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/scroll_api.ets b/ets2panda/linter/test/deprecatedapi/scroll_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..0e584adaccb79dfd4d8327c19cb656f8e56df46b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/scroll_api.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 {ScrollDirection,Scroller,ScrollAttribute} from './sdk/api/scroll'; + +const scroller: Scroller = new Scroller() +@Entry +@Component +struct ScrollExample { + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(scroller) + .scrollable(ScrollDirection.Free) //error + Column() { + }.width('100%') + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/scroll_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/scroll_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..f32e2bf1c3875937214427864c21697b2fc00082 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 25, + "column": 37, + "endLine": 25, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Stack\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Alignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroll\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/scroll_api.ets.json b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/scroll_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.animator.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.animator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fea7915eac8a117c22f118e80e9b8c2cb50bf0e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.animator.d.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 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. + */ + +export declare class Animator { + static createAnimator(options: AnimatorOptions): AnimatorResult; + static create(options: AnimatorOptions): AnimatorResult; +} + +export interface AnimatorOptions { + duration: number; + easing: string; + delay: number; + fill: "none" | "forwards" | "backwards" | "both"; + direction: "normal" | "reverse" | "alternate" | "alternate-reverse"; + iterations: number; + begin: number; + end: number; +} + +export interface AnimatorResult { + update(options: AnimatorOptions): void; + reset(options: AnimatorOptions): void; + reset(options: AnimatorOptions | SimpleAnimatorOptions): void; + play(): void; + finish(): void; + pause(): void; + cancel(): void; + reverse(): void; + onframe: (progress: number) => void; + onFrame: (progress: number) => void; + onfinish: () => void; + onFinish: () => void; + oncancel: () => void; + onCancel: () => void; + onrepeat: () => void; + onRepeat: () => void; + setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange): void; +} + +export declare class SimpleAnimatorOptions { + duration(duration: number): SimpleAnimatorOptions; + easing(curve: string): SimpleAnimatorOptions; + delay(delay: number): SimpleAnimatorOptions; + fill(fillMode: FillMode): SimpleAnimatorOptions; + direction(direction: PlayMode): SimpleAnimatorOptions; + iterations(iterations: number): SimpleAnimatorOptions; +} + +declare enum PlayMode { + Normal, + Reverse, + Alternate, + AlternateReverse +} + +declare interface ExpectedFrameRateRange { + min: number; + max: number; + expected: number; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.curves.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.curves.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8d7164186ce16777d6ebc2f398c765abbc41d631 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.curves.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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. + */ + +export declare namespace curves { + function init(curve?: Curve): string; +} diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.font.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.font.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d8a7e565ce3b06649db971abadab352a0dbebab4 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.font.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ +export declare namespace font { + function getFontByName(fontName: string): FontInfo; + function getSystemFontList(): Array; + function registerFont(options: FontOptions): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.matrix4.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.matrix4.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..29f253a989d28078c193956f21a11690401d0a65 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.matrix4.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export declare namespace matrix4 { + function rotate(options: RotateOption): Matrix4Transit; + function copy(): Matrix4Transit; + function translate(options: TranslateOption): Matrix4Transit; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.prompt.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.prompt.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d8a0fae2aac6e8af4a52dc294f23fe187d28f284 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.prompt.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 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. + */ +declare namespace prompt { + + interface ShowToastOptions { + message: string; + duration?: number; + bottom?: string | number; + } + interface Button { + text: string; + color: string; + } + interface ShowDialogSuccessResponse { + index: number; + } + interface ShowDialogOptions { + title?: string; + message?: string; + buttons?: [ + Button, + Button?, + Button? + ]; + } + interface ActionMenuSuccessResponse { + index: number; + } + interface ActionMenuOptions { + title?: string; + buttons: [ + Button, + Button?, + Button?, + Button?, + Button?, + Button? + ]; + } + function showToast(options: ShowToastOptions): void; + function showDialog(options: ShowDialogOptions, callback: AsyncCallback): void; + function showDialog(options: ShowDialogOptions): Promise; + function showActionMenu(options: ActionMenuOptions, callback: AsyncCallback): void; + function showActionMenu(options: ActionMenuOptions): Promise; +} +export default prompt; diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.router.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.router.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c2e6dc51a3b83ba737b17072cac18e4d678398d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@ohos.router.d.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +export declare namespace router { + function push(options: RouterOptions): void; +} + +export interface BackRouterOptions { + uri?: string; + params?: Object; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@system.app.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.app.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..274e07311ccd4ebbf7d5ce242853d3012a68b401 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.app.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ +export default class App { + static setImageCacheCount(value: number): void; + static setImageRawDataCacheSize(value: number): void; + static setImageFileCacheSize(value: number): void; + static screenOnVisible(options?: ScreenOnVisibleOptions): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@system.prompt.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.prompt.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cf2a916ea8b3603fc88e2f50f42a4853f197e6e5 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.prompt.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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. + */ +export default class Prompt { + static showToast(options: ShowToastOptions): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/@system.router.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.router.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..771cd691992e9241b0a0f94cecca58e5bd9d2fdf --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/@system.router.d.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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. + */ + +export default class Router { + static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; + static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; + static replace(options: RouterOptions): void; + static clear(): void; +} + +export interface DisableAlertBeforeBackPageOptions { + success?: (errMsg: string) => void; + complete?: () => void; +} + +export interface RouterState { + index: number; + name: string; + path: string; +} + +export interface RouterOptions { + uri: string; + params?: Object; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/ChipGroup.d.ets b/ets2panda/linter/test/deprecatedapi/sdk/api/ChipGroup.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..552b88513cf344f80c93b4409b36e817285e9fd1 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/ChipGroup.d.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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. + */ +export interface ChipGroupItemOptions { + suffixIcon?: IconOptions; +} diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/action_sheet.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/action_sheet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ad8ab60c94222eab5c432cbaaec1cf171730974 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/action_sheet.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +export interface ActionSheetOptions { + autoCancel?: boolean; + showInSubWindow?: boolean; + isModal?: boolean; +} + +export declare class ActionSheet { + static show(value: ActionSheetOptions); +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/alert_dialog.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/alert_dialog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a26a6671d472ddf5d82fb800d2ed4e456975739b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/alert_dialog.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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. + */ + +export declare class AlertDialog { + static show(value: AlertDialogParamWithConfirm | AlertDialogParamWithButtons | AlertDialogParamWithOptions); +} + +declare interface AlertDialogParamWithConfirm extends AlertDialogParam { + confirm?: AlertDialogButtonBaseOptions; +} + +declare interface AlertDialogParamWithButtons extends AlertDialogParam { + primaryButton: AlertDialogButtonBaseOptions; + secondaryButton: AlertDialogButtonBaseOptions; +} + +declare interface AlertDialogParamWithOptions extends AlertDialogParam { + buttons: Array; +} + +declare interface AlertDialogButtonBaseOptions {} + +declare interface AlertDialogParam {} + +declare interface AlertDialogButtonOptions extends AlertDialogButtonBaseOptions { + primary?: boolean; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/common.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/common.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ab9ed204bd66018bf38960d81ae116ca120c54ac --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/common.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 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. + */ + +export declare interface CustomPopupOptions { + maskColor?: Color | string | Resource | number; +} + +export declare interface DragEvent { + getX(): number; + getY(): number; +} +declare class CommonMethod { + gridSpan(value: number): T; + gridOffset(value: number): T; +} +export declare interface LayoutInfo {} +export declare interface LayoutChild {} +export declare interface LayoutBorderInfo {} +export declare interface TransitionOptions {} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/common_ts_ets_api.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/common_ts_ets_api.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4498350f03186a2debad00175b32cd533f56ba7f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/common_ts_ets_api.d.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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. + */ + +export declare class LocalStorage { + constructor(initializingProperties?: Object); + static getShared(): LocalStorage; +} + +export declare class Environment { + static EnvProp(key: string, value: S): boolean; + static Keys(): Array; + static EnvProps(props: { + key: string; + defaultValue: any; + }[]): void; +} + +export declare class AppStorage { + static IsMutable(propName: string): boolean; + static Get(propName: string): T | undefined; + static Clear(): boolean; + static Delete(propName: string): boolean; + static Size(): number; +} + +export declare class PersistentStorage { + static PersistProps(properties: { + key: string; + defaultValue: any; + }[]): void; + static Keys(): Array; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/enums.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/enums.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f08eae1aea29c05b534457210c81d5a22c6619bb --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/enums.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +export declare enum XComponentType { + SURFACEE, + COMPONENT, + TEXTURE, + NODE +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/grid.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/grid.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..49c677c793dfb970977a3ffeca4e5c178e0fffa4 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/grid.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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. + */ + +export declare class GridAttribute extends ScrollableCommonMethod { + onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): GridAttribute; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/grid_container.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/grid_container.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6cbc689ddd628a95391cfd57e7ecb9566b1d0580 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/grid_container.d.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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. + */ + +export interface GridContainerInterface { + + (value?: GridContainerOptions): GridContainerAttribute; +} + +export declare class GridContainerAttribute extends ColumnAttribute { +} + +export declare enum SizeType { + Auto, + XS, + SM, + MD, + LG +} + +export declare interface GridContainerOptions { + columns?: number | "auto"; + sizeType?: SizeType; + gutter?: number | string; + margin?: number | string; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/list_item.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/list_item.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8394f36bafdd354579db5e49ae75729d7047f35 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/list_item.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 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. + */ + +export declare class ListItemAttribute extends CommonMethod { + sticky(value: Sticky): ListItemAttribute; + editable(value: boolean | EditMode): ListItemAttribute; +} + +export declare enum Sticky { + None, + Normal, + Opacity +} + +export declare enum EditMode { + None, + Deletable, + Movable +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/nav_router.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/nav_router.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddce579ce4cdf1ce5b613b2143b67ee8e921bb63 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/nav_router.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + +export declare const NavRouterInstance: NavRouterAttribute; +export declare const NavRouter: NavRouterInterface; + +export declare class NavRouterAttribute extends CommonMethod { + mode(mode: NavRouteMode): NavRouterAttribute; + onStateChange(callback: (isActivated: boolean) => void): NavRouterAttribute; +} + +export declare enum NavRouteMode{ + PUSH_WITH_RECREATE, + PUSH, + REPLACE +} + +export declare interface NavRouterInterface { + (): NavRouterAttribute + (value: RouteInfo): NavRouterAttribute; +} + +export declare interface RouteInfo { + name: string; + param?: unknown; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/navigator.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/navigator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a9894459b38b9fa1d352eab3f6e0ae084faa56c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/navigator.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +export declare const NavigatorInstance: NavigatorAttribute; +export declare const Navigator: NavigatorInterface; + +export declare class NavigatorAttribute extends CommonMethod { + active(value: boolean): NavigatorAttribute; + type(value: NavigationType): NavigatorAttribute; + target(value: string): NavigatorAttribute; + params(value: object): NavigatorAttribute; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/panel.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/panel.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b011566efad9aec0da31ebd343302136d239738f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/panel.d.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +export declare enum PanelHeight { + WRAP_CONTENT = 'wrapContent' +} +export declare enum PanelType { + Minibar = 0, + Foldable = 1, + Temporary = 2, + CUSTOM = 3 +} +export declare enum PanelMode { + Mini, + Half, + Full +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/scroll.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/scroll.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96bb53c6482b7d53a7ee4311430a9cf73ed85bb2 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/scroll.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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. + */ + +export declare class ScrollAttribute extends ScrollableCommonMethod { + onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute; + onScrollEnd(event: () => void): ScrollAttribute; +} + +export declare enum ScrollDirection { + Vertical, + Horizontal, + Free, + None +} +export declare class Scroller{ + scrollPage(value: { + next: boolean; + direction?: Axis; + }); +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/slider.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/slider.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2aae70dd88065d93815de2de9480f26f4557d78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/slider.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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. + */ +export declare class SliderAttribute extends CommonMethod { + minLabel(value: string): SliderAttribute; + maxLabel(value: string): SliderAttribute; +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sdk/api/swiper.d.ts b/ets2panda/linter/test/deprecatedapi/sdk/api/swiper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c33e754d3ab49d627939ac10257d55e2b197abb --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sdk/api/swiper.d.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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. + */ + +export declare interface IndicatorStyle { + left?: Length; + top?: Length; + right?: Length; + bottom?: Length; + size?: Length; + mask?: boolean; + color?: ResourceColor; + selectedColor?: ResourceColor; +} +export declare class SwiperAttribute extends CommonMethod { + indicatorStyle(value?: IndicatorStyle): SwiperAttribute; +} + +export declare enum SwiperDisplayMode { + Stretch, + AutoLinear, + STRETCH, + AUTO_LINEAR +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..2adcbc65c5e9e47fa498a1e5ee11cbb438e674fd --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 App from './sdk/api/@system.app'; + +export default class Req { + requestFullWindow() { + App.setImageCacheCount(104857600); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..d53d7bd350bf64c8d86436d990c5a6aca459e6de --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.arkts2.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 28, + "endLine": 19, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.json b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageCacheCount_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..d391c2718ccca26b50f16cf76512cefc4705b5c0 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 App from './sdk/api/@system.app'; + +export default class Req { + requestFullWindow() { + App.setImageFileCacheSize(104857600); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..5f505ff2ec724a5d3fd88615cb5227a72b7c65be --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.arkts2.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 30, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 31, + "endLine": 19, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.json b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageFileCacheSize_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..8e717bba1fb9c70ec174ba47feafac997e8dd6ad --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 App from './sdk/api/@system.app'; + +export default class Req { + requestFullWindow() { + App.setImageRawDataCacheSize(104857600); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ea7d95ceec648ca7c330ae7cae8b137c45f47aec --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.arkts2.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 34, + "endLine": 19, + "endColumn": 43, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.json b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/setImageRawDataCacheSize_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/shortName.ets b/ets2panda/linter/test/deprecatedapi/shortName.ets new file mode 100755 index 0000000000000000000000000000000000000000..a51ac48ceb7d93ead8aea6e9cbf39e76a91c84b7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/shortName.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 { ElementName } from './sdk/api/elementName'; + +funtion a() { + console.log(ElementName.shortName) +} diff --git a/ets2panda/linter/test/deprecatedapi/shortName.ets.args.json b/ets2panda/linter/test/deprecatedapi/shortName.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/shortName.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/shortName.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/shortName.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/shortName.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/shortName.ets.json b/ets2panda/linter/test/deprecatedapi/shortName.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/shortName.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showActionMenu.ets b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets new file mode 100755 index 0000000000000000000000000000000000000000..543db4aed1d7d5f0430132be6de1ae4a9c348768 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 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 prompt from './sdk/api/@ohos.prompt'; + + +prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + }, + { + text: 'item2', + color: '#000000' + }, + ] +}, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; + } + console.info('showActionMenu success callback, click button: ' + data.index); +}) + +prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666' + }, + { + text: 'item2', + color: '#000000' + }, + ] +}).then(()=>{ + +}) \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.args.json b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..b44f2449617b1c6218a3775622194c04a81f140f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.arkts2.json @@ -0,0 +1,118 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 18, + "column": 8, + "endLine": 18, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 3, + "endLine": 20, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 10, + "endLine": 30, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 8, + "endLine": 38, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 3, + "endLine": 40, + "endColumn": 10, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 7, + "endLine": 43, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 12, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.json b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..496f2c021f17b4c85cd1fe5c601d30e5686c36e9 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showActionMenu.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 10, + "endLine": 30, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showToast_api.ets b/ets2panda/linter/test/deprecatedapi/showToast_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..a59df53bff76a6fa7a1da5fc6c3fdde2df680c97 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showToast_api.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 Prompt from "./sdk/api/@system.prompt" +class A{ + showToast() { + Prompt.showToast({ + message: 'Message Info', + }); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/showToast_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/showToast_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..9f33816e3cec28049daae4692712ce23c2a5b084 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/showToast_api.ets.json b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f33816e3cec28049daae4692712ce23c2a5b084 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/showToast_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/sizeType.ets b/ets2panda/linter/test/deprecatedapi/sizeType.ets new file mode 100755 index 0000000000000000000000000000000000000000..ec52efea3e623cf9c7eb7b31292ae6d64b61a3ce --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeType.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 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 { SizeType } from './sdk/api/grid_container' + +@Entry +@Component +struct GridContainerExample { + @State sizeType: SizeType = SizeType.XS + + build() { + Column({ space: 5 }) { + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeType.ets.args.json b/ets2panda/linter/test/deprecatedapi/sizeType.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeType.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeType.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/sizeType.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d3824f7d72530407fa1d0a5e53e9cdf686a39cc1 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeType.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 40, + "endLine": 20, + "endColumn": 42, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 66, + "endLine": 24, + "endColumn": 67, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 29, + "endLine": 28, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 38, + "endLine": 28, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 29, + "endLine": 32, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 38, + "endLine": 32, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 29, + "endLine": 36, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 38, + "endLine": 36, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 29, + "endLine": 40, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 38, + "endLine": 40, + "endColumn": 40, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 35, + "endLine": 43, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 9, + "endLine": 34, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 9, + "endLine": 38, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeType.ets.json b/ets2panda/linter/test/deprecatedapi/sizeType.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeType.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..9f6cc8207dfe58be5217f4abed9573cf2c3d7a64 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {SizeType} from './sdk/api/grid_container'; + +@Entry +@Component +struct ResponsiveExample { + @StorageLink('currentSizeType') currentSizeType: SizeType = SizeType.SM; + + build() { + Column() { + if (this.currentSizeType === SizeType.XS) { + } + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..969b9eb44b53b8bd38a164e1786f39e7e95d0428 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 63, + "endLine": 20, + "endColumn": 71, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 72, + "endLine": 20, + "endColumn": 74, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 36, + "endLine": 24, + "endColumn": 44, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 45, + "endLine": 24, + "endColumn": 47, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"StorageLink\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.json b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/sizeTypeXS_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets b/ets2panda/linter/test/deprecatedapi/slider_api.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ec3620c2eb0995594f53b65e0a6179d1911ae52 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 {SliderAttribute} from './sdk/api/slider'; + +@Entry +@Component +struct SliderExample { + build() { + Column({ space: 8 }) { + Row() { + Slider() + .minLabel('aa') //error + .maxLabel('bb') //error + } + .width('100%') + }.width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..811b3fa6edb311680f99de72c56efc371290d6cc --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 21, + "endLine": 21, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 9, + "endLine": 23, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets.json b/ets2panda/linter/test/deprecatedapi/slider_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/swiper_api.ets b/ets2panda/linter/test/deprecatedapi/swiper_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..07a2506defed6a3f55e7cd2f8ef035df79fc6a89 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/swiper_api.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 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 {IndicatorStyle,SwiperDisplayMode} from './sdk/api/swiper'; + +class Test extends Test implements IndicatorStyle{ //error + layoutInfo: IndicatorStyle|undefined = undefined;//error + get(option:Map){//error + option.set('',{top:100,color:1111});//error + option.set('',{bottom:SwiperDisplayMode.Stretch})//error + } + getInfo(){ + return this.layoutInfo; + } + set(){ + typeof this.layoutInfo?.left//error + this.layoutInfo?.right == 100//error + this.layoutInfo?.color?.toString()//error + const info = this.layoutInfo; + console.log(info?.selectedColor+'');//error + this.getInfo()?.mask//error + this.layoutInfo?.bottom//error + setTop(this.getInfo()) + } + setSize(layoutInfo: IndicatorStyle|undefined){//error + layoutInfo?.size ;//error + } +} +function setTop(layoutInfo: IndicatorStyle|undefined ){//error + layoutInfo?.top == 0;//error +} +function getBotton(){ + new Test().getInfo()?.bottom;//error + const test = new Test(); + return test.layoutInfo?.bottom;//error +} +function get(){ + const AutoLinear = SwiperDisplayMode.AutoLinear//error + typeof SwiperDisplayMode.Stretch;//error + return SwiperDisplayMode.AUTO_LINEAR;//error +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/swiper_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/swiper_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..9aeb20fcecfe373e000c3fd631edb1ef6f643bcc --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.arkts2.json @@ -0,0 +1,298 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 37, + "endLine": 17, + "endColumn": 51, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 29, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 25, + "endLine": 19, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 20, + "endLine": 20, + "endColumn": 23, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 24, + "endLine": 20, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 34, + "endLine": 20, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 20, + "endLine": 21, + "endColumn": 26, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 45, + "endLine": 21, + "endColumn": 52, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 29, + "endLine": 27, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 22, + "endLine": 28, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 31, + "endLine": 28, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 22, + "endLine": 29, + "endColumn": 27, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 36, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 21, + "endLine": 32, + "endColumn": 25, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 22, + "endLine": 33, + "endColumn": 28, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 23, + "endLine": 36, + "endColumn": 37, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 21, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 29, + "endLine": 40, + "endColumn": 43, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 15, + "endLine": 41, + "endColumn": 18, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 22, + "endLine": 41, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 10, + "endLine": 43, + "endColumn": 19, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 25, + "endLine": 44, + "endColumn": 31, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 27, + "endLine": 46, + "endColumn": 33, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 9, + "endLine": 49, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 40, + "endLine": 49, + "endColumn": 50, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 28, + "endLine": 50, + "endColumn": 35, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 28, + "endLine": 51, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/swiper_api.ets.json b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..828c0d03a22449f6f683532ff0b945b8eb38c668 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/swiper_api.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 43, + "column": 10, + "endLine": 43, + "endColumn": 19, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/system_prompt.ets b/ets2panda/linter/test/deprecatedapi/system_prompt.ets new file mode 100755 index 0000000000000000000000000000000000000000..af14dd835279282e24405ec1f4320cc49cd03c85 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_prompt.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 prompt, { ShowToastOptions } from '@system.prompt'; + +class A { + private options: ShowToastOptions = { // error + message: 'Message Info', // error + duration: 2000, // error + bottom: 10 // error + } + + showToast() { + prompt.showToast(this.options); + } +} + +export default new A() diff --git a/ets2panda/linter/test/deprecatedapi/system_prompt.ets.args.json b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/system_prompt.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..bd5ae47f21a1ec0032294ce564ef280810586df7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.arkts2.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 21, + "column": 15, + "endLine": 21, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 13, + "endLine": 22, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/system_prompt.ets.json b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..7633c79b6aa0073a72cf8f74a66e11dac370f619 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_prompt.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/system_router.ets b/ets2panda/linter/test/deprecatedapi/system_router.ets new file mode 100755 index 0000000000000000000000000000000000000000..fd53ea0ce38981d75b29b98e0b2de27ed12785b7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_router.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 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 router, { + BackRouterOptions, + DisableAlertBeforeBackPageOptions, + EnableAlertBeforeBackPageOptions, RouterOptions, RouterState } from '@system.router'; + +class K { + private router: RouterOptions = { + uri: 'pages/routerpage2/routerpage2', + params: { // error + data1: 'message', + data2: { + data3: [123, 456, 789] + } + } + } + + private options: BackRouterOptions = { + uri: 'pages/detail/detail', // error + params: { // error + data1: 'message' + } + } + + getState() { + let page: RouterState = router.getState(); // error + console.log('current index = ' + page.index); // error + console.log('current name = ' + page.name); // error + console.log('current path = ' + page.path); // error + } + + pushPage() { + router.push(this.router); // error + } + + defaultBack() { + router.back(this.options); // error + } +} + +export default new K() + +class L { + private options: EnableAlertBeforeBackPageOptions = { + message: 'Message Info', + success: () => { + console.log('success'); + }, + cancel: () => { // error + console.log('cancel'); + }, + complete: () => { // error + console.log('complete'); + } + } + + enableAlertBeforeBackPage() { + router.enableAlertBeforeBackPage(this.options); + } +} + +class M { + enableAlertBeforeBackPage() { + router.enableAlertBeforeBackPage({ + message: 'Message Info', + success: () => { // error + console.log('success'); + }, + cancel: () => { + console.log('cancel'); + } + }); + } +} + +class Z { + private options: DisableAlertBeforeBackPageOptions = { // error + success: () => { + console.log('success'); + }, + cancel: () => { + console.log('cancel'); + } + } + + disableAlertBeforeBackPage() { + router.disableAlertBeforeBackPage(this.options); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/system_router.ets.args.json b/ets2panda/linter/test/deprecatedapi/system_router.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..4dfa4f20174c5965ff0a03fe9745d4cece7b7efa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_router.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/system_router.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/system_router.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..3379c9304b7f94d92d2e2d537d1a42654a012a6b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_router.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 14, + "endLine": 26, + "endColumn": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 22, + "endLine": 27, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 27, + "endLine": 27, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 13, + "endLine": 34, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/system_router.ets.json b/ets2panda/linter/test/deprecatedapi/system_router.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..bc7f37b6ed6a7d55e4bb110bda7f253f21db8c88 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/system_router.ets.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 14, + "endLine": 26, + "endColumn": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 13, + "endLine": 34, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/temporary_api.ets b/ets2panda/linter/test/deprecatedapi/temporary_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..014b717110d37d6683ece1956e966f06832c080a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/temporary_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {PanelType} from './sdk/api/panel' + +@@Entry +@Component +struct WrapContentPanelExample { + @State isVisible: boolean = true + build() { + Column() { + Panel(this.isVisible) + .type(PanelType.Temporary) // error + } + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/temporary_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/temporary_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..6a24afa2aac4d5e054cd450c061e7d3ff0b6969c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 2, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 13, + "endLine": 24, + "endColumn": 22, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 32, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/temporary_api.ets.json b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/temporary_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets b/ets2panda/linter/test/deprecatedapi/text_input.ets new file mode 100644 index 0000000000000000000000000000000000000000..34ea448f8453d32505d6209f0535bbc998a9f1ab --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct TextInputExample { + controller: TextInputController = new TextInputController(); + + build() { + Column() { + TextInput({ controller: this.controller }) + .onEditChanged((isEditing: boolean) => { //error + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json b/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..dd029d72759d079651eeae7e5aef81800af40361 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 41, + "endLine": 19, + "endColumn": 60, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 15, + "endLine": 19, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInputController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 41, + "endLine": 19, + "endColumn": 60, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInputController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInput\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets.json b/ets2panda/linter/test/deprecatedapi/text_input.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets b/ets2panda/linter/test/deprecatedapi/text_picker.ets new file mode 100644 index 0000000000000000000000000000000000000000..9cf5d2196f51eb2e7d1c6fd4bec01f98cd79815c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct TextPickerExample { + private select: number = 1; + private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4']; + + + build() { + Column() { + Button("TextPickerDialog") + .margin(20) + .onClick(() => { + TextPickerDialog.show() //error + }) + + TextPicker({ + range: this.fruits, + selected: this.select, + value: this.fruits[this.select] + }).onAccept(()=> {}) //error + .onCancel(()=> {}) //error + + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0579213c3c729ce6593b6816cc446f8cf5493058 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json @@ -0,0 +1,108 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 28, + "endLine": 19, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 17, + "endLine": 26, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 28, + "endLine": 34, + "endColumn": 39, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextPickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextPicker\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets.json b/ets2panda/linter/test/deprecatedapi/text_picker.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets new file mode 100755 index 0000000000000000000000000000000000000000..34cec151b3183d52dd3fa924a9f668d9f89b5698 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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 {PanelHeight} from './sdk/api/panel' + +@@Entry +@Component +struct WrapContentPanelExample { + @State isVisible: boolean = true + build() { + Column() { + Panel(this.isVisible) + .height(PanelHeight.WRAP_CONTENT) //error + } + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..2e6eb36ba331904bfaa72a500323fd751ed89a09 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 2, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 15, + "endLine": 24, + "endColumn": 26, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 27, + "endLine": 24, + "endColumn": 39, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Panel\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.json b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/wrap_content_api.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets b/ets2panda/linter/test/deprecatedapi/xcomponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..89b2897eecb25d473319c2121b9a708d13beeb8b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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. + */ + +@Entry +@Component +struct PreviewArea { + xcomponentController: XComponentController = new XComponentController() + build() { + Row() { + XComponent({ + id: 'xcomponent', + type: 'type', + controller: this.xcomponentController + }) + .onLoad(() => { + this.xcomponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}); //error + }) + } + .backgroundColor(Color.Black) + .position({x: 0, y: 48}) + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0e998f08269e40119b64bda69f1b01fb3ee2f528 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json @@ -0,0 +1,148 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 52, + "endLine": 19, + "endColumn": 72, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 76, + "endLine": 28, + "endColumn": 80, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 95, + "endLine": 28, + "endColumn": 99, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 6, + "endLine": 32, + "endColumn": 14, + "problem": "SdkTypeQuery", + "suggest": "", + "rule": "Using typeof as a type is not allowed in this API (sdk-type-query)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 19, + "endLine": 32, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 25, + "endLine": 19, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponentController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 52, + "endLine": 19, + "endColumn": 72, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponentController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets.json b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json index 7795884ac22abfdf7f90c5a93e3138411c8a596c..950dead5c234a56c680131b73543475d20a7ba6c 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 53, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 656, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 53 - }, - { - "start": 656, - "end": 656, - "replacementText": "let foo = ESValue.load('./binary_operation_js_obj_js').getProperty('foo');\nlet m = ESValue.load('./binary_operation_js_obj_js').getProperty('m');\nlet n = ESValue.load('./binary_operation_js_obj_js').getProperty('n');\n", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 53 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -514,9 +494,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 747, - "end": 752, - "replacementText": "x: number = 1", + "start": 748, + "end": 748, + "replacementText": ": number", "line": 29, "column": 5, "endLine": 29, @@ -556,9 +536,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 754, - "end": 759, - "replacementText": "y: number = 2", + "start": 755, + "end": 755, + "replacementText": ": number", "line": 29, "column": 12, "endLine": 29, @@ -691,9 +671,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 822, - "end": 832, - "replacementText": "x2: number = bar.a", + "start": 824, + "end": 824, + "replacementText": ": number", "line": 37, "column": 5, "endLine": 37, @@ -712,9 +692,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 834, - "end": 844, - "replacementText": "y2: number = bar.b", + "start": 836, + "end": 836, + "replacementText": ": number", "line": 37, "column": 17, "endLine": 37, diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets index 7a93ab3ecba4333743782320a30eabec62e44bc2..5c4f835784d72e4a0bf720da6d48d176852e4ad1 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets @@ -12,10 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./binary_operation_js_obj_js').getProperty('foo'); -let m = ESValue.load('./binary_operation_js_obj_js').getProperty('m'); -let n = ESValue.load('./binary_operation_js_obj_js').getProperty('n'); - +import {foo,m,n} from "./binary_operation_js_obj_js" let a = foo.getProperty("a") let b = foo.getProperty("b") a + b diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json index f0dfd043375ffecce257d2610defd361d1df6f34..0f7384dffa2b6c6d565e67310f0736f6dfa48252 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json @@ -16,19 +16,19 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 53, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 16, "column": 5, "endLine": 16, - "endColumn": 70, + "endColumn": 29, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,26 +38,6 @@ "line": 17, "column": 5, "endLine": 17, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 29, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, "endColumn": 29, "problem": "AnyType", "suggest": "", @@ -65,9 +45,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 23, "column": 1, - "endLine": 26, + "endLine": 23, "endColumn": 15, "problem": "MathPow", "suggest": "", @@ -75,9 +55,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 27, "column": 1, - "endLine": 30, + "endLine": 27, "endColumn": 37, "problem": "MathPow", "suggest": "", @@ -85,9 +65,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 33, "column": 1, - "endLine": 36, + "endLine": 33, "endColumn": 15, "problem": "MathPow", "suggest": "", @@ -95,9 +75,9 @@ "severity": "ERROR" }, { - "line": 48, + "line": 45, "column": 1, - "endLine": 48, + "endLine": 45, "endColumn": 17, "problem": "MathPow", "suggest": "", diff --git a/ets2panda/linter/test/interop/call_function.ets b/ets2panda/linter/test/interop/call_function.ets index 74665b905caef883c904b8ee1d13c01b7efc4e0a..63596274071ecb6f425932990d09bc832f3c7736 100644 --- a/ets2panda/linter/test/interop/call_function.ets +++ b/ets2panda/linter/test/interop/call_function.ets @@ -13,6 +13,10 @@ * limitations under the License. */ import {foo,bar} from "./call_function_js" +import {a,b} from "./call_function_js" foo() -bar(123) \ No newline at end of file +bar(123) + +//a(); +b(); diff --git a/ets2panda/linter/test/interop/call_function.ets.args.json b/ets2panda/linter/test/interop/call_function.ets.args.json index 9c3d9734324a7b8b9c89fa7f62dce43ac44888ca..d683e78822869ab7d4dca23d3cc629224baf1046 100644 --- a/ets2panda/linter/test/interop/call_function.ets.args.json +++ b/ets2panda/linter/test/interop/call_function.ets.args.json @@ -14,6 +14,8 @@ "limitations under the License." ], "mode": { - "arkts2": "" + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" } } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function.ets.arkts2.json b/ets2panda/linter/test/interop/call_function.ets.arkts2.json index 66335fa504eb461da8ade9c2cc71a8119f4e11f0..fba3aed8a95554d0f0bdfcf30b9963998de93a89 100644 --- a/ets2panda/linter/test/interop/call_function.ets.arkts2.json +++ b/ets2panda/linter/test/interop/call_function.ets.arkts2.json @@ -25,9 +25,19 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, + "endColumn": 39, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, "endColumn": 6, "problem": "CallJSFunction", "suggest": "", @@ -35,9 +45,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 19, "column": 1, - "endLine": 18, + "endLine": 19, "endColumn": 9, "problem": "CallJSFunction", "suggest": "", @@ -45,14 +55,24 @@ "severity": "ERROR" }, { - "line": 18, + "line": 19, "column": 5, - "endLine": 18, + "endLine": 19, "endColumn": 8, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 4, + "problem": "CallJSFunction", + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function.ets.autofix.json b/ets2panda/linter/test/interop/call_function.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..206be26dd22cf08430da8f0425958201401b8c50 --- /dev/null +++ b/ets2panda/linter/test/interop/call_function.ets.autofix.json @@ -0,0 +1,122 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 43, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 39, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 6, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 687, + "end": 692, + "replacementText": "foo.invoke()", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 693, + "end": 701, + "replacementText": "bar.invoke(ESValue.wrap(123))", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 8, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 697, + "end": 700, + "replacementText": "123.0", + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 4, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 710, + "end": 713, + "replacementText": "b.invoke()", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function.ets.migrate.ets b/ets2panda/linter/test/interop/call_function.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..488924d012ea7a6c533ed9be6340ea7676f57123 --- /dev/null +++ b/ets2panda/linter/test/interop/call_function.ets.migrate.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 {foo,bar} from "./call_function_js" +import {a,b} from "./call_function_js" + +foo.invoke() +bar.invoke(ESValue.wrap(123.0)) + +//a(); +b.invoke(); diff --git a/ets2panda/linter/test/interop/call_function.ets.migrate.json b/ets2panda/linter/test/interop/call_function.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..c9ca5e0d96fd9c8b231049bc0b25fc487020c4e1 --- /dev/null +++ b/ets2panda/linter/test/interop/call_function.ets.migrate.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 43, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 39, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function_js.js b/ets2panda/linter/test/interop/call_function_js.js index 1ca0a23aebf1d5ffa73f72c779aa2d87675ab0da..2a35cd0c1f7c9cb84e24dab16b70ec7dc44ca419 100644 --- a/ets2panda/linter/test/interop/call_function_js.js +++ b/ets2panda/linter/test/interop/call_function_js.js @@ -14,4 +14,6 @@ */ export function foo(){} -export function bar(a){} \ No newline at end of file +export function bar(a){} +export function a(){} +export function b(){} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json index 0168feead4146a8ff3979eb4846aba20c577ec20..afc8eb134a088f606ce6dcbacd6b0be75281bac7 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 47, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 650, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 47 - }, - { - "start": 650, - "end": 650, - "replacementText": "let foo = ESValue.load('./call_object_methods_js').getProperty('foo');\n", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 47 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets index e9e2087b586717af5c059e9675bdb27e7179ed28..d18b4715365f3f292433fc55b19e04d98c724535 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./call_object_methods_js').getProperty('foo'); - +import { foo } from "./call_object_methods_js" foo.invokeMethod("bar", ESValue.wrap(123.0)) diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json index 149a43f6f592beed295eb162f2eb5adb2f8c0e1c..94a7c680a7bed414b3aac1b4c0da3972817f96d1 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 47, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/ignore_files/unique_types.ts b/ets2panda/linter/test/interop/ignore_files/unique_types.ts index f56856f73a92392809c9b4ff47702dfa14efecc9..60cf239e961e8bc48fb661fd84822eb98ed45d71 100644 --- a/ets2panda/linter/test/interop/ignore_files/unique_types.ts +++ b/ets2panda/linter/test/interop/ignore_files/unique_types.ts @@ -30,6 +30,12 @@ export let function_var: Function = function() { return true; }; +//mixed enum +export enum enum_var { + a = 0, + b = '1', +} + export class A { static instance = new A(); } diff --git a/ets2panda/linter/test/interop/ignore_files/unique_types2.ts b/ets2panda/linter/test/interop/ignore_files/unique_types2.ts new file mode 100644 index 0000000000000000000000000000000000000000..e915e9bb10b8a7abf3f4fdae9f26467d37d00f80 --- /dev/null +++ b/ets2panda/linter/test/interop/ignore_files/unique_types2.ts @@ -0,0 +1,268 @@ +/* + * Copyright (c) 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. + */ + +// any +let any_var: any = 10; +any_var = "string"; +export { any_var } + +// unknown +export let unknown_var: unknown = 10; + +// Symbol +export let symbol_var: symbol = Symbol("description"); + +// Function +export let function_var: Function = function () { + console.log("Hello, World!"); + return true; +}; + +// objectLiteral +export let objectLiteral_var: { x: number, y: string } = { x: 10, y: "hello" }; +export let objectLiteral_var2 = { x: 10, y: "hello" }; +export let objectLiteral_var3:{}; +export let objectLiteral_var32={}; +export let objectLiteral_var4 = { x: 1 }; +export function objectLiteral_var5() { + return { x: 1 }; +} +export function objectLiteral_var51(aa:{}):{}{ + return { x: 1 }; +} + +export class objectLiteral_var6 { + get() { return { a: '1' }; } + get2():{} { return {}; } + get3() { return {}; } + get4():{}|undefined {return; } + get1(): { x: number }|undefined { + return; + } + set(aa: { x: 1 }) { } + set3(aa: {}) { } + set1(aa: { x: 1 }|boolean) { } + set2(aa: { x: 1,y: string }|boolean,bb:string) { } +} +// enum +export enum enum_var { + a = 0, + b = '1', +} + +// function type +export type func_type = (arg: number) => string; +export type func_type2 = {(arg: number): string}; + +// Construct signature +export let constructor_type: { new(name: string): { name: string } } = class { + constructor(public name: string) { } +}; + +// Index Signature +let objIndexSignature_var: { [index: number]: string } = {}; +objIndexSignature_var[0] = "zero"; +objIndexSignature_var[1] = "one"; +export { objIndexSignature_var } + +// Intersection +interface TypeA { + a: number; +} +interface TypeB { + b: string; +} + +export let Intersection_obj: TypeA & TypeB = { a: 10, b: "hello" }; + +// keyof +export interface X { + a: number; + b: string; +} + +export type KeyOf_Type = keyof X; +export let de: KeyOf_Type; +export let key: keyof X; +export function keyFuns(){ + return key; +} +export class Keys{ + keys:keyof X; + set(x:keyof X|undefined){} + get():keyof X|void{} + get1(){ return this.keys} +} + +// typeof +let p = { x: 1, y: "" }; +export let typeOf_type = typeof p; +export let typeOf_type1: typeof p; +// let q: typeof p = { x: 2, y: "world" }; + +export let user = { name: "John", age: 25 }; + +export type SomeType = { + name: string, +} +//indexed access: type[index]。 +const MyArray = [{ name: "Alice", age: 15 }] +export type Person = typeof MyArray[number] +export let Person1 = MyArray[0] +type StringArray = string[]; +export type ElementType = StringArray[number]; +type Demo = { + id: number; + name: string; + address: { city: string; }; +}; +type NameType = Demo["name"]; +type CityType = Demo["address"]["city"]; +export type NameOrAddress =Demo["name" | "address"]; +export function getInfo(name:NameType){ + return name as CityType; +} +type Tuple = [string, number, boolean]; +type FirstElement = Tuple[0]; +type LastElement = Tuple[2]; +export class IndexAccess{ + par:Person; + set(city:CityType,NameOrAddr:NameOrAddress){} + get(name:NameType):Tuple|FirstElement|LastElement{ + return getInfo(name); + } +} +type UserKeys = keyof Demo; +export type UserValueTypes = Demo[UserKeys]; + +//Template Literal Types:${T}${U}... +type UnionString = "A" | "B"; +export type TemplateLiteralType =` ${UnionString}_id`; +type Direction = "up" | "down" | "left" | "right"; +type Action = "move" | "rotate"; +export type Commands = `${Action}_${Direction}`; +type PropEventNames = `${T}Changed`; +export type NameChanged = PropEventNames<"name">; +type Colors1 = "red" | "blue"; +type Sizes = "small" | "large"; +export type Variants = `${Colors1}_${Sizes}`; +type IsString = T extends string ? true : false; +export type Check = `${T}` extends string ? true : false; +export function testTemplateLiteralType(bb:Commands){ + let a :PropEventNames<"name">; +} + +export let objectLiteralType: SomeType; +export let mixedEnumType: X; +export let intersectionType: SomeType & X; +export let templateLiteralType: TemplateLiteralType|undefined; + +export function tsFunction() { }; +export let stringType: string; +export class Test{ + returnStr(){ + return stringType; + } +} +//conditional types:T extends U ? X : Y +type ExtractNumber = T extends number ? T : never; +export type NumbersOnly = ExtractNumber; +export type ReturnVal any> = + T extends (...args: any[]) => infer R ? R : never; +export type Num = ReturnVal<() => number>; + +//mapped types:{[K in KeyType]: TypeExpression} +type Readonly = { + readonly [K in keyof T]: T[K]; +}; +export type ReadonlyUser = Readonly; +export type Partial = { + [K in keyof T]?: T[K]; +}; +export type OptionalUser = Partial; +type Original = { + [key: string]: number; + name: string; +}; +export type Mapped = { + [K in keyof Original]: Original[K]; +}; + +export let sumType: { [index: number]: string ,temp:TemplateLiteralType,index:UserValueTypes} ; +//tool +type User = { + name: string; + age: number; + email: string; +}; +type Colors = 'red' | 'blue' | 'green' | 'yellow'; +// Pick +export type NameAndEmail = Pick; +// Omit +export type WithoutEmail = Omit; +// Exclude +export type PrimaryColors = Exclude; +// Extract +type Values = string | number | boolean | null; +export type PrimitiveValues = Extract; +// NonNullable +type Data = string | null | undefined; +export type CleanData = NonNullable; +// Parameters +function add(a: number, b: string): void { } +export type AddParams = Parameters; +// ConstructorParameters +class Per { + constructor(name: string, age: number) { } +} +export type PerParams = ConstructorParameters; +// ReturnType +function createUser(): { id: number; name: string } { + return { id: 1, name: 'Alice' }; +} +export type UserType = ReturnType; +// InstanceType +class Point { + x: number; + y: number; +} +export type PointInstance = InstanceType; +// NoInfer +type NoInfer = [T][T extends any ? 0 : never]; +export function identity(x: T, y: NoInfer): T { + return x; +} +// ThisParameterType +type getThis = (this: { name: string }) => void; +export type thisParameterType = ThisParameterType; +// OmitThisParameter +type GetThis = (this: { name: string }, x: number) => void; +export type WithoutThis = OmitThisParameter; +// ThisType +export type ClassThisType = ThisType<{ + getName(): string; +}>; +// Uppercase +type Greeting = 'hello'; +export type ShoutGreeting = Uppercase; +// Lowercase +export type QuietGreeting = Lowercase; +// Capitalize +export type CapitalizedWord = Capitalize; +// Uncapitalize +export type UncapitalizedWord = Uncapitalize; +export function getCapitalize(): Capitalize { + return 'Hello'; +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json index f8d8a8cfdc1ba30ef321a989822442291959bd07..e9af2d47b12258b4f93b91f9aae002c4d6acbca4 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 52, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 655, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 52 - }, - { - "start": 655, - "end": 655, - "replacementText": "let foo = ESValue.load('./increases_decreases_js_obj_js').getProperty('foo');\n", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 52 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -402,4 +382,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets index cf3c50c2c8a89af985acb0b136fe0c30360eac52..cde3dfacf9603ad8b8b0311c8fa27026fa5e7616 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./increases_decreases_js_obj_js').getProperty('foo'); - +import {foo} from "./increases_decreases_js_obj_js" let a: number =0.0 a = foo.getProperty("num").toNumber() foo.setProperty(num, a + 1.0) diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json index 2d9436fba2c494e011863cffb8548f5f6d263639..c1eebeb25c56ef572edb41bc0480ef0fb51e8bab 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json @@ -16,18 +16,18 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 77, - "problem": "AnyType", + "endColumn": 52, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 35, + "line": 34, "column": 5, - "endLine": 35, + "endLine": 34, "endColumn": 46, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 38, "column": 5, - "endLine": 39, + "endLine": 38, "endColumn": 46, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 43, + "line": 42, "column": 5, - "endLine": 43, + "endLine": 42, "endColumn": 46, "problem": "AnyType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 47, + "line": 46, "column": 5, - "endLine": 47, + "endLine": 46, "endColumn": 46, "problem": "AnyType", "suggest": "", @@ -65,4 +65,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json index 40daaaa99e5deaa49cd6d17eeb16b8db96f71b3f..a0da97f1f6ab56d0e9be78800c3a59ed8d78d18c 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 655, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 51 - }, - { - "start": 655, - "end": 655, - "replacementText": "let Foo = ESValue.load('./instantiated_js_obj_js').getProperty('Foo');\nlet Foo1 = ESValue.load('./instantiated_js_obj_js').getProperty('Foo1');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets index 9f8564ec60c420c654dce212ba8110f1a975cd17..c41c16e387b95fdbf4bf38b976b4b7a0e0aece46 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets @@ -13,9 +13,7 @@ * limitations under the License. */ -let Foo = ESValue.load('./instantiated_js_obj_js').getProperty('Foo'); -let Foo1 = ESValue.load('./instantiated_js_obj_js').getProperty('Foo1'); - +import {Foo, Foo1} from "./instantiated_js_obj_js" class A { num: number = 1.0; constructor() { diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json index a1be17f7a40899eb98b78b56687678a26cf3b3fd..8ae4b51b2e860913274a052ebd930922bdafa5cc 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json @@ -16,22 +16,12 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json index 728ef37abc8c8fc19fc711e9b8947b4640fb45f7..e90ddfedb1e2b6569ca3a200c81a31019f672661 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 106, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 636, - "end": 740, - "replacementText": "", - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106 - }, - { - "start": 740, - "end": 740, - "replacementText": "let foo = ESValue.load('./interop_convert_import_js.js').getProperty('foo');\r\nlet foo2 = ESValue.load('./interop_convert_import_js.js').getProperty('foo2');\r\nlet foo3 = ESValue.load('./interop_convert_import_js.js').getProperty('foo3');\r\nlet foo4 = ESValue.load('./interop_convert_import_js.js').getProperty('foo4');\r\nlet array_val = ESValue.load('./interop_convert_import_js.js').getProperty('array_val');\r\nlet null_val = ESValue.load('./interop_convert_import_js.js').getProperty('null_val');\r\nlet undefined_val = ESValue.load('./interop_convert_import_js.js').getProperty('undefined_val');\r\n", - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets index b90e38880f2bf78c88e511682f3394ffc28975d4..a04503ccc23347821ab0beb697e7db0205ad8ada 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets @@ -14,14 +14,7 @@ */ 'use static' - let foo = ESValue.load('./interop_convert_import_js.js').getProperty('foo'); -let foo2 = ESValue.load('./interop_convert_import_js.js').getProperty('foo2'); -let foo3 = ESValue.load('./interop_convert_import_js.js').getProperty('foo3'); -let foo4 = ESValue.load('./interop_convert_import_js.js').getProperty('foo4'); -let array_val = ESValue.load('./interop_convert_import_js.js').getProperty('array_val'); -let null_val = ESValue.load('./interop_convert_import_js.js').getProperty('null_val'); -let undefined_val = ESValue.load('./interop_convert_import_js.js').getProperty('undefined_val'); - + import {foo, foo2, foo3, foo4, array_val, null_val, undefined_val} from "./interop_convert_import_js.js" let a: number = foo.getProperty("num").toNumber() let a1: boolean = foo2.getProperty("bool").toBoolean() diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json index e2860e27258d30de9de0d714726d7602804025d9..477162ca035537626a2cdf2e2a5e633a98b9b8ba 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json @@ -16,89 +16,69 @@ "result": [ { "line": 17, - "column": 6, + "column": 2, "endLine": 17, - "endColumn": 77, - "problem": "AnyType", + "endColumn": 106, + "problem": "ImportAfterStatement", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" }, { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 78, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 78, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 78, - "problem": "AnyType", + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 106, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 88, - "problem": "AnyType", + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 27, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 86, - "problem": "AnyType", + "line": 25, + "column": 44, + "endLine": 25, + "endColumn": 68, + "problem": "GenericCallNoTypeArgs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 96, - "problem": "AnyType", + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 30, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 32, - "column": 44, - "endLine": 32, - "endColumn": 68, - "problem": "GenericCallNoTypeArgs", + "line": 35, + "column": 8, + "endLine": 35, + "endColumn": 24, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 42, + "line": 40, "column": 8, - "endLine": 42, - "endColumn": 24, + "endLine": 40, + "endColumn": 34, "problem": "InterOpConvertImport", "suggest": "", "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets b/ets2panda/linter/test/interop/interop_equality_judgment.ets index 65ce20fddcdcb02a9f4cfa54fc92aafdea6934c7..aebc647fbe87aa5df306caab6e04767cdd39fc9a 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets @@ -13,8 +13,12 @@ * limitations under the License. */ -import {a, b} from "./interop_equality_judgment_js" +import {a, b, c, d} from "./interop_equality_judgment_js" a == b a != b a === b -a !== b \ No newline at end of file +a !== b +c.num1 == d.num1 +c.num1 != d.num2 +c.num1 === d.num1 +c.num1 !== d.num2 diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json index 920de865a7bf8abad43c5dda169887cb74d79938..24b5949ab2d6c71157d92449926b4160fda4868e 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json @@ -14,55 +14,175 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 7, - "problem": "InteropEqualityJudgment", - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 7, - "problem": "InteropEqualityJudgment", - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 8, - "problem": "InteropEqualityJudgment", - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 8, - "problem": "InteropEqualityJudgment", - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" - } - ] -} \ No newline at end of file + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 58, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 7, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 7, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 8, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 8, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 17, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 7, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 17, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 17, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 7, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 17, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 18, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 7, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 12, + "endLine": 23, + "endColumn": 18, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 18, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 7, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 12, + "endLine": 24, + "endColumn": 18, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json index d38814d67ccf68720a9390399e58f98042c1e5f7..73d6eea5c8064980fd5c71ce5995ccb80999269c 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json @@ -18,28 +18,8 @@ "line": 16, "column": 1, "endLine": 16, - "endColumn": 52, + "endColumn": 58, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 656, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52 - }, - { - "start": 656, - "end": 656, - "replacementText": "let a = ESValue.load('./interop_equality_judgment_js').getProperty('a');\nlet b = ESValue.load('./interop_equality_judgment_js').getProperty('b');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -52,8 +32,8 @@ "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 657, - "end": 663, + "start": 663, + "end": 669, "replacementText": "a.areEqual(b)", "line": 17, "column": 1, @@ -73,8 +53,8 @@ "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 664, - "end": 670, + "start": 670, + "end": 676, "replacementText": "!a.areEqual(b)", "line": 18, "column": 1, @@ -94,8 +74,8 @@ "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 671, - "end": 678, + "start": 677, + "end": 684, "replacementText": "a.areStrictlyEqual(b)", "line": 19, "column": 1, @@ -115,8 +95,8 @@ "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 679, - "end": 686, + "start": 685, + "end": 692, "replacementText": "!a.areStrictlyEqual(b)", "line": 20, "column": 1, @@ -127,6 +107,258 @@ "suggest": "", "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 17, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 693, + "end": 709, + "replacementText": "c.getProperty(\"num1\").areEqual(d.getProperty(\"num1\"))", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 7, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 693, + "end": 699, + "replacementText": "c.getProperty(\"num1\")", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 17, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 703, + "end": 709, + "replacementText": "d.getProperty(\"num1\")", + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 17, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 710, + "end": 726, + "replacementText": "!c.getProperty(\"num1\").areEqual(d.getProperty(\"num2\"))", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 7, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 710, + "end": 716, + "replacementText": "c.getProperty(\"num1\")", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 17, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 720, + "end": 726, + "replacementText": "d.getProperty(\"num2\")", + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 18, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 727, + "end": 744, + "replacementText": "c.getProperty(\"num1\").areStrictlyEqual(d.getProperty(\"num1\"))", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 7, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 727, + "end": 733, + "replacementText": "c.getProperty(\"num1\")", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 12, + "endLine": 23, + "endColumn": 18, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 738, + "end": 744, + "replacementText": "d.getProperty(\"num1\")", + "line": 23, + "column": 12, + "endLine": 23, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 18, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 745, + "end": 762, + "replacementText": "!c.getProperty(\"num1\").areStrictlyEqual(d.getProperty(\"num2\"))", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 7, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 745, + "end": 751, + "replacementText": "c.getProperty(\"num1\")", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 12, + "endLine": 24, + "endColumn": 18, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 756, + "end": 762, + "replacementText": "d.getProperty(\"num2\")", + "line": 24, + "column": 12, + "endLine": 24, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets index 75dfa93e7094995f00a4ef31eb0bb9dca245afe1..f0bdc4e3ea0e54767723b86fac1a5582629d621b 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets @@ -13,10 +13,12 @@ * limitations under the License. */ -let a = ESValue.load('./interop_equality_judgment_js').getProperty('a'); -let b = ESValue.load('./interop_equality_judgment_js').getProperty('b'); - +import {a, b, c, d} from "./interop_equality_judgment_js" a.areEqual(b) !a.areEqual(b) a.areStrictlyEqual(b) -!a.areStrictlyEqual(b) \ No newline at end of file +!a.areStrictlyEqual(b) +c.getProperty("num1").areEqual(d.getProperty("num1")) +!c.getProperty("num1").areEqual(d.getProperty("num2")) +c.getProperty("num1").areStrictlyEqual(d.getProperty("num1")) +!c.getProperty("num1").areStrictlyEqual(d.getProperty("num2")) diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json index c8a37393a693d0cbeecc24da7889934ae686dc61..1f0874db0ddfe681b007ec3fd09c2c1d15cab099 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json @@ -16,22 +16,52 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 72, - "problem": "AnyType", + "endColumn": 58, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 17, - "column": 5, + "column": 12, "endLine": 17, - "endColumn": 72, - "problem": "AnyType", + "endColumn": 13, + "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 13, + "endLine": 18, + "endColumn": 14, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 20, + "endLine": 19, + "endColumn": 21, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 22, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/interop_equality_judgment_js.js b/ets2panda/linter/test/interop/interop_equality_judgment_js.js index 6461191d6871a2e1ead802773ac1e5cc635fc707..036eb5a333ca70de6dc450533377ff0d91d3a657 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment_js.js +++ b/ets2panda/linter/test/interop/interop_equality_judgment_js.js @@ -15,4 +15,12 @@ class A {} export let a = new A() -export let b = new A() \ No newline at end of file +export let b = new A() +export let c = { + num1:1, + num2:2, +} +export let d = { + num1: 1, + num2: 2, +} diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json index 95ff8c7ad144fd1bbf3e921de6e130eb0251c586..f8dbfb7b6c507c635f7e41fd8c93a7b1ee20432a 100755 --- a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 38, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 606, - "end": 643, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 38 - }, - { - "start": 952, - "end": 952, - "replacementText": "let Cjs = ESValue.load('../main/js_lib').getProperty('Cjs');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 38 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 17, "endColumn": 38, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 644, - "end": 681, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38 - }, - { - "start": 952, - "end": 952, - "replacementText": "let fjs = ESValue.load('../main/js_lib').getProperty('fjs');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -80,26 +40,6 @@ "endLine": 18, "endColumn": 64, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 682, - "end": 745, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 64 - }, - { - "start": 952, - "end": 952, - "replacementText": "let CPreview = ESValue.load('./jsfiles/preview_import_js').getProperty('CPreview');\nlet bar = ESValue.load('./jsfiles/preview_import_js').getProperty('bar');\nlet foo = ESValue.load('./jsfiles/preview_import_js').getProperty('foo');\n", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 64 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -110,26 +50,6 @@ "endLine": 19, "endColumn": 44, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 746, - "end": 789, - "replacementText": "", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 44 - }, - { - "start": 952, - "end": 952, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');\n", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 44 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -140,26 +60,6 @@ "endLine": 20, "endColumn": 57, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 790, - "end": 846, - "replacementText": "", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 57 - }, - { - "start": 952, - "end": 952, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');\nlet ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA');\nlet Dog = ESValue.load('./interop_import_js_js').getProperty('Dog');\n", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 57 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -170,26 +70,6 @@ "endLine": 21, "endColumn": 47, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 847, - "end": 893, - "replacementText": "", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 47 - }, - { - "start": 952, - "end": 952, - "replacementText": "let tjs = ESValue.load('./interop_import_js_js').getProperty('tjs');\n", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 47 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -200,26 +80,6 @@ "endLine": 22, "endColumn": 59, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 894, - "end": 952, - "replacementText": "", - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 59 - }, - { - "start": 952, - "end": 952, - "replacementText": "let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');\nlet Doge = ESValue.load('./interop_import_js_js').getProperty('Dog');\n", - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 59 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets index 4ac9329ef8aa702c969d0b66d3bf030d342fc626..a4c0b8fea69eeb2c1cb904f44aac79c764e47804 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets @@ -13,21 +13,10 @@ * limitations under the License. */ - - - - - - -let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); -let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let tjs = ESValue.load('./interop_import_js_js').getProperty('tjs'); -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA'); -let Dog = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let CPreview = ESValue.load('./jsfiles/preview_import_js').getProperty('CPreview'); -let bar = ESValue.load('./jsfiles/preview_import_js').getProperty('bar'); -let foo = ESValue.load('./jsfiles/preview_import_js').getProperty('foo'); -let fjs = ESValue.load('../main/js_lib').getProperty('fjs'); -let Cjs = ESValue.load('../main/js_lib').getProperty('Cjs'); +import { Cjs } from '../main/js_lib'; +import { fjs } from '../main/js_lib'; +import { CPreview,bar,foo } from "./jsfiles/preview_import_js"; +import myAaa from "./interop_import_js_js"; +import myAaa,{ClassA,Dog} from "./interop_import_js_js"; +import * as tjs from "./interop_import_js_js"; +import { Wiki, Dog as Doge } from './interop_import_js_js' \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json index b401dd1af61260112e1f58f838d259e0d8fc0397..f8dbfb7b6c507c635f7e41fd8c93a7b1ee20432a 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json @@ -15,123 +15,73 @@ ], "result": [ { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 69, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 5, - "endLine": 24, - "endColumn": 68, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 5, - "endLine": 25, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 5, - "endLine": 26, - "endColumn": 74, - "problem": "AnyType", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 38, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 27, - "column": 5, - "endLine": 27, - "endColumn": 68, - "problem": "AnyType", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 38, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 28, - "column": 5, - "endLine": 28, - "endColumn": 70, - "problem": "AnyType", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 64, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 29, - "column": 5, - "endLine": 29, - "endColumn": 83, - "problem": "AnyType", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 44, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 30, - "column": 5, - "endLine": 30, - "endColumn": 73, - "problem": "AnyType", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 57, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 73, - "problem": "AnyType", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 47, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 32, - "column": 5, - "endLine": 32, - "endColumn": 60, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 60, - "problem": "AnyType", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 59, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json index 069c2730b0bf41cb95c272d3e7df974d866ccd2d..5c02835f89f300921d0236a6432c6b48207cf51b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 17, "endColumn": 57, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 607, - "end": 663, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 57 - }, - { - "start": 663, - "end": 663, - "replacementText": "let foo = ESValue.load('./interop_import_js_compare_js').getProperty('foo');\nlet m = ESValue.load('./interop_import_js_compare_js').getProperty('m');\nlet n = ESValue.load('./interop_import_js_compare_js').getProperty('n');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 57 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -346,9 +326,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 742, - "end": 747, - "replacementText": "x: number = 1", + "start": 743, + "end": 743, + "replacementText": ": number", "line": 29, "column": 5, "endLine": 29, @@ -388,9 +368,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 749, - "end": 754, - "replacementText": "y: number = 2", + "start": 750, + "end": 750, + "replacementText": ": number", "line": 29, "column": 12, "endLine": 29, @@ -502,9 +482,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 818, - "end": 828, - "replacementText": "x2: number = bar.a", + "start": 820, + "end": 820, + "replacementText": ": number", "line": 37, "column": 5, "endLine": 37, @@ -523,9 +503,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 830, - "end": 840, - "replacementText": "y2: number = bar.b", + "start": 832, + "end": 832, + "replacementText": ": number", "line": 37, "column": 17, "endLine": 37, diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets index a95b861772eda6a44fce54e779ec10ee6f350566..51e820d9092d3e093223e832564114cfdb140f9f 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets @@ -14,10 +14,7 @@ */ -let foo = ESValue.load('./interop_import_js_compare_js').getProperty('foo'); -let m = ESValue.load('./interop_import_js_compare_js').getProperty('m'); -let n = ESValue.load('./interop_import_js_compare_js').getProperty('n'); - +import {foo, m, n} from "./interop_import_js_compare_js" let a = foo.getProperty("a") let b = foo.getProperty("b") a > b diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json index b425bd1e5ac7fb8023a82667b073b90995e83676..27f3d3c0d454d71d6ad5c5d374f723aa58558f6b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json @@ -16,19 +16,19 @@ "result": [ { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 76, - "problem": "AnyType", + "endColumn": 57, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, "column": 5, "endLine": 18, - "endColumn": 72, + "endColumn": 29, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,26 +38,6 @@ "line": 19, "column": 5, "endLine": 19, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 29, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 5, - "endLine": 22, "endColumn": 29, "problem": "AnyType", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets b/ets2panda/linter/test/interop/interop_import_js_index.ets index a4ffabe66033a933d7d064a305ba857dbfe78c7a..411f8c70a656a3989c7a2b9a0e8eccd769fd48f0 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets @@ -31,4 +31,4 @@ for (let element of arr1) { //error if (element == 8) { console.log("hi"); } -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json index 8b38c2c03fe78137b0636a10d3c6c8d9d9f850b2..7467f08a68d90b50ad957c56000c7aae7be57a42 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 654, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - }, - { - "start": 703, - "end": 703, - "replacementText": "let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3');\n", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 16, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 655, - "end": 703, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49 - }, - { - "start": 703, - "end": 703, - "replacementText": "let foo = ESValue.load('./interop_import_js_index_js').getProperty('foo');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -228,9 +188,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 801, - "end": 806, - "replacementText": "i: number = 0", + "start": 802, + "end": 802, + "replacementText": ": number", "line": 23, "column": 10, "endLine": 23, @@ -478,6 +438,26 @@ "endLine": 34, "endColumn": 2, "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "start": 970, + "end": 989, + "replacementText": "let tmp_1 = 0; tmp_1 < arr1.getProperty('length').toNumber(); ++tmp_1", + "line": 30, + "column": 1, + "endLine": 34, + "endColumn": 2 + }, + { + "start": 1008, + "end": 1015, + "replacementText": "arr1.getProperty(tmp_1).toNumber()", + "line": 30, + "column": 1, + "endLine": 34, + "endColumn": 2 + } + ], "suggest": "", "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", "severity": "ERROR" @@ -504,4 +484,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets index 7cac462bbc2b818778b2d8594616fcf129a11c74..11371d2a4f49baf5a939dd632fed067c61dbbf43 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets @@ -12,10 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -let foo = ESValue.load('./interop_import_js_index_js').getProperty('foo'); -let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3'); - +import { ff3 } from "./interop_import_js_rules_js" +import {foo} from "./interop_import_js_index_js" let arr = foo.getProperty("arr") arr.getProperty(1.0) arr.setProperty(3.0, ESValue.wrap(4.0)) @@ -30,8 +28,8 @@ for (let i: number = 0.0; i < arr1.getProperty("length"); ++i) { console.log(arr1.getProperty(i).toNumber()+''); //error } -for (let element of arr1) { //error - if (element == 8.0) { +for (let tmp_1: number = 0.0; tmp_1 < arr1.getProperty('length').toNumber(); ++tmp_1) { //error + if (arr1.getProperty(tmp_1).toNumber() == 8.0) { console.log("hi"); } -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json index bc80aa171a2ec94d9fe1aa56f0cbc3c468d1c296..bc5a9efda1c70321cd41c703b92a3ef695e946bd 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json @@ -15,29 +15,29 @@ ], "result": [ { - "line": 16, - "column": 5, - "endLine": 16, - "endColumn": 74, - "problem": "AnyType", + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 74, - "problem": "AnyType", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 49, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 19, + "line": 17, "column": 5, - "endLine": 19, + "endLine": 17, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 23, + "line": 21, "column": 5, - "endLine": 23, + "endLine": 21, "endColumn": 34, "problem": "AnyType", "suggest": "", @@ -55,24 +55,14 @@ "severity": "ERROR" }, { - "line": 27, + "line": 25, "column": 9, - "endLine": 27, + "endLine": 25, "endColumn": 43, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" - }, - { - "line": 33, - "column": 10, - "endLine": 33, - "endColumn": 17, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json index e160d4c3d08b3ae890c11d606050da565d1f123a..4fb8162057de9a0e0273f80d9e0c6b97b87758b3 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 619, - "end": 669, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let foo = ESValue.load('./interop_import_js_rules_js').getProperty('foo');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -70,26 +50,6 @@ "endLine": 18, "endColumn": 56, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 670, - "end": 725, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let ff1 = ESValue.load('./interop_import_js_rules_js').getProperty('ff1');\nlet ff2 = ESValue.load('./interop_import_js_rules_js').getProperty('ff2');\n", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -110,26 +70,6 @@ "endLine": 20, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 727, - "end": 775, - "replacementText": "", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let A = ESValue.load('./interop_import_js_rules_js').getProperty('A');\n", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -150,26 +90,6 @@ "endLine": 21, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 776, - "end": 824, - "replacementText": "", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let C = ESValue.load('./interop_import_js_rules_js').getProperty('C');\n", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -190,26 +110,6 @@ "endLine": 23, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 826, - "end": 876, - "replacementText": "", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3');\n", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -230,26 +130,6 @@ "endLine": 25, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 878, - "end": 928, - "replacementText": "", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let ff4 = ESValue.load('./interop_import_js_rules_js').getProperty('ff4');\n", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -270,26 +150,6 @@ "endLine": 27, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 930, - "end": 983, - "replacementText": "", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let handle = ESValue.load('./interop_import_js_rules_js').getProperty('handle');\n", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -310,26 +170,6 @@ "endLine": 29, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 985, - "end": 1038, - "replacementText": "", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let expand = ESValue.load('./interop_import_js_rules_js').getProperty('expand');\n", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -350,26 +190,6 @@ "endLine": 30, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 1039, - "end": 1092, - "replacementText": "", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let orange = ESValue.load('./interop_import_js_rules_js').getProperty('orange');\n", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -601,9 +421,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1392, - "end": 1397, - "replacementText": "i: number = 0", + "start": 1393, + "end": 1393, + "replacementText": ": number", "line": 52, "column": 10, "endLine": 52, @@ -830,9 +650,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1582, - "end": 1588, - "replacementText": "a: number = 1;", + "start": 1583, + "end": 1583, + "replacementText": ": number", "line": 67, "column": 9, "endLine": 67, @@ -872,9 +692,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1589, - "end": 1594, - "replacementText": "b: number = 2;", + "start": 1590, + "end": 1590, + "replacementText": ": number", "line": 67, "column": 16, "endLine": 67, @@ -914,9 +734,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1595, - "end": 1599, - "replacementText": "c: number = 3;", + "start": 1596, + "end": 1596, + "replacementText": ": number", "line": 67, "column": 22, "endLine": 67, @@ -1051,7 +871,7 @@ { "start": 1831, "end": 1858, - "replacementText": "orange.isVegetable1.areStrictlyEqual(123)", + "replacementText": "orange.getProperty(\"isVegetable1\").areStrictlyEqual(123)", "line": 84, "column": 5, "endLine": 84, @@ -1110,6 +930,26 @@ "endLine": 92, "endColumn": 2, "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "start": 1882, + "end": 1900, + "replacementText": "let tmp_1 = 0; tmp_1 < arr.getProperty('length').toNumber(); ++tmp_1", + "line": 88, + "column": 1, + "endLine": 92, + "endColumn": 2 + }, + { + "start": 1910, + "end": 1917, + "replacementText": "arr.getProperty(tmp_1).toNumber()", + "line": 88, + "column": 1, + "endLine": 92, + "endColumn": 2 + } + ], "suggest": "", "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json index cfe6324f31b9569623dcf5cff392d058c33e4fbd..d6958993db88cdda9b601cc2e835179fcfc763f6 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 69, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 606, - "end": 674, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 69 - }, - { - "start": 783, - "end": 783, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');\nlet ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA');\nlet Dog = ESValue.load('./interop_import_js_js').getProperty('Dog');\nlet Person = ESValue.load('./interop_import_js_js').getProperty('Person');\nlet Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 69 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 17, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 675, - "end": 728, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 54 - }, - { - "start": 783, - "end": 783, - "replacementText": "let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -80,26 +40,6 @@ "endLine": 18, "endColumn": 55, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 729, - "end": 783, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 55 - }, - { - "start": 783, - "end": 783, - "replacementText": "let wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');\n", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 55 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets index f7cde32163d4c0c4031ce29b783bcaf61fa964b0..59105c01fa7da01ef0d7bdf25e9cdbcbfc26ab63 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets @@ -13,16 +13,9 @@ * limitations under the License. */ - - -let wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); -let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA'); -let Dog = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let Person = ESValue.load('./interop_import_js_js').getProperty('Person'); -let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); - +import myAaa,{ClassA,Dog,Person,Wiki} from "./interop_import_js_js"; +import { Dog as Doge } from './interop_import_js_js'; +import { Wiki as wiki } from './interop_import_js_js'; myAaa.invoke().typeOf(); //error let fun = myAaa.invoke(); diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json index fadac292b142e8d2c1b87a492ad418d41482c1a0..b0154468d307ea51471633e2abd2216c3399b3dd 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json @@ -15,80 +15,60 @@ ], "result": [ { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 70, - "problem": "AnyType", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 69, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 69, - "problem": "AnyType", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 54, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 70, - "problem": "AnyType", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 55, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 21, "column": 5, "endLine": 21, - "endColumn": 74, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 68, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 74, + "endColumn": 25, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 24, + "line": 29, "column": 5, - "endLine": 24, - "endColumn": 70, + "endLine": 29, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 28, + "line": 35, "column": 5, - "endLine": 28, - "endColumn": 25, + "endLine": 35, + "endColumn": 37, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -98,7 +78,7 @@ "line": 36, "column": 5, "endLine": 36, - "endColumn": 35, + "endColumn": 42, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -106,28 +86,28 @@ }, { "line": 42, - "column": 5, + "column": 10, "endLine": 42, - "endColumn": 37, - "problem": "AnyType", + "endColumn": 30, + "problem": "LimitedVoidType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, { - "line": 43, - "column": 5, - "endLine": 43, - "endColumn": 42, - "problem": "AnyType", + "line": 47, + "column": 21, + "endLine": 47, + "endColumn": 41, + "problem": "LimitedVoidType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, { - "line": 56, + "line": 49, "column": 7, - "endLine": 56, + "endLine": 49, "endColumn": 13, "problem": "InvalidIdentifier", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json index a4046013b93e430245d0721aa7819fa408f81b59..66925f8b56c90b9336082f29d62d500a01d2bfd9 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 106, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 618, - "end": 723, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 106 - }, - { - "start": 723, - "end": 723, - "replacementText": "let foo = ESValue.load('./interop_not_have_property_js').getProperty('foo');\nlet person = ESValue.load('./interop_not_have_property_js').getProperty('person');\nlet TestHelper = ESValue.load('./interop_not_have_property_js').getProperty('TestHelper');\nlet Machine = ESValue.load('./interop_not_have_property_js').getProperty('Machine');\nlet User = ESValue.load('./interop_not_have_property_js').getProperty('User');\nlet Person = ESValue.load('./interop_not_have_property_js').getProperty('Person');\nlet Employee = ESValue.load('./interop_not_have_property_js').getProperty('Employee');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 106 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -431,7 +411,7 @@ { "start": 1005, "end": 1031, - "replacementText": "machine.name.areStrictlyEqual(\"machine\")", + "replacementText": "machine.getProperty(\"name\").areStrictlyEqual(\"machine\")", "line": 32, "column": 12, "endLine": 32, @@ -515,7 +495,7 @@ { "start": 1173, "end": 1190, - "replacementText": "user.id.areStrictlyEqual(\"Bob\")", + "replacementText": "user.getProperty(\"id\").areStrictlyEqual(\"Bob\")", "line": 37, "column": 12, "endLine": 37, @@ -620,7 +600,7 @@ { "start": 1312, "end": 1326, - "replacementText": "user.id.areStrictlyEqual(10)", + "replacementText": "user.getProperty(\"id\").areStrictlyEqual(10)", "line": 42, "column": 8, "endLine": 42, @@ -725,7 +705,7 @@ { "start": 1454, "end": 1470, - "replacementText": "user.id.areStrictlyEqual(123n)", + "replacementText": "user.getProperty(\"id\").areStrictlyEqual(123n)", "line": 47, "column": 12, "endLine": 47, @@ -809,7 +789,7 @@ { "start": 1601, "end": 1617, - "replacementText": "user.id.areStrictlyEqual(true)", + "replacementText": "user.getProperty(\"id\").areStrictlyEqual(true)", "line": 52, "column": 12, "endLine": 52, @@ -914,7 +894,7 @@ { "start": 1758, "end": 1784, - "replacementText": "machine.name.areStrictlyEqual(\"machine\")", + "replacementText": "machine.getProperty(\"name\").areStrictlyEqual(\"machine\")", "line": 57, "column": 12, "endLine": 57, @@ -998,7 +978,7 @@ { "start": 1929, "end": 1957, - "replacementText": "employee.name.areStrictlyEqual(\"employee\")", + "replacementText": "employee.getProperty(\"name\").areStrictlyEqual(\"employee\")", "line": 62, "column": 12, "endLine": 62, diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets index 3a19e5d1511c66c75b76ff0903e5120d555ac0f3..f289defb389042127ad4212664ce9509ee694de9 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets @@ -14,14 +14,7 @@ */ 'use static' -let foo = ESValue.load('./interop_not_have_property_js').getProperty('foo'); -let person = ESValue.load('./interop_not_have_property_js').getProperty('person'); -let TestHelper = ESValue.load('./interop_not_have_property_js').getProperty('TestHelper'); -let Machine = ESValue.load('./interop_not_have_property_js').getProperty('Machine'); -let User = ESValue.load('./interop_not_have_property_js').getProperty('User'); -let Person = ESValue.load('./interop_not_have_property_js').getProperty('Person'); -let Employee = ESValue.load('./interop_not_have_property_js').getProperty('Employee'); - +import { foo, person, TestHelper, Machine, User, Person, Employee } from "./interop_not_have_property_js" foo.getProperty("name") foo.setProperty("name", ESValue.wrap("456")) @@ -35,36 +28,36 @@ a.setProperty("age", ESValue.wrap(12.0)) let test_helper = TestHelper.instantiate(ESValue.wrap("TEST_INSTANTIATE_JS_OBJECT")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let machine = new Machine(); - return machine.name === "machine"; // arkts-interop-js2s-access-js-prop + let machine = Machine.instantiate(); + return machine.getProperty("name").areStrictlyEqual("machine"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("machine.name === 'machine'")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User("Bob"); - return user.id === "Bob"; // arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap("Bob")); + return user.getProperty("id").areStrictlyEqual("Bob"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 'Bob'")); test_helper.invokeMethod("test", ESValue.wrap(() => { -let user = new User(10.0); -return user.id === 10.0;// arkts-interop-js2s-access-js-prop +let user = User.instantiate(ESValue.wrap(10.0)); +return user.getProperty("id").areStrictlyEqual(10.0);// arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 10")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User(123n); - return user.id === 123n; // arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap(123n)); + return user.getProperty("id").areStrictlyEqual(123n); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 123n")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User(true); - return user.id === true;// arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap(true)); + return user.getProperty("id").areStrictlyEqual(true);// arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === true")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let machine = new Person("John", 10.0); - return machine.name === "machine"; // arkts-interop-js2s-access-js-prop + let machine = Person.instantiate(ESValue.wrap("John"), ESValue.wrap(10.0)); + return machine.getProperty("name").areStrictlyEqual("machine"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("machine.name === 'machine'")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let employee = new Employee(); - return employee.name === "employee"; // arkts-interop-js2s-access-js-prop + let employee = Employee.instantiate(); + return employee.getProperty("name").areStrictlyEqual("employee"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("employee.name === 'employee'")); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json index b8e566357c116732b2dc8a4c11f7e2deceea02af..65c441a16bebab818412e967fc266a3ca72cc2e6 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json @@ -16,233 +16,183 @@ "result": [ { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 76, - "problem": "AnyType", + "endColumn": 106, + "problem": "ImportAfterStatement", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" }, { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 82, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 90, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 84, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 78, - "problem": "AnyType", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 106, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 22, + "line": 26, "column": 5, - "endLine": 22, - "endColumn": 82, + "endLine": 26, + "endColumn": 26, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 23, + "line": 29, "column": 5, - "endLine": 23, - "endColumn": 86, + "endLine": 29, + "endColumn": 85, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 33, - "column": 5, + "line": 30, + "column": 47, "endLine": 33, - "endColumn": 26, - "problem": "AnyType", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 36, - "column": 5, - "endLine": 36, - "endColumn": 85, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 38, + "line": 31, "column": 9, - "endLine": 38, - "endColumn": 32, + "endLine": 31, + "endColumn": 40, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 38, - "column": 23, + "line": 35, + "column": 47, "endLine": 38, - "endColumn": 30, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 43, + "line": 36, "column": 9, - "endLine": 43, - "endColumn": 31, + "endLine": 36, + "endColumn": 53, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 43, - "column": 20, + "line": 40, + "column": 47, "endLine": 43, - "endColumn": 24, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 48, + "line": 41, "column": 5, - "endLine": 48, - "endColumn": 26, + "endLine": 41, + "endColumn": 48, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 48, - "column": 16, + "line": 45, + "column": 47, "endLine": 48, - "endColumn": 20, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 53, + "line": 46, "column": 9, - "endLine": 53, - "endColumn": 30, + "endLine": 46, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 53, - "column": 20, + "line": 50, + "column": 47, "endLine": 53, - "endColumn": 24, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 58, + "line": 51, "column": 9, - "endLine": 58, - "endColumn": 30, + "endLine": 51, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 58, - "column": 20, + "line": 55, + "column": 47, "endLine": 58, - "endColumn": 24, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 63, + "line": 56, "column": 9, - "endLine": 63, - "endColumn": 43, + "endLine": 56, + "endColumn": 79, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 63, - "column": 23, + "line": 60, + "column": 47, "endLine": 63, - "endColumn": 29, - "problem": "DynamicCtorCall", + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 68, + "line": 61, "column": 9, - "endLine": 68, - "endColumn": 34, + "endLine": 61, + "endColumn": 42, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" - }, - { - "line": 68, - "column": 24, - "endLine": 68, - "endColumn": 32, - "problem": "DynamicCtorCall", - "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json index e2cc9e5d4c304a7e81e9f0161e212837f15bf57f..5a00e93e85d4b302625e82ef5b3bfe8a8e648fe2 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 46, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 650, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 46 - }, - { - "start": 650, - "end": 650, - "replacementText": "let foo = ESValue.load('./interop_property_num_js').getProperty('foo');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 46 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets index b67f968b2194a5096ebe9bbeb12b2b56d3755b3c..397d49f4e68017f85604eb52118a48973d74f8f1 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -let foo = ESValue.load('./interop_property_num_js').getProperty('foo'); - +import {foo} from "./interop_property_num_js" +foo.getProperty("num").toNumber(); -foo.getProperty("num").toNumber(); diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json index 5c300a0f06e69097793e229c1c3690f080cc48ef..923652a6ed843e53643967940e9a49e35e5e2616 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json @@ -16,18 +16,18 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 71, - "problem": "AnyType", + "endColumn": 46, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 1, - "endLine": 20, + "endLine": 19, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 22, + "line": 21, "column": 1, - "endLine": 22, + "endLine": 21, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 23, + "line": 22, "column": 1, - "endLine": 23, + "endLine": 22, "endColumn": 37, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 1, - "endLine": 24, + "endLine": 23, "endColumn": 37, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 25, "column": 1, - "endLine": 26, + "endLine": 25, "endColumn": 37, "problem": "UnaryArithmNotNumber", "suggest": "", diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json index 196e9489ea59563866b74d541eaf24afc2c81604..10055bdbb3c857fb01df06afa1e8b1b764f15480 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 89, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 693, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 89 - }, - { - "start": 693, - "end": 693, - "replacementText": "let p = ESValue.load('./no_await_js_promise_export').getProperty('p');\nlet foo = ESValue.load('./no_await_js_promise_export').getProperty('foo');\nlet pFuncCall = ESValue.load('./no_await_js_promise_export').getProperty('pFuncCall');\nlet arrowFunc = ESValue.load('./no_await_js_promise_export').getProperty('arrowFunc');\nlet pArrowCall = ESValue.load('./no_await_js_promise_export').getProperty('pArrowCall');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 89 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets index 7729b47d7a6cd5c444ef70ccab73a8c18dce3602..63fd6e25e811a3538b264edb96e5d30366412a2c 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets @@ -13,12 +13,7 @@ * limitations under the License. */ -let p = ESValue.load('./no_await_js_promise_export').getProperty('p'); -let foo = ESValue.load('./no_await_js_promise_export').getProperty('foo'); -let pFuncCall = ESValue.load('./no_await_js_promise_export').getProperty('pFuncCall'); -let arrowFunc = ESValue.load('./no_await_js_promise_export').getProperty('arrowFunc'); -let pArrowCall = ESValue.load('./no_await_js_promise_export').getProperty('pArrowCall'); - +import { p, foo, pFuncCall, arrowFunc, pArrowCall } from "./no_await_js_promise_export"; async function awaitPromise() { return await p.toPromise(); @@ -61,7 +56,7 @@ const exampleObj = { }; (async () => { - console.log("IIFE result:", await p); + console.log("IIFE result:", await p.toPromise()); })(); (async () => { diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json index 0b6e2511ceacaa613c5a0fe7631766f9321db601..e83601dd74cdf19e93132d4109945addda867301 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json @@ -16,58 +16,18 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 89, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 74, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 86, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 86, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 88, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 23, "column": 16, - "endLine": 23, + "endLine": 18, "endColumn": 28, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -75,9 +35,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 22, "column": 16, - "endLine": 27, + "endLine": 22, "endColumn": 33, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -85,9 +45,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 26, "column": 16, - "endLine": 31, + "endLine": 26, "endColumn": 31, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -95,19 +55,9 @@ "severity": "ERROR" }, { - "line": 35, - "column": 16, - "endLine": 35, - "endColumn": 30, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 39, + "line": 34, "column": 16, - "endLine": 39, + "endLine": 34, "endColumn": 32, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -115,9 +65,9 @@ "severity": "ERROR" }, { - "line": 44, + "line": 39, "column": 9, - "endLine": 44, + "endLine": 39, "endColumn": 20, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -125,9 +75,9 @@ "severity": "ERROR" }, { - "line": 48, + "line": 43, "column": 13, - "endLine": 50, + "endLine": 45, "endColumn": 4, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -135,9 +85,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 48, "column": 20, - "endLine": 53, + "endLine": 48, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -145,9 +95,9 @@ "severity": "ERROR" }, { - "line": 54, + "line": 49, "column": 3, - "endLine": 56, + "endLine": 51, "endColumn": 4, "problem": "ObjectLiteralProperty", "suggest": "", @@ -155,9 +105,9 @@ "severity": "ERROR" }, { - "line": 54, + "line": 49, "column": 9, - "endLine": 54, + "endLine": 49, "endColumn": 18, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -165,9 +115,9 @@ "severity": "ERROR" }, { - "line": 58, + "line": 53, "column": 17, - "endLine": 60, + "endLine": 55, "endColumn": 4, "problem": "LimitedReturnTypeInference", "suggest": "", diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json index 653a902126e27bc67f81ab01aaccf13af138d7ce..eaa20eba2386671ee333872a2868b8c5553fcb23 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 88, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 692, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 88 - }, - { - "start": 692, - "end": 692, - "replacementText": "let Foo = ESValue.load('./no_js_instanceof_file.js').getProperty('Foo');\nlet foo = ESValue.load('./no_js_instanceof_file.js').getProperty('foo');\nlet CreatePerson = ESValue.load('./no_js_instanceof_file.js').getProperty('CreatePerson');\nlet a = ESValue.load('./no_js_instanceof_file.js').getProperty('a');\nlet b = ESValue.load('./no_js_instanceof_file.js').getProperty('b');\nlet MyNamespace = ESValue.load('./no_js_instanceof_file.js').getProperty('MyNamespace');\n", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 88 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -391,4 +371,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets index 619b63d4659038a813e10087178256f80689a392..be46340ed8446bf6875928a2076f5ce47394f8d5 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets @@ -13,13 +13,7 @@ * limitations under the License. */ -let Foo = ESValue.load('./no_js_instanceof_file.js').getProperty('Foo'); -let foo = ESValue.load('./no_js_instanceof_file.js').getProperty('foo'); -let CreatePerson = ESValue.load('./no_js_instanceof_file.js').getProperty('CreatePerson'); -let a = ESValue.load('./no_js_instanceof_file.js').getProperty('a'); -let b = ESValue.load('./no_js_instanceof_file.js').getProperty('b'); -let MyNamespace = ESValue.load('./no_js_instanceof_file.js').getProperty('MyNamespace'); - +import { Foo, foo, CreatePerson, a , b, MyNamespace } from "./no_js_instanceof_file.js" class Foo1 {} @@ -71,12 +65,12 @@ if(a.isInstanceOf(Array)) { } -if(b().isInstanceOf(Array)) { +if(b.invoke().isInstanceOf(Array)) { } -const myDog: MyNamespace.Dog = new MyNamespace.getProperty("Dog")('Buddy'); +const myDog: MyNamespace.Dog = new MyNamespace.getProperty("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("Dog")('Buddy'); -if (myDog.isInstanceOf(MyNamespace.Dog)) { +if (myDog.isInstanceOf(MyNamespace.getProperty("Dog"))) { console.log("This is a Dog!"); } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json index 7833e5b9a6ab314cc65509d10791e321d4eebf47..614491fbff0302bbd0e855eec4d722ef2d6c5c68 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json @@ -16,93 +16,73 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 90, - "problem": "AnyType", + "endColumn": 88, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 68, - "problem": "AnyType", + "line": 64, + "column": 19, + "endLine": 64, + "endColumn": 24, + "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 68, - "problem": "AnyType", + "line": 64, + "column": 19, + "endLine": 64, + "endColumn": 24, + "problem": "ClassAsObjectError", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 88, - "problem": "AnyType", + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 33, + "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", "severity": "ERROR" }, { - "line": 70, - "column": 19, - "endLine": 70, - "endColumn": 24, + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 33, "problem": "ClassAsObjectError", "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, { - "line": 74, - "column": 21, - "endLine": 74, - "endColumn": 26, - "problem": "ClassAsObjectError", + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 59, + "problem": "DynamicCtorCall", "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 78, + "line": 72, "column": 36, - "endLine": 78, + "endLine": 72, "endColumn": 59, - "problem": "DynamicCtorCall", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/object_literal_union_type.ets b/ets2panda/linter/test/interop/object_literal_union_type.ets index 2e730940c353d44edcde943baabc3cbe84d96937..403b45935861d995d1acd0d4a479512da91863a4 100644 --- a/ets2panda/linter/test/interop/object_literal_union_type.ets +++ b/ets2panda/linter/test/interop/object_literal_union_type.ets @@ -25,4 +25,6 @@ let xyz: X | Y | Z = { name: "xyz" } let ab: A | B = { name: "hello" } // legal -let y: X | Y = { name: "hello" } as Y; // legal \ No newline at end of file +let y: X | Y = { name: "hello" } as Y; // legal + +let res: Record | object[] = {} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json index 855bd5e9a2c3b9bc81eb5ff2062c5e5f36b6b445..a619d83610fe29ef5e2427badbd66e433ea96bcf 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 654, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - }, - { - "start": 654, - "end": 654, - "replacementText": "let foo = ESValue.load('./unary_operation_js_obj_js.js').getProperty('foo');\n", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets index 2cdab6f2ed8d1721df7d852f267de441a29f8765..7fef071bd036dd04adf66fec6acb429e207bbd37 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./unary_operation_js_obj_js.js').getProperty('foo'); - +import {foo} from "./unary_operation_js_obj_js.js" +foo.getProperty("num").toNumber(); -foo.getProperty("num").toNumber(); diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json index cb1d1f02e88ce65beb43b91ed8e53709c9bc7eb2..0a055b7965f1bf8ab53fa19829d87d9a4e8491bc 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json @@ -16,18 +16,18 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 76, - "problem": "AnyType", + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 21, + "line": 20, "column": 1, - "endLine": 21, + "endLine": 20, "endColumn": 35, "problem": "UnaryArithmNotNumber", "suggest": "", diff --git a/ets2panda/linter/test/interop/unique_types.ets b/ets2panda/linter/test/interop/unique_types.ets index 9c16a54d2b84b1c00967e1b3183e3b1f47b866d0..10b1d97c338a97888b0f6c285c7a389aafef6285 100644 --- a/ets2panda/linter/test/interop/unique_types.ets +++ b/ets2panda/linter/test/interop/unique_types.ets @@ -18,6 +18,7 @@ import { unknown_var, symbol_var, function_var, + enum_var, A, B, TestHelper, @@ -71,6 +72,7 @@ typeof symbol_var === 'object'; function_var() === true; A.instance; let obj: B = { name: "hello" }; +enum_var.a === 0; export function test_ts_non_standard_exception(testCaseRet: Array) { let test_helper = new TestHelper("TEST_TS_NON_STANDARD_EXCEPTION"); diff --git a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json index 7fb34afcb3d58763f347f8db772e0cd58f5c4d0e..ad93ff0af7b8299c75bcd115e8855c4864cfffb3 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json +++ b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "ExplicitFunctionType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -65,9 +65,29 @@ "severity": "ERROR" }, { - "line": 76, + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -75,9 +95,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -85,9 +105,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -95,9 +115,9 @@ "severity": "ERROR" }, { - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -105,9 +125,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -115,9 +135,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -125,9 +145,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -135,9 +155,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -145,9 +165,9 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +175,9 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +185,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -175,9 +195,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -185,9 +205,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -195,9 +215,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -205,9 +225,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -215,9 +235,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -225,9 +245,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -235,9 +255,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -245,9 +265,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -255,9 +275,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -265,9 +285,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -275,9 +295,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -285,9 +305,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -295,9 +315,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -305,9 +325,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -315,9 +335,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -325,9 +345,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -335,9 +355,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -345,9 +365,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -355,9 +375,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -365,9 +385,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -375,9 +395,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -385,9 +405,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -395,9 +415,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -405,9 +425,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -415,9 +435,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -425,9 +445,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -435,9 +455,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -445,9 +465,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -455,9 +475,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -465,9 +485,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -475,9 +495,9 @@ "severity": "ERROR" }, { - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -485,9 +505,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -495,9 +515,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -505,9 +525,9 @@ "severity": "ERROR" }, { - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -515,9 +535,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -525,9 +545,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -535,9 +555,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -545,9 +565,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.autofix.json b/ets2panda/linter/test/interop/unique_types.ets.autofix.json index bdb124b2ed0f5e5e555d8e2667ececa24b629721..203ab57067c1c62fe267b24574d87c2363f5f097 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.autofix.json +++ b/ets2panda/linter/test/interop/unique_types.ets.autofix.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,19 +45,19 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "ExplicitFunctionType", "autofix": [ { - "start": 1767, - "end": 1779, + "start": 1778, + "end": 1790, "replacementText": "function_var.unsafeCall", - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13 } ], @@ -66,9 +66,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -76,9 +76,40 @@ "severity": "ERROR" }, { - "line": 76, + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1862, + "end": 1863, + "replacementText": "0.0", + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -86,9 +117,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -96,9 +127,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -106,19 +137,19 @@ "severity": "ERROR" }, { - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 2118, - "end": 2121, + "start": 2147, + "end": 2150, "replacementText": "123.0", - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33 } ], @@ -127,9 +158,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -137,9 +168,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -147,9 +178,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -157,9 +188,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -167,19 +198,19 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39, "problem": "NumericSemantics", "autofix": [ { - "start": 3384, - "end": 3387, + "start": 3413, + "end": 3416, "replacementText": "123.0", - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39 } ], @@ -188,19 +219,19 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 3408, - "end": 3411, + "start": 3437, + "end": 3440, "replacementText": "456.0", - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63 } ], @@ -209,9 +240,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -219,9 +250,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -229,9 +260,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -239,9 +270,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -249,9 +280,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -259,9 +290,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -269,9 +300,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -279,9 +310,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -289,9 +320,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -299,9 +330,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -309,9 +340,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -319,9 +350,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -329,9 +360,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -339,9 +370,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -349,9 +380,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -359,9 +390,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -369,9 +400,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -379,9 +410,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -389,9 +420,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -399,9 +430,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -409,9 +440,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -419,9 +450,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -429,9 +460,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -439,9 +470,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -449,9 +480,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -459,9 +490,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -469,9 +500,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -479,9 +510,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -489,9 +520,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -499,9 +530,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -509,9 +540,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -519,19 +550,19 @@ "severity": "ERROR" }, { - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24, "problem": "NumericSemantics", "autofix": [ { - "start": 7971, - "end": 7972, + "start": 8000, + "end": 8001, "replacementText": "1.0", - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24 } ], @@ -540,9 +571,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -550,9 +581,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -560,19 +591,19 @@ "severity": "ERROR" }, { - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24, "problem": "NumericSemantics", "autofix": [ { - "start": 9425, - "end": 9426, + "start": 9454, + "end": 9455, "replacementText": "1.0", - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24 } ], @@ -581,9 +612,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -591,9 +622,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -601,9 +632,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -611,9 +642,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.json b/ets2panda/linter/test/interop/unique_types.ets.json index 017acb4fb6675fb0cb02104708b636850af28e85..b8a27de8736fc9b9090ab6e4c9dbea95a025445f 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.json +++ b/ets2panda/linter/test/interop/unique_types.ets.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 76, + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -115,9 +115,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets index 6f0585bf51ee08e41531004a3e9294a1211a1828..9aed01dd7956ddca64ec4ccc5dcabf3f50638447 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets @@ -18,6 +18,7 @@ import { unknown_var, symbol_var, function_var, + enum_var, A, B, TestHelper, @@ -71,6 +72,7 @@ typeof symbol_var === 'object'; function_var.unsafeCall() === true; A.instance; let obj: B = { name: "hello" }; +enum_var.a === 0.0; export function test_ts_non_standard_exception(testCaseRet: Array) { let test_helper = new TestHelper("TEST_TS_NON_STANDARD_EXCEPTION"); diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.json b/ets2panda/linter/test/interop/unique_types.ets.migrate.json index e78688989e029c10c72585f6d5d311db087036a5..3eb75a8fe4df6211f5934d4e04459e0469c9770a 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.json +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,9 +45,29 @@ "severity": "ERROR" }, { - "line": 76, + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 13, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -55,9 +75,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -65,9 +85,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -75,9 +95,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -85,9 +105,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -95,9 +115,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -105,9 +125,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -115,9 +135,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -125,9 +145,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -135,9 +155,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -145,9 +165,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -155,9 +175,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -165,9 +185,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -175,9 +195,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -185,9 +205,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -195,9 +215,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -205,9 +225,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -215,9 +235,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -225,9 +245,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -235,9 +255,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -245,9 +265,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -255,9 +275,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -265,9 +285,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -275,9 +295,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -285,9 +305,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -295,9 +315,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -305,9 +325,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -315,9 +335,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -325,9 +345,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -335,9 +355,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -345,9 +365,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -355,9 +375,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -365,9 +385,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -375,9 +395,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -385,9 +405,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -395,9 +415,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -405,9 +425,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -415,9 +435,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -425,9 +445,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -435,9 +455,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -445,9 +465,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -455,9 +475,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -465,9 +485,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -475,9 +495,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types2.ets b/ets2panda/linter/test/interop/unique_types2.ets new file mode 100644 index 0000000000000000000000000000000000000000..245729ec2cf9007e5ad193d6de5ad53c30acb744 --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types2.ets @@ -0,0 +1,120 @@ +/* + * Copyright (c) 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 { + NameAndEmail, + WithoutEmail, + PrimaryColors, + PrimitiveValues, + CleanData, + AddParams, + PerParams, + UserType, + PointInstance, + identity, + thisParameterType, + WithoutThis, + ClassThisType, + ShoutGreeting, + QuietGreeting, + CapitalizedWord, + UncapitalizedWord, + getCapitalize +} from './ignore_files/unique_types2'; + +//tools +const res :ShoutGreeting = 'HELLO'; //error + +const withoutThis: WithoutThis = {name: 'aaa'}; //error +class AA{ + private email:WithoutEmail={name:'1',age:10}; //error + set(color:PrimaryColors){ //error + } + get():PrimitiveValues|undefined{ //error + this.email as thisParameterType //error + const cc:ClassThisType = {} //error + return ; + } +} +function test(user:UserType,point:PointInstance,per:PerParams){} //error*3 +@Entry +@Component +struct MyComponent { + // 1. Pick/Omit 示例 + @State user: NameAndEmail = { name: 'Alice', email: 'alice@example.com' }; //error + @State partialUser: WithoutEmail = { name: 'Bob', age: 30 }; //error + + // 2. Exclude/Extract 示例 + @State primaryColor: PrimaryColors = 'red'; //error + @State primitiveValue: PrimitiveValues = true; //error + + // 3. NonNullable 示例 + @State validData: CleanData = 'valid'; //error + + // 4. Parameters/ConstructorParameters 示例 + private handleParams = (params: AddParams) => { //error + } + + // 5. ReturnType/InstanceType 示例 + @State userData: UserType = { id: 1, name: 'Charlie' }; //error + private point: PointInstance = { x: 10, y: 20 }; //error + + // 6. NoInfer 示例 + private useIdentity = () => { + const numResult = identity(123, 456); //error + // const errorResult = identity(123, 'abc'); //error + console.log('Identity result:', numResult); + } + + // 7. ThisParameterType/OmitThisParameter 示例 + private thisContext: thisParameterType = { name: 'Context' }; //error + private noThisFunc: WithoutThis = (x) => { //error + console.log('Without this:', x); + } + + // 8. 字符串工具类型示例 + @State shout: ShoutGreeting = 'HELLO'; //error + @State quiet: QuietGreeting = 'hello'; //error + @State capitalized: CapitalizedWord = 'Hello'; //error + @State uncapitalized: UncapitalizedWord = 'hello'; //error + + // 9. getCapitalize 函数 + computedWord= getCapitalize(); //error + + build() { + Column() { + // 显示用户信息 + Text(`Name: ${this.user.name}`) + Text(`Email: ${this.user.email}`) + + // 显示颜色和值 + Text(`Primary Color: ${this.primaryColor}`) + Text(`Primitive Value: ${this.primitiveValue}`) + + // 显示字符串转换结果 + Text(`Shout: ${this.shout}`) + Text(`Quiet: ${this.quiet}`) + Text(`Capitalized: ${this.capitalized}`) + Text(`Computed: ${this.computedWord}`) + + // 按钮触发函数 + Button('Call Identity') + .onClick(this.useIdentity) + + Button('Submit Parameters') + .onClick(() => this.handleParams([123, 'test'])) + } + .width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types2.ets.args.json b/ets2panda/linter/test/interop/unique_types2.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..bc4d2071daf6e9354e711c3b74b6be2b56659066 --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types2.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/interop/unique_types2.ets.arkts2.json b/ets2panda/linter/test/interop/unique_types2.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..2ff6a935c471b27421e63a39e6fb72f51cf3d8fc --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types2.ets.arkts2.json @@ -0,0 +1,668 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 25, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 20, + "endLine": 39, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 34, + "endLine": 39, + "endColumn": 35, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 19, + "endLine": 41, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 32, + "endLine": 41, + "endColumn": 33, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 46, + "endLine": 41, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 15, + "endLine": 42, + "endColumn": 28, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 11, + "endLine": 44, + "endColumn": 26, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 21, + "endLine": 45, + "endColumn": 38, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 16, + "endLine": 46, + "endColumn": 29, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 20, + "endLine": 50, + "endColumn": 28, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 35, + "endLine": 50, + "endColumn": 48, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 53, + "endLine": 50, + "endColumn": 62, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 16, + "endLine": 55, + "endColumn": 28, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 31, + "endLine": 55, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 23, + "endLine": 56, + "endColumn": 35, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 39, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 58, + "endLine": 56, + "endColumn": 60, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 24, + "endLine": 59, + "endColumn": 37, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 26, + "endLine": 60, + "endColumn": 41, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 21, + "endLine": 63, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 35, + "endLine": 66, + "endColumn": 44, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 20, + "endLine": 70, + "endColumn": 28, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 31, + "endLine": 70, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 37, + "endLine": 70, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 18, + "endLine": 71, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 39, + "endLine": 71, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 46, + "endLine": 71, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 11, + "endLine": 75, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 23, + "endLine": 75, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 32, + "endLine": 75, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 37, + "endLine": 75, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 24, + "endLine": 81, + "endColumn": 41, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 44, + "endLine": 81, + "endColumn": 45, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 23, + "endLine": 82, + "endColumn": 34, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 17, + "endLine": 87, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 17, + "endLine": 88, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 23, + "endLine": 89, + "endColumn": 38, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 25, + "endLine": 90, + "endColumn": 42, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 17, + "endLine": 93, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 18, + "endLine": 116, + "endColumn": 56, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 43, + "endLine": 116, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 2, + "endLine": 51, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 2, + "endLine": 52, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 4, + "endLine": 55, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 4, + "endLine": 56, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 4, + "endLine": 59, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 4, + "endLine": 60, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 4, + "endLine": 63, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 4, + "endLine": 70, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 4, + "endLine": 87, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 4, + "endLine": 88, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 4, + "endLine": 89, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 4, + "endLine": 90, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 5, + "endLine": 96, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 7, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 7, + "endLine": 99, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 7, + "endLine": 106, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 7, + "endLine": 107, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 7, + "endLine": 108, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 7, + "endLine": 109, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 7, + "endLine": 115, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types2.ets.json b/ets2panda/linter/test/interop/unique_types2.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ee4603f669d4004aed50443f8205fcf73b955ba3 --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types2.ets.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 39, + "column": 34, + "endLine": 39, + "endColumn": 35, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 32, + "endLine": 41, + "endColumn": 33, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 31, + "endLine": 55, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 39, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 31, + "endLine": 70, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 44, + "endLine": 81, + "endColumn": 45, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 18, + "endLine": 116, + "endColumn": 56, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types3.ets b/ets2panda/linter/test/interop/unique_types3.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e80761e144ed99290aa56d7c7bfa9ebce63aeee --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types3.ets @@ -0,0 +1,214 @@ +/* + * Copyright (c) 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 { + any_var, + symbol_var, + user, + unknown_var, + function_var, + func_type2, + objectLiteral_var, + objectLiteral_var2, + objectLiteral_var3, + objectLiteral_var32, + objectLiteral_var4, + objectLiteral_var5, + objectLiteral_var51, + objectLiteral_var6, + enum_var, + func_type, + constructor_type, + objIndexSignature_var, + Intersection_obj, + KeyOf_Type, + de, + key, + keyFuns, + Keys, + SomeType, + Person, + Person1, + ElementType, + NameOrAddress, + getInfo, + IndexAccess, + UserValueTypes, + stringType, + NumbersOnly, + ReturnVal, + Num, + typeOf_type, + typeOf_type1, + templateLiteralType, + TemplateLiteralType, + NameChanged, + testTemplateLiteralType, + Test, + ReadonlyUser, + Partial, + OptionalUser, + Mapped, + sumType +} from "./ignore_files/unique_types2" + +class TestHelper { + test(arg0: () => boolean, arg1: string) { + throw new Error("Method not implemented."); + } + constructor(name: string) { + } +} +export function test_unique_type(testCaseRet: Array) { + let test_helper = new TestHelper("TEST_UNIQUE_TYPE"); + + test_helper.test(() => { + return typeof any_var === 'object' //error + }, "any_var ") + + test_helper.test(() => { + return typeof unknown_var === 'number' //error + }, "unknown_var ") + + test_helper.test(() => { + return typeof symbol_var === 'object' //error + }, "symbol_var ") + + test_helper.test(() => { + return function_var() === true //error + }, "function_var ") + + test_helper.test(() => { + return enum_var.a === 0 //error + }, "enum_var ") + + test_helper.test(() => { + const res = new objectLiteral_var6().set({}); //error + const res2 = new objectLiteral_var6().set1(true); //error + const res3 = new objectLiteral_var6().set2({},true); //error + const res3 = new objectLiteral_var6().set3(); + return typeof res === 'object' + }, "objectLiteral_var7 ") + + test_helper.test(() => { + const res = new objectLiteral_var6().get(); //error + const res2 = new objectLiteral_var6().get1(); //error + const res3 = new objectLiteral_var6().get2(); //error + const res4 = new objectLiteral_var6().get3(); //error + const res5 = new objectLiteral_var6().get4(); + return typeof res === 'object' + }, "objectLiteral_var6 ") + + test_helper.test(() => { + typeof objectLiteral_var2 === 'object' //error + typeof objectLiteral_var3 === 'object' + typeof objectLiteral_var32 === 'object' //error + typeof objectLiteral_var4 === 'object' //error + typeof objectLiteral_var5 === 'object' //error + typeof objectLiteral_var51 === 'object' //error + return typeof objectLiteral_var === 'object' //error + }, "objectLiteral_var ") + + test_helper.test(() => { + console.log(typeOf_type) + console.log(typeOf_type1+'') //error + return typeof user === 'object' //error + }, "typeof") + + test_helper.test(() => { + let fun: func_type = (arg: number) => { //error + return arg.toString(); + }; + let fun2: func_type2 = (arg: number) => { //error + }; + return fun2(1) === '111' + }, "func_type ") + + test_helper.test(() => { + return typeof user === 'object' //error + }, "user ") + + test_helper.test(() => { + // const aa = '' as SomeType; + return typeof ('object' as SomeType) === 'object' //error + }, "SomeType ") + + + test_helper.test(() => { + return objIndexSignature_var[0] === "zero" //error + }, "objIndexSignature_var ") + + test_helper.test(() => { + return Intersection_obj.a === 10 && Intersection_obj.b === 'hello' //error*2 + }, "Intersection_obj ") + + test_helper.test(() => { + let keyof_var1: KeyOf_Type = 'a'; //error + let kk = de; //error + console.log(key) //error + keyFuns(); //error + const keys = new Keys(); + keys.set(undefined); //error + new Keys().get(); //error + keys.get1(); //error + return keyof_var1 === 'a' + }, "KeyOf_Type ") + + test_helper.test(() => { + let a :Person= {name:'a',age:1}; //error + a=Person1; //error + const b = 'a' as ElementType; //error + getInfo(b) as NameOrAddress; //error*2 + typeof new IndexAccess().par; //error + const indexAcc = new IndexAccess(); + indexAcc.set('',''); //error + indexAcc.get(''); //error + let c = '' as UserValueTypes //error + return typeof a === 'object' + }, "indexed access type") + + test_helper.test(() => { + new Test().returnStr(); //error? + return typeof stringType === 'object' //error? + }, "stringType ") + + test_helper.test(() => { + const c:NumbersOnly|undefined = undefined; //error + let d:ReturnVal = c as Num; //error*2 + return typeof c === 'boolean' + }, "conditional types ") + + test_helper.test(() => { + const c:ReadonlyUser|OptionalUser|undefined = undefined; //error*2 + let d:Mapped|boolean = false; //error + let e : Partial; //error + return typeof c === 'boolean' + }, "mapped types ") + + test_helper.test(() => { + const res: NameChanged = testTemplateLiteralType(''); //error*2 + let b :TemplateLiteralType; //error + return typeof templateLiteralType !== "undefined" //error + }, "templateLiteralType ") + + test_helper.test(() => { + let instance = new constructor_type("Alice"); //error + return instance.name === 'Alice' + }, "constructor_type ") + + test_helper.test(() => { + return typeof sumType !== "undefined" //error + }, "sumType ") + +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types3.ets.args.json b/ets2panda/linter/test/interop/unique_types3.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..bc4d2071daf6e9354e711c3b74b6be2b56659066 --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types3.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/interop/unique_types3.ets.arkts2.json b/ets2panda/linter/test/interop/unique_types3.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..aabbdb78be04ab1345c2781a79d78fefb24ae10e --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types3.ets.arkts2.json @@ -0,0 +1,738 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 77, + "column": 19, + "endLine": 77, + "endColumn": 26, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 19, + "endLine": 81, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 19, + "endLine": 85, + "endColumn": 29, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 12, + "endLine": 89, + "endColumn": 24, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 12, + "endLine": 89, + "endColumn": 24, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 12, + "endLine": 93, + "endColumn": 20, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 27, + "endLine": 93, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 17, + "endLine": 97, + "endColumn": 49, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 42, + "endLine": 97, + "endColumn": 45, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 46, + "endLine": 97, + "endColumn": 47, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 18, + "endLine": 98, + "endColumn": 53, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 43, + "endLine": 98, + "endColumn": 47, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 18, + "endLine": 99, + "endColumn": 56, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 43, + "endLine": 99, + "endColumn": 47, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 48, + "endLine": 99, + "endColumn": 49, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 18, + "endLine": 100, + "endColumn": 49, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 42, + "endLine": 105, + "endColumn": 45, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 43, + "endLine": 106, + "endColumn": 47, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 43, + "endLine": 107, + "endColumn": 47, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 43, + "endLine": 108, + "endColumn": 47, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 12, + "endLine": 114, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 12, + "endLine": 116, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 12, + "endLine": 117, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 12, + "endLine": 118, + "endColumn": 30, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 12, + "endLine": 119, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 19, + "endLine": 120, + "endColumn": 36, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 17, + "endLine": 125, + "endColumn": 29, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 19, + "endLine": 126, + "endColumn": 23, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 14, + "endLine": 130, + "endColumn": 23, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 133, + "column": 15, + "endLine": 133, + "endColumn": 25, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 17, + "endLine": 135, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 19, + "endLine": 139, + "endColumn": 23, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 32, + "endLine": 144, + "endColumn": 40, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 12, + "endLine": 149, + "endColumn": 36, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 12, + "endLine": 149, + "endColumn": 33, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 12, + "endLine": 153, + "endColumn": 28, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 35, + "endLine": 153, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 41, + "endLine": 153, + "endColumn": 57, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 21, + "endLine": 157, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 158, + "column": 14, + "endLine": 158, + "endColumn": 16, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 159, + "column": 17, + "endLine": 159, + "endColumn": 20, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 160, + "column": 5, + "endLine": 160, + "endColumn": 12, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 10, + "endLine": 162, + "endColumn": 13, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 163, + "column": 16, + "endLine": 163, + "endColumn": 19, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 10, + "endLine": 164, + "endColumn": 14, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 12, + "endLine": 169, + "endColumn": 18, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 20, + "endLine": 169, + "endColumn": 21, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 34, + "endLine": 169, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 170, + "column": 7, + "endLine": 170, + "endColumn": 14, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 171, + "column": 22, + "endLine": 171, + "endColumn": 33, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 172, + "column": 5, + "endLine": 172, + "endColumn": 12, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 172, + "column": 19, + "endLine": 172, + "endColumn": 32, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 173, + "column": 30, + "endLine": 173, + "endColumn": 33, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 175, + "column": 14, + "endLine": 175, + "endColumn": 17, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 14, + "endLine": 176, + "endColumn": 17, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 19, + "endLine": 177, + "endColumn": 33, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 187, + "column": 13, + "endLine": 187, + "endColumn": 24, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 188, + "column": 11, + "endLine": 188, + "endColumn": 20, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 188, + "column": 28, + "endLine": 188, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 13, + "endLine": 193, + "endColumn": 25, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 26, + "endLine": 193, + "endColumn": 38, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 194, + "column": 11, + "endLine": 194, + "endColumn": 17, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 195, + "column": 13, + "endLine": 195, + "endColumn": 20, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 200, + "column": 16, + "endLine": 200, + "endColumn": 27, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 200, + "column": 30, + "endLine": 200, + "endColumn": 57, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 200, + "column": 30, + "endLine": 200, + "endColumn": 53, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 12, + "endLine": 201, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 202, + "column": 19, + "endLine": 202, + "endColumn": 38, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 206, + "column": 24, + "endLine": 206, + "endColumn": 40, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 206, + "column": 24, + "endLine": 206, + "endColumn": 40, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 19, + "endLine": 211, + "endColumn": 26, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 188, + "column": 23, + "endLine": 188, + "endColumn": 31, + "problem": "StrictDiagnostic", + "suggest": "Conversion of type 'undefined' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.", + "rule": "Conversion of type 'undefined' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types3.ets.json b/ets2panda/linter/test/interop/unique_types3.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ba08ebc2873f575bc7978e7ac86eff69ea2a415b --- /dev/null +++ b/ets2panda/linter/test/interop/unique_types3.ets.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 97, + "column": 46, + "endLine": 97, + "endColumn": 47, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 48, + "endLine": 99, + "endColumn": 49, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 12, + "endLine": 149, + "endColumn": 36, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 20, + "endLine": 169, + "endColumn": 21, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 188, + "column": 23, + "endLine": 188, + "endColumn": 31, + "problem": "StrictDiagnostic", + "suggest": "Conversion of type 'undefined' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.", + "rule": "Conversion of type 'undefined' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets b/ets2panda/linter/test/main/arkts-array-type-immutable.ets index 8f805d822991f5155bfc793f9a0f344ca9c1bc33..3c018c68ab24c13ba22459b3696df7c95d28fe6c 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets @@ -153,4 +153,20 @@ if (handler.apply) handler.apply(objA, objA, []); let readonlyArr: ReadonlyArray = []; let arr66 = new Array(); -readonlyArr = arr66; //error \ No newline at end of file +readonlyArr = arr66; //error + +let stringArray: string[] = [] +let correctArr: (string | number)[] = [] + +const Foo = (): string[] => stringArray; + +const FooBar = (): (string | number)[] => stringArray; +const Baz = (): (string | number)[] => correctArr; + +async function Foo_a(): Promise<(string| number)[]> { + return stringArray; +} + +async function Foo_b(): Promise<(string| number)[]> { + return correctArr; +} diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json index e2441885c34ec65cda9f6053db97f9fcbe36c3af..74eb906e2fd654a4e341b370d93e0d7d63548e4d 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json @@ -733,6 +733,26 @@ "suggest": "", "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" + }, + { + "line": 163, + "column": 43, + "endLine": 163, + "endColumn": 54, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 167, + "column": 5, + "endLine": 167, + "endColumn": 24, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/arkts-no-import-json-file.ets b/ets2panda/linter/test/main/arkts-no-import-json-file.ets new file mode 100644 index 0000000000000000000000000000000000000000..550f8734be6b6a460913f004c8cc96b7f09f4f36 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-import-json-file.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + +// Valid import (non-json) +import { config } from './config'; + +// Invalid import - should trigger arkts-no-import-json-file +import data from './data.json'; // error + +// Another invalid case +import something from "../assets/data/data.json"; // error + +// Still invalid even if aliased +import * as jsonData from "./mock.json"; // error + +// Valid ArkTS-style config object (as alternative) +export const jsonLikeConfig = { + port: 3000, + secure: true, + options: { + retry: false + } +}; + +// Usage of config object +const portNumber: number = jsonLikeConfig.port; diff --git a/ets2panda/linter/test/main/arkts-no-import-json-file.ets.args.json b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..d8d3390ad9befeca9b595017d9eea0f5ada3d049 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-import-json-file.ets.arkts2.json b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..093aa8360756378b092021c56431061af7ba70a1 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 18, + "endLine": 20, + "endColumn": 31, + "problem": "NoImportJsonFile", + "suggest": "", + "rule": "JSON files cannot be imported (arkts-no-import-json-file)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 23, + "endLine": 23, + "endColumn": 49, + "problem": "NoImportJsonFile", + "suggest": "", + "rule": "JSON files cannot be imported (arkts-no-import-json-file)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 27, + "endLine": 26, + "endColumn": 40, + "problem": "NoImportJsonFile", + "suggest": "", + "rule": "JSON files cannot be imported (arkts-no-import-json-file)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 31, + "endLine": 29, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-import-json-file.ets.json b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..fc8e8a5f95de70396685642567b4b7961643683e --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-import-json-file.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 31, + "endLine": 29, + "endColumn": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets new file mode 100644 index 0000000000000000000000000000000000000000..0079ae69de97af89494f2ec7d79b3c9e3e79ab39 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + + +class A{ + public age:number = 1.0; +} + +class B{ + public name:string = "Joe"; + public age:number = 30; +} + +class C{ + public salary:number = 100; + public age:number = 30; +} + +let a: A = {"age": 30} + +let b: Record = { age: 30} + +let c: B = {"name" : "Annie", "age" : 25} + +let d: Record = {salary : 250, age: 30} + diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..bc4d2071daf6e9354e711c3b74b6be2b56659066 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.arkts2.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d9865e34233a35209039277b727b8e0a08548d9f --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.arkts2.json @@ -0,0 +1,178 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 23, + "column": 25, + "endLine": 23, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 28, + "endLine": 27, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 25, + "endLine": 28, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 13, + "endLine": 31, + "endColumn": 18, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 20, + "endLine": 31, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 35, + "endLine": 33, + "endColumn": 42, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 33, + "endLine": 33, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 40, + "endLine": 33, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 13, + "endLine": 35, + "endColumn": 19, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 31, + "endLine": 35, + "endColumn": 36, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 39, + "endLine": 35, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 34, + "endLine": 37, + "endColumn": 46, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 48, + "endLine": 37, + "endColumn": 55, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 33, + "endLine": 37, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 43, + "endLine": 37, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 53, + "endLine": 37, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..c41e2343989fdaf2f20b1c92f4c941cf0fa1b469 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 33, + "column": 33, + "endLine": 33, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 33, + "endLine": 37, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa688edec8041d27fc0065562f5df524dcef238c --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 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. + */ + +function foo1(a = 2){} + +function foo2(a = 2, b:number = 3){} + +function foo3(a = 2, b = 3){} + +class Calculator { + // Method with parameters + add(a, b): number { + return a + b; + } + + multiply(x: number, y): number { + return x * y; + } +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..66fb88f85945924e8be0e83d90123507033f4c5d --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d46010af5f9074ecd83285bb8ed5809eabe2ddb3 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json @@ -0,0 +1,168 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 15, + "endLine": 16, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 19, + "endLine": 16, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 19, + "endLine": 18, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 33, + "endLine": 18, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 15, + "endLine": 20, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 22, + "endLine": 20, + "endColumn": 27, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 19, + "endLine": 20, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 26, + "endLine": 20, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..e2df81fe91730df3834d19d02b08f5278fb98ff5 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2c357ee4cb4b59e0d55af1dea0d04b6c3ad3cdc --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 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. + */ + +class A { + readonly x: number = 10; +} +class B extends A { + readonly x: number = 20; // legal +} + +class C { + readonly y: string = "base"; +} +class D extends C { + readonly y: string = "child"; // legal +} + +class E { + z: boolean = true; +} +class F extends E { + z: boolean = false; // legal +} + +class G { + readonly foo: number = 42; +} +class H extends G {} // legal + +class M1 { + data: number = 1; +} +class M2 extends M1 { + readonly data: number = 2; // error +} + +class M3 { + version: string = "1.0"; +} +class M4 extends M3 { + readonly version: "2.0" = "2.0"; // error +} + +class M5 { + isReady: boolean = false; +} +class M6 extends M5 { + readonly isReady: true = true; // error +} + +class A1 { + data: number = 1; +} + +class A2 extends A1 { +} + +class A3 extends A2 { + readonly data: number= 2; // error +} + +class B1 { + readonly data: number = 1; +} + +class B2 extends B1 { +} + +class B3 extends B2 { + readonly data: number= 2; // legal +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.arkts2.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0d2d081c9cd812e8e708e3776131d4039c407231 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.arkts2.json @@ -0,0 +1,178 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 24, + "endLine": 17, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 24, + "endLine": 20, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 26, + "endLine": 38, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 18, + "endLine": 43, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 3, + "endLine": 46, + "endColumn": 29, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 27, + "endLine": 46, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 12, + "endLine": 53, + "endColumn": 19, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 3, + "endLine": 53, + "endColumn": 35, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 12, + "endLine": 60, + "endColumn": 19, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 3, + "endLine": 60, + "endColumn": 33, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 21, + "endLine": 60, + "endColumn": 25, + "problem": "LimitedLiteralType", + "suggest": "", + "rule": "Literal types are restricted(arkts-limited-literal-types)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 20, + "endLine": 64, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 5, + "endLine": 71, + "endColumn": 30, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 28, + "endLine": 71, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 29, + "endLine": 75, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 28, + "endLine": 82, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json index 8aff28f18833ef33a985c0474e23397bce8bda52..2ca2aebf6a3c14eefaa734154b5dbf4a933beefe 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 639, - "end": 657, - "replacementText": "an_array: number[] = [1, 2, 3]", + "start": 647, + "end": 647, + "replacementText": ": number[]", "line": 17, "column": 7, "endLine": 17, @@ -106,9 +106,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 664, - "end": 683, - "replacementText": "a: number = an_array[index]", + "start": 665, + "end": 665, + "replacementText": ": number", "line": 18, "column": 7, "endLine": 18, @@ -158,9 +158,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 690, - "end": 714, - "replacementText": "a1: number = an_array[index + 1]", + "start": 692, + "end": 692, + "replacementText": ": number", "line": 19, "column": 7, "endLine": 19, @@ -210,9 +210,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 721, - "end": 747, - "replacementText": "a2: number = an_array[index + 1.1]", + "start": 723, + "end": 723, + "replacementText": ": number", "line": 20, "column": 7, "endLine": 20, @@ -262,9 +262,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 754, - "end": 772, - "replacementText": "b: number = an_array[1.23]", + "start": 755, + "end": 755, + "replacementText": ": number", "line": 21, "column": 7, "endLine": 21, @@ -394,9 +394,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 887, - "end": 901, - "replacementText": "g: number = an_array[]", + "start": 888, + "end": 888, + "replacementText": ": number", "line": 26, "column": 7, "endLine": 26, @@ -425,9 +425,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 908, - "end": 925, - "replacementText": "h: number = an_array[12.]", + "start": 909, + "end": 909, + "replacementText": ": number", "line": 27, "column": 7, "endLine": 27, @@ -477,9 +477,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 932, - "end": 950, - "replacementText": "i: number = an_array[12.0]", + "start": 933, + "end": 933, + "replacementText": ": number", "line": 28, "column": 7, "endLine": 28, @@ -529,9 +529,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 957, - "end": 972, - "replacementText": "j: number = an_array[0]", + "start": 958, + "end": 958, + "replacementText": ": number", "line": 29, "column": 7, "endLine": 29, @@ -560,9 +560,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 979, - "end": 1009, - "replacementText": "k: number = an_array[Number.MAX_VALUE]", + "start": 980, + "end": 980, + "replacementText": ": number", "line": 30, "column": 7, "endLine": 30, @@ -612,9 +612,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1016, - "end": 1046, - "replacementText": "l: number = an_array[Number.MIN_VALUE]", + "start": 1017, + "end": 1017, + "replacementText": ": number", "line": 31, "column": 7, "endLine": 31, @@ -664,9 +664,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1053, - "end": 1090, - "replacementText": "m: number = an_array[Number.MAX_SAFE_INTEGER]", + "start": 1054, + "end": 1054, + "replacementText": ": number", "line": 32, "column": 7, "endLine": 32, @@ -716,9 +716,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1098, - "end": 1113, - "replacementText": "array: number[] = [1, 2, 3]", + "start": 1103, + "end": 1103, + "replacementText": ": number[]", "line": 35, "column": 5, "endLine": 35, @@ -945,9 +945,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1391, - "end": 1409, - "replacementText": "array1: number[] = [1, 2, 3]", + "start": 1397, + "end": 1397, + "replacementText": ": number[]", "line": 50, "column": 5, "endLine": 50, @@ -1060,9 +1060,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1436, - "end": 1454, - "replacementText": "array2: number[] = [1, 2, 3]", + "start": 1442, + "end": 1442, + "replacementText": ": number[]", "line": 53, "column": 5, "endLine": 53, @@ -1663,9 +1663,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1924, - "end": 1932, - "replacementText": "test: number = 1", + "start": 1928, + "end": 1928, + "replacementText": ": number", "line": 87, "column": 5, "endLine": 87, @@ -1798,9 +1798,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2154, - "end": 2169, - "replacementText": "array: number[] = [1, 2, 3]", + "start": 2159, + "end": 2159, + "replacementText": ": number[]", "line": 98, "column": 13, "endLine": 98, @@ -1948,4 +1948,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets index 70fb78c3800c4408724f13f60875326f2d12a5d3..7266dd25101a50a8c50e62a93a01b2654ac08926 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets @@ -19,7 +19,7 @@ import { } from '@kit.ArkUI'; function foo(index:number){ - let an_array: number[] = [1.0, 2.0, 3.0] + let an_array: number[] = [1.0,2.0,3.0] let a: number = an_array[index as int] let a1: number = an_array[(index + 1) as int] let a2: number = an_array[(index + 1.1) as int] @@ -37,7 +37,7 @@ function foo(index:number){ let m: number = an_array[Number.MAX_SAFE_INTEGER as int] } -let array: number[] = [1.0, 2.0, 3.0] +let array: number[] = [1.0,2.0,3.0] const index_1: number = 1.3; let index_2: number = 1.3; let index_3: number = 1.0; @@ -100,7 +100,7 @@ struct Test { async cateMode(testIndex: number) { emitter.on(innerEvent, (eventData) => { if (this.testIndex == 0.0) { - let array: number[] = [1.0, 2.0, 3.0]; + let array: number[] = [1.0,2.0,3.0]; array[this.testIndex as int]; } }) diff --git a/ets2panda/linter/test/main/builder_node.ets b/ets2panda/linter/test/main/builder_node.ets new file mode 100644 index 0000000000000000000000000000000000000000..a277872e970debdb85bfe7d4f35e99d570c12d83 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets @@ -0,0 +1,123 @@ +/* + * Copyright (c) 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 { NodeController, BuilderNode, FrameNode } from './ui_modules/@kit.ArkUI'; + +class Params { + item: string = ''; + + constructor(item: string) { + this.item = item; + } +} + +interface CustomInterface { + item: string; + age: number; +} + +class CustomClass { + private item: string = 'C'; + age: number = 10; +} + +@Builder +function buildNode(param: Params) {} + +function getObject1() { + const customInterfaceParams: CustomInterface | number = 1 > 0 ? { item: 'C', age: 100 } : 1; + return customInterfaceParams; +} + +function getObject2() { + const customInterfaceParams: CustomInterface = { + item: 'C', + age: 100 + }; + return customInterfaceParams; +} + +class MyNodeController extends NodeController { + public builderNode1: BuilderNode<[Params]> | null = null; // error + public builderNode2: BuilderNode<[Params]> | null = null; // error + public builderNode3: BuilderNode<[]> | null = null; // error + public builderNode4: BuilderNode<[]> | null = null; // error + public frameNode: FrameNode | null = null; + public item: string = ""; + + getObject3() { + const customInterfaceParams: CustomInterface = { + item: 'C', + age: 100 + }; + return customInterfaceParams; + } + + makeNode(uiContext: UIContext): FrameNode | null { + if (this.builderNode1 == null || this.builderNode2 == null + || this.builderNode3 == null || this.builderNode4 == null) { + this.builderNode1 = new BuilderNode(uiContext, { selfIdealSize : { width: 300, height: 200} }); + this.builderNode2 = new BuilderNode<[Params]>(uiContext, { selfIdealSize: { width: 300, height: 200} }); // error + this.builderNode3 = new BuilderNode(uiContext, { selfIdealSize : { width: 300, height: 200} }); + this.builderNode4 = new BuilderNode<[]>(uiContext, { selfIdealSize : { width: 300, height: 200} }); // error + this.builderNode1.build(wrapBuilder<[Params]>(buildNode), new Params(this.item), { nestingBuilderSupported: false }) // error + let flag = true; + this.builderNode2.build(wrapBuilder<[Params]>(buildNode), new Params(this.item), { nestingBuilderSupported: flag }); // error + } + + return this.frameNode; + } + + updateItem(item: string, customParam: boolean): void { + this.item = item; + if (this.builderNode1 && this.builderNode2 && this.builderNode3 && this.builderNode4) { + if (customParam) { + const a1: CustomInterface = { + item: 'C', + age: 100 + }; + const a2: CustomInterface | number = 1 > 0 ? { item: 'C', age: 100 } : 1; + const a3 = getObject1(); + const a4 = getObject2(); + const customClassParams: CustomClass = new CustomClass(); + this.builderNode1.update(a1); // error + this.builderNode2.update(a2); // error + this.builderNode3.update(a3); // error + this.builderNode4.update(a4); // error + this.builderNode1.update({ item: 'C', age: 100 }); // error + this.builderNode2.update(1 > 0 ? a1 : 1); // error + this.builderNode3.update(customClassParams); + this.builderNode3.update({ item: 'C', age: 100}); // error + this.builderNode4.update(getObject1()); // error + this.builderNode4.update(getObject2()); // error + this.builderNode4.update(this.getObject3()); // error + } else {} + } + } +} + +@Reusable +@Component +struct ReusableChildComponent { + private controller: MyNodeController = new MyNodeController(); + + aboutToReuse(params: Record): void { + this.controller?.builderNode1?.reuse(params); + } + + build() { + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/builder_node.ets.args.json b/ets2panda/linter/test/main/builder_node.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ec9992d92461d66e16b80975e33f95872c06af54 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/builder_node.ets.arkts2.json b/ets2panda/linter/test/main/builder_node.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..57d4b5b5c63d5f161643e86a0432f72ccaaa8fd3 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.arkts2.json @@ -0,0 +1,568 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 33, + "column": 17, + "endLine": 33, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 60, + "endLine": 40, + "endColumn": 61, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 64, + "endLine": 40, + "endColumn": 65, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 86, + "endLine": 40, + "endColumn": 89, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 94, + "endLine": 40, + "endColumn": 95, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 10, + "endLine": 47, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 24, + "endLine": 53, + "endColumn": 45, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 24, + "endLine": 54, + "endColumn": 45, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 24, + "endLine": 55, + "endColumn": 39, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 24, + "endLine": 56, + "endColumn": 39, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 12, + "endLine": 63, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 27, + "endLine": 71, + "endColumn": 101, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 72, + "endLine": 71, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 81, + "endLine": 71, + "endColumn": 84, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 94, + "endLine": 71, + "endColumn": 97, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 27, + "endLine": 72, + "endColumn": 110, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 81, + "endLine": 72, + "endColumn": 82, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 90, + "endLine": 72, + "endColumn": 93, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 103, + "endLine": 72, + "endColumn": 106, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 27, + "endLine": 73, + "endColumn": 101, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 72, + "endLine": 73, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 81, + "endLine": 73, + "endColumn": 84, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 94, + "endLine": 73, + "endColumn": 97, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 27, + "endLine": 74, + "endColumn": 105, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 76, + "endLine": 74, + "endColumn": 77, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 85, + "endLine": 74, + "endColumn": 88, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 98, + "endLine": 74, + "endColumn": 101, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 7, + "endLine": 75, + "endColumn": 123, + "problem": "BuilderNodeNoNestingBuilderSupported", + "suggest": "", + "rule": "Property \"nestingBuilderSupported\" is not supported (arkui-buildernode-no-nestingbuildersupported)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 31, + "endLine": 75, + "endColumn": 63, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 7, + "endLine": 77, + "endColumn": 122, + "problem": "BuilderNodeNoNestingBuilderSupported", + "suggest": "", + "rule": "Property \"nestingBuilderSupported\" is not supported (arkui-buildernode-no-nestingbuildersupported)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 31, + "endLine": 77, + "endColumn": 63, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 16, + "endLine": 89, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 46, + "endLine": 91, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 50, + "endLine": 91, + "endColumn": 51, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 72, + "endLine": 91, + "endColumn": 75, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 80, + "endLine": 91, + "endColumn": 81, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 9, + "endLine": 95, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 9, + "endLine": 96, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 9, + "endLine": 97, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 9, + "endLine": 98, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 9, + "endLine": 99, + "endColumn": 58, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 52, + "endLine": 99, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 9, + "endLine": 100, + "endColumn": 49, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 34, + "endLine": 100, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 38, + "endLine": 100, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 47, + "endLine": 100, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 9, + "endLine": 102, + "endColumn": 57, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 52, + "endLine": 102, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 9, + "endLine": 103, + "endColumn": 47, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 9, + "endLine": 104, + "endColumn": 47, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 9, + "endLine": 105, + "endColumn": 52, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 2, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 23, + "endLine": 68, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"UIContext\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 2, + "endLine": 111, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Reusable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 2, + "endLine": 112, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/builder_node.ets.json b/ets2panda/linter/test/main/builder_node.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..cbe274b6acf883f870cc6ad44d783f614d81fb8d --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 71, + "column": 72, + "endLine": 71, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 81, + "endLine": 72, + "endColumn": 82, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 72, + "endLine": 73, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 76, + "endLine": 74, + "endColumn": 77, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/case_expr.ets.arkts2.json b/ets2panda/linter/test/main/case_expr.ets.arkts2.json index abc2f67950850ae0e8ee1634cee91d1c7cc073f1..44cd6542b5ef56b30ed8d9d729d7a9549071304a 100755 --- a/ets2panda/linter/test/main/case_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/case_expr.ets.arkts2.json @@ -121,7 +121,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json index 461137accaf6240bf2fdf90a6d49561d3c968c57..44a60b85bb81f801a67c7fe752b4a1521a07c780 100644 --- a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json @@ -881,7 +881,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/collections_module.ets b/ets2panda/linter/test/main/collections_module.ets index 5fba982f6b6426a38730e4019763ff9658df5fc2..f61a5a5a4d52d648c5a17b1166ade1c58a424468 100644 --- a/ets2panda/linter/test/main/collections_module.ets +++ b/ets2panda/linter/test/main/collections_module.ets @@ -19,7 +19,7 @@ import { collections as collectionsAlias } from './oh_modules/@arkts.collections import { collections as kitCollections } from './oh_modules/@kit.ArkTS'; -import { collections as definedCollections } from 'user_defined_worker'; //legal +import { collections as definedCollections } from './ignore_files/user_defined_collections'; //legal function tesCollectionsUsage() { @@ -36,3 +36,11 @@ function tesCollectionsUsage() { let collections6: definedCollections.Array; // legal } + +function test(array: collections.Array) { + const map = collections.Map(); +} + +function testBitVector(bv: collections.BitVector) { + const bitVector = new collections.BitVector(); +} diff --git a/ets2panda/linter/test/main/collections_module.ets.arkts2.json b/ets2panda/linter/test/main/collections_module.ets.arkts2.json index 584e375a01ba06e7a2ecd03772a34d762c5ccbba..6fb86f244dfc3ed0b8908ed97460eb09399ffc6b 100644 --- a/ets2panda/linter/test/main/collections_module.ets.arkts2.json +++ b/ets2panda/linter/test/main/collections_module.ets.arkts2.json @@ -24,16 +24,6 @@ "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", "severity": "ERROR" }, - { - "line": 18, - "column": 10, - "endLine": 18, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 18, "column": 25, @@ -44,16 +34,6 @@ "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", "severity": "ERROR" }, - { - "line": 20, - "column": 10, - "endLine": 20, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 20, "column": 25, @@ -68,7 +48,7 @@ "line": 26, "column": 23, "endLine": 26, - "endColumn": 34, + "endColumn": 40, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -78,7 +58,7 @@ "line": 26, "column": 55, "endLine": 26, - "endColumn": 66, + "endColumn": 72, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -88,7 +68,7 @@ "line": 28, "column": 28, "endLine": 28, - "endColumn": 44, + "endColumn": 50, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -98,7 +78,7 @@ "line": 30, "column": 28, "endLine": 30, - "endColumn": 42, + "endColumn": 48, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -108,7 +88,7 @@ "line": 32, "column": 21, "endLine": 32, - "endColumn": 37, + "endColumn": 43, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -118,7 +98,7 @@ "line": 34, "column": 23, "endLine": 34, - "endColumn": 39, + "endColumn": 45, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -128,7 +108,87 @@ "line": 34, "column": 60, "endLine": 34, - "endColumn": 76, + "endColumn": 82, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 22, + "endLine": 40, + "endColumn": 39, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 11, + "endLine": 41, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 32, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 32, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", diff --git a/ets2panda/linter/test/main/collections_module.ets.autofix.json b/ets2panda/linter/test/main/collections_module.ets.autofix.json index 3b091c13f428361247667bb4cc8bd51cef9274b9..9be897f59e5ec888e5fcf18f65ebcbdab3e3da2b 100644 --- a/ets2panda/linter/test/main/collections_module.ets.autofix.json +++ b/ets2panda/linter/test/main/collections_module.ets.autofix.json @@ -24,24 +24,11 @@ { "start": 605, "end": 667, - "replacementText": "" - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 10, - "endLine": 18, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 669, - "end": 751, - "replacementText": "" + "replacementText": "", + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 21 } ], "suggest": "", @@ -58,24 +45,11 @@ { "start": 669, "end": 751, - "replacementText": "" - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 10, - "endLine": 20, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 753, - "end": 825, - "replacementText": "" + "replacementText": "", + "line": 18, + "column": 25, + "endLine": 18, + "endColumn": 41 } ], "suggest": "", @@ -92,7 +66,11 @@ { "start": 753, "end": 825, - "replacementText": "" + "replacementText": "", + "line": 20, + "column": 25, + "endLine": 20, + "endColumn": 39 } ], "suggest": "", @@ -103,13 +81,17 @@ "line": 26, "column": 23, "endLine": 26, - "endColumn": 34, + "endColumn": 40, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 965, - "end": 982, - "replacementText": "Array" + "start": 985, + "end": 1002, + "replacementText": "Array", + "line": 26, + "column": 23, + "endLine": 26, + "endColumn": 40 } ], "suggest": "", @@ -120,13 +102,17 @@ "line": 26, "column": 55, "endLine": 26, - "endColumn": 66, + "endColumn": 72, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 997, - "end": 1014, - "replacementText": "Array" + "start": 1017, + "end": 1034, + "replacementText": "Array", + "line": 26, + "column": 55, + "endLine": 26, + "endColumn": 72 } ], "suggest": "", @@ -137,13 +123,17 @@ "line": 28, "column": 28, "endLine": 28, - "endColumn": 44, + "endColumn": 50, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 1054, - "end": 1076, - "replacementText": "Array" + "start": 1074, + "end": 1096, + "replacementText": "Array", + "line": 28, + "column": 28, + "endLine": 28, + "endColumn": 50 } ], "suggest": "", @@ -154,13 +144,17 @@ "line": 30, "column": 28, "endLine": 30, - "endColumn": 42, + "endColumn": 48, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 1116, - "end": 1136, - "replacementText": "Array" + "start": 1136, + "end": 1156, + "replacementText": "Array", + "line": 30, + "column": 28, + "endLine": 30, + "endColumn": 48 } ], "suggest": "", @@ -171,13 +165,17 @@ "line": 32, "column": 21, "endLine": 32, - "endColumn": 37, + "endColumn": 43, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 1169, - "end": 1191, - "replacementText": "Array" + "start": 1189, + "end": 1211, + "replacementText": "Array", + "line": 32, + "column": 21, + "endLine": 32, + "endColumn": 43 } ], "suggest": "", @@ -188,13 +186,17 @@ "line": 34, "column": 23, "endLine": 34, - "endColumn": 39, + "endColumn": 45, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 1224, - "end": 1246, - "replacementText": "Array" + "start": 1244, + "end": 1266, + "replacementText": "Array", + "line": 34, + "column": 23, + "endLine": 34, + "endColumn": 45 } ], "suggest": "", @@ -205,13 +207,159 @@ "line": 34, "column": 60, "endLine": 34, - "endColumn": 76, + "endColumn": 82, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { - "start": 1261, - "end": 1283, - "replacementText": "Array" + "start": 1281, + "end": 1303, + "replacementText": "Array", + "line": 34, + "column": 60, + "endLine": 34, + "endColumn": 82 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 22, + "endLine": 40, + "endColumn": 39, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1404, + "end": 1421, + "replacementText": "Array", + "line": 40, + "column": 22, + "endLine": 40, + "endColumn": 39 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 11, + "endLine": 41, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 32, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1449, + "end": 1464, + "replacementText": "Map", + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 32, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1514, + "end": 1535, + "replacementText": "BitVector", + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49 + }, + { + "start": 919, + "end": 919, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1573, + "end": 1594, + "replacementText": "BitVector", + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48 + }, + { + "start": 919, + "end": 919, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48 } ], "suggest": "", diff --git a/ets2panda/linter/test/main/collections_module.ets.json b/ets2panda/linter/test/main/collections_module.ets.json index ca88f857e960b437dcf767c0ac40be998c8f1236..927ff202214f3a1090827f0856d16510b65298d6 100644 --- a/ets2panda/linter/test/main/collections_module.ets.json +++ b/ets2panda/linter/test/main/collections_module.ets.json @@ -13,5 +13,36 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] -} \ No newline at end of file + "result": [ + { + "line": 41, + "column": 11, + "endLine": 41, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 32, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.ets b/ets2panda/linter/test/main/collections_module.ets.migrate.ets index 02fc9aaad5de07117bf611e6701de10bcfd98aa1..9915905ea53f6be768dfe0ad9871dd9059a031a9 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.ets +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.ets @@ -19,7 +19,9 @@ -import { collections as definedCollections } from 'user_defined_worker'; //legal +import { collections as definedCollections } from './ignore_files/user_defined_collections'; +import { BitVector } from "@arkts.collections"; + //legal function tesCollectionsUsage() { @@ -36,3 +38,11 @@ function tesCollectionsUsage() { let collections6: definedCollections.Array; // legal } + +function test(array: Array) { + const map = Map(); +} + +function testBitVector(bv: BitVector) { + const bitVector = new BitVector(); +} diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.json b/ets2panda/linter/test/main/collections_module.ets.migrate.json index 4dcf9e56dbc14e1fbd427eeb3ad24f841cacf0ce..e3768540dc783f9b6fe11d045ce1217df7aaff07 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.json +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.json @@ -13,6 +13,36 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 43, + "column": 11, + "endLine": 43, + "endColumn": 38, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 11, + "endLine": 47, + "endColumn": 46, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 27, + "endLine": 47, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] } - diff --git a/ets2panda/linter/test/main/comment_test.ets.autofix.json b/ets2panda/linter/test/main/comment_test.ets.autofix.json index e1951adff8ddddfaedb6f848ebbbffdc784079e6..9fc28462eacba428d5df2a5aba7ce9fa66971c48 100644 --- a/ets2panda/linter/test/main/comment_test.ets.autofix.json +++ b/ets2panda/linter/test/main/comment_test.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 669, - "end": 684, - "replacementText": "property: number = 123;", + "start": 677, + "end": 677, + "replacementText": ": number", "line": 20, "column": 5, "endLine": 20, @@ -64,9 +64,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 737, - "end": 750, - "replacementText": "arr: number[] = [1, 0];", + "start": 740, + "end": 740, + "replacementText": ": number[]", "line": 22, "column": 5, "endLine": 22, diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index 23fd6cb93cf96de9e3288cff0f2499cba8f50d71..491b4f1e67bae405604ae18203cfb27287346557 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -295,9 +295,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1416, - "end": 1430, - "replacementText": "startPos: number = 300", + "start": 1424, + "end": 1424, + "replacementText": ": number", "line": 54, "column": 9, "endLine": 54, @@ -337,9 +337,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1476, - "end": 1519, - "replacementText": "pos: number = startPos - child.measureResult.height", + "start": 1479, + "end": 1479, + "replacementText": ": number", "line": 56, "column": 11, "endLine": 56, @@ -442,9 +442,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1958, - "end": 1968, - "replacementText": "size: number = 100", + "start": 1962, + "end": 1962, + "replacementText": ": number", "line": 80, "column": 9, "endLine": 80, @@ -631,9 +631,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2642, - "end": 2652, - "replacementText": "size: number = 100", + "start": 2646, + "end": 2646, + "replacementText": ": number", "line": 110, "column": 9, "endLine": 110, @@ -736,9 +736,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3055, - "end": 3069, - "replacementText": "startPos: number = 300", + "start": 3063, + "end": 3063, + "replacementText": ": number", "line": 121, "column": 9, "endLine": 121, @@ -778,9 +778,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3115, - "end": 3158, - "replacementText": "pos: number = startPos - child.measureResult.height", + "start": 3118, + "end": 3118, + "replacementText": ": number", "line": 123, "column": 11, "endLine": 123, diff --git a/ets2panda/linter/test/main/derived_class_field_type_matching.ets b/ets2panda/linter/test/main/derived_class_field_type_matching.ets new file mode 100644 index 0000000000000000000000000000000000000000..2807603e1334df15008dad76a06d1de1bf0fec72 --- /dev/null +++ b/ets2panda/linter/test/main/derived_class_field_type_matching.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 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. + */ + +class A { + obj1: number | string = 0.0; + obj2: string = 'hello'; + obj3: number | string | boolean = false; +} + +class B extends A { + obj1: string | number = 0.0; // OK + obj2: string = 'hello'; // OK + obj3: number | string | boolean = false; // OK +} + +class C extends A { + obj1: string = 'hello'; // MISMATCH/ERROR + obj2: number = 0.0; // MISMATCH/ERROR + obj3: number | boolean = false; // MISMATCH/ERROR +} + +class D extends A { + obj1: string | number | boolean = 'hello'; // MISMATCH/ERROR + obj2: number | string = 0.0; // MISMATCH/ERROR +} + +class E { obj: number | string = 1.0; } +class F extends E { obj: number = 1.0; } // will be flagged on F vs E => MISMATCH/ERROR +class G extends F { obj: number = 1.0; } // will be checked on G vs F => OK + +class A1 {} +class A2 extends A1 { + obj: number | string = 0.0; +} +class A3 extends A2 {} +class A4 extends A3 { + obj: number = 0.0; // ERROR/MISMATCH => field type is not matching with obj from base class A2 +} + +class B1 { + obj: number | string = 0.0; +} + +class B2 extends B1 { // no error + obj: number | string = 0.0; + obj2: number | string = 0.0; + obj3: boolean = false; + obj4: string = 'hello'; +} diff --git a/ets2panda/linter/test/main/derived_class_field_type_matching.ets.args.json b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..66fb88f85945924e8be0e83d90123507033f4c5d --- /dev/null +++ b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/main/derived_class_field_type_matching.ets.arkts2.json b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..e12acd531a0c002f49fca591ed20a024ce5aa4b2 --- /dev/null +++ b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 3, + "endLine": 29, + "endColumn": 7, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 3, + "endLine": 30, + "endColumn": 7, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 3, + "endLine": 31, + "endColumn": 7, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 7, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 7, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 21, + "endLine": 40, + "endColumn": 24, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 3, + "endLine": 49, + "endColumn": 6, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/derived_class_field_type_matching.ets.json b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..dd03fcf5442488620bcd4b3447f0fcdd89e1905b --- /dev/null +++ b/ets2panda/linter/test/main/derived_class_field_type_matching.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} diff --git a/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json b/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json index f70c84d16450b2b2796d25983c1283e4ec747e6b..c50bf91050e0382ae355068411b23712d4b41b2e 100644 --- a/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json +++ b/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json @@ -171,7 +171,7 @@ { "start": 1662, "end": 1685, - "replacementText": "{\n value: this.value,\n $value: value => {\n this.value = value;\n }\n }", + "replacementText": "{\n value: this.value,\n $value: (value: number) => {\n this.value = value;\n }\n }", "line": 92, "column": 21, "endLine": 92, @@ -192,7 +192,7 @@ { "start": 1700, "end": 1719, - "replacementText": "{\n str: this.str,\n $str: value => {\n this.str = value;\n }\n }", + "replacementText": "{\n str: this.str,\n $str: (value: string) => {\n this.str = value;\n }\n }", "line": 93, "column": 21, "endLine": 93, diff --git a/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.ets b/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.ets index e95837b57fdc91faee2a52c20e37f1b77d9e5215..c9fb83935c837c552a978de9287cfdb94c4125c8 100644 --- a/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.ets @@ -109,13 +109,13 @@ struct Index { }) Star({ value: this.value, - $value: value => { + $value: (value: number) => { this.value = value; } }) MyCard({ str: this.str, - $str: value => { + $str: (value: string) => { this.str = value; } }) diff --git a/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.json b/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.json index 83e5c37e26b39e420ea24ba454e6e000c204250d..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.json +++ b/ets2panda/linter/test/main/double_excla_binding_1.ets.migrate.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 118, - "column": 15, - "endLine": 118, - "endColumn": 20, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json index ab41a3326a9ceca4e10b9e62c529cdeed8ad5d21..e485c6f536c40e478abb267572b243df161f06ab 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json @@ -84,16 +84,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json index cce8e07d1c1fab1b091c6a4f074adfc7d2b94787..f78396b2f083af0430c14f88c0f8f4f105057b05 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json @@ -150,16 +150,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json index 9c5d050cc76a943c1a57c9ddbd6c9eca934470d4..b17d2989de701fb9fea8cc55fa8e3e51164796d1 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json @@ -24,16 +24,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/exponent.ets.autofix.json b/ets2panda/linter/test/main/exponent.ets.autofix.json index cc6218a973907d838d74561163aeb985f0df4a53..1ee1a7d8571b4f0c9e1569e949e06a586efdc593 100644 --- a/ets2panda/linter/test/main/exponent.ets.autofix.json +++ b/ets2panda/linter/test/main/exponent.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 609, - "end": 628, - "replacementText": "kk: number = Math.pow(6, 3)", + "start": 611, + "end": 611, + "replacementText": ": number", "line": 16, "column": 5, "endLine": 16, @@ -95,9 +95,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 652, - "end": 662, - "replacementText": "k: number = 5 ** 2", + "start": 653, + "end": 653, + "replacementText": ": number", "line": 19, "column": 5, "endLine": 19, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json index d1ca60d4ff31e83b6b4d74b04b596d8d7099ea38..b48bb237150aedc77faa44871a8e2591409b004b 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json @@ -244,6 +244,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 41, + "column": 46, + "endLine": 41, + "endColumn": 66, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 41, "column": 34, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json index c53b7da247fd5afc1070851dfb394632b7dedcc7..8c3c8bc2cfb158836b5555587aa1deb126927700 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json @@ -354,6 +354,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 41, + "column": 46, + "endLine": 41, + "endColumn": 66, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 41, "column": 34, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json index 0b10990af1e4f586fff32414b1e2111eb5fe7f15..452d9d6225f6f7e27b5814b2af5bde4081f692cc 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json @@ -144,6 +144,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 48, + "column": 54, + "endLine": 48, + "endColumn": 74, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 59, "column": 10, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets b/ets2panda/linter/test/main/func_inferred_type_args_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..cefc55fba0a8f50f3fee8ff86e62b29abee5a8bf --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 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 {A} from './func_inferred_type_args_ts'; +import B from './func_inferred_type_args_ts' +import A2 from './func_inferred_type_args_ts2' +import {A3} from './func_inferred_type_args_ts2' +import { HashMap } from '@kit.ArkTS'; +import { IMonitorValue, IMonitor, LocalStorage, AbstractProperty, SubscribedAbstractProperty, AppStorage} from './oh_modules/common_ts_ets_api'; + +function test() { + const a = new A(); + a.map = new Map(); //error +} +function test2() { + const a = new A2(); + a.map = new Map(); //error +} +function test3() { + const a = new A3(); + a.map = new Map(); //error +} + +class A4 { + id?: string; + map?: HashMap; +} +class Demo{} + +function test4() { + const a = new A4(); + a.map = new HashMap(); //error +} + +@ComponentV2 +struct Child { + @Param info: Info = new Info(); + @Monitor("info.message") + onMessageChange(monitor: IMonitor) { + let beforeValue: IMonitorValue = monitor.value(); + let beforeValue: IMonitorValue = monitor.value("info.message"); + console.info(`Child message change from ${monitor.value()?.before} to ${monitor.value('info.message')?.now}`); + } +} + +let para: Record = { 'PropA': 47 }; +let storage: LocalStorage = new LocalStorage(para); +let propA: number | undefined = storage.get('PropA'); +let link1: SubscribedAbstractProperty = storage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = storage.ref('PropA'); + +let propA: number | undefined = AppStorage.get('PropA'); +let link1: SubscribedAbstractProperty = AppStorage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = AppStorage.ref('PropA'); \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.args.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..30973c00a22aa0a072616f644b02c89a4a4dd4fa --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3d3a2b6001a02fdfee09fc0c09db5c1525e5a7f6 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json @@ -0,0 +1,258 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 11, + "endLine": 24, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 11, + "endLine": 32, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 15, + "endLine": 43, + "endColumn": 22, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 11, + "endLine": 43, + "endColumn": 24, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 27, + "endLine": 48, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 2, + "endLine": 46, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 4, + "endLine": 48, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Monitor\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a45c3a167352ec8374262312781c3717d6295c5b --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json @@ -0,0 +1,445 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 11, + "endLine": 24, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1033, + "end": 1033, + "replacementText": "", + "line": 24, + "column": 11, + "endLine": 24, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 11, + "endLine": 32, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1177, + "end": 1177, + "replacementText": "", + "line": 32, + "column": 11, + "endLine": 32, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 15, + "endLine": 43, + "endColumn": 22, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 11, + "endLine": 43, + "endColumn": 24, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1328, + "end": 1328, + "replacementText": "", + "line": 43, + "column": 11, + "endLine": 43, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 27, + "endLine": 48, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1529, + "end": 1529, + "replacementText": "", + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1591, + "end": 1591, + "replacementText": "", + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1668, + "end": 1668, + "replacementText": "", + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1698, + "end": 1698, + "replacementText": "", + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1776, + "end": 1778, + "replacementText": "47.0", + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1877, + "end": 1877, + "replacementText": "", + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1948, + "end": 1948, + "replacementText": "", + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2026, + "end": 2026, + "replacementText": "", + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2084, + "end": 2084, + "replacementText": "", + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2158, + "end": 2158, + "replacementText": "", + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2239, + "end": 2239, + "replacementText": "", + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 2, + "endLine": 46, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 4, + "endLine": 48, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Monitor\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..9b8ac8bc7dba0a8c8b78a0303ccffd0b78a19807 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..c98487895d216a7a1b4b1ead3a99988c0410d7a8 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 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 { + ComponentV2, + Param, + Monitor, +} from '@kit.ArkUI'; + +import {A} from './func_inferred_type_args_ts'; +import B from './func_inferred_type_args_ts' +import A2 from './func_inferred_type_args_ts2' +import {A3} from './func_inferred_type_args_ts2' +import { HashMap } from '@kit.ArkTS'; +import { IMonitorValue, IMonitor, LocalStorage, AbstractProperty, SubscribedAbstractProperty, AppStorage} from './oh_modules/common_ts_ets_api'; + +function test() { + const a = new A(); + a.map = new Map(); //error +} +function test2() { + const a = new A2(); + a.map = new Map(); //error +} +function test3() { + const a = new A3(); + a.map = new Map(); //error +} + +class A4 { + id?: string; + map?: HashMap; +} +class Demo{} + +function test4() { + const a = new A4(); + a.map = new HashMap(); //error +} + +@ComponentV2 +struct Child { + @Param info: Info = new Info(); + @Monitor("info.message") + onMessageChange(monitor: IMonitor) { + let beforeValue: IMonitorValue = monitor.value(); + let beforeValue: IMonitorValue = monitor.value("info.message"); + console.info(`Child message change from ${monitor.value()?.before} to ${monitor.value('info.message')?.now}`); + } +} + +let para: Record = { 'PropA': 47.0 }; +let storage: LocalStorage = new LocalStorage(para); +let propA: number | undefined = storage.get('PropA'); +let link1: SubscribedAbstractProperty = storage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = storage.ref('PropA'); + +let propA: number | undefined = AppStorage.get('PropA'); +let link1: SubscribedAbstractProperty = AppStorage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = AppStorage.ref('PropA'); \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..62f3ae72ba416c8d81e7056a12bd739734bbc4c4 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 20, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 15, + "endLine": 50, + "endColumn": 22, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 27, + "endLine": 55, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 9, + "endLine": 58, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 59, + "column": 9, + "endLine": 59, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 71, + "column": 5, + "endLine": 71, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_ts.ts b/ets2panda/linter/test/main/func_inferred_type_args_ts.ts new file mode 100644 index 0000000000000000000000000000000000000000..59435fad582f9b7fc7f17f56d2f5be3a6520997f --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_ts.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ +export class A { + id?: string; + map?: Map; +} + +export default class B {} +export class C {} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_ts.ts.json b/ets2panda/linter/test/main/func_inferred_type_args_ts.ts.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a8809e02ae14f7f14ed7adbd6d2d3f630fa3f6 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_ts.ts.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts b/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts new file mode 100644 index 0000000000000000000000000000000000000000..aedcb256cb4182f35f30974ac952de81423d1bfd --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 {C} from './func_inferred_type_args_ts' +import B from './func_inferred_type_args_ts' +export default class A2 { + id?: string; + map?: Map; +} +export class A3 { + id?: string; + map?: Map; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts.json b/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a8809e02ae14f7f14ed7adbd6d2d3f630fa3f6 --- /dev/null +++ b/ets2panda/linter/test/main/func_inferred_type_args_ts2.ts.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/ignore_files/user_created_collections.ets b/ets2panda/linter/test/main/ignore_files/user_created_collections.ets new file mode 100644 index 0000000000000000000000000000000000000000..f900dc1034ce5799ff90b47fcc74be9ab3301d19 --- /dev/null +++ b/ets2panda/linter/test/main/ignore_files/user_created_collections.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +export namespace collections { + export class Array implements ConcatArray { + constructor(); + } + + export class Map { + constructor(entries?: readonly (readonly [K, V])[] | null); + } + + export interface ConcatArray { + + } +} diff --git a/ets2panda/linter/test/main/incompatible_function.ets b/ets2panda/linter/test/main/incompatible_function.ets index e137fe5ecc7c1d95332b75831e1e407433c031df..db3f4250b777e4141bd55293a133e44c7096f477 100644 --- a/ets2panda/linter/test/main/incompatible_function.ets +++ b/ets2panda/linter/test/main/incompatible_function.ets @@ -79,4 +79,37 @@ type FuncTypeNoParams = () => void; let fNoParams: FuncTypeNoParams = () => { return 0; -}; \ No newline at end of file +}; + +class A {} + +class C extends Array {} + +class B { + private arr: Array = []; + + test(): C { + return this.arr; + } +} + +function sleep(time: number): Promise { + return new Promise((resolve) => setTimeout(resolve, time)); +} +sleep(100); + +const caseName = 'PromiseAnyTest0200'; +console.info(`${caseName} test start`); +const startTime = Date.now(); +const promises: Promise[] = []; +const totalPromises = 1000; +const delay = 100; +for (let i = 0; i < totalPromises; i++) { + promises.push( + new Promise((_, reject) => + setTimeout(() => { + reject(new Error(`Failure ${i}`)); + }, delay) + ) + ); +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json index da908095d3d48a520457fd8c8455423a513ff7ff..4b83d28887e4392eb5204fd7e6f59205effb9074 100644 --- a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json +++ b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json @@ -203,6 +203,126 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 92, + "column": 12, + "endLine": 92, + "endColumn": 20, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 12, + "endLine": 92, + "endColumn": 20, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 31, + "endLine": 97, + "endColumn": 38, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 7, + "endLine": 99, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 7, + "endLine": 105, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 23, + "endLine": 105, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 7, + "endLine": 106, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 15, + "endLine": 106, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 10, + "endLine": 107, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 14, + "endLine": 107, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 26, + "endLine": 109, + "endColumn": 35, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json index 26b266ff8c62d21c13f89816f7c6c37d3b0f7490..5362d5eaba8a5429488bcaec6e3f7478363d9b11 100644 --- a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json +++ b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json @@ -91,7 +91,7 @@ "endColumn": 13, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json index d5851681b3cbccba32d5112080bd44cc294ca6e8..77cf362c1527086e6780739896b50bcf4d9fb6dc 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json @@ -1374,16 +1374,6 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, - { - "line": 251, - "column": 11, - "endLine": 251, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 252, "column": 10, diff --git a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json index 6f5db8552032294b7974848e0d120ab14b44b82d..d80964b3403d86d70caba07f981713790f4387b4 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json @@ -1111,7 +1111,7 @@ { "start": 4720, "end": 4720, - "replacementText": "\nreturn undefined;\n", + "replacementText": "\n return undefined;\n", "line": 162, "column": 16, "endLine": 162, @@ -1151,7 +1151,7 @@ { "start": 4800, "end": 4800, - "replacementText": "\nreturn undefined;\n", + "replacementText": "\n return undefined;\n ", "line": 165, "column": 8, "endLine": 165, @@ -1289,9 +1289,9 @@ "endColumn": 42 }, { - "start": 5587, - "end": 5587, - "replacementText": "\nreturn undefined;\n", + "start": 5586, + "end": 5586, + "replacementText": "\n return undefined;", "line": 211, "column": 29, "endLine": 211, @@ -1530,9 +1530,9 @@ "endColumn": 44 }, { - "start": 5952, - "end": 5952, - "replacementText": "\nreturn undefined;\n", + "start": 5951, + "end": 5951, + "replacementText": "\n return undefined;", "line": 228, "column": 31, "endLine": 228, @@ -1652,9 +1652,9 @@ "endColumn": 35 }, { - "start": 6160, - "end": 6160, - "replacementText": "\nreturn undefined;\n", + "start": 6159, + "end": 6159, + "replacementText": "\n return undefined;", "line": 246, "column": 22, "endLine": 246, @@ -1692,9 +1692,9 @@ "endColumn": 48 }, { - "start": 6290, - "end": 6290, - "replacementText": "\nreturn undefined;\n", + "start": 6289, + "end": 6289, + "replacementText": "\n return undefined;", "line": 250, "column": 35, "endLine": 250, @@ -1715,16 +1715,6 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, - { - "line": 251, - "column": 11, - "endLine": 251, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 252, "column": 10, @@ -1762,9 +1752,9 @@ "endColumn": 35 }, { - "start": 6402, - "end": 6402, - "replacementText": "\nreturn undefined;\n", + "start": 6401, + "end": 6401, + "replacementText": "\n return undefined;", "line": 257, "column": 22, "endLine": 257, @@ -1962,9 +1952,9 @@ "endColumn": 35 }, { - "start": 6812, - "end": 6812, - "replacementText": "\nreturn undefined;\n", + "start": 6809, + "end": 6809, + "replacementText": "\n return undefined;", "line": 287, "column": 21, "endLine": 287, @@ -2086,7 +2076,7 @@ { "start": 6982, "end": 6982, - "replacementText": "\nreturn undefined;\n", + "replacementText": "\n return undefined;\n ", "line": 302, "column": 12, "endLine": 302, @@ -2264,9 +2254,9 @@ "endColumn": 42 }, { - "start": 7333, - "end": 7333, - "replacementText": "\nreturn undefined;\n", + "start": 7332, + "end": 7332, + "replacementText": "\n return undefined;", "line": 325, "column": 28, "endLine": 325, @@ -2388,7 +2378,7 @@ { "start": 7510, "end": 7510, - "replacementText": "\nreturn undefined;\n", + "replacementText": "\n return undefined;\n", "line": 340, "column": 28, "endLine": 340, diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets index b9a240dfe5be2337d97b90856d88d0f2edd8eac0..6b8f40649c5f86a834156b4bc0719f5b4cfd2dc5 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets @@ -164,13 +164,13 @@ class A { } function f3(): undefined | Promise { -return undefined; + return undefined; } // type `void` is not allowed in union type class B { m(): undefined | number { -return undefined; -} // type `void` is not allowed in union type + return undefined; + } // type `void` is not allowed in union type } type ss = void; @@ -220,8 +220,7 @@ function foocfe(a: number): string | undefined { if (a >= 0.0) { return "a >= 0"; } - -return undefined; + return undefined; } function foocfe2(a: number): string | undefined { @@ -243,8 +242,7 @@ function greet(hour: number): string | undefined { } else { return undefined; } - -return undefined; + return undefined; } function logOrReturn(flag: boolean): string | undefined { @@ -257,8 +255,7 @@ function logOrReturn(flag: boolean): string | undefined { function justLogs(): string | undefined { console.log("Hello!"); - -return undefined; + return undefined; } function getStatus(code: number): string | undefined { @@ -266,8 +263,7 @@ function getStatus(code: number): string | undefined { case 1: return "OK"; case 2: return "Warning"; } - -return undefined; + return undefined; } function tryThing(): string | undefined { @@ -276,8 +272,7 @@ function tryThing(): string | undefined { } catch (e) { console.error(e); } - -return undefined; + return undefined; } class A1 { @@ -307,9 +302,8 @@ class A1 { // will return return undefined; } - -return undefined; -} + return undefined; + } test3(a: number): undefined | boolean { if (a > 0.0) { @@ -322,8 +316,8 @@ return undefined; test4(): undefined | boolean { // will return -return undefined; -} + return undefined; + } } function test(a: number): boolean | undefined { @@ -349,8 +343,7 @@ function test2(a: number): undefined | boolean { // will return return undefined; } - -return undefined; + return undefined; } function test3(a: number): undefined | boolean { @@ -364,7 +357,7 @@ function test3(a: number): undefined | boolean { function test4(a: number): undefined | boolean { // will return -return undefined; + return undefined; } let unionVoid = (()=>{ diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json index 0ab5549e55155123c47cafcb9a8f2cafddd7243a..45016261114b25295b9fbc45da97c51d76361c93 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json @@ -995,9 +995,9 @@ "severity": "ERROR" }, { - "line": 234, + "line": 233, "column": 5, - "endLine": 234, + "endLine": 233, "endColumn": 7, "problem": "DeclWithDuplicateName", "suggest": "", @@ -1005,9 +1005,9 @@ "severity": "ERROR" }, { - "line": 234, + "line": 233, "column": 9, - "endLine": 234, + "endLine": 233, "endColumn": 13, "problem": "LimitedVoidType", "suggest": "", @@ -1015,9 +1015,9 @@ "severity": "ERROR" }, { - "line": 234, + "line": 233, "column": 16, - "endLine": 234, + "endLine": 233, "endColumn": 21, "problem": "LimitedVoidType", "suggest": "", @@ -1025,9 +1025,9 @@ "severity": "ERROR" }, { - "line": 235, + "line": 234, "column": 8, - "endLine": 235, + "endLine": 234, "endColumn": 21, "problem": "LimitedVoidType", "suggest": "", @@ -1035,9 +1035,9 @@ "severity": "ERROR" }, { - "line": 235, + "line": 234, "column": 8, - "endLine": 235, + "endLine": 234, "endColumn": 12, "problem": "LimitedVoidType", "suggest": "", @@ -1045,9 +1045,9 @@ "severity": "ERROR" }, { - "line": 235, + "line": 234, "column": 24, - "endLine": 235, + "endLine": 234, "endColumn": 29, "problem": "LimitedVoidType", "suggest": "", @@ -1055,9 +1055,9 @@ "severity": "ERROR" }, { - "line": 236, + "line": 235, "column": 9, - "endLine": 236, + "endLine": 235, "endColumn": 22, "problem": "LimitedVoidType", "suggest": "", @@ -1065,9 +1065,9 @@ "severity": "ERROR" }, { - "line": 236, + "line": 235, "column": 9, - "endLine": 236, + "endLine": 235, "endColumn": 13, "problem": "LimitedVoidType", "suggest": "", @@ -1075,19 +1075,9 @@ "severity": "ERROR" }, { - "line": 265, - "column": 11, - "endLine": 265, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 266, + "line": 263, "column": 10, - "endLine": 266, + "endLine": 263, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1095,9 +1085,9 @@ "severity": "ERROR" }, { - "line": 267, + "line": 264, "column": 10, - "endLine": 267, + "endLine": 264, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1105,9 +1095,9 @@ "severity": "ERROR" }, { - "line": 285, + "line": 280, "column": 8, - "endLine": 285, + "endLine": 280, "endColumn": 22, "problem": "LimitedVoidType", "suggest": "", @@ -1115,9 +1105,9 @@ "severity": "ERROR" }, { - "line": 285, + "line": 280, "column": 18, - "endLine": 285, + "endLine": 280, "endColumn": 22, "problem": "LimitedVoidType", "suggest": "", @@ -1125,9 +1115,9 @@ "severity": "ERROR" }, { - "line": 372, + "line": 365, "column": 9, - "endLine": 372, + "endLine": 365, "endColumn": 13, "problem": "LimitedVoidType", "suggest": "", @@ -1135,9 +1125,9 @@ "severity": "ERROR" }, { - "line": 379, + "line": 372, "column": 35, - "endLine": 379, + "endLine": 372, "endColumn": 39, "problem": "LimitedVoidType", "suggest": "", @@ -1145,9 +1135,9 @@ "severity": "ERROR" }, { - "line": 380, + "line": 373, "column": 36, - "endLine": 380, + "endLine": 373, "endColumn": 40, "problem": "LimitedVoidType", "suggest": "", @@ -1155,9 +1145,9 @@ "severity": "ERROR" }, { - "line": 381, + "line": 374, "column": 36, - "endLine": 381, + "endLine": 374, "endColumn": 40, "problem": "LimitedVoidType", "suggest": "", @@ -1165,9 +1155,9 @@ "severity": "ERROR" }, { - "line": 384, + "line": 377, "column": 23, - "endLine": 384, + "endLine": 377, "endColumn": 27, "problem": "LimitedVoidType", "suggest": "", @@ -1175,9 +1165,9 @@ "severity": "ERROR" }, { - "line": 387, + "line": 380, "column": 39, - "endLine": 387, + "endLine": 380, "endColumn": 43, "problem": "LimitedVoidType", "suggest": "", @@ -1185,9 +1175,9 @@ "severity": "ERROR" }, { - "line": 388, + "line": 381, "column": 50, - "endLine": 388, + "endLine": 381, "endColumn": 54, "problem": "LimitedVoidType", "suggest": "", @@ -1195,9 +1185,9 @@ "severity": "ERROR" }, { - "line": 389, + "line": 382, "column": 38, - "endLine": 389, + "endLine": 382, "endColumn": 42, "problem": "LimitedVoidType", "suggest": "", @@ -1205,9 +1195,9 @@ "severity": "ERROR" }, { - "line": 389, + "line": 382, "column": 23, - "endLine": 389, + "endLine": 382, "endColumn": 34, "problem": "LimitedVoidType", "suggest": "", @@ -1215,9 +1205,9 @@ "severity": "ERROR" }, { - "line": 390, + "line": 383, "column": 29, - "endLine": 390, + "endLine": 383, "endColumn": 33, "problem": "LimitedVoidType", "suggest": "", @@ -1225,9 +1215,9 @@ "severity": "ERROR" }, { - "line": 391, + "line": 384, "column": 28, - "endLine": 391, + "endLine": 384, "endColumn": 32, "problem": "LimitedVoidType", "suggest": "", diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets b/ets2panda/linter/test/main/literals_as_prop_names.ets index 114339394cb2a8634ac97a7594c104b8c7bd5920..0f2781e90b8c704334aef16842824a9d1ebd75ac 100755 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets @@ -147,4 +147,19 @@ let compPropObj = { ['CompProp']: 1, // Error in arkts 2.0 [2]: 'CompProp2', // Error in arkts 2.0 [LiteralAsPropertyNameEnum.One]: 3 // Error in arkts 2.0 -}; \ No newline at end of file +}; + +enum TEST { + A, + B, + C, +} +enum TEST2 { + A, + B, + C, +} + +let de3 = TEST2[TEST.A] //error +let de4 = TEST2[TEST.A| TEST.B] //error +let de5 = TEST[TEST.C] //ok \ No newline at end of file diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json index 5062fc598a9ff3a3afff09acf1a3400e9ded0fba..25a3ca26f62f9baab6dbf8cc743387bf9b008a95 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json @@ -554,6 +554,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 15, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 135, "column": 37, @@ -724,6 +734,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 163, + "column": 11, + "endLine": 163, + "endColumn": 24, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 11, + "endLine": 164, + "endColumn": 32, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 115, "column": 2, @@ -785,4 +815,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json index b16fee9cc94db1f161805763cff2f05a6b4230ce..127be23a53799c26b92a3aa385e0036f4dc58ded 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json @@ -761,9 +761,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2119, - "end": 2145, - "replacementText": "case17: number = Direction17[\"\\\\\"]", + "start": 2125, + "end": 2125, + "replacementText": ": number", "line": 105, "column": 5, "endLine": 105, @@ -792,9 +792,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2150, - "end": 2180, - "replacementText": "case172: number = Direction17[\"__x5c\"]", + "start": 2157, + "end": 2157, + "replacementText": ": number", "line": 106, "column": 5, "endLine": 106, @@ -990,6 +990,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 15, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 135, "column": 37, @@ -1248,6 +1258,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 163, + "column": 11, + "endLine": 163, + "endColumn": 24, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 11, + "endLine": 164, + "endColumn": 32, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 115, "column": 2, @@ -1331,4 +1361,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets index 735fe00359fdf4bf0ed72a5a748981a08e40dd9f..0cbab448d613ab68550f99805762eeb01ddcea13 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets @@ -156,4 +156,19 @@ let compPropObj = { ['CompProp']: 1.0, // Error in arkts 2.0 [2.0]: 'CompProp2', // Error in arkts 2.0 [LiteralAsPropertyNameEnum.One]: 3.0 // Error in arkts 2.0 -}; \ No newline at end of file +}; + +enum TEST { + A, + B, + C, +} +enum TEST2 { + A, + B, + C, +} + +let de3 = TEST2[TEST.A] //error +let de4 = TEST2[TEST.A| TEST.B] //error +let de5 = TEST[TEST.C] //ok \ No newline at end of file diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json index 61d1781a5e9357addae257c8db0e40eaf586cf17..3b5d627860fa5ce150f836bb8f54f8e8cd5e0c38 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json @@ -224,6 +224,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 145, + "column": 3, + "endLine": 145, + "endColumn": 17, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 144, "column": 37, @@ -314,6 +324,26 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 172, + "column": 11, + "endLine": 172, + "endColumn": 24, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 173, + "column": 11, + "endLine": 173, + "endColumn": 32, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 31, "column": 11, @@ -365,4 +395,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json index 30c37afc53dcc2542c42356017353b794acf9e2b..bfb88a65c82c067497faa74d062e2d596c7c90dc 100755 --- a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json @@ -95,50 +95,40 @@ "severity": "ERROR" }, { - "line": 66, - "column": 10, - "endLine": 66, - "endColumn": 16, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, - { - "line": 69, - "column": 3, - "endLine": 69, - "endColumn": 7, + "line": 98, + "column": 17, + "endLine": 98, + "endColumn": 22, "problem": "MethodInheritRule", "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, { - "line": 72, - "column": 11, - "endLine": 72, - "endColumn": 21, + "line": 103, + "column": 18, + "endLine": 103, + "endColumn": 19, "problem": "MethodInheritRule", "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, { - "line": 98, + "line": 108, "column": 17, - "endLine": 98, - "endColumn": 22, + "endLine": 108, + "endColumn": 29, "problem": "MethodInheritRule", "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, { - "line": 108, - "column": 17, - "endLine": 108, - "endColumn": 29, + "line": 112, + "column": 18, + "endLine": 112, + "endColumn": 19, "problem": "MethodInheritRule", "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", diff --git a/ets2panda/linter/test/main/method_inheritance3.ets b/ets2panda/linter/test/main/method_inheritance3.ets new file mode 100755 index 0000000000000000000000000000000000000000..d31da9911bdba10fc816d7677500f8a4feae3ff1 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 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. + */ + +class A{ + getData(a:T):T{ + return a; + } +} + +class B extends A{ + getData(a: number): number { // no error + return 123; + } +} + +enum E{ + E1, + E2 +} + +interface I { + fun(e:E):void +} + +class C implements I { + fun(e:E):void{ // no error + + } +} + +Class UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void; + onWindowStageCreate(windowStage: window.WindowStage): void; +} + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { // no error + + } + + onWindowStageCreate(windowStage: window.WindowStage): void { // no error + try { + windowStage.loadContent('pages/Index', (err: BusinessError | null): void => { + if (err && err.code) { + return; + } + }); + } catch (e) { + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.args.json b/ets2panda/linter/test/main/method_inheritance3.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..d8d3390ad9befeca9b595017d9eea0f5ada3d049 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..1dfcce5603792b0fa38a6e3c592a373b2d6103ac --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 24, + "column": 12, + "endLine": 24, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 67, + "endLine": 44, + "endColumn": 71, + "problem": "VoidOperator", + "suggest": "", + "rule": "\"void\" operator is not supported (arkts-no-void-operator)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 57, + "endLine": 45, + "endColumn": 61, + "problem": "VoidOperator", + "suggest": "", + "rule": "\"void\" operator is not supported (arkts-no-void-operator)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 18, + "endLine": 44, + "endColumn": 22, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Want\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 18, + "endLine": 49, + "endColumn": 22, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Want\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 52, + "endLine": 55, + "endColumn": 65, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BusinessError\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.json b/ets2panda/linter/test/main/method_inheritance3.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets b/ets2panda/linter/test/main/no_function_return_this.ets new file mode 100644 index 0000000000000000000000000000000000000000..7642726e36ed3c8882ea0df6b8853513bde21077 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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. + */ + +let t1 = Function('return this')(); // error + +let t2 = Function("return this")(); // error + +let t3 = Function(`return this`)(); // error + +let t4 = new Function('return this')(); // error + +let fn = Function('return this'); // error +let t5 = fn(); + +let t6 = (Function)('return this')(); // error + +let t7 = (globalThis.Function)('return this')(); // error + +let t8 = (0, Function)('return this')(); // error + +let t9 = (Function.bind(null))('return this')(); // error + +const body = "return this"; +let t10 = Function(body)(); // error + +let a1 = Function('return 123')(); // legal + +let a2 = Function('return window')(); // legal + +let a3 = Function('x', 'return this')(); // legal + +const a4 = Function; // legal + +let a5 = Function("return somethingElse")(); // legal + +let a7 = SomeOtherConstructor('return this'); // legal \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.args.json b/ets2panda/linter/test/main/no_function_return_this.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.json b/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3a1dcaed0a0807d9f70a8a76e2209221a3604e56 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.json @@ -0,0 +1,478 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 39, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 10, + "endLine": 22, + "endColumn": 37, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 10, + "endLine": 22, + "endColumn": 37, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 12, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 35, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 35, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 19, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 10, + "endLine": 29, + "endColumn": 46, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 10, + "endLine": 29, + "endColumn": 46, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 30, + "problem": "GlobalThisError", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 22, + "endLine": 29, + "endColumn": 30, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 38, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 38, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 22, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 14, + "endLine": 31, + "endColumn": 22, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 10, + "endLine": 33, + "endColumn": 46, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 20, + "endLine": 33, + "endColumn": 24, + "problem": "FunctionBindError", + "suggest": "", + "rule": "'Function.bind' is not supported (arkts-no-func-bind)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 27, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 25, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 25, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 10, + "endLine": 38, + "endColumn": 32, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 5, + "endLine": 40, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 10, + "endLine": 40, + "endColumn": 35, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 38, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 20, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 10, + "endLine": 46, + "endColumn": 42, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 45, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.json b/ets2panda/linter/test/main/no_function_return_this.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..44fc2a3c888b0d859694801338cdb7358a6be175 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.json @@ -0,0 +1,238 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 39, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 19, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 21, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "WARNING" + }, + { + "line": 29, + "column": 22, + "endLine": 29, + "endColumn": 30, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 22, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 14, + "endLine": 31, + "endColumn": 22, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 20, + "endLine": 33, + "endColumn": 30, + "problem": "FunctionBind", + "suggest": "", + "rule": "'Function.bind' is not supported (arkts-no-func-bind)", + "severity": "WARNING" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 27, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 5, + "endLine": 40, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 20, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 45, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets b/ets2panda/linter/test/main/no_import_concurrency.ets index 9eb3c99118766d1011341a40fe3f2976f2df5c9d..7602f347cf2980eb0993c3d4eae0a8435f9a3a77 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets @@ -25,7 +25,6 @@ import fooke from '@ohos.process'; import { process as ps, collections as clt } from '@kit.ArkTS'; import process from '@ohos.process'; import aaa from '@ohos.taskpool' -import aa from '@arkts.utils' import aaaa from '@arkts.collections'; aaa.getTaskPoolInfo() @@ -37,7 +36,6 @@ function concurrency () { ps.isIsolatedProcess(); tsk.cancel(); -aa.locks.AsyncLock aaaa.Set() clt.Set() fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json index d3aaa8c933a1854550d6ae1f5078a23c6f554af5..f23fdd92f6b74c9170ea2a05d90a0ac754077976 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json @@ -1,178 +1,168 @@ { - "copyright": [ - "Copyright (c) 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." - ], - "result": [ - { - "line": 17, - "column": 21, - "endLine": 17, - "endColumn": 36, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 8, - "endLine": 19, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 25, - "endLine": 20, - "endColumn": 42, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 15, - "endLine": 21, - "endColumn": 32, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 34, - "endLine": 21, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 16, - "endLine": 23, - "endColumn": 31, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 33, - "endLine": 23, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 8, - "endLine": 24, - "endColumn": 13, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 10, - "endLine": 25, - "endColumn": 23, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 25, - "endLine": 25, - "endColumn": 43, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 8, - "endLine": 26, - "endColumn": 15, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 8, - "endLine": 27, - "endColumn": 11, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 10, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 8, - "endLine": 29, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 34, - "column": 11, - "endLine": 34, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 34, - "column": 17, - "endLine": 34, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - } - ] -} \ No newline at end of file + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 17, + "column": 21, + "endLine": 17, + "endColumn": 36, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 25, + "endLine": 20, + "endColumn": 42, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 15, + "endLine": 21, + "endColumn": 32, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 34, + "endLine": 21, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 13, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 23, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 8, + "endLine": 26, + "endColumn": 15, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 11, + "endLine": 33, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 17, + "endLine": 33, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json index 6c5606e0185c023b67988ae8be32675471370e3b..ad3c6460fae5fbdd747cf9ee3331686dd3a363cc 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json @@ -136,8 +136,8 @@ "endColumn": 31 }, { - "start": 1397, - "end": 1400, + "start": 1367, + "end": 1370, "replacementText": "taskpool", "line": 23, "column": 16, @@ -208,8 +208,8 @@ "endColumn": 23 }, { - "start": 1373, - "end": 1375, + "start": 1343, + "end": 1345, "replacementText": "process", "line": 25, "column": 10, @@ -238,8 +238,8 @@ "endColumn": 43 }, { - "start": 1441, - "end": 1444, + "start": 1392, + "end": 1395, "replacementText": "collections", "line": 25, "column": 25, @@ -289,8 +289,8 @@ "endColumn": 11 }, { - "start": 1278, - "end": 1281, + "start": 1248, + "end": 1251, "replacementText": "taskpool", "line": 27, "column": 8, @@ -306,55 +306,25 @@ "line": 28, "column": 8, "endLine": 28, - "endColumn": 10, + "endColumn": 12, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { "start": 1208, - "end": 1237, + "end": 1246, "replacementText": "", "line": 28, "column": 8, "endLine": 28, - "endColumn": 10 - }, - { - "start": 1411, - "end": 1413, - "replacementText": "ArkTSUtils", - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 8, - "endLine": 29, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "autofix": [ - { - "start": 1238, - "end": 1276, - "replacementText": "", - "line": 29, - "column": 8, - "endLine": 29, "endColumn": 12 }, { - "start": 1430, - "end": 1434, + "start": 1381, + "end": 1385, "replacementText": "collections", - "line": 29, + "line": 28, "column": 8, - "endLine": 29, + "endLine": 28, "endColumn": 12 } ], @@ -363,19 +333,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 11, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 1337, - "end": 1346, - "replacementText": "aaa: number = 123", - "line": 34, + "start": 1310, + "end": 1310, + "replacementText": ": number", + "line": 33, "column": 11, - "endLine": 34, + "endLine": 33, "endColumn": 20 } ], @@ -384,19 +354,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 17, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 1343, - "end": 1346, + "start": 1313, + "end": 1316, "replacementText": "123.0", - "line": 34, + "line": 33, "column": 17, - "endLine": 34, + "endLine": 33, "endColumn": 20 } ], diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets index ec7742adfb5b2ee082fb7a749ce18649f122ccb5..f159439aa475095e71d5c957d527210d4f87a1a8 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets @@ -27,7 +27,6 @@ import bbbb from '@kit.ArkTS'; - taskpool.getTaskPoolInfo() function concurrency () { @@ -37,7 +36,6 @@ function concurrency () { process.isIsolatedProcess(); taskpool.cancel(); -ArkTSUtils.locks.AsyncLock -collections.Set() -collections.Set() +Set() +Set() fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json index ca88f857e960b437dcf767c0ac40be998c8f1236..75faa009317be813e325733eb9cce302f88bbc8c 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json @@ -13,5 +13,26 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] -} \ No newline at end of file + "result": [ + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 6, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 1, + "endLine": 40, + "endColumn": 6, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/no_side_effect_import.ets.args.json b/ets2panda/linter/test/main/no_side_effect_import.ets.args.json index 4d93062f69db6d74420adeb506e0ca28c5580728..a89d885810708ad03d96e3e14bb6590efd1a7547 100755 --- a/ets2panda/linter/test/main/no_side_effect_import.ets.args.json +++ b/ets2panda/linter/test/main/no_side_effect_import.ets.args.json @@ -14,6 +14,8 @@ "limitations under the License." ], "mode": { - "arkts2": "" + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" } } diff --git a/ets2panda/linter/test/main/no_side_effect_import.ets.autofix.json b/ets2panda/linter/test/main/no_side_effect_import.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..4723887320a710cda4191b750032bd80aae8e28a --- /dev/null +++ b/ets2panda/linter/test/main/no_side_effect_import.ets.autofix.json @@ -0,0 +1,110 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 19, + "problem": "NoSideEffectImport", + "autofix": [ + { + "start": 610, + "end": 628, + "replacementText": "initModule(\"./logger\");", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Import for side-effect only is prohibited.(arkts-no-side-effect-import)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 23, + "problem": "NoSideEffectImport", + "autofix": [ + { + "start": 669, + "end": 691, + "replacementText": "initModule(\"./utils/init\");", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Import for side-effect only is prohibited.(arkts-no-side-effect-import)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 23, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 45, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 31, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 34, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 40, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.ets b/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..a70297d4caea562168c338d773124639dca8b6ce --- /dev/null +++ b/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024-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. + */ + +initModule("./logger"); +console.log("Main program running..."); +initModule("./utils/init"); + +import { cookBookTag } from './CookBookMsg'; +import Logger from './logger'; +import * as Utils from './utils'; + +import { initApp } from './utils/init'; + + diff --git a/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.json b/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..e6817505079c74e6aa9b918b489be9036ce13b40 --- /dev/null +++ b/ets2panda/linter/test/main/no_side_effect_import.ets.migrate.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 45, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 31, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 34, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 40, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_sparse_array.ets b/ets2panda/linter/test/main/no_sparse_array.ets index e8e2ef3ba47da4e68b73e64a5cfa64ef66b9bee8..39116898dffd135353fa87d9dff42e8d81483934 100644 --- a/ets2panda/linter/test/main/no_sparse_array.ets +++ b/ets2panda/linter/test/main/no_sparse_array.ets @@ -77,3 +77,25 @@ function foo5(a: T[]) { return; } foo5([]); + +let set1 = new WeakSet(); +set1.has(['1']); +set1.add(['1']); +set1.delete(['1']); + +let map1 = new WeakMap(); +map1.has(['1']); +map1.set(['1'], ""); +map1.delete(['1']); +map1.get(['1']); + +let set2 = new Set(); +set2.has(['1']); +set2.add(['1']); +set2.delete(['1']); + +let map2 = new Map(); +map2.has(['1']); +map2.set(['1'], ""); +map2.delete(['1']); +map2.get(['1']); \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_sparse_array2.ets b/ets2panda/linter/test/main/no_sparse_array2.ets index 5e923a25cb15945e32119bd08f3627e434b699d8..1bc89431c2f8e74bb400e24b5fd3ffed829d8f86 100644 --- a/ets2panda/linter/test/main/no_sparse_array2.ets +++ b/ets2panda/linter/test/main/no_sparse_array2.ets @@ -48,3 +48,25 @@ let str1 = new String([]); let bool1 = new Boolean([]); let num1 = new Number([]); let obj1 = new Object([]); + +let set1 = new WeakSet(); +set1.has([]); +set1.add([]); +set1.delete([]); + +let map1 = new WeakMap(); +map1.has([]); +map1.set([], ""); +map1.delete([]); +map1.get([]); + +let set2 = new Set(); +set2.has([]); +set2.add([]); +set2.delete([]); + +let map2 = new Map(); +map2.has([]); +map2.set([], ""); +map2.delete([]); +map2.get([]); \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json b/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json index c9499abe6ca782a912246eebf95edcc4071dccf6..b7f01e7ef6481d1fbd05412c9c5d2d2f865a3b46 100644 --- a/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json @@ -343,6 +343,146 @@ "suggest": "", "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", "severity": "ERROR" + }, + { + "line": 53, + "column": 10, + "endLine": 53, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 10, + "endLine": 54, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 13, + "endLine": 55, + "endColumn": 15, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 10, + "endLine": 58, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 10, + "endLine": 59, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 13, + "endLine": 60, + "endColumn": 15, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 10, + "endLine": 61, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 10, + "endLine": 64, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 10, + "endLine": 65, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 13, + "endLine": 66, + "endColumn": 15, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 10, + "endLine": 69, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 10, + "endLine": 70, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 13, + "endLine": 71, + "endColumn": 15, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 10, + "endLine": 72, + "endColumn": 12, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets b/ets2panda/linter/test/main/no_ts_like_smart_type.ets index 3bcd3fae8c67fb66bf6ee7ca66ed64c5f80504e8..7cdff3d524a3211820c8e0ecad1fe4f5692292f3 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets @@ -162,3 +162,35 @@ class AA { } } } + + +function sleep(ms: number): PromiseLike { + return new Promise( + (resolve: (value: T | PromiseLike) => void): number => setTimeout(resolve, ms) + ); +} + +type TypeA = (key: string) => string | undefined + +class ClassA { + static sA?: TypeA = undefined + + static funA(key: string): string | undefined { + if (ClassA.sA) { + return ClassA.sA(key) //error + } + else { + return undefined; + } + } +} + +class A { + b?: boolean + + isRelease(): boolean { + if (this.b != undefined) { + return this.b //error + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json index 7ee5337c99b6d395132c25433356e9b5bb3c1ef0..b46fb92edd1fdc5c1e122aaea725287007ad7e22 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json @@ -334,6 +334,46 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 169, + "column": 6, + "endLine": 169, + "endColumn": 47, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, + { + "line": 168, + "column": 10, + "endLine": 170, + "endColumn": 4, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 180, + "column": 13, + "endLine": 180, + "endColumn": 34, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 13, + "endLine": 193, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, { "line": 137, "column": 5, @@ -363,6 +403,16 @@ "suggest": "'b.a' is possibly 'undefined'.", "rule": "'b.a' is possibly 'undefined'.", "severity": "ERROR" + }, + { + "line": 191, + "column": 18, + "endLine": 191, + "endColumn": 25, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json index fd7351eff41090b5a7ad6ffde13531123acab287..0eff9f6a2478414fa918796ff6e19f694e43d858 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json @@ -53,6 +53,16 @@ "suggest": "'b.a' is possibly 'undefined'.", "rule": "'b.a' is possibly 'undefined'.", "severity": "ERROR" + }, + { + "line": 191, + "column": 18, + "endLine": 191, + "endColumn": 25, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets b/ets2panda/linter/test/main/numeric_semantics.ets index c04cf3209c05fe00a5065dbb5cdd6a7fee6e1f82..9cc9bf26f5c12e31bc14edba1078c2da493d057f 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets @@ -104,9 +104,9 @@ identity(42); let an_array = [1,2,3] -let g = an_array[] +let g2 = an_array[] -const a = 1 +const a2 = 1 enum Test { A = 1, // 显式赋值为 1 @@ -142,7 +142,8 @@ export class G{ const fingerprintPositionY = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0; -private doCloseFolderBackgroundAnimation(): void { +class Layout { + private doCloseFolderBackgroundAnimation(): void { openFolderLayout.getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight; openFolderLayout.getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth; @@ -161,9 +162,10 @@ private doCloseFolderBackgroundAnimation(): void { openFolderLayout.getGridSwiperLayout().bgTranslateY = pos[1] + editModeTranslateY - openFolderLayout.getBackgroundLayout().closedHeight * 0.5 - openFolderLayout.getBackgroundLayout().openedMargin; } + } } -let f = 0.0; +let f2 = 0.0; let b5: number = 0; f = b5; // OK @@ -182,9 +184,9 @@ e = e | 3; // OK let arr1 = [1,2,3] e += arr1[0]; // OK -let a = 0.0; -a = fun1(); -a = fun2()!; +let a3 = 0.0; +a3 = fun1(); +a3 = fun2()!; function fun1():number{ return 1; @@ -196,17 +198,17 @@ function fun2():number|undefined{ import { ArrayList } from "@kit.ArkTS"; -let arr = new ArrayList() +let arr2 = new ArrayList() for (let i:number = 0; i < 100; i++) { - arr.add(i) + arr2.add(i) } -let cancelIds:ArrayList = arr.subArrayList(6, 86) -let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) +let cancelIds:ArrayList = arr2.subArrayList(6, 86) +let arr3: Array = Array.from(cancelIds) +let arr4: Array = Array.from(new ArrayList()) -let a:number = 0.000; +let a4: number = 0.000; -const b:number = 0.000; +const b4: number = 0.000; export enum WalletStageValue { DEFAULT = 0, @@ -229,3 +231,16 @@ export enum AnimationStage { class C { public static readonly SIX_MONTH = 180 * 24 * 60 * 60 * 1000 } + +function testIndentation(): void { + let a = (() => { + console.log('hello'); + return 0; + })(); +} + +@Sendable +export function add(a: number, b: number) { + console.log("SharedModule: Hap call ShareFile add"); + return a + b; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json index d7bc71bee6c0d885b12ab73d0771f0f30c34dced..35164935cf2df9b2676aa6a0056880d98c390fb6 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -374,6 +374,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 92, + "column": 19, + "endLine": 92, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 26, + "endLine": 92, + "endColumn": 31, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -468,7 +488,7 @@ "line": 107, "column": 5, "endLine": 107, - "endColumn": 19, + "endColumn": 20, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -476,9 +496,9 @@ }, { "line": 107, - "column": 18, + "column": 19, "endLine": 107, - "endColumn": 18, + "endColumn": 19, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -488,7 +508,7 @@ "line": 109, "column": 7, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -496,9 +516,9 @@ }, { "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -705,109 +725,19 @@ "severity": "ERROR" }, { - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49, - "problem": "VoidOperator", - "suggest": "", - "rule": "\"void\" operator is not supported (arkts-no-void-operator)", - "severity": "ERROR" - }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23, - "problem": "ObjectLiteralProperty", + "problem": "NumericSemantics", "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 12, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -815,49 +745,29 @@ "severity": "ERROR" }, { - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -865,9 +775,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101, "problem": "NumericSemantics", "suggest": "", @@ -875,9 +785,19 @@ "severity": "ERROR" }, { - "line": 160, + "line": 161, + "column": 61, + "endLine": 161, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85, "problem": "NumericSemantics", "suggest": "", @@ -885,19 +805,29 @@ "severity": "ERROR" }, { - "line": 166, + "line": 162, + "column": 61, + "endLine": 162, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12, + "endLine": 168, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -905,9 +835,9 @@ "severity": "ERROR" }, { - "line": 170, + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -915,9 +845,9 @@ "severity": "ERROR" }, { - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -925,9 +855,9 @@ "severity": "ERROR" }, { - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -935,9 +865,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -945,9 +875,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -955,9 +885,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -965,9 +895,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16, "problem": "NumericSemantics", "suggest": "", @@ -975,9 +905,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -985,9 +915,9 @@ "severity": "ERROR" }, { - "line": 183, + "line": 185, "column": 6, - "endLine": 183, + "endLine": 185, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -995,19 +925,19 @@ "severity": "ERROR" }, { - "line": 185, + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12, + "endLine": 187, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1015,9 +945,9 @@ "severity": "ERROR" }, { - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1025,9 +955,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -1035,29 +965,29 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 199, - "column": 15, - "endLine": 199, - "endColumn": 24, + "line": 201, + "column": 16, + "endLine": 201, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -1065,9 +995,9 @@ "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31, "problem": "NumericSemantics", "suggest": "", @@ -1075,29 +1005,29 @@ "severity": "ERROR" }, { - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53, + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57, + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 205, + "line": 207, "column": 42, - "endLine": 205, + "endLine": 207, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -1105,9 +1035,9 @@ "severity": "ERROR" }, { - "line": 212, + "line": 214, "column": 13, - "endLine": 212, + "endLine": 214, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -1115,9 +1045,9 @@ "severity": "ERROR" }, { - "line": 213, + "line": 215, "column": 17, - "endLine": 213, + "endLine": 215, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1125,9 +1055,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 17, - "endLine": 214, + "endLine": 216, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1135,9 +1065,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 17, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1145,9 +1075,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 218, "column": 19, - "endLine": 216, + "endLine": 218, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -1155,9 +1085,9 @@ "severity": "ERROR" }, { - "line": 217, + "line": 219, "column": 18, - "endLine": 217, + "endLine": 219, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -1165,9 +1095,9 @@ "severity": "ERROR" }, { - "line": 218, + "line": 220, "column": 20, - "endLine": 218, + "endLine": 220, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -1175,9 +1105,9 @@ "severity": "ERROR" }, { - "line": 222, + "line": 224, "column": 10, - "endLine": 222, + "endLine": 224, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1185,9 +1115,9 @@ "severity": "ERROR" }, { - "line": 223, + "line": 225, "column": 11, - "endLine": 223, + "endLine": 225, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -1195,9 +1125,9 @@ "severity": "ERROR" }, { - "line": 224, + "line": 226, "column": 14, - "endLine": 224, + "endLine": 226, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -1205,9 +1135,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 227, "column": 16, - "endLine": 225, + "endLine": 227, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -1215,9 +1145,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 14, - "endLine": 226, + "endLine": 228, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -1225,9 +1155,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", @@ -1235,9 +1165,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41, "problem": "NumericSemantics", "suggest": "", @@ -1245,9 +1175,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46, "problem": "NumericSemantics", "suggest": "", @@ -1255,9 +1185,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51, "problem": "NumericSemantics", "suggest": "", @@ -1265,9 +1195,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56, "problem": "NumericSemantics", "suggest": "", @@ -1275,15 +1205,55 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -1345,9 +1315,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 46, - "endLine": 153, + "endLine": 154, "endColumn": 56, "problem": "UIInterfaceImport", "suggest": "", @@ -1355,9 +1325,9 @@ "severity": "ERROR" }, { - "line": 154, + "line": 155, "column": 33, - "endLine": 154, + "endLine": 155, "endColumn": 43, "problem": "UIInterfaceImport", "suggest": "", @@ -1365,9 +1335,9 @@ "severity": "ERROR" }, { - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44, "problem": "UIInterfaceImport", "suggest": "", @@ -1375,4 +1345,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index 72ddcbaa863effb8817cf4602190402e159164a8..99e139c5e9372ec72c4c887a1b7b5adacc4eb835 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 744, - "end": 749, - "replacementText": "a: number = 1", + "start": 745, + "end": 745, + "replacementText": ": number", "line": 18, "column": 5, "endLine": 18, @@ -190,9 +190,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1377, - "end": 1384, - "replacementText": "c: number = 1.5", + "start": 1378, + "end": 1378, + "replacementText": ": number", "line": 39, "column": 5, "endLine": 39, @@ -211,9 +211,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1561, - "end": 1566, - "replacementText": "d: number = 2", + "start": 1562, + "end": 1562, + "replacementText": ": number", "line": 45, "column": 5, "endLine": 45, @@ -253,9 +253,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1712, - "end": 1717, - "replacementText": "n: number = 2", + "start": 1713, + "end": 1713, + "replacementText": ": number", "line": 51, "column": 5, "endLine": 51, @@ -316,9 +316,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1747, - "end": 1760, - "replacementText": "g: number[] = [1, 2, 3]", + "start": 1748, + "end": 1748, + "replacementText": ": number[]", "line": 55, "column": 5, "endLine": 55, @@ -410,9 +410,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1786, - "end": 1799, - "replacementText": "t8: number = Infinity", + "start": 1788, + "end": 1788, + "replacementText": ": number", "line": 59, "column": 5, "endLine": 59, @@ -431,9 +431,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1807, - "end": 1821, - "replacementText": "t9: number = -Infinity", + "start": 1809, + "end": 1809, + "replacementText": ": number", "line": 61, "column": 5, "endLine": 61, @@ -452,9 +452,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1830, - "end": 1839, - "replacementText": "t10: number = NaN", + "start": 1833, + "end": 1833, + "replacementText": ": number", "line": 63, "column": 5, "endLine": 63, @@ -473,9 +473,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1848, - "end": 1870, - "replacementText": "t11: number = Number.MAX_VALUE", + "start": 1851, + "end": 1851, + "replacementText": ": number", "line": 65, "column": 5, "endLine": 65, @@ -494,9 +494,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1879, - "end": 1901, - "replacementText": "t12: number = Number.MIN_VALUE", + "start": 1882, + "end": 1882, + "replacementText": ": number", "line": 67, "column": 5, "endLine": 67, @@ -557,9 +557,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1959, - "end": 1965, - "replacementText": "o2: number = o", + "start": 1961, + "end": 1961, + "replacementText": ": number", "line": 73, "column": 5, "endLine": 73, @@ -578,9 +578,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1975, - "end": 1982, - "replacementText": "o3: number = oo", + "start": 1977, + "end": 1977, + "replacementText": ": number", "line": 75, "column": 5, "endLine": 75, @@ -599,9 +599,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2001, - "end": 2007, - "replacementText": "a: number = 1;", + "start": 2002, + "end": 2002, + "replacementText": ": number", "line": 78, "column": 4, "endLine": 78, @@ -641,9 +641,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2043, - "end": 2052, - "replacementText": "t2: number = +123", + "start": 2045, + "end": 2045, + "replacementText": ": number", "line": 83, "column": 5, "endLine": 83, @@ -683,9 +683,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2061, - "end": 2070, - "replacementText": "t3: number = -234", + "start": 2063, + "end": 2063, + "replacementText": ": number", "line": 85, "column": 5, "endLine": 85, @@ -725,9 +725,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2079, - "end": 2100, - "replacementText": "num: number = Math.floor(4.8)", + "start": 2082, + "end": 2082, + "replacementText": ": number", "line": 87, "column": 5, "endLine": 87, @@ -746,9 +746,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2124, - "end": 2146, - "replacementText": "value: number = parseInt(\"42\")", + "start": 2129, + "end": 2129, + "replacementText": ": number", "line": 89, "column": 5, "endLine": 89, @@ -759,6 +759,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 92, + "column": 19, + "endLine": 92, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 26, + "endLine": 92, + "endColumn": 31, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -767,9 +787,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2188, - "end": 2193, - "replacementText": "x: number = 2", + "start": 2189, + "end": 2189, + "replacementText": ": number", "line": 92, "column": 1, "endLine": 94, @@ -788,9 +808,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2195, - "end": 2200, - "replacementText": "y: number = 3", + "start": 2196, + "end": 2196, + "replacementText": ": number", "line": 92, "column": 1, "endLine": 94, @@ -914,9 +934,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2368, - "end": 2386, - "replacementText": "an_array: number[] = [1, 2, 3]", + "start": 2376, + "end": 2376, + "replacementText": ": number[]", "line": 105, "column": 5, "endLine": 105, @@ -994,17 +1014,17 @@ "line": 107, "column": 5, "endLine": 107, - "endColumn": 19, + "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 2394, - "end": 2408, - "replacementText": "g: number = an_array[]", + "start": 2396, + "end": 2396, + "replacementText": ": number", "line": 107, "column": 5, "endLine": 107, - "endColumn": 19 + "endColumn": 20 } ], "suggest": "", @@ -1013,9 +1033,9 @@ }, { "line": 107, - "column": 18, + "column": 19, "endLine": 107, - "endColumn": 18, + "endColumn": 19, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -1025,17 +1045,17 @@ "line": 109, "column": 7, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 2418, - "end": 2423, - "replacementText": "a: number = 1", + "start": 2421, + "end": 2421, + "replacementText": ": number", "line": 109, "column": 7, "endLine": 109, - "endColumn": 12 + "endColumn": 13 } ], "suggest": "", @@ -1044,19 +1064,19 @@ }, { "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 2422, - "end": 2423, + "start": 2424, + "end": 2425, "replacementText": "1.0", "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12 + "endColumn": 13 } ], "suggest": "", @@ -1091,9 +1111,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2493, - "end": 2506, - "replacementText": "test: number = Test.A", + "start": 2499, + "end": 2499, + "replacementText": ": number", "line": 115, "column": 7, "endLine": 115, @@ -1112,9 +1132,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2593, - "end": 2609, - "replacementText": "readonly c1: number = 1;", + "start": 2606, + "end": 2606, + "replacementText": ": number", "line": 121, "column": 3, "endLine": 121, @@ -1133,8 +1153,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2607, - "end": 2608, + "start": 2609, + "end": 2610, "replacementText": "1.0", "line": 121, "column": 17, @@ -1154,9 +1174,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2620, - "end": 2638, - "replacementText": "readonly c4: number = 1.7;", + "start": 2633, + "end": 2633, + "replacementText": ": number", "line": 122, "column": 3, "endLine": 122, @@ -1175,9 +1195,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2651, - "end": 2671, - "replacementText": "readonly c5: number = 0x123;", + "start": 2664, + "end": 2664, + "replacementText": ": number", "line": 123, "column": 3, "endLine": 123, @@ -1196,9 +1216,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2683, - "end": 2703, - "replacementText": "readonly c6: number = 0o123;", + "start": 2696, + "end": 2696, + "replacementText": ": number", "line": 124, "column": 3, "endLine": 124, @@ -1217,9 +1237,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2713, - "end": 2733, - "replacementText": "readonly c7: number = 0b101;", + "start": 2726, + "end": 2726, + "replacementText": ": number", "line": 125, "column": 3, "endLine": 125, @@ -1238,9 +1258,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2743, - "end": 2764, - "replacementText": "readonly c8: number[] = [1, 2, 3];", + "start": 2756, + "end": 2756, + "replacementText": ": number[]", "line": 126, "column": 3, "endLine": 126, @@ -1259,8 +1279,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2758, - "end": 2759, + "start": 2760, + "end": 2761, "replacementText": "1.0", "line": 126, "column": 18, @@ -1280,8 +1300,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2760, - "end": 2761, + "start": 2762, + "end": 2763, "replacementText": "2.0", "line": 126, "column": 20, @@ -1301,8 +1321,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2762, - "end": 2763, + "start": 2764, + "end": 2765, "replacementText": "3.0", "line": 126, "column": 22, @@ -1322,9 +1342,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2893, - "end": 2899, - "replacementText": "c1: number = 1", + "start": 2897, + "end": 2897, + "replacementText": ": number", "line": 137, "column": 7, "endLine": 137, @@ -1343,8 +1363,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2898, - "end": 2899, + "start": 2900, + "end": 2901, "replacementText": "1.0", "line": 137, "column": 12, @@ -1364,9 +1384,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2923, - "end": 2939, - "replacementText": "readonly a5: number = 4;", + "start": 2936, + "end": 2936, + "replacementText": ": number", "line": 140, "column": 3, "endLine": 140, @@ -1385,8 +1405,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2937, - "end": 2938, + "start": 2939, + "end": 2940, "replacementText": "4.0", "line": 140, "column": 17, @@ -1416,9 +1436,9 @@ "problem": "NumericSemantics", "autofix": [ { - "replacementText": "fingerprintPositionY: number = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0", - "start": 2952, - "end": 3068, + "start": 2974, + "end": 2974, + "replacementText": ": number", "line": 143, "column": 30, "endLine": 143, @@ -1437,8 +1457,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3067, - "end": 3068, + "start": 3069, + "end": 3070, "replacementText": "0.0", "line": 143, "column": 122, @@ -1451,207 +1471,40 @@ "severity": "ERROR" }, { - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49, - "problem": "VoidOperator", - "autofix": [ - { - "start": 3117, - "end": 3558, - "replacementText": "(() => {\r\n ({\r\n openFolderLayout, : .getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight,\r\n openFolderLayout, : .getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth,\r\n let, pos = [-1, -1],\r\n pos = folderLayoutUtil.getFolderComponentCenterPosition(FolderData.getInstance().getOpenedFolder()),\r\n let, editModeTranslateY = this.getEditModeTranslateY(pos),\r\n if(pos) { }, : .length > 1\r\n });\r\n return undefined;\r\n})()", - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "\"void\" operator is not supported (arkts-no-void-operator)", - "severity": "ERROR" - }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3129, - "end": 3145, - "replacementText": "openFolderLayout: openFolderLayout", - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3237, - "end": 3253, - "replacementText": "openFolderLayout: openFolderLayout", - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3345, - "end": 3348, - "replacementText": "let: let", - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23, - "problem": "ObjectLiteralProperty", + "problem": "NumericSemantics", "autofix": [ { - "start": 3349, - "end": 3363, - "replacementText": "pos: pos", - "line": 149, + "start": 3372, + "end": 3372, + "replacementText": ": number[]", + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23 } ], "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3370, - "end": 3469, - "replacementText": "pos: pos", - "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3476, - "end": 3479, - "replacementText": "let: let", - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3480, - "end": 3532, - "replacementText": "editModeTranslateY: editModeTranslateY", - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 12, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 3356, - "end": 3358, + "start": 3376, + "end": 3378, "replacementText": "-1.0", - "line": 149, + "line": 150, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18 } ], @@ -1660,19 +1513,19 @@ "severity": "ERROR" }, { - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 3360, - "end": 3362, + "start": 3380, + "end": 3382, "replacementText": "-1.0", - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22 } ], @@ -1680,50 +1533,30 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 3556, - "end": 3557, + "start": 3576, + "end": 3577, "replacementText": "1.0", - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23 } ], @@ -1732,19 +1565,19 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101, "problem": "NumericSemantics", "autofix": [ { - "start": 3661, - "end": 3662, + "start": 3681, + "end": 3682, "replacementText": "0.0", - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101 } ], @@ -1753,19 +1586,29 @@ "severity": "ERROR" }, { - "line": 160, + "line": 161, + "column": 61, + "endLine": 161, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85, "problem": "NumericSemantics", "autofix": [ { - "start": 4128, - "end": 4129, + "start": 4148, + "end": 4149, "replacementText": "2.0", - "line": 160, + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85 } ], @@ -1774,20 +1617,30 @@ "severity": "ERROR" }, { - "line": 166, + "line": 162, + "column": 61, + "endLine": 162, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12, + "endLine": 168, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 4388, - "end": 4395, - "replacementText": "f: number = 0.0", - "line": 166, + "start": 4415, + "end": 4415, + "replacementText": ": number", + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12 + "endLine": 168, + "endColumn": 13 } ], "suggest": "", @@ -1795,19 +1648,19 @@ "severity": "ERROR" }, { - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4415, - "end": 4416, + "start": 4441, + "end": 4442, "replacementText": "0.0", - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19 } ], @@ -1816,19 +1669,19 @@ "severity": "ERROR" }, { - "line": 170, + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12, "problem": "NumericSemantics", "autofix": [ { - "start": 4440, - "end": 4447, - "replacementText": "e: number = 0.0", - "line": 170, + "start": 4467, + "end": 4467, + "replacementText": ": number", + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12 } ], @@ -1837,19 +1690,19 @@ "severity": "ERROR" }, { - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4467, - "end": 4468, + "start": 4493, + "end": 4494, "replacementText": "0.0", - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19 } ], @@ -1858,19 +1711,19 @@ "severity": "ERROR" }, { - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10, "problem": "NumericSemantics", "autofix": [ { - "start": 4595, - "end": 4596, + "start": 4621, + "end": 4622, "replacementText": "3.0", - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10 } ], @@ -1879,19 +1732,19 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10, "problem": "NumericSemantics", "autofix": [ { - "start": 4613, - "end": 4614, + "start": 4639, + "end": 4640, "replacementText": "3.0", - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10 } ], @@ -1900,19 +1753,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4627, - "end": 4641, - "replacementText": "arr1: number[] = [1, 2, 3]", - "line": 182, + "start": 4657, + "end": 4657, + "replacementText": ": number[]", + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19 } ], @@ -1921,19 +1774,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 4635, - "end": 4636, + "start": 4661, + "end": 4662, "replacementText": "1.0", - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14 } ], @@ -1942,19 +1795,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16, "problem": "NumericSemantics", "autofix": [ { - "start": 4637, - "end": 4638, + "start": 4663, + "end": 4664, "replacementText": "2.0", - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16 } ], @@ -1963,19 +1816,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 4639, - "end": 4640, + "start": 4665, + "end": 4666, "replacementText": "3.0", - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18 } ], @@ -1984,9 +1837,9 @@ "severity": "ERROR" }, { - "line": 183, + "line": 185, "column": 6, - "endLine": 183, + "endLine": 185, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -1994,20 +1847,20 @@ "severity": "ERROR" }, { - "line": 185, + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12, + "endLine": 187, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 4670, - "end": 4677, - "replacementText": "a: number = 0.0", - "line": 185, + "start": 4698, + "end": 4698, + "replacementText": ": number", + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12 + "endLine": 187, + "endColumn": 13 } ], "suggest": "", @@ -2015,19 +1868,19 @@ "severity": "ERROR" }, { - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 4743, - "end": 4744, + "start": 4772, + "end": 4773, "replacementText": "1.0", - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11 } ], @@ -2036,19 +1889,19 @@ "severity": "ERROR" }, { - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 4796, - "end": 4797, + "start": 4825, + "end": 4826, "replacementText": "1.0", - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11 } ], @@ -2057,9 +1910,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -2067,39 +1920,39 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 199, - "column": 15, - "endLine": 199, - "endColumn": 24, + "line": 201, + "column": 16, + "endLine": 201, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 4903, - "end": 4904, + "start": 4933, + "end": 4934, "replacementText": "0.0", - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22 } ], @@ -2108,19 +1961,19 @@ "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31, "problem": "NumericSemantics", "autofix": [ { - "start": 4910, - "end": 4913, + "start": 4940, + "end": 4943, "replacementText": "100.0", - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31 } ], @@ -2129,20 +1982,20 @@ "severity": "ERROR" }, { - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53, + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54, "problem": "NumericSemantics", "autofix": [ { - "start": 4991, - "end": 4992, + "start": 5023, + "end": 5024, "replacementText": "6.0", - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53 + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54 } ], "suggest": "", @@ -2150,20 +2003,20 @@ "severity": "ERROR" }, { - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57, + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58, "problem": "NumericSemantics", "autofix": [ { - "start": 4994, - "end": 4996, + "start": 5026, + "end": 5028, "replacementText": "86.0", - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57 + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58 } ], "suggest": "", @@ -2171,9 +2024,9 @@ "severity": "ERROR" }, { - "line": 205, + "line": 207, "column": 42, - "endLine": 205, + "endLine": 207, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -2181,9 +2034,9 @@ "severity": "ERROR" }, { - "line": 212, + "line": 214, "column": 13, - "endLine": 212, + "endLine": 214, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -2191,9 +2044,9 @@ "severity": "ERROR" }, { - "line": 213, + "line": 215, "column": 17, - "endLine": 213, + "endLine": 215, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2201,9 +2054,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 17, - "endLine": 214, + "endLine": 216, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2211,9 +2064,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 17, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2221,9 +2074,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 218, "column": 19, - "endLine": 216, + "endLine": 218, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -2231,9 +2084,9 @@ "severity": "ERROR" }, { - "line": 217, + "line": 219, "column": 18, - "endLine": 217, + "endLine": 219, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -2241,9 +2094,9 @@ "severity": "ERROR" }, { - "line": 218, + "line": 220, "column": 20, - "endLine": 218, + "endLine": 220, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -2251,9 +2104,9 @@ "severity": "ERROR" }, { - "line": 222, + "line": 224, "column": 10, - "endLine": 222, + "endLine": 224, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -2261,9 +2114,9 @@ "severity": "ERROR" }, { - "line": 223, + "line": 225, "column": 11, - "endLine": 223, + "endLine": 225, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -2271,9 +2124,9 @@ "severity": "ERROR" }, { - "line": 224, + "line": 226, "column": 14, - "endLine": 224, + "endLine": 226, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -2281,9 +2134,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 227, "column": 16, - "endLine": 225, + "endLine": 227, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -2291,9 +2144,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 14, - "endLine": 226, + "endLine": 228, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -2301,19 +2154,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 5469, - "end": 5529, - "replacementText": "public static readonly SIX_MONTH: number = 180 * 24 * 60 * 60 * 1000;", - "line": 230, + "start": 5540, + "end": 5540, + "replacementText": ": number", + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63 } ], @@ -2322,19 +2175,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41, "problem": "NumericSemantics", "autofix": [ { - "start": 5504, - "end": 5507, + "start": 5543, + "end": 5546, "replacementText": "180.0", - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41 } ], @@ -2343,19 +2196,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46, "problem": "NumericSemantics", "autofix": [ { - "start": 5510, - "end": 5512, + "start": 5549, + "end": 5551, "replacementText": "24.0", - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46 } ], @@ -2364,19 +2217,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51, "problem": "NumericSemantics", "autofix": [ { - "start": 5515, - "end": 5517, + "start": 5554, + "end": 5556, "replacementText": "60.0", - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51 } ], @@ -2385,19 +2238,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56, "problem": "NumericSemantics", "autofix": [ { - "start": 5520, - "end": 5522, + "start": 5559, + "end": 5561, "replacementText": "60.0", - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56 } ], @@ -2406,19 +2259,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 5525, - "end": 5529, + "start": 5564, + "end": 5568, "replacementText": "1000.0", - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63 } ], @@ -2426,6 +2279,90 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5618, + "end": 5618, + "replacementText": ": number", + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5669, + "end": 5670, + "replacementText": "0.0", + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5739, + "end": 5739, + "replacementText": ": number", + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "autofix": [ + { + "start": 5687, + "end": 5696, + "replacementText": "", + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -2437,9 +2374,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2458,9 +2395,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2479,9 +2416,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2500,9 +2437,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2521,9 +2458,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2542,9 +2479,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2553,9 +2490,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 46, - "endLine": 153, + "endLine": 154, "endColumn": 56, "problem": "UIInterfaceImport", "autofix": [ @@ -2563,9 +2500,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2574,9 +2511,9 @@ "severity": "ERROR" }, { - "line": 154, + "line": 155, "column": 33, - "endLine": 154, + "endLine": 155, "endColumn": 43, "problem": "UIInterfaceImport", "autofix": [ @@ -2584,9 +2521,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2595,9 +2532,9 @@ "severity": "ERROR" }, { - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44, "problem": "UIInterfaceImport", "autofix": [ @@ -2605,9 +2542,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2616,4 +2553,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.json b/ets2panda/linter/test/main/numeric_semantics.ets.json index 47737941ad04d6a390c617f5cd735c817853aba8..2104782a9f9aedaf0c50e2b0a6d5c1fd03818c0e 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.json @@ -34,40 +34,20 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -75,10 +55,10 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets index 43753aa4987f263c914c9445d1ddf7660eb70fb6..a5bab563d4debeb46c9ddb3bb0e990e41c26e0be 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets @@ -16,13 +16,13 @@ // TypeScript: treats 'n' as having type number // ArkTS: treats 'n' as having type int to reach max code performance -import { - Entry, - Component, - State, - RelativeContainer, - Text, - AppStorage, +import { + Entry, + Component, + State, + RelativeContainer, + Text, + AppStorage, } from '@kit.ArkUI'; let a: number = 1.0; @@ -112,11 +112,11 @@ function identity(value: T): T { } identity(42.0); -let an_array: number[] = [1.0, 2.0, 3.0] +let an_array: number[] = [1.0,2.0,3.0] -let g: number = an_array[] +let g2: number = an_array[] -const a: number = 1.0 +const a2: number = 1.0 enum Test { A = 1, // 显式赋值为 1 @@ -133,7 +133,7 @@ struct Index2 { readonly c5: number = 0x123; // 16进制 readonly c6: number = 0o123; //8进制 readonly c7: number = 0b101; //2进制 - readonly c8: number[] = [1.0, 2.0, 3.0]; + readonly c8: number[] = [1.0,2.0,3.0] build() { RelativeContainer() { @@ -152,17 +152,15 @@ export class G{ const fingerprintPositionY: number = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0.0; -private doCloseFolderBackgroundAnimation(): (() => { - ({ - openFolderLayout: openFolderLayout, : .getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight, - openFolderLayout: openFolderLayout, : .getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth, - let: let, pos: pos, - pos: pos, - let: let, editModeTranslateY: editModeTranslateY, - if(pos) { }, : .length > 1.0 - }); - return undefined; -})() { +class Layout { + private doCloseFolderBackgroundAnimation(): void { + openFolderLayout.getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight; + openFolderLayout.getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth; + + let pos: number[] = [-1.0, -1.0]; + pos = folderLayoutUtil.getFolderComponentCenterPosition(FolderData.getInstance().getOpenedFolder()); + let editModeTranslateY = this.getEditModeTranslateY(pos); + if (pos.length > 1.0) { let translateXForScreenSplit: number = AppStorage.get('translateXForScreenSplit') ?? 0.0 as number; let screenWidth: number = AppStorage.get('screenWidth') as number; let screenHeight: number = AppStorage.get('screenHeight') as number; @@ -174,9 +172,10 @@ private doCloseFolderBackgroundAnimation(): (() => { openFolderLayout.getGridSwiperLayout().bgTranslateY = pos[1] + editModeTranslateY - openFolderLayout.getBackgroundLayout().closedHeight * 0.5 - openFolderLayout.getBackgroundLayout().openedMargin; } + } } -let f: number = 0.0; +let f2: number = 0.0; let b5: number = 0.0; f = b5; // OK @@ -192,12 +191,12 @@ e >>= g1; // OK e &= g1; // OK e = e & 3.0; // OK e = e | 3.0; // OK -let arr1: number[] = [1.0, 2.0, 3.0] +let arr1: number[] = [1.0,2.0,3.0] e += arr1[0]; // OK -let a: number = 0.0; -a = fun1(); -a = fun2()!; +let a3: number = 0.0; +a3 = fun1(); +a3 = fun2()!; function fun1():number{ return 1.0; @@ -209,17 +208,17 @@ function fun2():number|undefined{ import { ArrayList } from "@kit.ArkTS"; -let arr = new ArrayList() +let arr2 = new ArrayList() for (let i:number = 0.0; i < 100.0; i++) { - arr.add(i) + arr2.add(i) } -let cancelIds:ArrayList = arr.subArrayList(6.0, 86.0) -let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) +let cancelIds:ArrayList = arr2.subArrayList(6.0, 86.0) +let arr3: Array = Array.from(cancelIds) +let arr4: Array = Array.from(new ArrayList()) -let a:number = 0.000; +let a4: number = 0.000; -const b:number = 0.000; +const b4: number = 0.000; export enum WalletStageValue { DEFAULT = 0, @@ -240,5 +239,18 @@ export enum AnimationStage { } class C { - public static readonly SIX_MONTH: number = 180.0 * 24.0 * 60.0 * 60.0 * 1000.0; + public static readonly SIX_MONTH: number = 180.0 * 24.0 * 60.0 * 60.0 * 1000.0 +} + +function testIndentation(): void { + let a: number = (() => { + console.log('hello'); + return 0.0; + })(); } + + +export function add(a: number, b: number): number { + console.log("SharedModule: Hap call ShareFile add"); + return a + b; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json index 09385a376c0a71f5f8ab507066c36cbb0f10a3f5..ae0621e24de33924117743a1b7bf713ee3b4e9ac 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json @@ -26,9 +26,9 @@ }, { "line": 117, - "column": 26, + "column": 27, "endLine": 117, - "endColumn": 26, + "endColumn": 27, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -54,50 +54,40 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 156, - "column": 6, - "endLine": 156, - "endColumn": 7, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, { "line": 162, "column": 9, "endLine": 162, - "endColumn": 20, - "problem": "ObjectLiteralProperty", + "endColumn": 61, + "problem": "AnyType", "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 162, - "column": 9, - "endLine": 162, - "endColumn": 11, - "problem": "InvalidIdentifier", + "line": 171, + "column": 61, + "endLine": 171, + "endColumn": 67, + "problem": "RuntimeArrayCheck", "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 162, - "column": 12, - "endLine": 162, - "endColumn": 15, - "problem": "AnyType", + "line": 172, + "column": 61, + "endLine": 172, + "endColumn": 67, + "problem": "RuntimeArrayCheck", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 196, + "line": 195, "column": 6, - "endLine": 196, + "endLine": 195, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 210, + "line": 209, "column": 1, - "endLine": 210, + "endLine": 209, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -115,29 +105,29 @@ "severity": "ERROR" }, { - "line": 212, + "line": 211, "column": 5, - "endLine": 212, - "endColumn": 34, + "endLine": 211, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 212, - "column": 15, - "endLine": 212, - "endColumn": 24, + "line": 211, + "column": 16, + "endLine": 211, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 218, + "line": 217, "column": 42, - "endLine": 218, + "endLine": 217, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -145,9 +135,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 224, "column": 13, - "endLine": 225, + "endLine": 224, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +145,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 225, "column": 17, - "endLine": 226, + "endLine": 225, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +155,9 @@ "severity": "ERROR" }, { - "line": 227, + "line": 226, "column": 17, - "endLine": 227, + "endLine": 226, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -175,9 +165,9 @@ "severity": "ERROR" }, { - "line": 228, + "line": 227, "column": 17, - "endLine": 228, + "endLine": 227, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -185,9 +175,9 @@ "severity": "ERROR" }, { - "line": 229, + "line": 228, "column": 19, - "endLine": 229, + "endLine": 228, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +185,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 229, "column": 18, - "endLine": 230, + "endLine": 229, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -205,9 +195,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 230, "column": 20, - "endLine": 231, + "endLine": 230, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -215,9 +205,9 @@ "severity": "ERROR" }, { - "line": 235, + "line": 234, "column": 10, - "endLine": 235, + "endLine": 234, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -225,9 +215,9 @@ "severity": "ERROR" }, { - "line": 236, + "line": 235, "column": 11, - "endLine": 236, + "endLine": 235, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -235,9 +225,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 236, "column": 14, - "endLine": 237, + "endLine": 236, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -245,9 +235,9 @@ "severity": "ERROR" }, { - "line": 238, + "line": 237, "column": 16, - "endLine": 238, + "endLine": 237, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +245,9 @@ "severity": "ERROR" }, { - "line": 239, + "line": 238, "column": 14, - "endLine": 239, + "endLine": 238, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -265,4 +255,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json index 8c2a778ec9f98e3debce809d5fc606ab7aa784bc..afbbb893dfd27386d5c9c87f365feaeccc52296f 100755 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json @@ -715,4 +715,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index 9cee3116485dd985f550b19ad95c9d6f09e67846..f4e1b08a2126a8a998f337a662aa36b8cd859662 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -53,9 +53,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 702, - "end": 708, - "replacementText": "b: number = 12", + "start": 703, + "end": 703, + "replacementText": ": number", "line": 18, "column": 11, "endLine": 18, @@ -95,9 +95,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 730, - "end": 738, - "replacementText": "c: number = 13.0", + "start": 731, + "end": 731, + "replacementText": ": number", "line": 19, "column": 11, "endLine": 19, @@ -646,9 +646,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2321, - "end": 2327, - "replacementText": "e: number = 15", + "start": 2322, + "end": 2322, + "replacementText": ": number", "line": 86, "column": 9, "endLine": 86, @@ -688,9 +688,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2347, - "end": 2357, - "replacementText": "e1: number = e & 3", + "start": 2349, + "end": 2349, + "replacementText": ": number", "line": 87, "column": 9, "endLine": 87, @@ -730,9 +730,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2378, - "end": 2388, - "replacementText": "e2: number = e | 3", + "start": 2380, + "end": 2380, + "replacementText": ": number", "line": 88, "column": 9, "endLine": 88, @@ -1253,4 +1253,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json index 2103eb7cf5387f30295dca218d7ff81e6a850e86..3f86f1a88b08a4e9f8c826153a26827a9083cf8b 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json @@ -275,4 +275,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/object_literals_properties.ets b/ets2panda/linter/test/main/object_literals_properties.ets index 1944ed2ef90d437ad280ef9b5227a5a026087bb3..5c88953eb0847554c4dcfb3e311eb9a2963c80e1 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets +++ b/ets2panda/linter/test/main/object_literals_properties.ets @@ -295,3 +295,28 @@ function baz(fooBar: Map) { function baz2(fooBarBaz: FooBarBaz) { } + +class JJ { + mm?: Map + aa?: string +} +const mm: Map = new Map(); +let nn: JJ = {mm} // no error + + +class DD { + tt?: Map + gg?: string +} +const tt: Map = new Map(); +let gg: DD = {tt} // error + +interface Q { + a:number; + foo():void; +} + +let w: Q = { + a:1.0, + foo(){} // no error +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json index 8ed64f688b1637ca397321e8a120fb5b1d0c1bba..a63a7a849d8ea047a41f71ef2772e7c26c7bb945 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json @@ -474,16 +474,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 81, - "column": 3, - "endLine": 83, - "endColumn": 4, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 82, "column": 17, @@ -634,36 +624,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 110, - "column": 3, - "endLine": 110, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 111, - "column": 3, - "endLine": 111, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 112, - "column": 3, - "endLine": 112, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 113, "column": 3, @@ -694,36 +654,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 117, - "column": 3, - "endLine": 117, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 118, - "column": 3, - "endLine": 118, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 119, - "column": 3, - "endLine": 119, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 120, "column": 3, @@ -834,36 +764,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 134, - "column": 3, - "endLine": 134, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 135, - "column": 3, - "endLine": 135, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 136, - "column": 3, - "endLine": 136, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 137, "column": 3, @@ -1144,16 +1044,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 209, - "column": 3, - "endLine": 209, - "endColumn": 9, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 208, "column": 6, @@ -1284,26 +1174,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 251, - "column": 15, - "endLine": 251, - "endColumn": 18, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 258, - "column": 15, - "endLine": 258, - "endColumn": 19, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 274, "column": 16, @@ -1335,15 +1205,45 @@ "severity": "ERROR" }, { - "line": 281, - "column": 5, - "endLine": 283, - "endColumn": 6, + "line": 303, + "column": 32, + "endLine": 303, + "endColumn": 41, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 311, + "column": 32, + "endLine": 311, + "endColumn": 41, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 312, + "column": 15, + "endLine": 312, + "endColumn": 17, "problem": "ObjectLiteralProperty", "suggest": "", "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, + { + "line": 319, + "column": 12, + "endLine": 319, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, { "line": 187, "column": 3, @@ -1355,4 +1255,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json index bbb319af18b8c79801bc869be8d35b1cd69507fd..432b311d060d6e363d60832bedbeb65972c13771 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json @@ -184,9 +184,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 875, - "end": 880, - "replacementText": "x: number = 1", + "start": 876, + "end": 876, + "replacementText": ": number", "line": 31, "column": 5, "endLine": 31, @@ -578,9 +578,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1351, - "end": 1357, - "replacementText": "x2: number = 1", + "start": 1353, + "end": 1353, + "replacementText": ": number", "line": 65, "column": 5, "endLine": 65, @@ -620,9 +620,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1359, - "end": 1365, - "replacementText": "y2: number = 2", + "start": 1361, + "end": 1361, + "replacementText": ": number", "line": 65, "column": 13, "endLine": 65, @@ -662,9 +662,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1367, - "end": 1373, - "replacementText": "z2: number = 3", + "start": 1369, + "end": 1369, + "replacementText": ": number", "line": 65, "column": 21, "endLine": 65, @@ -851,36 +851,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 81, - "column": 3, - "endLine": 83, - "endColumn": 4, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 1599, - "end": 1599, - "replacementText": "class GeneratedObjectLiteralClass_5 implements I {\n m() {\n console.log(100);\n }\n}\n\n", - "line": 81, - "column": 3, - "endLine": 83, - "endColumn": 4 - }, - { - "start": 1610, - "end": 1658, - "replacementText": "new GeneratedObjectLiteralClass_5()", - "line": 81, - "column": 3, - "endLine": 83, - "endColumn": 4 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 82, "column": 17, @@ -1053,9 +1023,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1866, - "end": 1874, - "replacementText": "x2: number = 10;", + "start": 1868, + "end": 1868, + "replacementText": ": number", "line": 103, "column": 3, "endLine": 103, @@ -1095,9 +1065,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1877, - "end": 1885, - "replacementText": "y2: number = 20;", + "start": 1879, + "end": 1879, + "replacementText": ": number", "line": 104, "column": 3, "endLine": 104, @@ -1137,9 +1107,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1888, - "end": 1896, - "replacementText": "z2: number = 30;", + "start": 1890, + "end": 1890, + "replacementText": ": number", "line": 105, "column": 3, "endLine": 105, @@ -1181,69 +1151,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 110, - "column": 3, - "endLine": 110, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 1926, - "end": 1928, - "replacementText": "x2: x2", - "line": 110, - "column": 3, - "endLine": 110, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 111, - "column": 3, - "endLine": 111, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 1943, - "end": 1945, - "replacementText": "y2: y2", - "line": 111, - "column": 3, - "endLine": 111, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 112, - "column": 3, - "endLine": 112, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 1960, - "end": 1962, - "replacementText": "z2: z2", - "line": 112, - "column": 3, - "endLine": 112, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 113, "column": 3, @@ -1305,69 +1212,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 117, - "column": 3, - "endLine": 117, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2034, - "end": 2036, - "replacementText": "x2: x2", - "line": 117, - "column": 3, - "endLine": 117, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 118, - "column": 3, - "endLine": 118, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2051, - "end": 2053, - "replacementText": "y2: y2", - "line": 118, - "column": 3, - "endLine": 118, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 119, - "column": 3, - "endLine": 119, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2068, - "end": 2070, - "replacementText": "z2: z2", - "line": 119, - "column": 3, - "endLine": 119, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 120, "column": 3, @@ -1427,9 +1271,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2200, - "end": 2208, - "replacementText": "x2: number = 10;", + "start": 2202, + "end": 2202, + "replacementText": ": number", "line": 125, "column": 3, "endLine": 125, @@ -1469,9 +1313,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2211, - "end": 2219, - "replacementText": "y2: number = 20;", + "start": 2213, + "end": 2213, + "replacementText": ": number", "line": 126, "column": 3, "endLine": 126, @@ -1511,9 +1355,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2222, - "end": 2230, - "replacementText": "z2: number = 30;", + "start": 2224, + "end": 2224, + "replacementText": ": number", "line": 127, "column": 3, "endLine": 127, @@ -1555,69 +1399,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 134, - "column": 3, - "endLine": 134, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2289, - "end": 2291, - "replacementText": "x2: x2", - "line": 134, - "column": 3, - "endLine": 134, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 135, - "column": 3, - "endLine": 135, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2306, - "end": 2308, - "replacementText": "y2: y2", - "line": 135, - "column": 3, - "endLine": 135, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 136, - "column": 3, - "endLine": 136, - "endColumn": 5, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 2323, - "end": 2325, - "replacementText": "z2: z2", - "line": 136, - "column": 3, - "endLine": 136, - "endColumn": 5 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 137, "column": 3, @@ -1657,9 +1438,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2469, - "end": 2474, - "replacementText": "a: number = 1", + "start": 2470, + "end": 2470, + "replacementText": ": number", "line": 141, "column": 7, "endLine": 141, @@ -1699,9 +1480,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2476, - "end": 2481, - "replacementText": "b: number = 2", + "start": 2477, + "end": 2477, + "replacementText": ": number", "line": 141, "column": 14, "endLine": 141, @@ -2041,16 +1822,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 209, - "column": 3, - "endLine": 209, - "endColumn": 9, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 208, "column": 6, @@ -2276,48 +2047,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 251, - "column": 15, - "endLine": 251, - "endColumn": 18, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 4619, - "end": 4622, - "replacementText": "map: map", - "line": 251, - "column": 15, - "endLine": 251, - "endColumn": 18 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 258, - "column": 15, - "endLine": 258, - "endColumn": 19, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 4766, - "end": 4770, - "replacementText": "map1: map1", - "line": 258, - "column": 15, - "endLine": 258, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, { "line": 274, "column": 16, @@ -2369,35 +2098,78 @@ "severity": "ERROR" }, { - "line": 281, - "column": 5, - "endLine": 283, - "endColumn": 6, - "problem": "ObjectLiteralProperty", + "line": 303, + "column": 32, + "endLine": 303, + "endColumn": 41, + "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 4956, - "end": 4956, - "replacementText": "class GeneratedObjectLiteralClass_12 implements X.I {\n m(): void {\n console.log(\"I\");\n }\n}\n\n", - "line": 281, - "column": 5, - "endLine": 283, - "endColumn": 6 - }, + "start": 5382, + "end": 5382, + "replacementText": "", + "line": 303, + "column": 32, + "endLine": 303, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 311, + "column": 32, + "endLine": 311, + "endColumn": 41, + "problem": "GenericCallNoTypeArgs", + "autofix": [ { - "start": 5055, - "end": 5106, - "replacementText": "new GeneratedObjectLiteralClass_12()", - "line": 281, - "column": 5, - "endLine": 283, - "endColumn": 6 + "start": 5514, + "end": 5514, + "replacementText": "", + "line": 311, + "column": 32, + "endLine": 311, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 312, + "column": 15, + "endLine": 312, + "endColumn": 17, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 5532, + "end": 5534, + "replacementText": "tt: tt", + "line": 312, + "column": 15, + "endLine": 312, + "endColumn": 17 } ], "suggest": "", "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, + { + "line": 319, + "column": 12, + "endLine": 319, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, { "line": 187, "column": 3, @@ -2409,4 +2181,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.json b/ets2panda/linter/test/main/object_literals_properties.ets.json index 97cb35867cee19acd5d2782fa51f2cc23bdc5f80..bd4222ae87a1590c4b67731567fb4fdf3c0bc053 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.json @@ -314,6 +314,16 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 319, + "column": 12, + "endLine": 319, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, { "line": 187, "column": 3, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets index ef4628d62ad4102230155207f7d93a7427f70fdf..fb644f560c6d4c0abefae9423c1a0c76efa4a342 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets +++ b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets @@ -108,13 +108,11 @@ let mixedBad = { // Not fixable interface I { m(): void; } -class GeneratedObjectLiteralClass_5 implements I { - m() { - console.log(100.0); - } -} - -let i: I = new GeneratedObjectLiteralClass_5(); +let i: I = { + m() { // Fixable + console.log(100.0); + } +}; class C { m(): void { @@ -147,7 +145,7 @@ class GeneratedObjectLiteralClass_8 extends C2 { x2: number; y2: number; z2: number; - constructor(init: GeneratedObjectLiteralInitInterface_1) { + constructor(init: GeneratedObjectLiteralInitInterface_8) { super(); this.x2 = init.x2; this.y2 = init.y2; @@ -156,7 +154,7 @@ class GeneratedObjectLiteralClass_8 extends C2 { m() { console.log(1.0); } // Fixable } -interface GeneratedObjectLiteralInitInterface_1 { +interface GeneratedObjectLiteralInitInterface_8 { x2: number; y2: number; z2: number; @@ -169,9 +167,9 @@ let c2: C2 = new GeneratedObjectLiteralClass_8({ }); let c22: C2 = { - x2: x2, // Fixable - y2: y2, // Fixable - z2: z2, // Fixable + x2, // Fixable + y2, // Fixable + z2, // Fixable m() { console.log(1.0); }, // Not fixable, object has spread property ...shorthand // Not fixable }; @@ -186,9 +184,9 @@ class C3 { constructor(a: number) {} } let c3: C3 = { - x2: x2, // Fixable - y2: y2, // Fixable - z2: z2, // Fixable + x2, // Fixable + y2, // Fixable + z2, // Fixable m() { console.log(1.0); } // Not fixable, class type has constructor with parameters }; @@ -310,14 +308,14 @@ interface I4 { map: Map; } let map:Map = new Map(); -let i4: I4 = {map: map}; +let i4: I4 = {map}; class C6 { map1: Map = new Map(); } let map1:Map = new Map(); -let c6: C6 = {map1: map1}; +let c6: C6 = {map1}; // Namespace typed object literals namespace X { @@ -338,16 +336,14 @@ class GeneratedObjectLiteralClass_11 extends X.C { } } -class GeneratedObjectLiteralClass_12 implements X.I { - m(): void { - console.log("I"); - } -} - function test() { let c: X.C = new GeneratedObjectLiteralClass_11() - let i: X.I = new GeneratedObjectLiteralClass_12() + let i: X.I = { + m(): void { + console.log("I"); + } + } } class FooBarBaz { @@ -361,3 +357,28 @@ function baz(fooBar: Map) { function baz2(fooBarBaz: FooBarBaz) { } + +class JJ { + mm?: Map + aa?: string +} +const mm: Map = new Map(); +let nn: JJ = {mm} // no error + + +class DD { + tt?: Map + gg?: string +} +const tt: Map = new Map(); +let gg: DD = {tt: tt} // error + +interface Q { + a:number; + foo():void; +} + +let w: Q = { + a:1.0, + foo(){} // no error +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json index 675cc2476a8a98d88b903bea26dcf8ab85279545..35c8ec6cd00afdabe9b36d4287d09a6d7d268496 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json @@ -85,9 +85,19 @@ "severity": "ERROR" }, { - "line": 171, + "line": 111, + "column": 12, + "endLine": 111, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 169, "column": 15, - "endLine": 171, + "endLine": 169, "endColumn": 16, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -95,9 +105,9 @@ "severity": "ERROR" }, { - "line": 175, + "line": 173, "column": 3, - "endLine": 175, + "endLine": 173, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -105,9 +115,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 174, "column": 3, - "endLine": 176, + "endLine": 174, "endColumn": 15, "problem": "ObjectLiteralProperty", "suggest": "", @@ -115,9 +125,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 174, "column": 3, - "endLine": 176, + "endLine": 174, "endColumn": 15, "problem": "SpreadOperator", "suggest": "", @@ -125,9 +135,9 @@ "severity": "ERROR" }, { - "line": 188, + "line": 186, "column": 14, - "endLine": 188, + "endLine": 186, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -135,9 +145,9 @@ "severity": "ERROR" }, { - "line": 192, + "line": 190, "column": 3, - "endLine": 192, + "endLine": 190, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -145,9 +155,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 195, "column": 25, - "endLine": 197, + "endLine": 195, "endColumn": 26, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -155,9 +165,9 @@ "severity": "ERROR" }, { - "line": 198, + "line": 196, "column": 5, - "endLine": 200, + "endLine": 198, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -165,9 +175,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 201, "column": 29, - "endLine": 203, + "endLine": 201, "endColumn": 30, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -175,9 +185,9 @@ "severity": "ERROR" }, { - "line": 204, + "line": 202, "column": 5, - "endLine": 206, + "endLine": 204, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -185,9 +195,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 212, "column": 26, - "endLine": 214, + "endLine": 212, "endColumn": 27, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -195,9 +205,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 213, "column": 5, - "endLine": 217, + "endLine": 215, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -205,9 +215,9 @@ "severity": "ERROR" }, { - "line": 219, + "line": 217, "column": 27, - "endLine": 219, + "endLine": 217, "endColumn": 28, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -215,9 +225,9 @@ "severity": "ERROR" }, { - "line": 220, + "line": 218, "column": 5, - "endLine": 222, + "endLine": 220, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -225,9 +235,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 224, "column": 27, - "endLine": 226, + "endLine": 224, "endColumn": 28, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -235,9 +245,9 @@ "severity": "ERROR" }, { - "line": 227, + "line": 225, "column": 5, - "endLine": 229, + "endLine": 227, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -245,9 +255,9 @@ "severity": "ERROR" }, { - "line": 238, + "line": 236, "column": 14, - "endLine": 238, + "endLine": 236, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -255,9 +265,9 @@ "severity": "ERROR" }, { - "line": 249, + "line": 247, "column": 3, - "endLine": 249, + "endLine": 247, "endColumn": 9, "problem": "ObjectLiteralProperty", "suggest": "", @@ -265,9 +275,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 254, "column": 14, - "endLine": 256, + "endLine": 254, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -275,19 +285,9 @@ "severity": "ERROR" }, { - "line": 267, - "column": 3, - "endLine": 267, - "endColumn": 9, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 274, + "line": 272, "column": 1, - "endLine": 276, + "endLine": 274, "endColumn": 2, "problem": "MissingSuperCall", "suggest": "", @@ -295,9 +295,9 @@ "severity": "ERROR" }, { - "line": 286, + "line": 284, "column": 1, - "endLine": 288, + "endLine": 286, "endColumn": 2, "problem": "MissingSuperCall", "suggest": "", @@ -305,9 +305,9 @@ "severity": "ERROR" }, { - "line": 289, + "line": 287, "column": 20, - "endLine": 289, + "endLine": 287, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -315,9 +315,9 @@ "severity": "ERROR" }, { - "line": 290, + "line": 288, "column": 3, - "endLine": 290, + "endLine": 288, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -325,9 +325,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 301, "column": 1, - "endLine": 305, + "endLine": 303, "endColumn": 2, "problem": "MissingSuperCall", "suggest": "", @@ -336,18 +336,28 @@ }, { "line": 342, - "column": 5, + "column": 16, "endLine": 342, - "endColumn": 6, - "problem": "MethodInheritRule", + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 381, + "column": 12, + "endLine": 381, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, { - "line": 245, + "line": 243, "column": 3, - "endLine": 245, + "endLine": 243, "endColumn": 4, "problem": "StrictDiagnostic", "suggest": "Property 'b' has no initializer and is not definitely assigned in the constructor.", @@ -355,4 +365,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/oh_modules/@ohos.app.ability.AbilityStage.d.ts b/ets2panda/linter/test/main/oh_modules/@ohos.app.ability.AbilityStage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b55881d9048802032a602b6e48b83a8722ba7b5a --- /dev/null +++ b/ets2panda/linter/test/main/oh_modules/@ohos.app.ability.AbilityStage.d.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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 ApplicationContext from './ApplicationContext'; + +export default class AbilityStage { + + context: ApplicationContext; + + onCreate(): void; + +} + diff --git a/ets2panda/linter/test/main/oh_modules/ApplicationContext.d.ts b/ets2panda/linter/test/main/oh_modules/ApplicationContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..838e34b98c58a262b5b7a8c175ee0e70ab88129a --- /dev/null +++ b/ets2panda/linter/test/main/oh_modules/ApplicationContext.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export default class ApplicationContext { + on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number; + off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback): void; + getApplicationContext(): ApplicationContext; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts b/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0be36a0a8eb13282a0468bccffd1145ad19fc6e1 --- /dev/null +++ b/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + */ + +export declare interface IMonitor { + value(path?: string): IMonitorValue | undefined; +} +export declare interface IMonitorValue { + before: T; + now: T; + path: string; +} +export declare class LocalStorage { + get(propName: string): T | undefined; + ref(propName: string): AbstractProperty | undefined; + link(propName: string): SubscribedAbstractProperty | undefined; +} + +export declare class AppStorage { + static get(propName: string): T | undefined; + static ref(propName: string): AbstractProperty | undefined; + static link(propName: string): SubscribedAbstractProperty | undefined; +} + +export declare interface AbstractProperty { + get(): T; + set(newValue: T): void; + info(): string; +} +export declare abstract class SubscribedAbstractProperty { + info(): string; + abstract get(): T; + abstract set(newValue: T): void; + abstract aboutToBeDeleted(): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json index b96614d1d1551b528fe6479f872307057c021d46..fe3418b262b571c50dc73f6c3f14f3fcba7aef35 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json @@ -43,9 +43,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 704, + "start": 705, "end": 709, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 24, "column": 3, "endLine": 24, @@ -64,9 +64,9 @@ "problem": "StoragePropDecoratorNotSupported", "autofix": [ { - "start": 895, - "end": 916, - "replacementText": "@StoragePropRef", + "start": 896, + "end": 907, + "replacementText": "StoragePropRef", "line": 34, "column": 3, "endLine": 34, @@ -85,9 +85,9 @@ "problem": "LocalStoragePropDecoratorNotSupported", "autofix": [ { - "start": 944, - "end": 970, - "replacementText": "@LocalStoragePropRef", + "start": 945, + "end": 961, + "replacementText": "LocalStoragePropRef", "line": 35, "column": 3, "endLine": 35, diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets index ca03196a9306b8aabaffa4778e25e96a9aa46a63..598b9e31679d237abf9e60a8f37eecb50dd28a30 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets @@ -44,8 +44,8 @@ struct FatherComponent { @Component struct ChildComponent { - @StoragePropRef user2: User = new User() - @LocalStoragePropRef user3: User = new User() + @StoragePropRef("user2") user2: User = new User() + @LocalStoragePropRef("user3") user3: User = new User() build() { } diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json index 66e9c58bab9d619077975c856be68b9cec1c47f6..e03a31e43e674f46b9dd392f7638beff8289ece4 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json @@ -28,7 +28,7 @@ "line": 47, "column": 3, "endLine": 47, - "endColumn": 18, + "endColumn": 27, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", @@ -38,7 +38,7 @@ "line": 48, "column": 3, "endLine": 48, - "endColumn": 23, + "endColumn": 32, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json index 9a56497197e37b67f43078d6e4eca9c91d8f6e6d..cebe97786c9393b24b42b5afd4db049456941c06 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json @@ -115,9 +115,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 1396, + "start": 1397, "end": 1401, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 58, "column": 3, "endLine": 58, @@ -136,9 +136,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 1710, + "start": 1711, "end": 1715, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 76, "column": 3, "endLine": 76, @@ -199,9 +199,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 2040, + "start": 2041, "end": 2045, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 94, "column": 3, "endLine": 94, diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json index 2247b1cc2e70af1c1a076519ab7bedee45e4528e..d53752ee4808099169beec98c3ba007c4bf70fef 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json @@ -868,7 +868,7 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34, + "endColumn": 44, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -995,4 +995,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json index 3e8481358e4982d9ace28266eb547a6f83c93d2e..efd13151c42adb61ca4eccc3c89d3658bcbe0239 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2023-2024 Huawei Device Co., Ltd.", + "Copyright (c) 2024-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", @@ -63,9 +63,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1158, - "end": 1176, - "replacementText": "ar1: number[] = [1, 2, 3, 4]", + "start": 1161, + "end": 1161, + "replacementText": ": number[]", "line": 33, "column": 5, "endLine": 33, @@ -261,9 +261,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1260, - "end": 1277, - "replacementText": "r0: number = [1, 2, 3][1]", + "start": 1262, + "end": 1262, + "replacementText": ": number", "line": 41, "column": 7, "endLine": 41, @@ -282,9 +282,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1283, - "end": 1303, - "replacementText": "r1: number = [1, 2, 3, 4][0]", + "start": 1285, + "end": 1285, + "replacementText": ": number", "line": 42, "column": 5, "endLine": 42, @@ -323,9 +323,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1422, - "end": 1436, - "replacementText": "array1: number[] = [0, 1]", + "start": 1428, + "end": 1428, + "replacementText": ": number[]", "line": 53, "column": 5, "endLine": 53, @@ -386,9 +386,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1441, - "end": 1461, - "replacementText": "array2: number[] = [1, 2, 3, 4, 5]", + "start": 1447, + "end": 1447, + "replacementText": ": number[]", "line": 54, "column": 5, "endLine": 54, @@ -1374,7 +1374,7 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34, + "endColumn": 44, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -1384,7 +1384,16 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34 + "endColumn": 44 + }, + { + "start": 713, + "end": 713, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 177, + "column": 23, + "endLine": 177, + "endColumn": 44 } ], "suggest": "", @@ -1420,9 +1429,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3802, - "end": 3807, - "replacementText": "i: number = 0", + "start": 3803, + "end": 3803, + "replacementText": ": number", "line": 180, "column": 14, "endLine": 180, @@ -1600,4 +1609,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets index d010da0be00ea18aeeedaa6a5be60ca6ccac41e2..6a3cbe36afb397b39f328e127c7b0533ce69429e 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets @@ -13,6 +13,8 @@ * limitations under the License. */ import {OhosInterface} from './oh_modules/ohos_lib'; +import { BitVector } from "@arkts.collections"; + // #14071 class A { @@ -50,8 +52,8 @@ function fobject2(o: Object) { o['k'] } -let array1: number[] = [0.0, 1.0] -let array2: number[] = [1.0, 2.0, 3.0, 4.0, 5.0] +let array1: number[] = [0.0,1.0] +let array2: number[] = [1.0,2.0,3.0,4.0,5.0] let array3: number[] = [1.0,2.0,3.0,4.0,5.0] let array4: Array = [1.0,2.0,3.0,4.0,5.0] let array5 = new Array(10.0) diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json index e2746dde008b85a1c320af9f8162e34e82dd1c34..12bd72ca456622b4c439c477985f0c361bcf2c04 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 22, + "line": 24, "column": 3, - "endLine": 22, + "endLine": 24, "endColumn": 14, "problem": "PropertyAccessByIndex", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 27, "column": 10, - "endLine": 25, + "endLine": 27, "endColumn": 21, "problem": "PropertyAccessByIndex", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 37, + "line": 39, "column": 1, - "endLine": 37, + "endLine": 39, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 38, + "line": 40, "column": 1, - "endLine": 38, + "endLine": 40, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 41, "column": 1, - "endLine": 39, + "endLine": 41, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 48, "column": 3, - "endLine": 46, + "endLine": 48, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 50, + "line": 52, "column": 3, - "endLine": 50, + "endLine": 52, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 57, + "line": 59, "column": 5, - "endLine": 57, + "endLine": 59, "endColumn": 29, "problem": "AnyType", "suggest": "", @@ -95,35 +95,15 @@ "severity": "ERROR" }, { - "line": 57, + "line": 59, "column": 14, - "endLine": 57, + "endLine": 59, "endColumn": 29, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, - { - "line": 70, - "column": 1, - "endLine": 70, - "endColumn": 10, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 1, - "endLine": 71, - "endColumn": 10, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 72, "column": 1, @@ -198,7 +178,7 @@ "line": 79, "column": 1, "endLine": 79, - "endColumn": 11, + "endColumn": 10, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -208,7 +188,7 @@ "line": 80, "column": 1, "endLine": 80, - "endColumn": 11, + "endColumn": 10, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -265,9 +245,29 @@ "severity": "ERROR" }, { - "line": 97, + "line": 86, "column": 1, - "endLine": 97, + "endLine": 86, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, "endColumn": 18, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -275,9 +275,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 1, - "endLine": 98, + "endLine": 100, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -285,9 +285,9 @@ "severity": "ERROR" }, { - "line": 99, + "line": 101, "column": 1, - "endLine": 99, + "endLine": 101, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -295,9 +295,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 24, - "endLine": 107, + "endLine": 109, "endColumn": 39, "problem": "ArrayIndexExprType", "suggest": "", @@ -305,9 +305,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 24, - "endLine": 107, + "endLine": 109, "endColumn": 39, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -315,9 +315,9 @@ "severity": "ERROR" }, { - "line": 108, + "line": 110, "column": 5, - "endLine": 108, + "endLine": 110, "endColumn": 40, "problem": "AnyType", "suggest": "", @@ -325,9 +325,9 @@ "severity": "ERROR" }, { - "line": 117, + "line": 119, "column": 20, - "endLine": 117, + "endLine": 119, "endColumn": 35, "problem": "ArrayIndexExprType", "suggest": "", @@ -335,9 +335,9 @@ "severity": "ERROR" }, { - "line": 117, + "line": 119, "column": 20, - "endLine": 117, + "endLine": 119, "endColumn": 35, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -345,9 +345,9 @@ "severity": "ERROR" }, { - "line": 118, + "line": 120, "column": 5, - "endLine": 118, + "endLine": 120, "endColumn": 36, "problem": "AnyType", "suggest": "", @@ -355,9 +355,9 @@ "severity": "ERROR" }, { - "line": 139, + "line": 141, "column": 12, - "endLine": 139, + "endLine": 141, "endColumn": 31, "problem": "CreatingPrimitiveTypes", "suggest": "", @@ -365,9 +365,9 @@ "severity": "ERROR" }, { - "line": 159, + "line": 161, "column": 3, - "endLine": 159, + "endLine": 161, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -375,9 +375,9 @@ "severity": "ERROR" }, { - "line": 172, + "line": 174, "column": 1, - "endLine": 172, + "endLine": 174, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -385,9 +385,9 @@ "severity": "ERROR" }, { - "line": 173, + "line": 175, "column": 1, - "endLine": 173, + "endLine": 175, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -395,9 +395,9 @@ "severity": "ERROR" }, { - "line": 174, + "line": 176, "column": 1, - "endLine": 174, + "endLine": 176, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -405,9 +405,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 7, - "endLine": 181, + "endLine": 183, "endColumn": 14, "problem": "PropertyAccessByIndex", "suggest": "", @@ -415,9 +415,9 @@ "severity": "ERROR" }, { - "line": 192, + "line": 194, "column": 1, - "endLine": 192, + "endLine": 194, "endColumn": 5, "problem": "PropertyAccessByIndex", "suggest": "", @@ -425,9 +425,9 @@ "severity": "ERROR" }, { - "line": 193, + "line": 195, "column": 1, - "endLine": 193, + "endLine": 195, "endColumn": 7, "problem": "PropertyAccessByIndex", "suggest": "", @@ -435,9 +435,9 @@ "severity": "ERROR" }, { - "line": 196, + "line": 198, "column": 1, - "endLine": 196, + "endLine": 198, "endColumn": 23, "problem": "PropertyAccessByIndex", "suggest": "", @@ -445,9 +445,9 @@ "severity": "ERROR" }, { - "line": 208, + "line": 210, "column": 1, - "endLine": 208, + "endLine": 210, "endColumn": 20, "problem": "PropertyAccessByIndex", "suggest": "", @@ -455,4 +455,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json index e7463248c2903dda6e2372790d0e73ed95392b24..c69595dde9bb832ed87a31fb18b06db442de1a30 100644 --- a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 739, - "end": 744, - "replacementText": "i: number = 0", + "start": 740, + "end": 740, + "replacementText": ": number", "line": 22, "column": 14, "endLine": 22, diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets b/ets2panda/linter/test/main/runtime_array_bound.ets index 934e9df563e128fa24f570286ac41e09eeb61c92..33c5e11fbfee39878779b70ecd8f61efa7ef0471 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets +++ b/ets2panda/linter/test/main/runtime_array_bound.ets @@ -295,3 +295,16 @@ let values: string[] = Object.values(arr); for (let i = 0; i < keys.length; i++) { values[i]; } + +let concatArray: ConcatArray = new Array(1.0, 2.0, 3.0); + +let tempNum: number = concatArray[5]; + + +for (let i = 0; i < concatArray.length; i++) { + concatArray[i] +}; + +if (concatArray.length > 10) { + concatArray[10] +}; diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.args.json b/ets2panda/linter/test/main/runtime_array_bound.ets.args.json index 8a4be28991e8164c0366b8b3ad0dffbc04910a27..18566d7d5af12119eda3f7c6a7d4859530d7b726 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.args.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.args.json @@ -1,20 +1,20 @@ { - "copyright": [ - "Copyright (c) 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." - ], - "mode": { - "arkts2": "", - "migrate": "--arkts-2" - } + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "", + "migrate": "--arkts-2" + } } diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json index ac6388b655d916b890b248e5f5950ce90459433a..eeab471943dea119a5df2506dfe1e2b6cefb3855 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json @@ -2513,6 +2513,46 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 301, + "column": 23, + "endLine": 301, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 304, + "column": 10, + "endLine": 304, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 304, + "column": 14, + "endLine": 304, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 308, + "column": 26, + "endLine": 308, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.json b/ets2panda/linter/test/main/runtime_array_bound.ets.json index bd1b7140ca95b67336908f5fca6dec77fb46b2c0..9f305c86d7ff705098b1e480818e125d5e6e3a4a 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.json @@ -1,17 +1,17 @@ { - "copyright": [ - "Copyright (c) 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." - ], + "copyright": [ + "Copyright (c) 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." + ], "result": [] } diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets index 31f0749e9f76421209911521934f7b62d52d0ee0..5531ae7190fbacfb0cd23ea1d5aefaab27680da0 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets @@ -295,3 +295,16 @@ let values: string[] = Object.values(arr); for (let i: number = 0.0; i < keys.length; i++) { values[i as int]; } + +let concatArray: ConcatArray = new Array(1.0, 2.0, 3.0); + +let tempNum: number = concatArray[5]; + + +for (let i: number = 0.0; i < concatArray.length; i++) { + concatArray[i as int] +}; + +if (concatArray.length > 10.0) { + concatArray[10] +}; diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json index 3d9a0f6ccc36d3b41c0f957b1f0d03fb2118363d..84420569c7afc81e1a53ff83f2da02c069d5981a 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json @@ -233,6 +233,16 @@ "suggest": "", "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" + }, + { + "line": 301, + "column": 23, + "endLine": 301, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets index 71d8cd2396a17b3ef5261f5ddb4d43efe5230b73..b3af1c4b7764f50f47272f85f4e3c83fe158323d 100644 --- a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets @@ -14,28 +14,58 @@ */ import { UIAbility } from '@kit.AbilityKit'; +import { UIExtensionAbility } from '@kit.AbilityKit'; +import { AutoFillExtensionAbility } from '@kit.AbilityKit'; +import { ServiceExtensionAbility } from '@kit.AbilityKit'; function sleep(ms: number): Promise { return new Promise((resolve, reject) => { setTimeout(resolve, ms) }) } -export default class MyUIAbility extends UIAbility { - async onDestroy(): Promise { // ❌ Error + +function sleep1(ms: number): void { + return void +} + +export default class MyUIAbility1 extends UIAbility { + async onDestroy(): Promise { // use UIAbility onDestroy, should report error hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); return sleep(1000); } } +export default class MyUIAbility2 extends UIExtensionAbility { + async onDestroy(): Promise { // use UIExtensionAbility onDestroy, should report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep(1000); + } +} -function sleep(ms: number): Promise { - return new Promise((resolve, reject) => { - setTimeout(resolve, ms) - }) +export default class MyUIAbility3 extends AutoFillExtensionAbility { + async onDestroy(): Promise { // use AutoFillExtensionAbility onDestroy, should report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep(1000); + } } -export default class MyUIAbility extends UIAbility { - onDestroy() { // ❌ Error + +export default class MyUIAbility4 extends ServiceExtensionAbility { + async onDisconnect(): Promise { // use UIAbility onDestroy, should report error hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); return sleep(1000); } } + +export default class MyUIAbility5 extends UIAbility { + onDestroy() { // use UIAbility onDestroy with Promise return, should report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep(1000); + } +} + +export default class MyUIAbility6 extends UIAbility { + onDestroy() { // use UIAbility onDestroy with void return, should not report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep1(1000); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets.arkts2.json index dd37cd82be901a52af98be7a50ce82d1870dcb01..423ad83ad2f85bf7c107bf44a8f895f378362bc3 100644 --- a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets.arkts2.json +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle.ets.arkts2.json @@ -15,29 +15,29 @@ ], "result": [ { - "line": 18, - "column": 1, - "endLine": 22, - "endColumn": 2, - "problem": "TsOverload", + "line": 22, + "column": 10, + "endLine": 24, + "endColumn": 5, + "problem": "GenericCallNoTypeArgs", "suggest": "", - "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, { - "line": 19, + "line": 28, "column": 10, - "endLine": 21, - "endColumn": 5, - "problem": "GenericCallNoTypeArgs", + "endLine": 28, + "endColumn": 14, + "problem": "VoidOperator", "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "rule": "\"void\" operator is not supported (arkts-no-void-operator)", "severity": "ERROR" }, { - "line": 24, + "line": 32, "column": 3, - "endLine": 27, + "endLine": 35, "endColumn": 4, "problem": "LimitedVoidTypeFromSdk", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 32, "column": 9, - "endLine": 24, + "endLine": 32, "endColumn": 18, "problem": "SdkAbilityAsynchronousLifecycle", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 34, "column": 18, - "endLine": 26, + "endLine": 34, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -65,29 +65,79 @@ "severity": "ERROR" }, { - "line": 31, - "column": 1, - "endLine": 35, - "endColumn": 2, - "problem": "TsOverload", + "line": 39, + "column": 3, + "endLine": 42, + "endColumn": 4, + "problem": "LimitedVoidTypeFromSdk", "suggest": "", - "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, { - "line": 32, - "column": 10, - "endLine": 34, - "endColumn": 5, - "problem": "GenericCallNoTypeArgs", + "line": 39, + "column": 9, + "endLine": 39, + "endColumn": 18, + "problem": "SdkAbilityAsynchronousLifecycle", "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "rule": "1.2 Void cannot be combined. OnDestroy/onDisconnect (The return type of the method is now void | Promise) needs to be split into two interfaces. (sdk-ability-asynchronous-lifecycle)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 18, + "endLine": 41, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 9, + "endLine": 46, + "endColumn": 18, + "problem": "SdkAbilityAsynchronousLifecycle", + "suggest": "", + "rule": "1.2 Void cannot be combined. OnDestroy/onDisconnect (The return type of the method is now void | Promise) needs to be split into two interfaces. (sdk-ability-asynchronous-lifecycle)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 18, + "endLine": 48, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 37, + "line": 53, + "column": 9, + "endLine": 53, + "endColumn": 21, + "problem": "SdkAbilityAsynchronousLifecycle", + "suggest": "", + "rule": "1.2 Void cannot be combined. OnDestroy/onDisconnect (The return type of the method is now void | Promise) needs to be split into two interfaces. (sdk-ability-asynchronous-lifecycle)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 18, + "endLine": 55, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 60, "column": 3, - "endLine": 40, + "endLine": 63, "endColumn": 4, "problem": "LimitedVoidTypeFromSdk", "suggest": "", @@ -95,9 +145,9 @@ "severity": "ERROR" }, { - "line": 37, + "line": 60, "column": 3, - "endLine": 37, + "endLine": 60, "endColumn": 12, "problem": "SdkAbilityAsynchronousLifecycle", "suggest": "", @@ -105,14 +155,34 @@ "severity": "ERROR" }, { - "line": 39, + "line": 62, "column": 18, - "endLine": 39, + "endLine": 62, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 67, + "column": 3, + "endLine": 70, + "endColumn": 4, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 19, + "endLine": 69, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..d480eb33021fa05682128f0e7e3b3f00db3e9aa9 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 { ServiceExtensionAbility } from '@kit.AbilityKit'; + +function sleep(ms: number): Promise { + return new Promise((resolve, reject) => { + setTimeout(resolve, ms) + }) +} + +export default class MyUIAbility1 extends ServiceExtensionAbility { + async onDestroy(): Promise { // use ServiceExtensionAbility onDestroy, should not report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep(1000); + } +} + +class UIAbility {} +export default class MyUIAbility2 extends UIAbility { + async onDestroy(): Promise { // use UIAbility not from SDK, should not report error + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + return sleep(1000); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.args.json b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..66fb88f85945924e8be0e83d90123507033f4c5d --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e2d851980528aac83f9b8a48bfbeac0f63876b --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 19, + "column": 10, + "endLine": 21, + "endColumn": 5, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 18, + "endLine": 27, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 18, + "endLine": 35, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.json b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_asynchronous_lifecycle_2.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets index a204f773197277e1b47b3e819c5e992938846f32..b3c46a743715c647bfe939c22f9f54d46d4dd7d6 100644 --- a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets @@ -13,23 +13,76 @@ * limitations under the License. */ -import { UIAbility } from '@kit.AbilityKit'; -import { MyAbility } from 'X'; +import AbilityStage from './oh_modules/@ohos.app.ability.AbilityStage'; +import ApplicationContext from './oh_modules/ApplicationContext'; class MyAbilityStage extends AbilityStage { onCreate() { let abilityLifecycleCallback: AbilityLifecycleCallback = { - onAbilityCreate(ability:UIAbility) { - let myAbility:MyAbility = ability as MyAbility; - myAbility.foo() + onAbilityCreate(ability) { + }, + onWindowStageCreate: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageActive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageInactive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageDestroy: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onAbilityDestroy: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityForeground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityBackground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityContinue: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + } } + let applicationContext = this.context.getApplicationContext(); + let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); // report error normally } - let applicationContext = appMgr.getApplicationContext(); - try { - // 2.通过applicationContext注册监听应用内生命周期 - lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); // Error - } catch (paramError) { - console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`); +} + +class MyAbilityStage extends AbilityStage { + onCreate() { + let abilityLifecycleCallback: AbilityLifecycleCallback = { + onAbilityCreate(ability) { + }, + onWindowStageCreate: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageActive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageInactive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageDestroy: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onAbilityDestroy: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityForeground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityBackground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityContinue: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + } } + let applicationContext = new ApplicationContext(); + let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); // report error normally } } + diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json index 1bb9b8c66ff1e070ddc91480fad1d52e4bc853c3..c285b29dfe12480814ac4c36a17613ddca2ce542 100644 --- a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json @@ -1,10 +1,24 @@ { + "copyright": [ + "Copyright (c) 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." + ], "result": [ { "line": 22, "column": 7, - "endLine": 25, - "endColumn": 6, + "endLine": 23, + "endColumn": 8, "problem": "ObjectLiteralProperty", "suggest": "", "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", @@ -15,60 +29,90 @@ "column": 23, "endLine": 22, "endColumn": 30, - "problem": "AnyType", + "problem": "ParameterType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", "severity": "ERROR" }, { "line": 22, - "column": 31, + "column": 23, "endLine": 22, - "endColumn": 40, + "endColumn": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 27, + "line": 50, "column": 9, - "endLine": 27, - "endColumn": 60, - "problem": "AnyType", + "endLine": 50, + "endColumn": 90, + "problem": "NumericSemantics", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 30, - "column": 21, - "endLine": 30, - "endColumn": 88, + "line": 50, + "column": 23, + "endLine": 50, + "endColumn": 90, "problem": "SdkAbilityLifecycleMonitor", "suggest": "", "rule": "The UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback. The original AbilityLifecycleCallback can only listen to the UIAbility of 1.1 (sdk-ability-lifecycle-monitor)", "severity": "ERROR" }, { - "line": 32, - "column": 46, - "endLine": 32, - "endColumn": 59, - "problem": "UIInterfaceImport", + "line": 57, + "column": 7, + "endLine": 58, + "endColumn": 8, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 23, + "endLine": 57, + "endColumn": 30, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 23, + "endLine": 57, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 9, + "endLine": 85, + "endColumn": 90, + "problem": "NumericSemantics", "suggest": "", - "rule": "The ArkUI interface \"BusinessError\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 32, - "column": 85, - "endLine": 32, - "endColumn": 98, - "problem": "UIInterfaceImport", + "line": 85, + "column": 23, + "endLine": 85, + "endColumn": 90, + "problem": "SdkAbilityLifecycleMonitor", "suggest": "", - "rule": "The ArkUI interface \"BusinessError\" should be imported before it is used (arkui-modular-interface)", + "rule": "The UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback. The original AbilityLifecycleCallback can only listen to the UIAbility of 1.1 (sdk-ability-lifecycle-monitor)", "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json index d651a483feeff55940b384a204da36fb4dd6ddf6..81beed97c616587a30286ec0e80e1fd643531b12 100644 --- a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json @@ -1,4 +1,18 @@ { + "copyright": [ + "Copyright (c) 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." + ], "result": [ { "line": 22, @@ -11,20 +25,10 @@ "severity": "ERROR" }, { - "line": 22, - "column": 31, - "endLine": 22, - "endColumn": 40, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 9, - "endLine": 27, - "endColumn": 60, + "line": 57, + "column": 23, + "endLine": 57, + "endColumn": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a16dab7436ce3fba442cfd7d0e0729ca4b569bf --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 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. + */ + +class AbilityStage { + context: ApplicationContext; + onCreate(): void; +} + +class ApplicationContext { + on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number; + off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback): void; + getApplicationContext(): ApplicationContext; +} +class MyAbilityStage extends AbilityStage { + onCreate() { + let abilityLifecycleCallback: AbilityLifecycleCallback = { + onAbilityCreate(ability) { + }, + onWindowStageCreate: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageActive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageInactive: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onWindowStageDestroy: (ability: UIAbility, windowStage: window.WindowStage): void => { + throw new Error('Function not implemented.'); + }, + onAbilityDestroy: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityForeground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityBackground: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + }, + onAbilityContinue: (ability: UIAbility): void => { + throw new Error('Function not implemented.'); + } + } + let applicationContext = this.context.getApplicationContext(); + let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); // No report error for the source is not target + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.args.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..b214d57430c6b63de949705fe4fc0db53c4bb327 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } + } diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..f577df3546443ea934c88f8f1f08741bdcc54c69 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 7, + "endLine": 30, + "endColumn": 8, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 30, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 9, + "endLine": 57, + "endColumn": 90, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Property 'context' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'context' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..20ef67fcd05fda79aa98cd3c55147ad84eae4786 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.json @@ -0,0 +1,38 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 3, + "endLine": 17, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Property 'context' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'context' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json index e1640cf89ef3344d347b3562f8fdaf8f3cf37c9e..8e3ee4d132e85b85e33063b7fb3e8042329864ba 100644 --- a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json @@ -324,6 +324,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 49, + "column": 26, + "endLine": 49, + "endColumn": 30, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 53, "column": 10, @@ -385,4 +395,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/structural_identity_promise.ets b/ets2panda/linter/test/main/structural_identity_promise.ets index e9fe68fd17fa5e01d5d58d483cc7488f3499cd18..59edca4ff0a7985fdf09f1c14fb832e4c6ffbce9 100644 --- a/ets2panda/linter/test/main/structural_identity_promise.ets +++ b/ets2panda/linter/test/main/structural_identity_promise.ets @@ -32,4 +32,10 @@ class PromiseTest { public async bar(): Promise { return this.foo(); // No error in ArkTS 1.2 } +} + +function sleep(ms: number): PromiseLike { + return new Promise( + (resolve: (value: T | PromiseLike) => void): number => setTimeout(resolve, ms) + ); } \ No newline at end of file diff --git a/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json index ca88f857e960b437dcf767c0ac40be998c8f1236..8687ce3be3eff8ee38ebbf2aca224f013d9fd2c3 100644 --- a/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 39, + "column": 6, + "endLine": 39, + "endColumn": 50, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/subclass_super_call.ets b/ets2panda/linter/test/main/subclass_super_call.ets index 7e8034806431ea58a666b1a78cf468910585e6f3..2ed960ed9071cc0141abcf6db8a1abe4ff6985bb 100644 --- a/ets2panda/linter/test/main/subclass_super_call.ets +++ b/ets2panda/linter/test/main/subclass_super_call.ets @@ -83,3 +83,21 @@ class EpicBar extends Error { super("foo") } } + +export enum EEE { + E1, + E2, +} + +export class A { + protected _e:EEE + constructor(e: EEE) { + this._e = e; + } +} + +class B extends A { + constructor() { + super(EEE.E1) + } +} diff --git a/ets2panda/linter/test/main/swicth_expr.ets b/ets2panda/linter/test/main/swicth_expr.ets index 45055cf2effb98cfa502ee3854ea24d1305b1372..f44ab3e8e278572230b170104e0cbdd99d03e9c1 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets +++ b/ets2panda/linter/test/main/swicth_expr.ets @@ -193,7 +193,6 @@ switch (num1) { console.log('Other number'); } -1.0 let num111 = 1.0; switch (num111) { case 1.0: @@ -230,7 +229,7 @@ switch (isnum1) { default: console.log('F'); } -// 整型 5.2fail + type sw1 = number function FunSw4(): sw1 { @@ -245,7 +244,6 @@ switch (FunSw4()) { console.log('F'); } -// 浮点 5.2fail type sw2 = number | string function FunSw5(): sw2 { @@ -299,7 +297,6 @@ switch (FunSw2()) { console.log('F'); } -// 正无穷 let number4 = Infinity; switch (number4) { case Infinity: @@ -309,7 +306,6 @@ switch (number4) { console.log("Default case"); } -// 负无穷 let number5 = -Infinity; switch (number5) { case -Infinity: @@ -319,7 +315,6 @@ switch (number5) { console.log("Default case"); } -// NaN let number6 = NaN; switch (number6) { case NaN: @@ -338,7 +333,6 @@ switch (num111) { console.log('Other number'); } -// let声明整型,case浮点 let number33: number = 1; switch (number33) { case 1.1: @@ -354,7 +348,6 @@ switch (number33) { console.log("Default case"); } -// const声明,整型number,有类型 const num11: number = 2; switch (num11) { case 1: { @@ -367,7 +360,6 @@ switch (num11) { } } -// let声明,整型number,有类型 let num00: number = 2; switch (num00) { case 1: { @@ -380,7 +372,6 @@ switch (num00) { } } - enum Direction1 { North, South, @@ -390,7 +381,7 @@ enum Direction1 { function funSE() : string | Direction1 { return 'aaa' } -switch (funSE()) { // 误报 +switch (funSE()) { case 'aaa': console.log('aaa'); break; @@ -401,14 +392,20 @@ switch (funSE()) { // 误报 console.log('F'); } - enum H { RED, BLUE } -function foo11(e: H) { // 误报 +function foo11(e: H) { switch (e) { case H.RED: } } +function foo(index: number) { + switch (index) { + case 0: + break; + } +} + diff --git a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json index 207e0d7ebf74d0b53f12ef7ce8e7538c45e99f3e..3fbbc5b9b538f022d1af56aaa7a7b92d148f2579 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json @@ -21,7 +21,7 @@ "endColumn": 15, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 17, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 19, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 16, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -244,16 +244,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 91, - "column": 9, - "endLine": 91, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 95, "column": 8, @@ -274,16 +264,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 101, - "column": 9, - "endLine": 101, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 105, "column": 8, @@ -311,7 +291,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -394,16 +374,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 140, - "column": 11, - "endLine": 140, - "endColumn": 19, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 141, "column": 10, @@ -434,16 +404,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 9, - "endLine": 152, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 153, "column": 8, @@ -514,16 +474,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 176, - "column": 9, - "endLine": 176, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 177, "column": 8, @@ -575,9 +525,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 196, "column": 5, - "endLine": 197, + "endLine": 196, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -585,19 +535,9 @@ "severity": "ERROR" }, { - "line": 198, - "column": 9, - "endLine": 198, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 206, + "line": 205, "column": 7, - "endLine": 206, + "endLine": 205, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -605,9 +545,9 @@ "severity": "ERROR" }, { - "line": 206, + "line": 205, "column": 19, - "endLine": 206, + "endLine": 205, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -615,9 +555,9 @@ "severity": "ERROR" }, { - "line": 208, + "line": 207, "column": 8, - "endLine": 208, + "endLine": 207, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -625,9 +565,9 @@ "severity": "ERROR" }, { - "line": 211, + "line": 210, "column": 8, - "endLine": 211, + "endLine": 210, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -635,9 +575,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 215, "column": 13, - "endLine": 216, + "endLine": 215, "endColumn": 32, "problem": "CreatingPrimitiveTypes", "suggest": "", @@ -645,9 +585,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 224, "column": 31, - "endLine": 225, + "endLine": 224, "endColumn": 32, "problem": "NumericSemantics", "suggest": "", @@ -655,19 +595,9 @@ "severity": "ERROR" }, { - "line": 226, - "column": 9, - "endLine": 226, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 237, + "line": 236, "column": 10, - "endLine": 237, + "endLine": 236, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -676,18 +606,8 @@ }, { "line": 240, - "column": 9, - "endLine": 240, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 241, "column": 8, - "endLine": 241, + "endLine": 240, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -695,19 +615,9 @@ "severity": "ERROR" }, { - "line": 255, - "column": 9, - "endLine": 255, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 263, + "line": 261, "column": 5, - "endLine": 263, + "endLine": 261, "endColumn": 30, "problem": "NumericSemantics", "suggest": "", @@ -715,29 +625,9 @@ "severity": "ERROR" }, { - "line": 264, - "column": 9, - "endLine": 264, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 271, + "line": 269, "column": 9, - "endLine": 271, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 271, - "column": 9, - "endLine": 271, + "endLine": 269, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -745,9 +635,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 7, - "endLine": 279, + "endLine": 277, "endColumn": 27, "problem": "NumericSemantics", "suggest": "", @@ -755,9 +645,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 21, - "endLine": 279, + "endLine": 277, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -765,9 +655,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 25, - "endLine": 279, + "endLine": 277, "endColumn": 26, "problem": "NumericSemantics", "suggest": "", @@ -775,19 +665,9 @@ "severity": "ERROR" }, { - "line": 280, - "column": 9, - "endLine": 280, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 281, + "line": 279, "column": 8, - "endLine": 281, + "endLine": 279, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -795,9 +675,9 @@ "severity": "ERROR" }, { - "line": 284, + "line": 282, "column": 8, - "endLine": 284, + "endLine": 282, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -805,19 +685,9 @@ "severity": "ERROR" }, { - "line": 294, - "column": 9, - "endLine": 294, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 303, + "line": 300, "column": 5, - "endLine": 303, + "endLine": 300, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -825,19 +695,9 @@ "severity": "ERROR" }, { - "line": 304, - "column": 9, - "endLine": 304, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 313, + "line": 309, "column": 5, - "endLine": 313, + "endLine": 309, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -845,19 +705,9 @@ "severity": "ERROR" }, { - "line": 314, - "column": 9, - "endLine": 314, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 323, + "line": 318, "column": 5, - "endLine": 323, + "endLine": 318, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -865,19 +715,9 @@ "severity": "ERROR" }, { - "line": 324, - "column": 9, - "endLine": 324, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 332, + "line": 327, "column": 5, - "endLine": 332, + "endLine": 327, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -885,19 +725,9 @@ "severity": "ERROR" }, { - "line": 333, - "column": 9, - "endLine": 333, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 342, + "line": 336, "column": 24, - "endLine": 342, + "endLine": 336, "endColumn": 25, "problem": "NumericSemantics", "suggest": "", @@ -905,19 +735,9 @@ "severity": "ERROR" }, { - "line": 343, - "column": 9, - "endLine": 343, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 347, + "line": 341, "column": 8, - "endLine": 347, + "endLine": 341, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -925,9 +745,9 @@ "severity": "ERROR" }, { - "line": 350, + "line": 344, "column": 8, - "endLine": 350, + "endLine": 344, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -935,9 +755,9 @@ "severity": "ERROR" }, { - "line": 358, + "line": 351, "column": 23, - "endLine": 358, + "endLine": 351, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -945,19 +765,9 @@ "severity": "ERROR" }, { - "line": 359, - "column": 9, - "endLine": 359, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 360, + "line": 353, "column": 8, - "endLine": 360, + "endLine": 353, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -965,9 +775,9 @@ "severity": "ERROR" }, { - "line": 364, + "line": 357, "column": 8, - "endLine": 364, + "endLine": 357, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -975,9 +785,9 @@ "severity": "ERROR" }, { - "line": 371, + "line": 363, "column": 21, - "endLine": 371, + "endLine": 363, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -985,19 +795,19 @@ "severity": "ERROR" }, { - "line": 372, - "column": 9, - "endLine": 372, - "endColumn": 14, - "problem": "SwitchExpression", + "line": 365, + "column": 8, + "endLine": 365, + "endColumn": 9, + "problem": "NumericSemantics", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 373, + "line": 369, "column": 8, - "endLine": 373, + "endLine": 369, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -1005,10 +815,10 @@ "severity": "ERROR" }, { - "line": 377, - "column": 8, - "endLine": 377, - "endColumn": 9, + "line": 407, + "column": 10, + "endLine": 407, + "endColumn": 11, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets b/ets2panda/linter/test/main/ts-like-catch-type.ets index 84b0d23a1013b25ac660b387dfc8efac51ccad44..1f16edc96f4fbfdb718a594c5328f327d9cfa53c 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets @@ -14,6 +14,7 @@ */ import { BusinessError } from '@ohos.base'; +import { AError, AError1, BError, BError1 } from "./ts-like-catch-type111"; try { throw new Error(); @@ -31,4 +32,184 @@ try { let that = 123; } catch (err: BusinessError) { console.log(err.toString()); +} + +class RpcException { + msg: string; + code: number; +} + +class RpcException1 { + msg: string; + code: number; +} + +// not extends Error +function a1() { + try { + throw new RpcException('msg', 1); + } catch (e) { + let errorCode = 1; + let errorMsg = ''; + if (e instanceof RpcException) { // error + errorMsg = e.msg; // not check + errorCode = e.code; // not check + } else if (e instanceof RpcException1) { // error + errorMsg = e.msg; // not check + errorCode = e.code; // not check + } else { + console.log('else prop: ' + e.prop); // error + console.log('else message: ' + e.message); // ok + } + // e instanceof RpcException / e.prop error + e instanceof RpcException ? e.msg : e.prop; + // e instanceof RpcException / e.prop error + e instanceof RpcException ? console.log('when true: ' + e.msg) : console.log('when false: ' + e.prop); + // e instanceof RpcException / e instanceof RpcException1 / e.prop error + e instanceof RpcException ? console.log('when true: ' + (e instanceof RpcException1 ? e.msg : e.code)) : console.log('when false: ' + (e instanceof RpcException1 ? e.msg : e.prop)); + // e instanceof RpcException / e instanceof RpcException1 + e instanceof RpcException ? console.log('when true: ' + (e instanceof RpcException1 ? e.msg : e.code)) : console.log('when false: ' + (e instanceof RpcException1 ? e.msg : e.message)); // error * 2 + console.log(errorMsg); + (e as RpcException).msg; // error + console.log('errorMsg: ' + (e as RpcException).msg); // error + const temp = e; + temp.prop; // error + console.log('errorMsg: ' + temp.prop); // error + const temp1 = e as RpcException; // error + temp1.msg; // not check + temp1.message; // not check + console.log('errorMsg: ' + temp1.message); // not check + } +} + +// import / not extends Error +function a2() { + try { + throw new BError('msg', 1); + } catch (e) { + let errorCode = 1; + let errorMsg = ''; + if (e instanceof BError) { // error + errorMsg = e.a; // not check + errorCode = e.code; // not check + } else if (e instanceof BError1) { // error + errorMsg = e.b; // not check + errorCode = e.message; // not check + } else { + console.log('else prop: ' + e.prop); // error + console.log('else message: ' + e.message); // ok + } + // e instanceof BError / e.prop error + e instanceof BError ? e.msg : e.prop; + // e instanceof BError / e.prop error + e instanceof BError ? console.log('when true: ' + e.msg) : console.log('when false: ' + e.prop); + // e instanceof BError / e instanceof BError1 / e.prop error + e instanceof BError ? console.log('when true: ' + (e instanceof BError1 ? e.msg : e.code)) : console.log('when false: ' + (e instanceof BError1 ? e.msg : e.prop)); + // e instanceof BError / e instanceof BError1 + e instanceof BError ? console.log('when true: ' + (e instanceof BError1 ? e.msg : e.code)) : console.log('when false: ' + (e instanceof BError1 ? e.msg : e.message)); + console.log(errorMsg); + (e as BError).msg; // error + console.log('errorMsg: ' + (e as BError).msg); // error + const temp = e; + temp.prop; // error + console.log('errorMsg: ' + temp.prop); // error + const temp1 = e as BError; // error + temp1.msg; // not check + temp1.message; // not check + console.log('errorMsg: ' + temp1.message); // not check + } +} + +class RpcException2 extends Error { + msg: string; + code: number; + constructor(msg: string, code: number) { + super(msg); + this.msg = msg; + this.code = code; + } +} + +class RpcException3 extends Error { + msg: string; + code: number; + constructor(msg: string, code: number) { + super(msg); + this.msg = msg; + this.code = code; + } +} + +// extends Error +function a3() { + try { + throw new RpcException2(); + } catch (e) { + let errorCode = 1; + let errorMsg = ''; + if (e instanceof RpcException2) { + errorMsg = e.msg; + errorCode = e.code; + console.log('a3: ' + e.prop); // error + } else if (e instanceof RpcException3) { + errorMsg = e.msg; + errorCode = e.code; + } else { + console.log('else prop: ' + e.prop); // error + console.log('else message: ' + e.message); // ok + } + e instanceof RpcException2 ? e.msg : e.prop; // e.prop error + e instanceof RpcException2 ? console.log('when true: ' + e.msg) : console.log('when false: ' + e.prop); // e.prop error + // e.msg1 / e.prop error + e instanceof RpcException2 ? console.log('when true: ' + (e instanceof RpcException3 ? e.msg1 : e.code)) : console.log('when false: ' + (e instanceof RpcException3 ? e.msg : e.prop)); + e instanceof RpcException2 ? console.log('when true: ' + (e instanceof RpcException3 ? e.msg : e.code)) : console.log('when false: ' + (e instanceof RpcException3 ? e.msg : e.message)); + console.log(errorMsg); + (e as RpcException2).msg; // ok + console.log('errorMsg: ' + (e as RpcException2).msg); // ok + const temp = e; + temp.prop; // error + console.log('errorMsg: ' + temp.prop); // error + const temp1 = e as RpcException2; + temp1.msg; // ok + temp1.message; // ok + console.log('errorMsg: ' + temp1.message); // ok + console.log('errorMsg: ' + temp1.prop); // error + } +} + +// import / extends Error +function a4() { + try { + throw new AError('msg'); + } catch (e) { + let errorCode = 1; + let errorMsg = ''; + if (e instanceof AError) { + errorMsg = e.customProp; + errorCode = e.code; + console.log('a4: ' + e.prop); // error + } else if (e instanceof AError1) { + errorMsg = e.customProp; + errorCode = e.code; + } else { + console.log('else prop: ' + e.prop); // error + console.log('else message: ' + e.message); // ok + } + e instanceof AError ? e.customProp : e.prop; // e.prop error + e instanceof AError ? console.log('when true: ' + e.customProp) : console.log('when false: ' + e.prop); // e.prop error + // e.customProp1 / e.prop error + e instanceof AError ? console.log('when true: ' + (e instanceof AError1 ? e.customProp1 : e.code)) : console.log('when false: ' + (e instanceof AError1 ? e.customProp : e.prop)); + e instanceof AError ? console.log('when true: ' + (e instanceof AError1 ? e.customProp : e.code)) : console.log('when false: ' + (e instanceof AError1 ? e.customProp : e.message)); + console.log(errorMsg); + (e as AError).customProp; // ok + console.log('errorMsg: ' + (e as AError).customProp); // ok + const temp = e; + temp.prop; // error + console.log('errorMsg: ' + temp.prop); // error + const temp1 = e as AError; + temp1.customProp; // ok + temp1.message; // ok + console.log('errorMsg: ' + temp1.message); // ok + console.log('errorMsg: ' + temp1.prop); // error + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json b/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json index e77370a4f37a5496ceced5b0ed9c1088a0f396a3..8decc568f8ed3c830d4bdf3fdc409fa70bf9643d 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 22, + "line": 23, "column": 3, - "endLine": 22, + "endLine": 23, "endColumn": 9, "problem": "TsLikeCatchType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 7, - "endLine": 31, + "endLine": 32, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 14, - "endLine": 31, + "endLine": 32, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -45,14 +45,734 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 10, - "endLine": 32, + "endLine": 33, "endColumn": 28, "problem": "CatchWithUnsupportedType", "suggest": "", "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", "severity": "ERROR" + }, + { + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 38, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 35, + "endLine": 50, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 9, + "endLine": 54, + "endColumn": 34, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 16, + "endLine": 57, + "endColumn": 42, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 35, + "endLine": 61, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 5, + "endLine": 65, + "endColumn": 30, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 41, + "endLine": 65, + "endColumn": 47, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 30, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 99, + "endLine": 67, + "endColumn": 105, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 5, + "endLine": 69, + "endColumn": 30, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 141, + "endLine": 69, + "endColumn": 167, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 178, + "endLine": 69, + "endColumn": 184, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 5, + "endLine": 71, + "endColumn": 30, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 141, + "endLine": 71, + "endColumn": 167, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 6, + "endLine": 73, + "endColumn": 23, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 33, + "endLine": 74, + "endColumn": 50, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 5, + "endLine": 76, + "endColumn": 14, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 32, + "endLine": 77, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 19, + "endLine": 78, + "endColumn": 36, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 21, + "endLine": 52, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 11, + "endLine": 75, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 5, + "endLine": 88, + "endColumn": 32, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 29, + "endLine": 88, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 28, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 16, + "endLine": 95, + "endColumn": 36, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 35, + "endLine": 99, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 5, + "endLine": 103, + "endColumn": 24, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 35, + "endLine": 103, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 5, + "endLine": 105, + "endColumn": 24, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 93, + "endLine": 105, + "endColumn": 99, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 5, + "endLine": 107, + "endColumn": 24, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 129, + "endLine": 107, + "endColumn": 149, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 160, + "endLine": 107, + "endColumn": 166, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 5, + "endLine": 109, + "endColumn": 24, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 129, + "endLine": 109, + "endColumn": 149, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 6, + "endLine": 111, + "endColumn": 17, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 33, + "endLine": 112, + "endColumn": 44, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 5, + "endLine": 114, + "endColumn": 14, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 32, + "endLine": 115, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 19, + "endLine": 116, + "endColumn": 30, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 9, + "endLine": 90, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 21, + "endLine": 90, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 11, + "endLine": 113, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 28, + "endLine": 153, + "endColumn": 34, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 158, + "column": 35, + "endLine": 158, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 42, + "endLine": 161, + "endColumn": 48, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 100, + "endLine": 162, + "endColumn": 106, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 92, + "endLine": 164, + "endColumn": 98, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 180, + "endLine": 164, + "endColumn": 186, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 170, + "column": 5, + "endLine": 170, + "endColumn": 14, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 171, + "column": 32, + "endLine": 171, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 32, + "endLine": 176, + "endColumn": 42, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 9, + "endLine": 148, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 21, + "endLine": 148, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 11, + "endLine": 169, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 190, + "column": 28, + "endLine": 190, + "endColumn": 34, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 195, + "column": 35, + "endLine": 195, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 198, + "column": 42, + "endLine": 198, + "endColumn": 48, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 199, + "column": 100, + "endLine": 199, + "endColumn": 106, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 79, + "endLine": 201, + "endColumn": 92, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 175, + "endLine": 201, + "endColumn": 181, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 207, + "column": 5, + "endLine": 207, + "endColumn": 14, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 208, + "column": 32, + "endLine": 208, + "endColumn": 41, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 213, + "column": 32, + "endLine": 213, + "endColumn": 42, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 185, + "column": 9, + "endLine": 185, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 185, + "column": 21, + "endLine": 185, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 206, + "column": 11, + "endLine": 206, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 3, + "endLine": 38, + "endColumn": 6, + "problem": "StrictDiagnostic", + "suggest": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 39, + "column": 3, + "endLine": 39, + "endColumn": 7, + "problem": "StrictDiagnostic", + "suggest": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 43, + "column": 3, + "endLine": 43, + "endColumn": 6, + "problem": "StrictDiagnostic", + "suggest": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 7, + "problem": "StrictDiagnostic", + "suggest": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets.json b/ets2panda/linter/test/main/ts-like-catch-type.ets.json index 50c51fe19411b014e6cc71deb314c017d82264c3..e5a6b2de816142f498549720a3e6eab81ef06e9d 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets.json +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets.json @@ -15,14 +15,114 @@ ], "result": [ { - "line": 32, + "line": 33, "column": 10, - "endLine": 32, + "endLine": 33, "endColumn": 28, "problem": "CatchWithUnsupportedType", "suggest": "", "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", "severity": "ERROR" + }, + { + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 38, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 11, + "endLine": 75, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 5, + "endLine": 88, + "endColumn": 32, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 11, + "endLine": 113, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 11, + "endLine": 169, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 206, + "column": 11, + "endLine": 206, + "endColumn": 19, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 3, + "endLine": 38, + "endColumn": 6, + "problem": "StrictDiagnostic", + "suggest": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 39, + "column": 3, + "endLine": 39, + "endColumn": 7, + "problem": "StrictDiagnostic", + "suggest": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 43, + "column": 3, + "endLine": 43, + "endColumn": 6, + "problem": "StrictDiagnostic", + "suggest": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'msg' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 7, + "problem": "StrictDiagnostic", + "suggest": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'code' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type111.ts b/ets2panda/linter/test/main/ts-like-catch-type111.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c483947ad0a3ea53d285f1c5f3af29f5a14bbd8 --- /dev/null +++ b/ets2panda/linter/test/main/ts-like-catch-type111.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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. +*/ + +export class AError extends Error { + customProp: string; + constructor(message: string) { + super(message); + this.customProp = "custom"; + } +} + +export class AError1 extends Error { + customProp: string; + constructor(message: string) { + super(message); + this.customProp = "custom"; + } +} + +export class BError { + msg: string; + code: number; + constructor(msg: string, code: number) { + this.msg = msg; + this.code = code; + } +} + +export class BError1 { + msg: string; + code: number; + constructor(msg: string, code: number) { + this.msg = msg; + this.code = code; + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type111.ts.args.json b/ets2panda/linter/test/main/ts-like-catch-type111.ts.args.json new file mode 100644 index 0000000000000000000000000000000000000000..b87ffd2bb39b887f217040e1b8dfdd4aeebffb03 --- /dev/null +++ b/ets2panda/linter/test/main/ts-like-catch-type111.ts.args.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "commonArgs": "--no-check-ts-as-source" +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type111.ts.json b/ets2panda/linter/test/main/ts-like-catch-type111.ts.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/ts-like-catch-type111.ts.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts b/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf71890e70f66a55e52e5cc7d90ca8f1207ca921 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 { BuilderNode } from './@ohos.arkui.node'; +export { BuilderNode }; \ No newline at end of file diff --git a/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts b/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbf489a77f1f965c1b646aa2e464ea4a2ce2b206 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export { BuilderNode } from './BuilderNode'; \ No newline at end of file diff --git a/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts b/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae79a092ff2c1ab1330a7637f53ae2f24c20ea26 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export class BuilderNode { + build(): void; + update(): void; + reuse(): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/undefined_check_calls.ets.json b/ets2panda/linter/test/main/undefined_check_calls.ets.json index 5f20af3a4401e4c627ee4aea349b20b309373644..2085f45b054f42c324cfb371cebe43666612f6ab 100644 --- a/ets2panda/linter/test/main/undefined_check_calls.ets.json +++ b/ets2panda/linter/test/main/undefined_check_calls.ets.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2023-2024 Huawei Device Co., Ltd.", + "Copyright (c) 2023-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", @@ -30,8 +30,8 @@ "endLine": 51, "endColumn": 60, "problem": "StrictDiagnostic", - "suggest": "Argument of type 'string | undefined' is not assignable to parameter of type 'ResourceStr'.", - "rule": "Argument of type 'string | undefined' is not assignable to parameter of type 'ResourceStr'.", + "suggest": "Argument of type 'string | undefined' is not assignable to parameter of type 'ResourceStr'.\n Type 'undefined' is not assignable to type 'ResourceStr'.", + "rule": "Argument of type 'string | undefined' is not assignable to parameter of type 'ResourceStr'.\n Type 'undefined' is not assignable to type 'ResourceStr'.", "severity": "ERROR" }, { @@ -100,8 +100,8 @@ "endLine": 92, "endColumn": 15, "problem": "StrictDiagnostic", - "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.", - "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.", + "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", + "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", "severity": "WARNING" }, { @@ -120,8 +120,8 @@ "endLine": 99, "endColumn": 15, "problem": "StrictDiagnostic", - "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.", - "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.", + "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", + "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", "severity": "ERROR" }, { @@ -130,8 +130,8 @@ "endLine": 105, "endColumn": 15, "problem": "StrictDiagnostic", - "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.", - "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.", + "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", + "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", "severity": "ERROR" }, { @@ -140,9 +140,9 @@ "endLine": 106, "endColumn": 15, "problem": "StrictDiagnostic", - "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.", - "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.", + "suggest": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", + "rule": "Type 'TestClassC' is not assignable to type 'TestClassD'.\n Types of property 'ccc' are incompatible.\n Type 'null' is not assignable to type 'string'.", "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/void_operator.ets.autofix.json b/ets2panda/linter/test/main/void_operator.ets.autofix.json index 517ba65f3afc2c9d7aaf7505eed7645eefb1a281..12662791b0d03735dd0cac102b5a5845e0a3a21b 100644 --- a/ets2panda/linter/test/main/void_operator.ets.autofix.json +++ b/ets2panda/linter/test/main/void_operator.ets.autofix.json @@ -744,9 +744,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1090, - "end": 1095, - "replacementText": "a: number = 1", + "start": 1091, + "end": 1091, + "replacementText": ": number", "line": 55, "column": 7, "endLine": 55, @@ -807,9 +807,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1116, - "end": 1129, - "replacementText": "b: number[] = [1, 2, 3]", + "start": 1117, + "end": 1117, + "replacementText": ": number[]", "line": 58, "column": 7, "endLine": 58, diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2d7d44538b3d84143b3ed15dbbf65e447675560 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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. + */ + +@Builder +function MyBuilder(value: string, size: number) { + Text(value) + .fontSize(size) +} + +const wrappedBuilder1: WrappedBuilder<[string, number]> = wrapBuilder(MyBuilder); +const wrappedBuilder2: WrappedBuilder<[string, number]> = wrapBuilder<[string, number]>(MyBuilder); +const wrappedBuilder3: WrappedBuilder<[string, number]> = new WrappedBuilder(MyBuilder); +const wrappedBuilder4: WrappedBuilder<[string, number]> = new WrappedBuilder<[string, number]>(MyBuilder); + +@Entry +@Component +struct TestWrappedBuilder1 { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + wrappedBuilder1.builder(this.message, 50) + wrappedBuilder2.builder(this.message, 50) + wrappedBuilder3.builder(this.message, 50) + wrappedBuilder4.builder(this.message, 50) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.args.json b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..d8d3390ad9befeca9b595017d9eea0f5ada3d049 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1c422977b254cf24de2672ba19d19aad0a6f135b --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json @@ -0,0 +1,278 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 22, + "column": 24, + "endLine": 22, + "endColumn": 56, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 24, + "endLine": 23, + "endColumn": 56, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 59, + "endLine": 23, + "endColumn": 99, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 24, + "endLine": 24, + "endColumn": 56, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 59, + "endLine": 24, + "endColumn": 88, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 63, + "endLine": 24, + "endColumn": 77, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 24, + "endLine": 25, + "endColumn": 56, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 59, + "endLine": 25, + "endColumn": 106, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 63, + "endLine": 25, + "endColumn": 77, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 47, + "endLine": 35, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 47, + "endLine": 36, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 47, + "endLine": 37, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 47, + "endLine": 38, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 24, + "endLine": 22, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 24, + "endLine": 23, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 24, + "endLine": 24, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 63, + "endLine": 24, + "endColumn": 77, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 24, + "endLine": 25, + "endColumn": 38, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 63, + "endLine": 25, + "endColumn": 77, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 2, + "endLine": 27, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 2, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 4, + "endLine": 30, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 7, + "endLine": 34, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.json b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a55bd24a7f326595c0ffef8f3e4520df68bd78a --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 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. + */ + +@Builder +function MyBuilder(value: string, size: number) { + Text(value) + .fontSize(size) +} + +@Builder +function YourBuilder(value: string, size: number) { + Text(value) + .fontSize(size) + .fontColor(Color.Pink) +} + +const builderArr1: WrappedBuilder<[string, number]>[] = [wrapBuilder(MyBuilder), wrapBuilder(YourBuilder)]; +const builderArr2: WrappedBuilder<[string, number]>[] = [wrapBuilder<[string, number]>(MyBuilder), wrapBuilder<[string, number]>(YourBuilder)]; +const builderArr3: WrappedBuilder<[string, number]>[] = [new WrappedBuilder(MyBuilder), new WrappedBuilder(YourBuilder)]; +const builderArr4: WrappedBuilder<[string, number]>[] = [new WrappedBuilder<[string, number]>(MyBuilder), new WrappedBuilder<[string, number]>(YourBuilder)]; + +@Entry +@Component +struct Index { + @Builder + testBuilder() { + ForEach(builderArr1, (item: WrappedBuilder<[string, number]>) => { + item.builder('Hello World', 30) + }) + ForEach(builderArr2, (item: WrappedBuilder<[string, number]>) => { + item.builder('Hello World', 30) + }) + ForEach(builderArr3, (item: WrappedBuilder<[string, number]>) => { + item.builder('Hello World', 30) + }) + ForEach(builderArr4, (item: WrappedBuilder<[string, number]>) => { + item.builder('Hello World', 30) + }) + } + + build() { + Row() { + Column() { + this.testBuilder() + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.args.json b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..d8d3390ad9befeca9b595017d9eea0f5ada3d049 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..735f83a19040fec8cf34dad391dad78b8fa560d0 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json @@ -0,0 +1,498 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [ + { + "line": 29, + "column": 20, + "endLine": 29, + "endColumn": 52, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 20, + "endLine": 30, + "endColumn": 52, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 58, + "endLine": 30, + "endColumn": 98, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 100, + "endLine": 30, + "endColumn": 142, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 20, + "endLine": 31, + "endColumn": 52, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 58, + "endLine": 31, + "endColumn": 87, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 62, + "endLine": 31, + "endColumn": 76, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 89, + "endLine": 31, + "endColumn": 120, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 93, + "endLine": 31, + "endColumn": 107, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 20, + "endLine": 32, + "endColumn": 52, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 58, + "endLine": 32, + "endColumn": 105, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 62, + "endLine": 32, + "endColumn": 76, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 107, + "endLine": 32, + "endColumn": 156, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 111, + "endLine": 32, + "endColumn": 125, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 33, + "endLine": 39, + "endColumn": 65, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 35, + "endLine": 40, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 33, + "endLine": 42, + "endColumn": 65, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 35, + "endLine": 43, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 33, + "endLine": 45, + "endColumn": 65, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 35, + "endLine": 46, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 65, + "problem": "WrappedBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 35, + "endLine": 49, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 2, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 16, + "endLine": 26, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 20, + "endLine": 29, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 20, + "endLine": 30, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 20, + "endLine": 31, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 62, + "endLine": 31, + "endColumn": 76, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 93, + "endLine": 31, + "endColumn": 107, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 20, + "endLine": 32, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 62, + "endLine": 32, + "endColumn": 76, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 111, + "endLine": 32, + "endColumn": 125, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 2, + "endLine": 34, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 2, + "endLine": 35, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 4, + "endLine": 37, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 5, + "endLine": 39, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 33, + "endLine": 39, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 33, + "endLine": 42, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 33, + "endLine": 45, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"WrappedBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 7, + "endLine": 55, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.json b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 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." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json index d351a537bd6a910bd2443741e098df05f14db2d7..76d25532694166291452e1d717bbc7c68b7b324b 100644 --- a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json @@ -194,6 +194,16 @@ "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", "severity": "ERROR" }, + { + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 37, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 54, "column": 15, @@ -425,4 +435,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/lsp/BUILD.gn b/ets2panda/lsp/BUILD.gn index 78dec71308cb8958669941d823fa4f3e3ce87f48..611d4b7fc6a35788c56e198f33bc0b43756930e9 100644 --- a/ets2panda/lsp/BUILD.gn +++ b/ets2panda/lsp/BUILD.gn @@ -11,7 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} if (ark_standalone_build) { import("$build_root/ark.gni") @@ -81,15 +87,19 @@ ohos_source_set("libes2panda_lsp_static") { "src/refactors/refactor_types.cpp", "src/references.cpp", "src/register_code_fix/add_missing_declare_property.cpp", - "src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp", + "src/register_code_fix/add_missing_new_operator.cpp", "src/register_code_fix/convert_const_to_let.cpp", + "src/register_code_fix/fix_add_function_return_statement.cpp", + "src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp", + "src/register_code_fix/fix_expected_comma.cpp", "src/register_code_fix/fix_missing_call_parantheses.cpp", "src/register_code_fix/fix_nan_equality.cpp", - "src/register_code_fix/forgetten_this_property_access.cpp", + "src/register_code_fix/fix_return_type_in_async_function.cpp", + "src/register_code_fix/forgotten_this_property_access.cpp", "src/register_code_fix/import_fixes.cpp", "src/register_code_fix/remove_accidental_call_parentheses.cpp", - "src/rename.cpp", "src/register_code_fix/ui_plugin_suggest.cpp", + "src/rename.cpp", "src/script_element_kind.cpp", "src/services/services.cpp", "src/services/text_change/change_tracker.cpp", @@ -101,13 +111,20 @@ ohos_source_set("libes2panda_lsp_static") { "src/todo_comments.cpp", "src/types.cpp", ] - configs = [ + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } + configs += [ "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", "../:libes2panda_public_config", "../:libes2panda_config", "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libarkfile:arkfile_public_config", ":libes2panda_lsp_config", ] diff --git a/ets2panda/lsp/CMakeLists.txt b/ets2panda/lsp/CMakeLists.txt index bb3d59457c48eef00230ab2c6729276cd534dbc4..c152fd89c3e3e84c6c4c93d971020c985e06332e 100644 --- a/ets2panda/lsp/CMakeLists.txt +++ b/ets2panda/lsp/CMakeLists.txt @@ -110,14 +110,18 @@ set(ES2PANDA_LSP_SRC ./src/types.cpp ./src/navigate_to.cpp ./src/code_fix_provider.cpp + ./src/register_code_fix/add_missing_new_operator.cpp ./src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp + ./src/register_code_fix/fix_expected_comma.cpp + ./src/register_code_fix/fix_return_type_in_async_function.cpp ./src/register_code_fix/add_missing_declare_property.cpp ./src/register_code_fix/convert_const_to_let.cpp ./src/register_code_fix/fix_missing_call_parantheses.cpp ./src/register_code_fix/fix_nan_equality.cpp - ./src/register_code_fix/forgetten_this_property_access.cpp + ./src/register_code_fix/forgotten_this_property_access.cpp ./src/register_code_fix/import_fixes.cpp ./src/register_code_fix/remove_accidental_call_parentheses.cpp + ./src/register_code_fix/fix_add_function_return_statement.cpp ./src/register_code_fix/ui_plugin_suggest.cpp ./src/get_name_or_dotted_name_span.cpp ) diff --git a/ets2panda/lsp/include/api.h b/ets2panda/lsp/include/api.h index e1fbb8e8e19146dfad6b6b14b606a560da601cef..ffe9c4741c60150aa7ff92c1530db8f7921e3c5e 100644 --- a/ets2panda/lsp/include/api.h +++ b/ets2panda/lsp/include/api.h @@ -545,6 +545,7 @@ typedef struct LSPAPI { ark::es2panda::lsp::CancellationToken *cancellationToken); InlayHintList (*provideInlayHints)(es2panda_Context *context, const TextSpan *span); SignatureHelpItems (*getSignatureHelpItems)(es2panda_Context *context, size_t position); + size_t (*getOffsetByColAndLine)(es2panda_Context *context, size_t line, size_t column); std::vector (*getCodeFixesAtPosition)(es2panda_Context *context, size_t start_position, size_t end_position, std::vector &errorCodes, CodeFixOptions &codeFixOptions); diff --git a/ets2panda/lsp/include/code_fixes/code_fix_types.h b/ets2panda/lsp/include/code_fixes/code_fix_types.h index 3f88578046b9fe17f16486bc3b9e3d7683383b72..31ce206b8ec90f70cb7b49b51dfbb7356336faaa 100644 --- a/ets2panda/lsp/include/code_fixes/code_fix_types.h +++ b/ets2panda/lsp/include/code_fixes/code_fix_types.h @@ -31,6 +31,7 @@ #include "public/es2panda_lib.h" #include "public/public.h" #include "../get_class_property_info.h" +#include "lsp/include/services/text_change/text_change_context.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/include/formatting/formatting.h b/ets2panda/lsp/include/formatting/formatting.h index 32a89e7eab5c0dce253b24d8e33032fc25c9030a..4edb858971153e4c2da007ad2a51a91a535003f6 100644 --- a/ets2panda/lsp/include/formatting/formatting.h +++ b/ets2panda/lsp/include/formatting/formatting.h @@ -16,8 +16,10 @@ #ifndef FORMATTING_H #define FORMATTING_H +#include #include "formatting_settings.h" #include "rules_map.h" +#include "lsp/include/types.h" namespace ark::es2panda::lsp { @@ -44,6 +46,7 @@ private: }; FormatContext GetFormatContext(FormatCodeSettings &options); +std::vector FormatDocument(es2panda_Context *context, FormatContext formatContext); } // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/include/formatting/formatting_context.h b/ets2panda/lsp/include/formatting/formatting_context.h index 0748a440fbda948fd4d639c5573d64f3eca25ba3..49e725f0500f99aa46fc9a2b5c367eca54d5821f 100644 --- a/ets2panda/lsp/include/formatting/formatting_context.h +++ b/ets2panda/lsp/include/formatting/formatting_context.h @@ -2,9 +2,9 @@ * Copyright (c) 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* + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.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, @@ -17,99 +17,42 @@ #define FORMATTING_CONTEXT_H #include "ir/astNode.h" -#include "formatting_settings.h" +#include "lexer/token/token.h" +#include namespace ark::es2panda::lsp { -enum class FormattingRequestKind { - FORMAT_DOCUMENT, - FORMAT_SELECTION, - FORMAT_ON_ENTER, - FORMAT_ON_SEMICOLON, - FORMAT_ON_OPENING_CURLY_BRACE, - FORMAT_ON_CLOSING_CURLY_BRACE, -}; - -struct RangeWithKind : lexer::SourceRange { -private: - ir::AstNodeType kind_; - +class FormattingContext { public: - explicit RangeWithKind(lexer::SourcePosition startPos = lexer::SourcePosition(), - lexer::SourcePosition endPos = lexer::SourcePosition(), - ir::AstNodeType nodeKind = ir::AstNodeType::DUMMYNODE) - : lexer::SourceRange(startPos, endPos), kind_(nodeKind) - { - } - - const ir::AstNodeType &GetKind() - { - return kind_; - } -}; - -struct FormattingContext { -public: - explicit FormattingContext(FormattingRequestKind requestKind, FormatCodeSettings &formatSettings); - - void UpdateContext(es2panda_Context *context, RangeWithKind ¤tToken, RangeWithKind &nextToken); + explicit FormattingContext(const std::string &sourceText); + + void SetCurrentToken(const lexer::Token &token); + void SetPreviousToken(const lexer::Token &token); + void SetNextToken(const lexer::Token &token); + void SetCurrentTokenParent(ir::AstNode *node); + void SetNextTokenParent(ir::AstNode *node); + + const lexer::Token &GetCurrentToken() const; + const lexer::Token &GetPreviousToken() const; + const lexer::Token &GetNextToken() const; + ir::AstNode *GetCurrentTokenParent() const; + ir::AstNode *GetNextTokenParent() const; + const std::string &GetSourceText() const; + const lexer::SourceRange &GetCurrentTokenSpan() const; - bool ContextNodeAllOnSameLine() const; - bool NextNodeAllOnSameLine() const; - bool TokensAreOnSameLine() const; bool ContextNodeBlockIsOnOneLine() const; - bool NextNodeBlockIsOnOneLine() const; - - const RangeWithKind &GetCurrentTokenSpan() const - { - return currentTokenSpan_; - } - const RangeWithKind &GetNextTokenSpan() const - { - return nextTokenSpan_; - } - - ir::AstNode *GetContextNode() const - { - return contextNode_; - } - ir::AstNode *GetCurrentTokenParent() const - { - return currentTokenParent_; - } - ir::AstNode *GetNextTokenParent() const - { - return nextTokenParent_; - } - - FormatCodeSettings GetFormatCodeSettings() - { - return formatCodeSettings_; - } - - FormattingRequestKind GetformattingRequestKind() - { - return formattingRequestKind_; - } + bool TokensAreOnSameLine() const; private: - bool NodeIsOnOneLine(ir::AstNode *node) const; bool BlockIsOnOneLine(ir::AstNode *node) const; - - bool contextNodeAllOnSameLine_ = false; - bool nextNodeAllOnSameLine_ = false; - bool tokensAreOnSameLine_ = false; - bool contextNodeBlockIsOnOneLine_ = false; - bool nextNodeBlockIsOnOneLine_ = false; - - RangeWithKind currentTokenSpan_; - RangeWithKind nextTokenSpan_; - ir::AstNode *contextNode_ = nullptr; - ir::AstNode *currentTokenParent_ = nullptr; - ir::AstNode *nextTokenParent_ = nullptr; - - FormatCodeSettings formatCodeSettings_; - FormattingRequestKind formattingRequestKind_; + const std::string &sourceText_; + + lexer::Token currentToken_; + lexer::Token prevToken_; + lexer::Token nextToken_; + ir::AstNode *currentTokenParent_ {nullptr}; + ir::AstNode *nextTokenParent_ {nullptr}; + lexer::SourceRange currentTokenSpan_; }; } // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/include/formatting/rule.h b/ets2panda/lsp/include/formatting/rule.h index 3e9e10a1098557e29582ea6a5326546773ab67ca..0ede2cea53ae76e2c6c70fabc176c6c06a73ff3e 100644 --- a/ets2panda/lsp/include/formatting/rule.h +++ b/ets2panda/lsp/include/formatting/rule.h @@ -18,7 +18,8 @@ #include #include -#include "ir/astNode.h" +#include "generated/tokenType.h" +#include "lexer/lexer.h" #include "formatting_context.h" namespace ark::es2panda::lsp { @@ -40,7 +41,7 @@ enum class RuleFlags { NONE, CAN_DELETE_NEWLINES }; struct Rule { public: - explicit Rule(std::vector &cb, RuleAction action, RuleFlags flag) + explicit Rule(std::vector cb, RuleAction action, RuleFlags flag) : context_(std::move(cb)), action_(action), flags_(flag) { } @@ -68,12 +69,12 @@ private: struct TokenRange { public: - explicit TokenRange(std::vector &tokens, bool isSpecific) + explicit TokenRange(std::vector tokens, bool isSpecific) : tokens_(std::move(tokens)), isSpecific_(isSpecific) { } - std::vector &GetTokens() + std::vector &GetTokens() { return tokens_; } @@ -84,7 +85,7 @@ public: } private: - std::vector tokens_; + std::vector tokens_; bool isSpecific_; }; diff --git a/ets2panda/lsp/include/formatting/rules_map.h b/ets2panda/lsp/include/formatting/rules_map.h index 402b805216be1361f28fa3b22865f84a54d7b2af..fcb3c33d2edda2daade47f528e56417eafa66fd6 100644 --- a/ets2panda/lsp/include/formatting/rules_map.h +++ b/ets2panda/lsp/include/formatting/rules_map.h @@ -39,7 +39,7 @@ private: static RulesMap rulesMap_; - static RulesMap CreateRulesMap(std::vector ruleSpec); + static RulesMap CreateRulesMap(const std::vector &ruleSpec); }; } // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/include/internal_api.h b/ets2panda/lsp/include/internal_api.h index 02e4692c90a672bbd4da8d37d6bfa4df9b477f1b..e52b422cc87bf62f3793a741a10e806750af16d7 100644 --- a/ets2panda/lsp/include/internal_api.h +++ b/ets2panda/lsp/include/internal_api.h @@ -59,15 +59,16 @@ public: } es2panda_SuggestionInfo *CreateSuggestionInfo(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc, const char *substitutionCode) + const char **args, size_t argc, const char *substitutionCode, + es2panda_SourceRange *range) { - return impl_->CreateSuggestionInfo(context, kind, args, argc, substitutionCode); + return impl_->CreateSuggestionInfo(context, kind, args, argc, substitutionCode, range); } es2panda_DiagnosticInfo *CreateDiagnosticInfo(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc) + const char **args, size_t argc, es2panda_SourcePosition *pos) { - return impl_->CreateDiagnosticInfo(context, kind, args, argc); + return impl_->CreateDiagnosticInfo(context, kind, args, argc, pos); } es2panda_SourcePosition *CreateSourcePosition(es2panda_Context *context, size_t index, size_t line) @@ -82,9 +83,9 @@ public: } void LogDiagnosticWithSuggestion(es2panda_Context *context, const es2panda_DiagnosticInfo *diagnosticInfo, - const es2panda_SuggestionInfo *suggestionInfo, es2panda_SourceRange *range) + const es2panda_SuggestionInfo *suggestionInfo) { - return impl_->LogDiagnosticWithSuggestion(context, diagnosticInfo, suggestionInfo, range); + return impl_->LogDiagnosticWithSuggestion(context, diagnosticInfo, suggestionInfo); } void LogDiagnostic(es2panda_Context *context, const es2panda_DiagnosticKind *ekind, const char **args, size_t argc, @@ -109,7 +110,7 @@ ir::AstNode *FindPrecedingToken(const size_t pos, const ir::AstNode *startNode, ir::AstNode *GetIdentifierFromSuper(ir::AstNode *super); ir::AstNode *GetOriginalNode(ir::AstNode *astNode); checker::VerifiedType GetTypeOfSymbolAtLocation(checker::ETSChecker *checker, ir::AstNode *astNode); -FileDiagnostic CreateDiagnosticForNode(es2panda_AstNode *node, Diagnostic diagnostic, +FileDiagnostic CreateDiagnosticForNode(es2panda_AstNode *node, Diagnostic diagnostic, es2panda_Context *context, const std::vector &args = std::vector()); std::string GetCurrentTokenValueImpl(es2panda_Context *context, size_t position); void GetRangeOfEnclosingComment(es2panda_Context *context, size_t pos, CommentRange *result); @@ -139,6 +140,7 @@ ir::Identifier *GetIdentFromNewClassExprPart(const ir::Expression *value); varbinder::Decl *FindDeclInFunctionScope(varbinder::Scope *scope, const util::StringView &name); varbinder::Decl *FindDeclInGlobalScope(varbinder::Scope *scope, const util::StringView &name); varbinder::Decl *FindDeclInScopeWithFallback(varbinder::Scope *scope, const util::StringView &name); +std::string GetImportFilePath(es2panda_Context *context, size_t pos); } // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/include/isolated_declaration.h b/ets2panda/lsp/include/isolated_declaration.h index 7c1ac4d65c407d58d4fea9c43989c24f712c5099..ecf029c9877c1e5eac5afbcc0c3a45f1e4c3dc3e 100644 --- a/ets2panda/lsp/include/isolated_declaration.h +++ b/ets2panda/lsp/include/isolated_declaration.h @@ -21,6 +21,9 @@ namespace ark::es2panda::lsp { std::optional ProcessIdentifier(ir::Identifier *identifier, checker::ETSChecker *checker, parser::Program *program); +std::string GetReturnTypeStr(const checker::Type *checkerType, checker::ETSChecker *checker); +const checker::Signature *GetFuncSignature(const checker::ETSFunctionType *etsFunctionType, + const ir::MethodDefinition *methodDef); } // namespace ark::es2panda::lsp #endif \ No newline at end of file diff --git a/ets2panda/lsp/include/quick_info.h b/ets2panda/lsp/include/quick_info.h index 7c4075b6ae96f249d3af3261e10a1da6fe6ca953..a051b6a48f4455b7afcddc43196090c00ec185be 100644 --- a/ets2panda/lsp/include/quick_info.h +++ b/ets2panda/lsp/include/quick_info.h @@ -36,7 +36,8 @@ std::vector CreateDisplayForTypeAlias(ir::AstNode *node); std::vector CreateDisplayForEnum(ir::AstNode *node); std::vector CreateDisplayForEnumMember(ir::AstNode *node); std::vector CreateDisplayForTypeParameter(ir::AstNode *node); -std::vector CreateDisplayForMethodDefinition(ir::AstNode *node, const std::string &kindModifier); +std::vector CreateDisplayForMethodDefinition(ir::AstNode *node, const std::string &kindModifier, + checker::ETSChecker *checker); std::vector CreateDisplayForClassProperty(ir::AstNode *node); std::vector CreateDisplayForETSParameterExpression(ir::AstNode *node); QuickInfo GetQuickInfoAtPositionImpl(es2panda_Context *context, size_t position, std::string fileName); diff --git a/ets2panda/lsp/include/register_code_fix/add_missing_new_operator.h b/ets2panda/lsp/include/register_code_fix/add_missing_new_operator.h new file mode 100644 index 0000000000000000000000000000000000000000..8066643d074cbc5fab5ee71577aed40f807248bb --- /dev/null +++ b/ets2panda/lsp/include/register_code_fix/add_missing_new_operator.h @@ -0,0 +1,40 @@ +/** + Copyright (c) 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. + */ + +#ifndef FIX_ADD_MISSING_NEW_OPERATOR_H +#define FIX_ADD_MISSING_NEW_OPERATOR_H + +#include "lsp/include/code_fixes/code_fix_types.h" +#include "lsp/include/services/text_change/change_tracker.h" +#include "lsp/include/types.h" +#include +#include + +namespace ark::es2panda::lsp { +class FixAddMissingNewOperator : public CodeFixRegistration { +public: + FixAddMissingNewOperator(); + std::vector GetCodeActions(const CodeFixContext &context) override; + CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &codeFixAll) override; + static std::vector GetCodeActionsToFix(const CodeFixContext &context); + +private: + static void MakeChange(ChangeTracker &changeTracker, es2panda_Context *context, size_t pos, + std::vector &fixedNodes); + static bool IsValidTarget(const ir::AstNode *node); +}; + +} // namespace ark::es2panda::lsp +#endif // FIX_ADD_MISSING_NEW_OPERATOR_H \ No newline at end of file diff --git a/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h b/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h new file mode 100644 index 0000000000000000000000000000000000000000..f7f5189a99a846d629d1fca45c4cfc2dfe00f2a3 --- /dev/null +++ b/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h @@ -0,0 +1,69 @@ +/** + * Copyright (c) 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. + */ + +#ifndef FIX_ADD_FUNCTION_RETURN_STATEMENT_H +#define FIX_ADD_FUNCTION_RETURN_STATEMENT_H + +#include +#include "../services/text_change/change_tracker.h" +#include "lsp/include/types.h" +#include "lsp/include/code_fixes/code_fix_types.h" +#include "utils/arena_containers.h" + +namespace ark::es2panda::lsp { + +class FixAddFunctionReturnStatement : public CodeFixRegistration { +public: + FixAddFunctionReturnStatement(); + + std::vector GetCodeActions(const CodeFixContext &context) override; + + CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &ctx) override; +}; + +struct Info { +private: + ark::es2panda::ir::AstNode *returnTypeNode_; + ark::es2panda::ir::AstNode *body_; + std::vector statements_; + +public: + Info(ark::es2panda::ir::AstNode *returnTypeNode, ark::es2panda::ir::AstNode *body, + std::vector statements) + : returnTypeNode_(returnTypeNode), body_(body), statements_(std::move(statements)) + { + } + ark::es2panda::ir::AstNode *GetReturnTypeNode() const + { + return returnTypeNode_; + } + ark::es2panda::ir::AstNode *GetBody() const + { + return body_; + } + const std::vector &GetStatements() const + { + return statements_; + } +}; + +ir::AstNode *FindAncessor(ir::AstNode *node); +Info GetInfo(es2panda_Context *context, size_t position); +void ReplaceReturnType(ChangeTracker &changes, es2panda_Context *context, Info &info); +void AddReturnStatement(ChangeTracker &changes, es2panda_Context *context, std::vector statements, + ir::AstNode *body); + +} // namespace ark::es2panda::lsp +#endif diff --git a/ets2panda/lsp/include/register_code_fix/fix_expected_comma.h b/ets2panda/lsp/include/register_code_fix/fix_expected_comma.h new file mode 100644 index 0000000000000000000000000000000000000000..d1aea039ba220658cdf9d14f59f03ce2bb6ece13 --- /dev/null +++ b/ets2panda/lsp/include/register_code_fix/fix_expected_comma.h @@ -0,0 +1,37 @@ +/** + * Copyright (c) 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. + */ + +#ifndef FIX_EXPECTED_COMMA_H +#define FIX_EXPECTED_COMMA_H + +#include "lsp/include/services/text_change/change_tracker.h" +#include "lsp/include/code_fixes/code_fix_types.h" +#include "lsp/include/types.h" +#include "lsp/include/api.h" + +namespace ark::es2panda::lsp { + +class FixExpectedComma : public CodeFixRegistration { +public: + FixExpectedComma(); + std::vector GetCodeActions(const CodeFixContext &context) override; + CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &codeFixAll) override; + static std::vector GetCodeActionsToFix(const CodeFixContext &context); + static ir::AstNode *GetNodeAtLocation(es2panda_Context *context, Range range); + static void MakeChange(ChangeTracker &changeTracker, es2panda_Context *context, Range range, + const std::string &possibleFix); +}; +} // namespace ark::es2panda::lsp +#endif // FIX_EXPECTED_COMMA_H diff --git a/ets2panda/lsp/include/register_code_fix/forgetten_this_property_access.h b/ets2panda/lsp/include/register_code_fix/fix_return_type_in_async_function.h similarity index 66% rename from ets2panda/lsp/include/register_code_fix/forgetten_this_property_access.h rename to ets2panda/lsp/include/register_code_fix/fix_return_type_in_async_function.h index d5ea48b3195fad2cff697cf846cecb0af4919067..11f34d634d1a58548d6f7173632c606ab999803c 100644 --- a/ets2panda/lsp/include/register_code_fix/forgetten_this_property_access.h +++ b/ets2panda/lsp/include/register_code_fix/fix_return_type_in_async_function.h @@ -12,11 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef FIX_RETURN_TYPE_IN_ASYNC_FUNCTION_H +#define FIX_RETURN_TYPE_IN_ASYNC_FUNCTION_H -#ifndef FORGOTTEN_THIS_PROPERTY_ACCESS_H -#define FORGOTTEN_THIS_PROPERTY_ACCESS_H - -#include #include #include "lsp/include/code_fixes/code_fix_types.h" #include "lsp/include/services/text_change/change_tracker.h" @@ -24,14 +22,19 @@ namespace ark::es2panda::lsp { -class ForgettenThisPropertyAccess : public CodeFixRegistration { +class FixReturnTypeInAsyncFunction : public CodeFixRegistration { public: - ForgettenThisPropertyAccess(); + FixReturnTypeInAsyncFunction(); std::vector GetCodeActions(const CodeFixContext &context) override; + CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &codeFixAllCtx) override; + std::vector GetChanges(const CodeFixContext &context); + ir::AstNode *GetFunctionReturnType(es2panda_Context *context, size_t position); - CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &codeFixAll) override; +private: + void MakeChangeReturnTypeInAsyncFunction(ChangeTracker &changeTracker, es2panda_Context *context, size_t pos); }; } // namespace ark::es2panda::lsp + #endif diff --git a/ets2panda/lsp/src/register_code_fix/forgetten_this_property_access.cpp b/ets2panda/lsp/include/register_code_fix/forgotten_this_property_access.h similarity index 35% rename from ets2panda/lsp/src/register_code_fix/forgetten_this_property_access.cpp rename to ets2panda/lsp/include/register_code_fix/forgotten_this_property_access.h index c1bda5b238ae79e836cacf9dcebb4062e51f84b1..add5dcdfa74af79a18f05fc07c05ff19064b7cb4 100644 --- a/ets2panda/lsp/src/register_code_fix/forgetten_this_property_access.cpp +++ b/ets2panda/lsp/include/register_code_fix/forgotten_this_property_access.h @@ -13,39 +13,47 @@ * limitations under the License. */ -#include "lsp/include/register_code_fix/forgetten_this_property_access.h" -#include +#ifndef FORGOTTEN_THIS_PROPERTY_ACCESS_H +#define FORGOTTEN_THIS_PROPERTY_ACCESS_H + #include -#include "lsp/include/code_fix_provider.h" -#include "lsp/include/internal_api.h" +#include +#include "lsp/include/code_fixes/code_fix_types.h" +#include "public/es2panda_lib.h" +#include "lsp/include/services/text_change/change_tracker.h" namespace ark::es2panda::lsp { -const int G_FORGETTEN_THIS_PROPERTY_ACCESS_CODE = 1004; // change this to the error code you want to handle +class ForgottenThisPropertyAccess : public CodeFixRegistration { +public: + ForgottenThisPropertyAccess(); -ForgettenThisPropertyAccess::ForgettenThisPropertyAccess() -{ - const char *forgottenThisPropertAccesId = "ForgettenThisPropertyAccess"; - SetErrorCodes({G_FORGETTEN_THIS_PROPERTY_ACCESS_CODE}); // change this to the error code you want to handle - SetFixIds({forgottenThisPropertAccesId}); -} + std::vector GetCodeActions(const CodeFixContext &context) override; -std::vector ForgettenThisPropertyAccess::GetCodeActions(const CodeFixContext &context) -{ - std::vector returnedActions; - if (context.errorCode == G_FORGETTEN_THIS_PROPERTY_ACCESS_CODE) { - } - return returnedActions; -} + CombinedCodeActions GetAllCodeActions(const CodeFixAllContext &codeFixAll) override; +}; + +struct Info { +private: + ark::es2panda::ir::AstNode *node_; + std::string className_; + +public: + Info(ark::es2panda::ir::AstNode *node, std::string className) : node_(node), className_(std::move(className)) {} -CombinedCodeActions ForgettenThisPropertyAccess::GetAllCodeActions(const CodeFixAllContext &codeFixAll) -{ - CombinedCodeActions combinedCodeActions; - if (codeFixAll.fixId == "ForgettenThisPropertyAccess") { + ark::es2panda::ir::AstNode *GetNode() const + { + return node_; } + const std::string &GetClassName() const + { + return className_; + } +}; + +Info GetInfoThisProp(es2panda_Context *context, size_t offset); +void DoChanges(es2panda_Context *context, ChangeTracker tracker); - return combinedCodeActions; -} -// NOLINTNEXTLINE(fuchsia-statically-constructed-objects, cert-err58-cpp) -AutoCodeFixRegister g_forgettenThisPropertyAccess("ForgettenThisPropertyAccess"); } // namespace ark::es2panda::lsp + +#endif // FORGOTTEN_THIS_PROPERTY_ACCESS_H \ No newline at end of file diff --git a/ets2panda/lsp/include/services/text_change/change_tracker.h b/ets2panda/lsp/include/services/text_change/change_tracker.h index d5514d57d48e778af770f623b92be4b246c1fa23..d029a37b20d2e91925a4741ac043289b68aa373d 100644 --- a/ets2panda/lsp/include/services/text_change/change_tracker.h +++ b/ets2panda/lsp/include/services/text_change/change_tracker.h @@ -26,6 +26,7 @@ #include "public/public.h" #include #include +#include "text_change_context.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/include/services/text_change/text_change_context.h b/ets2panda/lsp/include/services/text_change/text_change_context.h new file mode 100644 index 0000000000000000000000000000000000000000..861d7b877c74c8af65769a9983cc9944ebfe1a8c --- /dev/null +++ b/ets2panda/lsp/include/services/text_change/text_change_context.h @@ -0,0 +1,32 @@ +/** + * Copyright (c) 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. + */ + +#ifndef TEXT_CHANGE_H +#define TEXT_CHANGE_H + +#include "lsp/include/formatting/formatting.h" +#include "lsp/include/user_preferences.h" + +struct LanguageServiceHost { + std::string name = "lsp"; +}; + +struct TextChangesContext { + LanguageServiceHost host = {}; + ark::es2panda::lsp::FormatContext formatContext; + ark::es2panda::lsp::UserPreferences preferences; +}; + +#endif \ No newline at end of file diff --git a/ets2panda/lsp/include/suggestion_diagnostics.h b/ets2panda/lsp/include/suggestion_diagnostics.h index 735d88ef0b1e3705292d1f097ec662bff531b036..0c447ac0ff9128bbfccbf91cc44df642cefb3d0e 100644 --- a/ets2panda/lsp/include/suggestion_diagnostics.h +++ b/ets2panda/lsp/include/suggestion_diagnostics.h @@ -25,10 +25,12 @@ namespace ark::es2panda::lsp { -std::vector GetSuggestionDiagnosticsImpl(ir::AstNode *astNode); -void Check(ir::AstNode *node, std::vector &diag, std::unordered_map &visitedFunc); +std::vector GetSuggestionDiagnosticsImpl(ir::AstNode *astNode, es2panda_Context *context); +void Check(ir::AstNode *node, std::vector &diag, std::unordered_map &visitedFunc, + es2panda_Context *context); void AddConvertToAsyncFunctionDiagnostics(ir::AstNode *node, std::vector &diag, - std::unordered_map &visitedFunc); + std::unordered_map &visitedFunc, + es2panda_Context *context); bool IsConvertibleFunction(ir::AstNode *node, std::unordered_map &visitedFunc); bool HasReturnStatementWithPromiseHandler(ir::AstNode *node, std::unordered_map &visitedFunc); bool IsReturnStatementWithFixablePromiseHandler(ir::AstNode *node, std::unordered_map &visitedFunc); diff --git a/ets2panda/lsp/include/types.h b/ets2panda/lsp/include/types.h index 438144e733adeacb158b09c643bef25431661f35..dab625c4a96aa614b2564ccafdccd60fc86d794b 100644 --- a/ets2panda/lsp/include/types.h +++ b/ets2panda/lsp/include/types.h @@ -19,8 +19,6 @@ #include #include #include -#include "formatting/formatting.h" -#include "user_preferences.h" // NOLINTBEGIN @@ -222,16 +220,6 @@ public: } }; -struct LanguageServiceHost { - std::string name = "lsp"; -}; - -struct TextChangesContext { - LanguageServiceHost host = {}; - ark::es2panda::lsp::FormatContext formatContext; - ark::es2panda::lsp::UserPreferences preferences; -}; - struct SignatureHelpItems { private: std::vector items_; diff --git a/ets2panda/lsp/src/api.cpp b/ets2panda/lsp/src/api.cpp index a514a83a25e7596c3648e1d8137caf1acf7a97fa..50a852b0288341046f00425797f66c6e10f5d16d 100644 --- a/ets2panda/lsp/src/api.cpp +++ b/ets2panda/lsp/src/api.cpp @@ -51,8 +51,15 @@ DefinitionInfo GetDefinitionAtPosition(es2panda_Context *context, size_t positio { auto ctx = reinterpret_cast(context); SetPhaseManager(ctx->phaseManager); + auto importFilePath = GetImportFilePath(context, position); + if (!importFilePath.empty()) { + return {importFilePath, 0, 0}; + } auto declInfo = GetDefinitionAtPositionImpl(context, position); DefinitionInfo result {}; + if (declInfo.first == nullptr) { + return result; + } auto node = declInfo.first; auto targetNode = declInfo.first->FindChild([&declInfo](ir::AstNode *childNode) { return childNode->IsIdentifier() && childNode->AsIdentifier()->Name() == declInfo.second; @@ -346,7 +353,7 @@ DiagnosticReferences GetSuggestionDiagnostics(es2panda_Context *context) auto ctx = reinterpret_cast(context); SetPhaseManager(ctx->phaseManager); auto ast = ctx->parserProgram->Ast(); - auto vec = GetSuggestionDiagnosticsImpl(ast); + auto vec = GetSuggestionDiagnosticsImpl(ast, context); res.diagnostic.reserve(vec.size()); for (const auto &diag : vec) { res.diagnostic.push_back(diag.diagnostic); @@ -425,6 +432,14 @@ SignatureHelpItems GetSignatureHelpItems(es2panda_Context *context, size_t posit auto cancellationToken = ark::es2panda::lsp::CancellationToken(defaultTime, nullptr); return ark::es2panda::lsp::GetSignatureHelpItems(context, position, invokedReason, cancellationToken); } + +size_t GetOffsetByColAndLine(es2panda_Context *context, size_t line, size_t column) +{ + auto ctx = reinterpret_cast(context); + auto index = lexer::LineIndex(ctx->parserProgram->SourceCode()); + return index.GetOffset(lexer::SourceLocation(line, column, ctx->parserProgram)); +} + std::vector GetCodeFixesAtPosition(es2panda_Context *context, size_t startPosition, size_t endPosition, std::vector &errorCodes, CodeFixOptions &codeFixOptions) @@ -487,6 +502,7 @@ LSPAPI g_lspImpl = {GetDefinitionAtPosition, GetTodoComments, ProvideInlayHints, GetSignatureHelpItems, + GetOffsetByColAndLine, GetCodeFixesAtPosition, GetCombinedCodeFix, GetNameOrDottedNameSpan}; diff --git a/ets2panda/lsp/src/completions_details.cpp b/ets2panda/lsp/src/completions_details.cpp index de85c72152384c4c04824958af9564389adf3782..c2c29da6cc058b5cad1ea902ff97218f66858192 100644 --- a/ets2panda/lsp/src/completions_details.cpp +++ b/ets2panda/lsp/src/completions_details.cpp @@ -32,51 +32,40 @@ namespace ark::es2panda::lsp::details { void GetDisplayPartAndKind(ir::AstNode *node, std::vector &displayParts, std::string &kind, - std::string &kindModifiers) + std::string &kindModifiers, checker::ETSChecker *checker) { if (IsClass(node)) { displayParts = ark::es2panda::lsp::CreateDisplayForClass(node); - kind = "class"; } else if (node->IsETSParameterExpression()) { displayParts = ark::es2panda::lsp::CreateDisplayForETSParameterExpression(node); - kind = "parameter"; } else if (node->IsClassProperty()) { // After enum refactoring, enum declaration is transformed to a class declaration if (compiler::ClassDefinitionIsEnumTransformed(node->Parent())) { auto enumDecl = node->Parent()->AsClassDefinition()->OrigEnumDecl()->AsTSEnumDeclaration(); auto enumMember = GetEnumMemberByName(enumDecl, node->AsClassProperty()->Key()->AsIdentifier()->Name()); displayParts = ark::es2panda::lsp::CreateDisplayForEnumMember(enumMember); - kind = "enum member"; } else { displayParts = ark::es2panda::lsp::CreateDisplayForClassProperty(node); - kind = "property"; } } else if (node->IsTSInterfaceDeclaration()) { displayParts = ark::es2panda::lsp::CreateDisplayForInterface(node); - kind = "interface"; } else if (node->IsTSTypeAliasDeclaration()) { displayParts = ark::es2panda::lsp::CreateDisplayForTypeAlias(node); - kind = "type alias"; } else if (node->IsTSEnumDeclaration()) { displayParts = ark::es2panda::lsp::CreateDisplayForEnum(node); - kind = "enum"; } else if (node->IsImportDeclaration()) { displayParts = CreateDisplayForImportDeclaration(node); - kind = "import"; } else if (node->IsTSTypeParameter()) { displayParts = ark::es2panda::lsp::CreateDisplayForTypeParameter(node); - kind = "type parameter"; } else if (node->IsMethodDefinition()) { - displayParts = ark::es2panda::lsp::CreateDisplayForMethodDefinition(node, kindModifiers); - kind = "function"; - if (node->Parent() != nullptr && node->Parent()->IsTSInterfaceBody()) { - kind = "property"; - } + displayParts = ark::es2panda::lsp::CreateDisplayForMethodDefinition(node, kindModifiers, checker); } + // Unify this kind + kind = GetNodeKindForRenameInfo(node); } CompletionEntryDetails GetCompletionEntryDetails(ir::AstNode *node, const std::string &entryName, - const std::string &fileName) + const std::string &fileName, checker::ETSChecker *checker) { if (node == nullptr) { return CompletionEntryDetails(); @@ -89,7 +78,7 @@ CompletionEntryDetails GetCompletionEntryDetails(ir::AstNode *node, const std::s std::vector source; std::vector sourceDisplay; - GetDisplayPartAndKind(node, displayParts, kind, kindModifiers); + GetDisplayPartAndKind(node, displayParts, kind, kindModifiers, checker); return CompletionEntryDetails(entryName, kind, kindModifiers, displayParts, document, source, sourceDisplay, fileName); @@ -106,6 +95,7 @@ CompletionEntryDetails GetCompletionEntryDetailsImpl(es2panda_Context *context, return CompletionEntryDetails(); } auto ctx = reinterpret_cast(context); + auto checker = reinterpret_cast(ctx->GetChecker()); auto ast = ctx->parserProgram->Ast(); auto leIdentifier = ast->FindChild([entryName](ir::AstNode *node) { return HasPropertyAccessExpressionWithName(node, entryName); }); @@ -116,7 +106,7 @@ CompletionEntryDetails GetCompletionEntryDetailsImpl(es2panda_Context *context, if (targetNode == nullptr) { return CompletionEntryDetails(); } - return GetCompletionEntryDetails(targetNode, entryName, fileName); + return GetCompletionEntryDetails(targetNode, entryName, fileName, checker); } } // namespace ark::es2panda::lsp::details \ No newline at end of file diff --git a/ets2panda/lsp/src/formatting/formatting.cpp b/ets2panda/lsp/src/formatting/formatting.cpp index f57e9eeba045f1a5250356180cba06cbd12e9dde..11973a8461a2a49edd29c57cc6edfd19570f1244 100644 --- a/ets2panda/lsp/src/formatting/formatting.cpp +++ b/ets2panda/lsp/src/formatting/formatting.cpp @@ -2,9 +2,9 @@ * Copyright (c) 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* + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.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, @@ -14,13 +14,193 @@ */ #include "formatting/formatting.h" +#include "formatting/formatting_context.h" #include "formatting/rules_map.h" +#include "internal_api.h" +#include "public/public.h" +#include "lexer/lexer.h" +#include "lexer/token/token.h" namespace ark::es2panda::lsp { +// NOLINTNEXTLINE +bool TokenMatch(std::vector &tokenRanges, lexer::TokenType tokenType) +{ + for (auto &range : tokenRanges) { + auto &tokens = range.GetTokens(); + if (tokens.empty() || std::find(tokens.begin(), tokens.end(), tokenType) != tokens.end()) { + return true; + } + } + return false; +} + +void ApplyInsertSpace(RuleAction action, const TextSpan &span, std::vector &changes) +{ + if ((static_cast(RuleAction::INSERT_SPACE) & static_cast(action)) != 0) { + changes.emplace_back(TextChange {span, " "}); + } +} + +void ApplyDeleteSpace(RuleAction action, const TextSpan &span, std::vector &changes) +{ + if ((static_cast(RuleAction::DELETE_SPACE) & static_cast(action)) != 0) { + if (span.length > 0) { + changes.emplace_back(TextChange {span, ""}); + } + } +} + +void ApplyInsertNewline(RuleAction action, const TextSpan &span, std::vector &changes) +{ + if ((static_cast(RuleAction::INSERT_NEWLINE) & static_cast(action)) != 0) { + changes.emplace_back(TextChange {span, "\n"}); + } +} + +void ApplyDeleteToken(RuleAction action, const lexer::SourceRange &tokenLoc, std::vector &changes) +{ + if ((static_cast(RuleAction::DELETE_TOKEN) & static_cast(action)) != 0) { + TextSpan span {tokenLoc.start.index, tokenLoc.end.index - tokenLoc.start.index}; + changes.emplace_back(TextChange {span, ""}); + } +} + +void ApplyInsertSemicolon(RuleAction action, const lexer::SourceRange &tokenLoc, std::vector &changes) +{ + if ((static_cast(RuleAction::INSERT_TRAILING_SEMICOLON) & static_cast(action)) != 0) { + TextSpan span {tokenLoc.end.index, 0}; + changes.emplace_back(TextChange {span, ";"}); + } +} + +void ExecuteRuleAction(FormattingContext &context, std::vector &changes, Rule &rule) +{ + const auto &prevToken = context.GetPreviousToken(); + const auto ¤tToken = context.GetCurrentToken(); + auto action = rule.GetRuleAction(); + + auto prevLoc = prevToken.Loc(); + auto currLoc = currentToken.Loc(); + + size_t start = prevLoc.end.index; + size_t end = currLoc.start.index; + + if (start <= end) { + TextSpan whitespaceSpan {start, end - start}; + ApplyInsertSpace(action, whitespaceSpan, changes); + ApplyDeleteSpace(action, whitespaceSpan, changes); + ApplyInsertNewline(action, whitespaceSpan, changes); + } + + ApplyDeleteToken(action, currLoc, changes); + ApplyInsertSemicolon(action, currLoc, changes); +} + +void ApplyRulesOnRange(FormattingContext &context, std::vector &changes, RulesMap &rulesMap) +{ + const auto ¤tToken = context.GetCurrentToken(); + const auto &nextToken = context.GetNextToken(); + + if (currentToken.Type() == lexer::TokenType::EOS || nextToken.Type() == lexer::TokenType::EOS) { + return; + } + + auto allRules = rulesMap(context); + + for (auto &ruleSpec : allRules) { + if (!TokenMatch(ruleSpec.GetLeftTokenRange(), currentToken.Type())) { + continue; + } + + if (!TokenMatch(ruleSpec.GetRightTokenRange(), nextToken.Type())) { + continue; + } + + bool predicatesMet = true; + for (const auto &predicate : ruleSpec.GetRule().GetContext()) { + if (!predicate(&context)) { + predicatesMet = false; + break; + } + } + if (predicatesMet) { + ExecuteRuleAction(context, changes, ruleSpec.GetRule()); + if ((static_cast(ruleSpec.GetRule().GetRuleAction()) & + (static_cast(static_cast(RuleAction::STOP_PROCESSING_SPACE_ACTIONS) | + static_cast(RuleAction::STOP_PROCESSING_TOKEN_ACTIONS)))) != 0) { + break; + } + } + } +} + +std::vector FormatDocument(es2panda_Context *context, FormatContext formatContext) +{ + if (context == nullptr) { + return {}; + } + + auto *publicContext = reinterpret_cast(context); + if (publicContext == nullptr || publicContext->parserProgram == nullptr) { + return {}; + } + + RulesMap &rulesMap = formatContext.GetRulesMap(); + [[maybe_unused]] const FormatCodeSettings &options = formatContext.GetFormatCodeSettings(); + + parser::ParserContext parserCtx(publicContext->parserProgram, parser::ParserStatus::NO_OPTS); + lexer::Lexer lexer(&parserCtx, *publicContext->diagnosticEngine); + + std::string sourceText(publicContext->parserProgram->SourceCode().Utf8()); + + FormattingContext formattingContext(sourceText); + std::vector changes; + + lexer::Token prevToken; + prevToken.SetTokenType(lexer::TokenType::EOS); + + lexer.NextToken(); + lexer::Token currentToken = lexer.GetToken(); + if (currentToken.Type() == lexer::TokenType::EOS) { + return {}; + } + lexer.NextToken(); + lexer::Token nextToken = lexer.GetToken(); + + while (currentToken.Type() != lexer::TokenType::EOS) { + formattingContext.SetPreviousToken(prevToken); + formattingContext.SetCurrentToken(currentToken); + formattingContext.SetNextToken(nextToken); + + auto *currentTokenParent = GetTouchingToken(context, currentToken.Loc().start.index, false); + formattingContext.SetCurrentTokenParent(currentTokenParent); + + ir::AstNode *nextTokenParent = nullptr; + if (nextToken.Type() != lexer::TokenType::EOS) { + nextTokenParent = GetTouchingToken(context, nextToken.Loc().start.index, false); + } + formattingContext.SetNextTokenParent(nextTokenParent); + + ApplyRulesOnRange(formattingContext, changes, rulesMap); + + prevToken = currentToken; + currentToken = nextToken; + + if (currentToken.Type() != lexer::TokenType::EOS) { + lexer.NextToken(); + nextToken = lexer.GetToken(); + } else { + nextToken.SetTokenType(lexer::TokenType::EOS); + } + } + return changes; +} + FormatContext GetFormatContext(FormatCodeSettings &options) { - return FormatContext(options, RulesMapCache::Instance().GetRulesMap()); + RulesMap &rulesMap = RulesMapCache::Instance().GetRulesMap(); + return FormatContext(options, rulesMap); } } // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/formatting/formatting_context.cpp b/ets2panda/lsp/src/formatting/formatting_context.cpp index 86b3627d2702715a24179bf59fa933a885fd71b1..39dacb334b685a41fffd0c21a299f963b942d4db 100644 --- a/ets2panda/lsp/src/formatting/formatting_context.cpp +++ b/ets2panda/lsp/src/formatting/formatting_context.cpp @@ -14,91 +14,96 @@ */ #include "formatting/formatting_context.h" -#include "brace_matching.h" -#include "public/public.h" +#include "ir/astNode.h" +#include "ir/statements/blockStatement.h" namespace ark::es2panda::lsp { -FormattingContext::FormattingContext(FormattingRequestKind requestKind, FormatCodeSettings &formatSettings) +FormattingContext::FormattingContext(const std::string &sourceText) : sourceText_(sourceText) {} + +void FormattingContext::SetCurrentToken(const lexer::Token &token) { - formatCodeSettings_ = formatSettings; - formattingRequestKind_ = requestKind; + currentToken_ = token; + currentTokenSpan_ = token.Loc(); } -void FormattingContext::UpdateContext(es2panda_Context *context, RangeWithKind ¤tToken, RangeWithKind &nextToken) +void FormattingContext::SetPreviousToken(const lexer::Token &token) { - currentTokenSpan_ = currentToken; - nextTokenSpan_ = nextToken; - - if (context == nullptr) { - return; - } + prevToken_ = token; +} - auto ctx = reinterpret_cast(context); - if (ctx->parserProgram == nullptr || ctx->parserProgram->Ast() == nullptr) { - return; - } +void FormattingContext::SetNextToken(const lexer::Token &token) +{ + nextToken_ = token; +} - contextNode_ = reinterpret_cast(ctx->parserProgram->Ast()); +void FormattingContext::SetCurrentTokenParent(ir::AstNode *node) +{ + currentTokenParent_ = node; +} - auto current = GetTouchingToken(context, currentTokenSpan_.start.index, false); - if (current == nullptr) { - return; - } - currentTokenParent_ = current->Parent(); +void FormattingContext::SetNextTokenParent(ir::AstNode *node) +{ + nextTokenParent_ = node; +} - nextTokenParent_ = GetTouchingToken(context, nextToken.start.index, false)->Parent(); +const lexer::Token &FormattingContext::GetCurrentToken() const +{ + return currentToken_; +} - contextNodeAllOnSameLine_ = NodeIsOnOneLine(contextNode_); - nextNodeAllOnSameLine_ = NodeIsOnOneLine(nextTokenParent_); - tokensAreOnSameLine_ = currentTokenSpan_.start.ToLocation().line == nextTokenSpan_.start.ToLocation().line; - contextNodeBlockIsOnOneLine_ = BlockIsOnOneLine(contextNode_); - nextNodeBlockIsOnOneLine_ = BlockIsOnOneLine(nextTokenParent_); +const lexer::Token &FormattingContext::GetPreviousToken() const +{ + return prevToken_; } -bool FormattingContext::ContextNodeAllOnSameLine() const +const lexer::Token &FormattingContext::GetNextToken() const { - return contextNodeAllOnSameLine_; + return nextToken_; } -bool FormattingContext::NextNodeAllOnSameLine() const +ir::AstNode *FormattingContext::GetCurrentTokenParent() const { - return nextNodeAllOnSameLine_; + return currentTokenParent_; } -bool FormattingContext::TokensAreOnSameLine() const +ir::AstNode *FormattingContext::GetNextTokenParent() const { - return tokensAreOnSameLine_; + return nextTokenParent_; } -bool FormattingContext::ContextNodeBlockIsOnOneLine() const +const std::string &FormattingContext::GetSourceText() const { - return contextNodeBlockIsOnOneLine_; + return sourceText_; } -bool FormattingContext::NextNodeBlockIsOnOneLine() const +const lexer::SourceRange &FormattingContext::GetCurrentTokenSpan() const { - return nextNodeBlockIsOnOneLine_; + return currentTokenSpan_; } -bool FormattingContext::NodeIsOnOneLine(ir::AstNode *node) const +bool FormattingContext::ContextNodeBlockIsOnOneLine() const { - if (node == nullptr) { - return false; + if (currentTokenParent_ == nullptr) { + return true; } + return BlockIsOnOneLine(currentTokenParent_); +} - return node->Start().line == node->End().line; +bool FormattingContext::TokensAreOnSameLine() const +{ + return prevToken_.Loc().end.line == currentToken_.Loc().start.line; } bool FormattingContext::BlockIsOnOneLine(ir::AstNode *node) const { - if (node == nullptr) { - return false; + if (node->IsBlockStatement()) { + auto block = node->AsBlockStatement(); + if (!block->Statements().empty()) { + return block->Start().line == block->Statements().back()->End().line; + } } - - auto nodeChild = node->FindChild([](ir::AstNode *astnode) { return CheckNodeKindForBraceMatching(astnode); }); - - return NodeIsOnOneLine(nodeChild); + return node->Start().line == node->End().line; } } // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/formatting/rules.cpp b/ets2panda/lsp/src/formatting/rules.cpp index c145eaf67daa7c0f273427c1230cc8b31debd052..10a02df0577123bb39697da89e7a689d14ea364f 100644 --- a/ets2panda/lsp/src/formatting/rules.cpp +++ b/ets2panda/lsp/src/formatting/rules.cpp @@ -15,13 +15,35 @@ #include "formatting/rules.h" #include +#include "formatting/formatting_context.h" +#include "ir/astNode.h" namespace ark::es2panda::lsp { +static bool IsConditionalOperatorContext(FormattingContext *ctx) +{ + auto *parent = ctx->GetCurrentTokenParent(); + return parent != nullptr && (parent->IsConditionalExpression() || parent->IsTSConditionalType()); +} + std::vector GetAllRules() { std::vector rules; + auto createTokenRange = [](const std::vector &tokens) { + return std::vector {TokenRange(tokens, true)}; + }; + auto anyTokenRange = createTokenRange({}); + + { + std::vector p = {[](FormattingContext *ctx) { return ctx->TokensAreOnSameLine(); }, + IsConditionalOperatorContext}; + Rule rule(p, RuleAction::INSERT_SPACE, RuleFlags::NONE); + auto left = createTokenRange({lexer::TokenType::PUNCTUATOR_QUESTION_MARK}); + auto right = anyTokenRange; + rules.emplace_back(rule, left, right); + } + return rules; } diff --git a/ets2panda/lsp/src/formatting/rules_map.cpp b/ets2panda/lsp/src/formatting/rules_map.cpp index a6f9101f13dbd717cb11c94fd5804a334bbbc417..1253f4d578881ea3de9e9de98d52708844b8b351 100644 --- a/ets2panda/lsp/src/formatting/rules_map.cpp +++ b/ets2panda/lsp/src/formatting/rules_map.cpp @@ -17,8 +17,6 @@ namespace ark::es2panda::lsp { -RulesMap RulesMapCache::rulesMap_; - RulesMapCache &RulesMapCache::Instance() { static RulesMapCache cache; @@ -27,15 +25,13 @@ RulesMapCache &RulesMapCache::Instance() RulesMap &RulesMapCache::GetRulesMap() { - if (!rulesMap_) { - rulesMap_ = CreateRulesMap(GetAllRules()); - } - return rulesMap_; + static RulesMap rulesMap = CreateRulesMap(GetAllRules()); + return rulesMap; } -RulesMap RulesMapCache::CreateRulesMap(std::vector ruleSpec) +RulesMap RulesMapCache::CreateRulesMap(const std::vector &ruleSpec) { - return [&ruleSpec]([[maybe_unused]] const FormattingContext &ctx) { return ruleSpec; }; + return [ruleSpec]([[maybe_unused]] const FormattingContext &ctx) { return ruleSpec; }; } -} // namespace ark::es2panda::lsp \ No newline at end of file +} // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/src/inlay_hints.cpp b/ets2panda/lsp/src/inlay_hints.cpp index 3a89585a1d727513d6428d5fbe9979621ac25bca..4aecc7a552c694a4bf1ea0453506da112d0da80c 100644 --- a/ets2panda/lsp/src/inlay_hints.cpp +++ b/ets2panda/lsp/src/inlay_hints.cpp @@ -13,17 +13,37 @@ * limitations under the License. */ -#include "inlay_hints.h" #include #include #include -#include "public/public.h" -#include "internal_api.h" #include "cancellation_token.h" +#include "compiler/lowering/util.h" +#include "inlay_hints.h" +#include "public/public.h" #include "utils/arena_containers.h" namespace ark::es2panda::lsp { +/** + * this function tries to find the first child node that includes the given span. + * It can be used to avoid double processing of the same node, like in the following case in global scope: + * 1) let a = map.get("a"); + * In this case, the call expression node will be included both in the init method and in the global class property. + */ +ir::AstNode *TryGetIncludingNode(const ir::AstNode *ast, const TextSpan *span) +{ + if (ast == nullptr || span == nullptr) { + return nullptr; + } + auto expectedStart = span->start; + auto expectedEnd = expectedStart + span->length; + auto checkFunc = [&expectedStart, &expectedEnd](ir::AstNode *node) { + return expectedStart <= node->Range().end.index && node->Range().start.index <= expectedEnd; + }; + auto *found = ast->FindChild(checkFunc); + return found; +} + int GetFullWidth(const ir::AstNode *node) { return node->End().index - node->Start().index; @@ -77,7 +97,7 @@ bool TextSpanIntersectsWith(const TextSpan span, const int position, const int n bool IsExpressionWithTypeArguments(const ir::AstNode *node) { - return node->Type() == ir::AstNodeType::CALL_EXPRESSION; + return node->Type() == ir::AstNodeType::CALL_EXPRESSION || node->Type() == ir::AstNodeType::NEW_EXPRESSION; } void GetVariableDeclarationTypeForHints(const ir::AstNode *decl, InlayHintList *result) @@ -105,21 +125,23 @@ void GetVariableDeclarationTypeForHints(const ir::AstNode *decl, InlayHintList * return false; }); } -void AddParamIfTypeRef(const ir::AstNode *childNode, const ArenaVector &args, InlayHintList *result) + +void AddParamIfTypeRef(const ir::MethodDefinition *decl, const ArenaVector &args, + InlayHintList *result) { int paramIndex = 0; - childNode->FindChild([¶mIndex, args, &result](ark::es2panda::ir::AstNode *node) { - if (node->IsETSParameterExpression()) { - auto part = node->AsETSParameterExpression()->Name().Utf8(); - std::string s1 {part.data(), part.size()}; - AddParameterHints(std::string(s1), args.at(paramIndex)->Start().index, false, result); + auto params = decl->Function()->Params(); + for (const auto ¶m : params) { + if (param->IsETSParameterExpression()) { + auto part = param->AsETSParameterExpression()->Name().Utf8(); + std::string text {part.data(), part.size()}; + AddParameterHints(text, args.at(paramIndex)->Start().index, false, result); paramIndex++; } - return false; - }); + } } -void GetCallExpTypeForHints(const ir::AstNode *expr, const ir::AstNode *parent, InlayHintList *result) +void GetCallExpTypeForHints(const ir::AstNode *expr, [[maybe_unused]] const ir::AstNode *parent, InlayHintList *result) { const ir::Expression *callee; if (expr->IsCallExpression()) { @@ -129,7 +151,7 @@ void GetCallExpTypeForHints(const ir::AstNode *expr, const ir::AstNode *parent, } else { return; } - if (!callee->IsIdentifier()) { + if (!(callee->IsIdentifier() || callee->IsMemberExpression())) { return; } const auto args = @@ -138,13 +160,12 @@ void GetCallExpTypeForHints(const ir::AstNode *expr, const ir::AstNode *parent, return; } - parent->FindChild([args, callee, &result](ark::es2panda::ir::AstNode *childNode) { - if (childNode->IsMethodDefinition() && - childNode->AsMethodDefinition()->Function()->Id()->ToString() == callee->AsIdentifier()->Name().Utf8()) { - AddParamIfTypeRef(childNode, args, result); - } - return false; - }); + auto *decl = callee->IsIdentifier() + ? compiler::DeclarationFromIdentifier(callee->AsIdentifier()) + : compiler::DeclarationFromIdentifier(callee->AsMemberExpression()->Property()->AsIdentifier()); + if (decl != nullptr && decl->IsMethodDefinition()) { + AddParamIfTypeRef(decl->AsMethodDefinition(), args, result); + } } bool ShouldShowParameterNameHints(const UserPreferences &preferences) @@ -398,7 +419,9 @@ InlayHintList ProvideInlayHintsImpl(es2panda_Context *context, const TextSpan *s return {}; } InlayHintProcessingContext processingContext = {span, parent, cancellationToken, preferences}; - parent->FindChild([&processingContext, &result](ir::AstNode *childNode) { + const auto *searchNode = TryGetIncludingNode(parent, span); + searchNode = searchNode == nullptr ? parent : searchNode; + searchNode->FindChild([&processingContext, &result](ir::AstNode *childNode) { Visitor(childNode, processingContext, &result); return false; }); diff --git a/ets2panda/lsp/src/internal_api.cpp b/ets2panda/lsp/src/internal_api.cpp index 8d5460b2c4da430af9d147c8ebdb4af9b48922fc..86b27c2036ce2b4c18f193d22c97b17b8de7db76 100644 --- a/ets2panda/lsp/src/internal_api.cpp +++ b/ets2panda/lsp/src/internal_api.cpp @@ -118,27 +118,37 @@ std::string FormatStringFromArgs(const std::string &textStr, return ss.str(); } -FileDiagnostic CreateFileDiagnostic(es2panda_AstNode *node, lexer::SourceRange span, Diagnostic diagnostic, +FileDiagnostic CreateFileDiagnostic(es2panda_AstNode *node, Range span, Diagnostic diagnostic, const std::vector &args = std::vector()) { if (!args.empty()) { std::string newMessageStr = FormatStringFromArgs(diagnostic.message_, args); diagnostic.message_ = newMessageStr; } - FileDiagnostic fileDiagnostic(node, diagnostic, TransSourcePositionToPosition(span.start), - TransSourcePositionToPosition(span.end)); + FileDiagnostic fileDiagnostic(node, diagnostic, span.start, span.end); return fileDiagnostic; } -lexer::SourceRange GetErrorRangeForNode(ir::AstNode *node) +Range GetErrorRangeForNode(ir::AstNode *node, es2panda_Context *context) { - return lexer::SourceRange(node->Start(), node->End()); + auto ctx = reinterpret_cast(context); + // The line and col should start from 1 istead of 0 + auto index = lexer::LineIndex(ctx->parserProgram->SourceCode()); + auto sourceStartLocation = index.GetLocation(node->Range().start); + auto sourceEndLocation = index.GetLocation(node->Range().end); + Position posStart(sourceStartLocation.line, sourceStartLocation.col); + Position posEnd(sourceEndLocation.line, sourceEndLocation.col); + return Range(posStart, posEnd); } -FileDiagnostic CreateDiagnosticForNode(es2panda_AstNode *node, Diagnostic diagnostic, +FileDiagnostic CreateDiagnosticForNode(es2panda_AstNode *node, Diagnostic diagnostic, es2panda_Context *context, const std::vector &args) { - auto span = GetErrorRangeForNode(reinterpret_cast(node)); + auto span = diagnostic.range_; + // Only genereate range when original range is invalid + if (span.start.character_ <= 0 || span.end.character_ <= 0 || span.start.line_ <= 0 || span.end.line_ <= 0) { + span = GetErrorRangeForNode(reinterpret_cast(node), context); + } auto res = CreateFileDiagnostic(node, span, std::move(diagnostic), args); return res; } @@ -622,6 +632,20 @@ std::pair GetDefinitionAtPositionImpl(es2panda_ return res; } +std::string GetImportFilePath(es2panda_Context *context, size_t pos) +{ + std::string res; + auto node = GetTouchingToken(context, pos, false); + if (node == nullptr) { + return res; + } + auto parent = node->Parent(); + if (parent != nullptr && parent->IsETSImportDeclaration() && parent->AsETSImportDeclaration()->Source() == node) { + res = std::string(parent->AsETSImportDeclaration()->ImportMetadata().resolvedSource); + } + return res; +} + ArenaVector RemoveRefDuplicates(const ArenaVector &nodes, ArenaAllocator *allocator) { auto hashFunc = [](const ir::AstNode *node) { @@ -697,6 +721,7 @@ HighlightSpanKind GetHightlightSpanKind(ir::AstNode *identifierDeclaration, ir:: DocumentHighlights GetSemanticDocumentHighlights(es2panda_Context *context, size_t position) { auto ctx = reinterpret_cast(context); + auto ast = ctx->parserProgram->Ast(); std::string fileName(ctx->sourceFile->filePath); auto touchingToken = GetTouchingToken(context, position, false); if (!touchingToken->IsIdentifier()) { @@ -706,13 +731,24 @@ DocumentHighlights GetSemanticDocumentHighlights(es2panda_Context *context, size if (decl == nullptr) { return DocumentHighlights(fileName, {}); } - auto references = FindReferencesByName(ctx->parserProgram->Ast(), decl, touchingToken, ctx->allocator); + auto checkFunc = [&touchingToken](ir::AstNode *child) { + return child->IsIdentifier() && child->AsIdentifier()->Name() == touchingToken->AsIdentifier()->Name(); + }; + // Find the identifier's declaration. We consider the first found to be the identifier's declaration. + auto identifierDeclaration = decl->FindChild(checkFunc); + if (identifierDeclaration == nullptr) { + // If the identifier is not found in the declaration, we try to find it in the AST. + // This is needed for cases like `import {Foo as foo} from './a';` where + // `foo` is a alias for the imported `Foo` identifier. + identifierDeclaration = ast->FindChild(checkFunc); + } + if (identifierDeclaration == nullptr) { + return DocumentHighlights(fileName, {}); + } + + auto references = FindReferencesByName(ast, decl, touchingToken, ctx->allocator); auto highlightSpans = std::vector(); - // Find the identifier's declaration. We consider the first found to be the identifier's declaration. - ir::AstNode *identifierDeclaration = decl->FindChild([&touchingToken](ir::AstNode *child) { - return child->IsIdentifier() && child->AsIdentifier()->Name() == touchingToken->AsIdentifier()->Name(); - }); for (const auto &reference : references) { auto start = reference->Start().index; auto length = reference->AsIdentifier()->Name().Length(); diff --git a/ets2panda/lsp/src/quick_info.cpp b/ets2panda/lsp/src/quick_info.cpp index 097decf6413a839f5ee1c9d31a6a0cc073392d3d..9b4c6bdf5651fb7b8ddc66d3d9345b0ef3878334 100644 --- a/ets2panda/lsp/src/quick_info.cpp +++ b/ets2panda/lsp/src/quick_info.cpp @@ -20,6 +20,8 @@ #include "ir/ets/etsTuple.h" #include "ir/ets/etsUnionType.h" #include "api.h" +#include "rename.h" +#include "isolated_declaration.h" #include "compiler/lowering/util.h" namespace ark::es2panda::lsp { @@ -191,24 +193,8 @@ ir::AstNode *GetNodeAtLocation(ir::AstNode *node) if (node->IsProgram()) { return node->Modifiers() == ir::ModifierFlags::EXPORT ? node : nullptr; } - auto parent = node->Parent(); - if (IsIdentifierOfDeclaration(node)) { - return parent; - } if (node->Type() == ir::AstNodeType::IDENTIFIER) { - if (IsDeclaration(parent) || IsDefinition(parent)) { - if (compiler::ClassDefinitionIsEnumTransformed(parent)) { - parent = parent->AsClassDefinition()->OrigEnumDecl()->AsTSEnumDeclaration(); - } - return parent; - } - if (parent->Type() == ir::AstNodeType::MEMBER_EXPRESSION) { - auto declNode = compiler::DeclarationFromIdentifier(parent->AsMemberExpression()->Object()->AsIdentifier()); - if (compiler::ClassDefinitionIsEnumTransformed(declNode)) { - declNode = declNode->AsClassDefinition()->OrigEnumDecl()->AsTSEnumDeclaration(); - } - return declNode; - } + // could get decl instead of getting parant declaration and then child return compiler::DeclarationFromIdentifier(node->AsIdentifier()); } @@ -651,11 +637,21 @@ std::vector CreateDisplayForClass(ir::AstNode *node) // class definition if (node->AsClassDefinition()->OrigEnumDecl() != nullptr) { displayParts.emplace_back(CreateKeyword("enum")); + displayParts.emplace_back(CreateSpace()); + displayParts.emplace_back(CreateEnumName(GetNameFromClassDefinition(node))); + } else if (node->AsClassDefinition()->IsNamespaceTransformed()) { + displayParts.emplace_back(CreateKeyword("namespace")); + displayParts.emplace_back(CreateSpace()); + displayParts.emplace_back(CreateNamespace(GetNameFromClassDefinition(node))); + } else if (node->Parent()->IsETSStructDeclaration()) { + displayParts.emplace_back(CreateKeyword("struct")); + displayParts.emplace_back(CreateSpace()); + displayParts.emplace_back(SignatureCreateStructName(GetNameFromClassDefinition(node))); } else { displayParts.emplace_back(CreateKeyword("class")); + displayParts.emplace_back(CreateSpace()); + displayParts.emplace_back(CreateClassName(GetNameFromClassDefinition(node))); } - displayParts.emplace_back(CreateSpace()); - displayParts.emplace_back(CreateClassName(GetNameFromClassDefinition(node))); } return displayParts; } @@ -774,6 +770,21 @@ std::vector CreateDisplayOfReturnType(ark::es2panda::ir::Type auto typeName = part->Name()->AsIdentifier()->Name(); displayParts.emplace_back(CreateReturnType(std::string(typeName))); } + if (returnType->Type() == ir::AstNodeType::ETS_UNION_TYPE) { + auto unionType = returnType->AsETSUnionType(); + auto types = unionType->Types(); + for (size_t i = 0; i < types.size(); ++i) { + auto typeName = GetNameForTypeNode(types[i]); + displayParts.emplace_back(CreateReturnType(typeName)); + if (i != types.size() - 1) { + displayParts.emplace_back(CreatePunctuation("|")); + displayParts.emplace_back(CreateSpace()); + } + } + } + if (returnType->Type() == ir::AstNodeType::TS_THIS_TYPE) { + displayParts.emplace_back(CreateReturnType("this")); + } return displayParts; } @@ -882,7 +893,7 @@ std::vector CreateDisplayForEnumMember(ir::AstNode *node) displayParts.emplace_back(CreateSpace()); auto init = node->AsTSEnumMember()->Init(); if (init->Type() == ir::AstNodeType::NUMBER_LITERAL) { - displayParts.emplace_back(CreateText(std::string(init->AsNumberLiteral()->Str()))); + displayParts.emplace_back(CreateText(std::to_string(init->AsNumberLiteral()->Number().GetInt()))); } if (init->Type() == ir::AstNodeType::STRING_LITERAL) { displayParts.emplace_back(CreatePunctuation("\"")); @@ -1019,7 +1030,73 @@ std::vector CreateDisplayForMethodDefinitionOfInterfaceBody(i return displayParts; } -std::vector CreateDisplayForMethodDefinition(ir::AstNode *node, const std::string &kindModifier) +void AppendClassOrGlobalPrefix(std::vector &parts, ir::AstNode *parent) +{ + if (!parent->IsClassDefinition()) { + return; + } + + auto className = parent->AsClassDefinition()->Ident()->Name(); + if (className != "ETSGLOBAL") { + parts.emplace_back(CreateClassName(std::string(className))); + parts.emplace_back(CreatePunctuation(".")); + } else { + parts.emplace_back(CreateKeyword("function")); + parts.emplace_back(CreateSpace()); + } +} + +void AppendFunctionName(std::vector &parts, ir::MethodDefinition *method) +{ + auto name = method->Key()->AsIdentifier()->Name(); + parts.emplace_back(CreateFunctionName(std::string(name))); +} + +static void AppendSignature(std::vector &parts, ir::MethodDefinition *method, + checker::ETSChecker *checker) +{ + auto *funcExpr = method->Value(); + if (funcExpr == nullptr) { + return; + } + auto *script = funcExpr->AsFunctionExpression()->Function(); + if (script == nullptr || script->Type() != ir::AstNodeType::SCRIPT_FUNCTION) { + return; + } + // + if (auto *typeParams = script->TypeParams()) { + auto display = CreateDisplayOfTypeParams(typeParams->AsTSTypeParameterDeclaration()->Params()); + parts = MergeSymbolDisplayPart(parts, display); + } + // (a: number, b: string) + auto paramDisplay = CreateDisplayOfFunctionParams(script); + parts = MergeSymbolDisplayPart(parts, paramDisplay); + // return type + auto returnType = script->ReturnTypeAnnotation(); + if (returnType == nullptr) { + auto signature = GetFuncSignature(method->TsType()->AsETSFunctionType(), method); + auto typeStr = GetReturnTypeStr(signature->ReturnType(), checker); + parts.emplace_back(CreatePunctuation(":")); + parts.emplace_back(CreateSpace()); + parts.emplace_back(CreateReturnType(typeStr)); + } else { + auto retDisplay = CreateDisplayOfReturnType(script->ReturnTypeAnnotation()); + parts = MergeSymbolDisplayPart(parts, retDisplay); + } +} + +static std::vector CreateDisplayForRegularOrClassMethod(ir::AstNode *node, + checker::ETSChecker *checker) +{ + std::vector parts; + AppendClassOrGlobalPrefix(parts, node->Parent()); + AppendFunctionName(parts, node->AsMethodDefinition()); + AppendSignature(parts, node->AsMethodDefinition(), checker); + return parts; +} + +std::vector CreateDisplayForMethodDefinition(ir::AstNode *node, const std::string &kindModifier, + checker::ETSChecker *checker) { std::vector displayParts; if (node->Type() != ir::AstNodeType::METHOD_DEFINITION) { @@ -1035,44 +1112,8 @@ std::vector CreateDisplayForMethodDefinition(ir::AstNode *nod if (node->Parent() != nullptr && node->Parent()->Type() == ir::AstNodeType::TS_INTERFACE_BODY) { return CreateDisplayForMethodDefinitionOfInterfaceBody(node); } - if (node->Parent() != nullptr && node->Parent()->IsClassDefinition()) { - auto className = node->Parent()->AsClassDefinition()->Ident()->Name(); - if (className != "ETSGLOBAL") { - displayParts.emplace_back(CreateClassName(std::string(className))); - displayParts.emplace_back(CreatePunctuation(".")); - } else { - displayParts.emplace_back(CreateKeyword("function")); - displayParts.emplace_back(CreateSpace()); - } - } - - auto functionName = node->AsMethodDefinition()->Key()->AsIdentifier()->Name(); - displayParts.emplace_back(CreateFunctionName(std::string(functionName))); - if (node->AsMethodDefinition()->Value() == nullptr) { - return displayParts; - } - auto scriptFunction = node->AsMethodDefinition()->Value()->AsFunctionExpression()->Function(); - if (scriptFunction == nullptr) { - return displayParts; - } - if (scriptFunction->Type() == ir::AstNodeType::SCRIPT_FUNCTION) { - auto script = scriptFunction->AsScriptFunction(); - auto typeParameter = script->TypeParams(); - if (typeParameter != nullptr) { - auto params = typeParameter->AsTSTypeParameterDeclaration()->Params(); - auto displayOfTypeParams = CreateDisplayOfTypeParams(params); - displayParts = MergeSymbolDisplayPart(displayParts, displayOfTypeParams); - } - - auto displayOfFunctionParam = CreateDisplayOfFunctionParams(script); - displayParts = MergeSymbolDisplayPart(displayParts, displayOfFunctionParam); - - auto returnType = script->ReturnTypeAnnotation(); - auto displayOfReturnType = CreateDisplayOfReturnType(returnType); - displayParts = MergeSymbolDisplayPart(displayParts, displayOfReturnType); - } - return displayParts; + return CreateDisplayForRegularOrClassMethod(node, checker); } std::vector CreateDisplayForClassProperty(ir::AstNode *node) @@ -1169,14 +1210,13 @@ std::vector CreateDisplayForImportDeclaration(ir::AstNode *no } QuickInfo GetQuickInfo(ir::AstNode *node, ir::AstNode *containerNode, ir::AstNode *nodeForQuickInfo, - const std::string &fileName) + const std::string &fileName, checker::ETSChecker *checker) { if (containerNode == nullptr || nodeForQuickInfo == nullptr || node == nullptr) { return QuickInfo(); } auto kindModifiers = GetKindModifiers(node); TextSpan span(nodeForQuickInfo->Start().index, nodeForQuickInfo->End().index - nodeForQuickInfo->Start().index); - auto nodeKind = GetNodeKind(node); std::vector displayParts; std::string kind; @@ -1185,7 +1225,6 @@ QuickInfo GetQuickInfo(ir::AstNode *node, ir::AstNode *containerNode, ir::AstNod if (IsClass(node)) { displayParts = CreateDisplayForClass(node); - kind = "class"; } else if (node->Type() == ir::AstNodeType::ETS_PARAMETER_EXPRESSION) { displayParts = CreateDisplayForETSParameterExpression(node); } else if (node->Type() == ir::AstNodeType::CLASS_PROPERTY) { @@ -1196,11 +1235,11 @@ QuickInfo GetQuickInfo(ir::AstNode *node, ir::AstNode *containerNode, ir::AstNod displayParts = CreateDisplayForEnumMember(enumMember); } else { displayParts = CreateDisplayForClassProperty(node); - kind = "property"; } + } else if (node->Type() == ir::AstNodeType::TS_ENUM_MEMBER) { + displayParts = CreateDisplayForEnumMember(node); } else if (node->Type() == ir::AstNodeType::TS_INTERFACE_DECLARATION) { displayParts = CreateDisplayForInterface(node); - kind = "interface"; } else if (node->Type() == ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION) { displayParts = CreateDisplayForTypeAlias(node); } else if (node->Type() == ir::AstNodeType::TS_ENUM_DECLARATION) { @@ -1210,12 +1249,10 @@ QuickInfo GetQuickInfo(ir::AstNode *node, ir::AstNode *containerNode, ir::AstNod } else if (node->Type() == ir::AstNodeType::TS_TYPE_PARAMETER) { displayParts = CreateDisplayForTypeParameter(node); } else if (node->Type() == ir::AstNodeType::METHOD_DEFINITION) { - displayParts = CreateDisplayForMethodDefinition(node, kindModifiers); - kind = "function"; - if (node->Parent() != nullptr && node->Parent()->Type() == ir::AstNodeType::TS_INTERFACE_BODY) { - kind = "property"; - } + displayParts = CreateDisplayForMethodDefinition(node, kindModifiers, checker); } + // Unify this kind + kind = GetNodeKindForRenameInfo(node); return QuickInfo(kind, kindModifiers, span, displayParts, document, tags, fileName); } @@ -1228,6 +1265,9 @@ QuickInfo GetQuickInfoAtPositionImpl(es2panda_Context *context, size_t position, if (touchingToken == nullptr || touchingToken->IsProgram()) { return QuickInfo(); } + auto ctx = reinterpret_cast(context); + auto checker = reinterpret_cast(ctx->GetChecker()); + // The nodeForQuickInfo will be identifier in all of currently known scenarios auto nodeForQuickInfo = GetTokenForQuickInfo(context, position); auto node = GetNodeAtLocationForQuickInfo(nodeForQuickInfo); auto object = GetContainingObjectLiteralNode(nodeForQuickInfo); @@ -1242,7 +1282,7 @@ QuickInfo GetQuickInfoAtPositionImpl(es2panda_Context *context, size_t position, return QuickInfo(); } - return GetQuickInfo(node, GetContainerNode(nodeForQuickInfo), nodeForQuickInfo, nodeFileName); + return GetQuickInfo(node, GetContainerNode(nodeForQuickInfo), nodeForQuickInfo, nodeFileName, checker); } } // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/references.cpp b/ets2panda/lsp/src/references.cpp index cf4b87a9f13c317468d5f0e7cc5c1cc8a9bfd744..2370edb0e3cea65ad694452ad4b0c795fd148482 100644 --- a/ets2panda/lsp/src/references.cpp +++ b/ets2panda/lsp/src/references.cpp @@ -41,6 +41,10 @@ DeclInfoType GetDeclInfoImpl(ir::AstNode *astNode) auto declNode = compiler::DeclarationFromIdentifier(astNode->AsIdentifier()); auto node = declNode; while (node != nullptr) { + if (node->Range().start.Program() != nullptr) { + auto name = std::string(node->Range().start.Program()->SourceFilePath()); + return std::make_tuple(name, declNode->DumpEtsSrc()); + } if (node->IsETSModule()) { auto name = std::string(node->AsETSModule()->Program()->SourceFilePath()); return std::make_tuple(name, declNode->DumpEtsSrc()); diff --git a/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp b/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c678ce14e1fa1174cc39a274a7dc87584449f63 --- /dev/null +++ b/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 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. + */ + +#include "lsp/include/internal_api.h" +#include "lsp/include/code_fix_provider.h" +#include "lsp/include/register_code_fix/add_missing_new_operator.h" + +namespace ark::es2panda::lsp { +const int G_ADD_MISSING_NEW_OPERATOR_CODE = 1022; +FixAddMissingNewOperator::FixAddMissingNewOperator() +{ + const char *fixId = "FixAddMissingNewOperator"; + SetErrorCodes({G_ADD_MISSING_NEW_OPERATOR_CODE}); + SetFixIds({fixId}); +} + +bool FixAddMissingNewOperator::IsValidTarget(const ir::AstNode *node) +{ + return node != nullptr && node->IsCallExpression(); +} + +void FixAddMissingNewOperator::MakeChange(ChangeTracker &changeTracker, es2panda_Context *context, size_t pos, + std::vector &fixedNodes) +{ + const auto *impl = es2panda_GetImpl(ES2PANDA_LIB_VERSION); + auto *token = GetTouchingToken(context, pos, false); + if (token == nullptr) { + return; + } + const ir::AstNode *callExpr = token; + while (callExpr != nullptr && !callExpr->IsCallExpression()) { + callExpr = callExpr->Parent(); + } + if (!IsValidTarget(callExpr)) { + return; + } + auto *call = const_cast(callExpr->AsCallExpression()); + auto *callee = const_cast(call->Callee()); + if (callee == nullptr) { + return; + } + auto *calleeNode = reinterpret_cast(callee); + if (calleeNode == nullptr) { + return; + } + es2panda_AstNode *part = impl->CreateETSTypeReferencePart1(context, calleeNode); + impl->AstNodeSetParent(context, calleeNode, part); + es2panda_AstNode *typeRef = impl->CreateETSTypeReference(context, part); + impl->AstNodeSetParent(context, part, typeRef); + es2panda_AstNode *newExpr = impl->CreateETSNewClassInstanceExpression(context, typeRef, nullptr, 0); + impl->AstNodeSetParent(context, typeRef, newExpr); + auto *newExprNode = reinterpret_cast(newExpr); + if (newExprNode == nullptr) { + return; + } + newExprNode->SetParent(call->Parent()); + changeTracker.ReplaceNode(context, call, newExprNode, {}); + fixedNodes.push_back(newExprNode); +} + +std::vector FixAddMissingNewOperator::GetCodeActionsToFix(const CodeFixContext &context) +{ + TextChangesContext textChangesContext = {context.host, context.formatContext, context.preferences}; + std::vector fixedNodes; + auto fileTextChanges = ChangeTracker::With(textChangesContext, [&](ChangeTracker &tracker) { + MakeChange(tracker, context.context, context.span.start, fixedNodes); + }); + return fileTextChanges; +} + +std::vector FixAddMissingNewOperator::GetCodeActions(const CodeFixContext &context) +{ + std::vector returnedActions; + auto changes = GetCodeActionsToFix(context); + if (!changes.empty()) { + CodeFixAction codeAction; + codeAction.fixName = "addMissingNewOperator"; + codeAction.description = "Add missing 'new' operator to constructor call"; + codeAction.changes = changes; + codeAction.fixId = "AddMissingNewOperator"; + returnedActions.push_back(codeAction); + } + return returnedActions; +} + +CombinedCodeActions FixAddMissingNewOperator::GetAllCodeActions([[maybe_unused]] const CodeFixAllContext &codeFixAll) +{ + return {}; +} + +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects, cert-err58-cpp) +AutoCodeFixRegister g_addMissingNew("AddMissingNewOperator"); +} // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/register_code_fix/convert_const_to_let.cpp b/ets2panda/lsp/src/register_code_fix/convert_const_to_let.cpp index 057b14b581911f4b3ca033186828069fce4379dd..4d91d17813b7123cbe56596d304de48cffa9092c 100644 --- a/ets2panda/lsp/src/register_code_fix/convert_const_to_let.cpp +++ b/ets2panda/lsp/src/register_code_fix/convert_const_to_let.cpp @@ -33,12 +33,12 @@ void FixConvertConstToLet::MakeChangeForConvertConstToLet(ChangeTracker &changeT size_t pos) { auto *token = GetTouchingToken(context, pos, false); - if (token == nullptr || !token->IsNumberLiteral() || token->OriginalNode() == nullptr) { + if (token == nullptr) { return; } auto *scope = compiler::NearestScope(token); - auto *resolvedDecl = FindDeclInScopeWithFallback(scope, token->OriginalNode()->AsIdentifier()->Name()); + auto *resolvedDecl = FindDeclInScopeWithFallback(scope, token->AsIdentifier()->Name()); if (resolvedDecl == nullptr) { return; } diff --git a/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp b/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51beebf135f06381ca8df9a5ad6711611bc1bba1 --- /dev/null +++ b/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp @@ -0,0 +1,147 @@ +/** + * Copyright (c) 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. + */ + +#include "lsp/include/register_code_fix/fix_add_function_return_statement.h" +#include +#include +#include +#include +#include +#include "generated/code_fix_register.h" +#include "lsp/include/code_fix_provider.h" +#include "lsp/include/internal_api.h" +#include "public/es2panda_lib.h" + +namespace ark::es2panda::lsp { +using codefixes::FIX_ADD_FUNCTION_RETURN_STATEMENT; + +FixAddFunctionReturnStatement::FixAddFunctionReturnStatement() +{ + auto errorCodes = FIX_ADD_FUNCTION_RETURN_STATEMENT.GetSupportedCodeNumbers(); + SetErrorCodes({errorCodes.begin(), errorCodes.end()}); // change this to the error code you want to handle + SetFixIds({FIX_ADD_FUNCTION_RETURN_STATEMENT.GetFixId().data()}); +} + +std::vector FixAddFunctionReturnStatement::GetCodeActions(const CodeFixContext &context) +{ + std::vector returnedActions; + auto info = GetInfo(context.context, context.span.start); + if (info.GetReturnTypeNode() == nullptr || info.GetBody() == nullptr) { + return returnedActions; // No valid return type or body found + } + + TextChangesContext textChangesContext {context.host, context.formatContext, context.preferences}; + auto replaceReturnTypeChanges = ChangeTracker::With( + textChangesContext, [&](ChangeTracker &tracker) { ReplaceReturnType(tracker, context.context, info); }); + auto addReturnStatementChanges = ChangeTracker::With(textChangesContext, [&](ChangeTracker &tracker) { + AddReturnStatement(tracker, context.context, info.GetStatements(), info.GetBody()); + }); + CodeFixAction action; + action.fixName = FIX_ADD_FUNCTION_RETURN_STATEMENT.GetFixId().data(); + action.description = "Add missing return statement"; + action.fixId = FIX_ADD_FUNCTION_RETURN_STATEMENT.GetFixId().data(); + action.fixAllDescription = "Add all missing return statement"; + action.changes.insert(action.changes.end(), replaceReturnTypeChanges.begin(), replaceReturnTypeChanges.end()); + action.changes.insert(action.changes.end(), addReturnStatementChanges.begin(), addReturnStatementChanges.end()); + returnedActions.push_back(action); + + return returnedActions; +} + +CombinedCodeActions FixAddFunctionReturnStatement::GetAllCodeActions([[maybe_unused]] const CodeFixAllContext &ctx) +{ + CombinedCodeActions combinedActions; + return combinedActions; +} + +Info GetInfo(es2panda_Context *context, size_t position) +{ + const auto token = GetDefinitionAtPositionImpl(context, position); + const auto node = token.first; + const auto declaration = FindAncessor(node); + if (!declaration->IsFunctionExpression()) { + return Info(nullptr, nullptr, {}); + } + const auto returnTypeNode = declaration->AsFunctionExpression()->Function()->ReturnTypeAnnotation(); + if (returnTypeNode == nullptr || !returnTypeNode->IsETSTypeReference()) { + return Info(nullptr, nullptr, {}); + } + if (!declaration->AsFunctionExpression()->Function()->Body()->IsBlockStatement()) { + return Info(nullptr, nullptr, {}); + } + + const auto body = declaration->AsFunctionExpression()->Function()->Body(); + const auto statements = body->AsBlockStatement()->Statements(); + return Info(returnTypeNode, body, {statements.begin(), statements.end()}); +} + +void ReplaceReturnType(ChangeTracker &changes, es2panda_Context *context, Info &info) +{ + auto ctx = reinterpret_cast(context); + const auto &statements = info.GetStatements(); + bool statementFlag = false; + for (const auto &statement : statements) { + if (statement->IsReturnStatement()) { + statementFlag = true; + break; + } + } + if (statementFlag) { + return; + } + auto newNode = info.GetReturnTypeNode()->Clone(ctx->Allocator(), info.GetReturnTypeNode()->Parent()); + if (!newNode->IsETSTypeReference()) { + return; // Not a valid type reference node + } + auto typeRef = newNode->AsETSTypeReference(); + if (typeRef->Part()->IsETSTypeReferencePart()) { + auto part = typeRef->Part()->AsETSTypeReferencePart(); + part->GetIdent()->SetName("void"); // Change the type to 'void' + } + + changes.ReplaceNode(context, info.GetReturnTypeNode(), newNode, {}); +} +void AddReturnStatement(ChangeTracker &changes, es2panda_Context *context, std::vector statements, + ir::AstNode *body) +{ + const auto impl = es2panda_GetImpl(ES2PANDA_LIB_VERSION); + if (!statements.empty()) { + // If the body is empty, we can add a return statement + auto *returnStmt = impl->CreateReturnStatement(context); + changes.InsertNodeAfter(context, statements[statements.size() - 1]->AsStatement(), + reinterpret_cast(returnStmt)); + } else { + size_t newSize = statements.size() + 1; + std::vector newStatementsVec(newSize, nullptr); + for (size_t i = 0; i < statements.size(); ++i) { + newStatementsVec[i] = reinterpret_cast(statements[i]->AsStatement()); + } + newStatementsVec[statements.size()] = impl->CreateReturnStatement(context); + auto newBody = impl->CreateBlockStatement(context, newStatementsVec.data(), statements.size()); + changes.ReplaceNode(context, body->AsBlockStatement(), reinterpret_cast(newBody), {}); + } +} + +ir::AstNode *FindAncessor(ir::AstNode *node) +{ + if (node->IsFunctionDeclaration() || node->IsFunctionExpression()) { + return node; + } + return FindAncessor(node->Parent()); +} + +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects, cert-err58-cpp) +AutoCodeFixRegister g_fixAddFunctionReturnStatement("FixAddFunctionReturnStatement"); +} // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/src/register_code_fix/fix_expected_comma.cpp b/ets2panda/lsp/src/register_code_fix/fix_expected_comma.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e37751fd2d974f97bc9f51a3a67aeac131e99d1f --- /dev/null +++ b/ets2panda/lsp/src/register_code_fix/fix_expected_comma.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 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. + */ + +#include "lsp/include/internal_api.h" +#include "lsp/include/code_fix_provider.h" +#include "lsp/include/register_code_fix/fix_expected_comma.h" + +namespace ark::es2panda::lsp { +const int G_FIX_EXPECTED_COMMA = 1016; + +void FixExpectedComma::MakeChange(ChangeTracker &changeTracker, es2panda_Context *context, Range range, + const std::string &possibleFix) +{ + if (possibleFix.empty()) { + return; + } + + auto node = GetNodeAtLocation(context, range); + if (node == nullptr) { + return; + } + + if (node->Parent()->IsObjectExpression() && node->IsProperty()) { + changeTracker.ReplaceNodeWithText(context, node->Parent(), possibleFix); + } +} + +ir::AstNode *FixExpectedComma::GetNodeAtLocation(es2panda_Context *context, Range range) +{ + auto *ctx = reinterpret_cast(context); + auto ast = ctx->parserProgram->Ast(); + auto nodeAtLocation = + ast->FindChild([&range](ir::AstNode *node) { return node->Range().start.line == range.start.line_; }); + + return nodeAtLocation; +} + +std::vector FixExpectedComma::GetCodeActionsToFix(const CodeFixContext &context) +{ + CodeFixProvider provider; + auto diagnostics = provider.GetDiagnostics(context); + TextChangesContext textChangesContext = {context.host, context.formatContext, context.preferences}; + std::vector fileTextChanges; + + for (auto &diag : diagnostics->diagnostic) { + auto code = std::get(diag.code_); + if (code != G_FIX_EXPECTED_COMMA) { + continue; + } + + auto changes = ChangeTracker::With(textChangesContext, [&](ChangeTracker &tracker) { + MakeChange(tracker, context.context, diag.range_, diag.source_); + }); + + fileTextChanges.insert(fileTextChanges.end(), changes.begin(), changes.end()); + } + + return fileTextChanges; +} + +FixExpectedComma::FixExpectedComma() +{ + const char *fixId = "FixExpectedComma"; + SetErrorCodes({G_FIX_EXPECTED_COMMA}); + SetFixIds({fixId}); +} + +std::vector FixExpectedComma::GetCodeActions(const CodeFixContext &context) +{ + std::vector returnedActions; + + auto changes = GetCodeActionsToFix(context); + if (!changes.empty()) { + CodeFixAction codeAction; + codeAction.fixName = "fixExpectedComma"; + codeAction.description = "Use comma instead of semicolon at possition"; + codeAction.changes = changes; + codeAction.fixId = "FixExpectedComma"; + returnedActions.push_back(codeAction); + } + + return returnedActions; +} + +CombinedCodeActions FixExpectedComma::GetAllCodeActions(const CodeFixAllContext &codeFixAll) +{ + std::vector fixedNodes; + CodeFixProvider provider; + + return provider.GetAllFixes(codeFixAll); +} +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects, cert-err58-cpp) +} // namespace ark::es2panda::lsp diff --git a/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp b/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f26a16d5b7c08950277c68a4b39d8f98386721bc --- /dev/null +++ b/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp @@ -0,0 +1,142 @@ +/** + * Copyright (c) 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. + */ + +#include "lsp/include/register_code_fix/fix_return_type_in_async_function.h" +#include "generated/code_fix_register.h" +#include "lsp/include/code_fix_provider.h" +#include "lsp/include/internal_api.h" +#include "compiler/lowering/util.h" + +namespace ark::es2panda::lsp { +using codefixes::FIX_RETURN_TYPE_IN_ASYNC_FUNCTION; +constexpr size_t K_GENERIC_BRACKETS_LENGTH = 2; // '<' and '>' +FixReturnTypeInAsyncFunction::FixReturnTypeInAsyncFunction() +{ + auto errorCodes = FIX_RETURN_TYPE_IN_ASYNC_FUNCTION.GetSupportedCodeNumbers(); + SetErrorCodes({errorCodes.begin(), errorCodes.end()}); + SetFixIds({FIX_RETURN_TYPE_IN_ASYNC_FUNCTION.GetFixId().data()}); +} + +ir::AstNode *FixReturnTypeInAsyncFunction::GetFunctionReturnType(es2panda_Context *context, size_t position) +{ + const auto token = lsp::GetDefinitionAtPositionImpl(context, position); + const auto declaration = token.first; + + if (declaration == nullptr) { + return nullptr; + } + + auto *returnTypeNode = + declaration->FindChild([](ir::AstNode *childNode) { return childNode->IsETSTypeReference(); }); + + if (returnTypeNode == nullptr || !returnTypeNode->IsETSTypeReference()) { + return nullptr; + } + + return returnTypeNode; +} + +void FixReturnTypeInAsyncFunction::MakeChangeReturnTypeInAsyncFunction(ChangeTracker &changeTracker, + es2panda_Context *context, size_t pos) +{ + auto *returnTypeNode = GetFunctionReturnType(context, pos); + + if (returnTypeNode == nullptr || !returnTypeNode->IsETSTypeReference()) { + return; + } + + auto *ctx = reinterpret_cast(context); + auto *allocator = ctx->Allocator(); + + // Clone the original return type node + auto *originalInnerType1 = returnTypeNode->Clone(allocator, returnTypeNode->Parent()); + // Create a new Identifier for "Promise" + auto *promiseName = allocator->New(util::StringView("Promise"), allocator); + + // Wrap the original type inside Promise + ArenaVector typeParams(allocator->Adapter()); + auto *typedInner = static_cast(originalInnerType1); + typeParams.push_back(typedInner); + + auto *typeParamInstantiation = allocator->New(std::move(typeParams)); + + // Create the type reference part: Promise<...> + auto *promisePart = allocator->New(promiseName, typeParamInstantiation, + nullptr, // no previous part + allocator); + + // Create the final ETSTypeReference node + auto *newReturnType = allocator->New(promisePart, allocator); + + newReturnType->SetParent(returnTypeNode->Parent()); + originalInnerType1->SetParent(newReturnType); + newReturnType->SetStart(returnTypeNode->Start()); + auto returnTypeNodeIdent = returnTypeNode->AsETSTypeReference()->Part()->Name()->AsIdentifier(); + + lexer::SourcePosition endPos(newReturnType->Start().index + promiseName->Name().Length() + + returnTypeNodeIdent->Name().Length() + K_GENERIC_BRACKETS_LENGTH, + returnTypeNode->Start().line, ctx->parserProgram); + newReturnType->SetEnd(endPos); + // Replace the old return type with the new Promise type + changeTracker.ReplaceNode(context, returnTypeNode, newReturnType, {}); +} + +std::vector FixReturnTypeInAsyncFunction::GetChanges(const CodeFixContext &context) +{ + TextChangesContext textChangesContext = {context.host, context.formatContext, context.preferences}; + + auto fileTextChanges = ChangeTracker::With(textChangesContext, [&](ChangeTracker &tracker) { + MakeChangeReturnTypeInAsyncFunction(tracker, context.context, context.span.start); + }); + + return fileTextChanges; +} + +std::vector FixReturnTypeInAsyncFunction::GetCodeActions(const CodeFixContext &context) +{ + std::vector actions; + auto changes = GetChanges(context); + if (!changes.empty()) { + CodeFixAction action; + action.fixName = FIX_RETURN_TYPE_IN_ASYNC_FUNCTION.GetFixId().data(); + action.description = "Wrap return type in Promise"; + action.changes = changes; + action.fixId = FIX_RETURN_TYPE_IN_ASYNC_FUNCTION.GetFixId().data(); + action.fixAllDescription = "Wrap all incorrect async return types with Promise"; + actions.push_back(action); + } + + return actions; +} + +CombinedCodeActions FixReturnTypeInAsyncFunction::GetAllCodeActions(const CodeFixAllContext &codeFixAllCtx) +{ + CodeFixProvider provider; + const auto changes = provider.CodeFixAll( + codeFixAllCtx, GetErrorCodes(), [&](ChangeTracker &tracker, const DiagnosticWithLocation &diag) { + MakeChangeReturnTypeInAsyncFunction(tracker, codeFixAllCtx.context, diag.GetStart()); + }); + + CombinedCodeActions combined; + combined.changes = changes.changes; + combined.commands = changes.commands; + return combined; +} + +// NOLINTNEXTLINE +AutoCodeFixRegister g_fixReturnTypeInAsyncFunction( + FIX_RETURN_TYPE_IN_ASYNC_FUNCTION.GetFixId().data()); + +} // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/register_code_fix/forgotten_this_property_access.cpp b/ets2panda/lsp/src/register_code_fix/forgotten_this_property_access.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abad90b34984860c76b1749dbd261a4c768727e7 --- /dev/null +++ b/ets2panda/lsp/src/register_code_fix/forgotten_this_property_access.cpp @@ -0,0 +1,113 @@ +/** + * Copyright (c) 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. + */ + +#include "register_code_fix/forgotten_this_property_access.h" +#include +#include "code_fix_provider.h" +#include "generated/code_fix_register.h" + +namespace ark::es2panda::lsp { +using codefixes::FORGOTTEN_THIS_PROPERTY_ACCESS; + +ForgottenThisPropertyAccess::ForgottenThisPropertyAccess() +{ + auto errorCodes = FORGOTTEN_THIS_PROPERTY_ACCESS.GetSupportedCodeNumbers(); + SetErrorCodes({errorCodes.begin(), errorCodes.end()}); // change this to the error code you want to handle + SetFixIds({FORGOTTEN_THIS_PROPERTY_ACCESS.GetFixId().data()}); +} + +Info GetInfoThisProp(es2panda_Context *context, size_t offset) +{ + ir::AstNode *node = ark::es2panda::lsp::GetTouchingToken(context, offset, false); + std::string className; + if (node == nullptr) { + return {nullptr, ""}; + } + if (node->IsIdentifier()) { + className = node->AsIdentifier()->Name().Utf8(); + } + Info info(node, className); + return info; +} + +void DoChanges(es2panda_Context *context, ChangeTracker tracker) +{ + auto ctx = reinterpret_cast(context); + const auto impl = es2panda_GetImpl(ES2PANDA_LIB_VERSION); + + const auto &diagnostics = + ctx->diagnosticEngine->GetDiagnosticStorage(ark::es2panda::util::DiagnosticType::SEMANTIC); + + for (const auto &diagnostic : diagnostics) { + auto index = ark::es2panda::lexer::LineIndex(ctx->parserProgram->SourceCode()); + auto offset = index.GetOffset( + ark::es2panda::lexer::SourceLocation(diagnostic->Line(), diagnostic->Offset(), ctx->parserProgram)); + auto node = ark::es2panda::lsp::GetTouchingToken(context, offset, false); + es2panda_AstNode *thisExpr = impl->CreateThisExpression(context); + es2panda_AstNode *memberExpr = + impl->CreateMemberExpression(context, thisExpr, reinterpret_cast(node), + MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, false, false); + impl->AstNodeSetParent(context, thisExpr, memberExpr); + impl->AstNodeSetParent(context, reinterpret_cast(node), memberExpr); + auto memNode = reinterpret_cast(memberExpr); + if (memNode == nullptr) { + continue; + } + tracker.ReplaceNode(context, node, memNode, {}); + } +} + +std::vector ForgottenThisPropertyAccess::GetCodeActions(const CodeFixContext &context) +{ + std::vector returnedActions; + + const auto info = GetInfoThisProp(context.context, context.span.start); + if (info.GetNode() == nullptr) { + return {}; + } + TextChangesContext textChangesContext {context.host, context.formatContext, context.preferences}; + const auto changes = + ChangeTracker::With(textChangesContext, [&](ChangeTracker &tracker) { DoChanges(context.context, tracker); }); + std::vector actions; + CodeFixAction action; + action.fixName = FORGOTTEN_THIS_PROPERTY_ACCESS.GetFixId().data(); + action.description = "Add 'this.' to property access"; + action.fixId = FORGOTTEN_THIS_PROPERTY_ACCESS.GetFixId().data(); + action.changes.insert(action.changes.end(), changes.begin(), changes.end()); + action.fixAllDescription = "Add 'this.' to all property accesses in the file"; + returnedActions.push_back(action); + return returnedActions; +} + +CombinedCodeActions ForgottenThisPropertyAccess::GetAllCodeActions(const CodeFixAllContext &codeFixAll) +{ + CodeFixProvider provider; + const auto changes = provider.CodeFixAll(codeFixAll, GetErrorCodes(), + [&](ChangeTracker &tracker, const DiagnosticWithLocation &diag) { + auto info = GetInfoThisProp(codeFixAll.context, diag.GetStart()); + if (info.GetNode() != nullptr) { + DoChanges(codeFixAll.context, tracker); + } + }); + + CombinedCodeActions combined; + combined.changes = changes.changes; + combined.commands = changes.commands; + return combined; +} +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects, cert-err58-cpp) +AutoCodeFixRegister g_forgottenThisPropertyAccess("ForgottenThisPropertyAccess"); + +} // namespace ark::es2panda::lsp \ No newline at end of file diff --git a/ets2panda/lsp/src/rename.cpp b/ets2panda/lsp/src/rename.cpp index f4e385c428329ef862ee2f8ef1faecd162fe2fdd..d5bab32a0bf5383a288acd6d26cee9ebee79eacc 100644 --- a/ets2panda/lsp/src/rename.cpp +++ b/ets2panda/lsp/src/rename.cpp @@ -93,6 +93,9 @@ bool IsDefinedInLibraryFile(const ir::AstNode *node, const std::string &pandaLib return false; } auto filePath = node->Range().start.Program()->SourceFile().GetAbsolutePath().Utf8(); + if (filePath.find(pandaLibPath) != std::string::npos) { + return true; + } std::string etsPath = pandaLibPath; size_t pos = 0; const int threeLevelsUp = 3; @@ -102,13 +105,16 @@ bool IsDefinedInLibraryFile(const ir::AstNode *node, const std::string &pandaLib etsPath = etsPath.substr(0, pos); } } - const std::array libraryPaths = { - pandaLibPath + util::PATH_DELIMITER + "stdlib" + util::PATH_DELIMITER + "std", - pandaLibPath + util::PATH_DELIMITER + "stdlib" + util::PATH_DELIMITER + "escompat", - etsPath + util::PATH_DELIMITER + "api", etsPath + util::PATH_DELIMITER + "arkts", - etsPath + util::PATH_DELIMITER + "kits"}; - for (const auto &libraryPath : libraryPaths) { - if (filePath.find(libraryPath) != std::string::npos) { + // check etsPath in openharmony sdk + if (filePath.find(etsPath) != std::string::npos) { + return true; + } + std::string oh = "openharmony"; + pos = etsPath.rfind(oh); + if (pos != std::string::npos) { + etsPath.replace(pos, oh.size(), "hms"); + // check etsPath in hms sdk + if (filePath.find(etsPath) != std::string::npos) { return true; } } @@ -318,16 +324,60 @@ std::optional GetRenameInfoForModule(ir::AstNode *node, parse "", triggerSpan); } +std::string GetKindOfMethod(ir::AstNode *node) +{ + if (!node->IsMethodDefinition()) { + return ""; + } + switch (node->AsMethodDefinition()->Kind()) { + case ir::MethodDefinitionKind::METHOD: + return "method"; + case ir::MethodDefinitionKind::GET: + return "get"; + case ir::MethodDefinitionKind::SET: + return "set"; + case ir::MethodDefinitionKind::CONSTRUCTOR: + return "constructor"; + default: + return ""; + } +} + +std::string GetKindOfClassDefinition(ir::AstNode *node) +{ + if (!node->IsClassDefinition()) { + return ""; + } + if (node->AsClassDefinition()->OrigEnumDecl() != nullptr) { + return "enum"; + } + if (node->AsClassDefinition()->IsNamespaceTransformed()) { + return "namespace"; + } + if (node->Parent()->IsETSStructDeclaration()) { + return "struct"; + } + return "class"; +} + std::optional GetKindOfPropertyMethodFunctionOrVar(ir::AstNode *node) { switch (node->Type()) { case ir::AstNodeType::CLASS_PROPERTY: + if (compiler::ClassDefinitionIsEnumTransformed(node->Parent())) { + return "enum member"; + } return "property"; case ir::AstNodeType::FUNCTION_DECLARATION: - case ir::AstNodeType::METHOD_DEFINITION: return "function"; + case ir::AstNodeType::METHOD_DEFINITION: + return GetKindOfMethod(node); case ir::AstNodeType::VARIABLE_DECLARATION: return "variable"; + case ir::AstNodeType::IMPORT_DECLARATION: + return "import"; + case ir::AstNodeType::CLASS_DEFINITION: + return GetKindOfClassDefinition(node); default: return std::nullopt; } @@ -343,7 +393,7 @@ std::string GetNodeKindForRenameInfo(ir::AstNode *node) case ir::AstNodeType::TS_ENUM_DECLARATION: return "enum"; case ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION: - return "type"; + return "type alias"; case ir::AstNodeType::TS_INTERFACE_DECLARATION: return "interface"; case ir::AstNodeType::TS_TYPE_PARAMETER: @@ -352,6 +402,8 @@ std::string GetNodeKindForRenameInfo(ir::AstNode *node) return "enum member"; case ir::AstNodeType::TS_MODULE_DECLARATION: return "module"; + case ir::AstNodeType::ETS_PARAMETER_EXPRESSION: + return "parameter"; default: return ""; } diff --git a/ets2panda/lsp/src/services/text_change/change_tracker.cpp b/ets2panda/lsp/src/services/text_change/change_tracker.cpp index 949c7f1747eb1134ccc71651b392156f5bbffca3..77e1e41ff091d6cf0a3acf0fde6160358bba8915 100644 --- a/ets2panda/lsp/src/services/text_change/change_tracker.cpp +++ b/ets2panda/lsp/src/services/text_change/change_tracker.cpp @@ -18,7 +18,6 @@ #include #include #include -#include "util.h" #include #include @@ -795,6 +794,8 @@ std::vector ChangeTracker::GetTextChangesFromChanges(std::vecto addChange(textChange->sourceFile, textChange->range, textChange->text); } else if (const auto *remove = std::get_if(&change)) { addChange(remove->sourceFile, remove->range, ""); + } else if (const auto *replace = std::get_if(&change)) { + addChange(replace->sourceFile, replace->range, replace->node->DumpEtsSrc()); } } diff --git a/ets2panda/lsp/src/signature_help.cpp b/ets2panda/lsp/src/signature_help.cpp index 58a726287f413e54d0020a927636592cbe8c46ac..03cb954749b56aa8cc5f880ba8158193e95f8f38 100644 --- a/ets2panda/lsp/src/signature_help.cpp +++ b/ets2panda/lsp/src/signature_help.cpp @@ -325,16 +325,20 @@ std::optional GetImmediatelyContainingArgumentInfo(ir::AstNode if (position == 0) { return std::nullopt; } - if (node->Parent()->Type() == ir::AstNodeType::CALL_EXPRESSION || - node->Parent()->Type() == ir::AstNodeType::NEW_EXPRESSION) { - auto const invocation = node->Parent(); + auto parent = node->Parent(); + if (parent->Type() == ir::AstNodeType::CALL_EXPRESSION || parent->Type() == ir::AstNodeType::NEW_EXPRESSION || + parent->Type() == ir::AstNodeType::MEMBER_EXPRESSION) { + if (parent->IsMemberExpression() && parent->Parent() != nullptr && parent->Parent()->IsCallExpression()) { + parent = parent->Parent(); + } + auto const invocation = parent; - auto const argument = GetArgumentOrParameterListInfo(node->Parent()); + auto const argument = GetArgumentOrParameterListInfo(parent); const auto &list = argument.GetList(); if (!list.empty()) { auto const argumentIndex = argument.GetArgumentIndex(); - auto const argumentCount = GetArgumentCount(node->Parent(), false); - auto const span = CreateTextSpanForNode(node->Parent()); + auto const argumentCount = GetArgumentCount(parent, false); + auto const span = CreateTextSpanForNode(parent); ArgumentListInfo argumentList; argumentList.SetInvocation(Invocation(CallInvocation {InvocationKind::CALL, invocation})); argumentList.SetApplicableSpan(span); @@ -342,8 +346,8 @@ std::optional GetImmediatelyContainingArgumentInfo(ir::AstNode argumentList.SetArgumentCount(argumentCount); return argumentList; } - } else if (node->Parent()->Type() == ir::AstNodeType::METHOD_DEFINITION) { - auto const info = GetContextualSignatureLocationInfo(node->Parent()); + } else if (parent->Type() == ir::AstNodeType::METHOD_DEFINITION) { + auto const info = GetContextualSignatureLocationInfo(parent); if (!info) { return std::nullopt; } @@ -352,7 +356,7 @@ std::optional GetImmediatelyContainingArgumentInfo(ir::AstNode auto const span = info->GetArgumentsSpan(); std::optional argumentList = ArgumentListInfo(); const ContextualInvocation invocation = ContextualInvocation { - InvocationKind::CONTEXTUAL, node->Parent()->AsMethodDefinition()->Function()->Signature(), node->Parent()}; + InvocationKind::CONTEXTUAL, parent->AsMethodDefinition()->Function()->Signature(), parent}; argumentList->SetInvocation(invocation); argumentList->SetApplicableSpan(span); argumentList->SetArgumentIndex(index); diff --git a/ets2panda/lsp/src/suggestion_diagnostics.cpp b/ets2panda/lsp/src/suggestion_diagnostics.cpp index ae94deae2ec25755f8b6ded790026c46a1549fa3..9b7d54c8e69b554b92ca54dab4c026a3f404bdba 100644 --- a/ets2panda/lsp/src/suggestion_diagnostics.cpp +++ b/ets2panda/lsp/src/suggestion_diagnostics.cpp @@ -22,13 +22,13 @@ namespace ark::es2panda::lsp { -std::vector GetSuggestionDiagnosticsImpl(ir::AstNode *astNode) +std::vector GetSuggestionDiagnosticsImpl(ir::AstNode *astNode, es2panda_Context *context) { std::unordered_map visitedNestedConvertibleFunctions; std::vector diags; if (astNode != nullptr) { - Check(astNode, diags, visitedNestedConvertibleFunctions); + Check(astNode, diags, visitedNestedConvertibleFunctions, context); if (!diags.empty()) { std::sort(diags.begin(), diags.end(), [](const FileDiagnostic &d1, const FileDiagnostic &d2) { return d1.diagnostic.range_.start.line_ < d2.diagnostic.range_.start.line_; @@ -38,14 +38,18 @@ std::vector GetSuggestionDiagnosticsImpl(ir::AstNode *astNode) return diags; } -void Check(ir::AstNode *node, std::vector &diag, std::unordered_map &visitedFunc) +void Check(ir::AstNode *node, std::vector &diag, std::unordered_map &visitedFunc, + es2panda_Context *context) { if (CanBeConvertedToAsync(node)) { - AddConvertToAsyncFunctionDiagnostics(node, diag, visitedFunc); + AddConvertToAsyncFunctionDiagnostics(node, diag, visitedFunc, context); } - node->FindChild([&diag, &visitedFunc](ir::AstNode *childNode) { - Check(childNode, diag, visitedFunc); + node->FindChild([&diag, &visitedFunc, &node, &context](ir::AstNode *childNode) { + // It should only Check direct child node istead of all child and grandchild node, according to tsc + if (childNode->Parent() == node) { + Check(childNode, diag, visitedFunc, context); + } return false; }); } @@ -60,16 +64,21 @@ bool CheckGivenTypeExistInChilds(ir::AstNode *node, ir::AstNodeType type) } void AddConvertToAsyncFunctionDiagnostics(ir::AstNode *node, std::vector &diag, - std::unordered_map &visitedFunc) + std::unordered_map &visitedFunc, es2panda_Context *context) { if (IsConvertibleFunction(node, visitedFunc) && (visitedFunc.count(GetKeyFromNode(node)) == 0)) { - Position posStart(node->Range().start.line, node->Range().start.index); - Position posEnd(node->Range().end.line, node->Range().end.index); + auto ctx = reinterpret_cast(context); + // The line and col should start from 1 istead of 0 + auto index = lexer::LineIndex(ctx->parserProgram->SourceCode()); + auto sourceStartLocation = index.GetLocation(node->Range().start); + auto sourceEndLocation = index.GetLocation(node->Range().end); + Position posStart(sourceStartLocation.line, sourceStartLocation.col); + Position posEnd(sourceEndLocation.line, sourceEndLocation.col); Range range(posStart, posEnd); const std::string message = "This_may_be_converted_to_an_async_function"; Diagnostic diagnostic(range, {}, {}, DiagnosticSeverity::Hint, 0, message, {}, {}, {}); - diag.push_back(lsp::CreateDiagnosticForNode(reinterpret_cast(node), diagnostic)); + diag.push_back(lsp::CreateDiagnosticForNode(reinterpret_cast(node), diagnostic, context)); } } diff --git a/ets2panda/parser/ASparser.cpp b/ets2panda/parser/ASparser.cpp index f2567fef3d343350723a2e1b2eda79099eca4d4e..2e0e102951fd5e5354e778737b6ed345fbad31bc 100644 --- a/ets2panda/parser/ASparser.cpp +++ b/ets2panda/parser/ASparser.cpp @@ -1122,6 +1122,7 @@ ArenaVector ASParser::ParseClassImplementClause() const lexer::SourcePosition &implementStart = Lexer()->GetToken().Start(); auto *implementsName = AllocNode(Lexer()->GetToken().Ident(), Allocator()); + ES2PANDA_ASSERT(implementsName != nullptr); implementsName->SetRange(Lexer()->GetToken().Loc()); auto *implementsClause = AllocNode(implementsName, Allocator()); ES2PANDA_ASSERT(implementsClause != nullptr); @@ -1137,6 +1138,7 @@ ArenaVector ASParser::ParseClassImplementClause() } implementsName = AllocNode(Lexer()->GetToken().Ident(), Allocator()); + ES2PANDA_ASSERT(implementsName != nullptr); implementsName->SetRange(Lexer()->GetToken().Loc()); auto *next = AllocNode(implementsName, Allocator()); current->SetRange(Lexer()->GetToken().Loc()); @@ -1740,6 +1742,7 @@ ir::Statement *ASParser::ParseImportDeclaration([[maybe_unused]] StatementParsin source = ParseFromClause(false); } + ES2PANDA_ASSERT(source != nullptr); lexer::SourcePosition endLoc = source->End(); auto *importDeclaration = AllocNode(source, std::move(specifiers)); ES2PANDA_ASSERT(importDeclaration != nullptr); diff --git a/ets2panda/parser/ETSFormattedParser.cpp b/ets2panda/parser/ETSFormattedParser.cpp index 04f2616c11d49ee11dde706040f2d26ddd22d303..b3acf5e5596b2743139e756cb526ab959efd903c 100644 --- a/ets2panda/parser/ETSFormattedParser.cpp +++ b/ets2panda/parser/ETSFormattedParser.cpp @@ -106,8 +106,8 @@ ir::TypeNode *ETSParser::ParseTypeFormatPlaceholder(std::optionalGetToken().Start()); - ES2PANDA_UNREACHABLE(); + LogUnexpectedToken(lexer::TokenType::PUNCTUATOR_FORMAT); + return AllocBrokenType(Lexer()->GetToken().Loc()); } nodeFormat = GetFormatPlaceholderType(); diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 5541ac57d5cccf3e8bd73bceeebf9e07e9ab73a1..7847a5b8999cd2fe40f0282da0925000f4794c06 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -99,12 +99,15 @@ bool ETSParser::IsETSParser() const noexcept return true; } +bool ETSParser::IsValidIdentifierName(const lexer::Token &token) const noexcept +{ + return !token.IsPredefinedType() || util::Helpers::IsStdLib(GetProgram()); +} + std::unique_ptr ETSParser::InitLexer(const SourceFile &sourceFile) { GetProgram()->SetSource(sourceFile); - GetContext().Status() |= ParserStatus::ALLOW_JS_DOC_START; auto lexer = std::make_unique(&GetContext(), DiagnosticEngine()); - GetContext().Status() ^= ParserStatus::ALLOW_JS_DOC_START; SetLexer(lexer.get()); return lexer; } @@ -155,7 +158,7 @@ void ETSParser::ParseFileHeaderFlag(lexer::SourcePosition startLoc, ArenaVector< ir::Expression *fileHeaderFlag = ParseStringLiteral(); auto *exprStatementNode = AllocNode(fileHeaderFlag); - + ES2PANDA_ASSERT(exprStatementNode != nullptr); exprStatementNode->SetRange({startLoc, fileHeaderFlag->End()}); ConsumeSemicolon(exprStatementNode); if (statements != nullptr) { @@ -193,10 +196,6 @@ ir::ETSModule *ETSParser::ParseImportsAndReExportOnly(lexer::SourcePosition star ETSNolintParser etsnolintParser(this); etsnolintParser.CollectETSNolints(); - if (Lexer()->TryEatTokenType(lexer::TokenType::JS_DOC_START)) { - // Note: Not Support JS_DOC for Import declaration now, just go on; - ParseJsDocInfos(); - } auto imports = ParseImportDeclarations(); statements.insert(statements.end(), imports.begin(), imports.end()); etsnolintParser.ApplyETSNolintsToStatements(statements); @@ -209,9 +208,9 @@ ir::ETSModule *ETSParser::ParseImportsAndReExportOnly(lexer::SourcePosition star return etsModule; } -bool ETSParser::CheckDupAndReplace(Program *&oldProg, Program *newProg) +bool ETSParser::CheckDupAndReplace(Program *&oldProg, Program *newProg) const { - if (!importPathManager_->ArkTSConfig()->UseUrl() && oldProg->FileName() == newProg->FileName() && + if (oldProg->FileName() == newProg->FileName() && oldProg->FileNameWithExtension() != newProg->FileNameWithExtension()) { bool oldIsDeclare = oldProg->FileNameWithExtension().Length() > newProg->FileNameWithExtension().Length(); if (oldIsDeclare) { @@ -236,7 +235,7 @@ void ETSParser::AddExternalSource(const std::vector &programs) } bool found = false; auto &extProgs = extSources.at(name); - for (auto prog : extProgs) { + for (auto &prog : extProgs) { if (prog->SourceFilePath() == newProg->SourceFilePath()) { found = true; break; @@ -297,7 +296,13 @@ void ETSParser::AddDirectImportsToDirectExternalSources( if (GetProgram()->DirectExternalSources().count(name) == 0) { GetProgram()->DirectExternalSources().try_emplace(name, Allocator()->Adapter()); } - GetProgram()->DirectExternalSources().at(name).emplace_back(newProg); + auto &dirExternal = GetProgram()->DirectExternalSources().at(name); + for (auto &prog : dirExternal) { + if (CheckDupAndReplace(prog, newProg)) { + return; + } + } + dirExternal.emplace_back(newProg); } void ETSParser::ParseParseListElement(const util::ImportPathManager::ParseInfo &parseListElem, util::UString *extSrc, @@ -706,7 +711,16 @@ ir::AstNode *ETSParser::ParseInnerRest(const ArenaVector &propert } auto *memberName = ExpectIdentifier(false, false, TypeAnnotationParsingOptions::NO_OPTS); // don't report error - if (memberName == nullptr) { // log error here + if (memberName == nullptr) { + auto tokenType = Lexer()->GetToken().Type(); + if (Lexer()->TryEatTokenType(lexer::TokenType::KEYW_NEW) || + Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { + LogError(diagnostic::CALL_SIG_IN_OBJECT, + {tokenType == lexer::TokenType::KEYW_NEW ? "Constructor" : "Call"}); + auto *ident = AllocNode("dummy", Allocator()); + parseClassMethod(ident); + return AllocBrokenStatement(Lexer()->GetToken().Loc()); + } // log error here LogUnexpectedToken(Lexer()->GetToken()); const auto &rangeToken = Lexer()->GetToken().Loc(); Lexer()->NextToken(); @@ -801,10 +815,6 @@ ir::TSTypeAliasDeclaration *ETSParser::ParseTypeAliasDeclaration() ES2PANDA_ASSERT(Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_TYPE); const auto start = Lexer()->Save(); - - auto newStatus = GetContext().Status(); - newStatus &= ~ParserStatus::ALLOW_JS_DOC_START; - SavedParserContext savedContext(this, newStatus); lexer::SourcePosition typeStart = Lexer()->GetToken().Start(); Lexer()->NextToken(); // eat type keyword @@ -832,7 +842,8 @@ ir::TSTypeAliasDeclaration *ETSParser::ParseTypeAliasDeclaration() ExpectToken(lexer::TokenType::PUNCTUATOR_SUBSTITUTION); - TypeAnnotationParsingOptions options = TypeAnnotationParsingOptions::REPORT_ERROR; + TypeAnnotationParsingOptions options = + TypeAnnotationParsingOptions::REPORT_ERROR | TypeAnnotationParsingOptions::TYPE_ALIAS_CONTEXT; ir::TypeNode *typeAnnotation = ParseTypeAnnotation(&options); if (typeAnnotation == nullptr) { return nullptr; @@ -1027,6 +1038,7 @@ ir::TypeNode *ETSParser::ParseTypeReference(TypeAnnotationParsingOptions *option } typeRefPart = AllocNode(typeName, typeParams, typeRefPart, Allocator()); + ES2PANDA_ASSERT(typeRefPart != nullptr); typeRefPart->SetRange({partPos, Lexer()->GetToken().End()}); if (!Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_PERIOD)) { @@ -1071,7 +1083,7 @@ ir::TypeNode *ETSParser::ParseBaseTypeReference(TypeAnnotationParsingOptions *op ir::TypeNode *ETSParser::ParseLiteralIdent(TypeAnnotationParsingOptions *options) { - if (Lexer()->GetToken().IsDefinableTypeName()) { + if (Lexer()->GetToken().IsPredefinedType()) { return GetTypeAnnotationOfPrimitiveType(Lexer()->GetToken().KeywordType(), options); } @@ -1119,21 +1131,42 @@ ir::Statement *ETSParser::CreateReExportDeclarationNode(ir::ETSImportDeclaration } auto reExport = AllocNode(reExportDeclaration, std::vector(), GetProgram()->AbsoluteName(), Allocator()); + ES2PANDA_ASSERT(reExport != nullptr); reExport->AddModifier(modifiers); + reExport->SetRange(reExportDeclaration->Range()); return reExport; } +ir::Statement *ETSParser::ParseDefaultIfSingleExport(ir::ModifierFlags modifiers) +{ + auto tokenType = Lexer()->GetToken().Type(); + if (tokenType != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { + return ParseSingleExport(modifiers); + } + auto savePos = Lexer()->Save(); + Lexer()->NextToken(); + auto isSelectiveExport = Lexer()->TryEatTokenType(lexer::TokenType::LITERAL_IDENT) && + (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA || + Lexer()->GetToken().Type() == lexer::TokenType::KEYW_AS || + Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE); + Lexer()->Rewind(savePos); + return !isSelectiveExport ? ParseSingleExport(modifiers) : nullptr; +} + ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::ModifierFlags modifiers) { const size_t exportDefaultMaxSize = 1; if (!InAmbientContext() && (GetContext().Status() & ParserStatus::IN_NAMESPACE) != 0) { LogError(diagnostic::EXPORT_IN_NAMESPACE); } - [[maybe_unused]] auto tokenType = Lexer()->GetToken().Type(); // export a constant variable anonymously, as export default new A() - if ((modifiers & ir::ModifierFlags::DEFAULT_EXPORT) != 0U && tokenType != lexer::TokenType::PUNCTUATOR_MULTIPLY && - tokenType != lexer::TokenType::PUNCTUATOR_LEFT_BRACE && tokenType != lexer::TokenType::LITERAL_IDENT) { - return ParseSingleExport(modifiers); + if ((modifiers & ir::ModifierFlags::DEFAULT_EXPORT) != 0U && + Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_MULTIPLY && + Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { + auto exportedExpression = ParseDefaultIfSingleExport(modifiers); + if (exportedExpression != nullptr) { + return exportedExpression; + } } ArenaVector specifiers(Allocator()->Adapter()); @@ -1149,8 +1182,10 @@ ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::Modifi specifiers = util::Helpers::ConvertVector(specs.result); } else { ArenaVector exports(Allocator()->Adapter()); + auto endLoc = startLoc; for (auto spec : specs.result) { exports.emplace_back(AllocNode(spec->Local(), spec->Imported())); + endLoc = endLoc.index < spec->End().index ? spec->End() : endLoc; } if (specs.resultExportDefault.size() > exportDefaultMaxSize) { @@ -1158,12 +1193,14 @@ ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::Modifi } for (auto spec : specs.resultExportDefault) { exports.emplace_back(spec); + endLoc = endLoc.index < spec->End().index ? spec->End() : endLoc; } auto result = AllocNode(Allocator(), static_cast(nullptr), std::move(exports)); ES2PANDA_ASSERT(result != nullptr); result->AddModifier(modifiers); + result->SetRange({startLoc, endLoc}); return result; } } else { @@ -1180,11 +1217,6 @@ ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::Modifi ir::ETSPackageDeclaration *ETSParser::ParsePackageDeclaration() { auto startLoc = Lexer()->GetToken().Start(); - auto savedPos = Lexer()->Save(); - if (Lexer()->TryEatTokenType(lexer::TokenType::JS_DOC_START)) { - // Note: Not Support JS_DOC for Package declaration now, just go on; - ParseJsDocInfos(); - } if (!Lexer()->TryEatTokenType(lexer::TokenType::KEYW_PACKAGE)) { // NOTE(vpukhov): the *unnamed* modules are to be removed entirely @@ -1192,7 +1224,6 @@ ir::ETSPackageDeclaration *ETSParser::ParsePackageDeclaration() util::StringView moduleName = isUnnamed ? "" : importPathManager_->FormModuleName(GetProgram()->SourceFile(), startLoc); GetProgram()->SetPackageInfo(moduleName, util::ModuleKind::MODULE); - Lexer()->Rewind(savedPos); return nullptr; } @@ -1223,6 +1254,7 @@ ir::ETSImportDeclaration *ETSParser::ParseImportPathBuildImport(ArenaVector(ERROR_LITERAL); + ES2PANDA_ASSERT(errorLiteral != nullptr); errorLiteral->SetRange(Lexer()->GetToken().Loc()); auto *const importDeclaration = AllocNode( errorLiteral, util::ImportPathManager::ImportMetadata {}, std::move(specifiers), importKind); @@ -1263,15 +1295,6 @@ ir::ETSImportDeclaration *ETSParser::BuildImportDeclaration(ir::ImportKinds impo std::move(specifiers), importKind); } -lexer::LexerPosition ETSParser::HandleJsDocLikeComments() -{ - auto savedPos = Lexer()->Save(); - if (Lexer()->TryEatTokenType(lexer::TokenType::JS_DOC_START)) { - ParseJsDocInfos(); - } - return savedPos; -} - ArenaVector ETSParser::ParseETSInitModuleStatements() { std::vector userPaths; @@ -1284,9 +1307,9 @@ ArenaVector ETSParser::ParseETSInitModuleStatements() ArenaVector ETSParser::ParseImportDeclarations() { - auto savedPos = HandleJsDocLikeComments(); std::vector userPaths; ArenaVector statements(Allocator()->Adapter()); + while (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_IMPORT) { auto startLoc = Lexer()->GetToken().Start(); Lexer()->NextToken(); // eat import @@ -1312,6 +1335,7 @@ ArenaVector ETSParser::ParseImportDeclarations() auto pos = Lexer()->Save(); if (!specifiers.empty()) { auto *const importDecl = ParseImportPathBuildImport(std::move(specifiers), true, startLoc, importKind); + ES2PANDA_ASSERT(importDecl != nullptr); statements.push_back(importDecl->AsETSImportDeclaration()); } @@ -1325,11 +1349,8 @@ ArenaVector ETSParser::ParseImportDeclarations() statements.push_back(importDeclDefault->AsETSImportDeclaration()); } } - - savedPos = HandleJsDocLikeComments(); } - Lexer()->Rewind(savedPos); std::sort(statements.begin(), statements.end(), [](const auto *s1, const auto *s2) -> bool { return s1->Specifiers()[0]->IsImportNamespaceSpecifier() && !s2->Specifiers()[0]->IsImportNamespaceSpecifier(); }); @@ -1366,6 +1387,10 @@ ir::ExportNamedDeclaration *ETSParser::ParseSingleExport(ir::ModifierFlags modif return ParseSingleExportForAnonymousConst(modifiers); } + if (token.KeywordType() == lexer::TokenType::KEYW_AS) { + LogError(diagnostic::ERROR_ARKTS_NO_UMD, {}, token.Start()); + return nullptr; + } if (token.Type() != lexer::TokenType::LITERAL_IDENT) { LogError(diagnostic::EXPORT_NON_DECLARATION, {}, token.Start()); return nullptr; @@ -1379,8 +1404,10 @@ ir::ExportNamedDeclaration *ETSParser::ParseSingleExport(ir::ModifierFlags modif ArenaVector exports(Allocator()->Adapter()); exports.emplace_back(AllocNode(exported, ParseNamedExport(&token))); + exports.back()->SetRange(exported->Range()); auto result = AllocNode(Allocator(), static_cast(nullptr), std::move(exports)); + result->SetRange(exported->Range()); ES2PANDA_ASSERT(result != nullptr); result->AddModifier(modifiers); ConsumeSemicolon(result); @@ -1498,6 +1525,12 @@ SpecifiersInfo ETSParser::ParseNamedSpecifiers() ArenaVector resultDefault(Allocator()->Adapter()); ArenaVector resultExportDefault(Allocator()->Adapter()); + auto token = Lexer()->GetToken(); + if (token.Ident() == (lexer::TokenToString(lexer::TokenType::KEYW_IMPORT)) && + token.Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { + LogError(diagnostic::ERROR_ARKTS_NO_SIDE_EFFECT_IMPORT); + } + ParseList( lexer::TokenType::PUNCTUATOR_RIGHT_BRACE, lexer::NextTokenFlags::KEYWORD_TO_IDENT, [this, &result, &resultDefault, &resultExportDefault, &fileName]() { @@ -1552,6 +1585,10 @@ void ETSParser::ParseNameSpaceSpecifier(ArenaVector *specifiers, ir::AstNode *ETSParser::ParseImportDefaultSpecifier(ArenaVector *specifiers) { + if (Lexer()->GetToken().Type() == lexer::TokenType::LITERAL_STRING) { + LogError(diagnostic::ERROR_ARKTS_NO_SIDE_EFFECT_IMPORT); + return nullptr; + } if (Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { LogExpectedToken(lexer::TokenType::LITERAL_IDENT); } @@ -1605,6 +1642,7 @@ ir::AnnotatedExpression *ETSParser::GetAnnotatedExpressionFromParam() switch (Lexer()->GetToken().Type()) { case lexer::TokenType::LITERAL_IDENT: { parameter = AllocNode(Lexer()->GetToken().Ident(), Allocator()); + ES2PANDA_ASSERT(parameter != nullptr); if (parameter->AsIdentifier()->Decorators().empty()) { parameter->SetRange(Lexer()->GetToken().Loc()); } else { @@ -1627,6 +1665,7 @@ ir::AnnotatedExpression *ETSParser::GetAnnotatedExpressionFromParam() restIdent->SetRange(Lexer()->GetToken().Loc()); parameter = AllocNode(ir::AstNodeType::REST_ELEMENT, Allocator(), restIdent); + ES2PANDA_ASSERT(parameter != nullptr); parameter->SetRange({startLoc, Lexer()->GetToken().End()}); break; } @@ -1751,8 +1790,11 @@ ir::Expression *ETSParser::ParseFunctionParameter() typeAnnotation->SetParent(paramIdent); paramIdent->SetTsTypeAnnotation(typeAnnotation); paramIdent->SetEnd(typeAnnotation->End()); - } else if (!isArrow && !isOptional) { + } + + if ((!isArrow || isOptional) && paramIdent->TypeAnnotation() == nullptr) { LogError(diagnostic::EXPLICIT_PARAM_TYPE); + paramIdent->SetTsTypeAnnotation(AllocBrokenType(Lexer()->GetToken().Loc())); } return ParseFunctionParameterExpression(paramIdent, isOptional); @@ -1888,8 +1930,10 @@ void ETSParser::ParseCatchParamTypeAnnotation([[maybe_unused]] ir::AnnotatedExpr ir::Statement *ETSParser::ParseImportDeclaration([[maybe_unused]] StatementParsingFlags flags) { + bool isError = false; if ((flags & StatementParsingFlags::GLOBAL) == 0) { LogError(diagnostic::IMPORT_TOP_LEVEL); + isError = true; } char32_t nextChar = Lexer()->Lookahead(); @@ -1916,7 +1960,7 @@ ir::Statement *ETSParser::ParseImportDeclaration([[maybe_unused]] StatementParsi importDeclaration = ParseImportPathBuildImport(std::move(specifiers), false, startLoc, ir::ImportKinds::ALL); } - return importDeclaration; + return isError ? AllocBrokenStatement(startLoc) : importDeclaration; } ir::Statement *ETSParser::ParseExportDeclaration([[maybe_unused]] StatementParsingFlags flags) @@ -2047,15 +2091,19 @@ ir::AstNode *ETSParser::ParseAmbientSignature(const lexer::SourcePosition &start } // eat ":" - if (Lexer()->NextToken(); Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_NUMBER) { + if (Lexer()->NextToken(); Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_NUMBER && + Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_INT) { // ambient_indexer_3.ets LogError(diagnostic::INDEX_TYPE_NOT_NUMBER); Lexer()->GetToken().SetTokenType(lexer::TokenType::KEYW_NUMBER); } + TypeAnnotationParsingOptions typAnotationOptions = TypeAnnotationParsingOptions::NO_OPTS; + auto typeAnno = ParseTypeAnnotation(&typAnotationOptions); + // eat indexType - if (Lexer()->NextToken(); Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { + if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { // ambient_indexer_7.ets LogError(diagnostic::EXPECTED_BRACKETS_IN_INDEX); @@ -2066,26 +2114,24 @@ ir::AstNode *ETSParser::ParseAmbientSignature(const lexer::SourcePosition &start if (Lexer()->NextToken(); Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { // ambient_indexer_4.ets LogError(diagnostic::INDEX_MISSING_TYPE); + } - Lexer()->GetToken().SetTokenType(lexer::TokenType::PUNCTUATOR_COLON); + if (!Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_COLON)) { + LogError(diagnostic::EXPECTED_PARAM_GOT_PARAM, {":", TokenToString(Lexer()->GetToken().Type())}); } - // eat ":" - if (Lexer()->NextToken(); Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { - // ambient_indexer_5.ets + TypeAnnotationParsingOptions options = + TypeAnnotationParsingOptions::RETURN_TYPE | TypeAnnotationParsingOptions::REPORT_ERROR; + auto *returnType = ParseTypeAnnotation(&options); + if (returnType->IsBrokenTypeNode()) { LogError(diagnostic::INDEX_MISSING_IDENTIFIER); - - Lexer()->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); - Lexer()->GetToken().SetTokenStr(ERROR_LITERAL); + return AllocBrokenStatement({startPos, Lexer()->GetToken().End()}); } - auto const returnType = AllocNode( - AllocNode(Lexer()->GetToken().Ident(), Allocator()), Allocator()); auto dummyNode = AllocNode(compiler::Signatures::AMBIENT_INDEXER, indexName, returnType, - ir::DummyNodeFlag::INDEXER); + ir::DummyNodeFlag::INDEXER, typeAnno); ES2PANDA_ASSERT(dummyNode != nullptr); dummyNode->SetRange({startPos, Lexer()->GetToken().End()}); - Lexer()->NextToken(); // eat return type return dummyNode; } @@ -2206,8 +2252,9 @@ void ETSParser::CheckDeclare() void ETSParser::ValidateOverloadDeclarationModifiers(ir::ModifierFlags modifiers) { - ir::ModifierFlags allowModifiers = - ir::ModifierFlags::STATIC | ir::ModifierFlags::ASYNC | ir::ModifierFlags::ACCESS | ir::ModifierFlags::EXPORTED; + ir::ModifierFlags allowModifiers = ir::ModifierFlags::STATIC | ir::ModifierFlags::ASYNC | + ir::ModifierFlags::ACCESS | ir::ModifierFlags::EXPORTED | + ir::ModifierFlags::DECLARE; if ((modifiers & ~allowModifiers) != 0) { LogError(diagnostic::OVERLOAD_MODIFIERS); } @@ -2225,6 +2272,7 @@ bool ETSParser::ParseOverloadListElement(ArenaVector &overload while (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_PERIOD)) { if (Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { LogExpectedToken(lexer::TokenType::LITERAL_IDENT); + return false; } auto *identNode = AllocNode(Lexer()->GetToken().Ident(), Allocator()); identNode->SetRange(Lexer()->GetToken().Loc()); @@ -2285,7 +2333,7 @@ ir::FunctionDeclaration *ETSParser::ParseFunctionDeclaration(bool canBeAnonymous ES2PANDA_ASSERT(Lexer()->GetToken().Type() == lexer::TokenType::KEYW_FUNCTION); Lexer()->NextToken(); - auto newStatus = ParserStatus::NEED_RETURN_TYPE | ParserStatus::ALLOW_SUPER | ParserStatus::ALLOW_JS_DOC_START; + auto newStatus = ParserStatus::NEED_RETURN_TYPE | ParserStatus::ALLOW_SUPER; if ((modifiers & ir::ModifierFlags::ASYNC) != 0) { newStatus |= ParserStatus::ASYNC_FUNCTION; @@ -2322,6 +2370,7 @@ ir::FunctionDeclaration *ETSParser::ParseFunctionDeclaration(bool canBeAnonymous Lexer()->NextToken(); } + ES2PANDA_ASSERT(funcDecl != nullptr); funcDecl->SetRange(func->Range()); func->AddModifier(modifiers); func->SetStart(startLoc); diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index 8dddff53b552b11d0a614b68096e469630cd1ceb..bd8fcb7b1cf5b5fb2e3d2ae40926037f3d34e8af 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -18,7 +18,6 @@ #include "util/arktsconfig.h" #include "util/importPathManager.h" -#include "util/recursiveGuard.h" #include "innerSourceParser.h" #include "TypedParser.h" #include "ir/base/classDefinition.h" @@ -68,11 +67,12 @@ public: [[nodiscard]] bool IsETSParser() const noexcept override; + [[nodiscard]] bool IsValidIdentifierName(const lexer::Token &token) const noexcept override; + void AddDirectImportsToDirectExternalSources(const ArenaVector &directImportsFromMainSource, parser::Program *newProg) const; - bool CheckDupAndReplace(Program *&oldProg, Program *newProg); + bool CheckDupAndReplace(Program *&oldProg, Program *newProg) const; ArenaVector ParseDefaultSources(std::string_view srcFile, std::string_view importSrc); - lexer::LexerPosition HandleJsDocLikeComments(); public: //============================================================================================// @@ -153,7 +153,6 @@ private: ir::Identifier *ParseIdentifierFormatPlaceholder(std::optional nodeFormat) override; ir::TypeNode *ParseTypeFormatPlaceholder(std::optional nodeFormat = std::nullopt); ir::AstNode *ParseTypeParametersFormatPlaceholder() override; - void ApplyJsDocInfoToSpecificNodeType(ir::AstNode *node, ArenaVector &&jsDocInformation); void ApplyAnnotationsToArrayType(ir::AstNode *node, ArenaVector &&annotations, lexer::SourcePosition pos); void ApplyAnnotationsToSpecificNodeType(ir::AstNode *node, ArenaVector &&annotations, @@ -221,7 +220,6 @@ private: ir::AstNode *ParseImportDefaultSpecifier(ArenaVector *specifiers) override; void *ApplyAnnotationsToClassElement(ir::AstNode *property, ArenaVector &&annotations, lexer::SourcePosition pos); - void ApplyJsDocInfoToClassElement(ir::AstNode *property, ArenaVector &&jsDocInformation); ir::MethodDefinition *ParseClassGetterSetterMethod(const ArenaVector &properties, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags memberModifiers, bool isDefault); @@ -283,6 +281,8 @@ private: void ReportIfVarDeclaration(VariableParsingFlags flags) override; ir::TypeNode *ParsePotentialFunctionalType(TypeAnnotationParsingOptions *options, ir::TSTypeParameterDeclaration *typeParamDecl = nullptr); + std::pair ParseNonNullableType(TypeAnnotationParsingOptions *options); + void CheckForConditionalTypeError(TypeAnnotationParsingOptions options, lexer::TokenType tokenType); std::pair GetTypeAnnotationFromToken(TypeAnnotationParsingOptions *options); std::pair GetTypeAnnotationFromArrowFunction(TypeAnnotationParsingOptions *options); std::pair GetTypeAnnotationFromParentheses( @@ -302,6 +302,7 @@ private: ExpressionParseFlags flags = ExpressionParseFlags::NO_OPTS) override; ir::Statement *ParseTryStatement() override; ir::Statement *ParseDebuggerStatement() override; + ir::Statement *ParseDefaultIfSingleExport(ir::ModifierFlags modifiers); ir::Statement *ParseExport(lexer::SourcePosition startLoc, ir::ModifierFlags modifiers); ir::Statement *ParseImportDeclaration(StatementParsingFlags flags) override; ir::Statement *ParseExportDeclaration(StatementParsingFlags flags) override; @@ -314,7 +315,6 @@ private: const lexer::SourcePosition &startLoc) override; bool IsFieldStartToken(lexer::TokenType t); ir::AstNode *ParseTypeLiteralOrInterfaceMember() override; - ir::AstNode *ParseJsDocInfoInInterfaceBody(); ir::AstNode *ParseAnnotationsInInterfaceBody(); void ParseNameSpaceSpecifier(ArenaVector *specifiers, bool isReExport = false); void CheckModuleAsModifier(); @@ -334,6 +334,7 @@ private: ExpressionParseFlags flags = ExpressionParseFlags::NO_OPTS) override; // NOLINTNEXTLINE(google-default-arguments) ir::Expression *ParsePropertyDefinition(ExpressionParseFlags flags = ExpressionParseFlags::NO_OPTS) override; + ir::Expression *ParsePropertyKey(ExpressionParseFlags flags) override; // NOLINTNEXTLINE(google-default-arguments) ir::Expression *ParseDefaultPrimaryExpression(ExpressionParseFlags flags = ExpressionParseFlags::NO_OPTS); // NOLINTNEXTLINE(google-default-arguments) @@ -353,10 +354,6 @@ private: // NOLINTNEXTLINE(google-default-arguments) ir::Statement *ParseStructStatement(StatementParsingFlags flags, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags modFlags = ir::ModifierFlags::NONE) override; - ir::AstNode *ParseClassElementHelper( - const ArenaVector &properties, - std::tuple modifierInfo, - std::tuple elementFlag, std::tuple posInfo); ir::AstNode *ParseClassElement(const ArenaVector &properties, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags flags) override; std::tuple HandleClassElementModifiers(ir::ModifierFlags &memberModifiers); @@ -450,15 +447,8 @@ private: void ParseTrailingBlock([[maybe_unused]] ir::CallExpression *callExpr) override; void CheckDeclare(); - void ExcludeInvalidStart(); - std::tuple ParseJsDocInfoItemValue(); - std::string ParseJsDocInfoItemParam(); - ir::JsDocInfo ParseJsDocInfo(); - ArenaVector ParseJsDocInfos(); - friend class ExternalSourceParser; friend class InnerSourceParser; - friend ir::Expression *HandleLeftParanthesis(ETSParser *parser, ExpressionParseFlags flags); private: uint32_t namespaceNestedRank_; @@ -468,7 +458,6 @@ private: parser::Program *globalProgram_; std::vector insertingNodes_ {}; std::unique_ptr importPathManager_ {nullptr}; - RecursiveContext recursiveCtx_; }; class ExternalSourceParser { diff --git a/ets2panda/parser/ETSparserAnnotations.cpp b/ets2panda/parser/ETSparserAnnotations.cpp index 218b519d199fa6a4d8a9327246ff00aacc7cb6f8..e294a8573baf600112275eb0ac90ec63b0e3fa81 100644 --- a/ets2panda/parser/ETSparserAnnotations.cpp +++ b/ets2panda/parser/ETSparserAnnotations.cpp @@ -19,6 +19,7 @@ #include "ir/ets/etsTuple.h" #include "ir/ets/etsUnionType.h" #include "ir/statements/annotationDeclaration.h" +#include "ir/brokenTypeNode.h" namespace ark::es2panda::parser { @@ -56,26 +57,32 @@ ir::Expression *ETSParser::ParseAnnotationName() } }; auto save = Lexer()->Save(); + ir::Identifier *ident = nullptr; Lexer()->NextToken(); if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD_PERIOD_PERIOD) { Lexer()->Rewind(save); expr = ExpectIdentifier(); ES2PANDA_ASSERT(expr != nullptr); - setAnnotation(expr->AsIdentifier()); - return expr; - } - Lexer()->Rewind(save); - if (Lexer()->Lookahead() == '.') { - auto opt = TypeAnnotationParsingOptions::NO_OPTS; - expr = ParseTypeReference(&opt); - ES2PANDA_ASSERT(expr != nullptr); - setAnnotation(expr->AsETSTypeReference()->Part()->GetIdent()); + ident = expr->AsIdentifier(); } else { - expr = ExpectIdentifier(); - ES2PANDA_ASSERT(expr != nullptr); - setAnnotation(expr->AsIdentifier()); + Lexer()->Rewind(save); + if (Lexer()->Lookahead() == '.') { + auto opt = TypeAnnotationParsingOptions::NO_OPTS; + expr = ParseTypeReference(&opt); + ES2PANDA_ASSERT(expr != nullptr); + ident = expr->AsETSTypeReference()->Part()->GetIdent(); + } else { + expr = ExpectIdentifier(); + ES2PANDA_ASSERT(expr != nullptr); + ident = expr->AsIdentifier(); + } } + if (ident->IsBrokenExpression()) { + LogError(diagnostic::INVALID_ANNOTATION_NAME, {}, expr->Start()); + } + + setAnnotation(ident); return expr; } @@ -195,6 +202,8 @@ ir::AstNode *ETSParser::ParseAnnotationProperty(ir::Identifier *fieldName, ir::M if (typeAnnotation == nullptr && (memberModifiers & ir::ModifierFlags::ANNOTATION_DECLARATION) != 0 && !fieldName->IsErrorPlaceHolder()) { LogError(diagnostic::MISSING_TYPE_ANNOTATION, {fieldName->Name().Mutf8()}, Lexer()->GetToken().Start()); + typeAnnotation = AllocNode(Allocator()); + typeAnnotation->SetRange({endLoc, endLoc}); } if (typeAnnotation != nullptr) { @@ -217,6 +226,7 @@ ir::AstNode *ETSParser::ParseAnnotationProperty(ir::Identifier *fieldName, ir::M if (initializer != nullptr && !ValidAnnotationValue(initializer)) { LogError(diagnostic::INVALID_VAL_ANNOTATION_FIELD, {}, savePos); + initializer = AllocBrokenExpression(savePos); } memberModifiers |= ir::ModifierFlags::PUBLIC; @@ -366,14 +376,14 @@ void ETSParser::ApplyAnnotationsToSpecificNodeType(ir::AstNode *node, ArenaVecto } } -static lexer::SourcePosition GetExpressionEndLoc(ir::Expression *expr) +static lexer::SourcePosition GetAnnotationExpressionEndLoc(ir::Expression *expr) { ES2PANDA_ASSERT(expr != nullptr); if (expr->IsIdentifier()) { return expr->AsIdentifier()->End(); } - auto *part = expr->AsETSTypeReference()->Part(); - return part->Name()->AsTSQualifiedName()->Right()->End(); + + return expr->AsETSTypeReference()->Part()->GetIdent()->End(); } ir::AnnotationUsage *ETSParser::ParseAnnotationUsage() @@ -385,13 +395,14 @@ ir::AnnotationUsage *ETSParser::ParseAnnotationUsage() ArenaVector properties(Allocator()->Adapter()); if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && - !IsArrowFunctionExpressionStart() && IsAnnotationUsageStart(GetExpressionEndLoc(expr))) { + !IsArrowFunctionExpressionStart() && IsAnnotationUsageStart(GetAnnotationExpressionEndLoc(expr))) { Lexer()->NextToken(); // eat '(' if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { properties = ParseAnnotationProperties(flags); } else if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { // handle single field annotation auto *singleParamName = AllocNode(compiler::Signatures::ANNOTATION_KEY_VALUE, Allocator()); + ES2PANDA_ASSERT(singleParamName != nullptr); singleParamName->SetRange({Lexer()->GetToken().Start(), Lexer()->GetToken().End()}); const auto savePos = Lexer()->GetToken().Start(); @@ -420,7 +431,7 @@ ir::AnnotationUsage *ETSParser::ParseAnnotationUsage() auto *annotationUsage = AllocNode(expr, std::move(properties)); ES2PANDA_ASSERT(annotationUsage != nullptr); annotationUsage->AddModifier(flags); - annotationUsage->SetRange({startLoc, GetExpressionEndLoc(expr)}); + annotationUsage->SetRange({startLoc, GetAnnotationExpressionEndLoc(expr)}); return annotationUsage; } diff --git a/ets2panda/parser/ETSparserClasses.cpp b/ets2panda/parser/ETSparserClasses.cpp index fd98217de54e735976de68665cdf47d92f3f78b6..6341e82096dcc4f051cd8e729b45345b9088c7c8 100644 --- a/ets2panda/parser/ETSparserClasses.cpp +++ b/ets2panda/parser/ETSparserClasses.cpp @@ -223,6 +223,9 @@ std::tuple ETSParser::ParseClassMemberAccessModif accessFlag = ir::ModifierFlags::INTERNAL_PROTECTED; break; } + case lexer::TokenType::EOS: { // process invalid tokenType + return {ir::ModifierFlags::NONE, false, false}; + } default: { ES2PANDA_UNREACHABLE(); } @@ -421,6 +424,7 @@ ir::TypeNode *ETSParser::ConvertToOptionalUnionType(ir::TypeNode *typeAnno) types.push_back(AllocNode(Allocator())); types.back()->SetRange(typeAnno->Range()); auto *newTypeAnno = AllocNode(std::move(types), Allocator()); + ES2PANDA_ASSERT(newTypeAnno != nullptr); newTypeAnno->SetRange(typeAnno->Range()); return newTypeAnno; } @@ -541,8 +545,7 @@ ir::OverloadDeclaration *ETSParser::ParseClassOverloadDeclaration(ir::ModifierFl // To avoid duplicate names with anonymous constructors, overload constructor name is // "constructorOverloadDeclaration", instead of "constructor" if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_CONSTRUCTOR) { - overloadName = - AllocNode(compiler::Signatures::CONSTRUCTOR_OVERLOAD_DEFINITION_NAME, Allocator()); + overloadName = AllocNode(compiler::Signatures::CONSTRUCTOR_NAME, Allocator()); modifiers |= ir::ModifierFlags::CONSTRUCTOR; Lexer()->NextToken(); } else { @@ -596,6 +599,7 @@ ir::MethodDefinition *ETSParser::ParseClassMethodDefinition(ir::Identifier *meth funcExpr->SetRange(func->Range()); func->AddModifier(modifiers); + ES2PANDA_ASSERT(methodName->Clone(Allocator(), nullptr) != nullptr); auto *method = AllocNode(methodKind, methodName->Clone(Allocator(), nullptr)->AsExpression(), funcExpr, modifiers, Allocator(), false); ES2PANDA_ASSERT(method != nullptr); @@ -634,6 +638,7 @@ ir::MethodDefinition *ETSParser::ParseClassMethod(ClassElementDescriptor *desc, auto *method = AllocNode(desc->methodKind, propName->Clone(Allocator(), nullptr)->AsExpression(), funcExpr, desc->modifiers, Allocator(), desc->isComputed); + ES2PANDA_ASSERT(method != nullptr); method->SetRange(funcExpr->Range()); return method; @@ -674,16 +679,29 @@ std::tuple ETSParser::HandleClassElementModifiers(ir::Modifier return {seenStatic, isStepToken, isDefault}; } -ir::AstNode *ETSParser::ParseClassElementHelper( - const ArenaVector &properties, - std::tuple modifierInfo, - std::tuple elementFlag, std::tuple posInfo) +ir::AstNode *ETSParser::ParseClassElement(const ArenaVector &properties, + ir::ClassDefinitionModifiers modifiers, + [[maybe_unused]] ir::ModifierFlags flags) { - auto [seenStatic, isStepToken, isDefault] = elementFlag; - auto [startLoc, savedPos] = posInfo; - auto [modifiers, memberModifiers, flags] = modifierInfo; - auto delcStartLoc = Lexer()->GetToken().Start(); + auto startLoc = Lexer()->GetToken().Start(); + + ArenaVector annotations(Allocator()->Adapter()); + if (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_AT)) { + annotations = ParseAnnotations(false); + } + + ir::ModifierFlags memberModifiers = ir::ModifierFlags::NONE; + auto savedPos = Lexer()->Save(); // NOLINT(clang-analyzer-deadcode.DeadStores) + + if (Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_STATIC && + Lexer()->Lookahead() == lexer::LEX_CHAR_LEFT_BRACE) { + return ParseClassStaticBlock(); + } + + auto [seenStatic, isStepToken, isDefault] = HandleClassElementModifiers(memberModifiers); + ir::AstNode *result = nullptr; + auto delcStartLoc = Lexer()->GetToken().Start(); switch (Lexer()->GetToken().Type()) { case lexer::TokenType::KEYW_INTERFACE: case lexer::TokenType::KEYW_CLASS: @@ -712,45 +730,9 @@ ir::AstNode *ETSParser::ParseClassElementHelper( } default: { result = ParseInnerRest(properties, modifiers, memberModifiers, startLoc, isDefault); + break; } } - return result; -} - -ir::AstNode *ETSParser::ParseClassElement(const ArenaVector &properties, - ir::ClassDefinitionModifiers modifiers, - [[maybe_unused]] ir::ModifierFlags flags) -{ - ArenaVector jsDocInformation(Allocator()->Adapter()); - if (Lexer()->TryEatTokenType(lexer::TokenType::JS_DOC_START)) { - jsDocInformation = ParseJsDocInfos(); - if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE || - Lexer()->GetToken().Type() == lexer::TokenType::EOS) { - return nullptr; - } - } - - auto startLoc = Lexer()->GetToken().Start(); - - ArenaVector annotations(Allocator()->Adapter()); - if (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_AT)) { - annotations = ParseAnnotations(false); - } - - ir::ModifierFlags memberModifiers = ir::ModifierFlags::NONE; - auto savedPos = Lexer()->Save(); // NOLINT(clang-analyzer-deadcode.DeadStores) - - if (Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_STATIC && - Lexer()->Lookahead() == lexer::LEX_CHAR_LEFT_BRACE) { - return ParseClassStaticBlock(); - } - - auto [seenStatic, isStepToken, isDefault] = HandleClassElementModifiers(memberModifiers); - auto delcStartLoc = Lexer()->GetToken().Start(); - ir::AstNode *result = ParseClassElementHelper(properties, std::make_tuple(modifiers, memberModifiers, flags), - std::make_tuple(seenStatic, isStepToken, isDefault), - std::make_tuple(startLoc, savedPos)); - ApplyJsDocInfoToClassElement(result, std::move(jsDocInformation)); ApplyAnnotationsToClassElement(result, std::move(annotations), delcStartLoc); return result; } @@ -783,41 +765,6 @@ void *ETSParser::ApplyAnnotationsToClassElement(ir::AstNode *property, ArenaVect return property; } -static ir::JsDocInfo CloneJsDocInfo(ArenaAllocator *const allocator, const ir::JsDocInfo &src) -{ - ir::JsDocInfo res(allocator->Adapter()); - for (const auto &entry : src) { - const util::StringView &key = entry.first; - const ir::JsDocRecord &record = entry.second; - - util::UString copiedKey {key, allocator}; - util::UString copiedParam {record.param, allocator}; - util::UString copiedComment {record.comment, allocator}; - res.emplace(copiedKey.View(), ir::JsDocRecord(copiedKey.View(), copiedParam.View(), copiedComment.View())); - } - return res; -} - -void ETSParser::ApplyJsDocInfoToClassElement(ir::AstNode *property, ArenaVector &&jsDocInformation) -{ - if (property == nullptr || jsDocInformation.empty()) { - return; - } - - if (!property->IsTSInterfaceBody()) { - ApplyJsDocInfoToSpecificNodeType(property, std::move(jsDocInformation)); - return; - } - - for (auto *node : property->AsTSInterfaceBody()->Body()) { - ArenaVector clonedJsDocInformation(Allocator()->Adapter()); - for (auto const &jsdocInfo : jsDocInformation) { - clonedJsDocInformation.emplace_back(CloneJsDocInfo(Allocator(), jsdocInfo)); - } - ApplyJsDocInfoToSpecificNodeType(node, std::move(clonedJsDocInformation)); - } -} - ir::MethodDefinition *ETSParser::ParseClassGetterSetterMethod(const ArenaVector &properties, const ir::ClassDefinitionModifiers modifiers, const ir::ModifierFlags memberModifiers, bool isDefault) @@ -841,13 +788,16 @@ ir::MethodDefinition *ETSParser::ParseClassGetterSetterMethod(const ArenaVector< lexer::SourcePosition propEnd = methodName->End(); ir::MethodDefinition *method = ParseClassMethod(&desc, properties, methodName, &propEnd); + ES2PANDA_ASSERT(method != nullptr); method->SetDefaultAccessModifier(isDefault); - method->Function()->AddModifier(desc.modifiers); + auto *func = method->Function(); + ES2PANDA_ASSERT(func != nullptr); + func->AddModifier(desc.modifiers); method->SetRange({desc.propStart, propEnd}); if (desc.methodKind == ir::MethodDefinitionKind::GET) { - method->Function()->AddFlag(ir::ScriptFunctionFlags::GETTER); + func->AddFlag(ir::ScriptFunctionFlags::GETTER); } else { - method->Function()->AddFlag(ir::ScriptFunctionFlags::SETTER); + func->AddFlag(ir::ScriptFunctionFlags::SETTER); } return method; @@ -864,23 +814,25 @@ ir::MethodDefinition *ETSParser::ParseInterfaceGetterSetterMethod(const ir::Modi return nullptr; } method->AddModifier(ir::ModifierFlags::PUBLIC); - auto id = method->Id(); + auto *id = method->Id(); + auto *func = method->Function(); ES2PANDA_ASSERT(id != nullptr); + ES2PANDA_ASSERT(func != nullptr); if (methodKind == ir::MethodDefinitionKind::GET) { id->SetAccessor(); - method->Function()->AddFlag(ir::ScriptFunctionFlags::GETTER); + func->AddFlag(ir::ScriptFunctionFlags::GETTER); } else { id->SetMutator(); - method->Function()->AddFlag(ir::ScriptFunctionFlags::SETTER); + func->AddFlag(ir::ScriptFunctionFlags::SETTER); } method->AddModifier(ir::ModifierFlags::PUBLIC); - method->Function()->SetIdent(id->Clone(Allocator(), nullptr)); - method->Function()->AddModifier(method->Modifiers()); + func->SetIdent(id->Clone(Allocator(), nullptr)); + func->AddModifier(method->Modifiers()); - bool hasReturn = method->Function()->ReturnTypeAnnotation() != nullptr; + bool hasReturn = func->ReturnTypeAnnotation() != nullptr; if (hasReturn && methodKind == ir::MethodDefinitionKind::SET) { - LogError(diagnostic::SETTER_NO_RETURN_TYPE, {}, method->Function()->Range().start); + LogError(diagnostic::SETTER_NO_RETURN_TYPE, {}, func->Range().start); } return method; @@ -1008,14 +960,17 @@ ir::ModifierFlags ETSParser::ParseInterfaceMethodModifiers() LogError(diagnostic::LOCAL_CLASS_ACCESS_MOD, {}, Lexer()->GetToken().Start()); } } - const auto keywordType = Lexer()->GetToken().KeywordType(); const bool isPrivate = (keywordType == lexer::TokenType::KEYW_PRIVATE); const bool isDefaultInAmbient = (keywordType == lexer::TokenType::KEYW_DEFAULT) && InAmbientContext(); - if (!isPrivate && !isDefaultInAmbient) { - LogError(diagnostic::UNEXPECTED_TOKEN_PRIVATE_ID); + if (!isPrivate) { + if (!isDefaultInAmbient) { + LogError(diagnostic::UNEXPECTED_TOKEN_PRIVATE_ID); + } + if (keywordType == lexer::TokenType::KEYW_NEW) { + LogError(diagnostic::ERROR_ARKTS_NO_INTERFACE_CONSTRUCTOR_SIGNATURES); + } } - Lexer()->NextToken(); return isDefaultInAmbient ? ir::ModifierFlags::DEFAULT : ir::ModifierFlags::PRIVATE; } @@ -1110,6 +1065,7 @@ ir::AstNode *ETSParser::ParseInterfaceField() return AllocBrokenExpression(Lexer()->GetToken().Start()); } + ES2PANDA_ASSERT(name != nullptr); name->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); bool optionalField = false; @@ -1179,6 +1135,7 @@ ir::MethodDefinition *ETSParser::ParseInterfaceMethod(ir::ModifierFlags flags, i name = AllocBrokenExpression(Lexer()->GetToken().Loc()); } else { name = AllocNode(Lexer()->GetToken().Ident(), Allocator()); + ES2PANDA_ASSERT(name != nullptr); name->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); } @@ -1219,7 +1176,7 @@ ir::MethodDefinition *ETSParser::ParseInterfaceMethod(ir::ModifierFlags flags, i func->AddModifier(ir::ModifierFlags::ABSTRACT); } ValidateGetterSetter(methodKind, func->Params().size()); - func->SetRange({startLoc, GetEndLoc(body, func, Lexer())}); + func->SetRange({name->Start(), GetEndLoc(body, func, Lexer())}); auto *funcExpr = AllocNode(func); ES2PANDA_ASSERT(funcExpr != nullptr); @@ -1227,8 +1184,10 @@ ir::MethodDefinition *ETSParser::ParseInterfaceMethod(ir::ModifierFlags flags, i func->AddFlag(ir::ScriptFunctionFlags::METHOD); func->SetIdent(name); + ES2PANDA_ASSERT(name->Clone(Allocator(), nullptr) != nullptr); auto *method = AllocNode(methodKind, name->Clone(Allocator(), nullptr)->AsExpression(), funcExpr, flags, Allocator(), false); + ES2PANDA_ASSERT(method != nullptr); method->SetRange(funcExpr->Range()); ConsumeSemicolon(method); @@ -1236,23 +1195,6 @@ ir::MethodDefinition *ETSParser::ParseInterfaceMethod(ir::ModifierFlags flags, i return method; } -ir::AstNode *ETSParser::ParseJsDocInfoInInterfaceBody() -{ - Lexer()->NextToken(); // eat '/**' - - auto jsDocInformation = ParseJsDocInfos(); - if (Lexer()->GetToken().Type() == lexer::TokenType::EOS || - Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { - return nullptr; - } - - ir::AstNode *result = ParseTypeLiteralOrInterfaceMember(); - if (result != nullptr) { - ApplyJsDocInfoToSpecificNodeType(result, std::move(jsDocInformation)); - } - return result; -} - ir::AstNode *ETSParser::ParseAnnotationsInInterfaceBody() { Lexer()->NextToken(); // eat '@' @@ -1275,10 +1217,6 @@ bool ETSParser::IsFieldStartToken(lexer::TokenType tokenType) ir::AstNode *ETSParser::ParseTypeLiteralOrInterfaceMember() { - if (Lexer()->GetToken().Type() == lexer::TokenType::JS_DOC_START) { - return ParseJsDocInfoInInterfaceBody(); - } - if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT) { return ParseAnnotationsInInterfaceBody(); } @@ -1432,6 +1370,45 @@ void ETSParser::CreateImplicitConstructor([[maybe_unused]] ir::MethodDefinition properties.push_back(methodDef); } +static bool DeclareIsModifier(lexer::Lexer *lexer) +{ + bool result = false; + auto currentPos = lexer->Save(); + if (lexer->GetToken().KeywordType() == lexer::TokenType::KEYW_DECLARE) { + lexer->NextToken(); // eat 'declare' + switch (lexer->GetToken().KeywordType()) { + case lexer::TokenType::KEYW_LET: + case lexer::TokenType::KEYW_CONST: + case lexer::TokenType::KEYW_FUNCTION: + case lexer::TokenType::KEYW_CLASS: + case lexer::TokenType::KEYW_NAMESPACE: + case lexer::TokenType::KEYW_ENUM: + case lexer::TokenType::KEYW_ABSTRACT: + case lexer::TokenType::KEYW_FINAL: + case lexer::TokenType::KEYW_INTERFACE: + case lexer::TokenType::KEYW_TYPE: + case lexer::TokenType::KEYW_ASYNC: + case lexer::TokenType::KEYW_STRUCT: { + result = true; + break; + } + default: { + if (lexer->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT) { + result = true; + break; + } + if (lexer->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && + lexer->GetToken().Ident().Is("module")) { + result = true; + break; + } + } + } + } + lexer->Rewind(currentPos); + return result; +} + std::pair ETSParser::ParseMemberModifiers() { auto memberModifiers = ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC; @@ -1455,7 +1432,7 @@ std::pair ETSParser::ParseMemberModifi lexer::SourcePosition startLoc = Lexer()->GetToken().Start(); - if (Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_DECLARE) { + if (DeclareIsModifier(Lexer())) { CheckDeclare(); memberModifiers |= ir::ModifierFlags::DECLARE; } diff --git a/ets2panda/parser/ETSparserEnums.cpp b/ets2panda/parser/ETSparserEnums.cpp index 56be9b274962e1bc0db3005bb4c9760c582e9403..44434862cb24624894067944521b420157710561 100644 --- a/ets2panda/parser/ETSparserEnums.cpp +++ b/ets2panda/parser/ETSparserEnums.cpp @@ -148,9 +148,6 @@ ir::Statement *ETSParser::ParsePotentialConstEnum(VariableParsingFlags flags) return ParseEnumDeclaration(false); } -// NOLINTBEGIN(cert-err58-cpp) -// NOLINTEND(cert-err58-cpp) - ir::TSEnumDeclaration *ETSParser::ParseEnumMembers(ir::Identifier *const key, const lexer::SourcePosition &enumStart, const bool isConst, const bool isStatic) { @@ -250,7 +247,6 @@ lexer::SourcePosition ETSParser::ParseEnumMember(ArenaVector &mem // Lambda to parse enum member (maybe with initializer) auto const parseMember = [this, &members, ¤tNumberExpr]() { - HandleJsDocLikeComments(); auto *const ident = ExpectIdentifier(false, true); ir::Expression *ordinal; diff --git a/ets2panda/parser/ETSparserExpressions.cpp b/ets2panda/parser/ETSparserExpressions.cpp index d07eb0720854ac4c231c499b1cf588e204658bdc..67e3c40be1fdd9f28ef505cd496bc5babdfaeb11 100644 --- a/ets2panda/parser/ETSparserExpressions.cpp +++ b/ets2panda/parser/ETSparserExpressions.cpp @@ -41,11 +41,11 @@ static std::string GetArgumentsSourceView(lexer::Lexer *lexer, const util::Strin ir::Expression *ETSParser::ParseFunctionParameterExpression(ir::AnnotatedExpression *const paramIdent, bool isOptional) { ir::ETSParameterExpression *paramExpression; + ES2PANDA_ASSERT(paramIdent != nullptr); if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { auto const lexerPos = Lexer()->Save().Iterator(); Lexer()->NextToken(); // eat '=' - ES2PANDA_ASSERT(paramIdent != nullptr); if (paramIdent->IsRestElement()) { LogError(diagnostic::NO_DEFAULT_FOR_REST); } @@ -76,9 +76,11 @@ ir::Expression *ETSParser::ParseFunctionParameterExpression(ir::AnnotatedExpress paramExpression->SetRange({paramIdent->Start(), paramExpression->Initializer()->End()}); } else if (paramIdent->IsIdentifier()) { paramExpression = AllocNode(paramIdent->AsIdentifier(), isOptional, Allocator()); + ES2PANDA_ASSERT(paramExpression != nullptr); paramExpression->SetRange({paramIdent->Start(), paramIdent->End()}); } else { paramExpression = AllocNode(paramIdent->AsRestElement(), false, Allocator()); + ES2PANDA_ASSERT(paramExpression != nullptr); paramExpression->SetRange({paramIdent->Start(), paramIdent->End()}); } return paramExpression; @@ -130,13 +132,10 @@ ir::Expression *ETSParser::CreateUnaryExpressionFromArgument(ir::Expression *arg return returnExpr; } -// NOLINTNEXTLINE(google-default-arguments) -ir::Expression *ETSParser::ParseUnaryOrPrefixUpdateExpression(ExpressionParseFlags flags) +static bool IsLeftHandSideExpression(lexer::TokenType &operatorType, lexer::NextTokenFlags &tokenFlags, + lexer::TokenType keywordType) { - auto tokenFlags = lexer::NextTokenFlags::NONE; - lexer::TokenType operatorType = Lexer()->GetToken().Type(); - if (operatorType == lexer::TokenType::LITERAL_IDENT && - Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_TYPEOF) { + if (operatorType == lexer::TokenType::LITERAL_IDENT && keywordType == lexer::TokenType::KEYW_TYPEOF) { operatorType = lexer::TokenType::KEYW_TYPEOF; } @@ -150,12 +149,20 @@ ir::Expression *ETSParser::ParseUnaryOrPrefixUpdateExpression(ExpressionParseFla case lexer::TokenType::PUNCTUATOR_TILDE: case lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK: case lexer::TokenType::KEYW_TYPEOF: - case lexer::TokenType::KEYW_AWAIT: { - break; - } - default: { - return ParseLeftHandSideExpression(flags); - } + case lexer::TokenType::KEYW_AWAIT: + return false; + default: + return true; + } +} + +// NOLINTNEXTLINE(google-default-arguments) +ir::Expression *ETSParser::ParseUnaryOrPrefixUpdateExpression(ExpressionParseFlags flags) +{ + auto tokenFlags = lexer::NextTokenFlags::NONE; + lexer::TokenType operatorType = Lexer()->GetToken().Type(); + if (IsLeftHandSideExpression(operatorType, tokenFlags, Lexer()->GetToken().KeywordType())) { + return ParseLeftHandSideExpression(flags); } char32_t beginningChar = Lexer()->Lookahead(); @@ -181,6 +188,7 @@ ir::Expression *ETSParser::ParseUnaryOrPrefixUpdateExpression(ExpressionParseFla } ir::Expression *returnExpr = CreateUnaryExpressionFromArgument(argument, operatorType, beginningChar); + ES2PANDA_ASSERT(returnExpr != nullptr); returnExpr->SetRange({start, argument->End()}); return returnExpr; } @@ -218,6 +226,7 @@ ir::Expression *ETSParser::ParsePropertyDefinition(ExpressionParseFlags flags) if (propertyKind == ir::PropertyKind::INIT) { returnProperty = AllocNode(propertyKind, key, value, methodStatus != ParserStatus::NO_OPTS, isComputed); + ES2PANDA_ASSERT(returnProperty != nullptr); returnProperty->SetRange({start, end}); } else { returnProperty = AllocBrokenExpression(key->Start()); @@ -237,6 +246,47 @@ bool CheckNextTokenOfTypeof(const lexer::Token &token) return (pretendTypeof || pretendIdent || pretendOperator || pretendUnary || pretendPuctuator); } +ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlags flags) +{ + ir::Expression *key = nullptr; + + switch (Lexer()->GetToken().Type()) { + case lexer::TokenType::LITERAL_IDENT: { + const util::StringView &ident = Lexer()->GetToken().Ident(); + key = AllocNode(ident, Allocator()); + ES2PANDA_ASSERT(key != nullptr); + key->SetRange(Lexer()->GetToken().Loc()); + Lexer()->NextToken(); + return key; + } + case lexer::TokenType::LITERAL_STRING: { + const util::StringView &string = Lexer()->GetToken().String(); + key = AllocNode(string); + ES2PANDA_ASSERT(key != nullptr); + key->SetRange(Lexer()->GetToken().Loc()); + Lexer()->NextToken(); + return key; + } + case lexer::TokenType::LITERAL_NUMBER: { + if ((Lexer()->GetToken().Flags() & lexer::TokenFlags::NUMBER_BIGINT) != 0) { + key = AllocNode(Lexer()->GetToken().BigInt()); + } else { + key = AllocNode(Lexer()->GetToken().GetNumber()); + } + ES2PANDA_ASSERT(key != nullptr); + key->SetRange(Lexer()->GetToken().Loc()); + Lexer()->NextToken(); + return key; + } + default: { + const auto &rangeToken = Lexer()->GetToken().Loc(); + LogError(diagnostic::UNEXPECTED_TOKEN); + Lexer()->NextToken(); + return AllocBrokenExpression(rangeToken); + } + } +} + // NOLINTNEXTLINE(google-default-arguments) ir::Expression *ETSParser::ParseDefaultPrimaryExpression(ExpressionParseFlags flags) { @@ -317,26 +367,12 @@ ir::Expression *ETSParser::ParsePrimaryExpressionWithLiterals(ExpressionParseFla } } -// This function is used to handle the left parenthesis in the expression parsing. -ir::Expression *HandleLeftParanthesis(ETSParser *parser, ExpressionParseFlags flags) -{ - TrackRecursive trackRecursive(parser->recursiveCtx_); - if (!trackRecursive) { - parser->LogError(diagnostic::DEEP_NESTING); - while (parser->Lexer()->GetToken().Type() != lexer::TokenType::EOS) { - parser->Lexer()->NextToken(); - } - return parser->AllocBrokenExpression(parser->Lexer()->GetToken().Loc()); - } - return parser->ParseCoverParenthesizedExpressionAndArrowParameterList(flags); -} - // NOLINTNEXTLINE(google-default-arguments) ir::Expression *ETSParser::ParsePrimaryExpression(ExpressionParseFlags flags) { switch (Lexer()->GetToken().Type()) { case lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS: { - return HandleLeftParanthesis(this, flags); + return ParseCoverParenthesizedExpressionAndArrowParameterList(flags); } case lexer::TokenType::KEYW_THIS: { return ParseThisExpression(); @@ -505,6 +541,12 @@ ir::Expression *ETSParser::ParseCoverParenthesizedExpressionAndArrowParameterLis ir::Expression *expr = ParseExpression(newFlags); + if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { + LogError(diagnostic::ERROR_ARKTS_NO_COMMA_OUTSIDE_LOOPS); + auto sequenceExpression = ParseSequenceExpression(expr); + Lexer()->NextToken(); + return AllocBrokenExpression(sequenceExpression->Range()); + } if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { LogExpectedToken(lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS); } @@ -782,6 +824,14 @@ void ETSParser::ValidateInstanceOfExpression(ir::Expression *expr) // NOLINTNEXTLINE(google-default-arguments) ir::Expression *ETSParser::ParseExpression(ExpressionParseFlags flags) { + TrackRecursive trackRecursive(RecursiveCtx()); + if (!trackRecursive) { + LogError(diagnostic::DEEP_NESTING); + while (Lexer()->GetToken().Type() != lexer::TokenType::EOS) { + Lexer()->NextToken(); + } + return AllocBrokenExpression(Lexer()->GetToken().Loc()); + } ArenaVector annotations {Allocator()->Adapter()}; if (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_AT)) { annotations = ParseAnnotations(false); diff --git a/ets2panda/parser/ETSparserJsDocInfo.cpp b/ets2panda/parser/ETSparserJsDocInfo.cpp deleted file mode 100644 index e0dbcb23445d04809faadded9ac93f824977daab..0000000000000000000000000000000000000000 --- a/ets2panda/parser/ETSparserJsDocInfo.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/** - * Copyright (c) 2021-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. - */ - -#include "ETSparser.h" -#include "lexer/lexer.h" -#include "lexer/keywordsUtil.h" -#include "ir/astNode.h" -#include "ir/base/methodDefinition.h" -#include "ir/ets/etsStructDeclaration.h" -#include "ir/statements/classDeclaration.h" -#include -#include -#include -#include -#include -#include -#include - -namespace ark::es2panda::parser { -void ETSParser::ExcludeInvalidStart() -{ - auto cp = Lexer()->Lookahead(); - while (!lexer::KeywordsUtil::IsIdentifierStart(cp) && cp != util::StringView::Iterator::INVALID_CP && - cp != lexer::LEX_CHAR_LEFT_BRACE && cp != lexer::LEX_CHAR_ASTERISK) { - Lexer()->ForwardToken(Lexer()->GetToken().Type()); - cp = Lexer()->Lookahead(); - } -} - -std::string ETSParser::ParseJsDocInfoItemParam() -{ - ExcludeInvalidStart(); - Lexer()->NextToken(); - auto token = Lexer()->GetToken(); - std::string jsDocInfoParamStr {}; - bool needAppendToken = token.Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE; - bool needBackwardBlank = lexer::KeywordsUtil::IsIdentifierStart(Lexer()->Lookahead()); - size_t leftBraceCount = 1; - while (token.Type() != lexer::TokenType::EOS && token.Type() != lexer::TokenType::JS_DOC_END) { - if (needAppendToken) { - jsDocInfoParamStr += token.ToString(); - } - - if (needBackwardBlank) { - jsDocInfoParamStr += " "; - } - - auto cp = Lexer()->Lookahead(); - if (lexer::KeywordsUtil::IsIdentifierStart(cp) || cp == lexer::LEX_CHAR_ASTERISK) { - Lexer()->NextToken(); - token = Lexer()->GetToken(); - needAppendToken = lexer::KeywordsUtil::IsIdentifierStart(cp); - needBackwardBlank = lexer::KeywordsUtil::IsIdentifierStart(Lexer()->Lookahead()); - continue; - } - - if (cp == lexer::LEX_CHAR_RIGHT_BRACE) { - --leftBraceCount; - if (leftBraceCount == 0) { - Lexer()->NextToken(); - break; - } - } - - if (cp == lexer::LEX_CHAR_LEFT_BRACE) { - ++leftBraceCount; - } - - if (cp == util::StringView::Iterator::INVALID_CP) { - break; - } - - jsDocInfoParamStr += std::string(1, cp); - needAppendToken = false; - needBackwardBlank = false; - Lexer()->ForwardToken(token.Type()); - } - - return jsDocInfoParamStr; -} - -static void RegularCommentStr(std::string &str) -{ - if (str.empty()) { - return; - } - - auto backChar = static_cast(static_cast(str.back())); - while (backChar == lexer::LEX_CHAR_CR || backChar == lexer::LEX_CHAR_LF || backChar == lexer::LEX_CHAR_ASTERISK || - backChar == lexer::LEX_CHAR_NBSP || backChar == lexer::LEX_CHAR_SP) { - str.pop_back(); - if (str.empty()) { - return; - } - backChar = static_cast(static_cast(str.back())); - } -} - -std::tuple ETSParser::ParseJsDocInfoItemValue() -{ - ExcludeInvalidStart(); - util::UString jsDocInfoItemCommentStr(Allocator()); - std::string jsDocInfoParamStr {}; - if (Lexer()->GetToken().Type() == lexer::TokenType::JS_DOC_END) { - util::UString jsDocInfoItemParam {jsDocInfoParamStr, Allocator()}; - return std::make_tuple(jsDocInfoItemParam.View(), jsDocInfoItemCommentStr.View()); - } - - const auto startIdx = Lexer()->GetIndex(); - auto escapeEnd = startIdx; - do { - const char32_t cp = Lexer()->Lookahead(); - switch (cp) { - case lexer::LEX_CHAR_LEFT_BRACE: { - jsDocInfoParamStr = ParseJsDocInfoItemParam(); - continue; - } - case util::StringView::Iterator::INVALID_CP: { - break; - } - case lexer::LEX_CHAR_CR: - case lexer::LEX_CHAR_LF: { - Lexer()->HandleNewlineHelper(&jsDocInfoItemCommentStr, &escapeEnd); - continue; - } - case lexer::LEX_CHAR_AT: - case lexer::LEX_CHAR_ASTERISK: { - auto saved = Lexer()->Save(); - Lexer()->NextToken(); - auto nextType = Lexer()->GetToken().Type(); - Lexer()->Rewind(saved); - if (nextType == lexer::TokenType::JS_DOC_END || nextType == lexer::TokenType::PUNCTUATOR_AT) { - break; - } - [[fallthrough]]; - } - default: { - Lexer()->SkipCp(); - continue; - } - } - Lexer()->FinalizeJsDocInfoHelper(&jsDocInfoItemCommentStr, startIdx, escapeEnd); - break; - } while (true); - - std::string commentStr = std::string(jsDocInfoItemCommentStr.View()); - RegularCommentStr(commentStr); - util::UString jsDocInfoItemParam {jsDocInfoParamStr, Allocator()}; - util::UString jsDocInfoCommentStr {commentStr, Allocator()}; - return std::make_tuple(jsDocInfoItemParam.View(), jsDocInfoCommentStr.View()); -} - -ir::JsDocInfo ETSParser::ParseJsDocInfo() -{ - ir::JsDocInfo jsDocInfo(Allocator()->Adapter()); - auto tokenType = Lexer()->GetToken().Type(); - while (tokenType != lexer::TokenType::EOS && tokenType != lexer::TokenType::JS_DOC_END) { - if (tokenType != lexer::TokenType::PUNCTUATOR_AT) { - auto cp = Lexer()->Lookahead(); - if (cp == lexer::LEX_CHAR_ASTERISK || cp == lexer::LEX_CHAR_AT) { - Lexer()->NextToken(); - tokenType = Lexer()->GetToken().Type(); - continue; - } - - if (Lexer()->Lookahead() == util::StringView::Iterator::INVALID_CP) { - break; - } - - Lexer()->ForwardToken(tokenType, 1); - continue; - } - Lexer()->NextToken(); - auto const &token = Lexer()->GetToken(); - util::UString jsDocInfoItemKey {token.Ident(), Allocator()}; - auto [jsDocInfoItemParam, jsDocInfoItemComment] = ParseJsDocInfoItemValue(); - jsDocInfo.emplace(jsDocInfoItemKey.View(), - ir::JsDocRecord(jsDocInfoItemKey.View(), jsDocInfoItemParam, jsDocInfoItemComment)); - tokenType = Lexer()->GetToken().Type(); - } - - Lexer()->NextToken(); - return jsDocInfo; -} - -ArenaVector ETSParser::ParseJsDocInfos() -{ - ArenaVector result(Allocator()->Adapter()); - bool hasMoreJsDocInfos = true; - while (hasMoreJsDocInfos) { - auto jsDocInfo = ParseJsDocInfo(); - if (!jsDocInfo.empty()) { - result.emplace_back(jsDocInfo); - } - - if (Lexer()->GetToken().Type() != lexer::TokenType::JS_DOC_START) { - hasMoreJsDocInfos = false; - } - } - return result; -} - -static bool ApplyJsDocInfoToNamespace(ir::ETSModule *ns, ArenaVector &jsDocInformation) -{ - if (ns->IsNamespaceChainLastNode()) { - ns->SetJsDocInformation(std::move(jsDocInformation)); - return true; - } - - for (auto *node : ns->Statements()) { - if (node->IsETSModule()) { - if (ApplyJsDocInfoToNamespace(node->AsETSModule(), jsDocInformation)) { - return true; - } - } - } - return false; -} - -// CC-OFFNXT(huge_method,huge_cyclomatic_complexity,G.FUN.01-CPP) big switch-case, solid logic -void ETSParser::ApplyJsDocInfoToSpecificNodeType(ir::AstNode *node, ArenaVector &&jsDocInformation) -{ - if (jsDocInformation.empty()) { - return; - } - - switch (node->Type()) { - case ir::AstNodeType::METHOD_DEFINITION: { - auto *func = node->AsMethodDefinition()->Function(); - ES2PANDA_ASSERT(func != nullptr); - func->SetJsDocInformation(std::move(jsDocInformation)); - break; - } - case ir::AstNodeType::CLASS_DECLARATION: - node->AsClassDeclaration()->Definition()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::STRUCT_DECLARATION: - node->AsETSStructDeclaration()->Definition()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::FUNCTION_DECLARATION: - node->AsFunctionDeclaration()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::TS_INTERFACE_DECLARATION: - node->AsTSInterfaceDeclaration()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::CLASS_PROPERTY: - node->AsClassProperty()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::VARIABLE_DECLARATION: - node->AsVariableDeclaration()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION: - node->AsTSTypeAliasDeclaration()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::ARROW_FUNCTION_EXPRESSION: - node->AsArrowFunctionExpression()->SetJsDocInformation(std::move(jsDocInformation)); - break; - case ir::AstNodeType::ETS_MODULE: - ApplyJsDocInfoToNamespace(node->AsETSModule(), jsDocInformation); - break; - default: { - } - } -} -} // namespace ark::es2panda::parser diff --git a/ets2panda/parser/ETSparserNamespaces.cpp b/ets2panda/parser/ETSparserNamespaces.cpp index d60297de79692aaacc29201b9351696b2f691a3a..0bb77dc0c3acf9996d181b829af0ba306139d0b4 100644 --- a/ets2panda/parser/ETSparserNamespaces.cpp +++ b/ets2panda/parser/ETSparserNamespaces.cpp @@ -71,6 +71,7 @@ ir::ETSModule *ETSParser::ParseNamespaceImp(ir::ModifierFlags flags) auto *result = AllocNode(Allocator(), ArenaVector(Allocator()->Adapter()), ExpectIdentifier(), ir::ModuleFlag::NAMESPACE, GetContext().GetLanguage(), globalProgram_); + ES2PANDA_ASSERT(result != nullptr); ir::ETSModule *parent = result; ir::ETSModule *child = nullptr; while (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD) { @@ -101,9 +102,7 @@ ir::ETSModule *ETSParser::ParseNamespaceImp(ir::ModifierFlags flags) continue; } auto st = ParseTopLevelStatement(); - if (st != nullptr) { - statements.emplace_back(st); - } + statements.emplace_back(st); } Lexer()->NextToken(); if (child != nullptr) { diff --git a/ets2panda/parser/ETSparserStatements.cpp b/ets2panda/parser/ETSparserStatements.cpp index 68ffc5fa04d8627209a21b3bf27c8725f0ced526..dd62b35aeccc920e2927f6c8e6141c186e7491fb 100644 --- a/ets2panda/parser/ETSparserStatements.cpp +++ b/ets2panda/parser/ETSparserStatements.cpp @@ -241,23 +241,8 @@ ir::Statement *ETSParser::ParseTopLevelDeclStatement(StatementParsingFlags flags ir::Statement *ETSParser::ParseTopLevelStatement() { const auto flags = StatementParsingFlags::ALLOW_LEXICAL; - ArenaVector jsDocInformation(Allocator()->Adapter()); - if (Lexer()->TryEatTokenType(lexer::TokenType::JS_DOC_START)) { - jsDocInformation = ParseJsDocInfos(); - } - if (Lexer()->GetToken().Type() == lexer::TokenType::EOS || - ((GetContext().Status() & ParserStatus::IN_NAMESPACE) != 0 && - Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE)) { - return nullptr; - } - GetContext().Status() |= ParserStatus::ALLOW_JS_DOC_START; auto result = ParseTopLevelDeclStatement(flags); - GetContext().Status() ^= ParserStatus::ALLOW_JS_DOC_START; - if (result != nullptr) { - ApplyJsDocInfoToSpecificNodeType(result, std::move(jsDocInformation)); - } - if (result == nullptr) { result = ParseStatement(flags); } @@ -287,7 +272,9 @@ ir::Statement *ETSParser::ParseInitModuleStatement(StatementParsingFlags flags) // In order to build relationship between the current program and initModule program. importPathManager_->GatherImportMetadata(const_cast(GetContext().GetProgram()), util::ImportFlags::NONE, expr->Arguments().front()->AsStringLiteral()); - return AllocNode(expr); + auto initModuleStatement = AllocNode(expr); + ConsumeSemicolon(initModuleStatement); + return initModuleStatement; } ir::Statement *ETSParser::ParseAnnotationsInStatement(StatementParsingFlags flags) @@ -323,7 +310,7 @@ bool ETSParser::ValidateLabeledStatement(lexer::TokenType type) bool ETSParser::ValidateForInStatement() { - LogUnexpectedToken(lexer::TokenType::KEYW_IN); + LogError(diagnostic::ERROR_ARKTS_NO_FOR_IN_LOOP); return false; } diff --git a/ets2panda/parser/ETSparserTypes.cpp b/ets2panda/parser/ETSparserTypes.cpp index c27206d4813f0677d0009c6b8c18d75a178e1f32..209397b1dfd8a24599c3ead32b37462f3269c994 100644 --- a/ets2panda/parser/ETSparserTypes.cpp +++ b/ets2panda/parser/ETSparserTypes.cpp @@ -178,6 +178,7 @@ ir::TypeNode *ETSParser::ParseWildcardType(TypeAnnotationParsingOptions *options ir::ETSTypeReference *typeReference = nullptr; if (!isUnboundOut) { auto reference = ParseTypeReference(options); + ES2PANDA_ASSERT(reference != nullptr); typeReference = reference->AsETSTypeReference(); } @@ -312,13 +313,38 @@ ir::TypeNode *ETSParser::ParsePotentialFunctionalType(TypeAnnotationParsingOptio return nullptr; } +std::pair ETSParser::ParseNonNullableType(TypeAnnotationParsingOptions *options) +{ + ES2PANDA_ASSERT(Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_NON_NULLABLE); + Lexer()->NextToken(); // eat NonNullable + + ExpectToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, true); + auto *const typeAnnotation = ParseTypeAnnotationNoPreferParam(options); + ParsePunctuatorGreaterThan(); + return std::make_pair(AllocNode(typeAnnotation, Allocator()), true); +} + +// Helper function to reduce line count of GetTypeAnnotationFromToken(...) +void ETSParser::CheckForConditionalTypeError(TypeAnnotationParsingOptions options, lexer::TokenType tokenType) +{ + if ((options & TypeAnnotationParsingOptions::TYPE_ALIAS_CONTEXT) != 0 && + (tokenType == lexer::TokenType::KEYW_EXTENDS || tokenType == lexer::TokenType::PUNCTUATOR_QUESTION_MARK)) { + LogError(diagnostic::ERROR_ARKTS_NO_CONDITIONAL_TYPES); + } +} + // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic // Just to reduce the size of ParseTypeAnnotation(...) method std::pair ETSParser::GetTypeAnnotationFromToken(TypeAnnotationParsingOptions *options) { - auto tokenType = Lexer()->GetToken().Type(); - if (IsPrimitiveType(Lexer()->GetToken().KeywordType()) || tokenType == lexer::TokenType::LITERAL_IDENT) { + if (Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_NON_NULLABLE) { + return ParseNonNullableType(options); + } + + if (IsPrimitiveType(Lexer()->GetToken().KeywordType()) || + Lexer()->GetToken().Type() == lexer::TokenType::LITERAL_IDENT) { auto typeAnnotation = ParseLiteralIdent(options); + CheckForConditionalTypeError(*options, Lexer()->GetToken().Type()); if (((*options) & TypeAnnotationParsingOptions::POTENTIAL_CLASS_LITERAL) != 0 && (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_CLASS || IsStructKeyword())) { return std::make_pair(typeAnnotation, false); @@ -326,27 +352,19 @@ std::pair ETSParser::GetTypeAnnotationFromToken(TypeAnnota return std::make_pair(typeAnnotation, true); } - switch (tokenType) { + ir::TypeNode *typeAnnotation; + switch (Lexer()->GetToken().Type()) { case lexer::TokenType::LITERAL_NULL: { - auto typeAnnotation = AllocNode(Allocator()); - ES2PANDA_ASSERT(typeAnnotation != nullptr); - typeAnnotation->SetRange(Lexer()->GetToken().Loc()); - Lexer()->NextToken(); - return std::make_pair(typeAnnotation, true); + typeAnnotation = AllocNode(Allocator()); + break; } case lexer::TokenType::KEYW_UNDEFINED: { - auto typeAnnotation = AllocNode(Allocator()); - ES2PANDA_ASSERT(typeAnnotation != nullptr); - typeAnnotation->SetRange(Lexer()->GetToken().Loc()); - Lexer()->NextToken(); - return std::make_pair(typeAnnotation, true); + typeAnnotation = AllocNode(Allocator()); + break; } case lexer::TokenType::LITERAL_STRING: { - auto typeAnnotation = AllocNode(Lexer()->GetToken().String(), Allocator()); - ES2PANDA_ASSERT(typeAnnotation != nullptr); - typeAnnotation->SetRange(Lexer()->GetToken().Loc()); - Lexer()->NextToken(); - return std::make_pair(typeAnnotation, true); + typeAnnotation = AllocNode(Lexer()->GetToken().String(), Allocator()); + break; } case lexer::TokenType::PUNCTUATOR_BACK_TICK: { return std::make_pair(ParseMultilineString(), true); @@ -363,10 +381,25 @@ std::pair ETSParser::GetTypeAnnotationFromToken(TypeAnnota return std::make_pair(ParseETSTupleType(options), true); case lexer::TokenType::KEYW_THIS: return std::make_pair(ParseThisType(options), true); + case lexer::TokenType::PUNCTUATOR_LEFT_BRACE: + if (((*options) & TypeAnnotationParsingOptions::REPORT_ERROR) != 0) { + auto startPos = Lexer()->GetToken().Start(); + auto modifiers = ir::ClassDefinitionModifiers::ID_REQUIRED | ir::ClassDefinitionModifiers::CLASS_DECL | + ir::ClassDefinitionModifiers::DECLARATION; + auto flags = ir::ModifierFlags::NONE; + ParseClassBody(modifiers, flags); + LogError(diagnostic::ERROR_ARKTS_NO_OBJ_LITERAL_TO_DECL_TYPE, {}, startPos); + return {AllocBrokenType({startPos, Lexer()->GetToken().End()}), false}; + } + [[fallthrough]]; default: { return {nullptr, true}; } } + ES2PANDA_ASSERT(typeAnnotation != nullptr); + typeAnnotation->SetRange(Lexer()->GetToken().Loc()); + Lexer()->NextToken(); + return std::make_pair(typeAnnotation, true); } std::pair ETSParser::GetTypeAnnotationFromArrowFunction(TypeAnnotationParsingOptions *options) @@ -503,6 +536,7 @@ ir::TypeNode *ETSParser::ParseTypeAnnotationNoPreferParam(TypeAnnotationParsingO if (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_AT)) { annotations = ParseAnnotations(false); } + auto startPos = Lexer()->GetToken().Start(); auto [typeAnnotation, needFurtherProcessing] = GetTypeAnnotationFromToken(options); @@ -514,11 +548,6 @@ ir::TypeNode *ETSParser::ParseTypeAnnotationNoPreferParam(TypeAnnotationParsingO return nullptr; } - if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK) { - typeAnnotation = AllocNode(typeAnnotation, Allocator()); - Lexer()->NextToken(); - } - if (!needFurtherProcessing) { return typeAnnotation; } diff --git a/ets2panda/parser/JsdocHelper.cpp b/ets2panda/parser/JsdocHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e825a0d536cf8dd62d845334c7a869d983c3ed26 --- /dev/null +++ b/ets2panda/parser/JsdocHelper.cpp @@ -0,0 +1,202 @@ +/** + * Copyright (c) 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. + */ + +#include "JsdocHelper.h" +#include +#include "lexer/lexer.h" +#include "ir/ets/etsTuple.h" +#include "ir/statements/annotationDeclaration.h" + +namespace ark::es2panda::parser { +static constexpr std::string_view JSDOC_END = "*/"; +static constexpr std::string_view JSDOC_START = "/**"; +static constexpr std::string_view LICENSES_START = "/*"; +static constexpr std::string_view EMPTY_JSDOC = "Empty Jsdoc"; +static constexpr std::string_view EMPTY_LICENSE = "Empty License"; + +static constexpr size_t START_POS = 0; +static constexpr size_t COLLECT_CURRENT_POS = 1; + +// NOLINTBEGIN(modernize-avoid-c-arrays) +static constexpr std::string_view POTENTIAL_PREFIX[] = {"@", "get", "set", "let", "const", + "async", "readonly", "abstract", "native", "static", + "public", "private", "declare", "default", "export"}; +// NOLINTEND(modernize-avoid-c-arrays) + +// Note: Potential annotation allowed node need to collect jsdoc. +// NOLINTBEGIN(fuchsia-statically-constructed-objects, cert-err58-cpp) +static const std::unordered_set ANNOTATION_ALLOWED_NODE = {ir::AstNodeType::METHOD_DEFINITION, + ir::AstNodeType::CLASS_DECLARATION, + ir::AstNodeType::FUNCTION_DECLARATION, + ir::AstNodeType::TS_INTERFACE_DECLARATION, + ir::AstNodeType::CLASS_PROPERTY, + ir::AstNodeType::VARIABLE_DECLARATION, + ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION, + ir::AstNodeType::ARROW_FUNCTION_EXPRESSION, + ir::AstNodeType::ANNOTATION_DECLARATION}; +// NOLINTEND(fuchsia-statically-constructed-objects, cert-err58-cpp) + +static const ArenaVector &GetAstAnnotationUsage(const ir::AstNode *node) +{ + switch (node->Type()) { + case ir::AstNodeType::METHOD_DEFINITION: { + auto *func = node->AsMethodDefinition()->Function(); + ES2PANDA_ASSERT(func != nullptr); + return func->Annotations(); + } + case ir::AstNodeType::CLASS_DECLARATION: + return node->AsClassDeclaration()->Definition()->Annotations(); + case ir::AstNodeType::FUNCTION_DECLARATION: + return node->AsFunctionDeclaration()->Annotations(); + case ir::AstNodeType::TS_INTERFACE_DECLARATION: + return node->AsTSInterfaceDeclaration()->Annotations(); + case ir::AstNodeType::CLASS_PROPERTY: + return node->AsClassProperty()->Annotations(); + case ir::AstNodeType::VARIABLE_DECLARATION: + return node->AsVariableDeclaration()->Annotations(); + case ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION: + return node->AsTSTypeAliasDeclaration()->Annotations(); + case ir::AstNodeType::ETS_PARAMETER_EXPRESSION: + return node->AsETSParameterExpression()->Annotations(); + case ir::AstNodeType::ARROW_FUNCTION_EXPRESSION: + return node->AsArrowFunctionExpression()->Annotations(); + case ir::AstNodeType::ANNOTATION_DECLARATION: + return node->AsAnnotationDeclaration()->Annotations(); + default: + ES2PANDA_UNREACHABLE(); + } +} + +static void HandlePotentialPrefix(parser::JsdocHelper *jsdocHelper) +{ + jsdocHelper->Iterator().Reset(jsdocHelper->Node()->Start().index); + jsdocHelper->BackwardAndSkipSpace(1); + for (auto prefix : POTENTIAL_PREFIX) { + auto currentSv = jsdocHelper->SourceView(START_POS, jsdocHelper->Iterator().Index() + COLLECT_CURRENT_POS); + if (currentSv.EndsWith(prefix)) { + jsdocHelper->BackwardAndSkipSpace(prefix.length()); + } + } +} + +static void HandlePotentialPrefixOrAnnotationUsage(parser::JsdocHelper *jsdocHelper) +{ + if (ANNOTATION_ALLOWED_NODE.count(jsdocHelper->Node()->Type()) == 0) { + HandlePotentialPrefix(jsdocHelper); + return; + } + + auto const &annoUsage = GetAstAnnotationUsage(jsdocHelper->Node()); + if (annoUsage.empty()) { + HandlePotentialPrefix(jsdocHelper); + return; + } + + // Note: eat current iter. + jsdocHelper->Iterator().Reset(annoUsage[0]->Range().start.index - 1); + if (jsdocHelper->Iterator().Index() != START_POS) { + // Note: eat token `@` + jsdocHelper->BackwardAndSkipSpace(1); + } +} + +bool JsdocHelper::BackWardUntilJsdocStart() +{ + while (true) { + const char32_t cp = Iterator().Index() == START_POS ? util::StringView::Iterator::INVALID_CP : PeekBackWard(); + switch (cp) { + case util::StringView::Iterator::INVALID_CP: { + break; + } + case lexer::LEX_CHAR_ASTERISK: { + Backward(1); + if (PeekBackWard() != lexer::LEX_CHAR_ASTERISK) { + continue; + } + + if (Iterator().Index() == START_POS) { + break; + } + + Backward(1); + if (PeekBackWard() == lexer::LEX_CHAR_SLASH) { + return true; + } + continue; + } + default: { + SkipCpBackward(); + continue; + } + } + return false; + } +} + +util::StringView JsdocHelper::GetJsdocBackward() +{ + HandlePotentialPrefixOrAnnotationUsage(this); + size_t jsdocEndPos = Iterator().Index() + COLLECT_CURRENT_POS; + size_t backwardPos = jsdocEndPos; + auto currentSourceView = SourceView(START_POS, jsdocEndPos); + while (currentSourceView.EndsWith(JSDOC_END)) { + BackwardAndSkipSpace(JSDOC_END.length()); + if (!BackWardUntilJsdocStart()) { + break; + } + backwardPos = Iterator().Index(); + BackwardAndSkipSpace(1); + currentSourceView = SourceView(START_POS, Iterator().Index() + COLLECT_CURRENT_POS); + } + + if (backwardPos == jsdocEndPos) { + return EMPTY_JSDOC; + } + return SourceView(backwardPos, jsdocEndPos); +} + +util::StringView JsdocHelper::GetLicenseStringFromStart() +{ + if (!sourceCode_.StartsWith(LICENSES_START) && !sourceCode_.StartsWith(JSDOC_START)) { + return EMPTY_LICENSE; + } + Iterator().Reset(START_POS); + Forward(LICENSES_START.length()); + + do { + const char32_t cp = Iterator().Peek(); + switch (cp) { + case util::StringView::Iterator::INVALID_CP: { + break; + } + case lexer::LEX_CHAR_ASTERISK: { + Forward(1); + if (Iterator().Peek() == lexer::LEX_CHAR_SLASH) { + Forward(1); + break; + } + [[fallthrough]]; + } + default: { + Iterator().SkipCp(); + continue; + } + } + break; + } while (true); + + return SourceView(START_POS, Iterator().Index()); +} +} // namespace ark::es2panda::parser diff --git a/ets2panda/parser/JsdocHelper.h b/ets2panda/parser/JsdocHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..97418e245eb03e837c15d5171aaec1cdc1aa1571 --- /dev/null +++ b/ets2panda/parser/JsdocHelper.h @@ -0,0 +1,185 @@ +/** + * Copyright (c) 2021-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. + */ + +#ifndef ES2PANDA_JSDOC_HELPER_H +#define ES2PANDA_JSDOC_HELPER_H + +#include "parserImpl.h" +#include "parser/program/program.h" +#include "lexer/token/letters.h" +#include "ir/astNode.h" +#include "ir/base/classDefinition.h" +#include "ir/ets/etsModule.h" + +namespace ark::es2panda::parser { +using UStringView = util::StringView; +class JsdocHelper { +public: + explicit JsdocHelper(const ir::AstNode *inputNode) + { + auto root = inputNode; + while (root->Parent() != nullptr) { + root = root->Parent(); + } + root_ = root; + program_ = root_->AsETSModule()->Program(); + sourceCode_ = program_->SourceCode(); + iter_ = util::StringView::Iterator(sourceCode_); + InitNode(inputNode); + } + + NO_COPY_SEMANTIC(JsdocHelper); + DEFAULT_MOVE_SEMANTIC(JsdocHelper); + + ~JsdocHelper() = default; + + util::StringView GetJsdocBackward(); + util::StringView GetLicenseStringFromStart(); + + const ir::AstNode *Node() + { + return node_; + } + + util::StringView::Iterator &Iterator() + { + return iter_; + } + + util::StringView SourceView(size_t begin, size_t end) const + { + return sourceCode_.Substr(begin, end); + } + + void BackwardAndSkipSpace(size_t offset) + { + Iterator().Backward(offset); + SkipWhiteSpacesBackward(); + } + + void Backward(size_t offset) + { + Iterator().Backward(offset); + } + + void Forward(size_t offset) + { + Iterator().Forward(offset); + } + + char32_t PeekBackWard() const + { + return iter_.Peek(); + } + +private: + void InitNode(const ir::AstNode *input) + { + if (input->IsClassDefinition()) { + node_ = input->Parent(); + } else { + node_ = input; + } + } + + bool SkipWhiteSpacesBackwardHelper(const char32_t &cp) + { + if (cp < lexer::LEX_ASCII_MAX_BITS) { + return false; + } + + size_t cpSize {}; + + char32_t ch = Iterator().PeekCp(&cpSize); + switch (ch) { + case lexer::LEX_CHAR_LS: + case lexer::LEX_CHAR_PS: + case lexer::LEX_CHAR_NBSP: + case lexer::LEX_CHAR_ZWNBSP: + case lexer::LEX_CHAR_OGHAM: + case lexer::LEX_CHAR_NARROW_NO_BREAK_SP: + case lexer::LEX_CHAR_MATHEMATICAL_SP: + case lexer::LEX_CHAR_IDEOGRAPHIC_SP: + Iterator().Backward(cpSize); + return true; + default: + if (ch >= lexer::LEX_CHAR_ENQUAD && ch <= lexer::LEX_CHAR_ZERO_WIDTH_SP) { + Iterator().Backward(cpSize); + return true; + } + return false; + } + } + + void SkipWhiteSpacesBackward() + { + bool skipContinue = true; + while (skipContinue) { + auto cp = Iterator().Peek(); + switch (cp) { + case lexer::LEX_CHAR_CR: + case lexer::LEX_CHAR_LF: + case lexer::LEX_CHAR_VT: + case lexer::LEX_CHAR_FF: + case lexer::LEX_CHAR_SP: + case lexer::LEX_CHAR_TAB: + case lexer::LEX_CHAR_NEXT_LINE: + Iterator().Backward(1); + continue; + default: + skipContinue = SkipWhiteSpacesBackwardHelper(cp); + } + } + } + + void SkipCpBackward() + { + if (iter_.Index() == 0) { + return; + } + Backward(1U); + + char32_t cu0 = static_cast(iter_.Peek()); + if (cu0 < UStringView::Constants::UTF8_1BYTE_LIMIT) { + return; + } + + if ((cu0 & UStringView::Constants::UTF8_3BYTE_HEADER) == UStringView::Constants::UTF8_2BYTE_HEADER) { + Backward(1U); + return; + } + + if ((cu0 & UStringView::Constants::UTF8_4BYTE_HEADER) == UStringView::Constants::UTF8_3BYTE_HEADER) { + Backward(2U); + return; + } + + if (((cu0 & UStringView::Constants::UTF8_DECODE_4BYTE_MASK) == UStringView::Constants::UTF8_4BYTE_HEADER) && + (cu0 <= UStringView::Constants::UTF8_DECODE_4BYTE_LIMIT)) { + Backward(3U); + } + } + + bool BackWardUntilJsdocStart(); + + const ir::AstNode *root_ {}; + const parser::Program *program_ {}; + util::StringView sourceCode_ {}; + util::StringView::Iterator iter_ {nullptr}; + const ir::AstNode *node_ {}; +}; +} // namespace ark::es2panda::parser + +#endif diff --git a/ets2panda/parser/TSparser.cpp b/ets2panda/parser/TSparser.cpp index d2545ce4258ac527a5c3a340bb71ad14c40648a6..69368d4accaa49116bfee617847af2661966416e 100644 --- a/ets2panda/parser/TSparser.cpp +++ b/ets2panda/parser/TSparser.cpp @@ -515,7 +515,7 @@ ir::TypeNode *TSParser::ParseTypeOperatorOrTypeReference() } auto *typeOperator = AllocNode(type, ir::TSOperatorType::READONLY, Allocator()); - + ES2PANDA_ASSERT(typeOperator != nullptr); typeOperator->SetRange({typeOperatorStart, type->End()}); return typeOperator; @@ -754,7 +754,7 @@ ir::TSTypeParameter *TSParser::ParseMappedTypeParameter() lexer::SourcePosition endLoc = constraint->End(); auto *typeParameter = AllocNode(paramName, constraint, nullptr, Allocator()); - + ES2PANDA_ASSERT(typeParameter != nullptr); typeParameter->SetRange({startLoc, endLoc}); return typeParameter; @@ -1934,6 +1934,7 @@ ir::MethodDefinition *TSParser::ParseClassMethod(ClassElementDescriptor *desc, } auto *funcExpr = AllocNode(func); + ES2PANDA_ASSERT(funcExpr != nullptr); funcExpr->SetRange(func->Range()); if (desc->methodKind == ir::MethodDefinitionKind::SET) { @@ -1946,6 +1947,7 @@ ir::MethodDefinition *TSParser::ParseClassMethod(ClassElementDescriptor *desc, func->AddFlag(ir::ScriptFunctionFlags::METHOD); auto *method = AllocNode(desc->methodKind, propName, funcExpr, desc->modifiers, Allocator(), desc->isComputed); + ES2PANDA_ASSERT(method != nullptr); method->SetRange(funcExpr->Range()); return method; diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index 581e8dde2695d6a6b698eb2799ec66883c236bff..90150e77c62e99550c8d0618cebd32a12d6344c3 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -296,7 +296,7 @@ ir::TSModuleDeclaration *TypedParser::ParseAmbientExternalModuleDeclaration(cons name = AllocNode(Lexer()->GetToken().String()); } - + ES2PANDA_ASSERT(name != nullptr); name->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); @@ -511,6 +511,7 @@ ir::Statement *TypedParser::ParseInterfaceDeclaration(bool isStatic) auto members = ParseTypeLiteralOrInterface(); auto *body = AllocNode(std::move(members)); + ES2PANDA_ASSERT(body != nullptr); body->SetRange({bodyStart, Lexer()->GetToken().End()}); const auto isExternal = IsExternal(); @@ -587,10 +588,6 @@ ArenaVector TypedParser::ParseTypeLiteralOrInterfaceBody() util::ErrorRecursionGuard infiniteLoopBlocker(Lexer()); ir::AstNode *member = ParseTypeLiteralOrInterfaceMember(); - if (member == nullptr) { - break; - } - if (member->IsMethodDefinition() && member->AsMethodDefinition()->Function() != nullptr && member->AsMethodDefinition()->Function()->IsOverload() && member->AsMethodDefinition()->Function()->Body() != nullptr) { @@ -609,10 +606,6 @@ ArenaVector TypedParser::ParseTypeLiteralOrInterfaceBody() break; } - if (Lexer()->GetToken().Type() == lexer::TokenType::JS_DOC_START) { - continue; - } - if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA && Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_SEMI_COLON) { if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { diff --git a/ets2panda/parser/context/parserContext.cpp b/ets2panda/parser/context/parserContext.cpp index 2fa2490a991db3cf411a497e3798519831c9e32b..5b49e8a43824e5633428619c710f5215927e7828 100644 --- a/ets2panda/parser/context/parserContext.cpp +++ b/ets2panda/parser/context/parserContext.cpp @@ -23,11 +23,6 @@ ParserContext::ParserContext(const Program *program, ParserStatus status) { } -ParserContext::ParserContext(const Program *program, ParserStatus status, bool isEnableJsdoc) - : program_(program), status_(status), lang_(ToLanguage(program->Extension())), isEnableJsdoc_(isEnableJsdoc) -{ -} - const ParserContext *ParserContext::FindLabel(const util::StringView &label) const { const auto *iter = this; diff --git a/ets2panda/parser/context/parserContext.h b/ets2panda/parser/context/parserContext.h index 80620c2c64470287090c67db64fe6ee7f2a2b237..3c5fcd70e54648b81e0612dc7ae097390837bb15 100644 --- a/ets2panda/parser/context/parserContext.h +++ b/ets2panda/parser/context/parserContext.h @@ -74,8 +74,7 @@ enum class ParserStatus : uint64_t { DEPENDENCY_ANALYZER_MODE = 1ULL << 39ULL, STATIC_BLOCK = 1ULL << 40ULL, - ALLOW_JS_DOC_START = 1ULL << 41ULL, - IN_PACKAGE = 1ULL << 42ULL, + IN_PACKAGE = 1ULL << 41ULL, }; } // namespace ark::es2panda::parser @@ -93,8 +92,6 @@ public: explicit ParserContext(const Program *program, ParserStatus status); - explicit ParserContext(const Program *program, ParserStatus status, bool isEnableJsdoc); - explicit ParserContext(ParserContext *current, ParserStatus newStatus, util::StringView label = "") : program_(current->program_), prev_(current), label_(label), lang_(current->lang_) { @@ -103,7 +100,6 @@ public: ParserStatus::ALLOW_THIS_TYPE | ParserStatus::IN_CLASS_BODY | ParserStatus::FUNCTION | ParserStatus::IN_AMBIENT_CONTEXT); status_ = currentStatus | newStatus; - isEnableJsdoc_ = prev_->isEnableJsdoc_; } DEFAULT_COPY_SEMANTIC(ParserContext); @@ -190,11 +186,6 @@ public: return formattingFileName_; } - [[nodiscard]] bool IsEnableJsdocParse() const noexcept - { - return isEnableJsdoc_; - } - template void SetFormattingFileName(T &&fileName) { @@ -208,7 +199,6 @@ private: util::StringView label_ {}; std::string_view formattingFileName_ {DEFAULT_SOURCE_FILE}; Language lang_; - bool isEnableJsdoc_ {false}; }; } // namespace ark::es2panda::parser diff --git a/ets2panda/parser/expressionParser.cpp b/ets2panda/parser/expressionParser.cpp index 596a70e086461c7b6ffc6648ae3bc186c78da65e..89cd7fa0698f0e5de84cc37f8b57832665a8f888 100644 --- a/ets2panda/parser/expressionParser.cpp +++ b/ets2panda/parser/expressionParser.cpp @@ -348,6 +348,7 @@ ir::ArrowFunctionExpression *ParserImpl::ParseArrowFunctionExpressionBody(ArrowF funcNode->SetRange({desc->startLoc, endLoc}); auto *arrowFuncNode = AllocNode(funcNode, Allocator()); + ES2PANDA_ASSERT(arrowFuncNode != nullptr); arrowFuncNode->SetRange(funcNode->Range()); return arrowFuncNode; @@ -1599,6 +1600,9 @@ ir::MemberExpression *ParserImpl::ParsePrivatePropertyAccess(ir::Expression *pri auto *privateIdent = AllocNode(lexer_->GetToken().Ident(), Allocator()); ES2PANDA_ASSERT(privateIdent != nullptr); + if (program_->Extension() == util::gen::extension::ETS && privateIdent->Name().Is("prototype")) { + LogError(diagnostic::PROTOTYPE_ACCESS); + } privateIdent->SetRange({memberStart, lexer_->GetToken().End()}); privateIdent->SetPrivate(true); lexer_->NextToken(); @@ -1613,6 +1617,9 @@ ir::MemberExpression *ParserImpl::ParsePrivatePropertyAccess(ir::Expression *pri ir::MemberExpression *ParserImpl::ParsePropertyAccess(ir::Expression *primaryExpr, bool isOptional) { ir::Identifier *ident = ExpectIdentifier(true); + if (program_->Extension() == util::gen::extension::ETS && ident->Name().Is("prototype")) { + LogError(diagnostic::PROTOTYPE_ACCESS); + } auto *memberExpr = AllocNode(primaryExpr, ident, ir::MemberExpressionKind::PROPERTY_ACCESS, false, isOptional); ES2PANDA_ASSERT(memberExpr != nullptr); @@ -2370,7 +2377,7 @@ ir::Expression *ParserImpl::ParseUnaryOrPrefixUpdateExpression(ExpressionParseFl returnExpr = AllocNode(argument, operatorType); } - ES2PANDA_ASSERT(returnExpr); + ES2PANDA_ASSERT(returnExpr != nullptr); returnExpr->SetRange({start, end}); return returnExpr; @@ -2416,6 +2423,7 @@ ir::Expression *ParserImpl::ParseImportExpression() ExpectToken(lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS); auto *importExpression = AllocNode(source); + ES2PANDA_ASSERT(importExpression != nullptr); importExpression->SetRange({startLoc, endImportLoc}); return importExpression; @@ -2451,6 +2459,7 @@ ir::FunctionExpression *ParserImpl::ParseFunctionExpression(ParserStatus newStat } ir::ScriptFunction *functionNode = ParseFunction(newStatus); + ES2PANDA_ASSERT(functionNode != nullptr); functionNode->SetStart(startLoc); auto *funcExpr = AllocNode(ident, functionNode); diff --git a/ets2panda/parser/parserImpl.cpp b/ets2panda/parser/parserImpl.cpp index 2b6e9ce4816286d4105e555eacad3119d6577124..b9be71ce60be6a99817c0cc0315ab8f11f87e1a9 100644 --- a/ets2panda/parser/parserImpl.cpp +++ b/ets2panda/parser/parserImpl.cpp @@ -46,10 +46,7 @@ using namespace std::literals::string_literals; namespace ark::es2panda::parser { ParserImpl::ParserImpl(Program *program, const util::Options *options, util::DiagnosticEngine &diagnosticEngine, ParserStatus status) - : program_(program), - context_(program_, status, options == nullptr ? false : options->IsEnableJsdocParse()), - options_(options), - diagnosticEngine_(diagnosticEngine) + : program_(program), context_(program_, status), options_(options), diagnosticEngine_(diagnosticEngine) { } @@ -480,6 +477,7 @@ ir::MethodDefinition *ParserImpl::ParseClassMethod(ClassElementDescriptor *desc, : propName; auto *method = AllocNode(desc->methodKind, ident, funcExpr, desc->modifiers, Allocator(), desc->isComputed); + ES2PANDA_ASSERT(method != nullptr); method->SetRange(funcExpr->Range()); return method; @@ -495,6 +493,7 @@ ir::ClassElement *ParserImpl::ParseClassProperty(ClassElementDescriptor *desc, if (desc->classMethod) { property = ParseClassMethod(desc, properties, propName, &propEnd); + ES2PANDA_ASSERT(property != nullptr); property->SetRange({desc->propStart, propEnd}); return property; } @@ -514,7 +513,7 @@ ir::ClassElement *ParserImpl::ParseClassProperty(ClassElementDescriptor *desc, property = AllocNode(propName, value, typeAnnotation, desc->modifiers, Allocator(), desc->isComputed); - + ES2PANDA_ASSERT(property != nullptr); property->SetRange({desc->propStart, propEnd}); return property; @@ -685,6 +684,7 @@ ir::MethodDefinition *ParserImpl::BuildImplicitConstructor(ir::ClassDefinitionMo auto *key = AllocNode("constructor", Allocator()); if ((modifiers & ir::ClassDefinitionModifiers::SET_CTOR_ID) != 0U) { + ES2PANDA_ASSERT(key != nullptr); func->SetIdent(key->Clone(Allocator(), nullptr)); } @@ -710,6 +710,7 @@ void ParserImpl::CreateImplicitConstructor(ir::MethodDefinition *&ctor, ctor = BuildImplicitConstructor(modifiers, startLoc); if ((flags & ir::ModifierFlags::DECLARE) != 0) { + ES2PANDA_ASSERT(ctor != nullptr); auto *ctorFunc = ctor->Function(); ES2PANDA_ASSERT(ctorFunc != nullptr); ctorFunc->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); @@ -836,10 +837,6 @@ ParserImpl::ClassBody ParserImpl::ParseClassBody(ir::ClassDefinitionModifiers mo util::ErrorRecursionGuard infiniteLoopBlocker(Lexer()); ir::AstNode *property = ParseClassElement(properties, modifiers, flags); - if (property == nullptr) { - continue; - } - if (property->IsBrokenStatement()) { // Error processing. continue; } @@ -1216,6 +1213,39 @@ ArenaVector &ParserImpl::ParseExpressionsArrayFormatPlaceholde ES2PANDA_UNREACHABLE(); } +bool ParserImpl::ParsePunctuatorGreaterThan(bool throwError) +{ + switch (Lexer()->GetToken().Type()) { + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: { + Lexer()->BackwardToken(lexer::TokenType::PUNCTUATOR_GREATER_THAN, 1); + break; + } + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT_EQUAL: + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: { + Lexer()->BackwardToken(lexer::TokenType::PUNCTUATOR_GREATER_THAN, 2U); + break; + } + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL: { + Lexer()->BackwardToken(lexer::TokenType::PUNCTUATOR_GREATER_THAN, 3U); + break; + } + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: { + break; + } + default: { + if (throwError) { + LogError(diagnostic::EXPECTED_PARAM_GOT_PARAM, + {TokenToString(lexer::TokenType::PUNCTUATOR_GREATER_THAN), + TokenToString(Lexer()->GetToken().Type())}); + } + return false; + } + } + Lexer()->NextToken(); // eat `>` + return true; +} + util::StringView ParserImpl::ParseSymbolIteratorIdentifier() const noexcept { // Duplicate check - just in case of improper call! @@ -1304,8 +1334,7 @@ ir::Identifier *ParserImpl::ExpectIdentifier([[maybe_unused]] bool isReference, } auto const &tokenStart = token.Start(); - if (token.IsPredefinedType() && !util::Helpers::IsStdLib(program_) && - ((options & TypeAnnotationParsingOptions::ADD_TYPE_PARAMETER_BINDING) == 0)) { + if (!IsValidIdentifierName(token) && ((options & TypeAnnotationParsingOptions::ADD_TYPE_PARAMETER_BINDING) == 0)) { LogError(diagnostic::PREDEFINED_TYPE_AS_IDENTIFIER, {token.Ident()}, tokenStart); lexer_->NextToken(); return AllocBrokenExpression(tokenStart); diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index 533f14d32c005e746bcc9d8da0ab8a9d2b849022..83ee66ad7bcee45602b6b38df169937e916fe117 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -26,6 +26,7 @@ #include "parser/program/program.h" #include "util/diagnosticEngine.h" #include "util/helpers.h" +#include "util/recursiveGuard.h" namespace ark::es2panda::lexer { class RegExpParser; @@ -64,7 +65,8 @@ enum class TypeAnnotationParsingOptions : uint32_t { DISALLOW_UNION = 1U << 15U, POTENTIAL_NEW_ARRAY = 1U << 16U, ANNOTATION_NOT_ALLOW = 1U << 17U, - INSTANCEOF = 1U << 18U + INSTANCEOF = 1U << 18U, + TYPE_ALIAS_CONTEXT = 1U << 19U }; class ParserImpl { @@ -82,6 +84,11 @@ public: return false; } + [[nodiscard]] virtual bool IsValidIdentifierName([[maybe_unused]] const lexer::Token &token) const noexcept + { + return true; + } + ETSParser *AsETSParser() { ES2PANDA_ASSERT(IsETSParser()); @@ -111,7 +118,7 @@ public: ctx_ = ctx; } - public_lib::Context *Context() + public_lib::Context *Context() const { return ctx_; } @@ -151,7 +158,7 @@ protected: void ValidateGroupedExpression(ir::Expression *lhsExpression); ir::Expression *ParseImportExpression(); ir::Expression *ParseOptionalChain(ir::Expression *leftSideExpr); - ir::Expression *ParsePropertyKey(ExpressionParseFlags flags); + virtual ir::Expression *ParsePropertyKey(ExpressionParseFlags flags); void ValidateAssignmentTarget(ExpressionParseFlags flags, ir::Expression *node); void ValidateLvalueAssignmentTarget(ir::Expression *node); void ValidateArrowParameterBindings(const ir::Expression *node); @@ -191,6 +198,7 @@ protected: friend class ETSNolintParser; friend class lexer::RegExpParser; friend class util::SourcePositionHelper; + friend class JsdocHelper; void LogExpectedToken(lexer::TokenType tokenType); void LogUnexpectedToken(lexer::TokenType tokenType); @@ -244,6 +252,7 @@ protected: void ParseIndexSignature(); void EatTypeAnnotation(); + bool ParsePunctuatorGreaterThan(bool throwError = true); util::StringView ParseSymbolIteratorIdentifier() const noexcept; ir::Identifier *ExpectIdentifier(bool isReference = false, bool isUserDefinedType = false, TypeAnnotationParsingOptions options = TypeAnnotationParsingOptions::REPORT_ERROR); @@ -573,6 +582,11 @@ protected: const std::function &parseElement, lexer::SourcePosition *sourceEnd = nullptr, bool allowTrailingSep = false); + RecursiveContext &RecursiveCtx() + { + return recursiveCtx_; + } + private: bool GetCanBeForInOf(ir::Expression *leftNode, ir::AstNode *initNode); Program *program_; @@ -583,6 +597,7 @@ private: const util::Options *options_; util::DiagnosticEngine &diagnosticEngine_; public_lib::Context *ctx_ {nullptr}; + RecursiveContext recursiveCtx_; }; } // namespace ark::es2panda::parser diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index c311d81ec3c170237f0a2cf9d0b9b75b1e3eee7e..e45ca21c2d23a9436926fca75bbf4528f989ca60 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "ETSparser.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" #include "util/errorRecovery.h" @@ -63,6 +62,7 @@ #include "lexer/lexer.h" #include "lexer/token/letters.h" #include "lexer/token/sourceLocation.h" +#include "util/recursiveGuard.h" #include "util/ustring.h" #include "generated/diagnostic.h" @@ -91,6 +91,14 @@ ir::Statement *ParserImpl::ParseStatementLiteralIdentHelper(StatementParsingFlag // NOLINTNEXTLINE(google-default-arguments) ir::Statement *ParserImpl::ParseStatementPunctuatorsHelper(StatementParsingFlags flags) { + TrackRecursive trackRecursive(RecursiveCtx()); + if (!trackRecursive) { + LogError(diagnostic::DEEP_NESTING); + while (Lexer()->GetToken().Type() != lexer::TokenType::EOS) { + Lexer()->NextToken(); + } + return AllocBrokenStatement(Lexer()->GetToken().Loc()); + } switch (lexer_->GetToken().Type()) { case lexer::TokenType::PUNCTUATOR_LEFT_BRACE: return ParseBlockStatement(); @@ -138,10 +146,6 @@ ir::Statement *ParserImpl::ParseStatementControlFlowTokenHelper(StatementParsing // NOLINTNEXTLINE(google-default-arguments) ir::Statement *ParserImpl::ParseStatement(StatementParsingFlags flags) { - if (IsETSParser()) { - AsETSParser()->HandleJsDocLikeComments(); - } - const auto tokenType = lexer_->GetToken().Type(); bool isPunctuatorToken = tokenType == lexer::TokenType::PUNCTUATOR_LEFT_BRACE || tokenType == lexer::TokenType::PUNCTUATOR_SEMI_COLON || @@ -525,9 +529,11 @@ ir::Statement *ParserImpl::ParseBreakStatement() } auto *identNode = AllocNode(label, Allocator()); + ES2PANDA_ASSERT(identNode != nullptr); identNode->SetRange(lexer_->GetToken().Loc()); auto *breakStatement = AllocNode(identNode); + ES2PANDA_ASSERT(breakStatement != nullptr); breakStatement->SetRange({startLoc, lexer_->GetToken().End()}); lexer_->NextToken(); @@ -580,6 +586,7 @@ ir::Statement *ParserImpl::ParseContinueStatement() } auto *identNode = AllocNode(label, Allocator()); + ES2PANDA_ASSERT(identNode != nullptr); identNode->SetRange(lexer_->GetToken().Loc()); auto *continueStatement = AllocNode(identNode); @@ -662,9 +669,11 @@ ir::FunctionDeclaration *ParserImpl::ParseFunctionDeclaration(bool canBeAnonymou if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { if (canBeAnonymous) { ir::ScriptFunction *func = ParseFunction(newStatus | ParserStatus::NEED_RETURN_TYPE); + ES2PANDA_ASSERT(func != nullptr); func->SetStart(startLoc); auto *funcDecl = AllocNode(Allocator(), func, true); + ES2PANDA_ASSERT(funcDecl != nullptr); funcDecl->SetRange(func->Range()); return funcDecl; } @@ -684,6 +693,7 @@ ir::FunctionDeclaration *ParserImpl::ParseFunctionDeclaration(bool canBeAnonymou func->SetIdent(identNode); func->SetStart(startLoc); auto *funcDecl = AllocNode(Allocator(), func); + ES2PANDA_ASSERT(funcDecl != nullptr); funcDecl->SetRange(func->Range()); if (func->IsOverload() && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { @@ -1383,6 +1393,7 @@ ir::Statement *ParserImpl::ParseTryStatement() while (lexer_->GetToken().Type() == lexer::TokenType::KEYW_CATCH) { catchClause = ParseCatchClause(); + ES2PANDA_ASSERT(catchClause != nullptr); endLoc = catchClause->End(); catchClauses.push_back(catchClause); } @@ -1398,6 +1409,7 @@ ir::Statement *ParserImpl::ParseTryStatement() ArenaVector> finalizerInsertions(Allocator()->Adapter()); auto *tryStatement = AllocNode(body, std::move(catchClauses), finallyClause, finalizerInsertions); + ES2PANDA_ASSERT(tryStatement != nullptr); tryStatement->SetRange({startLoc, endLoc}); return tryStatement; } @@ -1539,6 +1551,11 @@ ir::Statement *ParserImpl::ParseVariableDeclaration(VariableParsingFlags flags) ir::VariableDeclarator *declarator = ParseVariableDeclarator(flags); if (declarator != nullptr) { // Error processing. declarators.push_back(declarator); + if (declarator->Init() != nullptr && declarator->Init()->IsETSClassLiteral()) { + ParseClassBody({}); + LogError(diagnostic::UNSUPPORTED_CLASS_LITERAL); + return AllocBrokenStatement(declarator->Init()->Start()); + } } if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA) { @@ -2001,6 +2018,7 @@ ir::Statement *ParserImpl::ParseImportDeclaration(StatementParsingFlags flags) source = ParseFromClause(false); } + ES2PANDA_ASSERT(source != nullptr); lexer::SourcePosition endLoc = source->End(); auto *importDeclaration = AllocNode(source, std::move(specifiers)); ES2PANDA_ASSERT(importDeclaration != nullptr); diff --git a/ets2panda/parser/statementTSParser.cpp b/ets2panda/parser/statementTSParser.cpp index 4cd60c24dbdc8d586dd6fa076ea8788d47759f75..b0a451bcd38a8e6b9058b610c281183fb618cbb2 100644 --- a/ets2panda/parser/statementTSParser.cpp +++ b/ets2panda/parser/statementTSParser.cpp @@ -372,6 +372,7 @@ ir::Statement *TSParser::ParseImportDeclaration([[maybe_unused]] StatementParsin ES2PANDA_ASSERT(source != nullptr); lexer::SourcePosition endLoc = source->End(); auto *importDeclaration = AllocNode(source, std::move(specifiers)); + ES2PANDA_ASSERT(importDeclaration != nullptr); importDeclaration->SetRange({startLoc, endLoc}); ConsumeSemicolon(importDeclaration); diff --git a/ets2panda/public/CMakeLists.txt b/ets2panda/public/CMakeLists.txt index 6d07c5e907a3b58d68004ec3ef4434dcf637f533..29ebe35e309529a070caf7e6df5a350d59a02d1e 100644 --- a/ets2panda/public/CMakeLists.txt +++ b/ets2panda/public/CMakeLists.txt @@ -281,7 +281,6 @@ set (HEADERS_TO_BE_PARSED ${ES2PANDA_ROOT}/ir/statements/annotationDeclaration.h ${ES2PANDA_ROOT}/ir/statements/annotationUsage.h ${ES2PANDA_ROOT}/ir/annotationAllowed.h - ${ES2PANDA_ROOT}/ir/jsDocAllowed.h ${ES2PANDA_ROOT}/ir/base/scriptFunctionSignature.h ${ES2PANDA_ROOT}/ir/expressions/yieldExpression.h ${ES2PANDA_ROOT}/ir/ets/etsNewMultiDimArrayInstanceExpression.h @@ -317,7 +316,6 @@ set (ES2PANDA_API_GENERATED ${LIBGEN_DIR}/gen/headers/varbinder/variableFlags.yaml ${LIBGEN_DIR}/gen/headers/ir/typed.yaml ${LIBGEN_DIR}/gen/headers/ir/annotationAllowed.yaml - ${LIBGEN_DIR}/gen/headers/ir/jsDocAllowed.yaml ${LIBGEN_DIR}/gen/headers/es2panda.yaml ${LIBGEN_DIR}/gen/headers/ir/statements/labelledStatement.yaml ${LIBGEN_DIR}/gen/headers/checker/types/ts/unknownType.yaml diff --git a/ets2panda/public/cppToCTypes.yaml b/ets2panda/public/cppToCTypes.yaml index 8e8f440bb0f04d4735ad0e557ee030c45452ad31..b65c6a310c6843706a28bd06990e9762fc79c01d 100644 --- a/ets2panda/public/cppToCTypes.yaml +++ b/ets2panda/public/cppToCTypes.yaml @@ -2105,7 +2105,7 @@ change_types: namespace: "parser::" cast: expression: >- - auto |es2panda_arg.type.ptr_depth||arg_name|E2p = + auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast(|arg_name|); var_name: '|arg_name|E2p' reverse_cast: @@ -2135,7 +2135,7 @@ change_types: expression: auto &|arg_name|E2p = *reinterpret_cast(|arg_name|); var_name: '|arg_name|E2p' reverse_cast: - start: >- + start: >- reinterpret_cast( reinterpret_cast(context)->allocator->New( end: '))' @@ -2199,12 +2199,26 @@ change_types: type: name: 'Language' min_ptr_depth: 1 + optional: true new_args: + - type: + name: 'Es2pandaLanguage' + ptr_depth: 0 + name: '|arg_name|' + namespace: '' cast: expression: >- + auto |es2panda_arg.type.ptr_depth||arg_name|E2p = + reinterpret_cast(context)->allocator-> + New(static_cast(|arg_name|)); + default_expression: >- auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast(context)->allocator-> New(Language::Id::ETS); + reverse_cast: + start: >- + static_cast( + end: '->GetId())' var_name: '|arg_name|E2p' - es2panda_arg: @@ -2212,10 +2226,21 @@ change_types: type: name: 'Language' max_ptr_depth: 0 + optional: true new_args: + - type: + name: 'Es2pandaLanguage' + ptr_depth: 0 + name: '|arg_name|' + namespace: '' cast: expression: >- - ark::es2panda::Language |arg_name|E2p {Language::Id::ETS}; + ark::es2panda::Language |arg_name|E2p {static_cast(|arg_name|)}; + default_expression: ark::es2panda::Language |arg_name|E2p {Language::Id::ETS}; + reverse_cast: + start: >- + static_cast( + end: '.GetId())' var_name: '|arg_name|E2p' - es2panda_arg: @@ -2892,28 +2917,6 @@ change_types: cast: reverse_cast: '' - - es2panda_arg: - name: '|arg_name|' - type: - name: JsDocInfo - max_ptr_depth: 0 - new_args: - - type: - name: es2panda_JsDocInfo - ptr_depth: 1 - namespace: 'ir::' - name: '|arg_name|' - cast: - expression: "\ - \tir::JsDocInfo |arg_name|ArenaUnorderedMap{reinterpret_cast(context)->allocator->Adapter()};\n - \tfor (size_t j = 0; j < |arg_name|->len; ++j) {\n - \t\t|arg_name|ArenaUnorderedMap.emplace(|arg_name|->strings[j], JsDocRecordToE2p(|arg_name|->jsDocRecords[j]));\n - \t}" - var_name: '|arg_name|ArenaUnorderedMap' - reverse_cast: - start: JsDocInfoFromE2p(reinterpret_cast(context)->allocator, - end: ) - - es2panda_arg: name: '|arg_name|' type: @@ -3666,6 +3669,26 @@ change_types: current_class: TSInterfaceDeclaration max_ptr_depth: 0 min_ptr_depth: 0 + optional: true + default_new_args: + - name: 'id' + type: + name: es2panda_AstNode + ptr_depth: 1 + - name: 'typeParams' + type: + name: es2panda_AstNode + ptr_depth: 1 + - name: 'body' + type: + name: es2panda_AstNode + ptr_depth: 1 + - name: isStatic + type: + name: bool + - name: isExternal + type: + name: bool new_args: - name: 'id' type: @@ -3685,8 +3708,18 @@ change_types: - name: isExternal type: name: bool + - type: + name: 'Es2pandaLanguage' + ptr_depth: 0 + name: 'language' cast: expression: "\ + auto es2pandaId = reinterpret_cast(id);\n + auto es2pandaTypeParams = reinterpret_cast(typeParams);\n + auto es2pandaBody = reinterpret_cast(body);\n + ark::es2panda::Language es2pandaLang {static_cast(language)};\n + " + default_expression: "\ auto es2pandaId = reinterpret_cast(id);\n auto es2pandaTypeParams = reinterpret_cast(typeParams);\n auto es2pandaBody = reinterpret_cast(body);\n @@ -3701,6 +3734,7 @@ change_types: current_class: ScriptFunction max_ptr_depth: 0 min_ptr_depth: 0 + optional: true new_args: - name: '|arg_name|body' type: @@ -3717,16 +3751,43 @@ change_types: - name: '|arg_name|flags' type: name: int + - type: + name: 'Es2pandaLanguage' + ptr_depth: 0 + name: '|arg_name|lang' + default_new_args: + - name: '|arg_name|body' + type: + name: es2panda_AstNode + ptr_depth: 1 + - name: '|arg_name|signature' + type: + name: es2panda_FunctionSignature + ptr_depth: 1 + - name: '|arg_name|funcFlags' + type: + name: int + ptr_depth: 0 + - name: '|arg_name|flags' + type: + name: int cast: expression: " auto *|arg_name|bodyE2p = reinterpret_cast(|arg_name|body);\n auto |arg_name|signatureE2p = std::move(*reinterpret_cast(|arg_name|signature));\n auto |arg_name|funcFlagsE2p = E2pToIrScriptFunctionFlags((Es2pandaScriptFunctionFlags)|arg_name|funcFlags);\n auto |arg_name|flagsE2p = E2pToIrModifierFlags((Es2pandaModifierFlags)|arg_name|flags);\n - ark::es2panda::Language |arg_name|lang {Language::Id::ETS};\n + ark::es2panda::Language |arg_name|langE2p {static_cast(|arg_name|lang)};\n + " + default_expression: " + auto *|arg_name|bodyE2p = reinterpret_cast(|arg_name|body);\n + auto |arg_name|signatureE2p = std::move(*reinterpret_cast(|arg_name|signature));\n + auto |arg_name|funcFlagsE2p = E2pToIrScriptFunctionFlags((Es2pandaScriptFunctionFlags)|arg_name|funcFlags);\n + auto |arg_name|flagsE2p = E2pToIrModifierFlags((Es2pandaModifierFlags)|arg_name|flags);\n + ark::es2panda::Language |arg_name|langE2p {Language::Id::ETS};\n " var_name: "ir::ScriptFunction::ScriptFunctionData {|arg_name|bodyE2p, std::move(|arg_name|signatureE2p), - |arg_name|funcFlagsE2p, |arg_name|flagsE2p, |arg_name|lang}" + |arg_name|funcFlagsE2p, |arg_name|flagsE2p, |arg_name|langE2p}" - es2panda_arg: name: '|arg_name|' diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index 0b0638b0f7878fd3396d306664bcc06b6e844ee9..f9295c138b39925fae9abee5f58d562e4e0266a8 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -14,6 +14,7 @@ */ #include "es2panda_lib.h" +#include #include #include @@ -200,37 +201,6 @@ __attribute__((unused)) es2panda_OverloadInfo OverloadInfoToE2p(const ir::Overlo return es2pandaOverloadInfo; } -__attribute__((unused)) ir::JsDocRecord JsDocRecordToE2p(const es2panda_JsDocRecord *jsDocRecord) -{ - return ir::JsDocRecord(jsDocRecord->name, jsDocRecord->param, jsDocRecord->comment); -} - -__attribute__((unused)) es2panda_JsDocRecord *JsDocRecordFromE2p(ArenaAllocator *allocator, - const ir::JsDocRecord &jsDocRecord) -{ - es2panda_JsDocRecord *res = allocator->New(); - res->name = StringViewToCString(allocator, jsDocRecord.name); - res->param = StringViewToCString(allocator, jsDocRecord.param); - res->comment = StringViewToCString(allocator, jsDocRecord.comment); - return res; -} - -__attribute__((unused)) es2panda_JsDocInfo *JsDocInfoFromE2p(ArenaAllocator *allocator, const ir::JsDocInfo &jsDocInfo) -{ - size_t jsDocInfoLen = jsDocInfo.size(); - es2panda_JsDocInfo *res = allocator->New(); - res->len = jsDocInfoLen; - res->strings = allocator->New(jsDocInfoLen); - res->jsDocRecords = allocator->New(jsDocInfoLen); - size_t i = 0; - for (const auto &[key, value] : jsDocInfo) { - res->strings[i] = StringViewToCString(allocator, key); - res->jsDocRecords[i] = JsDocRecordFromE2p(allocator, value); - ++i; - }; - return res; -} - __attribute__((unused)) char const *ArenaStrdup(ArenaAllocator *allocator, char const *src) { size_t len = strlen(src); @@ -542,6 +512,16 @@ extern __attribute__((unused)) es2panda_Context *CreateContextGenerateAbcForExte return reinterpret_cast(res); } +extern "C" __attribute__((unused)) es2panda_Context *CreateContextFromStringWithHistory(es2panda_Config *config, + const char *source, + char const *fileName) +{ + // NOTE: gogabr. avoid copying source. + es2panda_Context *context = CreateContextFromString(config, source, fileName); + ir::EnableContextHistory(); + return context; +} + __attribute__((unused)) static Context *Parse(Context *ctx) { if (ctx->state != ES2PANDA_STATE_NEW) { @@ -933,18 +913,20 @@ extern "C" const es2panda_DiagnosticKind *CreateDiagnosticKind(es2panda_Context } extern "C" es2panda_DiagnosticInfo *CreateDiagnosticInfo(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc) + const char **args, size_t argc, es2panda_SourcePosition *pos) { auto *allocator = reinterpret_cast(context)->allocator; auto diagnosticInfo = allocator->New(); diagnosticInfo->kind = kind; diagnosticInfo->args = args; diagnosticInfo->argc = argc; + diagnosticInfo->pos = pos; return diagnosticInfo; } extern "C" es2panda_SuggestionInfo *CreateSuggestionInfo(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc, const char *substitutionCode) + const char **args, size_t argc, const char *substitutionCode, + es2panda_SourceRange *range) { auto *allocator = reinterpret_cast(context)->allocator; auto suggestionInfo = allocator->New(); @@ -952,11 +934,12 @@ extern "C" es2panda_SuggestionInfo *CreateSuggestionInfo(es2panda_Context *conte suggestionInfo->args = args; suggestionInfo->argc = argc; suggestionInfo->substitutionCode = substitutionCode; + suggestionInfo->range = range; return suggestionInfo; } extern "C" void LogDiagnosticWithSuggestion(es2panda_Context *context, const es2panda_DiagnosticInfo *diagnosticInfo, - const es2panda_SuggestionInfo *suggestionInfo, es2panda_SourceRange *range) + const es2panda_SuggestionInfo *suggestionInfo) { auto ctx = reinterpret_cast(context); auto diagnostickind = reinterpret_cast(diagnosticInfo->kind); @@ -972,9 +955,8 @@ extern "C" void LogDiagnosticWithSuggestion(es2panda_Context *context, const es2 suggestionParams.push_back(suggestionInfo->args[i]); } - auto *allocator = reinterpret_cast(context)->allocator; - auto E2pRange = reinterpret_cast(range); - auto posE2p = allocator->New(E2pRange->start); + auto E2pRange = reinterpret_cast(suggestionInfo->range); + auto posE2p = reinterpret_cast(diagnosticInfo->pos); auto suggestion = ctx->diagnosticEngine->CreateSuggestion(suggestionkind, suggestionParams, suggestionInfo->substitutionCode, E2pRange); ctx->diagnosticEngine->LogDiagnostic(*diagnostickind, diagnosticParams, *posE2p, suggestion); @@ -1030,6 +1012,16 @@ extern "C" bool IsAnyError(es2panda_Context *context) return reinterpret_cast(context)->diagnosticEngine->IsAnyError(); } +extern "C" size_t SourcePositionCol([[maybe_unused]] es2panda_Context *context, es2panda_SourcePosition *position) +{ + static const size_t EMPTY = 1; + auto es2pandaPosition = reinterpret_cast(position); + if (es2pandaPosition->Program() == nullptr) { + return EMPTY; + } + return es2pandaPosition->ToLocation().col; +} + extern "C" size_t SourcePositionIndex([[maybe_unused]] es2panda_Context *context, es2panda_SourcePosition *position) { return reinterpret_cast(position)->index; @@ -1114,6 +1106,40 @@ extern "C" es2panda_AstNode *DeclarationFromIdentifier([[maybe_unused]] es2panda return reinterpret_cast(compiler::DeclarationFromIdentifier(E2pNode)); } +extern "C" bool IsImportTypeKind([[maybe_unused]] es2panda_Context *context, es2panda_AstNode *node) +{ + auto E2pNode = reinterpret_cast(node); + if (E2pNode->IsETSImportDeclaration()) { + return E2pNode->AsETSImportDeclaration()->IsTypeKind(); + } + + if (E2pNode->IsImportDeclaration()) { + return E2pNode->AsETSImportDeclaration()->IsTypeKind(); + } + + auto ctx = reinterpret_cast(context); + auto id = ctx->config->diagnosticKindStorage.size() + 1; + auto type = util::DiagnosticType::PLUGIN_WARNING; + util::DiagnosticMessageParams params {}; + diagnostic::DiagnosticKind *kind = &ctx->config->diagnosticKindStorage.emplace_back(type, id, "Insert wrong node!"); + ctx->diagnosticEngine->LogDiagnostic(*kind, params, E2pNode->Start()); + return false; +} + +extern "C" char *GetLicenseFromRootNode(es2panda_Context *ctx, es2panda_AstNode *node) +{ + auto E2pNode = reinterpret_cast(node); + auto *allocator = reinterpret_cast(ctx)->allocator; + return StringViewToCString(allocator, compiler::GetLicenseFromRootNode(E2pNode)); +} + +extern "C" char *JsdocStringFromDeclaration([[maybe_unused]] es2panda_Context *ctx, es2panda_AstNode *node) +{ + auto E2pNode = reinterpret_cast(node); + auto *allocator = reinterpret_cast(ctx)->allocator; + return StringViewToCString(allocator, compiler::JsdocStringFromDeclaration(E2pNode)); +} + extern "C" es2panda_AstNode *FirstDeclarationByNameFromNode([[maybe_unused]] es2panda_Context *ctx, const es2panda_AstNode *node, const char *name) { @@ -1243,7 +1269,7 @@ extern "C" es2panda_AstNode **AllDeclarationsByNameFromProgram([[maybe_unused]] extern "C" __attribute__((unused)) int GenerateTsDeclarationsFromContext(es2panda_Context *ctx, const char *outputDeclEts, const char *outputEts, bool exportAll, - bool isolated) + bool isolated, const char *recordFile) { auto *ctxImpl = reinterpret_cast(ctx); auto *checker = reinterpret_cast(ctxImpl->GetChecker()); @@ -1253,6 +1279,7 @@ extern "C" __attribute__((unused)) int GenerateTsDeclarationsFromContext(es2pand declgenOptions.outputDeclEts = outputDeclEts ? outputDeclEts : ""; declgenOptions.outputEts = outputEts ? outputEts : ""; declgenOptions.isolated = isolated; + declgenOptions.recordFile = recordFile ? recordFile : ""; return ark::es2panda::declgen_ets2ts::GenerateTsDeclarations(checker, ctxImpl->parserProgram, declgenOptions) ? 0 : 1; @@ -1329,6 +1356,7 @@ es2panda_Impl g_impl = { CreateContextFromFile, CreateCacheContextFromFile, CreateContextFromString, + CreateContextFromStringWithHistory, CreateCacheContextFromString, CreateContextGenerateAbcForExternalSourceFiles, ProceedToState, @@ -1357,6 +1385,7 @@ es2panda_Impl g_impl = { AllocMemory, CreateSourcePosition, CreateSourceRange, + SourcePositionCol, SourcePositionIndex, SourcePositionLine, SourceRangeStart, @@ -1377,6 +1406,9 @@ es2panda_Impl g_impl = { Es2pandaEnumFromString, Es2pandaEnumToString, DeclarationFromIdentifier, + IsImportTypeKind, + JsdocStringFromDeclaration, + GetLicenseFromRootNode, FirstDeclarationByNameFromNode, FirstDeclarationByNameFromProgram, AllDeclarationsByNameFromNode, diff --git a/ets2panda/public/es2panda_lib.h b/ets2panda/public/es2panda_lib.h index cbc9e0a411e5a470a203255e5fd6f472cefcb5ed..945578067875d79516a713f9166df6d4274a5089 100644 --- a/ets2panda/public/es2panda_lib.h +++ b/ets2panda/public/es2panda_lib.h @@ -129,18 +129,6 @@ typedef struct es2panda_OverloadInfo { bool returnVoid; } es2panda_OverloadInfo; -typedef struct es2panda_JsDocRecord { - char *name; - char *param; - char *comment; -} es2panda_JsDocRecord; - -typedef struct es2panda_JsDocInfo { - char **strings; - es2panda_JsDocRecord **jsDocRecords; - size_t len; -} es2panda_JsDocInfo; - enum es2panda_ContextState { ES2PANDA_STATE_NEW, ES2PANDA_STATE_PARSED, @@ -158,16 +146,25 @@ typedef struct es2panda_SuggestionInfo { const char **args; size_t argc; const char *substitutionCode; + es2panda_SourceRange *range; } es2panda_SuggestionInfo; typedef struct es2panda_DiagnosticInfo { const es2panda_DiagnosticKind *kind; const char **args; size_t argc; + es2panda_SourcePosition *pos; } es2panda_DiagnosticInfo; enum es2panda_PluginDiagnosticType { ES2PANDA_PLUGIN_WARNING, ES2PANDA_PLUGIN_ERROR, ES2PANDA_PLUGIN_SUGGESTION }; +typedef enum Es2pandaLanguage { + LANGUAGE_AS, + LANGUAGE_JS, + LANGUAGE_TS, + LANGUAGE_ETS, +} Es2pandaLanguage; + typedef enum es2panda_PluginDiagnosticType es2panda_PluginDiagnosticType; typedef enum es2panda_ContextState es2panda_ContextState; // CC-OFFNXT(G.INC.08) project code style @@ -188,6 +185,8 @@ struct CAPI_EXPORT es2panda_Impl { es2panda_Context *(*CreateCacheContextFromFile)(es2panda_Config *config, char const *source_file_name, es2panda_GlobalContext *globalContext, bool isExternal); es2panda_Context *(*CreateContextFromString)(es2panda_Config *config, const char *source, char const *file_name); + es2panda_Context *(*CreateContextFromStringWithHistory)(es2panda_Config *config, const char *source, + char const *file_name); es2panda_Context *(*CreateCacheContextFromString)(es2panda_Config *config, const char *source, char const *file_name, es2panda_GlobalContext *globalContext, bool isExternal); @@ -233,6 +232,7 @@ struct CAPI_EXPORT es2panda_Impl { es2panda_SourcePosition *(*CreateSourcePosition)(es2panda_Context *context, size_t index, size_t line); es2panda_SourceRange *(*CreateSourceRange)(es2panda_Context *context, es2panda_SourcePosition *start, es2panda_SourcePosition *end); + size_t (*SourcePositionCol)(es2panda_Context *context, es2panda_SourcePosition *position); size_t (*SourcePositionIndex)(es2panda_Context *context, es2panda_SourcePosition *position); size_t (*SourcePositionLine)(es2panda_Context *context, es2panda_SourcePosition *position); es2panda_SourcePosition *(*SourceRangeStart)(es2panda_Context *context, es2panda_SourceRange *range); @@ -240,11 +240,12 @@ struct CAPI_EXPORT es2panda_Impl { const es2panda_DiagnosticKind *(*CreateDiagnosticKind)(es2panda_Context *context, const char *dmessage, es2panda_PluginDiagnosticType etype); es2panda_DiagnosticInfo *(*CreateDiagnosticInfo)(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc); + const char **args, size_t argc, es2panda_SourcePosition *position); es2panda_SuggestionInfo *(*CreateSuggestionInfo)(es2panda_Context *context, const es2panda_DiagnosticKind *kind, - const char **args, size_t argc, const char *substitutionCode); + const char **args, size_t argc, const char *substitutionCode, + es2panda_SourceRange *range); void (*LogDiagnosticWithSuggestion)(es2panda_Context *context, const es2panda_DiagnosticInfo *diagnosticInfo, - const es2panda_SuggestionInfo *suggestionInfo, es2panda_SourceRange *range); + const es2panda_SuggestionInfo *suggestionInfo); void (*LogDiagnostic)(es2panda_Context *context, const es2panda_DiagnosticKind *kind, const char **args, size_t argc, es2panda_SourcePosition *pos); const es2panda_DiagnosticStorage *(*GetSemanticErrors)(es2panda_Context *context); @@ -258,6 +259,9 @@ struct CAPI_EXPORT es2panda_Impl { Es2pandaEnum (*Es2pandaEnumFromString)(es2panda_Context *ctx, const char *str); char *(*Es2pandaEnumToString)(es2panda_Context *ctx, Es2pandaEnum id); es2panda_AstNode *(*DeclarationFromIdentifier)(es2panda_Context *ctx, es2panda_AstNode *node); + bool (*IsImportTypeKind)(es2panda_Context *ctx, es2panda_AstNode *node); + char *(*JsdocStringFromDeclaration)(es2panda_Context *ctx, es2panda_AstNode *node); + char *(*GetLicenseFromRootNode)(es2panda_Context *ctx, es2panda_AstNode *node); es2panda_AstNode *(*FirstDeclarationByNameFromNode)(es2panda_Context *ctx, const es2panda_AstNode *node, const char *name); es2panda_AstNode *(*FirstDeclarationByNameFromProgram)(es2panda_Context *ctx, const es2panda_Program *program, @@ -268,7 +272,8 @@ struct CAPI_EXPORT es2panda_Impl { const char *name, size_t *declsLen); int (*GenerateTsDeclarationsFromContext)(es2panda_Context *context, const char *outputDeclEts, - const char *outputEts, bool exportAll, bool isolated); + const char *outputEts, bool exportAll, bool isolated, + const char *recordFile); void (*InsertETSImportDeclarationAndParse)(es2panda_Context *context, es2panda_Program *program, es2panda_AstNode *importDeclaration); int (*GenerateStaticDeclarationsFromContext)(es2panda_Context *context, const char *outputPath); diff --git a/ets2panda/public/es2panda_lib.idl.erb b/ets2panda/public/es2panda_lib.idl.erb index 3d997031adc25c515d03dd285653d65c1056b5a3..c52ea85899a6d4b5c5aebd2566bc44369e42243e 100644 --- a/ets2panda/public/es2panda_lib.idl.erb +++ b/ets2panda/public/es2panda_lib.idl.erb @@ -131,12 +131,14 @@ interface es2panda_SuggestionInfo { attribute sequence args; attribute u32 argc; attribute String substitutionCode; + attribute es2panda_SourceRange range; }; interface es2panda_DiagnosticInfo { attribute es2panda_DiagnosticKind kind; attribute sequence args; attribute u32 argc; + attribute es2panda_SourcePosition pos; }; dictionary es2panda_PluginDiagnosticType { @@ -175,6 +177,7 @@ interface es2panda_Impl { es2panda_Context CreateContextFromFile(es2panda_Config config, String source_file_name); es2panda_Context CreateCacheContextFromFile(es2panda_Config config, String source_file_name, es2panda_GlobalContext globalContext, boolean isExternal); es2panda_Context CreateContextFromString(es2panda_Config config, String source, String file_name); + es2panda_Context CreateContextFromStringWithHistory(es2panda_Config config, String source, String file_name); es2panda_Context CreateCacheContextFromString(es2panda_Config config, String source, String file_name, es2panda_GlobalContext globalContext, boolean isExternal); es2panda_Context CreateContextGenerateAbcForExternalSourceFiles(es2panda_Config config, i32 fileNamesCount, sequence fileNames); es2panda_Context ProceedToState(es2panda_Context context, es2panda_ContextState state); // context is consumed @@ -201,11 +204,11 @@ interface es2panda_Impl { es2panda_SourcePosition SourceRangeStart(es2panda_Context context, es2panda_SourceRange range); es2panda_SourcePosition SourceRangeEnd(es2panda_Context context, es2panda_SourceRange range); es2panda_DiagnosticInfo CreateDiagnosticInfo(es2panda_Context context, es2panda_DiagnosticKind kind, - sequence args, u32 argc); + sequence args, u32 argc, es2panda_SourcePosition position); es2panda_SuggestionInfo CreateDiagnosticInfo(es2panda_Context context, es2panda_DiagnosticKind kind, - sequence args, u32 argc, String substitutionCode); + sequence args, u32 argc, String substitutionCode, es2panda_SourceRange range); void LogDiagnosticWithSuggestion(es2panda_Context context, es2panda_DiagnosticInfo diagnosticInfo, - es2panda_SuggestionInfo suggestionInfo, es2panda_SourceRange range); + es2panda_SuggestionInfo suggestionInfo); void LogTypeError(es2panda_Context context, String errorMsg, es2panda_SourcePosition pos); void LogWarning(es2panda_Context context, String warnMsg, es2panda_SourcePosition pos); void LogSyntaxError(es2panda_Context context, String errorMsg, es2panda_SourcePosition pos); @@ -216,6 +219,9 @@ interface es2panda_Impl { Es2pandaEnum Es2pandaEnumFromString(es2panda_Context ctx, String str); String Es2pandaEnumToString(es2panda_Context ctx, Es2pandaEnum id); ir.AstNode DeclarationFromIdentifier(es2panda_Context ctx, ir.Identifier node); + boolean IsImportTypeKind(es2panda_Context ctx, ir.AstNode node); + String JsdocStringFromDeclaration(es2panda_Context ctx, ir.AstNode node); + String GetLicenseFromRootNode(es2panda_Context ctx, ir.AstNode node); ir.AstNode FirstDeclarationByNameFromNode(es2panda_Context ctx, ir.AstNode node, String name); ir.AstNode FirstDeclarationByNameFromProgram(es2panda_Context ctx, es2panda_Program program, String name); sequence AllDeclarationsByNameFromNode(es2panda_Context ctx, ir.AstNode node, String name); diff --git a/ets2panda/public/es2panda_lib.rb b/ets2panda/public/es2panda_lib.rb index ea0f1efc6d44a0f9754fdd140dffeeabc902034c..82f2cd6522a9269a242eeec28c2e0150afa6e504 100644 --- a/ets2panda/public/es2panda_lib.rb +++ b/ets2panda/public/es2panda_lib.rb @@ -33,6 +33,8 @@ module Es2pandaLibApi @is_scope_type = false @is_code_gen = false @is_decl_type = false + @is_optional = false + @default_optional = false @const = '' @base_namespace = '' @@ -245,7 +247,13 @@ module Es2pandaLibApi [found_change_type_link, err_msg] end - def initialize(arg_info, base_namespace) + def set_default_expression_cast(found_change_type) + return unless found_change_type && @is_optional && @default_optional + found_change_type.cast['expression'] = found_change_type.cast['default_expression'] + found_change_type.new_args = found_change_type.default_new_args || [] + end + + def initialize(arg_info, base_namespace, default_optional = false) found_change_type_link, err_msg = Arg.get_change_type_info_with_err_msg(arg_info) raise err_msg unless err_msg.nil? @@ -254,6 +262,7 @@ module Es2pandaLibApi @const = Arg.const(arg_info) @es2panda_arg['const'] = @const @base_namespace = base_namespace + @default_optional = default_optional @is_ast_node = Arg.is_ast_node(es2panda_arg) @is_ast_node_add_children = Arg.is_ast_node_add_children(es2panda_arg) @@ -267,6 +276,8 @@ module Es2pandaLibApi if found_change_type_link found_change_type = Marshal.load(Marshal.dump(found_change_type_link)) + @is_optional = found_change_type.es2panda_arg.respond_to?('optional') && found_change_type.es2panda_arg['optional'] + set_default_expression_cast(found_change_type) placeholders = find_placeholders(found_change_type.es2panda_arg) @@ -402,12 +413,13 @@ module Es2pandaLibApi Arg.set_const_modifier(@lib_args, @const) Arg.set_const_modifier(@idl_args, @const) - tmp = Arg.new(@lib_args[0], @base_namespace) + tmp = Arg.new(@lib_args[0], @base_namespace, @default_optional) @lib_args = tmp.lib_args @idl_args = tmp.idl_args @lib_cast = tmp.lib_cast @return_args = tmp.return_args @idl_return_args = tmp.idl_return_args + @is_optional = tmp.is_optional return if tmp.check_allowed_type(@lib_args[0]) nested_arg_transform @@ -508,6 +520,7 @@ module Es2pandaLibApi attr_reader :return_args attr_reader :idl_return_args attr_reader :const + attr_reader :is_optional def lib_args_to_str @lib_args.map do |lib_arg| @@ -806,31 +819,43 @@ module Es2pandaLibApi usings = usings_map constructor_overload = {} idl_constructor_overload = {} - dig(:constructors)&.each do |constructor| - if check_no_gen_constructor(constructor) - args = [] - begin - constructor_cast - constructor.args&.each do |arg| - arg['type'] = replace_with_usings(arg['type'], usings) - arg['type'] = add_base_namespace(arg['type']) - arg['type']['current_class'] = constructor.name - args << Arg.new(arg, class_base_namespace) + constructors = dig(:constructors) + constructors_with_optional = [] + [constructors, constructors_with_optional].each do |constructors_list| + is_with_optional_list = constructors_list == constructors_with_optional + constructors_list&.each do |constructor| + if check_no_gen_constructor(constructor) + begin + args = [] + constructor_cast + optional_args_info = [] + constructor.args&.each do |arg| + arg['type'] = replace_with_usings(arg['type'], usings) + arg['type'] = add_base_namespace(arg['type']) + arg['type']['current_class'] = constructor.name + processed_arg = Arg.new(arg, class_base_namespace, !is_with_optional_list) + if processed_arg.is_optional && !is_with_optional_list + optional_args_info << { name: arg['type']['name'] } + end + args << processed_arg + end + if !optional_args_info.empty? && !is_with_optional_list + constructors_with_optional << Marshal.load(Marshal.dump(constructor)) + end + rescue StandardError => e + error_catch_log('Constructor', constructor, e, 'Create' + class_name) + else + Es2pandaLibApi.stat_add_constructor(1, class_name, class_base_namespace, 'Create' + class_name) + Es2pandaLibApi.stat_add_class(1, class_name) + + Es2pandaLibApi.log('info', "Supported constructor for class '#{class_name}'\n") + res << { 'overload' => get_new_method_name(constructor_overload, '', ''), + 'idl_overload' => get_new_method_name(idl_constructor_overload, '', '', true), + 'args' => args, 'raw_decl' => constructor.raw_declaration } end - rescue StandardError => e - error_catch_log('Constructor', constructor, e, 'Create' + class_name) else - Es2pandaLibApi.stat_add_constructor(1, class_name, class_base_namespace, 'Create' + class_name) - Es2pandaLibApi.stat_add_class(1, class_name) - - Es2pandaLibApi.log('info', "Supported constructor for class '#{class_name}'\n") - - res << { 'overload' => get_new_method_name(constructor_overload, '', ''), - 'idl_overload' => get_new_method_name(idl_constructor_overload, '', '', true), - 'args' => args, 'raw_decl' => constructor.raw_declaration } + Es2pandaLibApi.log('info', "Banned constructor for class '#{class_name}'\n") end - else - Es2pandaLibApi.log('info', "Banned constructor for class '#{class_name}'\n") end end res @@ -985,39 +1010,52 @@ module Es2pandaLibApi template_extends.each do |template_extend| methods += Es2pandaLibApi.classes['ir'][template_extend]['methods'] end - methods.each do |method| - if check_no_gen_method(method) - begin - return_type = Type.new(add_base_namespace(replace_with_usings(method.return_type, usings)), - class_base_namespace, 'return') - const = get_const_modifier(method) - const_return = get_const_return_modifier(return_type) - - args = [] - method.args.each do |arg| - arg['type'] = add_base_namespace(replace_with_usings(arg['type'], usings)) - args << Arg.new(arg, class_base_namespace) + methods_with_optional = [] + [methods, methods_with_optional].each do |methods_list| + is_with_optional_list = methods_list == methods_with_optional + methods_list&.each do |method| + if check_no_gen_method(method) + begin + return_type = Type.new(add_base_namespace(replace_with_usings(method.return_type, usings)), + class_base_namespace, 'return') + const = get_const_modifier(method) + const_return = get_const_return_modifier(return_type) + + args = [] + optional_args_info = [] + method.args.each_with_index do |arg, arg_index| + arg['type'] = add_base_namespace(replace_with_usings(arg['type'], usings)) + processed_arg = Arg.new(arg, class_base_namespace, !is_with_optional_list) + if processed_arg.is_optional && !is_with_optional_list + optional_args_info << { name: arg['type']['name'] } + end + args << processed_arg + end + + if !optional_args_info.empty? && !is_with_optional_list + methods_with_optional << Marshal.load(Marshal.dump(method)) + end + + return_expr = get_return_expr(return_type, call_cast, [const, const_return], method, args, 'method') + rescue StandardError => e + stat_function_overload = Marshal.load(Marshal.dump(function_overload)) + error_catch_log('Method', method, e, class_name + + get_new_method_name(stat_function_overload, method.name, const)) + else + stat_function_overload = Marshal.load(Marshal.dump(function_overload)) + Es2pandaLibApi.stat_add_method(1, class_name, class_base_namespace, class_name + + get_new_method_name(stat_function_overload, method.name, const)) + Es2pandaLibApi.log('info', 'supported method: ', method.name, ' class: ', class_name, "\n") + + res << { 'name' => method.name, 'const' => const, 'return_arg_to_str' => return_type.return_args_to_str, + 'overload_name' => get_new_method_name(function_overload, method.name, const), 'args' => args, + 'idl_name' => get_new_method_name(idl_function_overload, method.name, const, true), + 'return_type' => return_type, 'return_expr' => return_expr, 'raw_decl' => method.raw_declaration, + 'const_return' => const_return, 'get_modifier' => method['additional_attributes'] } end - - return_expr = get_return_expr(return_type, call_cast, [const, const_return], method, args, 'method') - rescue StandardError => e - stat_function_overload = Marshal.load(Marshal.dump(function_overload)) - error_catch_log('Method', method, e, class_name + - get_new_method_name(stat_function_overload, method.name, const)) else - stat_function_overload = Marshal.load(Marshal.dump(function_overload)) - Es2pandaLibApi.stat_add_method(1, class_name, class_base_namespace, class_name + - get_new_method_name(stat_function_overload, method.name, const)) - Es2pandaLibApi.log('info', 'supported method: ', method.name, ' class: ', class_name, "\n") - - res << { 'name' => method.name, 'const' => const, 'return_arg_to_str' => return_type.return_args_to_str, - 'overload_name' => get_new_method_name(function_overload, method.name, const), 'args' => args, - 'idl_name' => get_new_method_name(idl_function_overload, method.name, const, true), - 'return_type' => return_type, 'return_expr' => return_expr, 'raw_decl' => method.raw_declaration, - 'const_return' => const_return, 'get_modifier' => method['additional_attributes'] } + Es2pandaLibApi.log('info', "Banned method\n") end - else - Es2pandaLibApi.log('info', "Banned method\n") end end res @@ -1300,7 +1338,7 @@ module Es2pandaLibApi end def template_extends_classes - %w[Annotated Typed AnnotationAllowed JsDocAllowed] + %w[Annotated Typed AnnotationAllowed] end def primitive_types @@ -1378,8 +1416,7 @@ module Es2pandaLibApi es2panda_Options es2panda_Path es2panda_OverloadInfo - es2panda_JsDocRecord - es2panda_JsDocInfo + Es2pandaLanguage ] end diff --git a/ets2panda/public/ignoredAllowed.yaml b/ets2panda/public/ignoredAllowed.yaml index ec92b68d4549a4df1b0aca010da5aeb809d6c77e..3c86e801fe0102fdcc81a4a8947c30fbcd3481c4 100644 --- a/ets2panda/public/ignoredAllowed.yaml +++ b/ets2panda/public/ignoredAllowed.yaml @@ -96,7 +96,6 @@ ignored_list: - name: optional namespace: std - name: WrapperDesc - - name: Language - name: ScopedDebugInfoPlugin - name: Args namespace: parser @@ -251,4 +250,3 @@ allowed_list: - StringView - TypeNode - ArkTsConfig - - JsDocInfo diff --git a/ets2panda/public/public.h b/ets2panda/public/public.h index b3cd4ade2b4619c18aa50c9089bc265a130b0ba7..72c7553a18454f2d47da38885160feb121da5090 100644 --- a/ets2panda/public/public.h +++ b/ets2panda/public/public.h @@ -176,11 +176,10 @@ struct Context { checkers_.push_back(checker); } - void DestoryCheckers() + // NOTE(zhelyapov): It's calling side responsibility to release resources + void ClearCheckers() { - for (auto item : checkers_) { - delete item; - } + checkers_.clear(); } checker::SemanticAnalyzer *GetAnalyzer() const; @@ -190,11 +189,18 @@ struct Context { return analyzers_.push_back(analyzer); } - void DestoryAnalyzers() + // NOTE(zhelyapov): It's calling side responsibility to release resources + void ClearAnalyzers() + { + analyzers_.clear(); + } + + util::StringView GetDupProgramOriginalPath(util::StringView oldPath) { - for (auto item : analyzers_) { - delete item; + if (auto it = dupPrograms.find(oldPath); it != dupPrograms.end()) { + return it->second->AbsoluteName(); } + return oldPath; } void MarkGenAbcForExternal(std::unordered_set &genAbcList, public_lib::ExternalSource &extSources); diff --git a/ets2panda/scripts/arkui.properties b/ets2panda/scripts/arkui.properties index 7d6bdd3fa139d1d75411a3b00c6007b7445f2198..0f1ace41c58ce40f7535a1d7545a873559ba43a8 100644 --- a/ets2panda/scripts/arkui.properties +++ b/ets2panda/scripts/arkui.properties @@ -1,3 +1,3 @@ ARKUI_DEV_REPO=https://gitee.com/rri_opensource/koala_projects.git -ARKUI_DEV_BRANCH=panda_rev_9-unions +ARKUI_DEV_BRANCH=panda_rev_9-decl_record_0702 ARKUI_DEST=koala-sig diff --git a/ets2panda/test/CMakeLists.txt b/ets2panda/test/CMakeLists.txt index 7694d4828f5fd03d527d30014b265fec919db64d..4f93b770d714d363126516a9a4235bdde2a79ae8 100644 --- a/ets2panda/test/CMakeLists.txt +++ b/ets2panda/test/CMakeLists.txt @@ -29,6 +29,8 @@ if(PANDA_TARGET_ARM32 OR PANDA_ARM64_TESTS_WITH_SANITIZER) return() endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") + add_custom_target(es2panda_tests COMMENT "Running es2panda test suites") add_custom_target(es2panda_gtests COMMENT "Running es2panda gtest suites") set(DEFAULT_TEST_GROUP ets_tests) @@ -87,4 +89,4 @@ endif() add_subdirectory(tsconfig) add_subdirectory(options) add_subdirectory(unit) -add_subdirectory(depanalyzer) \ No newline at end of file +add_subdirectory(depanalyzer) diff --git a/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_1.ets b/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bcecc08b108c82e890c26cca09adede03514cfd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_1.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +const e = 123 +@interface Ajno { + b:e: string[][X (c + d)],% + +/* @@? 18:7 Error TypeError: Cannot find type 'e'. */ +/* @@? 18:17 Error SyntaxError: Unexpected token ']'. */ +/* @@? 18:29 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 25:1 Error SyntaxError: Unexpected token 'end of stream'. */ + diff --git a/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_2.ets b/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..733c4a5ea39287c5feff86ad9570d5792ccd1d8f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/Const_Literal_As_TypeAnnotation_2.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +const e = true +@interface Ajno { + b:e: string[][X (c + d)],% + +/* @@? 18:7 Error TypeError: Cannot find type 'e'. */ +/* @@? 18:17 Error SyntaxError: Unexpected token ']'. */ +/* @@? 18:29 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 25:1 Error SyntaxError: Unexpected token 'end of stream'. */ + diff --git a/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets b/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets index 7cf36bcc8b7057d45402c54cb177cf50fe9a53d4..4bc211702aec007aadc16ba78c9c77aae9a249f8 100644 --- a/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets +++ b/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets @@ -17,6 +17,13 @@ declare class A { [index: number]: string // indexer declaration } +declare class B { + [index: int] : number +} + +declare interface C { + [index :int]: string + } function main () { diff --git a/ets2panda/test/ast/compiler/ets/Invalid_rest_element_wtih_tuple_type.ets b/ets2panda/test/ast/compiler/ets/Invalid_rest_element_wtih_tuple_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..2df27d5f56a862325f9c2a6c08f4187c54b23292 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/Invalid_rest_element_wtih_tuple_type.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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. + */ + +class TH { + static restMethod(...v: [number, B, C]) { + } +} + +function main() { + let mc = new TH +} + +/* @@? 17:38 Error TypeError: Cannot make a static reference to the non-static type B */ +/* @@? 17:41 Error TypeError: Cannot make a static reference to the non-static type C */ diff --git a/ets2panda/test/ast/compiler/ets/ambient_namesapce04.ets b/ets2panda/test/ast/compiler/ets/ambient_namesapce04.ets index 2f94e6b211099caf8f854c0e11ad69626db12558..22b20fdb661e543f2e6a4d3b3d7eb7921f2704b1 100644 --- a/ets2panda/test/ast/compiler/ets/ambient_namesapce04.ets +++ b/ets2panda/test/ast/compiler/ets/ambient_namesapce04.ets @@ -21,4 +21,4 @@ declare namespace MySpace{ } /* @@? 18:20 Error TypeError: Native, Abstract and Declare methods cannot have body. */ -/* @@? 19:12 Error TypeError: Native and Declare methods should have explicit return type. */ \ No newline at end of file +/* @@? 19:9 Error TypeError: Native and Declare methods should have explicit return type. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/anno_required_fields.ets b/ets2panda/test/ast/compiler/ets/anno_required_fields.ets new file mode 100644 index 0000000000000000000000000000000000000000..3791299398ac689ef2f36c845c9db3fd5315a60a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/anno_required_fields.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +@interface AnnoSrc.ClassAuthor { + mutilArray:number[][] = [ + [...(()=>{})] + ] +} + +@ClassAuthor +function main() {} + +/* @@? 16:12 Error TypeError: Cannot find type 'AnnoSrc'. */ +/* @@? 16:20 Error TypeError: 'ClassAuthor' type does not exist. */ +/* @@? 17:29 Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ diff --git a/ets2panda/test/ast/compiler/ets/annotation_decl_dot_empty.ets b/ets2panda/test/ast/compiler/ets/annotation_decl_dot_empty.ets new file mode 100644 index 0000000000000000000000000000000000000000..c077a76fd0de0cd1798da4d69b10e1ffa6f67022 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_decl_dot_empty.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +@interface Message. +{ +} + +/* @@? 16:12 Error SyntaxError: Invalid annotation name. */ +/* @@? 17:1 Error SyntaxError: Identifier expected. */ diff --git a/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets b/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets new file mode 100644 index 0000000000000000000000000000000000000000..195205770f44ca73bc0d7620e1f006014838e9d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +class MyTest { + @Consume. + private property1; +} + +/* @@? 17:6 Error SyntaxError: Invalid annotation name. */ +/* @@? 18:5 Error SyntaxError: Identifier expected. */ +/* @@? 18:22 Error SyntaxError: Field type annotation expected. */ diff --git a/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_and_class_with_same_name.ets b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_and_class_with_same_name.ets new file mode 100644 index 0000000000000000000000000000000000000000..28d6784792ee058afcb2e5e01cb887efc981acf4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_and_class_with_same_name.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +class A {} + +@interface A { } + +/* @@? 18:12 Error TypeError: Variable 'A' has already been declared. */ diff --git a/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_bad_target.ets b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_bad_target.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3deff1d62d3ad1055db607884d901f6d128a532 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_bad_target.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. +*/ + +@interface +this.context; + +/* @@? 17:1 Error SyntaxError: Identifier expected. */ +/* @@? 17:1 Error SyntaxError: Invalid annotation name. */ +/* @@? 17:1 Error SyntaxError: Expected '{', got 'this'. */ +/* @@? 17:5 Error SyntaxError: Identifier expected, got '.'. */ +/* @@? 17:13 Error SyntaxError: Missing type annotation for property 'context'. */ diff --git a/ets2panda/test/ast/compiler/ets/array_index.ets b/ets2panda/test/ast/compiler/ets/array_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b56d97710ad4fcb598a55d88d864b79e8e98cb23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/array_index.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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. + */ + +const a: Char[] = new Char[n = 10]; + +/* @@? 16:28 Error TypeError: Unresolved reference n */ diff --git a/ets2panda/test/ast/compiler/ets/arrow_function_call_as_record_property_key.ets b/ets2panda/test/ast/compiler/ets/arrow_function_call_as_record_property_key.ets index aac66bdd5465ff3d70694377378bad0d3ae7ac2c..4dc414ecae8d55007635a4f124f47655944fa159 100644 --- a/ets2panda/test/ast/compiler/ets/arrow_function_call_as_record_property_key.ets +++ b/ets2panda/test/ast/compiler/ets/arrow_function_call_as_record_property_key.ets @@ -24,6 +24,34 @@ const b: Record number> = { [(():number => +("bar"))()]: (y: string):number => y.length }; -/* @@? 21:20 Error TypeError: Wrong operand type for unary expression */ -/* @@? 21:34 Error SyntaxError: Function expressions are not supported, use arrow functions instead */ -/* @@? 24:20 Error TypeError: Wrong operand type for unary expression */ +/* @@? 16:35 Error TypeError: need to specify target type for class composite */ +/* @@? 17:5 Error SyntaxError: Unexpected token. */ +/* @@? 17:6 Error SyntaxError: Unexpected token, expected ':'. */ +/* @@? 17:22 Error SyntaxError: Unexpected token. */ +/* @@? 17:25 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:26 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:28 Error SyntaxError: Unexpected token '1'. */ +/* @@? 18:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 20:50 Error TypeError: need to specify target type for class composite */ +/* @@? 21:5 Error SyntaxError: Unexpected token. */ +/* @@? 21:6 Error SyntaxError: Unexpected token, expected ':'. */ +/* @@? 21:20 Error TypeError: Wrong operand type for unary expression */ +/* @@? 21:28 Error SyntaxError: Unexpected token. */ +/* @@? 21:31 Error SyntaxError: Unexpected token ']'. */ +/* @@? 21:32 Error SyntaxError: Unexpected token ':'. */ +/* @@? 21:34 Error SyntaxError: Unexpected token 'function'. */ +/* @@? 21:43 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 23:6 Error SyntaxError: Unexpected token ','. */ +/* @@? 23:6 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 24:20 Error TypeError: Wrong operand type for unary expression */ +/* @@? 24:32 Error SyntaxError: Unexpected token ':'. */ +/* @@? 24:35 Error TypeError: Unresolved reference y */ +/* @@? 24:36 Error SyntaxError: Unexpected token ':'. */ +/* @@? 24:36 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 24:38 Error SyntaxError: Unexpected token 'string'. */ +/* @@? 24:38 Error TypeError: Type name 'string' used in the wrong context */ +/* @@? 24:44 Error SyntaxError: Unexpected token ')'. */ +/* @@? 24:45 Error SyntaxError: Unexpected token ':'. */ +/* @@? 24:46 Error SyntaxError: Unexpected token 'number'. */ +/* @@? 24:46 Error TypeError: The type of parameter 'number' cannot be inferred */ +/* @@? 25:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets b/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ada0b3f4a16f33d233f126163a51cccf8c45000 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +let foo: (P: string, Q: string) => void + +foo((value: Object): void => { }, (err: Error): void => { }) + +/* @@? 18:1 Error TypeError: No matching call signature for ((value: Object) => void, (err: Error) => void) */ +/* @@? 18:5 Error TypeError: Type '(value: Object) => void' is not compatible with type 'String' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/assign_const.ets b/ets2panda/test/ast/compiler/ets/assign_const.ets new file mode 100644 index 0000000000000000000000000000000000000000..150e93078fba6d138db5456d9106038e3519a10a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/assign_const.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +function main(): void { + const c = 0; + /* @@ label */c = c + 1; +} + +/* @@@ label Error TypeError: Cannot assign to a constant variable c */ diff --git a/ets2panda/test/ast/compiler/ets/bad_call_setter.ets b/ets2panda/test/ast/compiler/ets/bad_call_setter.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e68c90948a0b0e4020b1ba1fc04c6a4ea1b623b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/bad_call_setter.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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. + */ + +interface I { + set text(s: string) +} + +class B implements I { + text: string = "" + s : string + this.text = s; +} + +function main() { + let ins: I = new B(); + ins.text = "He"; +} + +/* @@? 23:5 Error SyntaxError: Unexpected token 'this'. */ +/* @@? 23:9 Error SyntaxError: Unexpected token '.'. */ +/* @@? 23:10 Error TypeError: Variable 'text' has already been declared. */ +/* @@? 23:17 Error TypeError: Property 's' must be accessed through 'this' */ diff --git a/ets2panda/test/ast/compiler/ets/binary_operator_neg.ets b/ets2panda/test/ast/compiler/ets/binary_operator_neg.ets index 8b71c849f8ad5d88e633c11d47ad0de13bdd8ae8..4bee69637bc0a64837cb1169e070ffe61136a56f 100644 --- a/ets2panda/test/ast/compiler/ets/binary_operator_neg.ets +++ b/ets2panda/test/ast/compiler/ets/binary_operator_neg.ets @@ -15,7 +15,8 @@ /* @@ label1 */@@/@ -/* @@@ label1 Error SyntaxError: Unexpected token '@@'. */ -/* @@? 21:93 Error SyntaxError: Identifier expected, got 'end of stream'. */ -/* @@? 21:93 Error SyntaxError: Unexpected token 'end of stream'. */ -/* @@? 21:93 Error SyntaxError: Annotations are not allowed on this type of declaration. */ \ No newline at end of file +/* @@@ label1 Error SyntaxError: Unexpected token '@@'. */ +/* @@? 23:1 Error SyntaxError: Identifier expected, got 'end of stream'. */ +/* @@? 23:1 Error SyntaxError: Invalid annotation name. */ +/* @@? 23:1 Error SyntaxError: Unexpected token 'end of stream'. */ +/* @@? 23:1 Error SyntaxError: Annotations are not allowed on this type of declaration. */ diff --git a/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets b/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets new file mode 100644 index 0000000000000000000000000000000000000000..69ec693282a4dbdeaa781a7c0070ec839ebf2b9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +let tup : [['arkTs' | boolean, 1 | true]] = [['arkTs', 1]]; + +/* @@? 16:32 Error SyntaxError: Invalid Type. */ +/* @@? 16:32 Error SyntaxError: Unexpected token, expected ',' or ']'. */ +/* @@? 16:32 Error SyntaxError: Unexpected token '1'. */ +/* @@? 16:32 Error TypeError: Wrong type of operands for binary expression */ +/* @@? 16:40 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:41 Error SyntaxError: Unexpected token ']'. */ diff --git a/ets2panda/test/ast/compiler/ets/block_namespace_interface_name_conflict.ets b/ets2panda/test/ast/compiler/ets/block_namespace_interface_name_conflict.ets new file mode 100644 index 0000000000000000000000000000000000000000..545e1aa5f40daba7ddea7cf183439d762eaa679b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/block_namespace_interface_name_conflict.ets @@ -0,0 +1,26 @@ + +/* + * Copyright (c) 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. + */ + +{ + interface A { + } + namespace A { + } +} + +/* @@? 20:5 Error SyntaxError: Namespace is allowed only at the top level or inside a namespace. */ +/* @@? 20:15 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 20:15 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ diff --git a/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets new file mode 100755 index 0000000000000000000000000000000000000000..9c4ec53ad739e45888b7d93afc7c2439e82cf254 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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. + */ + +Class MyClass { + compare((value: number, index:number, arr: Array)) {} +} + +/* @@? 16:1 Error SyntaxError: Class cannot be used as object. */ +/* @@? 16:7 Error SyntaxError: Unexpected token 'MyClass'. */ +/* @@? 16:7 Error TypeError: Unresolved reference MyClass */ +/* @@? 16:15 Error SyntaxError: Unexpected token '{'. */ +/* @@? 17:3 Error TypeError: Unresolved reference compare */ +/* @@? 17:17 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token 'number'. */ +/* @@? 17:19 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:25 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:27 Error SyntaxError: Unexpected token 'index'. */ +/* @@? 17:33 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:33 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:39 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:41 Error SyntaxError: Unexpected token 'arr'. */ +/* @@? 17:46 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:46 Error TypeError: No matching call signature with trailing lambda */ +/* @@? 17:59 Error SyntaxError: Unexpected token, expected '('. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/call_signature_error.ets b/ets2panda/test/ast/compiler/ets/call_signature_error.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ec272c4893662db5f0d5284f7fbe4089092332a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/call_signature_error.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +type DescribableFunction = /* @@ label1 */{ + /* @@ label2 */(someArg: number): string +} + +/* @@@ label1 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@@ label2 Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ diff --git a/ets2panda/test/ast/compiler/ets/check_spreadElement.ets b/ets2panda/test/ast/compiler/ets/check_spreadElement.ets new file mode 100644 index 0000000000000000000000000000000000000000..69f13c49a7233439470f4d94ed06dcb94a10e042 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/check_spreadElement.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +[a, b, ...rest] = [1, 2, 3, 4, 5]; + +/* @@? 16:1 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 16:2 Error TypeError: Unresolved reference a */ +/* @@? 16:5 Error TypeError: Unresolved reference b */ +/* @@? 16:11 Error TypeError: Unresolved reference rest */ diff --git a/ets2panda/test/ast/compiler/ets/circular_unfold.ets b/ets2panda/test/ast/compiler/ets/circular_unfold.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fabd26be970ccdd8a3f6a791be482626d9d6c39 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/circular_unfold.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ + +function foo() { + const a = a + const b = b + return b - a +} + +/* @@? 17:11 Error TypeError: Circular dependency detected for identifier: a */ +/* @@? 17:15 Error TypeError: Variable 'a' is accessed before it's initialization. */ +/* @@? 18:11 Error TypeError: Circular dependency detected for identifier: b */ +/* @@? 18:15 Error TypeError: Variable 'b' is accessed before it's initialization. */ diff --git a/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets b/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets new file mode 100644 index 0000000000000000000000000000000000000000..d495c7c9514e0254f84b57b15d5a7a724ba318b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 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. + */ + +class A { + public x : int; + + public constructor() { + this(5); + } + + public constructor( + let tuple: {{c.to_type}} = {{caches.value}}; + let a : A = new A(...tuple); + let method_result = A.bar(...tuple); + ) { + this.x = a; + } +} + +/* @@? 23:23 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 24:9 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 24:9 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 24:9 Error SyntaxError: Unexpected token 'let'. */ +/* @@? 24:9 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 24:20 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 24:21 Error SyntaxError: Unexpected token '{'. */ +/* @@? 24:23 Error SyntaxError: Field type annotation expected. */ +/* @@? 24:23 Error SyntaxError: Unexpected token '.'. */ +/* @@? 24:31 Error SyntaxError: Field type annotation expected. */ +/* @@? 24:34 Error SyntaxError: Unexpected token '='. */ +/* @@? 24:36 Error SyntaxError: Unexpected token '{'. */ +/* @@? 24:38 Error TypeError: Unresolved reference caches */ +/* @@? 25:21 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@? 25:21 Error TypeError: No matching construct signature for class_cyclic_constructor.A(...tuple) */ +/* @@? 25:30 Error TypeError: Unresolved reference tuple */ +/* @@? 26:31 Error TypeError: Property 'bar' does not exist on type 'A' */ +/* @@? 27:5 Error SyntaxError: Unexpected token ')'. */ +/* @@? 27:7 Error SyntaxError: Unexpected token '{'. */ +/* @@? 28:9 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 28:14 Error TypeError: Property 'x' does not exist on type 'Error' */ +/* @@? 30:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/class_literal.ets b/ets2panda/test/ast/compiler/ets/class_literal.ets new file mode 100644 index 0000000000000000000000000000000000000000..6162acc11169e5bab28a982fc4ae3a2e44a22601 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/class_literal.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ + +let rectangle = class { + constructor(height: number, width: number) { + this.height = height + this.width = width + } + height: number; + width: number; +} + +/* @@? 26:1 Error TypeError: Class literal is not yet supported. */ diff --git a/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets b/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c4d1ca68c2f3f6c8f275eeda94077be514aa2bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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. + */ + +export default class TreeMap implements ReadonlyTreeMap { + + private mappedIterator(fn: (e: TreeMapEntry) => R): IterableIterator { + export default namespace buffer{ } + + const buffer = new ArrayBuffer(length); + let offset = 0; + for (let i = 0; i < length; i++) { + buffer.set(offset, length[i]); + } + return new buffer(buffer); + } +} + +/* @@? 16:47 Error TypeError: Cannot find type 'ReadonlyTreeMap'. */ +/* @@? 16:47 Error TypeError: Interface expected here. */ +/* @@? 18:39 Error TypeError: Cannot find type 'TreeMapEntry'. */ +/* @@? 19:9 Error SyntaxError: Unexpected token 'export'. */ +/* @@? 19:16 Error SyntaxError: Unexpected token 'default'. */ +/* @@? 19:24 Error SyntaxError: Unexpected token 'namespace'. */ +/* @@? 19:24 Error SyntaxError: Namespace is allowed only at the top level or inside a namespace. */ +/* @@? 21:15 Error TypeError: Variable 'buffer' has already been declared. */ +/* @@? 21:15 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 24:32 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 26:20 Error TypeError: Cannot find type 'buffer'. */ diff --git a/ets2panda/test/ast/compiler/ets/conditional-type-alias.ets b/ets2panda/test/ast/compiler/ets/conditional-type-alias.ets new file mode 100644 index 0000000000000000000000000000000000000000..d852f652917f4b46fc2edd7d7a331cfb3038dd20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/conditional-type-alias.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +// (arkts-no-conditional-types) +type X = T extends number ? T : string + +/* @@? 17:15 Error SyntaxError: Unexpected token 'extends'. */ +/* @@? 17:15 Error TypeError: Conditional type aliases are not supported. Introduce a new type with constraints explicitly, or rewrite logic using Object! */ +/* @@? 17:23 Error SyntaxError: Unexpected token 'number'. */ +/* @@? 17:23 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:32 Error TypeError: Unresolved reference T */ +/* @@? 17:36 Error TypeError: Type name 'string' used in the wrong context */ diff --git a/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference.ets b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..ece14278ce1e0ea0ce2eb5cc1836602e5dc6e2fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +const constExpr = "123" +let variable: constExpr = 42 + +/* @@? 17:15 Error TypeError: Cannot find type 'constExpr'. */ diff --git a/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference1.ets b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference1.ets new file mode 100644 index 0000000000000000000000000000000000000000..60cb72873ec79bf0374872f317c91ea67f254a95 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference1.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 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. + */ + +class NestedClass { + readonly constField: string = "123" +} + +class A { + readonly constClass: NestedClass + + constructor() { + this.constClass = new NestedClass + } +} + +const constExpr = new A +let variable: constExpr.constClass.constField = 42 + +/* @@? 29:15 Error TypeError: Cannot find type 'constExpr'. */ +/* @@? 29:25 Error TypeError: 'constClass' type does not exist. */ +/* @@? 29:36 Error TypeError: 'constField' type does not exist. */ diff --git a/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference2.ets b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference2.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba90d65351785c6f913951fcc97bb6ccce6730b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/constExpressionAsTypeReference2.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +class A { + readonly constField: string = "123" +} + +const constExpr = new A +let variable: constExpr.constField = 42 + +/* @@? 21:15 Error TypeError: Cannot find type 'constExpr'. */ +/* @@? 21:25 Error TypeError: 'constField' type does not exist. */ diff --git a/ets2panda/test/ast/compiler/ets/conversion_double_to_float.ets b/ets2panda/test/ast/compiler/ets/conversion_double_to_float.ets new file mode 100644 index 0000000000000000000000000000000000000000..18a14085dc15282e037ca0e0892f9833c732c931 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/conversion_double_to_float.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + +function foo(a: float) : Int { + return 0; +} + +export const f1: float = 1.0; + +function main() { + const f2: float = 2.0; + + foo(3.0); + foo(4.0); + + foo(1.0/0.0); + foo(Infinity); + foo(NaN); +} + +/* @@? 28:5 Error TypeError: No matching call signature for foo(Double) */ +/* @@? 28:9 Error TypeError: Type 'Double' is not compatible with type 'Float' at index 1 */ +/* @@? 29:5 Error TypeError: No matching call signature for foo(Double) */ +/* @@? 29:9 Error TypeError: Type 'Double' is not compatible with type 'Float' at index 1 */ +/* @@? 30:5 Error TypeError: No matching call signature for foo(Double) */ +/* @@? 30:9 Error TypeError: Type 'Double' is not compatible with type 'Float' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/default_type_circular_dependency.ets b/ets2panda/test/ast/compiler/ets/default_type_circular_dependency.ets new file mode 100644 index 0000000000000000000000000000000000000000..973142e608fa841101956aa3d71627bd596646eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/default_type_circular_dependency.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +class Racer { + stat; +} + +/* @@? 17:9 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:16 Error TypeError: Default type of type parameter has circular dependency. */ +/* @@? 17:22 Error TypeError: 'f' type does not exist. */ +/* @@? 17:23 Error SyntaxError: Unexpected token, expected '>'. */ +/* @@? 17:24 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 17:25 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 17:25 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 17:25 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:25 Error SyntaxError: Unexpected token '>'. */ diff --git a/ets2panda/test/ast/compiler/ets/empty_tuple_assignmemt.ets b/ets2panda/test/ast/compiler/ets/empty_tuple_assignmemt.ets new file mode 100644 index 0000000000000000000000000000000000000000..80163182816856e82a7c3e58a536d9d9e106ee05 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/empty_tuple_assignmemt.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + + +let tuple: [string,number] = /* @@ label */[] + +/* @@@ label Error TypeError: Initializer has 0 elements, but tuple requires 2 */ diff --git a/ets2panda/test/ast/compiler/ets/export_and_export_type_class.ets b/ets2panda/test/ast/compiler/ets/export_and_export_type_class.ets index 57d8b40dda03b0dd27436131530e014f8aed9172..ba28d7a7b82c333c15592100bf24415f65acfd2e 100644 --- a/ets2panda/test/ast/compiler/ets/export_and_export_type_class.ets +++ b/ets2panda/test/ast/compiler/ets/export_and_export_type_class.ets @@ -15,5 +15,3 @@ export class A {} export type {/* @@ label */A} - -/* @@@ label Error SyntaxError: Cannot export 'A', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/export_and_export_type_interface.ets b/ets2panda/test/ast/compiler/ets/export_and_export_type_interface.ets index 0b4bef4431094310a46587df4152ce66aec47e84..201b28a8dde1d91067b5c91d203a8a1ea6e5c548 100644 --- a/ets2panda/test/ast/compiler/ets/export_and_export_type_interface.ets +++ b/ets2panda/test/ast/compiler/ets/export_and_export_type_interface.ets @@ -15,5 +15,3 @@ export interface I {} export type {/* @@ label */I} - -/* @@@ label Error SyntaxError: Cannot export 'I', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/export_same_type_at_decl_and_selective_binding.ets b/ets2panda/test/ast/compiler/ets/export_same_type_at_decl_and_selective_binding.ets index e566df5aae04642896e431ed25cc40269097d0df..206cbcabbfdbe33e05b1b534c2dc0b1caa60e063 100644 --- a/ets2panda/test/ast/compiler/ets/export_same_type_at_decl_and_selective_binding.ets +++ b/ets2panda/test/ast/compiler/ets/export_same_type_at_decl_and_selective_binding.ets @@ -15,6 +15,3 @@ export type class A {} export type {/* @@ label */A} - - -/* @@@ label Error SyntaxError: Cannot export 'A', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_class_multiple_times.ets b/ets2panda/test/ast/compiler/ets/export_type_class_multiple_times.ets index 4609849c5dd6816c3d4ec31b3166efbc84023691..4a2147118c7545d83f849190cc7f84a2319c0ff6 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_class_multiple_times.ets +++ b/ets2panda/test/ast/compiler/ets/export_type_class_multiple_times.ets @@ -19,5 +19,4 @@ export type {A} export type MyA = A export type {MyA} -/* @@? 20:14 Error SyntaxError: The given name 'MyA' is already used in another export. */ -/* @@? 20:14 Error SyntaxError: Cannot export 'MyA', it was already exported. */ +/* @@? 16:1 Warning Warning: Duplicated export aliases for 'MyA'. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_interface_multiple_times.ets b/ets2panda/test/ast/compiler/ets/export_type_interface_multiple_times.ets index 0a34b8a2ccc76dfe13ec1f5db9f8a32b69a1f350..c714b60e24ca21ee91891a307510645039df3154 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_interface_multiple_times.ets +++ b/ets2panda/test/ast/compiler/ets/export_type_interface_multiple_times.ets @@ -18,6 +18,3 @@ interface I {} export type {I} export type MyI = I export type {MyI} - -/* @@? 20:14 Error SyntaxError: The given name 'MyI' is already used in another export. */ -/* @@? 20:14 Error SyntaxError: Cannot export 'MyI', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/extension_crash.ets b/ets2panda/test/ast/compiler/ets/extension_crash.ets new file mode 100644 index 0000000000000000000000000000000000000000..4cea736a025dceffd04c645e0d6f52efe5ac0157 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/extension_crash.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +class A { + foo(this.data); +} + +function foo(this: A) { +} + +/* @@? 17:8 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:13 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ +/* @@? 17:13 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:13 Error SyntaxError: Unexpected token '.'. */ +/* @@? 17:18 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:18 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/abstract_method.ets b/ets2panda/test/ast/compiler/ets/first_match/abstract_method.ets index c79e3ffb023ffe70e2e8944f0721c25e29113bad..2178322e65317b0220380a30f75519977a86a9a3 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/abstract_method.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/abstract_method.ets @@ -16,8 +16,5 @@ abstract class Base { abstract fooNumber(a: number): string; abstract fooString(a: string): string; - overload foo {/* @@ label1 */fooNumber,/* @@ label2 */fooString } + overload foo {fooNumber,fooString } } - -/* @@@ label1 Error TypeError: overload declaration cannot contain abstract methods. */ -/* @@@ label2 Error TypeError: overload declaration cannot contain abstract methods. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets b/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets index 46cd5f3a1508f0b19bc235a02ab5c147a3500717..4b2ca22d2237ede77d490dff5c8ca604fd5bbfb4 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets @@ -29,7 +29,7 @@ class Base { class Sub extends Base { bar() { - /* @@ label1 */this.foo("abc"); + /* @@ label */this.foo(/* @@ label1 */"abc"); this.foo(1); this.foo(true); } @@ -42,8 +42,10 @@ function main() { a.foo(true); } -/* @@@ label1 Error TypeError: Signature fooPrivate(x: String): void is not visible here. */ -/* @@@ label1 Error TypeError: No matching call signature for foo("abc") */ +/* @@@ label Error TypeError: Signature fooPrivate(x: String): void is not visible here. */ +/* @@@ label Error TypeError: No matching call signature for fooPrivate("abc") */ +/* @@@ label1 Error TypeError: Type '"abc"' is not compatible with type 'Double' at index 1 */ +/* @@@ label1 Error TypeError: Type '"abc"' is not compatible with type 'Boolean' at index 1 */ /* @@@ label2 Error TypeError: Signature fooPrivate(x: String): void is not visible here. */ /* @@@ label2 Error TypeError: No matching call signature for foo("abc") */ /* @@@ label3 Error TypeError: Signature fooProtected(x: Double): void is not visible here. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/declare_class.ets b/ets2panda/test/ast/compiler/ets/first_match/declare_class.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa5734b298d462a38e3a908e206699a4b7377410 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/declare_class.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export declare class A { + overload on{ on1, on2 } + on1(a: string): void + on2(a: number): void +} diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7a80816f02fbb0dec419f0ca02691fb0e1239bb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +overload foo{ foo.,T,} + +/* @@? 16:19 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:19 Error TypeError: overloaded name must refer to an accessible method. */ +/* @@? 16:20 Error SyntaxError: Unexpected token, expected ',' or '}'. */ +/* @@? 16:20 Error TypeError: Unresolved reference T */ +/* @@? 16:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 16:22 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_declare.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_declare.ets new file mode 100644 index 0000000000000000000000000000000000000000..090aa4c25a1bed2ae8e7fdd14100942d82869e32 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_declare.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +overload * you thMMMMMMMMdSTICKER, + +/* @@? 16:10 Error SyntaxError: Identifier expected, got '*'. */ +/* @@? 16:12 Error SyntaxError: Unexpected token, expected '{'. */ +/* @@? 16:12 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:12 Error TypeError: overloaded name must refer to an accessible method. */ +/* @@? 16:16 Error SyntaxError: Unexpected token, expected ',' or '}'. */ +/* @@? 16:16 Error TypeError: Unresolved reference thMMMMMMMMdSTICKER */ +/* @@? 16:34 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_declare2.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_declare2.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9f652b9de1bfb071691c24e84caf55b313d6842 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_declare2.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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. + */ + +class A{ + overload * you thMMMMMMMMdSTICKER, +} + +/* @@? 17:14 Error SyntaxError: Identifier expected, got '*'. */ +/* @@? 17:16 Error SyntaxError: Unexpected token, expected '{'. */ +/* @@? 17:16 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 17:16 Error TypeError: overloaded name must refer to an accessible method. */ +/* @@? 17:20 Error SyntaxError: Unexpected token, expected ',' or '}'. */ +/* @@? 17:38 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:38 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_identifier.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_identifier.ets index ae4fa8c99034df45a516c1c07df188bfc069a50c..597ad29e1a5d28de16e8d6f818b30dbc7bc1b145 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/invalid_identifier.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_identifier.ets @@ -32,12 +32,12 @@ function main(){ /* @@? 21:20 Error TypeError: overloaded name must refer to an accessible method. */ /* @@? 21:21 Error SyntaxError: Unexpected token, expected ',' or '}'. */ /* @@? 21:21 Error TypeError: Variable 'foo1' has already been declared. */ -/* @@? 21:25 Error SyntaxError: Field type annotation expected. */ /* @@? 21:25 Error SyntaxError: Unexpected token ','. */ +/* @@? 21:25 Error SyntaxError: Field type annotation expected. */ /* @@? 21:30 Error SyntaxError: Field type annotation expected. */ /* @@? 21:30 Error SyntaxError: Unexpected token ','. */ -/* @@? 21:35 Error SyntaxError: Field type annotation expected. */ /* @@? 21:35 Error SyntaxError: Unexpected token ')'. */ +/* @@? 21:35 Error SyntaxError: Field type annotation expected. */ /* @@? 21:36 Error SyntaxError: Unexpected token '{'. */ /* @@? 22:20 Error SyntaxError: Unexpected token, expected '{'. */ /* @@? 22:20 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -49,4 +49,3 @@ function main(){ /* @@? 22:26 Error TypeError: Unresolved reference foo2 */ /* @@? 22:30 Error SyntaxError: Unexpected token ')'. */ /* @@? 23:1 Error SyntaxError: Unexpected token '}'. */ -/* @@? 27:7 Error TypeError: Property 'foo111' does not exist on type 'Test' */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_paramter.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_paramter.ets index ab6be8fcab6e4ee1f5380ca84e87f214399db112..9e6faafbe0955c7fe3ed9eeb4ce616870c9db287 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/invalid_paramter.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_paramter.ets @@ -35,6 +35,3 @@ function main() { /* @@? 27:34 Error TypeError: overloaded name must refer to an accessible method. */ /* @@? 27:40 Error TypeError: overloaded name must refer to an accessible method. */ -/* @@? 32:5 Error TypeError: No matching call signature for foo111(A, A) */ -/* @@? 33:5 Error TypeError: No matching call signature for foo111(A, A, A) */ - diff --git a/ets2panda/test/ast/compiler/ets/first_match/modifier_static.ets b/ets2panda/test/ast/compiler/ets/first_match/modifier_static.ets index 216411ca48f5cc376a44c73b54b209a23cd02a59..28ab388f03bf34d17247229e6183ef07e8f07fa6 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/modifier_static.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/modifier_static.ets @@ -26,4 +26,6 @@ class Base2 { } /* @@@ label1 Error TypeError: Overload alias and overloaded method name must have exactly the same modifiers (static, async). */ +/* @@@ label1 Error TypeError: Static property 'fooNumber' must be accessed through it's class 'Base1' */ /* @@@ label2 Error TypeError: Overload alias and overloaded method name must have exactly the same modifiers (static, async). */ +/* @@@ label2 Error TypeError: Property 'fooString' must be accessed through 'this' */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/namespace.ets b/ets2panda/test/ast/compiler/ets/first_match/namespace.ets new file mode 100644 index 0000000000000000000000000000000000000000..562555e43fd2f058a7686cb22849741a9e8b7c6c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/namespace.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 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. + */ + +namespace NS { + function foo1(a: number) { + console.log("invoke foo1"); + } + + function foo2(a: string) { + console.log("invoke foo2"); + } + + export overload overloadfoo{ foo1, foo2 } + + export function foo3(a: number) { + console.log("invoke foo1"); + } + + function foo4(a: string) { + console.log("invoke foo2"); + } + + export overload overloadfoo2{ foo3, foo4 } + + export function foo5(a: number) { + console.log("invoke foo1"); + } + + function foo6(a: string) { + console.log("invoke foo2"); + } + + overload overloadfoo3{ foo5, foo6 } +} + +function main(){ + NS.foo1(1); + NS.foo2("abc"); + NS.foo3(1); + NS.foo4("abc"); + + NS.overloadfoo(1); + NS.overloadfoo("abc"); + + NS.overloadfoo2(1); + NS.overloadfoo2("abc"); + + NS.overloadfoo3(1); + NS.overloadfoo3("abc"); +} + +/* @@? 49:8 Error TypeError: 'foo1' is not exported in 'NS' */ +/* @@? 50:8 Error TypeError: 'foo2' is not exported in 'NS' */ +/* @@? 52:8 Error TypeError: 'foo4' is not exported in 'NS' */ +/* @@? 54:5 Error TypeError: 'foo1' is not exported in 'NS' */ +/* @@? 55:5 Error TypeError: 'foo2' is not exported in 'NS' */ +/* @@? 58:5 Error TypeError: 'foo4' is not exported in 'NS' */ +/* @@? 60:8 Error TypeError: 'overloadfoo3' is not exported in 'NS' */ +/* @@? 61:5 Error TypeError: 'foo6' is not exported in 'NS' */ +/* @@? 61:8 Error TypeError: 'overloadfoo3' is not exported in 'NS' */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/same_name.ets b/ets2panda/test/ast/compiler/ets/first_match/same_name.ets new file mode 100644 index 0000000000000000000000000000000000000000..22a1f98fa777f615d63f25ca9ba53a77e5afcc65 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/same_name.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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. + */ + +class C{ + foo(n:number){} + fooString(n:string){} + fooBoolean(n:boolean){} + + overload foo{foo,fooString,fooBoolean} +} + +class D{ + foo(n:number){} + fooString(n:string){} + fooBoolean(n:boolean){} + + overload foo{fooString,fooBoolean} +} + +/* @@? 29:5 Error TypeError: Method with the same name as overload declaration 'foo', overloadlist must list this medhod. */ diff --git a/ets2panda/test/ast/compiler/ets/function_namespace.ets b/ets2panda/test/ast/compiler/ets/function_namespace.ets new file mode 100644 index 0000000000000000000000000000000000000000..218177cc0576f25a40a0bc47a2be2213941a7d5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/function_namespace.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +function main () { +export namespace taskpool { + function taskfinished(task:Task) : boolean {} + +/* @@? 17:1 Error SyntaxError: Unexpected token 'export'. */ +/* @@? 17:8 Error SyntaxError: Namespace is allowed only at the top level or inside a namespace. */ +/* @@? 18:32 Error TypeError: Cannot find type 'Task'. */ +/* @@? 25:1 Error SyntaxError: Unexpected token. */ +/* @@? 25:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/compiler/ets/function_property.ets b/ets2panda/test/ast/compiler/ets/function_property.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0ca9949621a5f30e7c3afb54435133470626f1d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/function_property.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +function readImage(path: string) { } + readImage./* @@ label */sync = (path: string) => { + let contents = 1; + return contents; +} + +/* @@@ label Error TypeError: Property 'sync' does not exist on type 'Function' */ diff --git a/ets2panda/test/ast/compiler/ets/function_signature.ets b/ets2panda/test/ast/compiler/ets/function_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a516601825d7ffa8052117ce023a471493a9ce0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/function_signature.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ + +final class TypeCreateCtx { + internal static native getObjectArrayForCCtor(ctxPtr: long): FixedArray must have only one type parameter. */ +/* @@? 17:88 Error SyntaxError: Unexpected token, expected '>'. */ +/* @@? 17:88 Error SyntaxError: Unexpected token '>'. */ +/* @@? 17:97 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:120 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:138 Error TypeError: Cannot find type 'RuntimeTypeDescriptor'. */ diff --git a/ets2panda/test/ast/compiler/ets/fuzz_invalid_method.ets b/ets2panda/test/ast/compiler/ets/fuzz_invalid_method.ets new file mode 100644 index 0000000000000000000000000000000000000000..c85cff638a433b70fc6ea49c2c22a3176c708d76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/fuzz_invalid_method.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +function foo(this:A, p: T): T { + return this.data; +} + +class A { + data: T + goo + return this./* @@ label */classVal; + + (): T { + return foo(this, this.data); + } + +} + +/* @@? 22:8 Error SyntaxError: Field type annotation expected. */ +/* @@? 23:9 Error SyntaxError: Unexpected token 'return'. */ +/* @@? 23:16 Error SyntaxError: Unexpected token 'this'. */ +/* @@? 23:20 Error SyntaxError: Unexpected token '.'. */ +/* @@? 23:43 Error SyntaxError: Field type annotation expected. */ +/* @@? 25:5 Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/decl/eitest_import.d.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/decl/eitest_import.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..73a59d89fb13760d47857b2eb767f7192ec304ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/decl/eitest_import.d.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export declare namespace ns{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_import.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_import.ets new file mode 100644 index 0000000000000000000000000000000000000000..f83c0ec334719e43a769d0e14d8cf8eed7443634 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_import.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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. + */ + +export namespace ns{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_test.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9140ddbb0eaf8b656111908be89f967f70ea08ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_dup_import/eitest_test.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 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 {ns} from "./decl/eitest_import" +import {ns} from "./eitest_import" diff --git a/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.ets b/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.ets index c02f3a526ae875adb5d1ec2014619b77318671c5..1bcecf5a368b19c18e591af97df0c7138912a6c6 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.ets +++ b/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.ets @@ -58,11 +58,6 @@ export default function TestFuncToo(): void {} /*-----------------*/ /* @@? 16:10 Error SyntaxError: Cannot find name 'foo' to export. */ -/* @@? 27:14 Error SyntaxError: The given name 'foo2' is already used in another export. */ -/* @@? 27:27 Error SyntaxError: The given name 'foo2' is already used in another export. */ -/* @@? 33:11 Error SyntaxError: Cannot export 'foo3', it was already exported. */ -/* @@? 39:19 Error SyntaxError: Cannot export 'A', it was already exported. */ -/* @@? 46:14 Error SyntaxError: The given name 'MyI' is already used in another export. */ -/* @@? 46:14 Error SyntaxError: Cannot export 'MyI', it was already exported. */ +/* @@? 27:14 Error SyntaxError: Cannot export two different names with the same export alias name 'foo2'. */ /* @@? 56:16 Error TypeError: Only one default export is allowed in a module */ /* @@? 57:16 Error TypeError: Only one default export is allowed in a module */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/import_within_scope/scope_import_1.ets b/ets2panda/test/ast/compiler/ets/import_tests/import_within_scope/scope_import_1.ets index f6843e6780a276d26096a0d9f027689546df13a9..e7628a6a7050e85f4cba2a350b55735ecfc3e17e 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/import_within_scope/scope_import_1.ets +++ b/ets2panda/test/ast/compiler/ets/import_tests/import_within_scope/scope_import_1.ets @@ -18,4 +18,3 @@ namespace ns { } /* @@? 17:5 Error SyntaxError: Import declarations can only be used on the top level and before any other declaration, top level statement or directive. */ -/* @@? 17:12 Error TypeError: Variable 'nsi' has already been declared. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_1.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..3262d1a8397c9f94e46088aded27755baab15a52 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_1.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +export function foo(): void {} +export class A {} + +export { + foo as f1, + foo as f2, + A as a1, + A as a2 +} diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_2.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..54f88f12e3d075c93af321b165798e14331e755c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/export_type_several_times_2.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +function foo(): void {} +class A {} +let a = new A() + +export { + foo as f1, + foo as f2, + A as a1, + A as a2, + a as a3, + a as a4 +} diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_1.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3d2d5d4dce9f50757031609c6b892db8e539ee0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_1.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 { foo, f1, f2, A, a1, a2 } from "./export_type_several_times_1.ets" + +foo() +f1() +f2() +let c: A = new A() +let c1: A = new a1() +let c2: A = new a2() \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_2.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..91be1a73dbe8f87fd4b7b6696793289ce2f3f1bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_2.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 { f1, f2, a1, a2, a3, a4 } from "./export_type_several_times_2.ets" + +f1() +f2() +let c1: a1 = new a1() +let c2: a2 = new a2() +c1 = a3 +c2 = a4 \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_3.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..fec071802f9ed657b099cc121f7fced934488fd2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/import_same_type_form_alias_3.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 { foo, f1, f2, A, a1, a2 } from "./export_type_several_times_2.ets" + +f1() +f2() +let c1: a1 = new a1() +let c2: a2 = new a2() + +/* @@? 16:10 Error TypeError: Cannot find imported element 'foo' */ +/* @@? 16:23 Error TypeError: Cannot find imported element 'A' */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.ets index 453e606be33f02190dd29f0fd3abf2417c1936cf..bddda705c6dc2175b3fe368d4a3614e59d69c395 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.ets +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.ets @@ -16,7 +16,5 @@ export function foo(): void {} export { - foo as /* @@ label */bar + foo as bar } - -/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.ets b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.ets index b5eeab80f63d56146b1a930950285600f5b22ed5..a75a5dbac45bf1d154c2f08e209dc9db626f0e2e 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.ets +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.ets @@ -16,7 +16,5 @@ export default function foo(): void {} export { - foo as /* @@ label */bar + foo as bar } - -/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/infinityNarrowing.ets b/ets2panda/test/ast/compiler/ets/infinityNarrowing.ets index d885bc01afba2c67e281e33d493475b132b3f172..ceb44b333e6396435d9bc13e07403144c1e8010f 100644 --- a/ets2panda/test/ast/compiler/ets/infinityNarrowing.ets +++ b/ets2panda/test/ast/compiler/ets/infinityNarrowing.ets @@ -20,6 +20,6 @@ export const shortInf: short = /* @@ label1 */1.0 / 0.0 /* @@@ label Error TypeError: Type 'Double' cannot be assigned to type 'Byte' */ /* @@@ label1 Error TypeError: Type 'Double' cannot be assigned to type 'Short' */ /* @@@ label2 Error TypeError: Type 'Double' cannot be assigned to type 'Float' */ -/* @@@ label2 Error TypeError: Floating-point value cannot be converted */ +/* @@@ label2 Error TypeError: Value is out of range */ /* @@@ label1 Error TypeError: Floating-point value cannot be converted */ /* @@@ label Error TypeError: Floating-point value cannot be converted */ diff --git a/ets2panda/test/ast/compiler/ets/initializer_block_namesapce04.ets b/ets2panda/test/ast/compiler/ets/initializer_block_namesapce04.ets new file mode 100644 index 0000000000000000000000000000000000000000..630cd8cdfcbf54c2ed70e538bf17b5be3ae95718 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/initializer_block_namesapce04.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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. + */ + +export namespace xml { + static a: number = 1; + + static { + } + + static { + } +} + +/* @@? 17:3 Error SyntaxError: Unexpected token 'static'. */ +/* @@? 17:10 Error SyntaxError: Unexpected token 'a'. */ +/* @@? 17:13 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:13 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 20:3 Error SyntaxError: Only one static block is allowed in one namespace or class. */ diff --git a/ets2panda/test/ast/compiler/ets/interface-constructor-signatures.ets b/ets2panda/test/ast/compiler/ets/interface-constructor-signatures.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d2fef2044422f716fa5e9d5d606f9ae3f04f37f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface-constructor-signatures.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +//arkts-no-ctor-signatures-iface + +interface I { + new (s: string): I +} + +function fn(i: I) { + return new i("hello") +} + +/* @@? 19:5 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 19:5 Error SyntaxError: Constructor signatures are not supported in interfaces, use methods instead! */ +/* @@? 19:10 Error TypeError: Cannot find type 's'. */ +/* @@? 19:11 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 19:11 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 19:19 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 19:20 Error SyntaxError: Invalid Type. */ +/* @@? 19:20 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 19:20 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 20:1 Error SyntaxError: Invalid Type. */ +/* @@? 23:16 Error TypeError: Cannot find type 'i'. */ diff --git a/ets2panda/test/ast/compiler/ets/interface_class_implement.ets b/ets2panda/test/ast/compiler/ets/interface_class_implement.ets new file mode 100644 index 0000000000000000000000000000000000000000..41591ce4089dd86e86832407cbfa58594684c120 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface_class_implement.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023-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. + */ + +interface AA { + X :int; +} +class A implements AA{ + static X :int=1; +} + +/* @@? 19:22 Error TypeError: A is not abstract and does not implement getter for X property in AA */ diff --git a/ets2panda/test/ast/compiler/ets/interface_property_scope.ets b/ets2panda/test/ast/compiler/ets/interface_property_scope.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c8647af1e83986f2993a93f6fd6f0e77c54dc70 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface_property_scope.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +@Anno +interface itf0{ + @Anno(()=> {testList.subArrayList(0, 1)}, exceptionCherckEmptyContainer) +} + +/* @@? 16:2 Error TypeError: Cannot find type 'Anno'. */ +/* @@? 18:6 Error TypeError: Cannot find type 'Anno'. */ +/* @@? 18:11 Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ +/* @@? 18:45 Error SyntaxError: Expected ')', got ','. */ +/* @@? 18:45 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 18:76 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 19:1 Error SyntaxError: Invalid Type. */ diff --git a/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets b/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets new file mode 100644 index 0000000000000000000000000000000000000000..14f2dbbba75c0962f18f779e8cfb20e5f98ccfb7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +class A{ + private \\\\foo(){} +} + +/* @@? 17:13 Error SyntaxError: Invalid character. */ +/* @@? 17:13 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:14 Error SyntaxError: Invalid character. */ +/* @@? 17:14 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:15 Error SyntaxError: Invalid character. */ +/* @@? 17:15 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:16 Error SyntaxError: Invalid character. */ +/* @@? 17:16 Error SyntaxError: Access modifier must precede field and method modifiers. */ diff --git a/ets2panda/test/ast/compiler/ets/invalid_param_in_constructor.ets b/ets2panda/test/ast/compiler/ets/invalid_param_in_constructor.ets new file mode 100644 index 0000000000000000000000000000000000000000..c24f12ba1649dff7a22b5774705262a5d6537897 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_param_in_constructor.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +class A { + constructor(this.b) { + } +} + +/* @@? 17:16 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:21 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ +/* @@? 17:21 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:21 Error SyntaxError: Unexpected token '.'. */ +/* @@? 17:23 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:23 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:25 Error SyntaxError: Unexpected token '{'. */ +/* @@? 19:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/invalid_param_pack.ets b/ets2panda/test/ast/compiler/ets/invalid_param_pack.ets new file mode 100644 index 0000000000000000000000000000000000000000..47fe5706e0c2d9e4fbbf985b201d83bbb2a10a1d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_param_pack.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 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. + */ + +class Base { + constructor(...args) { + + } +} + +class Derived extends Base{ + constructor(){ + super(3); + } +} + +class Base2 { + my_func(...args) { + + } +} + +class Derived2 extends Base2{ + constructor(){ + my_func(3); + } +} + +/* @@? 17:17 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 17:24 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 24:3 Error TypeError: No matching call signature */ +/* @@? 29:13 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 29:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 36:3 Error TypeError: Unresolved reference my_func */ diff --git a/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets b/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets index 2f2807b6f56d84b3683ef2e7c6253d5f1baa1ae7..5edd48126e4922f1439ab8a08ec0c2294b004999 100644 --- a/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets +++ b/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets @@ -23,46 +23,41 @@ class ObservableImpl extends Observable { type NestedKey = T[K] extends object ? keyof T[K] : never; -/* @@? 16:24 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 16:24 Error SyntaxError: Invalid Type. */ -/* @@? 16:26 Error SyntaxError: Unexpected token ','. */ -/* @@? 16:28 Error SyntaxError: Unexpected token 'k'. */ -/* @@? 16:31 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 16:31 Error TypeError: Unresolved reference keyof */ -/* @@? 16:42 Error SyntaxError: Invalid Type. */ -/* @@? 16:42 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 16:45 Error SyntaxError: Unexpected token ')'. */ -/* @@? 16:47 Error SyntaxError: Unexpected token '{'. */ +/* @@? 16:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 16:42 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 16:45 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ /* @@? 18:33 Error TypeError: Cannot find type 'Observable'. */ /* @@? 18:33 Error TypeError: The super type of 'ObservableImpl' class is not extensible. */ -/* @@? 20:9 Error TypeError: Type 'ObservableImpl' is generic but type argument were not provided. */ -/* @@? 20:24 Error SyntaxError: Invalid Type. */ -/* @@? 20:24 Error SyntaxError: Unexpected token, expected '>'. */ -/* @@? 20:27 Error TypeError: Unresolved reference K */ -/* @@? 20:29 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 20:29 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 20:29 Error TypeError: Unresolved reference in */ -/* @@? 20:32 Error SyntaxError: Unexpected token 'keyof'. */ -/* @@? 20:32 Error TypeError: This expression is not callable. */ -/* @@? 20:41 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 20:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 20:27 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 20:31 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:41 Error SyntaxError: Unexpected token '&'. */ +/* @@? 20:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 20:41 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 20:44 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:44 Error SyntaxError: Field type annotation expected. */ /* @@? 20:45 Error SyntaxError: Unexpected token ']'. */ /* @@? 20:46 Error SyntaxError: Unexpected token ':'. */ -/* @@? 20:46 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 20:60 Error SyntaxError: Unexpected token '>'. */ -/* @@? 20:61 Error SyntaxError: Unexpected token '('. */ -/* @@? 20:62 Error SyntaxError: Unexpected token ')'. */ -/* @@? 22:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 20:48 Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ +/* @@? 20:51 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 20:51 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 20:51 Error SyntaxError: Unexpected token '&'. */ +/* @@? 20:54 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:54 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:56 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 20:57 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:36 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 24:42 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:42 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 24:42 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:43 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:45 Error SyntaxError: Unexpected token 'extends'. */ /* @@? 24:53 Error SyntaxError: Unexpected token 'object'. */ /* @@? 24:53 Error TypeError: Type name 'object' used in the wrong context */ +/* @@? 24:62 Error TypeError: Unresolved reference keyof */ /* @@? 24:68 Error SyntaxError: Unexpected token. */ /* @@? 24:68 Error TypeError: Unresolved reference T */ /* @@? 24:68 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 24:70 Error SyntaxError: Unexpected token, expected ']'. */ /* @@? 24:73 Error SyntaxError: Unexpected token ':'. */ -/* @@? 24:75 Error SyntaxError: Unexpected token 'never'. */ /* @@? 24:75 Error SyntaxError: Class cannot be used as object. */ +/* @@? 24:75 Error SyntaxError: Unexpected token 'never'. */ diff --git a/ets2panda/test/ast/compiler/ets/method_call_confilict_in_union_types.ets b/ets2panda/test/ast/compiler/ets/method_call_confilict_in_union_types.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0a65edf47dc84a2349095ad711a68459f59cfa2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/method_call_confilict_in_union_types.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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. + */ + +class A { + foo under the licenses { } + foo(v: int): void {} +} + +class B { + foo(v: string): void { } +} + +function foo(x: A | B) { + x.foo("123") +} + +/* @@? 17:8 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:14 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:18 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:27 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:28 Error SyntaxError: Unexpected token '{'. */ +/* @@? 18:9 Error TypeError: Unresolved reference v */ +/* @@? 18:10 Error SyntaxError: Unexpected token ':'. */ +/* @@? 18:10 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 18:12 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 18:15 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:16 Error SyntaxError: Unexpected token ':'. */ +/* @@? 18:18 Error SyntaxError: Unexpected token 'void'. */ +/* @@? 18:23 Error SyntaxError: Unexpected token '{'. */ +/* @@? 19:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/namespaceExport_neg.ets b/ets2panda/test/ast/compiler/ets/namespaceExport_neg.ets index e742a4cdc820877914a2ce0aaade1f4ab7910b05..fb3ea3bbd88e3a272e2f97495859f8006f8b68a8 100644 --- a/ets2panda/test/ast/compiler/ets/namespaceExport_neg.ets +++ b/ets2panda/test/ast/compiler/ets/namespaceExport_neg.ets @@ -30,5 +30,3 @@ declare namespace A { } export default A -/* @@? 27:20 Error SyntaxError: Cannot export 'A', it was already exported. */ - diff --git a/ets2panda/test/ast/compiler/ets/negative_optional_constructor.ets b/ets2panda/test/ast/compiler/ets/negative_optional_constructor.ets new file mode 100644 index 0000000000000000000000000000000000000000..f38f0c8d9deab4aa9c5463a0313c20dbb497607f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/negative_optional_constructor.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +class A { + constructor(buffer: ArrayBuffer, byteOffset?: number, length?V number); + +/* @@? 17:3 Error TypeError: No matching call signature for constructor */ +/* @@? 17:14 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:64 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 17:64 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:65 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:66 Error SyntaxError: number is a predefined type, cannot be used as an identifier */ +/* @@? 17:72 Error SyntaxError: Unexpected token ')'. */ +/* @@? 28:1 Error SyntaxError: Expected '}', got 'end of stream'. */ + diff --git a/ets2panda/test/ast/compiler/ets/negative_typo_1.ets b/ets2panda/test/ast/compiler/ets/negative_typo_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..946b6b4974729224417dbc0a781eda7c5d92fd7f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/negative_typo_1.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +@interface Anno { + e: @ring[][] = [["a", (c +ue)]] +} + +/* @@? 17:3 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */ +/* @@? 17:13 Error TypeError: Cannot find type 'ring'. */ +/* @@? 17:18 Error TypeError: Invalid value for annotation field, expected a constant literal. */ +/* @@? 17:19 Error TypeError: Initializer has 2 elements, but tuple requires 0 */ diff --git a/ets2panda/test/ast/compiler/ets/no_match_sig.ets b/ets2panda/test/ast/compiler/ets/no_match_sig.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac70bf305df8d8abcd844b96e070bed282991a00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/no_match_sig.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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. + */ + +function main() { + foo() +} + +function foo1(a: number, b: number) { + return "aaaa" +} + +function foo2(a: number, ...args: number[]) { + return "bbbb" +} + +function foo3(a: number, b: number, c?: number) { + return "cccc" +} + +overload foo{ foo1, foo2, foo3 } + +/* @@? 17:5 Error TypeError: No matching call signature for foo() */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/nonNullableKeyword.ets b/ets2panda/test/ast/compiler/ets/nonNullableKeyword.ets new file mode 100644 index 0000000000000000000000000000000000000000..d58ca014b280e98992adbbea042e4c85c21be64f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/nonNullableKeyword.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + + +class A{ + NonNullable = 1; +} + +class B{ + static NonNullable(param:T){} +} + +B.NonNullable(new Object()) + +class NonNullable{} + +/* @@? 27:7 Error SyntaxError: Cannot be used as user-defined type. */ diff --git a/ets2panda/test/ast/compiler/ets/nonNullishType.ets b/ets2panda/test/ast/compiler/ets/nonNullishType.ets index 1d1dcdf5c2b9a56ac81e61e6ecd01231940995fb..bbc688cdf6a24385c9699c278a710e2af00f08aa 100644 --- a/ets2panda/test/ast/compiler/ets/nonNullishType.ets +++ b/ets2panda/test/ast/compiler/ets/nonNullishType.ets @@ -13,8 +13,23 @@ * limitations under the License. */ -class A { - foo(a: T):T!{ - return a!; +class NonNullableGenericParam> { + foo(a: T):NonNullable{ + return a; } } + +class A{} + +type TesterUnionType = Int | A | null | undefined +type NonNullableTesterUnionType = NonNullable + +function main(){ + let a: NonNullable; + a = new A(); + let b: NonNullable> = new Object(); +} + +function foo(param:NonNullable){ + let a: Object = param +} diff --git a/ets2panda/test/ast/compiler/ets/nonNullishType_n.ets b/ets2panda/test/ast/compiler/ets/nonNullishType_n_1.ets similarity index 50% rename from ets2panda/test/ast/compiler/ets/nonNullishType_n.ets rename to ets2panda/test/ast/compiler/ets/nonNullishType_n_1.ets index 825f28300e385113ea8ed73a77a9ac6e9e07c158..409f8580b8f15020283442f61ebee9e9579509d0 100644 --- a/ets2panda/test/ast/compiler/ets/nonNullishType_n.ets +++ b/ets2panda/test/ast/compiler/ets/nonNullishType_n_1.ets @@ -13,18 +13,10 @@ * limitations under the License. */ -class Test{} - class A { - foo(a: T):Test!{ - let b : Object! = new Object(); - let c : (int)! = 0; - return a!; + foo(a: T):NonNullable{ + return a; } } -/* @@? 19:13 Error TypeError: Only type parameters can be used as a nonnullish type */ -/* @@? 20:13 Error TypeError: Only type parameters can be used as a nonnullish type */ -/* @@? 21:13 Error TypeError: Only type parameters can be used as a nonnullish type */ -/* @@? 22:12 Error TypeError: Type 'NonNullable' is not compatible with the enclosing method's return type 'Test' */ -/* @@? 22:12 Error TypeError: Type 'NonNullable' is not compatible with the enclosing method's return type 'Test' */ +/* @@? 18:12 Error TypeError: Type 'T' is not compatible with the enclosing method's return type 'NonNullable' */ diff --git a/ets2panda/test/ast/compiler/ets/nonNullishType_n_2.ets b/ets2panda/test/ast/compiler/ets/nonNullishType_n_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0f02874ff3793918c44852e41ab420097031032 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/nonNullishType_n_2.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +class A {} + +type unionType = Int | A | null | undefined + +function main(){ + let a: NonNullable = new A(); + a = new Int(); + a = null; + a = undefined; +} + +/* @@? 23:7 Error TypeError: Type 'null' cannot be assigned to type 'Int|A' */ +/* @@? 24:7 Error TypeError: Type 'undefined' cannot be assigned to type 'Int|A' */ + diff --git a/ets2panda/test/ast/compiler/ets/nonNullishType_n_3.ets b/ets2panda/test/ast/compiler/ets/nonNullishType_n_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ac195de816047fc3b954cdaabe265bcf4dba36e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/nonNullishType_n_3.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ + +type unionType = Object | null + +function main(){ + let a: NonNullable unionType; + a = null; +} + +/* @@? 19:22 Error SyntaxError: Expected '<', got 'identification literal'. */ +/* @@? 19:31 Error SyntaxError: Expected '>', got ';'. */ +/* @@? 20:7 Error TypeError: Type 'null' cannot be assigned to type 'Object' */ diff --git a/ets2panda/test/ast/compiler/ets/null_pointer_error.ets b/ets2panda/test/ast/compiler/ets/null_pointer_error.ets new file mode 100644 index 0000000000000000000000000000000000000000..289f308742ccaed4061906c17c10d7767d784317 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/null_pointer_error.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +export class AbstractDaoSession{ + public async queryRaw(entityClass: T,where: string, ...selectionArgs: dataRdb.ValueType[]):Promise{ + let paramUse = Type.of(entityClass) + let dao:AbstractDao = this.getDao(DbUtils.getEntityClassName(paramUse)); + return await dao.queryRaw(where, ...selectionArgs); + } +} + +/* @@? 1:3 Error TypeError: Cannot find type 'dataRdb'. */ +/* @@? 1:3 Error TypeError: 'ValueType' type does not exist. */ +/* @@? 17:62 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 19:17 Error TypeError: Cannot find type 'AbstractDao'. */ diff --git a/ets2panda/test/ast/compiler/ets/overload/overload_duplicate_overload_name_1.ets b/ets2panda/test/ast/compiler/ets/overload/overload_duplicate_overload_name_1.ets index 95eddfc644cd08ca50e6576711bb5a441f58b58e..d5a1d45da91831f60376e7d0956a1d2e3f3607a0 100644 --- a/ets2panda/test/ast/compiler/ets/overload/overload_duplicate_overload_name_1.ets +++ b/ets2panda/test/ast/compiler/ets/overload/overload_duplicate_overload_name_1.ets @@ -16,11 +16,10 @@ class Base { foo/* @@ label1 */(a: number) : string foo(a: string) : string - overload /* @@ label2 */foo {/* @@ label3 */foo, /* @@ label4 */foo} + overload foo {/* @@ label2 */foo, /* @@ label3 */foo} } /* @@@ label1 Error TypeError: Only abstract or native methods can't have body. */ -/* @@@ label2 Error TypeError: Variable 'foo' has already been declared. */ -/* @@@ label3 Error TypeError: overloaded name must refer to an accessible method. */ -/* @@@ label4 Error TypeError: Duplicate overloaded method. */ -/* @@@ label4 Error TypeError: overloaded name must refer to an accessible method. */ +/* @@@ label2 Error TypeError: The overloaded name 'foo' can't refer to a function with overload signatures. */ +/* @@@ label3 Error TypeError: Duplicate overloaded method. */ +/* @@@ label3 Error TypeError: The overloaded name 'foo' can't refer to a function with overload signatures. */ diff --git a/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_method_exported.ets b/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_method_exported.ets index b5511a3f9e899f24cd54486d6aab6534793f1eb8..1510e3ff407d418b93f7ffe436fd07df66385cfd 100644 --- a/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_method_exported.ets +++ b/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_method_exported.ets @@ -15,6 +15,4 @@ export function foo1() {} function foo2() {} -export overload foo {foo1, /* @@ label1 */foo2} - -/* @@@ label1 Error TypeError: Overload alias is exported, then overload functions must also be exported. */ +export overload foo {foo1, foo2} diff --git a/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_name_used_as_value_2.ets b/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_name_used_as_value_2.ets index 19db7f31f9cfe295d39ea17eac7873be5ec35d34..79401623d249b1af4deaf68041bac458edf77bdf 100644 --- a/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_name_used_as_value_2.ets +++ b/ets2panda/test/ast/compiler/ets/overload/overload_overloaded_name_used_as_value_2.ets @@ -13,15 +13,9 @@ * limitations under the License. */ - - function foo1() {} function foo2() {} overload foo{foo1, foo2} let OL = /* @@ label */foo; -/* @@@ label Error TypeError: Identifier 'foo' is used in wrong context. */ /* @@@ label Error TypeError: Overloaded method is used as value */ -/* @@@ label Error TypeError: Identifier 'foo' is used in wrong context. */ -/* @@@ label Error TypeError: Overloaded method is used as value */ - diff --git a/ets2panda/test/ast/compiler/ets/override15.ets b/ets2panda/test/ast/compiler/ets/override15.ets index 22632b2eefe39396421bc6e471e28c352943348a..2afb8940d3f7ff872881b3c2ffc60be47684b524 100644 --- a/ets2panda/test/ast/compiler/ets/override15.ets +++ b/ets2panda/test/ast/compiler/ets/override15.ets @@ -21,5 +21,5 @@ interface I2 extends I { fn(): float; } -/* @@? 21:5 Error TypeError: fn(): Float in I2 cannot override fn(): Int in I because overriding return type is not compatible with the other return type. */ -/* @@? 21:5 Error TypeError: Method fn(): Float in I2 not overriding any method */ +/* @@? 21:3 Error TypeError: fn(): Float in I2 cannot override fn(): Int in I because overriding return type is not compatible with the other return type. */ +/* @@? 21:3 Error TypeError: Method fn(): Float in I2 not overriding any method */ diff --git a/ets2panda/test/ast/compiler/ets/override3.ets b/ets2panda/test/ast/compiler/ets/override3.ets index 4031d36c0c90fcfbd6bf048a257250c9ab2888bd..96cdf17944ed5bf697ec2ac4054cd9d0b85b5ac5 100644 --- a/ets2panda/test/ast/compiler/ets/override3.ets +++ b/ets2panda/test/ast/compiler/ets/override3.ets @@ -17,5 +17,5 @@ interface I { toString(): int; } -/* @@? 17:11 Error TypeError: toString(): Int in I cannot override toString(): String in Object because overriding return type is not compatible with the other return type. */ -/* @@? 17:11 Error TypeError: Method toString(): Int in I not overriding any method */ +/* @@? 17:3 Error TypeError: toString(): Int in I cannot override toString(): String in Object because overriding return type is not compatible with the other return type. */ +/* @@? 17:3 Error TypeError: Method toString(): Int in I not overriding any method */ diff --git a/ets2panda/test/ast/compiler/ets/package_invalid_initializer/P3/P3.ets b/ets2panda/test/ast/compiler/ets/package_invalid_initializer/P3/P3.ets index 809e03282c8d1daf2580a62df3f0c732f27b23b3..3609cbb822433097e51adf6a68531a869e015874 100644 --- a/ets2panda/test/ast/compiler/ets/package_invalid_initializer/P3/P3.ets +++ b/ets2panda/test/ast/compiler/ets/package_invalid_initializer/P3/P3.ets @@ -47,8 +47,8 @@ static { /* @@? P3.ets:29:14 Error SyntaxError: Missing initialization for const package property */ /* @@? P3.ets:29:18 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? P3.ets:30:30 Error SyntaxError: Non-constant initializer of Package should be apply in Initializer Block. */ +/* @@? P3.ets:31:14 Error TypeError: Cannot reassign constant c_nn2 */ /* @@? P3.ets:32:6 Error SyntaxError: Non-constant initializer of Package should be apply in Initializer Block. */ /* @@? P3.ets:33:1 Error SyntaxError: Invalid package toplevel statement */ /* @@? P3.ets:34:1 Error SyntaxError: Invalid package toplevel statement */ -/* @@? P3.ets:36:5 Error TypeError: Invalid left-hand side of assignment expression */ /* @@? P3.ets:39:14 Error SyntaxError: Missing initialization for const package property */ diff --git a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/main_test.ets b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/main_test.ets index c0790ae4e613411c2095e420376f8d9cff46b878..9973e90217e072f4113e48d0fa682be2ddb01dc6 100644 --- a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/main_test.ets +++ b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/main_test.ets @@ -15,4 +15,4 @@ import {NS} from "./package" -/* @@? P2_01.ets:21:9 Error SyntaxError: Only one static block is allowed in one namespace or class. */ \ No newline at end of file +/* @@? P2_01.ets:22:5 Error SyntaxError: Only one static block is allowed in one namespace or class. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_01.ets b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_01.ets index bd3c4a657f6dffe284672e3feaae36f189d30da9..a61fb5e005e7ba1b10f593c7a0ec49d482673ad1 100644 --- a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_01.ets +++ b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_01.ets @@ -22,4 +22,4 @@ export namespace NS { } } -/* @@? P2_01.ets:21:9 Error SyntaxError: Only one static block is allowed in one namespace or class. */ +/* @@? P2_01.ets:22:5 Error SyntaxError: Only one static block is allowed in one namespace or class. */ diff --git a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_02.ets b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_02.ets index 2a88481c53ef9b343187034be105013c855851a9..8d0dd864534d22e2eeb5ea7783580aecb005f1f3 100644 --- a/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_02.ets +++ b/ets2panda/test/ast/compiler/ets/package_namespace_static_block_multi/package/P2_02.ets @@ -21,4 +21,4 @@ export namespace NS { } } -/* @@? P2_02.ets:20:9 Error SyntaxError: Only one static block is allowed in one namespace or class. */ +/* @@? P2_02.ets:21:5 Error SyntaxError: Only one static block is allowed in one namespace or class. */ diff --git a/ets2panda/test/ast/compiler/ets/parameter_anonymous_type.ets b/ets2panda/test/ast/compiler/ets/parameter_anonymous_type.ets index a84669385caa6a99f3234c8fb624f4be9c662e5a..39968154fee1957830420ef410bd854c23e857bf 100644 --- a/ets2panda/test/ast/compiler/ets/parameter_anonymous_type.ets +++ b/ets2panda/test/ast/compiler/ets/parameter_anonymous_type.ets @@ -20,4 +20,4 @@ const _innerFunc = (arg: { x: number } | undefined): number => { return arg.x; }; -/* @@? 16:26 Error SyntaxError: Invalid Type. */ +/* @@? 16:26 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ diff --git a/ets2panda/test/ast/compiler/ets/parser_import.ets b/ets2panda/test/ast/compiler/ets/parser_import.ets new file mode 100644 index 0000000000000000000000000000000000000000..3fb9464550bcc0d64c5aa909ff64063cd9c409e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/parser_import.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +let callbackc = (arrElem: JSValue) => { + import {a} from +} + +/* @@? 17:5 Error SyntaxError: Import declarations can only be used on the top level and before any other declaration, top level statement or directive. */ +/* @@? 18:1 Error SyntaxError: Unexpected token, expected string literal. */ +/* @@? 22:70 Error SyntaxError: Expected '}', got 'end of stream'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets b/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b6557074b07ccbedd8b296b0c99f794a80e98c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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. + */ + +function genericFunc(p: Partial): void { + if (p !== undefined) { + } +} +function main() { + genericFunc<{a: number, b: string}>({a: 1}) +} + +/* @@? 21:3 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ +/* @@? 21:15 Error TypeError: need to specify target type for class composite */ +/* @@? 21:38 Error TypeError: need to specify target type for class composite */ diff --git a/ets2panda/test/ast/compiler/ets/readonlyField.ets b/ets2panda/test/ast/compiler/ets/readonlyField.ets index 808ae692ee6df8f203cddae6d3f1fa9536ddfcfc..4b48970029505fe74164a27e30ec7937146c82fe 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyField.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyField.ets @@ -13,7 +13,7 @@ * limitations under the License. */ class ReadonlyData { - readonly /* @@ label */value: T; + readonly value: T; constructor(value: T) { this.value = value; } @@ -21,7 +21,7 @@ class ReadonlyData { function main(): void { let myData = new ReadonlyData("import data"); - myData.value = "new data"; + /* @@ label */myData.value = "new data"; } /* @@@ label Error TypeError: Cannot assign to a readonly variable value */ diff --git a/ets2panda/test/ast/compiler/ets/readonlyField_2.ets b/ets2panda/test/ast/compiler/ets/readonlyField_2.ets index 96451387facf12e946eceb951b435e1a530bd4d9..9dc39f7fa44be247318d885cf06cc13fc2b8ea0a 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyField_2.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyField_2.ets @@ -14,12 +14,12 @@ */ class ReadonlyPerson { - readonly /* @@ label */name: string; + readonly name: string; readonly age: number; } function updatePerson(person: ReadonlyPerson): ReadonlyPerson { - person.name = "Bob"; //CTE + /* @@ label */person.name = "Bob"; //CTE return person; } function main(): void { diff --git a/ets2panda/test/ast/compiler/ets/readonlyType_1.ets b/ets2panda/test/ast/compiler/ets/readonlyType_1.ets index 8a677d6521e06a57899f2117b5776990490dbb97..b2680473fc15c6ad0c57183fb2b8bed3f2396c2c 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyType_1.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyType_1.ets @@ -14,7 +14,7 @@ */ class A { - /* @@ label */fld: Number + fld: Number constructor (fld : Number) { this.fld = fld } @@ -22,9 +22,9 @@ class A { function foo(a0: A) { let a: Readonly = new A(2) - /* @@ label2 */a.fld = 5 + /* @@ label */a.fld = 5 } /* @@@ label Error TypeError: Cannot assign to a readonly variable fld */ -/* @@@ label2 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@@ label Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/ast/compiler/ets/readonlyType_2.ets b/ets2panda/test/ast/compiler/ets/readonlyType_2.ets index 17d1eaf99c29a370fbcc440273606bed37a10746..5685a9042ef15463186ccfd86e9a53e3c3199a9e 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyType_2.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyType_2.ets @@ -14,13 +14,13 @@ */ class A { - /* @@ label */fld: Number = 2 + fld: Number = 2 } function foo(a0: A) { let a: Readonly = {fld: 3} - /* @@ label2 */a.fld = 5 + /* @@ label */a.fld = 5 } /* @@@ label Error TypeError: Cannot assign to a readonly variable fld */ -/* @@@ label2 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@@ label Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/ast/compiler/ets/readonlyType_3.ets b/ets2panda/test/ast/compiler/ets/readonlyType_3.ets index 9c5e0a1b2d1a3bd2e3d5f1ac5ab95cde0cdd0bf9..7ef6007189723be2af27f5629dc3f96beeb8a05a 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyType_3.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyType_3.ets @@ -14,11 +14,11 @@ */ class A { - /* @@ label */fld: Number = 2 + fld: Number = 2 foo (a0: Readonly) { - /* @@ label2 */a0.fld = 5 + /* @@ label */a0.fld = 5 } } /* @@@ label Error TypeError: Cannot assign to a readonly variable fld */ -/* @@@ label2 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@@ label Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/ast/compiler/ets/readonlyType_4.ets b/ets2panda/test/ast/compiler/ets/readonlyType_4.ets index 82d154132b47ae32d209acffbfd80d41d9cbb49f..4d3bf9936efd7457877d54af9f0ce3af04dac227 100644 --- a/ets2panda/test/ast/compiler/ets/readonlyType_4.ets +++ b/ets2panda/test/ast/compiler/ets/readonlyType_4.ets @@ -14,7 +14,7 @@ */ class A { - /* @@ label */fld: Number = 2 + fld: Number = 2 foo (a0: A) { a0.fld = 5 } @@ -25,9 +25,9 @@ class B extends A {} class C extends B { fld: Number = 2 foo (a0: Readonly) { - /* @@ label2 */a0.fld = 6 + /* @@ label */a0.fld = 6 } } /* @@@ label Error TypeError: Cannot assign to a readonly variable fld */ -/* @@@ label2 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@@ label Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/ast/compiler/ets/readonly_array01.ets b/ets2panda/test/ast/compiler/ets/readonly_array01.ets index d377fa27f9c66e4041ebb53d2585c89e9f1e938b..35d50fac5059d4dbee3c79e8b97c152c816daded 100644 --- a/ets2panda/test/ast/compiler/ets/readonly_array01.ets +++ b/ets2panda/test/ast/compiler/ets/readonly_array01.ets @@ -14,10 +14,10 @@ */ function main() { - let v: readonly number[][] = [[1.0,2.0]] + let v = [[1.0,2.0]] as readonly number[][] // smart cast workaround v[0][0] = 3.0 // ok v[0] = [] // CTE } -/* @@? 19:5 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ - +/* @@? 19:5 Error TypeError: Object type doesn't have proper index access method. */ +/* @@? 19:12 Error TypeError: Can't resolve array type */ diff --git a/ets2panda/test/ast/compiler/ets/returnTypeAnnotation_typeParams_nullptr.ets b/ets2panda/test/ast/compiler/ets/returnTypeAnnotation_typeParams_nullptr.ets new file mode 100755 index 0000000000000000000000000000000000000000..6308a2528182ffca7f69fce93dbb8f1a8c72e2d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/returnTypeAnnotation_typeParams_nullptr.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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: * + * 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. + */ + +class Arr { + public mp(a: int): FixedArray<()> +} + +/* @@? 16:11 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 16:24 Error TypeError: FixedArray must have only one type parameter. */ +/* @@? 16:37 Error SyntaxError: Unexpected token, expected '=>'. */ +/* @@? 16:37 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 16:37 Error SyntaxError: Invalid Type. */ +/* @@? 16:37 Error SyntaxError: Unexpected token, expected '>'. */ +/* @@? 16:37 Error SyntaxError: Unexpected token '>'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/same_name_field_err.ets b/ets2panda/test/ast/compiler/ets/same_name_field_err.ets index 8c8f75dc32dc87b44c657e16073796c8834474a2..fdfa470be384a0a806dab24a940e14e528ea91e6 100644 --- a/ets2panda/test/ast/compiler/ets/same_name_field_err.ets +++ b/ets2panda/test/ast/compiler/ets/same_name_field_err.ets @@ -24,4 +24,3 @@ function main(): void { } /* @@? 19:12 Error TypeError: Variable 'a' has already been declared. */ -/* @@? 19:12 Error TypeError: Property 'a' must be accessed through 'this' */ diff --git a/ets2panda/test/ast/compiler/ets/spread_record.ets b/ets2panda/test/ast/compiler/ets/spread_record.ets index ec7aa3a9dc41272e5e078e7d845d45ffaddeb229..f9782ab9747c4499a218df40d74a3a8ebcc80400 100644 --- a/ets2panda/test/ast/compiler/ets/spread_record.ets +++ b/ets2panda/test/ast/compiler/ets/spread_record.ets @@ -20,15 +20,12 @@ let r3: Record = { ...r1, ...r2 } console.log(...r3) // crash - Issue #26773 -/* @@? 17:1 Error TypeError: Expected 0 arguments, got 1. */ +/* @@? 17:1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ /* @@? 17:1 Error TypeError: No matching call signature for log(...r1) */ -/* @@? 17:13 Error TypeError: Spread argument cannot be passed for ordinary parameter. */ +/* @@? 17:1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ /* @@? 17:13 Error TypeError: Type 'Record' is not compatible with rest parameter type 'Array' at index 1 */ /* @@? 17:13 Error TypeError: Spread expression can be applied only to array or tuple type, but 'Record' is provided */ -/* @@? 17:13 Error TypeError: Spread argument cannot be passed for ordinary parameter. */ /* @@? 20:1 Error TypeError: No matching call signature for log(...r3) */ -/* @@? 20:1 Error TypeError: Expected 0 arguments, got 1. */ -/* @@? 20:13 Error TypeError: Spread argument cannot be passed for ordinary parameter. */ +/* @@? 20:1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ /* @@? 20:13 Error TypeError: Type 'Record' is not compatible with rest parameter type 'Array' at index 1 */ /* @@? 20:13 Error TypeError: Spread expression can be applied only to array or tuple type, but 'Record' is provided */ -/* @@? 20:13 Error TypeError: Spread argument cannot be passed for ordinary parameter. */ diff --git a/ets2panda/test/ast/compiler/ets/subtype.ets b/ets2panda/test/ast/compiler/ets/subtype.ets new file mode 100644 index 0000000000000000000000000000000000000000..5207d81c18227c28b0b3fef250bc61fa73f5abca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/subtype.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 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. + */ + +interface Interface_1 {} +interface Interface_2 {} + +class GenericObject { + give(value: T) { + return value; + } +} + +interface Factory { + create(): T; +} + +class GenericObjectFactory implements Factory { + create(): GenericObject { + return new GenericObject(); + } +} + +function g(factory: Factory): T { + return factory.create(); +} + +const factory = new GenericObjectFactory(); +const obj = g(factory); +obj.give({}); + +/* @@? 19:58 Error TypeError: Type argument 'Interface_2' should be a subtype of 'Interface_1'-constraint */ diff --git a/ets2panda/test/ast/compiler/ets/switch_case_null_tstype.ets b/ets2panda/test/ast/compiler/ets/switch_case_null_tstype.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5cacaf668537b14bbfe830020f94752452ddf7d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/switch_case_null_tstype.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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. + */ + +let arg='2'; +let v null|int=null; +class A{} +switch (arg){ + case v: + break; + case A: + break; +} + +/* @@? 17:7 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 17:7 Error SyntaxError: Unexpected token 'null'. */ +/* @@? 17:7 Error TypeError: Bad operand type, the types of the operands must be numeric type. */ +/* @@? 17:12 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 22:5 Error TypeError: Constant expression required */ +/* @@? 22:10 Error SyntaxError: Class cannot be used as object. */ +/* @@? 22:10 Error TypeError: Switch case type 'A' is not comparable to discriminant type 'String' */ diff --git a/ets2panda/test/ast/compiler/ets/this_expr_invalid_call_in_annotation_decl.ets b/ets2panda/test/ast/compiler/ets/this_expr_invalid_call_in_annotation_decl.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff742c6bddad68f907eee6c43571c03d026d81ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/this_expr_invalid_call_in_annotation_decl.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +@interface Anno { + testBools: boolean[] = [ + this.barAttr = 0, + ] +} + +/* @@? 17:28 Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ diff --git a/ets2panda/test/ast/compiler/ets/try_catch_already_declared.ets b/ets2panda/test/ast/compiler/ets/try_catch_already_declared.ets new file mode 100644 index 0000000000000000000000000000000000000000..81a718b1216d20cff6c6eb00c6b894779ecc47d6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/try_catch_already_declared.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +try { +} catch (a) { + let a = 1 +} + +/* @@? 18:9 Error TypeError: Variable 'a' has already been declared. */ diff --git a/ets2panda/test/ast/compiler/ets/tuple_types_9_neg.ets b/ets2panda/test/ast/compiler/ets/tuple_types_9_neg.ets index b02458c7196ad10e56a4a88e2ad056426ea3e285..ea48bd251d88f0246ff63e8ff3fe23bb9b4410ea 100644 --- a/ets2panda/test/ast/compiler/ets/tuple_types_9_neg.ets +++ b/ets2panda/test/ast/compiler/ets/tuple_types_9_neg.ets @@ -24,4 +24,3 @@ function main(): void { /* @@? 18:29 Error SyntaxError: Unexpected token '...'. */ /* @@? 18:32 Error SyntaxError: Unexpected token 'Int'. */ /* @@? 18:37 Error SyntaxError: Unexpected token ']'. */ -/* @@@ label Error TypeError: Type '[Double, String, *ERROR_TYPE*]' cannot be assigned to type '[Double, String, Int]' */ diff --git a/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_01.ets b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_01.ets new file mode 100644 index 0000000000000000000000000000000000000000..976f1c71f6cdaf3aa8f97d3ada30bf5e0e532b3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_01.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +type ValueAlias = Record<"val", V>; + +declare function value(): ValueAlias; + + +/* @@@ label Error TypeError: Type argument 'U' should be a subtype of 'String'-constraint */ diff --git a/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_02.ets b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_02.ets new file mode 100644 index 0000000000000000000000000000000000000000..96cf4d03326b0bafb8935e69cb3d221657f63c8c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_02.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +type ValueAlias = Record<"val", V>; + +declare function value(): ValueAlias; + +/* @@ label */value(); + + +/* @@@ label Error TypeError: No matching call signature */ diff --git a/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_03.ets b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_03.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5d5d8815d23d6f9a844aca71ea07e7087ccd074 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_03.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +type ValueAlias = Record<"val", V>; + +declare function value(): ValueAlias; + +value(); diff --git a/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_04.ets b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_04.ets new file mode 100644 index 0000000000000000000000000000000000000000..7378bd24f9ea49436f55c00fad536ef825b814b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/typeAliasWithConstraint_04.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +type A = T; + +let v: A; + + +/* @@@ label1 Error TypeError: Type argument 'Int' should be a subtype of 'String'-constraint */ +/* @@@ label2 Error TypeError: Type argument 'String' should be a subtype of 'Numeric'-constraint */ diff --git a/ets2panda/test/ast/compiler/ets/type_alise_with_lambda.ets b/ets2panda/test/ast/compiler/ets/type_alise_with_lambda.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b39e198c9b2f0474894efc6606986117daa8b22 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_alise_with_lambda.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export type L T> + +/* @@? 16:26 Error TypeError: Cannot find type 'T'. */ +/* @@? 21:1 Error SyntaxError: Expected '=', got 'end of stream'. */ +/* @@? 21:1 Error SyntaxError: Invalid Type. */ diff --git a/ets2panda/test/ast/compiler/ets/type_error_processing/param_typeannotation_null.ets b/ets2panda/test/ast/compiler/ets/type_error_processing/param_typeannotation_null.ets new file mode 100644 index 0000000000000000000000000000000000000000..71e76536db95195f451ec2584e8ae947aa24a29d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_error_processing/param_typeannotation_null.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +interface inter { + get value(): Double; + set value(A = Int.MAX_VALUE + 1); +} + +function foo(i: Partial>): void {} + +/* @@? 18:17 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ diff --git a/ets2panda/test/ast/compiler/ets/type_error_processing/property_typeerror.ets b/ets2panda/test/ast/compiler/ets/type_error_processing/property_typeerror.ets new file mode 100644 index 0000000000000000000000000000000000000000..345a9e3ef7caa7a721626af9795859b8d9ecc564 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_error_processing/property_typeerror.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +class A { + set property(break) {} +} + +function foo (partial: Partial) {} + +/* @@? 17:15 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:16 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 17:16 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 17:16 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:16 Error SyntaxError: Unexpected token 'break'. */ +/* @@? 17:21 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:23 Error SyntaxError: Unexpected token '{'. */ +/* @@? 18:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/type_error_test.ets b/ets2panda/test/ast/compiler/ets/type_error_test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cbb33753e830d5f3662f40bf1d22372839d3ac50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_error_test.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +export class SHA1Hash{ + private _int32(data:Int32Array,offset?:int):void{ + offset=0 + swap32(data[offset ++] as int) + } +} +const swap32:(num:int)=>int = ((c:int):int =>c) + +/* @@? 19:16 Warning Warning: 'As' expression for cast is deprecated for numeric types. Use explicit conversion function Double.toInt(...) instead. */ diff --git a/ets2panda/test/ast/compiler/ets/type_error_test2.ets b/ets2panda/test/ast/compiler/ets/type_error_test2.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0f14ec6366e617b9d9e75ff87169d92d3e16279 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_error_test2.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +let f:(c:string, ...abe])=>void = (c:be ...abe])=>{} + +/* @@? 16:18 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 16:24 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 16:24 Error SyntaxError: Rest parameter must be the last formal parameter. */ +/* @@? 16:38 Error TypeError: Cannot find type 'be'. */ +/* @@? 16:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 16:41 Error SyntaxError: Expected '=>', got '...'. */ +/* @@? 16:41 Error SyntaxError: Unexpected token '...'. */ +/* @@? 16:44 Error SyntaxError: Unexpected token 'abe'. */ +/* @@? 16:44 Error TypeError: Unresolved reference abe */ +/* @@? 16:47 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:48 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:49 Error SyntaxError: Unexpected token '=>'. */ diff --git a/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets b/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e15bcbf7dada134279d2b9f12f5c685e0b3a4ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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. + */ + +let byteP: Promise = byteFunc() +let pthen = byteP.then((value ? Object): Object => { + return value + +}); +await byteP; + +/* @@? 16:30 Error TypeError: Unresolved reference byteFunc */ +/* @@? 17:41 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 17:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:41 Error SyntaxError: Expected '=>', got 'identification literal'. */ +/* @@? 17:41 Error SyntaxError: Class cannot be used as object. */ +/* @@? 17:48 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:50 Error SyntaxError: Unexpected token 'Object'. */ +/* @@? 17:50 Error TypeError: The type of parameter 'Object' cannot be inferred */ +/* @@? 18:12 Error TypeError: Unresolved reference value */ +/* @@? 20:2 Error SyntaxError: Unexpected token ')'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets b/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5bb53c7ebb55422acc3f0b24ff8b109b185e907 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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. + */ + +function foo(a?){} + +/* @@? 16:16 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/unionType_clone.ets b/ets2panda/test/ast/compiler/ets/unionType_clone.ets new file mode 100644 index 0000000000000000000000000000000000000000..1af439f0e8543de1bee657ea7694ae31acac4155 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unionType_clone.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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. + */ + +function castValueKoBoolean(value ?: boolect) { + if (value instanceof Sean) { + if (value === undefined) return; + + let innerValue = !value; +} : xml.XmlDyastValueToString(value: Object) { + if (value instanceof String) { + value += "Hello Smar/* + +/* @@? 16:38 Error TypeError: Cannot find type 'boolect'. */ +/* @@? 17:26 Error TypeError: Cannot find type 'Sean'. */ +/* @@? 21:3 Error SyntaxError: Unexpected token ':'. */ +/* @@? 21:5 Error SyntaxError: Unexpected token 'xml'. */ +/* @@? 21:5 Error TypeError: Unresolved reference xml */ +/* @@? 21:36 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 21:36 Error SyntaxError: Unexpected token ':'. */ +/* @@? 21:38 Error SyntaxError: Unexpected token 'Object'. */ +/* @@? 21:38 Error SyntaxError: Class cannot be used as object. */ +/* @@? 21:44 Error SyntaxError: Unexpected token ')'. */ +/* @@? 21:46 Error SyntaxError: Unexpected token '{'. */ +/* @@? 23:18 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 37:70 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/compiler/ets/union_field_access_2.ets b/ets2panda/test/ast/compiler/ets/union_field_access_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3810056329f128bf4653a78446cd05f6a3cd3c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/union_field_access_2.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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. + */ + +// ensure compiler doesn't crash when compiling invalid code. + +(a ? delete arguments==({: false, Float64Array: []}) : [ArrayBuffer[false]]) + +/* @@? 18:1 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 18:2 Error TypeError: Unresolved reference a */ +/* @@? 18:6 Error TypeError: Unresolved reference delete */ +/* @@? 18:13 Error SyntaxError: Unexpected token. */ +/* @@? 18:13 Error TypeError: Unresolved reference arguments */ +/* @@? 18:24 Error TypeError: need to specify target type for class composite */ +/* @@? 18:26 Error SyntaxError: Unexpected token. */ +/* @@? 18:28 Error SyntaxError: Unexpected token. */ +/* @@? 18:54 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 18:76 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/compiler/ets/union_overload_crash.ets b/ets2panda/test/ast/compiler/ets/union_overload_crash.ets new file mode 100644 index 0000000000000000000000000000000000000000..01d75715b7a7840938025bb0989de29ffe62b83d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/union_overload_crash.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +class A { + foo() {} + foo(a : number) {} +} + +type AVoidNumber = A | A + +let a = new A(); + +(a as AVoidNumber).foo !== undefined + +/* @@? 25:1 Error TypeError: Overloaded method is used as value */ diff --git a/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets b/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets new file mode 100644 index 0000000000000000000000000000000000000000..9347301cc3f96cac0dba997c2b30dd0fec9a5b9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +function foo>(record: Record>){ + +} + +foo({}) + +/* @@? 16:39 Error TypeError: Cannot find type 'A'. */ diff --git a/ets2panda/test/ast/compiler/ets/update_const.ets b/ets2panda/test/ast/compiler/ets/update_const.ets new file mode 100644 index 0000000000000000000000000000000000000000..15ffd430673492a7e6c6f970300e7698288ade34 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/update_const.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +function main(): void { + const c = 0; + /* @@ label */++c; +} + +/* @@@ label Error TypeError: Cannot assign to a constant variable c */ diff --git a/ets2panda/test/ast/compiler/ets/wrong_variable_binding.ets b/ets2panda/test/ast/compiler/ets/wrong_variable_binding.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9f2d161ac777d0a94186bbc33fbac1ace9ae92b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/wrong_variable_binding.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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. + */ + + +class C { + + public C; + + public C: "+v)"; + + public constructor() {} + + } + + class D extends C{} + +/* @@? 19:13 Error SyntaxError: Field type annotation expected. */ +/* @@? 21:12 Error TypeError: Variable 'C' has already been declared. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/xgc_ea/xgc_ea.ets b/ets2panda/test/ast/compiler/ets/xgc_ea/xgc_ea.ets new file mode 100755 index 0000000000000000000000000000000000000000..05b98fcb0a68a6c37b33e96200c65aaf43680e4c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/xgc_ea/xgc_ea.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 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: * + * 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. + */ + +package xgc_ea + +const SHARED_OBJECTS_COUNT: testResult, "test20 $2" + +/* @@? 17:7 Error SyntaxError: Missing initialization for const package property */ +/* @@? 17:29 Error TypeError: Cannot find type 'testResult'. */ +/* @@? 17:41 Error SyntaxError: Identifier expected, got 'string literal'. */ +/* @@? 17:41 Error SyntaxError: Number, string or computed value property name 'test20 $2' is not allowed, use classes to access data by property names that are identifiers */ +/* @@? 23:95 Error SyntaxError: Variable must be initialized or it's type must be declared. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/AllowSequence.ets b/ets2panda/test/ast/parser/ets/AllowSequence.ets index 1cba4591b8a47022f7352367060ace1bd3400b12..54699864e1235d2fe6fba812836e27f499bcd4f4 100644 --- a/ets2panda/test/ast/parser/ets/AllowSequence.ets +++ b/ets2panda/test/ast/parser/ets/AllowSequence.ets @@ -21,6 +21,4 @@ function main(): void { } } -/* @@? 19:17 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 19:19 Error SyntaxError: Unexpected token 'x'. */ -/* @@? 19:22 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:17 Error SyntaxError: Comma operator is supported only in 'for' loops. */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/InvalidStatements3.ets b/ets2panda/test/ast/parser/ets/FixedArray/InvalidStatements3.ets index 29c5aced21a30e34d933b5f39f6f9a22d678e5e1..ef5fb160524f486bcf001ae132a3c0868e648940 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/InvalidStatements3.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/InvalidStatements3.ets @@ -60,4 +60,4 @@ for (let i = 1 in [0, 1, 2]) {} /* @@? 38:13 Error SyntaxError: Unexpected token '@'. */ /* @@? 38:14 Error TypeError: Cannot find type 'annotate'. */ /* @@? 42:16 Error SyntaxError: for-in loop variable declaration may not have an initializer. */ -/* @@? 42:16 Error SyntaxError: Unexpected token 'in'. */ +/* @@? 42:16 Error SyntaxError: 'for ... in' loop is not supported, please use regular 'for' or 'for ... of ...' loop to iterate through arrays and iterable objects. */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets index 7fa2468144f7fe14e9182bdb19ef92e8bc7ab075..bf3c5717b906f081bc34692dda911d86fb0597a8 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets @@ -172,8 +172,8 @@ function main(): void { /* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ /* @@? 37:33 Error TypeError: Unresolved reference rethrows */ /* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ /* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ /* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ @@ -189,12 +189,11 @@ function main(): void { /* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ /* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ /* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ -/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ /* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ /* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:12 Error TypeError: The type of parameter 'a' cannot be inferred */ /* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 51:35 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 51:37 Error SyntaxError: Unexpected token '...'. */ @@ -241,10 +240,10 @@ function main(): void { /* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ /* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ /* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ /* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ @@ -254,8 +253,8 @@ function main(): void { /* @@? 120:5 Error SyntaxError: return keyword should be used in function body. */ /* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ /* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ -/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ +/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 123:6 Error TypeError: Unresolved reference abc */ /* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ /* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -285,4 +284,4 @@ function main(): void { /* @@? 165:5 Error TypeError: This expression is not callable. */ /* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ /* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 289:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 288:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/StringFasta.ets b/ets2panda/test/ast/parser/ets/FixedArray/StringFasta.ets index 87b568099bb05661d6a6599a853eb5fa09258647..3cc0fa0bcdae7f707deb82b25dd7f52c6b53d12e 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/StringFasta.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/StringFasta.ets @@ -126,25 +126,25 @@ function main(): void { /* @@? 18:46 Error TypeError: Cannot find type 'HashMap'. */ /* @@? 19:22 Error TypeError: Cannot find type 'HashMap'. */ /* @@? 19:50 Error TypeError: Cannot find type 'HashMap'. */ -/* @@? 21:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 22:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 23:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 24:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 25:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 26:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 27:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 28:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 29:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 30:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 31:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 32:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 33:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 34:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 35:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 36:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 37:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 38:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 39:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ +/* @@? 21:9 Error TypeError: Unresolved reference IUB */ +/* @@? 22:9 Error TypeError: Unresolved reference IUB */ +/* @@? 23:9 Error TypeError: Unresolved reference IUB */ +/* @@? 24:9 Error TypeError: Unresolved reference IUB */ +/* @@? 25:9 Error TypeError: Unresolved reference IUB */ +/* @@? 26:9 Error TypeError: Unresolved reference IUB */ +/* @@? 27:9 Error TypeError: Unresolved reference IUB */ +/* @@? 28:9 Error TypeError: Unresolved reference IUB */ +/* @@? 29:9 Error TypeError: Unresolved reference IUB */ +/* @@? 30:9 Error TypeError: Unresolved reference IUB */ +/* @@? 31:9 Error TypeError: Unresolved reference IUB */ +/* @@? 32:9 Error TypeError: Unresolved reference IUB */ +/* @@? 33:9 Error TypeError: Unresolved reference IUB */ +/* @@? 34:9 Error TypeError: Unresolved reference IUB */ +/* @@? 35:9 Error TypeError: Unresolved reference IUB */ +/* @@? 36:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 37:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 38:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 39:9 Error TypeError: Unresolved reference HomoSap */ /* @@@ label Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ /* @@? 47:13 Error TypeError: Static property 'last' must be accessed through it's class 'Random' */ /* @@? 47:21 Error TypeError: Static property 'last' must be accessed through it's class 'Random' */ @@ -171,8 +171,8 @@ function main(): void { /* @@? 112:32 Error TypeError: Property 'count' must be accessed through 'this' */ /* @@? 113:16 Error TypeError: Static property 'fastaRandom' must be accessed through it's class 'StringFasta' */ /* @@? 113:32 Error TypeError: Property 'count' must be accessed through 'this' */ -/* @@? 113:46 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ +/* @@? 113:46 Error TypeError: Unresolved reference IUB */ /* @@? 114:16 Error TypeError: Static property 'fastaRandom' must be accessed through it's class 'StringFasta' */ /* @@? 114:32 Error TypeError: Property 'count' must be accessed through 'this' */ -/* @@? 114:46 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ +/* @@? 114:46 Error TypeError: Unresolved reference HomoSap */ /* @@? 116:36 Error TypeError: 'expected' is a static property of 'StringFasta' */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets b/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets index 6651396d4b4f70b98d33b6f13bddcc063ecc15c2..49a08ff7e5c657fe249e7bb2090fec0104ec94d9 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets @@ -23,8 +23,8 @@ declare class Environment { static foo7(props1: {key:string, value:int}[], props2: FixedArray): void; } -/* @@? 17:23 Error SyntaxError: Invalid Type. */ -/* @@? 18:25 Error SyntaxError: Invalid Type. */ +/* @@? 17:23 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 18:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 19:25 Error SyntaxError: Invalid Type. */ /* @@? 21:20 Error SyntaxError: Invalid Type. */ /* @@? 21:28 Error SyntaxError: Invalid Type. */ @@ -32,4 +32,5 @@ declare class Environment { /* @@? 21:37 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 21:37 Error SyntaxError: Invalid Type. */ /* @@? 22:20 Error SyntaxError: Invalid Type. */ -/* @@? 23:25 Error SyntaxError: Invalid Type. */ \ No newline at end of file +/* @@? 23:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 23:36 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/spreadexpr_in_newexpr_neg01.ets b/ets2panda/test/ast/parser/ets/FixedArray/spreadexpr_in_newexpr_neg01.ets index ff2284a2983df75e6b7338f194c91987d71a4485..7eef9e9c85e61c440dcd6661ba7e7a5e12fc73a2 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/spreadexpr_in_newexpr_neg01.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/spreadexpr_in_newexpr_neg01.ets @@ -33,6 +33,5 @@ function main() { /* @@? 19:9 Error SyntaxError: Unexpected token 'this'. */ /* @@? 19:13 Error SyntaxError: Unexpected token '.'. */ /* @@? 19:14 Error TypeError: Variable 'fld' has already been declared. */ -/* @@? 19:14 Error TypeError: Property 'fld' must be accessed through 'this' */ /* @@? 19:20 Error TypeError: Unresolved reference p */ /* @@? 21:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/InvalidClasses.ets b/ets2panda/test/ast/parser/ets/InvalidClasses.ets index b73dc9af4c14bebae42fa2cc529e95e6ee810222..4b7a7a5cf9a9eb75832c74191b2b2c2247c07f49 100644 --- a/ets2panda/test/ast/parser/ets/InvalidClasses.ets +++ b/ets2panda/test/ast/parser/ets/InvalidClasses.ets @@ -104,6 +104,7 @@ interface I1 { /* @@? 47:21 Error TypeError: Return type of async function must be 'Promise'. */ /* @@? 54:21 Error TypeError: Initializers are not allowed in ambient contexts: x */ /* @@? 54:23 Error SyntaxError: Initializers are not allowed in ambient contexts. */ +/* @@? 58:1 Error TypeError: Unresolved reference declare */ /* @@? 58:9 Error SyntaxError: Unexpected token 'native'. */ /* @@? 58:16 Error SyntaxError: 'native' flags must be used for functions only at top-level. */ /* @@? 58:22 Error TypeError: Native and Declare methods should have explicit return type. */ diff --git a/ets2panda/test/ast/parser/ets/InvalidParserImpl.ets b/ets2panda/test/ast/parser/ets/InvalidParserImpl.ets index feca6d13fffc6c08f84198aede31717936a7c022..899de53972fe0f73745efbef8c0b7f314b523183 100644 --- a/ets2panda/test/ast/parser/ets/InvalidParserImpl.ets +++ b/ets2panda/test/ast/parser/ets/InvalidParserImpl.ets @@ -25,6 +25,4 @@ class int {} /* @@? 17:12 Error TypeError: Getter must return a value */ /* @@? 18:5 Error SyntaxError: Getter must not have formal parameters. */ /* @@? 19:1 Error SyntaxError: Setter must have exactly one formal parameter. */ -/* @@? 23:7 Error SyntaxError: Cannot be used as user-defined type. */ -/* @@? 23:7 Error SyntaxError: Hard keyword 'int' cannot be used as identifier */ -/* @@? 23:7 Error SyntaxError: Identifier expected, got 'int'. */ +/* @@? 23:7 Error SyntaxError: int is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/InvalidStatements3.ets b/ets2panda/test/ast/parser/ets/InvalidStatements3.ets index 85b2082bf489c9042642d5a0d34628fbc8c180d6..308ab7542c9dc3dca8077fb5dfc665065e625eba 100644 --- a/ets2panda/test/ast/parser/ets/InvalidStatements3.ets +++ b/ets2panda/test/ast/parser/ets/InvalidStatements3.ets @@ -55,9 +55,9 @@ for (let i = 1 in [0, 1, 2]) {} /* @@? 31:9 Error SyntaxError: Unexpected token 'let'. */ /* @@? 31:13 Error SyntaxError: Unexpected token 'x'. */ /* @@? 34:5 Error SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list. */ -/* @@? 38:5 Error SyntaxError: Unexpected token 'private'. */ /* @@? 38:5 Error SyntaxError: Annotation declaration can not have access modifier. */ +/* @@? 38:5 Error SyntaxError: Unexpected token 'private'. */ /* @@? 38:13 Error SyntaxError: Unexpected token '@'. */ /* @@? 38:14 Error TypeError: Cannot find type 'annotate'. */ /* @@? 42:16 Error SyntaxError: for-in loop variable declaration may not have an initializer. */ -/* @@? 42:16 Error SyntaxError: Unexpected token 'in'. */ +/* @@? 42:16 Error SyntaxError: 'for ... in' loop is not supported, please use regular 'for' or 'for ... of ...' loop to iterate through arrays and iterable objects. */ diff --git a/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets b/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets index 85f7f8a87135c0e294950d3ebbe3a70f80ae0539..e4ac2d35782c9a20b94cc544bb90aeb0ba88c1f0 100644 --- a/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets +++ b/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets @@ -17,9 +17,12 @@ function /* @@ label */(): void { } function /* @@ label1 */(): /* @@ label2 */{ - return 77; + /* @@ label3 */return /* @@ label4 */77; } /* @@@ label Error SyntaxError: Unexpected token, expected an identifier. */ /* @@@ label1 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@@ label2 Error SyntaxError: Invalid Type. */ +/* @@@ label1 Error TypeError: Only abstract or native methods can't have body. */ +/* @@@ label2 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@@ label3 Error SyntaxError: Unexpected token 'return'. */ +/* @@@ label4 Error SyntaxError: Unexpected token '77'. */ diff --git a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets index 804e16d1ad836a82c4596faf50287174b5ecbf9f..134fd0804fc8e36b16d4e607ab019596474b96ac 100644 --- a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets @@ -172,8 +172,8 @@ function main(): void { /* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ /* @@? 37:33 Error TypeError: Unresolved reference rethrows */ /* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ /* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ /* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ @@ -189,12 +189,11 @@ function main(): void { /* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ /* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ /* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ -/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ /* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ /* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:12 Error TypeError: The type of parameter 'a' cannot be inferred */ /* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 51:25 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 51:27 Error SyntaxError: Unexpected token '...'. */ @@ -225,10 +224,10 @@ function main(): void { /* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ /* @@? 92:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ /* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 115:32 Error SyntaxError: Unexpected token 'U'. */ /* @@? 115:32 Error TypeError: Unresolved reference U */ @@ -239,10 +238,10 @@ function main(): void { /* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ /* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ /* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ /* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ @@ -257,10 +256,10 @@ function main(): void { /* @@? 123:6 Error TypeError: Unresolved reference abc */ /* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ /* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ /* @@? 137:16 Error SyntaxError: Expected '{', got '='. */ /* @@? 137:16 Error SyntaxError: Expected ')', got '='. */ /* @@? 137:16 Error SyntaxError: Catch clause variable cannot have an initializer. */ -/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ /* @@? 137:18 Error SyntaxError: Unexpected token '0'. */ /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ /* @@? 137:21 Error SyntaxError: Unexpected token '{'. */ @@ -283,4 +282,4 @@ function main(): void { /* @@? 165:5 Error TypeError: This expression is not callable. */ /* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ /* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 287:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 286:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/StringFasta.ets b/ets2panda/test/ast/parser/ets/StringFasta.ets index 3292dd0c41902d1c734be12991833b084c986dea..758d82839fe141ae9f02ef51ac4447f179cc3d6d 100644 --- a/ets2panda/test/ast/parser/ets/StringFasta.ets +++ b/ets2panda/test/ast/parser/ets/StringFasta.ets @@ -126,25 +126,25 @@ function main(): void { /* @@? 18:46 Error TypeError: Cannot find type 'HashMap'. */ /* @@? 19:22 Error TypeError: Cannot find type 'HashMap'. */ /* @@? 19:50 Error TypeError: Cannot find type 'HashMap'. */ -/* @@? 21:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 22:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 23:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 24:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 25:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 26:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 27:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 28:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 29:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 30:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 31:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 32:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 33:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 34:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 35:9 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ -/* @@? 36:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 37:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 38:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ -/* @@? 39:9 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ +/* @@? 21:9 Error TypeError: Unresolved reference IUB */ +/* @@? 22:9 Error TypeError: Unresolved reference IUB */ +/* @@? 23:9 Error TypeError: Unresolved reference IUB */ +/* @@? 24:9 Error TypeError: Unresolved reference IUB */ +/* @@? 25:9 Error TypeError: Unresolved reference IUB */ +/* @@? 26:9 Error TypeError: Unresolved reference IUB */ +/* @@? 27:9 Error TypeError: Unresolved reference IUB */ +/* @@? 28:9 Error TypeError: Unresolved reference IUB */ +/* @@? 29:9 Error TypeError: Unresolved reference IUB */ +/* @@? 30:9 Error TypeError: Unresolved reference IUB */ +/* @@? 31:9 Error TypeError: Unresolved reference IUB */ +/* @@? 32:9 Error TypeError: Unresolved reference IUB */ +/* @@? 33:9 Error TypeError: Unresolved reference IUB */ +/* @@? 34:9 Error TypeError: Unresolved reference IUB */ +/* @@? 35:9 Error TypeError: Unresolved reference IUB */ +/* @@? 36:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 37:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 38:9 Error TypeError: Unresolved reference HomoSap */ +/* @@? 39:9 Error TypeError: Unresolved reference HomoSap */ /* @@@ label Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ /* @@? 47:13 Error TypeError: Static property 'last' must be accessed through it's class 'Random' */ /* @@? 47:21 Error TypeError: Static property 'last' must be accessed through it's class 'Random' */ @@ -171,8 +171,8 @@ function main(): void { /* @@? 112:32 Error TypeError: Property 'count' must be accessed through 'this' */ /* @@? 113:16 Error TypeError: Static property 'fastaRandom' must be accessed through it's class 'StringFasta' */ /* @@? 113:32 Error TypeError: Property 'count' must be accessed through 'this' */ -/* @@? 113:46 Error TypeError: Static property 'IUB' must be accessed through it's class 'StringFasta' */ +/* @@? 113:46 Error TypeError: Unresolved reference IUB */ /* @@? 114:16 Error TypeError: Static property 'fastaRandom' must be accessed through it's class 'StringFasta' */ /* @@? 114:32 Error TypeError: Property 'count' must be accessed through 'this' */ -/* @@? 114:46 Error TypeError: Static property 'HomoSap' must be accessed through it's class 'StringFasta' */ +/* @@? 114:46 Error TypeError: Unresolved reference HomoSap */ /* @@? 116:36 Error TypeError: 'expected' is a static property of 'StringFasta' */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_10.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_10.ets index 89543725ecbdc28e518f11a151d34188ddfab2cf..6089b2b4463dd14697fea0260bc15d1c68a1f96f 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_10.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_10.ets @@ -15,12 +15,8 @@ declare class ClassWithSymbols { public readonly [x: number]: string; - public /* @@ label1 */[x: number]: /* @@ label2 */(/* @@ label3 */) /* @@ label4 */=> /* @@ label5 */void; + public /* @@ label1 */[x: number]: () => void; } /* @@@ label1 Error SyntaxError: Only one index signature can exist in a class */ -/* @@@ label2 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ -/* @@@ label3 Error SyntaxError: Unexpected token ')'. */ -/* @@@ label4 Error SyntaxError: Unexpected token '=>'. */ -/* @@@ label5 Error SyntaxError: Unexpected token 'void'. */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_11.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_11.ets new file mode 100644 index 0000000000000000000000000000000000000000..b12c0c7f6655b79cfdcacd55f39ef44b55e57745 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_11.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +declare interface I{ + [index:number]:long; +} + +declare class C{ + [index:number]:long; +} diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_3.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_3.ets index c4f60ba8db373a47fe65087577a1826b8f7b66b1..4f06b3693e3fbd2a9b19aac40a6f7a13b882b374 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_3.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_3.ets @@ -14,11 +14,19 @@ */ declare class A { - [index : /* @@ label */string] : string + [index : string] : string } function main() { let a : A = new A(); } -/* @@@ label Error SyntaxError: Index type must be number in index signature. */ +/* @@? 17:14 Error SyntaxError: Index type must be number in index signature. */ +/* @@? 17:14 Error SyntaxError: ] expected in index signature. */ +/* @@? 17:20 Error SyntaxError: An index signature must have a type annotation. */ +/* @@? 17:20 Error SyntaxError: Expected ':', got ']'. */ +/* @@? 17:20 Error SyntaxError: Invalid Type. */ +/* @@? 17:20 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ +/* @@? 17:20 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:22 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:24 Error SyntaxError: string is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_4.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_4.ets index 7f0b37538a5524649eb0a6a217402813a7afa477..33e4fff0d11dc57e84ca295c89f2d1d1d37bbc0e 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_4.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_4.ets @@ -22,7 +22,6 @@ declare class A { } /* @@@ label Error SyntaxError: An index signature must have a type annotation. */ -/* @@@ label1 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ -/* @@@ label3 Error TypeError: Native and Declare methods should have explicit return type. */ -/* @@@ label2 Error SyntaxError: Expected '}', got 'end of stream'. */ -/* @@ label2 */ \ No newline at end of file +/* @@@ label Error SyntaxError: Expected ':', got '}'. */ +/* @@@ label Error SyntaxError: Invalid Type. */ +/* @@@ label Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_5.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_5.ets index 0319741534bdaff23b2d7436e57906189b3b7cae..7ea0d48dd447a6d9c576e9427a2d7b8cfbdc799d 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_5.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_5.ets @@ -21,4 +21,6 @@ function main() { let a : A = new A(); } +/* @@@ label Error SyntaxError: Invalid Type. */ /* @@@ label Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ +/* @@@ label Error SyntaxError: Unexpected token '?'. */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_7.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_7.ets index e387d2b7d7ab0be06ff4bc541ab4b772a01cb384..c9e6ef112ef706cb157758f8bb5c491a2c321b09 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_7.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_7.ets @@ -15,16 +15,12 @@ declare class A { [index : number /* @@ label */: /* @@ label1 */string -/* @@ label2 */} +} -/* @@ label3 */function main/* @@ label5 */() { +function main() { let a : A = new A(); } /* @@@ label Error SyntaxError: ] expected in index signature. */ /* @@@ label1 Error SyntaxError: An index signature must have a type annotation. */ -/* @@@ label2 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ -/* @@@ label3 Error SyntaxError: Unexpected token 'function'. */ -/* @@@ label5 Error TypeError: Native and Declare methods should have explicit return type. */ -/* @@@ label4 Error SyntaxError: Expected '}', got 'end of stream'. */ -/* @@ label4 */ \ No newline at end of file +/* @@@ label1 Error SyntaxError: Expected ':', got 'identification literal'. */ diff --git a/ets2panda/test/ast/parser/ets/ambient_indexer_8.ets b/ets2panda/test/ast/parser/ets/ambient_indexer_8.ets index 4afa270c8c14ed1ff5dd66fca45e968926dea725..62e5623e90ffa388b98664a0f462b1a359771abe 100644 --- a/ets2panda/test/ast/parser/ets/ambient_indexer_8.ets +++ b/ets2panda/test/ast/parser/ets/ambient_indexer_8.ets @@ -15,17 +15,14 @@ declare class A { [index/* @@ label */] /* @@ label1 */: /* @@ label2 */string -/* @@ label3 */} +} -/* @@ label4 */function main/* @@ label6 */() { +function main() { let a : A = new A(); } -/* @@@ label Error SyntaxError: Index type expected in index signature. */ -/* @@@ label1 Error SyntaxError: Index type must be number in index signature. */ -/* @@@ label2 Error SyntaxError: ] expected in index signature. */ -/* @@@ label3 Error SyntaxError: An index signature must have a type annotation. */ -/* @@@ label4 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ -/* @@@ label6 Error TypeError: Native and Declare methods should have explicit return type. */ -/* @@@ label5 Error SyntaxError: Expected '}', got 'end of stream'. */ -/* @@ label5 */ \ No newline at end of file +/* @@@ label Error SyntaxError: Index type expected in index signature. */ +/* @@@ label1 Error SyntaxError: Index type must be number in index signature. */ +/* @@@ label1 Error SyntaxError: ] expected in index signature. */ +/* @@@ label2 Error SyntaxError: An index signature must have a type annotation. */ +/* @@@ label2 Error SyntaxError: Expected ':', got 'identification literal'. */ diff --git a/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets b/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets index 69d61ed6c5ec131f6e29972eab984fc820e6cc13..f3fefe0e9d7faba4363d6e128cd0cede10d40f6b 100644 --- a/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets +++ b/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets @@ -45,6 +45,6 @@ class C{ public foo() {} } -/* @@? 29:2 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */ /* @@? 29:4 Error SyntaxError: Missing type annotation for property 'b'. */ /* @@? 42:11 Error TypeError: Invalid value for annotation field, expected a constant literal. */ +/* @@? 44:16 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_bad_initializer06.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_bad_initializer06.ets index f1e3bbdc40f04b9d2696fc2e936139672fcd38f2..8ede82f797615d800106dd7336fa08ef929f63d7 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_bad_initializer06.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_bad_initializer06.ets @@ -20,5 +20,3 @@ class A{} } /* @@@ label Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ -/* @@@ label Error TypeError: Invalid value for annotation field, expected a constant literal. */ -/* @@? 19:43 Error TypeError: Type '(a: Int) => void' cannot be assigned to type 'String' */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_parser_bad_token05.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_parser_bad_token05.ets index dd02b7775a4ff91a997b54029cc34129564ce478..5648eba09f5026058368c85d7c067fbcc59f697c 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_parser_bad_token05.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_parser_bad_token05.ets @@ -16,7 +16,7 @@ import * as Src from "./annotation_export" -Src./* @@ label */MyAnno() +/* @@ label */Src.MyAnno() class A{} -/* @@@ label Error TypeError: Property 'MyAnno' does not exist on type 'annotation_export' */ +/* @@@ label Error TypeError: MyAnno is an annotation therefore cannot be instantiated. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param05.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param05.ets index c3539ceb56291b5366659216cb0654c3c263b06a..587d3a3031f78346ca9b74188601993a842f4154 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param05.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param05.ets @@ -22,5 +22,3 @@ class B{} /* @@@ label Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ -/* @@@ label Error TypeError: Invalid value for annotation field, expected a constant literal. */ -/* @@? 21:40 Error TypeError: type String has no property named s */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets index 439897e7a608a875f61fb5e501d5ad24cda8c003..d5077544840f5baec9e408280c5c401c4a4c1374 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets @@ -19,9 +19,7 @@ } -function foo(@MyAnno ...a/* @@ label */){} - -/* @@@ label Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +function foo(@MyAnno ...a){} /* @@? 22:15 Error TypeError: The required field 'testProperty1' must be specified. Fields without default values cannot be omitted. */ -/* @@? 22:22 Error TypeError: The type of parameter 'a' cannot be inferred */ /* @@? 22:22 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 22:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets index a87e83104e6429bc3e96a54ea7f42dcc4735732d..96304af4406e85870489c188070c4065893f4f47 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets @@ -26,17 +26,15 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: } /* @@? 19:10 Error TypeError: Only abstract or native methods can't have body. */ -/* @@? 19:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ /* @@? 19:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 19:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 19:20 Error TypeError: need to specify target type for class composite */ /* @@? 19:42 Error SyntaxError: Unexpected token 'x'. */ -/* @@? 19:45 Error SyntaxError: Unexpected token 'int'. */ /* @@? 19:45 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 19:45 Error SyntaxError: Unexpected token 'int'. */ /* @@? 19:48 Error SyntaxError: Unexpected token ')'. */ /* @@? 19:50 Error SyntaxError: Unexpected token '{'. */ /* @@? 22:1 Error TypeError: Function foo is already declared. */ -/* @@? 22:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ /* @@? 22:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 22:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 22:20 Error TypeError: need to specify target type for class composite */ @@ -53,7 +51,6 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: /* @@? 22:87 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:89 Error SyntaxError: Unexpected token '{'. */ /* @@? 25:1 Error TypeError: Function foo is already declared. */ -/* @@? 25:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ /* @@? 25:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 25:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 25:20 Error TypeError: need to specify target type for class composite */ @@ -68,4 +65,4 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: /* @@? 25:81 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 25:81 Error TypeError: Type name 'string' used in the wrong context */ /* @@? 25:87 Error SyntaxError: Unexpected token ')'. */ -/* @@? 25:89 Error SyntaxError: Unexpected token '{'. */ +/* @@? 25:89 Error SyntaxError: Unexpected token '{'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/async_function_bad.ets b/ets2panda/test/ast/parser/ets/async_function_bad.ets index b55c2ffaf805c847953bbbdc5b6a313d38d8bde5..d7c4a852b25b8e90f91677213358c186e36d53bd 100644 --- a/ets2panda/test/ast/parser/ets/async_function_bad.ets +++ b/ets2panda/test/ast/parser/ets/async_function_bad.ets @@ -19,7 +19,6 @@ async native function foo(): Promise; /* @@? 16:14 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 16:14 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 16:14 Error TypeError: Only abstract or native methods can't have body. */ -/* @@? 16:23 Error TypeError: The type of parameter 'foo' cannot be inferred */ /* @@? 16:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 16:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 16:27 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets b/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets index 920263f091680b1a7e4356a37f2f30b36b682b12..09a0912afdb078b51efeb8e558a248d3b9c6d2fc 100644 --- a/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets +++ b/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets @@ -18,21 +18,19 @@ type Loop> = { }; /* @@? 16:24 Error TypeError: Circular type alias reference */ -/* @@? 16:38 Error SyntaxError: Invalid Type. */ -/* @@? 17:6 Error TypeError: Unresolved reference P */ -/* @@? 17:8 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 17:8 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 17:8 Error TypeError: Unresolved reference in */ -/* @@? 17:11 Error SyntaxError: Unexpected token 'keyof'. */ -/* @@? 17:11 Error TypeError: Unresolved reference keyof */ -/* @@? 17:17 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 17:17 Error TypeError: Unresolved reference T */ +/* @@? 16:38 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 17:6 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 17:10 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:16 Error SyntaxError: Field type annotation expected. */ /* @@? 17:18 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:18 Error SyntaxError: Field type annotation expected. */ /* @@? 17:19 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:21 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 17:21 Error TypeError: Unresolved reference U */ -/* @@? 17:21 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 17:22 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:23 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 17:24 Error SyntaxError: Unexpected token ']'. */ /* @@? 17:26 Error SyntaxError: Unexpected token 'extends'. */ -/* @@? 17:34 Error SyntaxError: Unexpected token 'boolean'. */ -/* @@? 17:44 Error TypeError: Type name 'number' used in the wrong context */ -/* @@? 17:53 Error TypeError: Type name 'string' used in the wrong context */ +/* @@? 17:34 Error SyntaxError: boolean is a predefined type, cannot be used as an identifier */ +/* @@? 17:42 Error SyntaxError: Unexpected token '?'. */ +/* @@? 17:44 Error SyntaxError: number is a predefined type, cannot be used as an identifier */ +/* @@? 17:51 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:53 Error SyntaxError: string is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/class-instance-field-redeclaration.ets b/ets2panda/test/ast/parser/ets/class-instance-field-redeclaration.ets index ef8d91f4ec84dbd0bdf6199e3a05f264d41c0dd5..5724caccac56b6e47b75648daeaaed243d5b1a28 100644 --- a/ets2panda/test/ast/parser/ets/class-instance-field-redeclaration.ets +++ b/ets2panda/test/ast/parser/ets/class-instance-field-redeclaration.ets @@ -19,4 +19,3 @@ class C { } /* @@@ label Error TypeError: Variable 'foo' has already been declared. */ -/* @@@ label Error TypeError: Property 'foo' must be accessed through 'this' */ diff --git a/ets2panda/test/ast/parser/ets/class-static-field-redeclaration.ets b/ets2panda/test/ast/parser/ets/class-static-field-redeclaration.ets index 87471276b09cc49968c4d2105a525345c4dabd4e..7951f410c99a0826dd9d00f62d92d5022f853a9c 100644 --- a/ets2panda/test/ast/parser/ets/class-static-field-redeclaration.ets +++ b/ets2panda/test/ast/parser/ets/class-static-field-redeclaration.ets @@ -19,4 +19,3 @@ class C { } /* @@@ label Error TypeError: Variable 'foo' has already been declared. */ -/* @@@ label Error TypeError: Static property 'foo' must be accessed through it's class 'C' */ diff --git a/ets2panda/test/ast/parser/ets/class_composite_invalid_target.ets b/ets2panda/test/ast/parser/ets/class_composite_invalid_target.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcf98bfb30aa553154b813838ef5df2056894836 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/class_composite_invalid_target.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024-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. + */ + +type A = number | boolean; + +let obj: A = { + x: 123 +}; + +/* @@? 18:14 Error TypeError: Target type for class composite needs to be an object type, found 'Double|Boolean' */ diff --git a/ets2panda/test/ast/parser/ets/comma_only_in_for.ets b/ets2panda/test/ast/parser/ets/comma_only_in_for.ets new file mode 100644 index 0000000000000000000000000000000000000000..049e5d2b5670040165073ca76becc3c44cc2502a --- /dev/null +++ b/ets2panda/test/ast/parser/ets/comma_only_in_for.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +let x = 0 +x = (++x/* @@ label */, x++) + +/* @@@ label Error SyntaxError: Comma operator is supported only in 'for' loops. */ diff --git a/ets2panda/test/ast/parser/ets/comma_only_in_for_2.ets b/ets2panda/test/ast/parser/ets/comma_only_in_for_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b39ce75341e138ad75365c91d09828ac6f915ba --- /dev/null +++ b/ets2panda/test/ast/parser/ets/comma_only_in_for_2.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +let x = 10 +let y = (x++/* @@ label */, 2, 44, x+10) + +/* @@@ label Error SyntaxError: Comma operator is supported only in 'for' loops. */ diff --git a/ets2panda/test/ast/parser/ets/declare_annotation.ets b/ets2panda/test/ast/parser/ets/declare_annotation.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba73fcc9baeb39b9f037ef4395bdaca852d3a71b --- /dev/null +++ b/ets2panda/test/ast/parser/ets/declare_annotation.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + */ + +@interface ClassAuthor { + au`horName: string = "1" +} + +class A{ + @ClassAuthor + foo1(){} + + @ClassAuthor("11") + foo2(){} + + @ClassAuthor({authorName: "22"}) + foo3() + +/* @@? 17:7 Error SyntaxError: Missing type annotation for property 'au'. */ +/* @@? 17:7 Error SyntaxError: Identifier expected, got '`'. */ +/* @@? 21:6 Error TypeError: The required field 'au' must be specified. Fields without default values cannot be omitted. */ +/* @@? 24:6 Error TypeError: Annotation 'ClassAuthor' requires multiple fields to be specified. */ +/* @@? 24:18 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */ +/* @@? 27:6 Error TypeError: The required field 'au' must be specified. Fields without default values cannot be omitted. */ +/* @@? 27:19 Error TypeError: The parameter 'authorName' does not match any declared property in the annotation 'ClassAuthor'. */ +/* @@? 28:9 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 39:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/default_parameter3.ets b/ets2panda/test/ast/parser/ets/default_parameter3.ets index a1ea174314af3add6e8317a2595810cc60eeafa6..80c76508f8a0a8e3b18f3bd1bc9ff341ff6df977 100644 --- a/ets2panda/test/ast/parser/ets/default_parameter3.ets +++ b/ets2panda/test/ast/parser/ets/default_parameter3.ets @@ -18,4 +18,4 @@ function foo(a : int = 10, /* @@ label */b : int, c : int = 15) : int return a + b; } -/* @@@ label Error SyntaxError: Required parameter follows default parameter(s). */ +/* @@@ label Error SyntaxError: A required parameter cannot follow an optional parameter. */ diff --git a/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_function_use_as_value.ets b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_function_use_as_value.ets new file mode 100644 index 0000000000000000000000000000000000000000..a82806dcf2aa847a9260193728d45e2b255d79df --- /dev/null +++ b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_function_use_as_value.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { foo, A } from "dynamic_import_tests/modules/module" + +function bar(f:(p:A)=>void){} + +bar(foo) // should not crash \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets b/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets index e085a3efaffb4ed91f7fcca39ce993d05794b0f6..dab191d5b7e27239944032f95c54f80efa65ebaa 100644 --- a/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets +++ b/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets @@ -25,3 +25,5 @@ /* @@? 20:1 Error TypeError: Can't resolve array type */ /* @@? 20:8 Error SyntaxError: Function expressions are not supported, use arrow functions instead */ /* @@? 20:18 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ + + diff --git a/ets2panda/test/ast/parser/ets/enum22.ets b/ets2panda/test/ast/parser/ets/enum22.ets index 1205a10d2bd28bec3efe710fa465df924a2036c3..b052216cadf5f248d42a0991f53e6cafe16ce94e 100644 --- a/ets2panda/test/ast/parser/ets/enum22.ets +++ b/ets2panda/test/ast/parser/ets/enum22.ets @@ -18,4 +18,3 @@ enum duplicateKeysStringCase { /* @@ label */Gray = "#ff808080" } /* @@@ label Error TypeError: Variable 'Gray' has already been declared. */ -/* @@@ label Error TypeError: Static property 'Gray' must be accessed through it's class 'duplicateKeysStringCase' */ diff --git a/ets2panda/test/ast/parser/ets/enum23.ets b/ets2panda/test/ast/parser/ets/enum23.ets index 800c35446e74cec12e57ace55229ce00085a88af..fbea4d6c3b28da754b46afcf9aefa975a6e94f11 100644 --- a/ets2panda/test/ast/parser/ets/enum23.ets +++ b/ets2panda/test/ast/parser/ets/enum23.ets @@ -17,5 +17,4 @@ enum duplicateKeysNumCase { Red = 1, /* @@ label */Red = 1 } -/* @@@ label Error TypeError: Variable 'Red' has already been declared. */ -/* @@@ label Error TypeError: Static property 'Red' must be accessed through it's class 'duplicateKeysNumCase' */ +/* @@@ label Error TypeError: Variable 'Red' has already been declared. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/export_as.ets b/ets2panda/test/ast/parser/ets/export_as.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2c130fbe82e2eb4dc9f52b8c778f816c0390894 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/export_as.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +export /* @@ label1 */as /* @@ label2 */namespace mathLib {} + +/* @@@ label1 Error SyntaxError: Universal module definitions are not supported, please use ordinary import/export syntax instead. */ +/* @@@ label1 Error SyntaxError: Unexpected token 'as'. */ +/* @@@ label2 Error SyntaxError: Unexpected token 'namespace'. */ diff --git a/ets2panda/test/ast/parser/ets/fields.ets b/ets2panda/test/ast/parser/ets/fields.ets index 414efc3575499d93614f562d11a6059d086b8b90..31cdc48edbacaced6e755ac2afbb339edea4b54f 100644 --- a/ets2panda/test/ast/parser/ets/fields.ets +++ b/ets2panda/test/ast/parser/ets/fields.ets @@ -28,4 +28,3 @@ class C { } /* @@@ label Error TypeError: Variable 'f' has already been declared. */ -/* @@@ label Error TypeError: Static property 'f' must be accessed through it's class 'C' */ diff --git a/ets2panda/test/ast/parser/ets/for_in.ets b/ets2panda/test/ast/parser/ets/for_in.ets new file mode 100644 index 0000000000000000000000000000000000000000..922bde17d5a79170a098ebc31071f129909015d2 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/for_in.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + +let a: number[] = [1.0, 2.0, 3.0] +for (let i /* @@ label */in a) { +} + +/* @@@ label Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@@ label Error SyntaxError: 'for ... in' loop is not supported, please use regular 'for' or 'for ... of ...' loop to iterate through arrays + and iterable objects. */ diff --git a/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets b/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets index b397027c6bc09776e6276193f9c9a1419bf51a80..3f31cfcb8cf04c96a3cb805c8e90f5f29a1ebf2b 100644 --- a/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets +++ b/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets @@ -23,8 +23,8 @@ declare class Environment { static foo7(props1: {key:string, value:int}[], props2: int[]): void; } -/* @@? 17:23 Error SyntaxError: Invalid Type. */ -/* @@? 18:25 Error SyntaxError: Invalid Type. */ +/* @@? 17:23 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 18:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 19:25 Error SyntaxError: Invalid Type. */ /* @@? 21:20 Error SyntaxError: Invalid Type. */ /* @@? 21:28 Error SyntaxError: Invalid Type. */ @@ -32,4 +32,5 @@ declare class Environment { /* @@? 21:37 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 21:37 Error SyntaxError: Invalid Type. */ /* @@? 22:20 Error SyntaxError: Invalid Type. */ -/* @@? 23:25 Error SyntaxError: Invalid Type. */ \ No newline at end of file +/* @@? 23:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 23:36 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/generic_lambda_err2.ets b/ets2panda/test/ast/parser/ets/generic_lambda_err2.ets index 6cca2895ebf3df8e30a4096ada6416423fdb13df..1a4ca53eb838d095b223a3775e94056ace0209e7 100644 --- a/ets2panda/test/ast/parser/ets/generic_lambda_err2.ets +++ b/ets2panda/test/ast/parser/ets/generic_lambda_err2.ets @@ -18,7 +18,7 @@ function main() { foo1("1", 2) foo1("1", 2) - let foo2 = (p: T): T! =>p; + let foo2 = (p: T): NonNullable =>p; let foo3 = (p: T): T => p; @@ -32,7 +32,7 @@ function main() { /* @@? 18:5 Error TypeError: No matching call signature for ("1", Int) */ /* @@? 19:5 Error TypeError: Expected 1 type arguments, got 2 . */ /* @@? 19:5 Error TypeError: No matching call signature for ("1", Int) */ -/* @@? 21:32 Error TypeError: Type 'T' is not compatible with the enclosing method's return type 'NonNullable' */ +/* @@? 21:44 Error TypeError: Type 'T' is not compatible with the enclosing method's return type 'NonNullable' */ /* @@? 23:20 Error TypeError: Duplicate type parameter 'T'. */ /* @@? 26:5 Error TypeError: Expected 2 arguments, got 1. */ /* @@? 26:5 Error TypeError: No matching call signature for (Int) */ diff --git a/ets2panda/test/ast/parser/ets/generic_type_alias_clone_fix.ets b/ets2panda/test/ast/parser/ets/generic_type_alias_clone_fix.ets index 661d448ab5e739ba97f88096f633d38ebf7d30e9..b3b1333ceefea9271b7c62ad021d0ff1f1e39602 100644 --- a/ets2panda/test/ast/parser/ets/generic_type_alias_clone_fix.ets +++ b/ets2panda/test/ast/parser/ets/generic_type_alias_clone_fix.ets @@ -21,11 +21,6 @@ type RecordMap = { n: number }; let myMap: MyMap<"n"> = { kind: "n" }; -/* Expected errors - these should NOT cause assertion failures or crashes: */ /* @@? 16:37 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 16:41 Error SyntaxError: Invalid Type. */ -/* @@? 17:11 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 17:11 Error TypeError: Unresolved reference K */ -/* @@? 20:18 Error SyntaxError: Invalid Type. */ -/* @@? 20:23 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 20:23 Error TypeError: Type name 'number' used in the wrong context */ \ No newline at end of file +/* @@? 16:41 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 20:18 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ diff --git a/ets2panda/test/ast/parser/ets/get_unexpected_void.ets b/ets2panda/test/ast/parser/ets/get_unexpected_void.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a698416952148b24f4b3c2561cf69d54104dd5e --- /dev/null +++ b/ets2panda/test/ast/parser/ets/get_unexpected_void.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024-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. + */ + +class SomeClass { + $_get (index: string, value: SomeClass) { } +} + +/* @@? 17:5 Error SyntaxError: The special predefined method '$_get' should have exactly one required parameter. */ +/* @@? 17:11 Error TypeError: 'The special predefined method '$_get' shouldn't have void return type. */ diff --git a/ets2panda/test/ast/parser/ets/global_const_vars4.ets b/ets2panda/test/ast/parser/ets/global_const_vars4.ets index f1d3d77aa9e8e3aadeaf80ed5fd67b0e33f99b77..7cc9886ebc6b5cb5cf5321c5c4dd6320e20ce637 100644 --- a/ets2panda/test/ast/parser/ets/global_const_vars4.ets +++ b/ets2panda/test/ast/parser/ets/global_const_vars4.ets @@ -14,14 +14,14 @@ */ class ABC { - public readonly /* @@ label */date: Date = new Date(); + public readonly date: Date = new Date(); constructor() { this.init() } private init(): void { - this.date = new Date(); + /* @@ label */this.date = new Date(); } public main(): void {} diff --git a/ets2panda/test/ast/parser/ets/import_no_empty_binding_list.ets b/ets2panda/test/ast/parser/ets/import_no_empty_binding_list.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd2ff3124f685c3e2ecc51514d1e4a27b8f41f38 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/import_no_empty_binding_list.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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 {/* @@ label1 */} /* @@ label2 */from /* @@ label3 */'module' + +/* @@@ label1 Error SyntaxError: Importing for side-effect only is prohibited! Please provide objects to be imported explicitly or use * to import all objects declared in the module! */ +/* @@@ label2 Error TypeError: Unresolved reference from */ +/* @@@ label3 Error SyntaxError: Unexpected token 'module'. */ diff --git a/ets2panda/test/ast/parser/ets/import_no_side_effect.ets b/ets2panda/test/ast/parser/ets/import_no_side_effect.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd4d80cab0b0de58957e3a3cec521d46be29cc37 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/import_no_side_effect.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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 /* @@ label1 */'module' + +/* @@@ label1 Error SyntaxError: Importing for side-effect only is prohibited! Please provide objects to be imported explicitly or use * to import all objects declared in the module! */ diff --git a/ets2panda/test/ast/parser/ets/import_tests/type/type_2.ets b/ets2panda/test/ast/parser/ets/import_tests/type/type_2.ets index aa88265896ace1057ed3c5b1512650ac2305064f..7cab79843aa6ea29448fdcacdafb4dc6a2275b8f 100644 --- a/ets2panda/test/ast/parser/ets/import_tests/type/type_2.ets +++ b/ets2panda/test/ast/parser/ets/import_tests/type/type_2.ets @@ -16,5 +16,3 @@ export class A {} export type {A as AA}; - -/* @@? 18:19 Error SyntaxError: Cannot export 'A', it was already exported. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/import_tests/type/type_3.ets b/ets2panda/test/ast/parser/ets/import_tests/type/type_3.ets index 0b9164b765f7c06ab2d9555a1be06ff19d4a9ea5..ea9cf69480b354a22de4ce154b6d7bd83b015012 100644 --- a/ets2panda/test/ast/parser/ets/import_tests/type/type_3.ets +++ b/ets2panda/test/ast/parser/ets/import_tests/type/type_3.ets @@ -19,5 +19,4 @@ class TestClass {} export {foo} export type {TestClass as foo} -/* @@? 20:14 Error SyntaxError: The given name 'foo' is already used in another export. */ -/* @@? 20:27 Error SyntaxError: The given name 'foo' is already used in another export. */ +/* @@? 20:14 Error SyntaxError: Cannot export two different names with the same export alias name 'foo'. */ diff --git a/ets2panda/test/ast/parser/ets/interface_ambient_indexer_2.ets b/ets2panda/test/ast/parser/ets/interface_ambient_indexer_2.ets index b8e57b5856ace9265904051f4df6c40303349890..6789f5f0985c114f39be7b3b0aaff4afdb74a515 100644 --- a/ets2panda/test/ast/parser/ets/interface_ambient_indexer_2.ets +++ b/ets2panda/test/ast/parser/ets/interface_ambient_indexer_2.ets @@ -17,4 +17,15 @@ declare interface A { [index : string]: string } -/* @@? 17:14 Error SyntaxError: Index type must be number in index signature. */ \ No newline at end of file +/* @@? 17:14 Error SyntaxError: Index type must be number in index signature. */ +/* @@? 17:14 Error SyntaxError: ] expected in index signature. */ +/* @@? 17:20 Error SyntaxError: An index signature must have a type annotation. */ +/* @@? 17:20 Error SyntaxError: Expected ':', got ']'. */ +/* @@? 17:20 Error SyntaxError: Invalid Type. */ +/* @@? 17:20 Error SyntaxError: Return type of index signature from exported class or interface need to be identifier. */ +/* @@? 17:20 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:20 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 17:21 Error SyntaxError: Identifier expected. */ +/* @@? 17:21 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:21 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 18:1 Error SyntaxError: Invalid Type. */ diff --git a/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets b/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets index 05540be90decdb67f05112134428cda9dd1abc45..589da49e760f1e3394d3d72d49cc066c66bae60c 100644 --- a/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets +++ b/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets @@ -55,14 +55,15 @@ function mdin() { let a = new A(); /* @@? 24:20 Error TypeError: Interface name 'I' used in the wrong context */ /* @@? 24:22 Error SyntaxError: Unexpected token '{'. */ /* @@? 25:4 Error TypeError: Unresolved reference reanstructor */ -/* @@? 26:19 Error SyntaxError: Unexpected token '�ls'. */ /* @@? 26:19 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 26:19 Error SyntaxError: Unexpected token '�ls'. */ /* @@? 27:5 Error SyntaxError: Unexpected token 'A'. */ /* @@? 27:7 Error SyntaxError: Unexpected token '{'. */ /* @@? 28:5 Error SyntaxError: Hard keyword 'constructor' cannot be used as identifier */ /* @@? 28:5 Error SyntaxError: Identifier expected, got 'constructor'. */ +/* @@? 28:16 Error SyntaxError: Invalid annotation name. */ /* @@? 28:19 Error SyntaxError: Annotations are not allowed on this type of declaration. */ /* @@? 29:18 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 31:2 Error SyntaxError: Unexpected token '*'. */ /* @@? 32:1 Error SyntaxError: Nested functions are not allowed. */ -/* @@? 69:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 70:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/invalid_object_expression.ets b/ets2panda/test/ast/parser/ets/invalid_object_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a7b52b85583f9176c23844e417e8b969944357cc --- /dev/null +++ b/ets2panda/test/ast/parser/ets/invalid_object_expression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + + +let obj: Record = { + [this.viewModel.ads] : 123 +} + +/* @@? 18:5 Error SyntaxError: Unexpected token. */ +/* @@? 18:6 Error SyntaxError: Unexpected token. */ +/* @@? 18:6 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 18:11 Error TypeError: Property 'viewModel' does not exist on type 'Error' */ +/* @@? 18:24 Error SyntaxError: Unexpected token. */ +/* @@? 18:26 Error SyntaxError: Unexpected token ':'. */ +/* @@? 18:28 Error SyntaxError: Unexpected token '123'. */ +/* @@? 19:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets b/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets new file mode 100644 index 0000000000000000000000000000000000000000..2eba0019b69d4a8da790cfad2bc98cd8fa23d3cc --- /dev/null +++ b/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +interface I { +J* @@? +} + +/* @@? 17:2 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 17:4 Error SyntaxError: Unexpected token '@@'. */ +/* @@? 17:4 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:4 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 17:6 Error SyntaxError: Identifier expected. */ +/* @@? 17:6 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:6 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 18:1 Error SyntaxError: Identifier expected. */ diff --git a/ets2panda/test/ast/parser/ets/invalid_recursive_generic_union_type.ets b/ets2panda/test/ast/parser/ets/invalid_recursive_generic_union_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbe7b44619d089abe9afdc7f092b9894a39d2a67 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/invalid_recursive_generic_union_type.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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. + */ + +// Recursive generic union type test case migrated for ArkTS 1.2 + +// ArkTS does not support recursive type aliases or type declarations inside namespaces. +// We flatten the structure and define types globally to avoid unsupported features. + +type Container = T | { [i: string]: Container }; + +declare namespace Test1 { +} + +/* @@? 21:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 21:28 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 21:49 Error SyntaxError: Unexpected token '<'. */ +/* @@? 21:51 Error SyntaxError: Field type annotation expected. */ +/* @@? 21:51 Error SyntaxError: Unexpected token '>'. */ diff --git a/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets b/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets index da4139c843567afddecb1a1a2fdbe69e620823ab..763dbf30f6cef41fb6af13babf263fcc9ff70b47 100644 --- a/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets +++ b/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets @@ -20,11 +20,7 @@ flags: [dynamic-ast] type Point = { x: number; y: number }; type AxeX = Point['x']; -/* @@? 20:18 Error SyntaxError: Invalid Type. */ -/* @@? 20:23 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 20:23 Error TypeError: Type name 'number' used in the wrong context */ -/* @@? 20:34 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 20:34 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 20:18 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 21:23 Error SyntaxError: Unexpected token, expected ']'. */ /* @@? 21:23 Error SyntaxError: Unexpected token ']'. */ -/* @@? 21:26 Error SyntaxError: Unexpected token ']'. */ +/* @@? 21:26 Error SyntaxError: Unexpected token ']'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/labelled_for_of.ets b/ets2panda/test/ast/parser/ets/labelled_for_of.ets new file mode 100644 index 0000000000000000000000000000000000000000..882614cc8d9da10302208bec0ef343e56a12aa09 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/labelled_for_of.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024-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. + */ + +function foo(){ + let arr1: int[] = [0,1,2] + loop1: for(let y of arr1){ + continue loop1; + } +} diff --git a/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_1.ets b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..e61d3b64e18f2ae1fdbf8dd176330282ad870078 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_1.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 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. + */ + +let fn = ( + str1: String, + str2: String, + str3: String, + str4: String, + str5: String, + str6: String, + str7: String, + str8: String, + str9: String, + str10: String, + str11: String, + str12: String, + str13: String, + str14: String, + str15: String, + str16: String, + str17: String, + str18: String +): void => { }; + + +function main(): void { + fn("hello", "world", "!", "!", "!", "!", "!", "!", "!"); +} + +/* @@? 39:4 Error TypeError: Expected 18 arguments, got 9. */ +/* @@? 39:4 Error TypeError: No matching call signature for ("hello", "world", "!", "!", "!", "!", "!", "!", "!") */ diff --git a/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_2.ets b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..74e21ab03d5558bbf38dbb1531d60a689c876d47 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_2.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 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. + */ + +let fn = ( + str1: String, + str2: String, + str3: String, + str4: String, + str5: String, + str6: String, + str7: String, + str8: String, + str9: String, + str10: String, + str11: String, + str12: String, + str13: String, + str14: String, + str15: String, + str16: String, + str17: String, + str18: String +): void => { }; + + +function main(): void { + fn("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!"); +} + +/* @@? 39:4 Error TypeError: Expected 18 arguments, got 23. */ +/* @@? 39:4 Error TypeError: No matching call signature for ("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!") */ diff --git a/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_3.ets b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..20dbdd881835be56fa509ea3fd69eeb28e5e0779 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_3.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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. + */ + +let fn = ( + str1: String, + str2: String, + str3: String, + str4: String, + str5: String, + str6: String, + str7: String, + str8: String, + str9: String, + str10: String, + str11: String, + str12: String, + str13: String, + str14: String, + str15: String, + str16: String, + str17?: String +): void => { }; + + +function main(): void { + fn("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!"); +} + +/* @@? 38:4 Error TypeError: Expected 16 arguments, got 18. */ +/* @@? 38:4 Error TypeError: No matching call signature for ("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!") */ diff --git a/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_4.ets b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_4.ets new file mode 100644 index 0000000000000000000000000000000000000000..57d60ac87968e7cfe94451d0a83aaf3642e33e76 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_4.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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. + */ + +let fn = ( + str1: String, + str2: String, + str3: String, + str4: String, + str5: String, + str6: String, + str7: String, + str8: String, + str9: String, + str10: String, + str11: String, + str12: String, + str13: String, + str14: String, + str15: String, + str16: String, + str17?: String +): void => { }; + + +function main(): void { + fn("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!"); +} + +/* @@? 38:4 Error TypeError: Expected 16 arguments, got 15. */ +/* @@? 38:4 Error TypeError: No matching call signature for ("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!") */ diff --git a/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_5.ets b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_5.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c97a6f8c33f3c0dffa2bb401e2ca78bd87957a6 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_n/lambda_n_too_many_arg_neg_5.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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. + */ + +let fn = ( + str1: String, + str2: String, + str3: String, + str4: String, + str5: String, + str6: String, + str7: String, + str8: String, + str9: String, + str10: String, + str11: String, + str12: String, + str13: String, + str14: String, + str15: String, + str16: String, + str17: String, + ...restStr: String[] +): void => { }; + +function main(): void { + fn("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!"); +} + +/* @@? 38:4 Error TypeError: Expected 17 arguments, got 15. */ +/* @@? 38:4 Error TypeError: No matching call signature for ("hello", "world", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!", "!") */ diff --git a/ets2panda/test/ast/parser/ets/namespace_bad_token.ets b/ets2panda/test/ast/parser/ets/namespace_bad_token.ets index 2b279dceae922adf414b83d7989d4b169ba60f3e..5576913d3324f063cc44624d95b259aba988a9d9 100644 --- a/ets2panda/test/ast/parser/ets/namespace_bad_token.ets +++ b/ets2panda/test/ast/parser/ets/namespace_bad_token.ets @@ -17,5 +17,5 @@ declare namespace uiObserver { function on(options: { a: number }, callback: ): void; } -/* @@? 17:26 Error SyntaxError: Invalid Type. */ +/* @@? 17:26 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 17:51 Error SyntaxError: Invalid Type. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/no-call-signatures.ets b/ets2panda/test/ast/parser/ets/no-call-signatures.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2758cb7fc4ea4903d2c84301c56126f491bd424 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/no-call-signatures.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 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. + */ + +class DescribableFunction { + description: string + /* @@ label */(someArg: number): string { + return someArg.toString() + } +} +function doSomething(fn: DescribableFunction) { + fn(6) +} + +/* @@@ label Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ +/* @@? 23:5 Error TypeError: No static $_invoke method and static $_instantiate method in fn. fn() is not allowed. */ +/* @@? 23:5 Error TypeError: Type 'DescribableFunction' has no call signatures. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/no-constructor-signatures.ets b/ets2panda/test/ast/parser/ets/no-constructor-signatures.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0f5d9193ac71e92920c8f2f80fed687db5ff02f --- /dev/null +++ b/ets2panda/test/ast/parser/ets/no-constructor-signatures.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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. + */ + +class SomeObject {} +class SomeConstructor { + new (s: string): SomeObject +} +function fn(ctor: SomeConstructor) { + return new ctor("hello") +} + +/* @@? 18:7 Error SyntaxError: Constructor signatures in object types are not supported. Use '$_invoke' method instead. */ +/* @@? 21:14 Error TypeError: Cannot find type 'ctor'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/no_prototype.ets b/ets2panda/test/ast/parser/ets/no_prototype.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f70cb7112e9d176b0c326e6865da24e13facf2e --- /dev/null +++ b/ets2panda/test/ast/parser/ets/no_prototype.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ + +class C {} + +C.prototype = Object.prototype + +C.prototype = { + m() { + console.log("C.m()") + } +} + +/* @@? 18:3 Error TypeError: Property 'prototype' does not exist on type 'C' */ +/* @@? 18:13 Error SyntaxError: Runtime prototype assignment is not supported because of static typing */ +/* @@? 18:22 Error TypeError: Property 'prototype' does not exist on type 'Object' */ +/* @@? 20:1 Error SyntaxError: Runtime prototype assignment is not supported because of static typing */ +/* @@? 20:3 Error TypeError: Property 'prototype' does not exist on type 'C' */ +/* @@? 20:13 Error SyntaxError: Runtime prototype assignment is not supported because of static typing */ +/* @@? 21:4 Error SyntaxError: Unexpected token, expected ':'. */ +/* @@? 21:5 Error SyntaxError: Unexpected token ')'. */ +/* @@? 21:7 Error SyntaxError: Unexpected token. */ +/* @@? 22:12 Error SyntaxError: Unexpected token, expected ':'. */ +/* @@? 24:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/nolint_bad.ets b/ets2panda/test/ast/parser/ets/nolint_bad.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4aa54d09744e878c4403a61fc3792f11e0aa11d --- /dev/null +++ b/ets2panda/test/ast/parser/ets/nolint_bad.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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. + */ + + +// ETSNOLINT(definitely-not-a-real-etsnolint-argument) +// ETSNOLINT(@) +function main() {} +/* @@? 1:3 Error SyntaxError: Invalid argument for ETSNOLINT! */ +/* @@? 1:3 Error SyntaxError: Unexpected character for ETSNOLINT argument! [VALID ONLY: a-z, '-']. */ +/* @@? 1:3 Error SyntaxError: Invalid argument for ETSNOLINT! */ diff --git a/ets2panda/test/ast/parser/ets/non-ambient_call_signature.ets b/ets2panda/test/ast/parser/ets/non-ambient_call_signature.ets index a61d358039ad25a947fa017048732fd46b03ca46..ede2ed654fee6430d96ff7c4d0020330910bf925 100644 --- a/ets2panda/test/ast/parser/ets/non-ambient_call_signature.ets +++ b/ets2panda/test/ast/parser/ets/non-ambient_call_signature.ets @@ -14,10 +14,7 @@ */ class A{ - /* @@ label */(a:number/* @@ label1 */)/* @@ label2 */:number + /* @@ label */(a:number) :number } -/* @@@ label Error SyntaxError: Unexpected token '('. */ -/* @@@ label1 Error SyntaxError: Unexpected token ')'. */ -/* @@@ label2 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:60 Error SyntaxError: number is a predefined type, cannot be used as an identifier */ +/* @@@ label Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ diff --git a/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-arg.ets b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-arg.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f8f222ce1e5c93af33ed56be2b6b643d3d96e7b --- /dev/null +++ b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-arg.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + */ + +function foo(arr: readonly int[]) { + arr./* @@ extendTo */extendTo(2, 0); + arr./* @@ shrinkTo */shrinkTo(2); + arr./* @@ sort */sort(); + arr./* @@ shift */shift(); + arr./* @@ pop */pop(); + arr./* @@ push */push(2, 3); + arr./* @@ pushECMA */pushECMA(4, 5); + arr./* @@ splice */splice(0,1,2,3); + arr./* @@ unshift */unshift(-1); + arr./* @@ copyWithin */copyWithin(0,0,0); + arr./* @@ fill */fill(3); + arr./* @@ toSpliced */toSpliced(); + arr./* @@ reverse */reverse(); + arr./* @@ with */with(0, 5); +} + +/* @@@ extendTo Error TypeError: Property 'extendTo' does not exist on type 'ReadonlyArray' */ +/* @@@ shrinkTo Error TypeError: Property 'shrinkTo' does not exist on type 'ReadonlyArray' */ +/* @@@ sort Error TypeError: Property 'sort' does not exist on type 'ReadonlyArray' */ +/* @@@ shift Error TypeError: Property 'shift' does not exist on type 'ReadonlyArray' */ +/* @@@ pop Error TypeError: Property 'pop' does not exist on type 'ReadonlyArray' */ +/* @@@ push Error TypeError: Property 'push' does not exist on type 'ReadonlyArray' */ +/* @@@ pushECMA Error TypeError: Property 'pushECMA' does not exist on type 'ReadonlyArray' */ +/* @@@ splice Error TypeError: Property 'splice' does not exist on type 'ReadonlyArray' */ +/* @@@ unshift Error TypeError: Property 'unshift' does not exist on type 'ReadonlyArray' */ +/* @@@ copyWithin Error TypeError: Property 'copyWithin' does not exist on type 'ReadonlyArray' */ +/* @@@ fill Error TypeError: Property 'fill' does not exist on type 'ReadonlyArray' */ +/* @@@ toSpliced Error TypeError: Property 'toSpliced' does not exist on type 'ReadonlyArray' */ +/* @@@ reverse Error TypeError: Property 'reverse' does not exist on type 'ReadonlyArray' */ +/* @@@ with Error TypeError: Property 'with' does not exist on type 'ReadonlyArray' */ diff --git a/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-field.ets b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-field.ets new file mode 100644 index 0000000000000000000000000000000000000000..49c10b6b192d71f2db90cc26672ea9b611a49505 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-field.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 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. + */ + +class A { + arr: readonly int[] = [1]; + foo() { + this.arr./* @@ extendTo */extendTo(2, 0); + this.arr./* @@ shrinkTo */shrinkTo(2); + this.arr./* @@ sort */sort(); + this.arr./* @@ shift */shift(); + this.arr./* @@ pop */pop(); + this.arr./* @@ push */push(2, 3); + this.arr./* @@ pushECMA */pushECMA(4, 5); + this.arr./* @@ splice */splice(0,1,2,3); + this.arr./* @@ unshift */unshift(-1); + this.arr./* @@ copyWithin */copyWithin(0,0,0); + this.arr./* @@ fill */fill(3); + this.arr./* @@ toSpliced */toSpliced(); + this.arr./* @@ reverse */reverse(); + this.arr./* @@ with */with(0, 5); + } +} + +/* @@@ extendTo Error TypeError: Property 'extendTo' does not exist on type 'ReadonlyArray' */ +/* @@@ shrinkTo Error TypeError: Property 'shrinkTo' does not exist on type 'ReadonlyArray' */ +/* @@@ sort Error TypeError: Property 'sort' does not exist on type 'ReadonlyArray' */ +/* @@@ shift Error TypeError: Property 'shift' does not exist on type 'ReadonlyArray' */ +/* @@@ pop Error TypeError: Property 'pop' does not exist on type 'ReadonlyArray' */ +/* @@@ push Error TypeError: Property 'push' does not exist on type 'ReadonlyArray' */ +/* @@@ pushECMA Error TypeError: Property 'pushECMA' does not exist on type 'ReadonlyArray' */ +/* @@@ splice Error TypeError: Property 'splice' does not exist on type 'ReadonlyArray' */ +/* @@@ unshift Error TypeError: Property 'unshift' does not exist on type 'ReadonlyArray' */ +/* @@@ copyWithin Error TypeError: Property 'copyWithin' does not exist on type 'ReadonlyArray' */ +/* @@@ fill Error TypeError: Property 'fill' does not exist on type 'ReadonlyArray' */ +/* @@@ toSpliced Error TypeError: Property 'toSpliced' does not exist on type 'ReadonlyArray' */ +/* @@@ reverse Error TypeError: Property 'reverse' does not exist on type 'ReadonlyArray' */ +/* @@@ with Error TypeError: Property 'with' does not exist on type 'ReadonlyArray' */ diff --git a/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-var.ets b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-var.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf24504eaaf22b79febf30b73510b592238fe115 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/readonly-array/readonly-array-var.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + */ + +let arr: readonly int[] = [1]; + +arr./* @@ extendTo */extendTo(2, 0); +arr./* @@ shrinkTo */shrinkTo(2); +arr./* @@ sort */sort(); +arr./* @@ shift */shift(); +arr./* @@ pop */pop(); +arr./* @@ push */push(2, 3); +arr./* @@ pushECMA */pushECMA(4, 5); +arr./* @@ splice */splice(0,1,2,3); +arr./* @@ unshift */unshift(-1); +arr./* @@ copyWithin */copyWithin(0,0,0); +arr./* @@ fill */fill(3); +arr./* @@ toSpliced */toSpliced(); +arr./* @@ reverse */reverse(); +arr./* @@ with */with(0, 5); + +/* @@@ extendTo Error TypeError: Property 'extendTo' does not exist on type 'ReadonlyArray' */ +/* @@@ shrinkTo Error TypeError: Property 'shrinkTo' does not exist on type 'ReadonlyArray' */ +/* @@@ sort Error TypeError: Property 'sort' does not exist on type 'ReadonlyArray' */ +/* @@@ shift Error TypeError: Property 'shift' does not exist on type 'ReadonlyArray' */ +/* @@@ pop Error TypeError: Property 'pop' does not exist on type 'ReadonlyArray' */ +/* @@@ push Error TypeError: Property 'push' does not exist on type 'ReadonlyArray' */ +/* @@@ pushECMA Error TypeError: Property 'pushECMA' does not exist on type 'ReadonlyArray' */ +/* @@@ splice Error TypeError: Property 'splice' does not exist on type 'ReadonlyArray' */ +/* @@@ unshift Error TypeError: Property 'unshift' does not exist on type 'ReadonlyArray' */ +/* @@@ copyWithin Error TypeError: Property 'copyWithin' does not exist on type 'ReadonlyArray' */ +/* @@@ fill Error TypeError: Property 'fill' does not exist on type 'ReadonlyArray' */ +/* @@@ toSpliced Error TypeError: Property 'toSpliced' does not exist on type 'ReadonlyArray' */ +/* @@@ reverse Error TypeError: Property 'reverse' does not exist on type 'ReadonlyArray' */ +/* @@@ with Error TypeError: Property 'with' does not exist on type 'ReadonlyArray' */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/Readonly-with-ArrayType-test2.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/Readonly-with-ArrayType-test2.ets index 7656872082259533c237005afc004ffbbcc3a816..e6e6e1759a06268cdcf5e6961f14950d7523c259 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/Readonly-with-ArrayType-test2.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/Readonly-with-ArrayType-test2.ets @@ -16,8 +16,9 @@ function foo (p: [int, string]) { } -let x: Readonly<[int, string]> = [] +let x: Readonly<[int, string]> = /* @@ label2 */[] /* @@ label */foo(/* @@ label1 */x) /* @@@ label1 Error TypeError: Type 'readonly [Int, String]' is not compatible with type '[Int, String]' at index 1 */ /* @@@ label Error TypeError: No matching call signature for foo(readonly [Int, String]) */ +/* @@@ label2 Error TypeError: Initializer has 0 elements, but tuple requires 2 */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test1.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test1.ets index 001e6dd5d9710dbb0a5fc110ccaadf2d144a3328..900402788108baae0efb5e44956f959fefaff1d1 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test1.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test1.ets @@ -14,11 +14,11 @@ */ -function foo (tuple: Readonly<[number, string, boolean]>, arr: Readonly) { +function foo (tuple: Readonly<[number, string, boolean]>, arr: ReadonlyArray) { } /* @@ label */function foo (tuple: readonly [number, string, boolean], arr: readonly int[]) { } -/* @@@ label Error TypeError: Function foo is already declared. */ +/* @@@ label Error TypeError: Function foo is already declared. */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test2.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test2.ets index e6ae30bc89f9baeffac599e4b3ebdb70b49346a2..9a5de252bdd79888be26407a19c118c2a251e65e 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test2.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-and-Readonly-test2.ets @@ -35,13 +35,13 @@ let x2 : Readonly = [0] let y2 : Readonly<[int, string]> /* @@ label9 */y2[1] = "b" -/* @@@ label6 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ -/* @@@ label7 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ -/* @@@ label8 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ -/* @@@ label9 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ -/* @@@ label Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ +/* @@@ label Error TypeError: Object type doesn't have proper index access method. */ /* @@@ label1 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ /* @@@ label2 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ /* @@@ label3 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ /* @@@ label4 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ /* @@@ label5 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ +/* @@@ label6 Error TypeError: Object type doesn't have proper index access method. */ +/* @@@ label7 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ +/* @@@ label8 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ +/* @@@ label9 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test3.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test3.ets index 2f156db7ce45ce245e336738222b1096fb5f5e6a..c19b5d8a1349594e581ffd05eb71434c29de9991 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test3.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test3.ets @@ -18,4 +18,4 @@ function foo (x: readonly int[]) { let x1 : int[] x1 = /* @@ label */x } -/* @@@ label Error TypeError: Type 'readonly Array' cannot be assigned to type 'Array' */ +/* @@@ label Error TypeError: Type 'ReadonlyArray' cannot be assigned to type 'Array' */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test4.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test4.ets index 05c22e9061434d45780e0daafb8a0ceecf35cb4c..d65a0c683f791006671f22c7a9f684f16585f4b2 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test4.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test4.ets @@ -19,5 +19,5 @@ function foo (p: int[]) { let x: readonly int[] = [] /* @@ label */foo(/* @@ label1 */x) -/* @@@ label Error TypeError: No matching call signature for foo(readonly Array) */ -/* @@@ label1 Error TypeError: Type 'readonly Array' is not compatible with type 'Array' at index 1 */ +/* @@@ label Error TypeError: No matching call signature for foo(ReadonlyArray) */ +/* @@@ label1 Error TypeError: Type 'ReadonlyArray' is not compatible with type 'Array' at index 1 */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test5.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test5.ets index c070f2aba93e0138a6a8cce31b73688f519f8c67..1434abd64149fe606b64f3a8b78fe5129bd571d2 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test5.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test5.ets @@ -16,8 +16,9 @@ function foo (p: [int, string]) { } -let x: readonly [int, string] = [] +let x: readonly [int, string] = /* @@ label2 */[] /* @@ label */foo(/* @@ label1 */x) /* @@@ label Error TypeError: No matching call signature for foo(readonly [Int, String]) */ /* @@@ label1 Error TypeError: Type 'readonly [Int, String]' is not compatible with type '[Int, String]' at index 1 */ +/* @@@ label2 Error TypeError: Initializer has 0 elements, but tuple requires 2 */ diff --git a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test6.ets b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test6.ets index 7747ed37497d5c09ab361de2e6b4102a290679cb..a792cb4bdde514333c1ea69eeae3a2f9c4bcc683 100644 --- a/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test6.ets +++ b/ets2panda/test/ast/parser/ets/readonly-parameter-test/readonly-parameter-test6.ets @@ -27,5 +27,5 @@ let arr = foo1() let tuple = foo2() /* @@ label1 */tuple[1] = "c" -/* @@@ label Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ +/* @@@ label Error TypeError: Object type doesn't have proper index access method. */ /* @@@ label1 Error TypeError: Cannot modify an array or tuple content that has the readonly parameter */ diff --git a/ets2panda/test/ast/parser/ets/readonly_reference_CTE_err_elimilate.ets b/ets2panda/test/ast/parser/ets/readonly_reference_CTE_err_elimilate.ets index 7452c971205878f7d592b5a637eda01237f0ed65..435c77d20aaa0727515fb8496a8b59e5cdaa12c6 100644 --- a/ets2panda/test/ast/parser/ets/readonly_reference_CTE_err_elimilate.ets +++ b/ets2panda/test/ast/parser/ets/readonly_reference_CTE_err_elimilate.ets @@ -14,7 +14,7 @@ */ class A { - /* @@ label */x: int = 444 + x: int = 444 } let changeAbleVar = new A(); @@ -22,7 +22,7 @@ let changeAbleVar = new A(); changeAbleVar.x=333 function bar(a:Readonly){ - /* @@ label2 */a.x=111 + /* @@ label */a.x=111 console.log(a) } @@ -30,4 +30,4 @@ bar(changeAbleVar) /* @@@ label Error TypeError: Cannot assign to a readonly variable x */ -/* @@@ label2 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@@ label Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets b/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets index 90fd2ccf79feb2a813546efb8a3f8747385cac3b..25e4a6d0eaaf25483db83cdaaa5298e7e0b37bf2 100644 --- a/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets +++ b/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets @@ -88,7 +88,7 @@ const _exported: ExportedType = _exportedStructure; export default _exported; -/* @@? 26:26 Error SyntaxError: Invalid Type. */ +/* @@? 26:26 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 41:12 Error TypeError: No matching call signature for (...) */ /* @@? 41:23 Error TypeError: need to specify target type for class composite */ /* @@? 54:20 Error TypeError: No matching call signature for (...) */ diff --git a/ets2panda/test/ast/parser/ets/segmentation_fault_test1.ets b/ets2panda/test/ast/parser/ets/segmentation_fault_test1.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5e9ad05f304c09b03cb90a973e47c8b9efd1113 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/segmentation_fault_test1.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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. + */ + +function A(a: string) { + let b = /* @@ label */c.a; + switch (a) { + case b: + case "aa": + } +} + +/* @@@ label Error TypeError: Unresolved reference c */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/set_unexpected_nonvoid.ets b/ets2panda/test/ast/parser/ets/set_unexpected_nonvoid.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7e6f36d169ddfde8cb64ddeddccbfeb788108a2 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/set_unexpected_nonvoid.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024-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. + */ + +class SomeClass { + $_set (index: string): SomeClass { return this } +} + +/* @@? 17:5 Error SyntaxError: The special predefined method '$_set' should have exactly two required parameter. */ +/* @@? 17:11 Error TypeError: 'The special predefined method '$_set' should have void return type. */ diff --git a/ets2panda/test/ast/parser/ets/setter_with_return_type.ets b/ets2panda/test/ast/parser/ets/setter_with_return_type.ets index 6764147803fa861c6a9a0c05fc769cbc9baac076..f0423da780a3e6082a00e8ad41abcf57f8fe0940 100644 --- a/ets2panda/test/ast/parser/ets/setter_with_return_type.ets +++ b/ets2panda/test/ast/parser/ets/setter_with_return_type.ets @@ -25,4 +25,4 @@ interface I{ class D extends C implements I{ } -/* @@? 22:10 Error SyntaxError: Setter must not have return type even if it is void. */ +/* @@? 22:9 Error SyntaxError: Setter must not have return type even if it is void. */ diff --git a/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_1.ets b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..26483b2780137c4e697099b19173c07c0e83d3ab --- /dev/null +++ b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_1.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 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. + */ + +function foo(x: number) { + console.log(x) +} +let args_tuple: [number, number] = [0, 1] +/* @@ label1 */foo(1, ...args_tuple) +let args_array: number[] = [2, 3] +/* @@ label2 */foo(4, ...args_array) + +/* @@@ label1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label1 Error TypeError: No matching call signature for foo(Int, [Double, Double]) */ +/* @@@ label2 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label2 Error TypeError: No matching call signature for foo(Int, Double) */ diff --git a/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_2.ets b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5407b76f91f8ed4787688a74ea581267c105884 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_2.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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. + */ + +function foo(x: number) { + console.log(x) +} +let args_tuple: [number, number] = [0, 1] +/* @@ label1 */foo(...args_tuple) +let args_array: number[] = [2, 3] +/* @@ label2 */foo(...args_array) + +function moo(x: number, y: number) { + console.log(x, y) +} +args_tuple = [0, 1] +/* @@ label3 */moo(1, ...args_tuple) +args_array = [2, 3] +/* @@ label4 */moo(2, ...args_array) + +/* @@@ label1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label1 Error TypeError: No matching call signature for foo([Double, Double]) */ +/* @@@ label2 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label2 Error TypeError: No matching call signature for foo(Double) */ +/* @@@ label3 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label3 Error TypeError: No matching call signature for moo(Int, [Double, Double]) */ +/* @@@ label4 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label4 Error TypeError: No matching call signature for moo(Int, Double) */ diff --git a/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_3.ets b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..89d5215fd1226415488589ea8be4a8376171f4aa --- /dev/null +++ b/ets2panda/test/ast/parser/ets/spread_parameter_only_with_rest_3.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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. + */ + +function foo(x: number, y: number) { + console.log(x, y) +} +let args_tuple: [number, number] = [0, 1] +/* @@ label1 */foo(...args_tuple) +let args_array: number[] = [2, 3] +/* @@ label2 */foo(...args_array) + +function moo(x: number, y: number, z: number) { + console.log(x, y, z) +} +args_tuple = [0, 1] +/* @@ label3 */moo(1, ...args_tuple) +args_array = [2, 3] +/* @@ label4 */moo(2, ...args_array) + +/* @@@ label1 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label1 Error TypeError: No matching call signature for foo([Double, Double]) */ +/* @@@ label2 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label2 Error TypeError: No matching call signature for foo(Double) */ +/* @@@ label3 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label3 Error TypeError: No matching call signature for moo(Int, [Double, Double]) */ +/* @@@ label4 Error TypeError: The function or method being called needs a rest parameter to accept arguments passed via the spread operator. */ +/* @@@ label4 Error TypeError: No matching call signature for moo(Int, Double) */ diff --git a/ets2panda/test/ast/parser/ets/spreadexpr_in_newexpr_neg01.ets b/ets2panda/test/ast/parser/ets/spreadexpr_in_newexpr_neg01.ets index 2a6b971d872d7eac87a6a3dfe1b4be0454b952f7..346e038a118c139cdee0e38a75a5b3360deb2467 100644 --- a/ets2panda/test/ast/parser/ets/spreadexpr_in_newexpr_neg01.ets +++ b/ets2panda/test/ast/parser/ets/spreadexpr_in_newexpr_neg01.ets @@ -33,6 +33,5 @@ function main() { /* @@? 19:9 Error SyntaxError: Unexpected token 'this'. */ /* @@? 19:13 Error SyntaxError: Unexpected token '.'. */ /* @@? 19:14 Error TypeError: Variable 'fld' has already been declared. */ -/* @@? 19:14 Error TypeError: Property 'fld' must be accessed through 'this' */ /* @@? 19:20 Error TypeError: Unresolved reference p */ -/* @@? 21:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 21:1 Error SyntaxError: Unexpected token '}'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/tuple_trailing_comma.ets b/ets2panda/test/ast/parser/ets/tuple_trailing_comma.ets index 7cfc6830a2aadcdfb0412fd79e7cecba7a84895f..093fa956bef06456fa83008ef6028cf71a8b2ebf 100644 --- a/ets2panda/test/ast/parser/ets/tuple_trailing_comma.ets +++ b/ets2panda/test/ast/parser/ets/tuple_trailing_comma.ets @@ -28,4 +28,3 @@ let b: [number, /* @@ label */,number, number,] = [1, 2, 3,]; /* @@? 17:34 Error SyntaxError: Unexpected token ','. */ /* @@? 17:35 Error SyntaxError: Unexpected token ']'. */ /* @@@ label Error SyntaxError: Invalid Type. */ -/* @@? 18:51 Error TypeError: Initializer has 3 elements, but tuple requires 4 */ diff --git a/ets2panda/test/ast/parser/ets/type_node_clone_assertion_fix.ets b/ets2panda/test/ast/parser/ets/type_node_clone_assertion_fix.ets index d28120b38d17af8f5663e90155adf747b3998d20..911938c62612630527a555580a31ace6a126b3d1 100644 --- a/ets2panda/test/ast/parser/ets/type_node_clone_assertion_fix.ets +++ b/ets2panda/test/ast/parser/ets/type_node_clone_assertion_fix.ets @@ -27,9 +27,5 @@ type RecordMap = { n: number }; // Expected compilation errors for unsupported TypeScript features in ETS: /* @@? 22:37 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 22:41 Error SyntaxError: Invalid Type. */ -/* @@? 23:11 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 23:11 Error TypeError: Unresolved reference K */ -/* @@? 26:18 Error SyntaxError: Invalid Type. */ -/* @@? 26:23 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 26:23 Error TypeError: Type name 'number' used in the wrong context */ \ No newline at end of file +/* @@? 22:41 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 26:18 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/type_references.ets b/ets2panda/test/ast/parser/ets/type_references.ets index a5db99d97c59ca2ae43d7fdb141ac2ab237c1c14..4659ad2318d3ba2c6233d479ebf8516b534424c4 100644 --- a/ets2panda/test/ast/parser/ets/type_references.ets +++ b/ets2panda/test/ast/parser/ets/type_references.ets @@ -20,14 +20,4 @@ let y: G<{a:String}, B> // Error /* @@? 18:8 Error TypeError: Cannot find type 'G'. */ /* @@? 19:8 Error TypeError: Cannot find type 'G'. */ -/* @@? 19:10 Error SyntaxError: Invalid Type. */ -/* @@? 19:10 Error SyntaxError: Unexpected token, expected '>'. */ -/* @@? 19:10 Error SyntaxError: Unexpected token '>'. */ -/* @@? 19:11 Error SyntaxError: Unexpected token 'a'. */ -/* @@? 19:13 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 19:13 Error SyntaxError: Class cannot be used as object. */ -/* @@? 19:19 Error SyntaxError: Unexpected token '}'. */ -/* @@? 19:20 Error SyntaxError: Unexpected token ','. */ -/* @@? 19:22 Error SyntaxError: Unexpected token 'B'. */ -/* @@? 19:22 Error TypeError: Type name 'B' used in the wrong context */ -/* @@? 34:1 Error SyntaxError: Unexpected token 'end of stream'. */ +/* @@? 19:10 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ diff --git a/ets2panda/test/ast/parser/ets/typenode_clone_brokentype.ets b/ets2panda/test/ast/parser/ets/typenode_clone_brokentype.ets index f955112a64a8c9d36e78da0b629073b7b607e670..3e8e77e5b8fbc7cde66c9be1a67e642743645bf5 100644 --- a/ets2panda/test/ast/parser/ets/typenode_clone_brokentype.ets +++ b/ets2panda/test/ast/parser/ets/typenode_clone_brokentype.ets @@ -39,21 +39,17 @@ type BrokenFunc = (param: T) => void; declare const broken1: BrokenType; declare const broken2: AnotherBroken; -/* Expected errors - these should NOT cause assertion failures or crashes: */ /* @@? 21:33 Error TypeError: Cannot find type 'UndefinedMap'. */ /* @@? 21:45 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 21:49 Error SyntaxError: Invalid Type. */ -/* @@? 22:11 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 22:11 Error TypeError: Unresolved reference K */ +/* @@? 21:49 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 26:36 Error TypeError: Cannot find type 'NonExistent'. */ /* @@? 26:47 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ /* @@? 27:27 Error TypeError: Cannot find type 'InvalidInterface'. */ -/* @@? 30:52 Error SyntaxError: Invalid Type. */ -/* @@? 31:13 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 30:52 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 31:14 Error SyntaxError: Unexpected token ','. */ -/* @@? 32:12 Error SyntaxError: Class cannot be used as object. */ -/* @@? 32:12 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 32:12 Error TypeError: Object type doesn't have proper index access method. */ +/* @@? 32:26 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 32:26 Error SyntaxError: Unexpected token ']'. */ +/* @@? 32:27 Error SyntaxError: Unexpected token ']'. */ /* @@? 36:27 Error TypeError: Cannot find type 'UndefinedInterface'. */ /* @@? 39:35 Error TypeError: Cannot find type 'any'. */ -/* @@? 40:38 Error TypeError: Cannot find type 'any'. */ \ No newline at end of file +/* @@? 40:38 Error TypeError: Cannot find type 'any'. */ diff --git a/ets2panda/test/ast/parser/ets/typenode_clone_comprehensive.ets b/ets2panda/test/ast/parser/ets/typenode_clone_comprehensive.ets index e3f3d7459d5343cfb766fb696909123331a969c7..069c51fb2f2b65c77959c4bb1af9b5001bce86c7 100644 --- a/ets2panda/test/ast/parser/ets/typenode_clone_comprehensive.ets +++ b/ets2panda/test/ast/parser/ets/typenode_clone_comprehensive.ets @@ -67,28 +67,19 @@ declare const test1: ComplexType<'n'>; declare const test2: ComplexType<'s'>; declare const test3: ComplexType<'b'>; -/* Expected errors (these are normal for ETS, but should not crash): */ -/* @@? 1:3 Error TypeError: Class 'UnionType' is already defined with different type. */ /* @@? 1:3 Error TypeError: Class 'TupleType' is already defined with different type. */ -/* @@? 21:19 Error SyntaxError: Invalid Type. */ -/* @@? 21:24 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 21:24 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 1:3 Error TypeError: Class 'UnionType' is already defined with different type. */ +/* @@? 21:19 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 21:30 Error SyntaxError: Unexpected token ','. */ -/* @@? 21:32 Error SyntaxError: Unexpected token 's'. */ -/* @@? 21:35 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 21:35 Error TypeError: Type name 'string' used in the wrong context */ /* @@? 21:41 Error SyntaxError: Unexpected token ','. */ -/* @@? 21:43 Error SyntaxError: Unexpected token 'b'. */ -/* @@? 21:46 Error SyntaxError: Unexpected token 'boolean'. */ -/* @@? 21:46 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 32:42 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ /* @@? 35:44 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 35:59 Error SyntaxError: Unexpected token ']'. */ /* @@? 35:59 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 35:59 Error SyntaxError: Unexpected token ']'. */ /* @@? 35:60 Error SyntaxError: Unexpected token ']'. */ /* @@? 38:19 Error TypeError: Cannot find type 'a'. */ -/* @@? 38:20 Error SyntaxError: Unexpected token, expected ',' or ']'. */ /* @@? 38:20 Error SyntaxError: Unexpected token ':'. */ +/* @@? 38:20 Error SyntaxError: Unexpected token, expected ',' or ']'. */ /* @@? 38:22 Error SyntaxError: Unexpected token 'number'. */ /* @@? 38:22 Error TypeError: Type name 'number' used in the wrong context */ /* @@? 38:28 Error SyntaxError: Unexpected token ','. */ @@ -96,45 +87,38 @@ declare const test3: ComplexType<'b'>; /* @@? 38:33 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 38:33 Error TypeError: Type name 'string' used in the wrong context */ /* @@? 38:39 Error SyntaxError: Unexpected token ']'. */ -/* @@? 41:19 Error SyntaxError: Invalid Type. */ -/* @@? 41:22 Error TypeError: Unresolved reference K */ -/* @@? 41:24 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 41:24 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 41:24 Error TypeError: Unresolved reference in */ -/* @@? 41:27 Error SyntaxError: Unexpected token 'keyof'. */ -/* @@? 41:27 Error TypeError: Unresolved reference keyof */ -/* @@? 41:33 Error SyntaxError: Unexpected token 'ObjectType'. */ -/* @@? 41:33 Error TypeError: Type name 'ObjectType' used in the wrong context */ +/* @@? 41:19 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 41:22 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 41:26 Error SyntaxError: Field type annotation expected. */ +/* @@? 41:32 Error SyntaxError: Field type annotation expected. */ /* @@? 41:43 Error SyntaxError: Unexpected token ']'. */ +/* @@? 41:43 Error SyntaxError: Field type annotation expected. */ /* @@? 41:44 Error SyntaxError: Unexpected token ':'. */ -/* @@? 41:46 Error SyntaxError: Unexpected token 'string'. */ -/* @@? 41:46 Error TypeError: Type name 'string' used in the wrong context */ +/* @@? 41:46 Error SyntaxError: string is a predefined type, cannot be used as an identifier */ /* @@? 44:41 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ /* @@? 44:60 Error SyntaxError: Unexpected token, expected ']'. */ /* @@? 54:34 Error TypeError: Cannot find type 'InvalidMap'. */ /* @@? 54:44 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 57:67 Error SyntaxError: Invalid Type. */ -/* @@? 58:11 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 57:45 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ +/* @@? 57:63 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ +/* @@? 57:67 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 58:12 Error SyntaxError: Unexpected token ','. */ -/* @@? 59:12 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 59:12 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 59:12 Error TypeError: Type name 'ObjectType' used in the wrong context */ +/* @@? 59:23 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 59:23 Error SyntaxError: Unexpected token ']'. */ +/* @@? 59:24 Error SyntaxError: Unexpected token ']'. */ /* @@? 59:25 Error SyntaxError: Unexpected token ','. */ -/* @@? 60:14 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 60:29 Error SyntaxError: Unexpected token, expected ']'. */ -/* @@? 60:36 Error SyntaxError: Unexpected token 'void'. */ /* @@? 60:40 Error SyntaxError: Unexpected token ','. */ -/* @@? 61:12 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 61:16 Error TypeError: Type name 'ObjectType' used in the wrong context */ -/* @@? 61:16 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 61:27 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 61:28 Error SyntaxError: Unexpected token ']'. */ +/* @@? 61:29 Error SyntaxError: Unexpected token ']'. */ /* @@? 61:30 Error SyntaxError: Unexpected token ','. */ -/* @@? 62:13 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 62:16 Error TypeError: Unresolved reference P */ -/* @@? 62:18 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 62:18 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 62:21 Error SyntaxError: Unexpected token 'K'. */ +/* @@? 62:13 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 62:16 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 62:20 Error SyntaxError: Field type annotation expected. */ /* @@? 62:22 Error SyntaxError: Unexpected token ']'. */ +/* @@? 62:22 Error SyntaxError: Field type annotation expected. */ /* @@? 62:23 Error SyntaxError: Unexpected token ':'. */ -/* @@? 62:25 Error SyntaxError: Unexpected token 'ObjectType'. */ -/* @@? 62:25 Error TypeError: Type name 'ObjectType' used in the wrong context */ -/* @@? 62:25 Error TypeError: Indexed access is not supported for such expression type. */ \ No newline at end of file +/* @@? 62:35 Error SyntaxError: Field type annotation expected. */ +/* @@? 62:36 Error TypeError: Indexed signatures are not allowed. Use arrays instead! */ +/* @@? 62:37 Error SyntaxError: Unexpected token ']'. */ diff --git a/ets2panda/test/ast/parser/ets/typenode_clone_primitives.ets b/ets2panda/test/ast/parser/ets/typenode_clone_primitives.ets index 19d5e3fed132ad6bca6c5ccef90ee6c703876f52..2cce27da50794b50a4af00d6506dadd9a932e9fd 100644 --- a/ets2panda/test/ast/parser/ets/typenode_clone_primitives.ets +++ b/ets2panda/test/ast/parser/ets/typenode_clone_primitives.ets @@ -46,18 +46,10 @@ declare const num: NumAlias<42>; declare const str: StrAlias<"test">; declare const bool: BoolAlias; -/* @@? 37:73 Error SyntaxError: Invalid Type. */ -/* @@? 38:15 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 38:15 Error TypeError: Unresolved reference N */ +/* @@? 37:73 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 38:16 Error SyntaxError: Unexpected token ','. */ -/* @@? 39:15 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 39:15 Error TypeError: Unresolved reference S */ /* @@? 39:16 Error SyntaxError: Unexpected token ','. */ -/* @@? 40:16 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 40:16 Error TypeError: Unresolved reference B */ /* @@? 40:17 Error SyntaxError: Unexpected token ','. */ -/* @@? 41:17 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 41:23 Error SyntaxError: Unexpected token 'void'. */ /* @@? 45:29 Error SyntaxError: Invalid Type. */ /* @@? 45:29 Error SyntaxError: Unexpected token, expected '>'. */ /* @@? 45:29 Error SyntaxError: Unexpected token '>'. */ @@ -65,4 +57,4 @@ declare const bool: BoolAlias; /* @@? 47:31 Error SyntaxError: Invalid Type. */ /* @@? 47:31 Error SyntaxError: Unexpected token, expected '>'. */ /* @@? 47:31 Error SyntaxError: Unexpected token '>'. */ -/* @@? 47:36 Error SyntaxError: Unexpected token ';'. */ \ No newline at end of file +/* @@? 47:36 Error SyntaxError: Unexpected token ';'. */ diff --git a/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl.ets b/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl.ets new file mode 100644 index 0000000000000000000000000000000000000000..633a00e7acf11705dee0444b85999910e74c4dfb --- /dev/null +++ b/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +let o: /* @@ label */{ x: number/* @@ label2 */, y: number } = { x: 2, y: 3 } + +/* @@@ label Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@@ label2 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl_2.ets b/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbbd45161ef1d205c44b95782ab7aa0df2c03554 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/types_no_object_lit_to_decl_2.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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. + */ + +type S = Set + +/* @@@ label Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@@ label2 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_52.ets b/ets2panda/test/ast/parser/ets/unexpected_token_52.ets index b447ab92d520874dc11995c29a7c4d1c8fd66ce7..9b65b55ca6dfc69334e73db9fd863823f19ec76a 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_52.ets +++ b/ets2panda/test/ast/parser/ets/unexpected_token_52.ets @@ -13,11 +13,21 @@ * limitations under the License. */ -let /* @@ label1 */a = { - get [/* @@ label2 */b/* @@ label3 */)(){}, - ...a, +let a = { + get [b)(){}, + ...a, } -/* @@@ label1 Error TypeError: Cannot infer type for a because class composite needs an explicit target type */ -/* @@@ label2 Error SyntaxError: Object pattern can't contain methods. */ -/* @@@ label3 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 16:5 Error TypeError: Cannot infer type for a because class composite needs an explicit target type */ +/* @@? 17:9 Error SyntaxError: Unexpected token. */ +/* @@? 17:10 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 17:10 Error SyntaxError: Object pattern can't contain methods. */ +/* @@? 17:12 Error SyntaxError: Expected '{', got '('. */ +/* @@? 17:12 Error SyntaxError: Unexpected token. */ +/* @@? 17:13 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:14 Error SyntaxError: Unexpected token '{'. */ +/* @@? 17:16 Error SyntaxError: Unexpected token ','. */ +/* @@? 18:5 Error SyntaxError: Unexpected token '...'. */ +/* @@? 18:8 Error SyntaxError: Unexpected token 'a'. */ +/* @@? 18:9 Error SyntaxError: Unexpected token ','. */ +/* @@? 19:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_61.ets b/ets2panda/test/ast/parser/ets/unexpected_token_61.ets index bf42eb21ad12c372ce6964fd6eb85e6e2fb388df..76c41c3aa432f2414e2e4c27053c8a3c7f2d55c7 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_61.ets +++ b/ets2panda/test/ast/parser/ets/unexpected_token_61.ets @@ -14,9 +14,10 @@ */ function main(): void { - for (const i : int = 0 /* @@ label1 */i < 10; i++) { + for (const i : int = 0 /* @@ label1 */i < 10; /* @@ label */i++) { console.log("a") } } +/* @@@ label Error TypeError: Cannot assign to a constant variable i */ /* @@@ label1 Error SyntaxError: Expected ';', got 'identification literal'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_63.ets b/ets2panda/test/ast/parser/ets/unexpected_token_63.ets index 342f45a066311abc9aa70196147db4170f458e35..40a8346dc0839833ce2ffd16fadac6498fa6510a 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_63.ets +++ b/ets2panda/test/ast/parser/ets/unexpected_token_63.ets @@ -35,13 +35,19 @@ class A { /* @@? 17:37 Error SyntaxError: Unexpected token ')'. */ /* @@? 17:39 Error SyntaxError: Unexpected token '{'. */ /* @@? 18:3 Error SyntaxError: Unexpected token 'while'. */ -/* @@? 18:8 Error SyntaxError: Unexpected token '('. */ +/* @@? 18:8 Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ +/* @@? 18:9 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 18:9 Error SyntaxError: Unexpected token 'true'. */ +/* @@? 18:9 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 18:9 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 18:13 Error SyntaxError: Unexpected token ')'. */ /* @@? 18:15 Error SyntaxError: Unexpected token '{'. */ /* @@? 19:4 Error SyntaxError: Unexpected token 'if'. */ -/* @@? 19:6 Error SyntaxError: Unexpected token '('. */ +/* @@? 19:6 Error SyntaxError: Call signatures in object types are not supported. Use '$_invoke' method instead. */ +/* @@? 19:7 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 19:7 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 19:7 Error SyntaxError: Unexpected token 'false'. */ +/* @@? 19:7 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 19:12 Error SyntaxError: Unexpected token ')'. */ /* @@? 19:14 Error SyntaxError: Unexpected token '{'. */ /* @@? 20:5 Error SyntaxError: Unexpected token 'break'. */ @@ -53,3 +59,4 @@ class A { /* @@? 25:3 Error SyntaxError: Unexpected token '}'. */ /* @@? 26:2 Error SyntaxError: Unexpected token '}'. */ /* @@? 27:1 Error SyntaxError: Unexpected token '}'. */ + diff --git a/ets2panda/test/ast/parser/ets/update_funcscope_error.ets b/ets2panda/test/ast/parser/ets/update_funcscope_error.ets index 966c78d0cc0d6a81c59e142d6857535301990fc1..7ca3f8b98c016452f86634a9eb2894793e19aff9 100644 --- a/ets2panda/test/ast/parser/ets/update_funcscope_error.ets +++ b/ets2panda/test/ast/parser/ets/update_funcscope_error.ets @@ -38,4 +38,14 @@ export const updateIfChanged = (t: Record) => { /* @@? 21:19 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 24:7 Error TypeError: Type '(v: Record) => Boolean' is not compatible with type '(previousValue: Boolean, currentValue: Boolean, index: Double, array: FixedArray) => Boolean' at index 2 */ /* @@? 27:11 Error TypeError: Invalid record property */ +/* @@? 28:11 Error SyntaxError: Unexpected token. */ +/* @@? 28:12 Error SyntaxError: Unexpected token. */ +/* @@? 28:12 Error TypeError: Type '*ERROR_TYPE*' is not compatible with type 'String' at index 1 */ +/* @@? 28:15 Error SyntaxError: Unexpected token. */ +/* @@? 28:16 Error SyntaxError: Unexpected token ':'. */ +/* @@? 28:18 Error SyntaxError: Unexpected token 'v'. */ +/* @@? 29:10 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 30:16 Error TypeError: Unresolved reference update */ +/* @@? 32:5 Error SyntaxError: Unexpected token ')'. */ +/* @@? 33:12 Error TypeError: Unresolved reference reduceResult */ +/* @@? 35:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_14.ets b/ets2panda/test/ast/parser/ets/user_defined_14.ets index a52c018c9981486973ab3bca26f22271103411b4..31c17e0cc894d95cfb988decab385f757e4d58c6 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_14.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_14.ets @@ -13,6 +13,9 @@ * limitations under the License. */ -class typeof{ +class /* @@ label */typeof { a : string = "15"; } + +/* @@@ label Error SyntaxError: Hard keyword 'typeof' cannot be used as identifier */ +/* @@@ label Error SyntaxError: Identifier expected, got 'typeof'. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_19.ets b/ets2panda/test/ast/parser/ets/user_defined_19.ets index 0da893731848a9ca3ba48665644ac591fe0e1053..8f81e7dbc795a24a5188d7b7e80fe4eb86cfaa11 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_19.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_19.ets @@ -18,3 +18,5 @@ struct typeof{ } /* @@? 16:1 Error TypeError: Structs are only used to define UI components, it should be translated at 'plugin after parser' phase. */ +/* @@? 16:8 Error SyntaxError: Hard keyword 'typeof' cannot be used as identifier */ +/* @@? 16:8 Error SyntaxError: Identifier expected, got 'typeof'. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_20.ets b/ets2panda/test/ast/parser/ets/user_defined_20.ets index 2826718e9bcbdc71d589e1ce4e54c2731efef3c4..11c00c085ab04a1aaa9a32c9f8aa67f3a774f110 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_20.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_20.ets @@ -17,6 +17,5 @@ struct bigint{ a : string = "15"; } -/* @@? 16:8 Error SyntaxError: Cannot be used as user-defined type. */ +/* @@? 16:8 Error SyntaxError: bigint is a predefined type, cannot be used as an identifier */ /* @@? 16:1 Error TypeError: Structs are only used to define UI components, it should be translated at 'plugin after parser' phase. */ -/* @@? 1:3 Error TypeError: Variable 'bigint' is already defined with different type. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_21.ets b/ets2panda/test/ast/parser/ets/user_defined_21.ets index 6ed80976387fa0f0f4fe3a265d75d1bcc98ea334..a7715989bf1d418e8d4c0263dca804341ef44563 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_21.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_21.ets @@ -17,5 +17,4 @@ class /* @@ label */bigint{ a : string = "15"; } -/* @@@ label Error SyntaxError: Cannot be used as user-defined type. */ -/* @@? 1:3 Error TypeError: Variable 'bigint' is already defined with different type. */ +/* @@@ label Error SyntaxError: bigint is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_5.ets b/ets2panda/test/ast/parser/ets/user_defined_5.ets index 54076098618908af969d791ce536c4b67d49c011..a20b8680d4ed2d7c4dac1f52b113a95206279b00 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_5.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_5.ets @@ -17,6 +17,4 @@ enum /* @@ label */double { A, B, C } -/* @@@ label Error SyntaxError: Cannot be used as user-defined type. */ -/* @@@ label Error SyntaxError: Identifier expected, got 'double'. */ -/* @@@ label Error SyntaxError: Hard keyword 'double' cannot be used as identifier */ +/* @@@ label Error SyntaxError: double is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_7.ets b/ets2panda/test/ast/parser/ets/user_defined_7.ets index 587457df03a00716aa658dc94de604c15c31a1a7..5b9519508f6746008b811c5d0d2d3eefcc2cb2d7 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_7.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_7.ets @@ -17,9 +17,7 @@ interface /* @@ label1 */double { name : string /* @@ label2 */= /* @@ label3 */"" /* @@ label4 */} -/* @@@ label1 Error SyntaxError: Cannot be used as user-defined type. */ -/* @@@ label1 Error SyntaxError: Identifier expected, got 'double'. */ -/* @@@ label1 Error SyntaxError: Hard keyword 'double' cannot be used as identifier */ +/* @@@ label1 Error SyntaxError: double is a predefined type, cannot be used as an identifier */ /* @@@ label2 Error SyntaxError: Interface member initialization is prohibited. */ /* @@@ label3 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 17:51 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_8.ets b/ets2panda/test/ast/parser/ets/user_defined_8.ets index 95556fc08294ee82fbe20c09051086b5d7fad317..52278742dd3f8ed2e018321cb303a067e5bcf713 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_8.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_8.ets @@ -17,7 +17,5 @@ struct string{ a : string = "15"; } -/* @@? 16:8 Error SyntaxError: Cannot be used as user-defined type. */ +/* @@? 16:8 Error SyntaxError: string is a predefined type, cannot be used as an identifier */ /* @@? 16:1 Error TypeError: Structs are only used to define UI components, it should be translated at 'plugin after parser' phase. */ -/* @@? 1:3 Error TypeError: Variable 'string' is already defined with different type. */ -/* @@? 17:16 Error TypeError: Type '"15"' cannot be assigned to type 'string' */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_9.ets b/ets2panda/test/ast/parser/ets/user_defined_9.ets index fecbee124f116921c19898efd6baa1ed741fd7bf..1170c80f98c44b47ee10471aed582e5cd53019a1 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_9.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_9.ets @@ -17,6 +17,4 @@ class /* @@ label */string{ a : string = "15"; } -/* @@@ label Error SyntaxError: Cannot be used as user-defined type. */ -/* @@? 1:3 Error TypeError: Variable 'string' is already defined with different type. */ -/* @@? 17:16 Error TypeError: Type '"15"' cannot be assigned to type 'string' */ +/* @@@ label Error SyntaxError: string is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/js/private_ctor_bad.js b/ets2panda/test/ast/parser/js/private_ctor_bad.js new file mode 100644 index 0000000000000000000000000000000000000000..1b9477045f2682176e219e5d18c7db2125030c6d --- /dev/null +++ b/ets2panda/test/ast/parser/js/private_ctor_bad.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + + +class A { + #constructor(){} +} +/* @@? 18:6 Error SyntaxError: Private identifier can not be constructor. */ diff --git a/ets2panda/test/ast/parser/js/private_number_bad.js b/ets2panda/test/ast/parser/js/private_number_bad.js new file mode 100644 index 0000000000000000000000000000000000000000..94cd82cad0adec7fc72ee2b4572247a0019ed93a --- /dev/null +++ b/ets2panda/test/ast/parser/js/private_number_bad.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +class WeAre { + #1 +} +/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ +/* @@? 17:6 Error SyntaxError: Private identifier name can not be number. */ diff --git a/ets2panda/test/ast/parser/js/private_ref_bad.js b/ets2panda/test/ast/parser/js/private_ref_bad.js new file mode 100644 index 0000000000000000000000000000000000000000..cc4b234705d69a92b2be25ca18a4cc86fb8deede --- /dev/null +++ b/ets2panda/test/ast/parser/js/private_ref_bad.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +class A{ + m(){ + return this.#x + } +} +/* @@? 18:21 Error SyntaxError: Private field 'x' must be declared in an enclosing class */ diff --git a/ets2panda/test/ast/parser/js/private_sqbracket_bad.js b/ets2panda/test/ast/parser/js/private_sqbracket_bad.js new file mode 100644 index 0000000000000000000000000000000000000000..426ccec09f494b4ac77389b6317cfa181521c25e --- /dev/null +++ b/ets2panda/test/ast/parser/js/private_sqbracket_bad.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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. + */ + +class WeAre { + #[ +} +/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ +/* @@? 17:6 Error SyntaxError: Unexpected character in private identifier. */ +/* @@? 18:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 18:1 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 24:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/js/private_string_bad.js b/ets2panda/test/ast/parser/js/private_string_bad.js new file mode 100644 index 0000000000000000000000000000000000000000..58c411b6fd9fcc16fd4c6cbaa533c681c3b85836 --- /dev/null +++ b/ets2panda/test/ast/parser/js/private_string_bad.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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. + */ + +class WeAre { + #"one" +} +/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ +/* @@? 17:6 Error SyntaxError: Private identifier name can not be string. */ diff --git a/ets2panda/test/benchmarks/README.md b/ets2panda/test/benchmarks/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4774895e4db5c49249240e6836aa8118bbf646b5 --- /dev/null +++ b/ets2panda/test/benchmarks/README.md @@ -0,0 +1,76 @@ +# Logic +- Run es2panda for benchmark files from this directory +- Dump perfmetrics to `/test-current-perf.txt` for current es2panda +- Dump perfmetrics to `/test-pre_merge-perf.txt` for another (pre-merge) es2panda +- Dump comparison report to `/test-report.txt` in format like `time=-90.00ms (-1.9%)` + +### Static mode +If `actual_perf > max_perf * (1 + static_regression)` - an error occurs. Example: +``` +[PERF REGRESSION] Failed for bench_1-current-perf.txt: Memory exceeded threshold. + Limit: 5.0%, Actual: +406.25% + Base: 32.00MB, New: 162.00MB + Threshold: < 33.60MB +``` + +If `actual_perf < max_perf * (1 + 3 * static_regression)` - an error occurs. Example: +``` +[UPDATE REQUIRED] Very good perf for bench_1-current-perf.txt: Please update *-max.txt. + Hint: use flag '--dump-perf-metrics' and Release build of es2panda. +``` + +### Dynamic mode +If `actual_perf > pre_merge_perf * dynamic_regression` - an error occurs (the same as in static mode). + +### Errors reporting +Errors are printed to the console and also to `/error_log.txt`. + +# Arguments +- `--mode` - 'static' to compare with `*-max.txt` files. 'dynamic' to compare with pre-merge es2panda. +- `--es2panda` - Path to current es2panda (aka /bin/es2panda) +- `--es2panda-pre-merge` - Path to pre-merge es2panda (aka /bin/es2panda) +- `--test-dir` - Path to test directory with test files +- `--work-dir` - Path to the working temp folder with gen, intermediate and report folders +- `--dynamic-regression` - Acceptable regression compared to the another (pre-merge) es2panda +- `--static-regression` - Acceptable regression compared to static vales from `*-max.txt` files +- `--runs` - The number of runs to average +- `--werror` - Warnings as errors + +# Max values +Each file have companion: for `test.ets` companion is `test-max.txt`. This file contains max values for metrics. + +# Local reproduction +```bash +# static mode +python3 /ets2panda/test/benchmarks/runner/runner.py --mode=static --es2panda=/bin/es2panda --work-dir=/e2p_benchmarks --test-dir=/ets2panda/test/benchmarks + +# dynamic mode +python3 /ets2panda/test/benchmarks/runner/runner.py --mode=dynamic --es2panda=/bin/es2panda --work-dir=/e2p_benchmarks --test-dir=/ets2panda/test/benchmarks --es2panda-pre-merge=/bin/es2panda +``` +See `--help` if needed. + +# CI +You can download artifacts for this job with perf stat. + +# Artifacts example + +test-perf.txt +``` +================ es2panda perf metrics (Averaged over 3 runs) ================ +:@phases : time=891.00ms mem=140.00MB +:@phases/ConstantExpressionLowering : time=233.00ms mem=0.26MB +:@phases/TopLevelStatements : time=193.00ms mem=79.00MB +:@phases/ResolveIdentifiers : time=83.40ms mem=6.00MB +:@phases/CheckerPhase : time=78.60ms mem=19.00MB +``` + +test-report.txt +``` +Performance Comparison: 'bench_1-max.txt' vs 'bench_1-current-perf.txt' +================================================================================ +:@EmitProgram : time=+2.90ms (+4.6%) mem=+0.00MB (+0.0%) +:@GenerateProgram : time=+4.67ms (+6.7%) mem=0.00MB (0.0%) +:@GenerateProgram/OptimizeBytecode : time=0.00ms (0.0%) mem=0.00MB (0.0%) +:@phases : time=+22.67ms (+2.6%) mem=+0.00MB (+0.0%) +:@phases/AmbientLowering : time=-0.07ms (-0.6%) mem=0.00MB (0.0%) +``` diff --git a/ets2panda/test/benchmarks/bench_1-max.txt b/ets2panda/test/benchmarks/bench_1-max.txt new file mode 100644 index 0000000000000000000000000000000000000000..81e3099f82e7696cbb68e727ae0288f68b6eb4ce --- /dev/null +++ b/ets2panda/test/benchmarks/bench_1-max.txt @@ -0,0 +1,66 @@ +================ es2panda perf metrics (Averaged over 500 runs) ================ + +:@phases : time=1472.50ms mem=159.89MB +:@GenerateProgram : time=439.95ms mem=0.00MB +:@phases/ConstantExpressionLowering : time=374.76ms mem=0.30MB +:@phases/TopLevelStatements : time=273.61ms mem=81.00MB +:@GenerateProgram/OptimizeBytecode : time=264.15ms mem=0.00MB +:@EmitProgram : time=148.99ms mem=31.22MB +:@phases/CheckerPhase : time=132.83ms mem=23.28MB +:@phases/ResolveIdentifiers : time=112.03ms mem=6.00MB +:@phases/InterfaceObjectLiteralLowering : time=81.20ms mem=7.00MB +:@phases/LambdaObjectConversion : time=74.07ms mem=5.00MB +:@phases/ScopesInitPhase : time=62.35ms mem=13.79MB +:@phases/PartialExportClassGen : time=45.10ms mem=8.00MB +:@phases/Unbox : time=29.11ms mem=0.74MB +:@phases/OptionalLowering : time=25.61ms mem=0.99MB +:@phases/ResizableArrayConvert : time=22.40ms mem=0.51MB +:@phases/InterfacePropertyDeclarationsPhase : time=21.20ms mem=1.00MB +:@phases/EnumLoweringPhase : time=19.05ms mem=0.81MB +:@phases/EnumPostCheckLoweringPhase : time=18.67ms mem=0.00MB +:@phases/OverloadMappingLowering : time=18.01ms mem=0.00MB +:@phases/DeclareOverloadLowering : time=17.97ms mem=0.00MB +:@phases/PromiseVoidInferencePhase : time=17.90ms mem=0.00MB +:@phases/InsertOptionalParametersAnnotation : time=17.38ms mem=0.74MB +:@phases/AmbientLowering : time=17.22ms mem=0.00MB +:@phases/ExpressionLambdaConstruction : time=17.15ms mem=0.00MB +:@phases/GradualTypeNarrowing : time=16.99ms mem=1.88MB +:@phases/DefaultParametersInConstructorLowering : time=16.67ms mem=0.52MB +:@phases/ObjectIndexLowering : time=3.65ms mem=0.71MB +:@phases/CreateGenericBridges : time=3.36ms mem=0.00MB +:@phases/ArrayLiteralLowering : time=3.24ms mem=0.52MB +:@phases/BoxingForLocals : time=1.64ms mem=0.00MB +:@phases/ObjectLiteralLowering : time=1.50ms mem=0.23MB +:@phases/PrimitiveConversion : time=1.26ms mem=0.00MB +:@phases/OpAssignmentLowering : time=1.22ms mem=0.00MB +:@phases/UnionLowering : time=0.95ms mem=0.00MB +:@phases/StringConstructorLowering : time=0.74ms mem=0.00MB +:@phases/OptionalArgumentsLowering : time=0.67ms mem=0.03MB +:@phases/LateInitializationConvert : time=0.63ms mem=0.00MB +:@phases/TypeFromLowering : time=0.63ms mem=0.00MB +:@phases/DefaultParametersLowering : time=0.62ms mem=0.00MB +:@phases/ExpandBracketsPhase : time=0.60ms mem=0.00MB +:@phases/CapturedVariables : time=0.57ms mem=0.00MB +:@phases/RestTupleConstructionPhase : time=0.54ms mem=0.00MB +:@phases/SpreadConstructionPhase : time=0.51ms mem=0.00MB +:@phases/DynamicImport : time=0.51ms mem=0.00MB +:@phases/StringComparisonLowering : time=0.47ms mem=0.00MB +:@phases/RestArgsLowering : time=0.37ms mem=0.00MB +:@phases/BigIntLowering : time=0.36ms mem=0.00MB +:@phases/ObjectIteratorLowering : time=0.32ms mem=0.00MB +:@phases/StringConstantsLowering : time=0.32ms mem=0.00MB +:@phases/SetterLowering : time=0.31ms mem=0.00MB +:@phases/RecordLowering : time=0.31ms mem=0.00MB +:@phases/ExtentionAccessorPhase : time=0.31ms mem=0.00MB +:@phases/AsyncMethodLowering : time=0.31ms mem=0.00MB +:@phases/AnnotationCopyPostLowering : time=0.28ms mem=0.00MB +:@phases/AnnotationCopyLowering : time=0.28ms mem=0.00MB +:@phases/SetJumpTargetPhase : time=0.26ms mem=0.00MB +:@phases/plugins-after-parse : time=0.01ms mem=0.00MB +:@phases/ExportAnonymousConstPhase : time=0.00ms mem=0.00MB +:@phases/plugins-after-lowering : time=0.00ms mem=0.00MB +:@phases/DeclGenPhase : time=0.00ms mem=0.00MB +:@phases/plugins-after-bind : time=0.00ms mem=0.00MB +:@phases/PackageImplicitImport : time=0.00ms mem=0.00MB +:@phases/plugins-after-check : time=0.00ms mem=0.00MB +:@phases/CFGBuilder : time=0.00ms mem=0.00MB diff --git a/ets2panda/test/benchmarks/bench_1.ets b/ets2panda/test/benchmarks/bench_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..a200b8c29d28a7b0b7332f96f72f3e5dbe958c30 --- /dev/null +++ b/ets2panda/test/benchmarks/bench_1.ets @@ -0,0 +1,1569 @@ +/* + * Copyright (c) 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. + */ + +// --------------------------------------------------------------------------------------------------------------------- +// AccessBinaryTrees.ets +// --------------------------------------------------------------------------------------------------------------------- + +class TreeNode { + private left: TreeNode | null; + private right: TreeNode | null; + private item: int; + + constructor(left: TreeNode | null, right: TreeNode | null, item: int) { + this.left = left; + this.right = right; + this.item = item; + } + + public itemCheck(): int { + if (this.left == null) + return this.item; + else + return this.item + this.left!.itemCheck() - this.right!.itemCheck(); + } +} + +export class AccessBinaryTrees { + static readonly startDepth = 4; + static readonly endDepth = 7; + static readonly expected = -4; + + static bottomUpTree(item: int, depth: int): TreeNode { + if (depth > 0) { + return new TreeNode( + AccessBinaryTrees.bottomUpTree(2*item - 1, depth-1), + AccessBinaryTrees.bottomUpTree(2*item, depth-1), + item + ); + } + return new TreeNode(null, null, item); + } + + public run(): void { + let ret: int = 0; + + for (let n: int = AccessBinaryTrees.startDepth; n <= AccessBinaryTrees.endDepth; n++) { + let minDepth: int = AccessBinaryTrees.startDepth; + let maxDepth: int = max(minDepth + 2, n); + let stretchDepth: int = maxDepth + 1; + let check: int = AccessBinaryTrees.bottomUpTree(0, stretchDepth).itemCheck(); + + let longLivedTree = AccessBinaryTrees.bottomUpTree(0, maxDepth); + + for (let depth = minDepth; depth <= maxDepth; depth += 2) { + let iterations: int = 1 << (maxDepth - depth + minDepth); + + check = 0; + for (let i: int = 1; i <= iterations; i++) { + check += AccessBinaryTrees.bottomUpTree(i, depth).itemCheck(); + check += AccessBinaryTrees.bottomUpTree(-i, depth).itemCheck(); + } + } + + ret += longLivedTree.itemCheck(); + } + + arktest.assertEQ(ret, AccessBinaryTrees.expected, "Incorrect result") + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// RestTuple6.ets +// --------------------------------------------------------------------------------------------------------------------- + +class A2 {} +class B2 {} + +class C2 { + foo(...p: [A2, B2]): boolean { + return p[0] == p[1] + } + + moo(a:int, ...p: [A2, B2]): boolean { + return p[0] == p[1] + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// GenericBridges_02.ets +// --------------------------------------------------------------------------------------------------------------------- + +interface B3 { + f23(v: B3): B3; +} + +class C3 implements B3 { + + f13(v: T3): T3 { + return v; + } + + f23(v: C3): C3 { + return new C3(); + } + + f23(v: B3): B3 { + return this.f23(v as C3); + } + + f33(v: T3|string): string { + return "C3.f33"; + } + + f43(v: C3|Numeric): string { + return "C3.f43"; + } + + f53(x: T1|Z3|C3[]): string { + return "C3.f53"; + } + + f63(x: C3, y: C3): string { + return "C3.f63"; + } + + f73(x: T3, y: C3): string { + return "C3.f73"; + } + + f83(x: string): string { + return "C3.f83"; + } + + f93(z: Z3, y: T1): string { + return "C3.f93"; + } +} + +class D3 extends C3 { + f13(v: string): string { + return "D3.f13"; + } + + f13(v: Numeric|string|C3): string { + return this.f13(v as string); + } + + f13(v: Int): Int { + return 7; + } + + f23(v: D3): D3 { + return new D3(); + } + + f33(v: string): string { + return "D3.f33"; + } + + f43(v: D3): string { + return "D3.f43"; + } + + f43 (x: int, y: int): int { + return x + y; + } + + f53(x: string|W3|C3[]): string { + return "D3.f53"; + } + + f63(): string { + return "D3.f63"; + } + +// f73(x: string, y: D3): string { +// return "D3.f73"; +// } + + f83(x: string): string { + return "D3.f83"; + } + + f93(z: W3, y: string): string { + return "D3.f93-1"; + } + + f93(z: W3, y: Int): string { + return "D3.f93-2"; + } +} + +class F3 extends D3 {} + +class G3 extends C3 {} + +class E3 extends C3 { + + f13(v: U3): Integral { + if (v instanceof Int) { + return new Int(7); + } else if (v instanceof Long) { + return new Long(8); + } else { + return new Int(-1); + } + } + + f23(v: E3): E3 { + return new E3(); + } + + f33(){} + + f43(x:int, y: int): int { return x + y; } + +// f73(x: U3, y: E3): string { +// return "E3.f73"; +// } +} + +function foo13(c: C3) { + arktest.assertEQ(c.f13(0), 7) + arktest.assertEQ(c.f23(c).f13(0), 7) + arktest.assertEQ(c.f53(""), "C3.f53") + arktest.assertEQ(c.f63(c, c), "C3.f63") +} + +function foo23(c: C3) { + arktest.assertEQ(c.f13(0), 8) + arktest.assertEQ(c.f23(c).f13(0), 8) + arktest.assertEQ(c.f53(""), "C3.f53") + arktest.assertEQ(c.f73(3, c), "E3.f73") +} + +function ttt3(c: C3): void { + arktest.assertEQ(c.f13("ah"), "D3.f13") + arktest.assertEQ(c.f23(c).f13("ah"), "D3.f13") + arktest.assertEQ((c.f23(c as B3) as C3).f13("ah"), "D3.f13") + arktest.assertEQ(c.f33("ah"), "D3.f33") + arktest.assertEQ(c.f43(c), "D3.f43") + arktest.assertEQ(c.f53("ah"), "D3.f53") + arktest.assertEQ(c.f63(c, c), "C3.f63") + arktest.assertEQ((c as D3).f63(), "D3.f63") + arktest.assertEQ(c.f73("ah", c), "D3.f73") + arktest.assertEQ(c.f83(""), "D3.f83") + arktest.assertEQ(c.f93("", ""), "C3.f93") + arktest.assertEQ((c as D3).f93("", 0), "D3.f93-2") +} + +// --------------------------------------------------------------------------------------------------------------------- +// ArrowArity.ets +// --------------------------------------------------------------------------------------------------------------------- + +type S4 = string + +function xassert4(a: S4, b: S4) { arktest.assertEQ(a, b) } + +function p0call4(f: () => S4, a: S4[]) { + return f() +} +function p1call4(f: (p1: S4) => S4, a: S4[]) { + return f(a[0]) +} +function p2call4(f: (p1: S4, p2: S4) => S4, a: S4[]) { + return f(a[0], a[1]) +} +function p012call4(f: () => S4, a: S4[]) { + return p0call4(f, a) + p1call4(f, a) + p2call4(f, a) +} +function p_12call4(f: (p1: S4) => S4, a: S4[]) { + return p1call4(f, a) + p2call4(f, a) +} +function p__2call4(f: (p1: S4, p2: S4) => S4, a: S4[]) { + return p2call4(f, a) +} + +function r0__call4(f: (p1?: S4, p2?: S4) => S4, a: S4[]) { + return f() + f(a[0]) + f(a[0], a[1]) +} +function r_1_call4(f: (p1: S4, p2?: S4) => S4, a: S4[]) { + return f(a[0]) + f(a[0], a[1]) +} + +function testBasicArity4() { + let args = ["a", "b"] + let f0 = () => "/f0:" + let f1 = (a1: S4) => "/f1:" + a1 + let f2 = (a1: S4, a2: S4) => "/f2:" + a1 + a2 + + xassert4(p012call4(f0, args), "/f0:/f0:/f0:") + xassert4(p_12call4(f0, args), "/f0:/f0:") + xassert4(p_12call4(f1, args), "/f1:a/f1:a") + xassert4(p__2call4(f0, args), "/f0:") + xassert4(p__2call4(f1, args), "/f1:a") + xassert4(p__2call4(f2, args), "/f2:ab") + + xassert4(r0__call4(f0, args), "/f0:/f0:/f0:") + xassert4(r_1_call4(f0, args), "/f0:/f0:") + xassert4(r_1_call4(f1, args), "/f1:a/f1:a") +} +testBasicArity4(); + +function testOptionalArity4() { + let args = ["a", "b"] + let tou = (v?: string) => v ?? "u" + let f0 = (a1?: S4, a2?: S4) => "/f0:" + tou(a1) + tou(a2) + let f1 = (a1: S4, a2?: S4) => "/f1:" + a1 + tou(a2) + let f2 = (a1: S4, a2: S4) => "/f2:" + a1 + a2 + + xassert4(p012call4(f0, args), "/f0:uu/f0:au/f0:ab") + xassert4(p_12call4(f0, args), "/f0:au/f0:ab") + xassert4(p_12call4(f1, args), "/f1:au/f1:ab") + xassert4(p__2call4(f0, args), "/f0:ab") + xassert4(p__2call4(f1, args), "/f1:ab") + xassert4(p__2call4(f2, args), "/f2:ab") + + xassert4(r0__call4(f0, args), "/f0:uu/f0:au/f0:ab") + xassert4(r_1_call4(f0, args), "/f0:au/f0:ab") + xassert4(r_1_call4(f1, args), "/f1:au/f1:ab") +} +testOptionalArity4(); + +function testDfltArity4() { + let args = ["a", "b"] + let f0 = (a1: S4 = "x", a2: S4 = "y") => "/f0:" + a1 + a2 + let f1 = (a1: S4, a2: S4 = "y") => "/f1:" + a1 + a2 + let f2 = (a1: S4, a2: S4) => "/f2:" + a1 + a2 + + xassert4(p012call4(f0, args), "/f0:xy/f0:ay/f0:ab") + xassert4(p_12call4(f0, args), "/f0:ay/f0:ab") + xassert4(p_12call4(f1, args), "/f1:ay/f1:ab") + xassert4(p__2call4(f0, args), "/f0:ab") + xassert4(p__2call4(f1, args), "/f1:ab") + xassert4(p__2call4(f2, args), "/f2:ab") + + xassert4(r0__call4(f0, args), "/f0:xy/f0:ay/f0:ab") + xassert4(r_1_call4(f0, args), "/f0:ay/f0:ab") + xassert4(r_1_call4(f1, args), "/f1:ay/f1:ab") +} +testDfltArity4() + +function testDfltEvaluation4() { + let counter = "c" + let inc = () => (counter += "x") + let f = (a: string = inc()) => a + xassert4(f("a"), "a") + xassert4(f(), "cx") + xassert4(f(), "cxx") + xassert4(f(undefined), "cxxx") +} +testDfltEvaluation4() + +function testArrowExprCalls4() { + let x = (a1: S4, a2?: S4, a3?: S4) => a1 + (a2 ?? "u") + (a3 ?? "u") + xassert4(x("a"), "auu") + xassert4(x("a", "b"), "abu") + xassert4(x("a", "b", "c"), "abc") + + xassert4(((a?: S4) => a ?? "u")(), "u") + // xassert4(((a?: S4) => a ?? "u")("a"), "a") // #22952: broken +} +testArrowExprCalls4() + +class X4 { + constructor(v: (p?: T4) => T4) { this.fv = v } + get f() { return this.fv } + fv: (p?: T4) => T4 +} +function gcall4(x: X4, a: T4) { + (x.f)(); + (x.f)(a); + (x.fv)(); + (x.fv)(a); +} +function testGenerics4() { + let res: string = ":" + let fn = (a?: string) => { + res += (a ?? "D"); + return res; + }; + gcall4(new X4(fn), "a") // #22952: inference fails + xassert4(res, ":DaDa") +} +testGenerics4(); + +function foo4(a1: S4, a2?: S4) { return a1 + (a2 ?? "D") } +function testFuncRef4() { + let f = (a1: S4, a2?: S4) => foo4(a1, a2) // #22952: foo4 is overloaded + xassert4(f("a"), "aD") + xassert4(f("a", undefined), "aD") + xassert4(f("a", "b"), "ab") +} +testFuncRef4(); + +// --------------------------------------------------------------------------------------------------------------------- +// OptionalChains.ets +// --------------------------------------------------------------------------------------------------------------------- + +function assert_n5(v: Object | null | undefined) { arktest.assertTrue(v === null); } +function assert_u5(v: Object | null | undefined) { arktest.assertTrue(v === undefined); } +function assert_o5(v: Object | null | undefined) { arktest.assertTrue(v !== null && v !== undefined); } +function assert_npe5(f: () => void) { + try { + f(); + } catch (e: NullPointerError) { + return; + } + arktest.assertTrue(false, "npe was not thrown") +} + +class Link5 { + m(): Link5 { return this; } + f: Link5 = this; + a: Link5[] = [(this)]; + c: () => Link5 = () => this + + om(): Link5 | null { return this.m() } + of: Link5 | null = this.f; + oa: Link5[] | null = this.a; + oc: (() => Link5) | null = this.c; + + nm(): Link5 | null { return null } + nf: Link5 | null = null; + na: Link5[] | null = null; + nc: (() => Link5) | null = null; + + static noevalFlag = true; + noeval(): Link5 { if (Link5.noevalFlag) { throw new Error("never evaluated"); } return this; } +} + +function test15(l: Link5 | null, nl: Link5 | null) { + assert_o5(l?.m()); + assert_o5(l?.f); + assert_o5(l?.a[0]); + assert_o5(l?.c()); + assert_o5(l?.of!.f); + + assert_u5(nl?.m()); + assert_u5(nl?.f); + assert_u5(nl?.a[0]); + assert_u5(nl?.c()); + assert_u5(nl?.of!.f); + assert_u5(nl?.nf!.f); + + nl?.m().noeval(); + nl?.f.noeval(); + nl?.a[0].noeval(); + nl?.c().noeval(); + nl?.of!.f.noeval(); + assert_npe5(() => { nl?.of!.f! }); +} + +function test25(l: Link5 | null, nl: Link5 | null) { + assert_o5(l?.m().f.a[0].c()); + assert_o5(l?.f.m().c().a[0]); + assert_o5(l?.a[0].c().f.m()); + assert_o5(l?.c().m().a[0].f); + assert_o5(l?.c().m().of!.a[0].oc!().f); + + assert_u5(nl?.m().f.a[0].c()); + assert_u5(nl?.f.m().c().a[0]); + assert_u5(nl?.a[0].c().f.m()); + assert_u5(nl?.c().m().a[0].f); + assert_u5(nl?.c().m().of!.a[0].oc!().f); + + nl?.m().f.a[0].c().noeval(); + nl?.f.m().c().a[0].noeval(); + nl?.a[0].c().f.m().noeval(); + nl?.c().m().a[0].f.noeval(); + nl?.c().m().of!.a[0].oc!().f.noeval(); +} + +function test35(l: Link5 | null, nl: Link5 | null) { + assert_o5(l?.om()?.of?.oa?.[0].oc?.()); + assert_o5(l?.of?.om()?.oc?.().oa?.[0]); + assert_o5(l?.oa?.[0]?.oc?.().of?.om()); + assert_o5(l?.oc?.().om()?.oa?.[0].of); + assert_o5(l?.oc?.().om()?.of!.oa?.[0].oc!().of); + + assert_u5(nl?.om()?.of?.oa?.[0].oc?.()); + assert_u5(nl?.of?.om()?.oc?.().oa?.[0]); + assert_u5(nl?.oa?.[0]?.oc?.().of?.om()); + assert_u5(nl?.oc?.().om()?.oa?.[0].of); + assert_u5(nl?.oc!().om()?.of!.oa![0].oc!().of); + + nl?.om()?.of?.oa?.[0].oc?.().noeval(); + nl?.of?.om()?.oc?.().oa?.[0].noeval(); + nl?.oa?.[0]?.oc?.().of?.om()?.noeval(); + nl?.oc?.().om()?.oa?.[0].of?.noeval(); + nl?.oc?.().om()?.of!.oa?.[0].oc!().of?.noeval(); +} + +function test45(l: Link5 | null, nl: Link5 | null) { + assert_npe5(() => { nl?.of! }); + nl?.of!.f; +} + +function test55(l: Link5 | null, nl: Link5 | null) { + l?.f.a[0]?.f.c(); + nl?.f.a[0]?.f.c().noeval(); + assert_npe5(() => { nl?.f.a[0]?.f.c()! }); + assert_npe5(() => { (nl?.f?.a)?.[0].f! }); + assert_u5(l?.f.a[0].nf?.a[0].noeval()?.m()); + + let u: Link5 | undefined = l?.f.oc?.().na?.[0].noeval().f?.oa?.[0]; +} + +// --------------------------------------------------------------------------------------------------------------------- +// UnionAsAndInstanceof.ets +// --------------------------------------------------------------------------------------------------------------------- + +function assert_ccexc6(f: () => void) { + try { + f(); + } catch (e) { + arktest.assertTrue(e instanceof ClassCastError) + return; + } + arktest.assertTrue(false, "exception expected") +} + +function assert_nothrow6(f: () => void) { + try { + f(); + } catch (e) { + arktest.assertTrue(false, "unexpected exception") + } +} + +class A6 { } +class B6 { } +class C6 { } + +function foo6(x: Object | null | undefined) { return x as Object } + +function test_nullsafety6() { + // Handling of Object may be a bit different, so test it separately + // let f = ... until inference in form ((p)=>expr)(a) is broken + assert_ccexc6(() => { let f = ((x: Object | null | undefined) => x as Object); f(null); }); + assert_ccexc6(() => { let f = ((x: Object | null | undefined) => x as Object); f(undefined); }); + assert_ccexc6(() => { let f = ((x: Object | null) => x as Object); f(null); }); + assert_ccexc6(() => { let f = ((x: Object | undefined) => x as Object); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: Object | null | undefined) => x as Object | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: Object | null | undefined) => x as Object | null); f(undefined); }); + assert_ccexc6(() => { let f = ((x: Object | null) => x as Object | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: Object | undefined) => x as Object | null); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6); f(undefined); }); + assert_ccexc6(() => { let f = ((x: A6 | null) => x as A6); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | undefined) => x as A6); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | null); f(undefined); }); + assert_ccexc6(() => { let f = ((x: A6 | null) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | undefined) => x as A6 | null); f(undefined); }); + + + assert_nothrow6(() => { let f = ((x: Object | null | undefined) => x as Object); f(new Object()); }); + assert_nothrow6(() => { let f = ((x: Object | null | undefined) => x as Object); f(new Object); }); + assert_nothrow6(() => { let f = ((x: Object | null) => x as Object); f(new Object()); }); + assert_nothrow6(() => { let f = ((x: Object | undefined) => x as Object); f(new Object()); }); + + assert_nothrow6(() => { let f = ((x: Object | null | undefined) => x as Object | undefined); f(new Object()); }); + assert_nothrow6(() => { let f = ((x: Object | null | undefined) => x as Object | null); f(new Object()); }); + assert_nothrow6(() => { let f = ((x: Object | null) => x as Object | undefined); f(new Object()); }); + assert_nothrow6(() => { let f = ((x: Object | undefined) => x as Object | null); f(new Object()); }); + + assert_nothrow6(() => { let f = ((x: A6 | null | undefined) => x as A6); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | null | undefined) => x as A6); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | null) => x as A6); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | undefined) => x as A6); f(new A6()); }); + + assert_nothrow6(() => { let f = ((x: A6 | null | undefined) => x as A6 | undefined); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | null | undefined) => x as A6 | null); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | null) => x as A6 | undefined); f(new A6()); }); + assert_nothrow6(() => { let f = ((x: A6 | undefined) => x as A6 | null); f(new A6()); }); +} + +function test_unions6() { + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6) => x as A6); f(new C6()); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6) => x as A6 | B6); f(new C6()); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6 | null) => x as A6 | B6); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6 | undefined) => x as A6 | B6); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | null); f(undefined); }); + assert_ccexc6(() => { let f = ((x: A6 | null) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | undefined) => x as A6 | null); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6) => x as A6); f(new C6()); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6) => x as A6 | B6); f(new C6()); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6 | null) => x as A6 | B6); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | B6 | C6 | undefined) => x as A6 | B6); f(undefined); }); + + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | null | undefined) => x as A6 | null); f(undefined); }); + assert_ccexc6(() => { let f = ((x: A6 | null) => x as A6 | undefined); f(null); }); + assert_ccexc6(() => { let f = ((x: A6 | undefined) => x as A6 | null); f(undefined); }); +} + +// --------------------------------------------------------------------------------------------------------------------- +// UncheckedCasts.ets +// --------------------------------------------------------------------------------------------------------------------- + +function assert_ccexc7(f: () => void) { + try { + f(); + } catch (e) { + arktest.assertTrue(e instanceof ClassCastError) + return; + } + arktest.assertTrue(false, "exception expected") +} + +class A7 { } +class B7 { } +class C7 { } +class X7 { } + +function erase7(x: Object | null | undefined): T7 { return x as T7; } + +function test_substitution7() { + assert_ccexc7(() => { erase7(null); }) + assert_ccexc7(() => { erase7(undefined); }) + assert_ccexc7(() => { erase7(null); }) + assert_ccexc7(() => { erase7(undefined); }) + + assert_ccexc7(() => { erase7(null); }) + assert_ccexc7(() => { erase7(undefined); }) + assert_ccexc7(() => { erase7(null); }) + assert_ccexc7(() => { erase7(undefined); }) + + assert_ccexc7(() => { erase7(undefined); }) + assert_ccexc7(() => { erase7(new Object()); }) + assert_ccexc7(() => { erase7(new B7()); }) + + assert_ccexc7(() => { erase7(undefined); }) + assert_ccexc7(() => { erase7(new Object()); }) + assert_ccexc7(() => { erase7(new C7()); }) + + assert_ccexc7(() => { erase7>(new B7[0]); }) +} + +class Erased7 { + constructor(x: Object | null | undefined) { this.t7 = x as T7; } + t7: T7; +} + +function test_substitution_memberexpr7() { + assert_ccexc7(() => { new Erased7(null).t7; }) + assert_ccexc7(() => { new Erased7(undefined).t7; }) + assert_ccexc7(() => { new Erased7(null).t7; }) + assert_ccexc7(() => { new Erased7(undefined).t7; }) + + assert_ccexc7(() => { new Erased7(null).t7; }) + assert_ccexc7(() => { new Erased7(undefined).t7; }) + assert_ccexc7(() => { new Erased7(null).t7; }) + assert_ccexc7(() => { new Erased7(undefined).t7; }) + + assert_ccexc7(() => { new Erased7(undefined).t7; }) + assert_ccexc7(() => { new Erased7(new Object()).t7; }) + assert_ccexc7(() => { new Erased7(new B7()).t7; }) + + assert_ccexc7(() => { new Erased7(undefined).t7; }) + assert_ccexc7(() => { new Erased7(new Object()).t7; }) + assert_ccexc7(() => { new Erased7(new C7()).t7; }) + + assert_ccexc7(() => { new Erased7>(new B7[0]).t7; }) +} + +function cast_to_tparam7(x: Object | null | undefined) { x as T7; } + +function test_constraint7() { + assert_ccexc7(() => { cast_to_tparam7(undefined); }) + assert_ccexc7(() => { cast_to_tparam7(new Object()); }) + assert_ccexc7(() => { cast_to_tparam7(new C7()); }) +} + +function to_basetype7(x: Object | null | undefined) { return x as X7; } + +function test_basetype7() { + assert_ccexc7(() => { to_basetype7(null); }) + assert_ccexc7(() => { to_basetype7(undefined); }) + assert_ccexc7(() => { to_basetype7(new Object()); }) + assert_ccexc7(() => { to_basetype7(new C7()); }) +} + +// --------------------------------------------------------------------------------------------------------------------- +// partialTypeRuntime_2.ets +// --------------------------------------------------------------------------------------------------------------------- + +class Class18 { fld: Number = 2; } + +function test_18(): void { + let class1_partial: Partial = {fld: 3}; + arktest.assertEQ(class1_partial.fld, 3) + class1_partial.fld = undefined; + arktest.assertTrue(class1_partial.fld === undefined) +} + +// ----------------------------------------------- + +class Class28 { + fld: Number = 2; + foo(a0: Partial) { + a0.fld = undefined; + } +} + +function test_28(): void { + let class2_original: Class28 = new Class28(); + let class2_partial: Partial = {fld: 3}; + arktest.assertEQ(class2_partial.fld, 3) + class2_original.foo(class2_partial); + arktest.assertTrue(class2_partial.fld === undefined) +} + +// ----------------------------------------------- + +class Class38 { + mmeb: Number = 2; + foo(a0: Partial){ + a0.mmeb = undefined; + } +} + +class Class48 extends Class38 {} + +class Class58 extends Class48 { + mmeb: Number = 2; + foo(a0: Partial){ + a0.mmeb = undefined; + } +} + +function test_38(): void { + let class3_original: Class38 = new Class38(); + let class5_original: Class38 = new Class58(); + let class3_partial: Partial = {mmeb: 8}; + let class5_partial: Partial = {mmeb: 10}; + class3_original.foo(class5_partial); + class5_original.foo(class3_partial); + arktest.assertTrue(class3_partial.mmeb === undefined) + arktest.assertTrue(class5_partial.mmeb === undefined) +} + +// ----------------------------------------------- + +class Class68 { + mmeb: Number = 2; + foo(a0: Partial){ + if(this.mmeb == 3){ + return; + } + + this.bar(a0); + } + bar(a0: Partial){ + this.mmeb = 3; + this.foo(a0); + } +} + +class Class78 { fld: Number = 6;} + +class Class88 { + baz(a0: Partial){ + a0.fld = undefined; + } +} + +function test_48(): void { + let class7_partial: Partial = {fld: 8}; + let class6_original: Class68 = new Class68(); + class6_original.foo(class7_partial); +} + +// ----------------------------------------------- + +class Class98 { fld: Number = 8; } + +class Class108 extends Class98 { memb: Number = 9; } + +function test_58(): void { + let class10_partial: Partial = {memb: 7, fld: 5}; + + arktest.assertEQ(class10_partial.memb, 7) + arktest.assertEQ(class10_partial.fld, 5) + + class10_partial.memb = undefined; + class10_partial.fld = undefined; + + arktest.assertTrue(class10_partial.memb === undefined) + arktest.assertTrue(class10_partial.fld === undefined) +} + +//--------------------------------------- + + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_01.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C33 { + bar(): string { + return "Class C33"; + } +} + +function foo33(c: Object|null|undefined): string { + if (c instanceof string) { + arktest.assertEQ(c.length, 11) + c = "Case 1"; + } else if (c instanceof C33) { + arktest.assertEQ(c.bar(), "Class C33") + c = "Case 2"; + } else if (c instanceof Int) { + arktest.assertEQ(c * 7, 49) + c = "Case 3"; + } else if (c instanceof null) { + arktest.assertEQ(c, null) + c = "Case 4"; + } else { + c = "Case 5"; + } + + arktest.assertEQ(c.length, 6) + return c; +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_02.ets +// --------------------------------------------------------------------------------------------------------------------- + +class A31 { + bar(): string { + return "Class A31"; + } +} + +class B31 extends A31 {} + +class C31 extends B31 { + bar(): string { + return "Class C31"; + } +} + +function foo31(c: Int|String|A31|null|undefined): void { + if (c instanceof String) { + arktest.assertEQ(c.length, 11) + } else if (c instanceof C31) { + arktest.assertEQ(c.bar(), "Class C31") + } else if (c instanceof Int) { + arktest.assertEQ(c * c, 49) + } else if (c === undefined) { + arktest.assertEQ(c, undefined) + } else { + arktest.assertEQ(c, null) + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_03.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C32 { + constructor() {} + + constructor(a: int) { + this.x = a; + } + + bar(): string { + return "Class C32"; + } + + baz(): int { + return this.x; + } + + private x: int = 7; +} + +function foo32(c: Object|null|undefined): string { + if (c instanceof string && (c.length == 11 || c == "Test")) { + c = "Case 1"; + } else if (c instanceof C32 && c.baz() == 7) { + arktest.assertEQ(c.bar(), "Class C32") + c = "Case 2"; + } else if (c instanceof Int && c >= 0) { + arktest.assertTrue(c >= 0) + c = "Case 3"; + } else if (c instanceof null) { + arktest.assertEQ(c, null) + c = "Case 4"; + } else { + c = "Case 5"; + } + + arktest.assertEQ(c.length, 6) + return c; +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_04.ets +// --------------------------------------------------------------------------------------------------------------------- + +function fooAnd34(x: String|null, y: String|null): string { + if (x != null && y != null) { + return x + " " + y; + } else if (x == null && y == null) { + return "null"; + } else if (x != null && y == null) { + return x; + } else if (x == null && y != null) { + return y; + } else { + throw new Error("Unreachable"); + } +} + +function fooOr134(x: String|null, y: String|null): string { + if (x != null || y != null) { + return "case 1"; + } else if (x == null && y == null) { + return "null"; + } else { + throw new Error("Unreachable"); + } +} + +function fooOr234(x: String|null, y: String|null): string { + if (x == null || y == null) { + return "case 1"; + } else if (x != null && y != null) { + return x + " " + y; + } else { + throw new Error("Unreachable"); + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_05.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C35 { + readonly a: boolean + constructor(a_: boolean = false) { + this.a = a_; + } +} + +function foo135(x: C35|null|undefined): string { + if (x == null || !x.a) { + return x != null ? "false1" : "null"; + } else { + return x.a ? "true2" : "false2"; + } +} + +function foo235(x: C35|null|undefined): string { + if (x != null && x.a) { + return "true"; + } else { + return x != null ? "false" : "null"; + } +} + +function bar35(x: C35|null|undefined, y: boolean, z: boolean): string { + if ((x instanceof C35 && y) || (x instanceof C35 && z)) { + return (x.a ? "true1" : "false1") + y + z; + } else { + return (x != null ? (x.a ? "true2" : "false2") : "null") + y + z; + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_06.ets +// --------------------------------------------------------------------------------------------------------------------- + +function foo36(x: int): string +{ + let rc: string|undefined = "default"; + + label1: switch(x) { + case 0: + rc = "case 0"; + case 1: { + let rc1: string|undefined = ():string => {return "case 1";}(); + label2: switch(rc) { + case "default": + rc = undefined; + break label2; + default: + break label1; + } + rc = rc1; + break; + } + case 2: + rc = undefined; + let rc2: string|null = ():string => {return "case 2";}(); + return rc2; + case 3: + rc = "case 3"; + break; + case 4: + rc = undefined; + default: + return rc != null ? rc :"case 4" + case 5: + rc = "case 5"; + } + + return rc; +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_08.ets +// --------------------------------------------------------------------------------------------------------------------- + +function foo37(flag37: boolean): int { + + let x: int|undefined = 0; + let y: int|undefined = 1; + let z: int|undefined = 2; + let w: int|undefined = 3; + + try { + y = 1; + if (flag37) { + throw new Error(); + } + } catch(ex: NullPointerError) { + z = 2; + } catch(ex) { + w = undefined; + } + + return x + y! + z + w!; +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_09.ets +// --------------------------------------------------------------------------------------------------------------------- + +class A38 { + prev_: A38|undefined = undefined; + next_: A38|undefined = undefined; + + m() { + const prev = this.prev_; + const next = this.next_; + + if (prev) { + this.prev_ = undefined; + prev.next_ = next; + } + + if (next) { + this.next_ = undefined; + next.prev_ = prev; + } + + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_10.ets +// --------------------------------------------------------------------------------------------------------------------- + +interface It39 { +} + +class Cl39 implements It39 { + + constructor(p: T39) { + this.x = p; + } + + static resolve(value: U|It39): Cl39 { + if (value instanceof Cl39) { + return value as Cl39; + } + return new Cl39(value as U); + } + + x: T39; + + print(): string { + if (this.x == undefined) { + return "value is " + this.x; + } + else if (this.x instanceof string) { + return "string: '" + this.x + "'"; + } else { + return "number = " + this.x; + } + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_11.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C41 {} + +function foo41(arg?: boolean): C41 | undefined { + if (arg == undefined) { + return undefined; + } + return arg == false ? undefined : new C41(); +} + +function bar41(arg?: boolean): C41 | undefined { + if (arg == true) return new C41(); + return arg == false ? undefined : new C41(); +} + +function baz41(arg?: boolean): int { + if (arg == undefined) return 0; + arktest.assertEQ(typeof arg, "boolean") + return 1; +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_13.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C43 {} + +function foo43(arg?: number): C43 | undefined { + if (arg == 5) return new C43(); + return arg == 3 ? undefined : new C43(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_14.ets +// --------------------------------------------------------------------------------------------------------------------- + +class A44 { + A44(a44?: T44 | number[]) { + if (a44 instanceof Error) { + return this.D(a44); + } else if (a44 instanceof undefined) { + return this.B(a44); + } else if (a44 instanceof number[]) { + return this.E(a44); + } else { + return this.C(a44); + } + } + + B(b: undefined) { + return "undefined"; + } + + C(c: T44) { + return "Generic"; + } + + D(d: Error) { + return "Error"; + } + + E(e: number[]) { + return "number[]" + } +} + +let a44 = new A44(); +arktest.assertEQ(a44.A44(Error()), "Error"); +arktest.assertEQ(a44.A44(undefined), "undefined"); +arktest.assertEQ(a44.A44(1), "Generic"); +arktest.assertEQ(a44.A44([1, 2, 3]), "number[]") + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_15.ets +// --------------------------------------------------------------------------------------------------------------------- + +// Issue #22779 - smart cast in return statement +function isEmpty45(text?: string): boolean { + return text === undefined || text === null || text.length === 0 +} + +// Some other examples +function foo45(text?: string): boolean { + let a: boolean = (text === undefined || text === null || text.length == 0) ? true : false + let b: boolean = text === undefined || text === null || text.length == 0 + let c: boolean = !(text !== undefined) || text === null || text.length == 0 + let d: boolean = (text !== undefined && text !== null) ? text.length == 0 : true + let e: boolean = (text != undefined && text != null) ? text.length == 0 : true + return a && b && c && d && e +} + +// --------------------------------------------------------------------------------------------------------------------- +// SmartCast_16.ets +// --------------------------------------------------------------------------------------------------------------------- + +class C45 { + readonly fld: T45 + constructor(p: T45) { + this.fld = p + } +} + +type NestedC45 = String | C45 | Error + + +function main(): void { + // ----------------------------------------------------------------------------------------------------------------- + // AccessBinaryTrees.ets + // ----------------------------------------------------------------------------------------------------------------- + + let a = new AccessBinaryTrees; + a.run(); + + // ----------------------------------------------------------------------------------------------------------------- + // ArrayLiteral.ets + // ----------------------------------------------------------------------------------------------------------------- + + let a1: byte = 2; + let b1: short = 20000; + let c1: int = 2000000; + let d1: long = 200000000000; + let e1: float = 2.2f; + let f1: double = 2.2222222222; + let g1: double[] = [a1, b1, c1, d1, e1, f1]; + arktest.assertEQ(g1[0], 2) + arktest.assertEQ(g1[1], 20000) + arktest.assertEQ(g1[2], 2000000) + arktest.assertEQ(g1[3], 200000000000) + arktest.assertEQ(g1[4], (Double.toFloat(2.2))) + arktest.assertEQ(g1[5], 2.2222222222) + + const h1: byte = 2; + const i1: short = 2; + const j1: int = 2; + const k1: long = 2; + const l1: float = 2.0f; + const m1: double = 2.0; + const n1: byte[] = [h1, Short.toByte(i1), j1, Long.toByte(k1), Float.toByte(l1), Double.toByte(m1)]; + arktest.assertEQ(n1[0], 2) + arktest.assertEQ(n1[1], 2) + arktest.assertEQ(n1[2], 2) + arktest.assertEQ(n1[3], 2) + arktest.assertEQ(n1[4], 2) + arktest.assertEQ(n1[5], 2) + + let o1: Object[] = [1, 1.1, "testStr", new Int(2), d1, k1]; + arktest.assertEQ(o1[0] as Int, 1) + arktest.assertEQ(o1[1] as Double, 1.1) + arktest.assertTrue((o1[2] as String).equals("testStr")) + arktest.assertEQ(o1[3] as Int, 2) + arktest.assertEQ(o1[4] as Long, 200000000000) + arktest.assertEQ(o1[5] as Long, 2) + + let p1: long[] = [new Int(3), new Short(2 as short), new Long(4)]; + arktest.assertEQ(p1[0], 3) + arktest.assertEQ(p1[1], 2) + arktest.assertEQ(p1[2], 4) + + // ----------------------------------------------------------------------------------------------------------------- + // RestTuple6.ets + // ----------------------------------------------------------------------------------------------------------------- + + let a12: [A2, B2] = [new A2, new B2] + arktest.assertTrue((new C2()).foo(...a12) == false) + arktest.assertTrue((new C2()).moo(12, ...a12) == false) + arktest.assertTrue((new C2()).foo(...[new A2, new B2]) == false) + arktest.assertTrue((new C2()).moo(12, ...[new A2, new B2]) == false) + arktest.assertTrue((new C2()).foo(...[new A2, new B2] as [A2, B2]) == false) + arktest.assertTrue((new C2()).moo(12, ...[new A2, new B2] as [A2, B2]) == false) + arktest.assertTrue((new C2()).foo(new A2, new B2) == false) + arktest.assertTrue((new C2()).moo(12, new A2, new B2) == false) + + // ----------------------------------------------------------------------------------------------------------------- + // GenericBridges_02.ets + // ----------------------------------------------------------------------------------------------------------------- + + ttt3(new D3()) + let c3: C3 = new E3(); + foo13(c3); + foo23(new E3()); + + // ----------------------------------------------------------------------------------------------------------------- + // OptionalChains.ets + // ----------------------------------------------------------------------------------------------------------------- + + test15(new Link5(), null) + test25(new Link5(), null) + test35(new Link5(), null) + test45(new Link5(), null) + test55(new Link5(), null) + + // ----------------------------------------------------------------------------------------------------------------- + // UnionAsAndInstanceof.ets + // ----------------------------------------------------------------------------------------------------------------- + + test_nullsafety6(); + test_unions6(); + + // ----------------------------------------------------------------------------------------------------------------- + // UncheckedCasts.ets + // ----------------------------------------------------------------------------------------------------------------- + + test_substitution7(); + test_substitution_memberexpr7(); + test_constraint7(); + test_basetype7(); + + // ----------------------------------------------------------------------------------------------------------------- + // partialTypeRuntime_2.ets + // ----------------------------------------------------------------------------------------------------------------- + + test_18(); + test_28(); + test_38(); + test_48(); + test_58(); + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_01.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(foo33("Test string"), "Case 1") + arktest.assertEQ(foo33(new Int(7)), "Case 3") + arktest.assertEQ(foo33(new C33()), "Case 2") + arktest.assertEQ(foo33(null), "Case 4") + arktest.assertEQ(foo33(undefined), "Case 5") + arktest.assertEQ(foo33(new Number(3.0)), "Case 5") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_02.ets + // ----------------------------------------------------------------------------------------------------------------- + + foo31("Test string"); + foo31(new Int(7)); + foo31(new C31()); + foo31(null); + foo31(undefined); + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_03.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(foo32("Test string"), "Case 1") + arktest.assertEQ(foo32("Test"), "Case 1") + arktest.assertEQ(foo32("Test string 2"), "Case 5") + arktest.assertEQ(foo32("test"), "Case 5") + + arktest.assertEQ(foo32(new Int(5)), "Case 3") + arktest.assertEQ(foo32(new Int(0)), "Case 3") + arktest.assertEQ(foo32(new Int(-5)), "Case 5") + + arktest.assertEQ(foo32(new C32(7)), "Case 2") + arktest.assertEQ(foo32(new C32()), "Case 2") + arktest.assertEQ(foo32(new C32(17)), "Case 5") + + arktest.assertEQ(foo32(null), "Case 4") + + arktest.assertEQ(foo32(undefined), "Case 5") + arktest.assertEQ(foo32(new Number(3.0)), "Case 5") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_04.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(fooAnd34("Test", "string"), "Test string") + arktest.assertEQ(fooAnd34("Test", null), "Test") + arktest.assertEQ(fooAnd34(null, "string"), "string") + arktest.assertEQ(fooAnd34(null, null), "null") + + arktest.assertEQ(fooOr134("Test", "string"), "case 1") + arktest.assertEQ(fooOr134("Test", null), "case 1") + arktest.assertEQ(fooOr134(null, "string"), "case 1") + arktest.assertEQ(fooOr134(null, null), "null") + + arktest.assertEQ(fooOr234("Test", "string"), "Test string") + arktest.assertEQ(fooOr234("Test", null), "case 1") + arktest.assertEQ(fooOr234(null, "string"), "case 1") + arktest.assertEQ(fooOr234(null, null), "case 1") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_05.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(foo135(null), "null") + arktest.assertEQ(foo235(null), "null") + arktest.assertEQ(bar35(null, true, true), "nulltruetrue") + arktest.assertEQ(bar35(null, true, false), "nulltruefalse") + arktest.assertEQ(bar35(null, false, true), "nullfalsetrue") + arktest.assertEQ(bar35(null, false, false), "nullfalsefalse") + + arktest.assertEQ(foo135(undefined), "null") + arktest.assertEQ(foo235(undefined), "null") + arktest.assertEQ(bar35(undefined, true, true), "nulltruetrue") + arktest.assertEQ(bar35(undefined, true, false), "nulltruefalse") + arktest.assertEQ(bar35(undefined, false, true), "nullfalsetrue") + arktest.assertEQ(bar35(undefined, false, false), "nullfalsefalse") + + let c = new C35(); + arktest.assertEQ(foo135(c), "false1") + arktest.assertEQ(foo235(c), "false") + arktest.assertEQ(bar35(c, true, true), "false1truetrue") + arktest.assertEQ(bar35(c, true, false), "false1truefalse") + arktest.assertEQ(bar35(c, false, true), "false1falsetrue") + arktest.assertEQ(bar35(c, false, false), "false2falsefalse") + + c = new C35(true); + arktest.assertEQ(foo135(c), "true2") + arktest.assertEQ(foo235(c), "true") + arktest.assertEQ(bar35(c, true, true), "true1truetrue") + arktest.assertEQ(bar35(c, true, false), "true1truefalse") + arktest.assertEQ(bar35(c, false, true), "true1falsetrue") + arktest.assertEQ(bar35(c, false, false), "true2falsefalse") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_06.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(foo36(0), "case 0") + arktest.assertEQ(foo36(1), "case 1") + arktest.assertEQ(foo36(2), "case 2") + arktest.assertEQ(foo36(3), "case 3") + arktest.assertEQ(foo36(4), "case 4") + arktest.assertEQ(foo36(5), "case 5") + arktest.assertEQ(foo36(7), "default") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_07.ets + // ----------------------------------------------------------------------------------------------------------------- + + let x363: int | boolean | string = 7; + arktest.assertEQ(x363, 7) + x363--; + arktest.assertEQ(x363, 6) + x363 = x363 == 7; + arktest.assertTrue(!x363) + x363 = !x363; + arktest.assertEQ(x363, true) + x363 = "x363 = " + x363.toString(); + arktest.assertEQ(x363, "x363 = true") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_08.ets + // ----------------------------------------------------------------------------------------------------------------- + + let flag37: boolean = false; + arktest.assertEQ(foo37(flag37), 6) + try { + foo37(!flag37); + } catch(ex) { + flag37 = true; + } + arktest.assertTrue(flag37) + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_10.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(Cl39.resolve(undefined).print(), "value is undefined") + arktest.assertEQ(Cl39.resolve("test").print(), "string: 'test'") + arktest.assertEQ(Cl39.resolve(5.5).print(), "number = 5.5") + arktest.assertEQ(Cl39.resolve(new Int(8)).print(), "number = 8") + + arktest.assertEQ(Cl39.resolve(new Cl39(null)).print(), "value is null") + arktest.assertEQ(Cl39.resolve(new Cl39("TEST")).print(), "string: 'TEST'") + arktest.assertEQ(Cl39.resolve(new Cl39(7.7)).print(), "number = 7.7") + arktest.assertEQ(Cl39.resolve(new Cl39(new Int(-8))).print(), "number = -8") + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_11.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertTrue(foo41(true) instanceof C41) + arktest.assertEQ(foo41(false), undefined) + arktest.assertEQ(foo41(), undefined) + + arktest.assertTrue(bar41(true) instanceof C41) + arktest.assertEQ(bar41(false), undefined) + arktest.assertTrue(bar41() instanceof C41) + + arktest.assertEQ(baz41(true), 1) + arktest.assertEQ(baz41(false), 1) + arktest.assertEQ(baz41(), 0) + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_12.ets + // ----------------------------------------------------------------------------------------------------------------- + + let resolve42: ((value: string) => void) | null = null; + + let p42 = new Promise((_resolve: (value: string)=> void): void => { + resolve42 = _resolve; + }); + + resolve42!("abc"); // no smart cast! + + let x42: Number|String|undefined = "test1"; + let y42: Number|String|undefined = "test2" + let z42: Number|String|undefined = 7 + + let lam42: () => void = () => { + let y42: Number|String|undefined = 2; // hides outer declaration! + x42 = z42; + let tmp: number = y42; // smart cast is used + arktest.assertEQ(tmp, 2); + }; + + if (x42 instanceof string) { + let tmp: string = x42 as string; // no smart cast! + arktest.assertEQ(tmp, "test1"); + } + + lam42(); + + arktest.assertEQ(x42, 7); + + if (y42 instanceof string) { + let tmp: string = y42; // smart cast is used + arktest.assertEQ(tmp, "test2"); + } + + let w42: number = z42; // smart cast is used + arktest.assertEQ(w42, 7) + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_13.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertTrue(foo43(5) instanceof C43) + arktest.assertEQ(foo43(3), undefined) + arktest.assertTrue(foo43(undefined) instanceof C43) + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_15.ets + // ----------------------------------------------------------------------------------------------------------------- + + arktest.assertEQ(isEmpty45(), true) + arktest.assertEQ(isEmpty45(""), true) + arktest.assertEQ(isEmpty45("a"), false) + arktest.assertEQ(foo45(), true) + + // ----------------------------------------------------------------------------------------------------------------- + // SmartCast_16.ets + // ----------------------------------------------------------------------------------------------------------------- + + let x45: NestedC45 = new C45>(new C45(new Error())) + let ok45 = x45 instanceof C45 && x45.fld instanceof C45 && x45.fld.fld instanceof Error + let aaa = ok45 ? 0 : 1 + +} diff --git a/ets2panda/test/benchmarks/etsstdlib-max.txt b/ets2panda/test/benchmarks/etsstdlib-max.txt new file mode 100644 index 0000000000000000000000000000000000000000..ab8a25fbeba5dce556305e95ec236cb135547251 --- /dev/null +++ b/ets2panda/test/benchmarks/etsstdlib-max.txt @@ -0,0 +1,66 @@ +================ es2panda perf metrics (Averaged over 500 runs) ================ + +:@phases : time=4770.18ms mem=324.00MB +:@GenerateProgram : time=2571.34ms mem=0.00MB +:@GenerateProgram/OptimizeBytecode : time=1896.82ms mem=0.00MB +:@phases/CheckerPhase : time=1781.74ms mem=81.00MB +:@EmitProgram : time=485.84ms mem=130.58MB +:@phases/Unbox : time=437.00ms mem=38.00MB +:@phases/ConstantExpressionLowering : time=363.29ms mem=0.28MB +:@phases/LambdaObjectConversion : time=328.18ms mem=22.00MB +:@phases/TopLevelStatements : time=277.34ms mem=83.00MB +:@phases/GradualTypeNarrowing : time=198.37ms mem=19.00MB +:@phases/ResolveIdentifiers : time=123.95ms mem=5.13MB +:@phases/OpAssignmentLowering : time=116.33ms mem=18.00MB +:@phases/InterfaceObjectLiteralLowering : time=76.22ms mem=7.00MB +:@phases/ScopesInitPhase : time=60.61ms mem=13.00MB +:@phases/ObjectIndexLowering : time=52.64ms mem=1.90MB +:@phases/PartialExportClassGen : time=50.08ms mem=8.00MB +:@phases/CreateGenericBridges : time=43.00ms mem=3.00MB +:@phases/RestArgsLowering : time=42.90ms mem=4.00MB +:@phases/BoxingForLocals : time=41.18ms mem=1.88MB +:@phases/PrimitiveConversion : time=39.01ms mem=4.00MB +:@phases/ArrayLiteralLowering : time=38.51ms mem=4.00MB +:@phases/LateInitializationConvert : time=38.24ms mem=0.00MB +:@phases/ObjectIteratorLowering : time=30.96ms mem=1.00MB +:@phases/UnionLowering : time=25.90ms mem=0.04MB +:@phases/ObjectLiteralLowering : time=25.72ms mem=0.00MB +:@phases/OptionalArgumentsLowering : time=25.23ms mem=0.22MB +:@phases/StringConstructorLowering : time=25.14ms mem=0.00MB +:@phases/TypeFromLowering : time=24.09ms mem=0.00MB +:@phases/ExpandBracketsPhase : time=23.46ms mem=0.00MB +:@phases/SetterLowering : time=23.02ms mem=0.27MB +:@phases/StringComparisonLowering : time=21.98ms mem=0.00MB +:@phases/RecordLowering : time=21.10ms mem=0.00MB +:@phases/ExtentionAccessorPhase : time=20.90ms mem=0.00MB +:@phases/InterfacePropertyDeclarationsPhase : time=20.54ms mem=1.00MB +:@phases/DynamicImport : time=20.29ms mem=0.00MB +:@phases/BigIntLowering : time=19.61ms mem=0.00MB +:@phases/EnumPostCheckLoweringPhase : time=19.03ms mem=0.21MB +:@phases/ResizableArrayConvert : time=18.56ms mem=0.48MB +:@phases/EnumLoweringPhase : time=18.53ms mem=0.83MB +:@phases/RestTupleConstructionPhase : time=18.49ms mem=0.23MB +:@phases/DefaultParametersLowering : time=18.43ms mem=0.26MB +:@phases/OptionalLowering : time=18.42ms mem=0.49MB +:@phases/AsyncMethodLowering : time=18.41ms mem=0.00MB +:@phases/OverloadMappingLowering : time=18.02ms mem=0.00MB +:@phases/SpreadConstructionPhase : time=17.69ms mem=0.00MB +:@phases/DeclareOverloadLowering : time=17.58ms mem=0.00MB +:@phases/PromiseVoidInferencePhase : time=17.22ms mem=0.00MB +:@phases/AnnotationCopyPostLowering : time=16.95ms mem=0.00MB +:@phases/AnnotationCopyLowering : time=16.86ms mem=0.00MB +:@phases/InsertOptionalParametersAnnotation : time=16.86ms mem=0.48MB +:@phases/AmbientLowering : time=16.77ms mem=0.00MB +:@phases/CapturedVariables : time=16.71ms mem=0.00MB +:@phases/ExpressionLambdaConstruction : time=16.60ms mem=0.03MB +:@phases/DefaultParametersInConstructorLowering : time=16.21ms mem=0.51MB +:@phases/SetJumpTargetPhase : time=16.00ms mem=0.00MB +:@phases/DeclGenPhase : time=0.02ms mem=0.00MB +:@phases/plugins-after-parse : time=0.01ms mem=0.00MB +:@phases/plugins-after-lowering : time=0.00ms mem=0.00MB +:@phases/plugins-after-bind : time=0.00ms mem=0.00MB +:@phases/CFGBuilder : time=0.00ms mem=0.00MB +:@phases/StringConstantsLowering : time=0.00ms mem=0.00MB +:@phases/plugins-after-check : time=0.00ms mem=0.00MB +:@phases/ExportAnonymousConstPhase : time=0.00ms mem=0.00MB +:@phases/PackageImplicitImport : time=0.00ms mem=0.00MB diff --git a/ets2panda/test/benchmarks/runner/arg_parser.py b/ets2panda/test/benchmarks/runner/arg_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..40cf4e5e8f1de82bcf3d3c86a5a612ad76564ef2 --- /dev/null +++ b/ets2panda/test/benchmarks/runner/arg_parser.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# Copyright (c) 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 argparse +import os + + +def parse_arguments() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Cpp headers parser to .yaml") + + parser.add_argument("--mode", "-m", type=str, required=True, help="Mode: 'static' or 'dynamic'") + parser.add_argument("--es2panda", "-e", type=str, required=True, help="Path to current es2panda") + parser.add_argument("--es2panda-pre-merge", "-c", type=str, required=False, help="Path to pre_merge es2panda") + parser.add_argument("--test-dir", "-t", type=str, required=True, help="Path to test directory with test files") + parser.add_argument("--work-dir", "-a", type=str, required=True, help="Path to the working temp folder") + parser.add_argument("--werror", "-w", action="store_true", help="Warnings as errors") + parser.add_argument( + "--dynamic-regression", + "-d", + type=float, + required=False, + default=0.05, + help="Acceptable regression compared to the pre_merge", + ) + parser.add_argument( + "--static-regression", + "-s", + type=float, + required=False, + default=0.1, + help="Acceptable regression compared to static measurement", + ) + parser.add_argument("--runs", "-n", type=int, required=False, default=25, help="Number of times to run the command") + + return parser.parse_args() + + +def check_arguments(args: argparse.Namespace) -> argparse.Namespace: + if args.mode not in ["static", "dynamic"]: + raise RuntimeError(f"Invalid mode: {args.mode}\nSee --help for more.") + if not os.path.isfile(args.es2panda): + raise RuntimeError(f"Bad path to current es2panda: {args.es2panda}\nSee --help for more.") + if args.mode == "dynamic" and not os.path.isfile(args.es2panda_pre_merge): + raise RuntimeError(f"Bad path to pre_merge es2panda: {args.es2panda_pre_merge}\nSee --help for more.") + if not os.path.isdir(args.test_dir): + raise RuntimeError(f"Bad path to test_dir: {args.test_dir}\nSee --help for more.") + if args.dynamic_regression > 1 or args.dynamic_regression < -1: + raise RuntimeError( + f"Static regression must be in value range [-1, 1], current: {args.dynamic_regression}\n" + "See --help for more." + ) + if args.static_regression > 1 or args.static_regression < -1: + raise RuntimeError( + f"Static regression must be in value range [-1, 1], current: {args.static_regression}\n" + "See --help for more." + ) + + return args diff --git a/ets2panda/test/benchmarks/runner/benchmark_comparator.py b/ets2panda/test/benchmarks/runner/benchmark_comparator.py new file mode 100644 index 0000000000000000000000000000000000000000..4e521f82f5a5521746483a9c4715a1a8d6b6c6b5 --- /dev/null +++ b/ets2panda/test/benchmarks/runner/benchmark_comparator.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# Copyright (c) 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 os +from pathlib import Path +from typing import Dict, Optional, Tuple, List, Callable + +from metrics_utils import parse_perf_file, format_diff, format_time_ms, format_mem_mb + + +def _get_phase_comparison(phase: str, base: Optional[Dict], new: Optional[Dict]) -> Tuple[str, str, str]: + if base and new: + label = phase + time_diff = new["time_ns"] - base["time_ns"] + mem_diff = new["mem_bytes"] - base["mem_bytes"] + time_str = format_diff(time_diff, base["time_ns"], format_time_ms) + mem_str = format_diff(mem_diff, base["mem_bytes"], format_mem_mb) + elif new: + label = f"{phase} [NEW]" + time_str = f"+{format_time_ms(new['time_ns'])}" + mem_str = f"+{format_mem_mb(new['mem_bytes'])}" + elif base: + label = f"{phase} [REMOVED]" + time_str = f"-{format_time_ms(base['time_ns'])}" + mem_str = f"-{format_mem_mb(base['mem_bytes'])}" + else: + return "", "", "" + return label, time_str, mem_str + + +def _write_report(report_path: Path, base_name: str, new_name: str, results: List[Dict]) -> None: + if not results: + print("No common or unique phases to compare.") + return + + max_phase_len = max(len(r["phase"]) for r in results) + header = f"Performance Comparison: '{base_name}' vs '{new_name}'\n" + "=" * 80 + + lines = [header] + for r in results: + phase_str = f":@{r['phase']}" + lines.append(f"{phase_str:<{max_phase_len + 3}}: time={r['time_str']:<25} mem={r['mem_str']:<25}") + + report_path.write_text("\n".join(lines), encoding="utf-8") + print(f"\n✅ Comparison finished! Results saved to: {report_path}") + + +def _print_and_log(level: str, msg: str, log_dir: Path) -> None: + if level == "Error": + print(f"\n❌ {msg}") + path = log_dir / "error_log.txt" + else: + print(f"\n⚠️ {msg}") + path = log_dir / "warning_log.txt" + with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_APPEND, mode=511), "a", encoding="utf-8") as f: + f.write(msg + "\n") + + +def _check_regression( + metric_name: str, + base_data: Dict, + new_data: Dict, + regression: float, + perf_name: str, + log_dir: Path, + is_static: bool = False, +) -> None: + format_func: Callable[[float], str] + success = True + if metric_name == "Time": + key = "time_ns" + format_func = format_time_ms + elif metric_name == "Memory": + key = "mem_bytes" + format_func = format_mem_mb + else: + raise RuntimeError(f"Unsupported metric: {metric_name}") + + base_sum = sum(base_data.get(p, {}).get(key, 0) for p in ["phases", "EmitProgram"]) + new_sum = sum(new_data.get(p, {}).get(key, 0) for p in ["phases", "EmitProgram"]) + + upper_threshold = base_sum * (1 + regression) + if new_sum > upper_threshold: + msg = ( + f"[PERF REGRESSION] Failed for {perf_name}: {metric_name} exceeded upper threshold.\n" + f"\tLimit: {regression:.1%}, Actual: +{((new_sum / base_sum) - 1) * 100:.2f}%\n" + f"\tBase: {format_func(base_sum)}, New: {format_func(new_sum)}\n" + f"\tThreshold: < {format_func(upper_threshold)}\n" + ) + _print_and_log("Error", msg, log_dir) + success = False + + lower_threshold = base_sum * (1 - regression * 3) + if is_static and new_sum < lower_threshold: + msg = ( + f"[UPDATE REQUIRED] Very good perf for {perf_name}: {metric_name} exceeded lower threshold.\n" + f"\tLimit: -{regression * 3:.1%}, Actual: {((new_sum / base_sum) - 1) * 100:.2f}%\n" + f"\tBase: {format_func(base_sum)}, New: {format_func(new_sum)}\n" + f"\tThreshold: > {format_func(lower_threshold)}\n\n" + "Please update *-max.txt.\n" + ) + _print_and_log("Warning", msg, log_dir) + success = False + + if success: + print(f"\n✅ {metric_name} regression check for {perf_name} finished!") + + +def compare_perf_files( + new_perf_path: Path, base_perf_path: Path, report_path: Path, regression: float, log_dir: Path +) -> None: + base_data = parse_perf_file(base_perf_path) + new_data = parse_perf_file(new_perf_path) + + if not new_data: + raise RuntimeError("New perf data is empty") + if not base_data: + raise RuntimeError("Base perf data is empty") + + is_static = base_perf_path.name.find("-max.txt") != -1 + _check_regression("Time", base_data, new_data, regression, new_perf_path.name, log_dir, is_static) + _check_regression("Memory", base_data, new_data, regression, new_perf_path.name, log_dir, is_static) + results = [] + all_phases = sorted(list(set(base_data.keys()) | set(new_data.keys()))) + + for phase in all_phases: + label, time_str, mem_str = _get_phase_comparison(phase, base_data.get(phase), new_data.get(phase)) + if label: + results.append({"phase": label, "time_str": time_str, "mem_str": mem_str}) + + _write_report(report_path, base_perf_path.name, new_perf_path.name, results) diff --git a/ets2panda/test/benchmarks/runner/benchmark_runner.py b/ets2panda/test/benchmarks/runner/benchmark_runner.py new file mode 100644 index 0000000000000000000000000000000000000000..9df01f66c625a38ad5c2baa461193ed63b366228 --- /dev/null +++ b/ets2panda/test/benchmarks/runner/benchmark_runner.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# Copyright (c) 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 subprocess +import re +from collections import defaultdict +from pathlib import Path +from typing import List, Dict, Union, DefaultDict + +from metrics_utils import parse_metric_value, format_time_ms, format_mem_mb + + +def run_and_parse(command: List) -> Dict: + print(f"Executing: {' '.join(command)}") + try: + result = subprocess.run(command, capture_output=True, text=True, check=True, encoding="utf-8") + except (FileNotFoundError, subprocess.CalledProcessError) as e: + print(f"Error executing command: {e}") + if isinstance(e, subprocess.CalledProcessError): + print(f"Stdout:\n{e.stdout}\nStderr:\n{e.stderr}") + return {} + + line_regex = re.compile(r":@(?P[\w\/-]+)\s*:\s*time=(?P