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

Update for latest code mapper proposal #213256

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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[] => {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}
}
}


Loading