@@ -6,10 +6,12 @@ import {
66 IChatContent ,
77 IChatProgress ,
88 IAIBackService ,
9+ CancellationToken ,
10+ ChatResponse ,
911} from '@opensumi/ide-core-common' ;
1012import { ClientAppContribution , Domain , getIcon } from '@opensumi/ide-core-browser' ;
1113import { ComponentContribution , ComponentRegistry } from '@opensumi/ide-core-browser/lib/layout' ;
12- import { AINativeCoreContribution , ERunStrategy , IChatFeatureRegistry , IInlineChatFeatureRegistry , IRenameCandidatesProviderRegistry , ITerminalProviderRegistry , TChatSlashCommandSend , TerminalSuggestionReadableStream } from '@opensumi/ide-ai-native/lib/browser/types' ;
14+ import { AINativeCoreContribution , ERunStrategy , IChatFeatureRegistry , IInlineChatFeatureRegistry , IProblemFixContext , IProblemFixProviderRegistry , IRenameCandidatesProviderRegistry , ITerminalProviderRegistry , TChatSlashCommandSend , TerminalSuggestionReadableStream } from '@opensumi/ide-ai-native/lib/browser/types' ;
1315import { ICodeEditor , MarkdownString , NewSymbolNameTag } from '@opensumi/ide-monaco' ;
1416import { MessageService } from '@opensumi/ide-overlay/lib/browser/message.service' ;
1517import { BaseTerminalDetectionLineMatcher , JavaMatcher , MatcherType , NodeMatcher , NPMMatcher , ShellMatcher , TSCMatcher } from '@opensumi/ide-ai-native/lib/browser/contrib/terminal/matcher' ;
@@ -518,4 +520,35 @@ export class AINativeContribution implements ComponentContribution, AINativeCore
518520 return stream ;
519521 } ) ;
520522 }
523+
524+
525+ registerProblemFixFeature ( registry : IProblemFixProviderRegistry ) : void {
526+ registry . registerHoverFixProvider ( {
527+ provideFix : async (
528+ editor : ICodeEditor ,
529+ context : IProblemFixContext ,
530+ token : CancellationToken ,
531+ ) : Promise < ChatResponse | InlineChatController > => {
532+ const { marker, editRange } = context ;
533+
534+ const prompt = `原始代码内容:
535+ \`\`\`
536+ ${ editor . getModel ( ) ! . getValueInRange ( editRange ) }
537+ \`\`\`
538+
539+ lint error 信息:
540+
541+ ${ marker . message } .
542+
543+ 请根据 lint error 信息修复代码!
544+ 不需要任何解释,只要返回修复后的代码块内容` ;
545+
546+ const controller = new InlineChatController ( { enableCodeblockRender : true } ) ;
547+ const stream = await this . aiBackService . requestStream ( prompt , { } , token ) ;
548+ controller . mountReadable ( stream ) ;
549+
550+ return controller ;
551+ } ,
552+ } ) ;
553+ }
521554}
0 commit comments