From d8a40aeab69733d57e016125a454741990919983 Mon Sep 17 00:00:00 2001 From: Marc Dumais Date: Tue, 9 May 2023 09:42:49 -0400 Subject: [PATCH] [vscode] Stub for proposed API: EditSessionIdentityProvider EditSessionIdentityProvider is a new proposed API. As of 1.72.2 it's only used in built-in git (vscode.git). This commit adds a stub implementation, sufficient to use vscode.git 1.72.2 and hopefully later versions, if we need it to. The eventual goal is to implement this API with a working implementation. Fixes #12437 Signed-off-by: Marc Dumais --- .../plugin-ext/src/common/plugin-api-rpc.ts | 1 + .../plugin-ext/src/plugin/plugin-context.ts | 3 +++ packages/plugin-ext/src/plugin/workspace.ts | 7 +++++- packages/plugin/src/theia-proposed.d.ts | 23 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index eeee279baca3e..17c63c553b129 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -702,6 +702,7 @@ export interface WorkspaceExt { $provideTextDocumentContent(uri: string): Promise; $onTextSearchResult(searchRequestId: number, done: boolean, result?: SearchInWorkspaceResult): void; $onWorkspaceTrustChanged(trust: boolean | undefined): void; + $registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable } export interface TimelineExt { diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index c171e4f54c065..4755adf5168cc 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -714,6 +714,9 @@ export function createAPIFactory( }, get onDidGrantWorkspaceTrust(): theia.Event { return workspaceExt.onDidGrantWorkspaceTrust; + }, + registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider) { + return workspaceExt.$registerEditSessionIdentityProvider(scheme, provider); } }; diff --git a/packages/plugin-ext/src/plugin/workspace.ts b/packages/plugin-ext/src/plugin/workspace.ts index 4a246a5082863..a59ecc313743b 100644 --- a/packages/plugin-ext/src/plugin/workspace.ts +++ b/packages/plugin-ext/src/plugin/workspace.ts @@ -34,7 +34,7 @@ import { Path } from '@theia/core/lib/common/path'; import { RPCProtocol } from '../common/rpc-protocol'; import { WorkspaceRootsChangeEvent, SearchInWorkspaceResult, Range } from '../common/plugin-api-rpc-model'; import { EditorsAndDocumentsExtImpl } from './editors-and-documents'; -import { URI } from './types-impl'; +import { Disposable, URI } from './types-impl'; import { normalize } from '@theia/core/lib/common/paths'; import { relative } from '../common/paths-util'; import { Schemes } from '../common/uri-components'; @@ -449,4 +449,9 @@ export class WorkspaceExtImpl implements WorkspaceExt { } } + // stub + $registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable { + return Disposable.NULL; + } + } diff --git a/packages/plugin/src/theia-proposed.d.ts b/packages/plugin/src/theia-proposed.d.ts index d97447cff6a10..89798e7aa86e4 100644 --- a/packages/plugin/src/theia-proposed.d.ts +++ b/packages/plugin/src/theia-proposed.d.ts @@ -614,6 +614,29 @@ export module '@theia/plugin' { } // #endregion + + // #region SessionIdentityProvider + export namespace workspace { + /** + * + * @param scheme The URI scheme that this provider can provide edit session identities for. + * @param provider A provider which can convert URIs for workspace folders of scheme @param scheme to + * an edit session identifier which is stable across machines. This enables edit sessions to be resolved. + */ + export function registerEditSessionIdentityProvider(scheme: string, provider: EditSessionIdentityProvider): Disposable; + } + + export interface EditSessionIdentityProvider { + /** + * + * @param workspaceFolder The workspace folder to provide an edit session identity for. + * @param token A cancellation token for the request. + * @returns An string representing the edit session identity for the requested workspace folder. + */ + provideEditSessionIdentity(workspaceFolder: WorkspaceFolder, token: CancellationToken): ProviderResult; + } + + // #endregion } /**