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 WorkspaceEditMetadata in workspace/applyEdit #1390

Merged
merged 5 commits into from
Jan 17, 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
3 changes: 2 additions & 1 deletion client/src/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
workspaceEdit.changeAnnotationSupport = {
groupsOnLabel: true
};
workspaceEdit.metadataSupport = true;
workspaceEdit.snippetEditSupport = true;

const diagnostics = ensure(ensure(result, 'textDocument')!, 'publishDiagnostics')!;
Expand Down Expand Up @@ -1992,7 +1993,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
if (versionMismatch) {
return Promise.resolve({ applied: false });
}
return Is.asPromise(Workspace.applyEdit(converted).then((value) => { return { applied: value }; }));
return Is.asPromise(Workspace.applyEdit(converted, { isRefactoring: params.metadata?.isRefactoring }).then((value) => { return { applied: value }; }));
}

private static RequestsToCancelOnContentModified: Set<string> = new Set([
Expand Down
18 changes: 17 additions & 1 deletion protocol/src/common/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ProgressToken, RequestHandler, TraceValue } from 'vscode-jsonrpc';
import { MessageDirection, ProtocolRequestType, ProtocolRequestType0, ProtocolNotificationType, ProtocolNotificationType0 } from './messages';

import {
Position, Range, Location, LocationLink, Diagnostic, Command, TextEdit, WorkspaceEdit, DocumentUri,
Position, Range, Location, LocationLink, Diagnostic, Command, TextEdit, WorkspaceEdit, WorkspaceEditMetadata, DocumentUri,
TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, CompletionItem, CompletionList,
Hover, SignatureHelp, Definition, DefinitionLink, ReferenceContext, DocumentHighlight, SymbolInformation,
CodeLens, CodeActionContext, FormattingOptions, DocumentLink, MarkupKind, SymbolKind, CompletionItemKind,
Expand Down Expand Up @@ -4095,6 +4095,14 @@ export interface WorkspaceEditClientCapabilities {
*/
changeAnnotationSupport?: ChangeAnnotationsSupportOptions;

/**
* Whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s.
*
* @since 3.18.0
* @proposed
*/
metadataSupport?: boolean;

/**
* Whether the client supports snippets as text edits.
*
Expand All @@ -4119,6 +4127,14 @@ export interface ApplyWorkspaceEditParams {
* The edits to apply.
*/
edit: WorkspaceEdit;

debonte marked this conversation as resolved.
Show resolved Hide resolved
/**
* Additional data about the edit.
*
* @since 3.18.0
* @proposed
*/
metadata?: WorkspaceEditMetadata;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions types/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,19 @@ export namespace WorkspaceEdit {
}
}

/**
* Additional data about a workspace edit.
*
* @since 3.18.0
* @proposed
*/
export interface WorkspaceEditMetadata {
debonte marked this conversation as resolved.
Show resolved Hide resolved
/**
* Signal to the editor that this edit is a refactoring.
*/
isRefactoring?: boolean;
}

/**
* A change to capture text edits for existing resources.
*/
Expand Down