Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support proposed API registerMappedEditsProvider2 introduced in vscode 1.94 #14276

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## 1.55.0 - not yet released

- [plugin] supported MappedEditProviders proposed API evolution [#14276](https://github.com/eclipse-theia/theia/pull/14276) - Contributed on behalf of STMicroelectronics

## 1.54.0 - 09/26/2024

- [ai] add Theia AI LLM Support [Experimental] [#14048](https://github.com/eclipse-theia/theia/pull/14048)
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,10 @@ export function createAPIFactory(
registerMappedEditsProvider(documentSelector: theia.DocumentSelector, provider: theia.MappedEditsProvider): Disposable {
return Disposable.NULL;
},
/** @stubbed MappedEditsProvider */
registerMappedEditsProvider2(provider: theia.MappedEditsProvider2) {
return Disposable.NULL;
},
/** @stubbed ChatRequestHandler */
createChatParticipant(id: string, handler: theia.ChatRequestHandler): theia.ChatParticipant {
return {
Expand Down
49 changes: 45 additions & 4 deletions packages/plugin/src/theia.proposed.mappedEditsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,24 @@ export module '@theia/plugin' {
readonly ranges: Range[];
}

export interface ConversationRequest {
readonly type: 'request';
readonly message: string;
}

export interface ConversationResponse {
readonly type: 'response';
readonly message: string;
readonly references?: DocumentContextItem[];
}

export interface MappedEditsContext {
documents: DocumentContextItem[][];
readonly documents: DocumentContextItem[][];
/**
* The conversation that led to the current code block(s).
* The last conversation part contains the code block(s) for which the code mapper should provide edits.
*/
readonly conversation?: (ConversationRequest | ConversationResponse)[];
}

/**
Expand All @@ -38,9 +54,8 @@ export module '@theia/plugin' {
/**
* Provide mapped edits for a given document.
* @param document The document to provide mapped edits for.
* @param codeBlocks Code blocks that come from an LLM's reply.
* "Insert at cursor" in the panel chat only sends one edit that the user clicks on, but inline chat can send multiple blocks
* and let the lang server decide what to do with them.
* @param codeBlocks Code blocks that come from an LLM's reply. "Apply in Editor" in the panel chat only sends one edit that the user clicks on, but inline chat can send
* multiple blocks and let the lang server decide what to do with them.
* @param context The context for providing mapped edits.
* @param token A cancellation token.
* @returns A provider result of text edits.
Expand All @@ -53,7 +68,33 @@ export module '@theia/plugin' {
): ProviderResult<WorkspaceEdit | null>;
}

export interface MappedEditsRequest {
readonly codeBlocks: { code: string; resource: Uri }[];
// for every prior response that contains codeblocks, make sure we pass the code as well as the resources based on the reported codemapper URIs
readonly conversation: (ConversationRequest | ConversationResponse)[];
}

export interface MappedEditsResponseStream {
textEdit(target: Uri, edits: TextEdit | TextEdit[]): void;
}

export interface MappedEditsResult {
readonly errorMessage?: string;
}

/**
* Interface for providing mapped edits for a given document.
*/
export interface MappedEditsProvider2 {
provideMappedEdits(
request: MappedEditsRequest,
result: MappedEditsResponseStream,
token: CancellationToken
): ProviderResult<MappedEditsResult>;
}

export namespace chat {
export function registerMappedEditsProvider(documentSelector: DocumentSelector, provider: MappedEditsProvider): Disposable;
export function registerMappedEditsProvider2(provider: MappedEditsProvider2): Disposable;
}
}
Loading