Update for latest code mapper proposal (#213256)

This commit is contained in:
Matt Bierner
2024-05-22 13:10:07 -07:00
committed by GitHub
parent 886f3b7229
commit 85fe2e2daf
2 changed files with 22 additions and 28 deletions

View File

@@ -27,8 +27,8 @@ class TsMappedEditsProvider implements vscode.MappedEditsProvider {
}
const response = await this.client.execute('mapCode', {
mappings: [{
file,
file,
mapping: {
contents: codeBlocks,
focusLocations: context.documents.map(documents => {
return documents.flatMap((contextItem): FileSpan[] => {
@@ -39,7 +39,7 @@ class TsMappedEditsProvider implements vscode.MappedEditsProvider {
return contextItem.ranges.map((range): FileSpan => ({ file, ...Range.toTextSpan(range) }));
});
}),
}],
}
}, token);
if (response.type !== 'response' || !response.body) {
return;

View File

@@ -20,42 +20,36 @@ declare module '../../../../node_modules/typescript/lib/typescript' {
readonly _serverType?: ServerType;
}
export interface MapCodeRequestArgs {
/// The files and changes to try and apply/map.
mappings: MapCodeRequestDocumentMapping[];
/// Edits to apply to the current workspace before performing the mapping.
updates?: FileCodeEdits[]
export interface MapCodeRequestArgs extends FileRequestArgs {
/**
* The files and changes to try and apply/map.
*/
mapping: MapCodeRequestDocumentMapping;
}
export interface MapCodeRequestDocumentMapping {
/// The file for the request (absolute pathname required). Null/undefined
/// if specific file is unknown.
file?: string;
/// Optional name of project that contains file
projectFileName?: string;
/// The specific code to map/insert/replace in the file.
/**
* The specific code to map/insert/replace in the file.
*/
contents: string[];
/// Areas of "focus" to inform the code mapper with. For example, cursor
/// location, current selection, viewport, etc. Nested arrays denote
/// priority: toplevel arrays are more important than inner arrays, and
/// inner array priorities are based on items within that array. Items
/// earlier in the arrays have higher priority.
focusLocations?: FileSpan[][];
/**
* Areas of "focus" to inform the code mapper with. For example, cursor
* location, current selection, viewport, etc. Nested arrays denote
* priority: toplevel arrays are more important than inner arrays, and
* inner array priorities are based on items within that array. Items
* earlier in the arrays have higher priority.
*/
focusLocations?: TextSpan[][];
}
export interface MapCodeRequest extends Request {
command: 'mapCode',
export interface MapCodeRequest extends FileRequest {
command: 'mapCode';
arguments: MapCodeRequestArgs;
}
export interface MapCodeResponse extends Response {
body: FileCodeEdits[]
body: readonly FileCodeEdits[];
}
}
}