From de9585a85db7c138a193aa81be2af4cc1d0ce687 Mon Sep 17 00:00:00 2001 From: anjiaqi Date: Mon, 4 Aug 2025 19:01:26 +0800 Subject: [PATCH] Add message to SuggestionInfo Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQYMJ Signed-off-by: anjiaqi --- arkui-plugins/ui-syntax-plugins/processor/index.ts | 1 + .../ui-syntax-plugins/rules/ui-syntax-rule.ts | 1 + koala-wrapper/native/src/bridges.cc | 10 ++++++---- koala-wrapper/src/Es2pandaNativeModule.ts | 2 +- koala-wrapper/src/arkts-api/peers/SuggestionInfo.ts | 5 +++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arkui-plugins/ui-syntax-plugins/processor/index.ts b/arkui-plugins/ui-syntax-plugins/processor/index.ts index da01b60ef..b491105da 100644 --- a/arkui-plugins/ui-syntax-plugins/processor/index.ts +++ b/arkui-plugins/ui-syntax-plugins/processor/index.ts @@ -82,6 +82,7 @@ class ConcreteUISyntaxRuleContext implements UISyntaxRuleContext { const suggestionInfo: arkts.SuggestionInfo = arkts.SuggestionInfo.create( suggestionKind, fixSuggestion.code, + fixSuggestion.title ? fixSuggestion.title : '', sourceRange ); arkts.Diagnostic.logDiagnosticWithSuggestion(diagnosticInfo, suggestionInfo); diff --git a/arkui-plugins/ui-syntax-plugins/rules/ui-syntax-rule.ts b/arkui-plugins/ui-syntax-plugins/rules/ui-syntax-rule.ts index 77e44ebf5..817d5ddd0 100644 --- a/arkui-plugins/ui-syntax-plugins/rules/ui-syntax-rule.ts +++ b/arkui-plugins/ui-syntax-plugins/rules/ui-syntax-rule.ts @@ -19,6 +19,7 @@ import { UISyntaxRuleComponents } from 'ui-syntax-plugins/utils'; export type FixSuggestion = { range: [start: arkts.SourcePosition, end: arkts.SourcePosition]; + title?: string; code: string; }; diff --git a/koala-wrapper/native/src/bridges.cc b/koala-wrapper/native/src/bridges.cc index 4e0a1f331..188983c25 100644 --- a/koala-wrapper/native/src/bridges.cc +++ b/koala-wrapper/native/src/bridges.cc @@ -653,7 +653,8 @@ KOALA_INTEROP_5(CreateDiagnosticInfo, KNativePointer, KNativePointer, KNativePoi KStringArray, KInt, KNativePointer); KNativePointer impl_CreateSuggestionInfo(KNativePointer context, KNativePointer kind, KStringArray argsPtr, - KInt argc, KStringPtr& substitutionCode, KNativePointer range) + KInt argc, KStringPtr& substitutionCode, KStringPtr& title, + KNativePointer range) { const auto _context = reinterpret_cast(context); const auto _kind = reinterpret_cast(kind); @@ -669,10 +670,11 @@ KNativePointer impl_CreateSuggestionInfo(KNativePointer context, KNativePointer position += strLen; } const auto _substitutionCode = getStringCopy(substitutionCode); - return GetImpl()->CreateSuggestionInfo(_context, _kind, _args, argc, _substitutionCode, _range); + const auto _title = getStringCopy(title); + return GetImpl()->CreateSuggestionInfo(_context, _kind, _args, argc, _substitutionCode, _title, _range); } -KOALA_INTEROP_6(CreateSuggestionInfo, KNativePointer, KNativePointer, KNativePointer, - KStringArray, KInt, KStringPtr, KNativePointer); +KOALA_INTEROP_7(CreateSuggestionInfo, KNativePointer, KNativePointer, KNativePointer, + KStringArray, KInt, KStringPtr, KStringPtr, KNativePointer); void impl_LogDiagnostic(KNativePointer context, KNativePointer kind, KStringArray argvPtr, KInt argc, KNativePointer pos) diff --git a/koala-wrapper/src/Es2pandaNativeModule.ts b/koala-wrapper/src/Es2pandaNativeModule.ts index ebdb8ed3d..5be8a563b 100644 --- a/koala-wrapper/src/Es2pandaNativeModule.ts +++ b/koala-wrapper/src/Es2pandaNativeModule.ts @@ -931,7 +931,7 @@ export class Es2pandaNativeModule { } _CreateSuggestionInfo(context: KNativePointer, kind: KNativePointer, args: string[], - argc: number, substitutionCode: string, range?: KNativePointer): KNativePointer { + argc: number, substitutionCode: string, title: string, range?: KNativePointer): KNativePointer { throw new Error('Not implemented'); } diff --git a/koala-wrapper/src/arkts-api/peers/SuggestionInfo.ts b/koala-wrapper/src/arkts-api/peers/SuggestionInfo.ts index df8fe6754..2155597bf 100644 --- a/koala-wrapper/src/arkts-api/peers/SuggestionInfo.ts +++ b/koala-wrapper/src/arkts-api/peers/SuggestionInfo.ts @@ -25,9 +25,10 @@ export class SuggestionInfo extends ArktsObject { super(peer); } - static create(kind: DiagnosticKind, substitutionCode: string, range: SourceRange, ...args: string[]): SuggestionInfo { + static create(kind: DiagnosticKind, substitutionCode: string, title: string, range: SourceRange, ...args: string[]): SuggestionInfo { return new SuggestionInfo( - global.es2panda._CreateSuggestionInfo(global.context, kind.peer, passStringArray(args), args.length, substitutionCode, range.peer) + global.es2panda._CreateSuggestionInfo(global.context, kind.peer, passStringArray(args), + args.length, substitutionCode, title, range.peer) ); } -- Gitee