diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 1f86fc3df7416f2d492275ae8f6650f852ffd5e8..09e1644514c8e4534fcfe7b130e52f0896fa66f6 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -110,14 +110,13 @@ class ParseIntent { node.members.forEach((member) => { if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword) && this.hasDecorator(member, [COMPONENT_USER_INTENTS_DECORATOR_METHOD])) { - const errorMessage: string = 'Methods decorated with @InsightIntentFunctionMethod must be in a class decorated with @InsightIntentFunction.'; + const errorMessage: string = '@InsightIntentFunctionMethod must be declared under the @InsightIntentFunction decorator'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: node.getStart(), - code: '10110013', - description: 'InsightIntent Compiler Error', - solutions: ['Either move the method or add @InsightIntentFunction to the class'] + code: '10105110', + description: 'ArkTs InsightIntent Error' }); return; } @@ -162,14 +161,13 @@ class ParseIntent { this.checker = checker; this.currentFilePath = filepath; if (!filepath.endsWith('.ets')) { - const errorMessage: string = 'The intent decorator can only be used in .ets files.'; + const errorMessage: string = 'IntentDecorator needs to be in the .ets file'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10101001', - description: 'InsightIntent Compiler Error', - solutions: ['Move it to an .ets file'] + code: '10101002', + description: 'ArkTs InsightIntent Error' }); return; } @@ -243,14 +241,13 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10101002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } @@ -280,28 +277,26 @@ class ParseIntent { this.analyzeBaseClass(node, pkgParams, intentObj, COMPONENT_USER_INTENTS_DECORATOR_ENTITY); this.createObfuscation(node); if (this.entityMap.has(entityClassName)) { - const errorMessage: string = 'Multiple @InsightIntentEntity decorators applied to the same class.'; + const errorMessage: string = 'class can be decorated with at most one @InsightIntentEntity'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110021', - description: 'InsightIntent Compiler Error', - solutions: ['Remove duplicates'] + code: '10101004', + description: 'ArkTs InsightIntent Error' }); return; } else { this.entityMap.set(entityClassName, intentObj); } } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = '10101003 ArkTs InsightIntent Error\n' + + 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003' }); return; } @@ -311,14 +306,14 @@ class ParseIntent { pkgParams: object): void { const expr: ts.Expression = decorator.expression; if (ts.isClassDeclaration(node)) { - const errorMessage: string = `@InsightIntentPage must be applied to a struct page.`; + const errorMessage: string = `@InsightIntentPage must be decorated on struct` + + `, className: ${node.name.getText()}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110016', - description: 'InsightIntent Compiler Error', - solutions: ['Decorate a struct page with @InsightIntentPage'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } @@ -337,33 +332,19 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } } private handleMethodDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator): void { - const isExported: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); - if (!isExported) { - const errorMessage: string = 'The class decorated with @InsightIntentFunction must be exported.'; - this.transformLog.push({ - type: LogType.ERROR, - message: errorMessage, - pos: this.currentNode.getStart(), - code: '10110014', - description: 'InsightIntent Compiler Error', - solutions: ['Add an export statement'] - }); - return; - } const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { Object.assign(intentObj, { @@ -371,13 +352,22 @@ class ParseIntent { 'moduleName': projectConfig.moduleName, 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_METHOD }); - const methodParameters: methodParametersInfo[] = this.parseClassMethods(node, COMPONENT_USER_INTENTS_DECORATOR_METHOD); - methodParameters?.forEach(methodDecorator => { + + interface methodParametersInfo { + functionName: string, + parameters: Record, + args: ts.NodeArray, + } + + const methodParameters: methodParametersInfo[] = + this.parseClassMethods(node, COMPONENT_USER_INTENTS_DECORATOR_METHOD); + methodParameters.forEach(methodDecorator => { const functionName: string = methodDecorator.functionName; const methodArgs: ts.NodeArray = methodDecorator.args; const properties: Record = methodDecorator.parameters; const functionParamList: Array = Object.keys(properties); - const methodObj: object = Object.assign({}, intentObj, { functionName, 'functionParamList': functionParamList }); + const methodObj: object = + Object.assign({}, intentObj, { functionName, 'functionParamList': functionParamList }); this.analyzeDecoratorArgs(methodArgs, methodObj, intentMethodInfoChecker); if (this.isUpdateCompile) { this.updatePageIntentObj.get(methodObj.decoratorFile).push(methodObj); @@ -386,14 +376,13 @@ class ParseIntent { }); this.createObfuscation(node); } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } @@ -415,14 +404,13 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10101002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } @@ -430,20 +418,6 @@ class ParseIntent { private handleEntryDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator, pkgParams: object): void { - const isExported: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); - const isDefault: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.DefaultKeyword); - if (!(isExported && isDefault)) { - const errorMessage: string = 'The class decorated with @InsightIntentEntry must be exported as default.'; - this.transformLog.push({ - type: LogType.ERROR, - message: errorMessage, - pos: this.currentNode.getStart(), - code: '10110019', - description: 'InsightIntent Compiler Error', - solutions: ['Use the \'export default\' syntax'] - }); - return; - } const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { const args: ts.NodeArray = expr.arguments; @@ -463,14 +437,13 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - const errorMessage: string = 'Decorators must be called as functions.'; + const errorMessage: string = 'Decorator is not CallExpression'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10101002', - description: 'InsightIntent Compiler Error', - solutions: ['Add parentheses after the decorator name'] + code: '10101003', + description: 'ArkTs InsightIntent Error' }); return; } @@ -490,14 +463,13 @@ class ParseIntent { const isExported: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); const isDefault: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.DefaultKeyword); if (!(bindFormInfo && isExported && isDefault)) { - const errorMessage: string = '@InsightIntentForm must be applied to formExtensionAbility.'; + const errorMessage: string = '@InsightIntentForm must be decorated on a formExtensionAbility'; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110022', - description: 'InsightIntent Compiler Error', - solutions: ['Decorate the formExtensionAbility class with @InsightIntentForm'] + code: '10101006', + description: 'ArkTs InsightIntent Error' }); return; } @@ -522,36 +494,22 @@ class ParseIntent { } }); if (!formNameFound) { - const errorMessage: string = 'formName in @InsightIntentForm must match the widget name registered in formExtensionAbility.'; + const errorMessage: string = '@InsightIntentForm param formName must match the card name. ' + + `Provided name: ${intentObj.formName}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110023', - description: 'InsightIntent Compiler Error', - solutions: ['Update formName to match the registered widget name'] + code: '10101006', + description: 'ArkTs InsightIntent Error' }); return; } } private readModuleJsonInfo(pkgParams: object): void { - const moduleJsonPath: string = path.join(pkgParams.pkgPath, 'src/main', 'module.json5'); - if (!fs.existsSync(moduleJsonPath)) { - const errorMessage: string = `The module.json5 file is missing.`; - this.transformLog.push({ - type: LogType.ERROR, - message: errorMessage, - pos: this.currentNode.getStart(), - code: '10110024', - description: 'InsightIntent Compiler Error', - solutions: ['Check the expected paths (typically entry/src/main/config.json or module.json5) and restore the file'] - }); - return; - } - if (!projectConfig.modulePathMap) { - return; - } + const moduleJsonPath: string = path.join(pkgParams.pkgPath, 'src', 'main', 'module.json5'); + if (fs.existsSync(moduleJsonPath)) { const jsonStr: string = fs.readFileSync(moduleJsonPath, 'utf8'); const obj: object = json5.parse(jsonStr); if (obj.module?.abilities) { @@ -560,20 +518,31 @@ class ParseIntent { if (obj.module?.extensionAbilities) { this.moduleJsonInfo.set('extensionAbilities', obj.module.extensionAbilities); } + } else { + const errorMessage: string = ` module.json5 not found, expect moduleJsonPath: ${moduleJsonPath}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101007', + description: 'ArkTs InsightIntent Error' + }); + return; + } } private validatePagePath(intentObj: object, pkgParams: object): void { if (pkgParams.pkgPath) { - const normalPagePath: string = path.join(pkgParams.pkgPath, 'src/main', intentObj.pagePath + '.ets'); + const normalPagePath: string = path.join(pkgParams.pkgPath, 'src', 'main', intentObj.pagePath + '.ets'); if (!fs.existsSync(normalPagePath)) { - const errorMessage: string = `PagePath in @InsightIntentPage does not match the actual page path.`; + const errorMessage: string = `@InsightIntentPage pagePath incorrect,` + + `${normalPagePath} does not exist, invalidDecoratorPath: ${this.currentFilePath}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110017', - description: 'InsightIntent Compiler Error', - solutions: ['Verify the file path'] + code: '10101008', + description: 'ArkTs InsightIntent Error' }); return; } else { @@ -612,14 +581,14 @@ class ParseIntent { const parentNode: ts.ExpressionWithTypeArguments = interfaces[0]; this.analyzeClassHeritage(parentNode, node, pkgParams, intentObj); } else { - const errorMessage: string = `Classes decorated with @InsightIntentEntity must implement InsightIntent.IntentEntity.`; + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110021', - description: 'InsightIntent Compiler Error', - solutions: ['Add the implementation or inherit from a base intent entity'] + code: '10101009', + description: 'ArkTs InsightIntent Error' }); return; } @@ -635,14 +604,14 @@ class ParseIntent { const parentFilePath: string = parentNodeSymbol.getDeclarations()?.[0].getSourceFile().fileName; const isGlobalPathFlag: boolean = this.isGlobalPath(parentFilePath); if (!(isGlobalPathFlag && parentClassName === 'InsightIntentEntryExecutor')) { - const errorMessage: string = `Classes decorated with @InsightIntentEntry must inherit from InsightIntentEntryExecutor.`; + const errorMessage: string = + `decorated with @InsightIntentEntry must be inherited to InsightIntentEntryExecutor`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110018', - description: 'InsightIntent Compiler Error', - solutions: ['Add the inheritance'] + code: '10101010', + description: 'ArkTs InsightIntent Error' }); return; } @@ -652,14 +621,13 @@ class ParseIntent { const recordPath: string = isGlobalPathFlag ? `sdk` : `@normalized:${parentRecordName}`; this.collectClassInheritanceInfo(parentNode, intentObj, parentClassName, recordPath); } else { - const errorMessage: string = `Classes decorated with @InsightIntentEntry must inherit from InsightIntentEntryExecutor.`; + const errorMessage: string = `decorated with @InsightIntentEntry must be inherited to InsightIntentEntryExecutor`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110018', - description: 'InsightIntent Compiler Error', - solutions: ['Add the inheritance'] + code: '10101010', + description: 'ArkTs InsightIntent Error' }); return; } @@ -672,7 +640,7 @@ class ParseIntent { private parseClassMethods(classNode: ts.ClassDeclaration, decoratorType: string): methodParametersInfo[] { const methodsArr: methodParametersInfo[] = []; for (const member of classNode.members) { - if (!ts.isMethodDeclaration(member)) { + if (!ts.isMethodDeclaration(member) || !this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { continue; } const decorator: ts.ModifierLike = member.modifiers?.find(modifier => { @@ -686,18 +654,6 @@ class ParseIntent { return decoratorName === decoratorType; }); if (decorator && ts.isCallExpression(decorator.expression)) { - if (!this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { - const errorMessage: string = `Methods decorated with @InsightIntentFunctionMethod must be static.`; - this.transformLog.push({ - type: LogType.ERROR, - message: errorMessage, - pos: this.currentNode.getStart(), - code: '10110015', - description: 'InsightIntent Compiler Error', - solutions: ['Change the method to static'] - }); - return undefined; - } let parameters: Record = {}; member.parameters.forEach(param => { const paramName: string = param.name.getText(); @@ -741,14 +697,14 @@ class ParseIntent { getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); if (isGlobalPathFlag) { if (parentClassName !== 'IntentEntity') { - const errorMessage: string = `Classes decorated with @InsightIntentEntity must implement InsightIntent.IntentEntity.`; + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110021', - description: 'InsightIntent Compiler Error', - solutions: ['Add the implementation or inherit from a base intent entity'] + code: '10101009', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1055,14 +1011,13 @@ class ParseIntent { }); } if (!flag) { - const errorMessage: string = `Decorator parameters must be compile-time constants.`; + const errorMessage: string = `Dynamic variable cannot be resolved`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110000', - description: 'InsightIntent Compiler Error', - solutions: ['Use a fixed value (such as a string literal) instead of a variable'] + code: '10101011', + description: 'ArkTs InsightIntent Error' }); return false; } @@ -1087,14 +1042,13 @@ class ParseIntent { } const missingFields: (keyof T)[] = requiredFields.filter(f => !existingParams.has(f)); if (missingFields.length > 0) { - const errorMessage: string = `Required parameters are missing for the decorator.`; + const errorMessage: string = `Decorator args missing required param, cause params: ${missingFields.join(', ')}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110003', - description: 'InsightIntent Compiler Error', - solutions: ['Add the required parameters as specified in the error message'] + code: '10101012', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1128,14 +1082,14 @@ class ParseIntent { const paramName: keyof T = prop.name.text; if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { if (!allowedFields.has(paramName)) { - const errorMessage: string = `The parameter type does not match the decorator's requirement.`; + const errorMessage: string = + `Decorator args missing required param, cause undeclared param: ${paramName.toString()}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110004', - description: 'InsightIntent Compiler Error', - solutions: ['Adjust the type to match the expected type'] + code: '10101012', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1144,27 +1098,25 @@ class ParseIntent { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop.initializer); const declaration: ts.Declaration = symbol?.valueDeclaration; if (validator && !validator(declaration?.initializer)) { - const errorMessage: string = `Unsupported parameters found in the decorator.`; + const errorMessage: string = `Param parsing occurs error param type, cause param: ${paramName.toString()}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110005', - description: 'InsightIntent Compiler Error', - solutions: ['Remove any parameters that are not supported'] + code: '10101013', + description: 'ArkTs InsightIntent Error' }); return; } } else { if (validator && !validator(prop.initializer)) { - const errorMessage: string = `Unsupported parameters found in the decorator.`; + const errorMessage: string = `Param parsing occurs error param type, cause param: ${paramName.toString()}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110005', - description: 'InsightIntent Compiler Error', - solutions: ['Remove any parameters that are not supported'] + code: '10101013', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1206,12 +1158,13 @@ class ParseIntent { private parseStaticObject(node: ts.Node, visited: Set = new Set()): StaticValue | undefined { if (visited.has(node)) { - const errorMessage: string = `Circular dependencies detected in decorator parameters.`; + const errorMessage: string = `Circular reference detected in param`; this.transformLog.push({ - type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110006', - description: 'InsightIntent Compiler Error', - solutions: ['Refactor the data structure by extracting common variables or using ID references to avoid nesting'] + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101023', + description: 'ArkTs InsightIntent Error' }); return undefined; } @@ -1244,12 +1197,13 @@ class ParseIntent { if (ts.isPropertyAccessExpression(node)) { return this.processEnumElement(node); } - const errorMessage: string = `Unsupported parameters found in the decorator.`; + const errorMessage: string = `Unsupported parameter type cannot be parsed, cause param: ${node.text}`; this.transformLog.push({ - type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110005', - description: 'InsightIntent Compiler Error', - solutions: ['Remove any parameters that are not supported'] + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101014', + description: 'ArkTs InsightIntent Error' }); return undefined; } @@ -1291,14 +1245,13 @@ class ParseIntent { } else if (paramCategoryEnum.has(enumValue)) { return paramCategoryEnum.get(enumValue); } else { - const errorMessage: string = `Unsupported parameters found in the decorator.`; + const errorMessage: string = `Unsupported parameter type cannot be parsed, cause param: ${node.text}`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110005', - description: 'InsightIntent Compiler Error', - solutions: ['Remove any parameters that are not supported'] + code: '10101014', + description: 'ArkTs InsightIntent Error' }); return ''; } @@ -1395,14 +1348,14 @@ class ParseIntent { private verifyInheritanceChain(): void { this.EntityHeritageClassSet.forEach(entityClassInfo => { if (!this.heritageClassSet.has(entityClassInfo)) { - const errorMessage: string = `Classes decorated with @InsightIntentEntity must implement InsightIntent.IntentEntity.`; + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110021', - description: 'InsightIntent Compiler Error', - solutions: ['Add the implementation or inherit from a base intent entity'] + code: '10101009', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1416,15 +1369,14 @@ class ParseIntent { const paramsSchema: object = schemaObj.properties; const keyArr: string[] = Object.keys(paramsSchema); keyArr.forEach(key => { - if (!schemaData[key]?.type && reqData.get(key)) { - const errorMessage: string = `A required field in the class property is missing.`; + if (!schemaData[key] && reqData.get(key)) { + const errorMessage: string = `Schema verification required parameter does not exist`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110008', - description: 'InsightIntent Compiler Error', - solutions: ['Add the required field as specified by the JSON Schema'] + code: '10101016', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1435,16 +1387,14 @@ class ParseIntent { private schemaPropertiesValidation(schemaData: Record, schemaObj: object): void { if (schemaObj.properties) { Object.entries(schemaObj.properties).forEach(([key, value]) => { - if ((schemaData[key]?.type && value.type !== schemaData[key].type) || - value.type === 'object' && schemaData[key]?.isEntity === false) { - const errorMessage: string = `The field type of the class property does not match the JSON Schema.`; + if (schemaData[key] && value.type !== schemaData[key]) { + const errorMessage: string = `Schema verification parameter type error`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110009', - description: 'InsightIntent Compiler Error', - solutions: ['Correct the type to match the requirement'] + code: '10101017', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1466,14 +1416,13 @@ class ParseIntent { } }); if (count !== 1) { - const errorMessage: string = `The class property parameter violates the oneOf/anyOf validation rules in the JSON Schema.`; + const errorMessage: string = `Not meeting the one of schema verification rules`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110010', - description: 'InsightIntent Compiler Error', - solutions: ['Modify it to satisfy the rules'] + code: '10101024', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1490,14 +1439,13 @@ class ParseIntent { } }); if (count === 0) { - const errorMessage: string = `The class property parameter violates the oneOf/anyOf validation rules in the JSON Schema.`; + const errorMessage: string = `Not meeting the any of schema verification rules`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110010', - description: 'InsightIntent Compiler Error', - solutions: ['Modify it to satisfy the rules'] + code: '10101018', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1515,14 +1463,13 @@ class ParseIntent { this.schemaValidateSync(schemaData, schemaObj.items.items); } if (schemaObj.type !== 'object') { - const errorMessage: string = `The root type of the JSON Schema for Parameters must be object.`; + const errorMessage: string = `Schema root type must be object`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110007', - description: 'InsightIntent Compiler Error', - solutions: ['Change the top-level definition to {"type":"object", ...}'] + code: '10101019', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1543,14 +1490,13 @@ class ParseIntent { private schemaAdditionalPropertiesValidation(schemaData, schemaProps): void { for (const key of Object.keys(schemaData)) { if (!schemaProps[key]) { - const errorMessage: string = `The class property includes parameters not defined in the JSON Schema.`; + const errorMessage: string = `Schema does not allow more parameters`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110011', - description: 'InsightIntent Compiler Error', - solutions: ['Remove any extra parameters'] + code: '10101025', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1633,14 +1579,13 @@ class ParseIntent { fs.writeFileSync(fullPath, updatedJson, 'utf8'); } } catch (e) { - const errorMessage: string = `Failed to write to the intent configuration file.`; + const errorMessage: string = `Internal error writeFile error`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110025', - description: 'InsightIntent Compiler Error', - solutions: ['Check file permissions, free disk space, or restart DevEco Studio'] + code: '10101020', + description: 'ArkTs InsightIntent Error' }); return; } @@ -1649,14 +1594,13 @@ class ParseIntent { private processIntentData(harIntentDataObj: object): object { this.matchEntities(); if (!projectConfig.aceProfilePath) { - const errorMessage: string = `Internal error: aceProject not found due to project configuration issues.`; + const errorMessage: string = `Internal error aceProfilePath not found`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110026', - description: 'InsightIntent Compiler Error', - solutions: ["Verify the project's compile configuration"] + code: '10101020', + description: 'ArkTs InsightIntent Error' }); return null; } @@ -1744,14 +1688,13 @@ class ParseIntent { }); writeJsonData.extractInsightIntents?.forEach(item => { if (duplicates.has(item.intentName)) { - const errorMessage: string = `Duplicate intentName definitions found.`; + const errorMessage: string = `User intents has duplicate intentName param`; this.transformLog.push({ type: LogType.ERROR, message: errorMessage, pos: this.currentNode.getStart(), - code: '10110012', - description: 'InsightIntent Compiler Error', - solutions: ['Rename or remove duplicate entries'] + code: '10101021', + description: 'ArkTs InsightIntent Error' }); return; } else if (item.intentName !== undefined) {