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

[vscode][proposed] Stub onWillCreateEditSessionIdentity #12533

Merged
merged 2 commits into from
May 19, 2023
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
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +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
$registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable;
}

export interface TimelineExt {
Expand Down
14 changes: 11 additions & 3 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ import {
TextMergeTabInput,
WebviewEditorTabInput,
DocumentPasteEdit,
ExternalUriOpenerPriority
ExternalUriOpenerPriority,
EditSessionIdentityMatch
} from './types-impl';
import { AuthenticationExtImpl } from './authentication-ext';
import { SymbolKind } from '../common/plugin-api-rpc-model';
Expand Down Expand Up @@ -735,7 +736,13 @@ export function createAPIFactory(
},
registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider) {
return workspaceExt.$registerEditSessionIdentityProvider(scheme, provider);
}
},
/**
* @stubbed
* This is a stub implementation, that should minimally satisfy vscode built-in extensions
* that currently use this proposed API.
*/
onWillCreateEditSessionIdentity: () => Disposable.NULL,
};

const onDidChangeLogLevel = new Emitter<theia.LogLevel>();
Expand Down Expand Up @@ -1369,7 +1376,8 @@ export function createAPIFactory(
TerminalExitReason,
DocumentPasteEdit,
ExternalUriOpenerPriority,
TerminalQuickFixType
TerminalQuickFixType,
EditSessionIdentityMatch
};
};
}
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3500,3 +3500,11 @@ export class DocumentPasteEdit {
additionalEdit?: WorkspaceEdit;
}
// #endregion

// #region DocumentPaste
export enum EditSessionIdentityMatch {
Complete = 100,
Partial = 50,
None = 0
}
// #endregion
23 changes: 0 additions & 23 deletions packages/plugin/src/theia-proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,29 +684,6 @@ 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

// #region ProfileContentHandler

export interface ProfileContentHandler {
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 @@ -23,6 +23,7 @@
import './theia-extra';
import './theia-proposed';
import './theia.proposed.externalUriOpener';
import './vscode.proposed.editSessionIdentityProvider';

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable max-len */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// *****************************************************************************
// Copyright (C) 2023 Ericsson 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 WITH Classpath-exception-2.0
// *****************************************************************************

// Copied from: https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts
// and slightly adapted to work in Theia

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export module '@theia/plugin' {

// https://github.com/microsoft/vscode/issues/157734

export namespace workspace {
/**
* An event that is emitted when an edit session identity is about to be requested.
*/
export const onWillCreateEditSessionIdentity: Event<EditSessionIdentityWillCreateEvent>;

/**
*
* @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 A string representing the edit session identity for the requested workspace folder.
*/
provideEditSessionIdentity(workspaceFolder: WorkspaceFolder, token: CancellationToken): ProviderResult<string>;

/**
*
* @param identity1 An edit session identity.
* @param identity2 A second edit session identity to compare to @param identity1.
* @param token A cancellation token for the request.
* @returns An {@link EditSessionIdentityMatch} representing the edit session identity match confidence for the provided identities.
*/
provideEditSessionIdentityMatch(identity1: string, identity2: string, token: CancellationToken): ProviderResult<EditSessionIdentityMatch>;
}

export enum EditSessionIdentityMatch {
Complete = 100,
Partial = 50,
None = 0
}

export interface EditSessionIdentityWillCreateEvent {

/**
* A cancellation token.
*/
readonly token: CancellationToken;

/**
* The workspace folder to create an edit session identity for.
*/
readonly workspaceFolder: WorkspaceFolder;

/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
waitUntil(thenable: Thenable<any>): void;
}
}