Skip to content

Commit

Permalink
[vscode] Stub for proposed API: EditSessionIdentityProvider (#12508)
Browse files Browse the repository at this point in the history
* [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 <marc.dumais@ericsson.com>

* Update packages/plugin-ext/src/plugin/workspace.ts

Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>

---------

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
marcdumais-work and vince-fugnitto authored May 10, 2023
1 parent 4c78d68 commit fa94013
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ export interface WorkspaceExt {
$provideTextDocumentContent(uri: string): Promise<string | undefined | null>;
$onTextSearchResult(searchRequestId: number, done: boolean, result?: SearchInWorkspaceResult): void;
$onWorkspaceTrustChanged(trust: boolean | undefined): void;
$registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable
}

export interface TimelineExt {
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ export function createAPIFactory(
},
get onDidGrantWorkspaceTrust(): theia.Event<void> {
return workspaceExt.onDidGrantWorkspaceTrust;
},
registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider) {
return workspaceExt.$registerEditSessionIdentityProvider(scheme, provider);
}
};

Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-ext/src/plugin/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -449,4 +449,9 @@ export class WorkspaceExtImpl implements WorkspaceExt {
}
}

/** @stubbed */
$registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable {
return Disposable.NULL;
}

}
23 changes: 23 additions & 0 deletions packages/plugin/src/theia-proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
}

// #endregion
}

/**
Expand Down

0 comments on commit fa94013

Please sign in to comment.