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

feat: empty implement VSCode proposed API: registerMultiDocumentHighlightProvider #4172

Merged
merged 1 commit into from
Nov 18, 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
23 changes: 23 additions & 0 deletions packages/extension/src/common/vscode/ext-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,29 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
}
}

@es5ClassCompat
export class MultiDocumentHighlight {
/**
* The URI of the document containing the highlights.
*/
uri: Uri;

/**
* The highlights for the document.
*/
highlights: DocumentHighlight[];

/**
* Creates a new instance of MultiDocumentHighlight.
* @param uri The URI of the document containing the highlights.
* @param highlights The highlights for the document.
*/
constructor(uri: Uri, highlights: DocumentHighlight[]) {
this.uri = uri;
this.highlights = highlights;
}
}

@es5ClassCompat
export class DocumentLink {
range: Range;
Expand Down
10 changes: 10 additions & 0 deletions packages/extension/src/hosted/api/vscode/ext.host.language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@ export function createLanguagesApiFactory(
): vscode.Disposable {
return extHostLanguages.registerDocumentPasteEditProvider(extension, selector, provider, metadata);
},
/**
* @monaco-todo: wait until API is available in Monaco (1.85.0+)
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
registerMultiDocumentHighlightProvider(
selector: vscode.DocumentSelector,
provider: vscode.MultiDocumentHighlightProvider,
): vscode.Disposable {
return toDisposable(() => {});
},
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/types/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/// <reference path='./vscode/typings/vscode.proposed.chatAgents2Additions.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.chatVariables.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.interactive.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.multiDocumentHighlightProvider.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.inlineCompletionsAdditions.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.codeActionAI.d.ts' />
/// <reference path='./vscode/typings/vscode.proposed.codeActionRanges.d.ts' />
Expand Down
1 change: 1 addition & 0 deletions packages/types/vscode/typings/vscode.language.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,7 @@ declare module 'vscode' {
* @param token A cancellation token.
* @returns A set of text edits or a thenable that resolves to such. The lack of a result can be
* signaled by returning `undefined`, `null`, or an empty array.
* @monaco-todo the current monaco version does not yet use this API
*/
provideDocumentRangesFormattingEdits?(document: TextDocument, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {

/**
* Represents a collection of document highlights from multiple documents.
*/
export class MultiDocumentHighlight {

/**
* The URI of the document containing the highlights.
*/
uri: Uri;

/**
* The highlights for the document.
*/
highlights: DocumentHighlight[];

/**
* Creates a new instance of MultiDocumentHighlight.
* @param uri The URI of the document containing the highlights.
* @param highlights The highlights for the document.
*/
constructor(uri: Uri, highlights: DocumentHighlight[]);
}

export interface MultiDocumentHighlightProvider {

/**
* Provide a set of document highlights, like all occurrences of a variable or
* all exit-points of a function.
*
* @param document The document in which the command was invoked.
* @param position The position at which the command was invoked.
* @param otherDocuments An array of additional valid documents for which highlights should be provided.
* @param token A cancellation token.
* @returns A Map containing a mapping of the Uri of a document to the document highlights or a thenable that resolves to such. The lack of a result can be
* signaled by returning `undefined`, `null`, or an empty map.
bk1012 marked this conversation as resolved.
Show resolved Hide resolved
*/
provideMultiDocumentHighlights(document: TextDocument, position: Position, otherDocuments: TextDocument[], token: CancellationToken): ProviderResult<MultiDocumentHighlight[]>;
}

namespace languages {

/**
* Register a multi document highlight provider.
*
* Multiple providers can be registered for a language. In that case providers are sorted
* by their {@link languages.match score} and groups sequentially asked for document highlights.
* The process stops when a provider returns a `non-falsy` or `non-failure` result.
*
* @param selector A selector that defines the documents this provider is applicable to.
* @param provider A multi-document highlight provider.
* @returns A {@link Disposable} that unregisters this provider when being disposed.
*/
export function registerMultiDocumentHighlightProvider(selector: DocumentSelector, provider: MultiDocumentHighlightProvider): Disposable;
}

}
Loading