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

Stub implementation of proposed API for multiDocumentHighlightProvider. #13248

Merged
merged 1 commit into from
Jan 15, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## not yet released

- [plugin] stub multiDocumentHighlightProvider proposed API [#13248](https://github.com/eclipse-theia/theia/pull/13248) - contributed on behalf of STMicroelectronics
- [terminal] update terminalQuickFixProvider proposed API according to vscode 1.85 version [#13240](https://github.com/eclipse-theia/theia/pull/13240) - contributed on behalf of STMicroelectronics

## v1.45.0 - 12/21/2023
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import {
InlineValueContext,
DocumentHighlightKind,
DocumentHighlight,
MultiDocumentHighlight,
DocumentLink,
DocumentDropEdit,
CodeLens,
Expand Down Expand Up @@ -916,6 +917,13 @@ export function createAPIFactory(
registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable {
return languagesExt.registerDocumentHighlightProvider(selector, provider, pluginToPluginInfo(plugin));
},
/**
* @stubbed
* @monaco-uplift: wait until API is available in Monaco (1.85.0+)
*/
registerMultiDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.MultiDocumentHighlightProvider): theia.Disposable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to make this work in the future, we should mark it with @monaco-uplift.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this annotation here:

* @monaco-uplift: wait until API is available in Monaco API (1.85.0+)

Should I also add it to this doc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to do as few changes to the api.d.ts files we take from VS Code because it makes it easier to maintain them, IMO (diff, etc.). Unless this is a general convention, I would prefer the @monaco-uplift annotatio where we put the stub implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explanation, @tsmaeder.
I have rebased and updated my changes, as this is a trivial fix and there was the usual conflict with the changelog. The monaco uplift annotation has been moved to plugin-context file.

return Disposable.NULL;
},
registerWorkspaceSymbolProvider(provider: theia.WorkspaceSymbolProvider): theia.Disposable {
return languagesExt.registerWorkspaceSymbolProvider(provider, pluginToPluginInfo(plugin));
},
Expand Down Expand Up @@ -1261,6 +1269,7 @@ export function createAPIFactory(
InlineValueContext,
DocumentHighlightKind,
DocumentHighlight,
MultiDocumentHighlight,
DocumentLink,
DocumentDropEdit,
CodeLens,
Expand Down
24 changes: 24 additions & 0 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,30 @@ export class DocumentHighlight {
}
}

@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;
}
}

export type Definition = Location | Location[];

@es5ClassCompat
Expand Down
1 change: 1 addition & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import './theia.proposed.notebookKernelSource';
import './theia.proposed.notebookMessaging';
import './theia.proposed.findTextInFiles';
import './theia.proposed.fsChunks';
import './theia.proposed.multiDocumentHighlightProvider';
import './theia.proposed.profileContentHandlers';
import './theia.proposed.resolvers';
import './theia.proposed.scmValidation';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// *****************************************************************************
// Copyright (C) 2023 STMicroelectronics and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// code copied and modified from https://github.com/microsoft/vscode/blob/1.85.1/src/vscode-dts/vscode.proposed.multiDocumentHighlightProvider.d.ts

declare module '@theia/plugin' {

/**
* 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.
*/
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.
* @stubbed
*/
export function registerMultiDocumentHighlightProvider(selector: DocumentSelector, provider: MultiDocumentHighlightProvider): Disposable;
}

}
Loading