mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Update for latest code mapper proposal (#213256)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user