mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 17:19:01 +01:00
remove user data api implementation
This commit is contained in:
@@ -18,7 +18,6 @@ import './mainThreadCodeInsets';
|
||||
import './mainThreadClipboard';
|
||||
import './mainThreadCommands';
|
||||
import './mainThreadConfiguration';
|
||||
import './mainThreadUserData';
|
||||
import './mainThreadConsole';
|
||||
import './mainThreadDebugService';
|
||||
import './mainThreadDecorations';
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { MainContext, ExtHostContext, IExtHostContext, MainThreadUserDataShape, ExtHostUserDataShape } from '../common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IUserData } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IUserDataSyncStoresRegistry, Extensions } from 'vs/workbench/services/userDataSync/common/userDataSyncStores';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadUserData)
|
||||
export class MainThreadUserData extends Disposable implements MainThreadUserDataShape {
|
||||
|
||||
private readonly proxy: ExtHostUserDataShape;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
) {
|
||||
super();
|
||||
this.proxy = extHostContext.getProxy(ExtHostContext.ExtHostUserData);
|
||||
}
|
||||
|
||||
$registerUserDataProvider(id: string, name: string): void {
|
||||
const proxy = this.proxy;
|
||||
Registry.as<IUserDataSyncStoresRegistry>(Extensions.UserDataSyncStoresRegistry).registerUserDataSyncStore({
|
||||
id,
|
||||
name,
|
||||
read(key: string): Promise<IUserData | null> {
|
||||
return proxy.$read(key);
|
||||
},
|
||||
write(key: string, content: string, ref: string): Promise<string> {
|
||||
return proxy.$write(key, content, ref);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$deregisterUserDataProvider(id: string): void {
|
||||
Registry.as<IUserDataSyncStoresRegistry>(Extensions.UserDataSyncStoresRegistry).deregisterUserDataSyncStore(id);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
const registry = Registry.as<IUserDataSyncStoresRegistry>(Extensions.UserDataSyncStoresRegistry);
|
||||
registry.all.forEach(store => registry.deregisterUserDataSyncStore(store.id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,7 +68,6 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { ExtHostUserData } from 'vs/workbench/api/common/extHostUserData';
|
||||
|
||||
export interface IExtensionApiFactory {
|
||||
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
|
||||
@@ -125,7 +124,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
const extHostWindow = rpcProtocol.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(rpcProtocol));
|
||||
const extHostProgress = rpcProtocol.set(ExtHostContext.ExtHostProgress, new ExtHostProgress(rpcProtocol.getProxy(MainContext.MainThreadProgress)));
|
||||
const extHostLabelService = rpcProtocol.set(ExtHostContext.ExtHosLabelService, new ExtHostLabelService(rpcProtocol));
|
||||
const extHostUserData = rpcProtocol.set(ExtHostContext.ExtHostUserData, new ExtHostUserData(rpcProtocol.getProxy(MainContext.MainThreadUserData), extHostLogService));
|
||||
|
||||
// Check that no named customers are missing
|
||||
const expected: ProxyIdentifier<any>[] = values(ExtHostContext);
|
||||
@@ -545,10 +543,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
},
|
||||
createInputBox(): vscode.InputBox {
|
||||
return extHostQuickOpen.createInputBox(extension.identifier);
|
||||
},
|
||||
registerUserDataSyncProvider: (name: string, userDataProvider: vscode.UserDataSyncProvider): vscode.Disposable => {
|
||||
checkProposedApiEnabled(extension);
|
||||
return extHostUserData.registerUserDataProvider(extension.identifier.value, name, userDataProvider);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -907,7 +901,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
CallHierarchyIncomingCall: extHostTypes.CallHierarchyIncomingCall,
|
||||
CallHierarchyItem: extHostTypes.CallHierarchyItem,
|
||||
Decoration: extHostTypes.Decoration,
|
||||
UserDataError: extHostTypes.UserDataError,
|
||||
WebviewEditorState: extHostTypes.WebviewEditorState,
|
||||
UIKind: UIKind
|
||||
};
|
||||
|
||||
@@ -46,7 +46,6 @@ import { ExtensionActivationError } from 'vs/workbench/services/extensions/commo
|
||||
import { createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId, IRPCProtocol } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import * as search from 'vs/workbench/services/search/common/search';
|
||||
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IUserData } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
|
||||
export interface IEnvironment {
|
||||
isExtensionDevelopmentDebug: boolean;
|
||||
@@ -146,11 +145,6 @@ export interface MainThreadConfigurationShape extends IDisposable {
|
||||
$removeConfigurationOption(target: ConfigurationTarget | null, key: string, resource: UriComponents | undefined): Promise<void>;
|
||||
}
|
||||
|
||||
export interface MainThreadUserDataShape extends IDisposable {
|
||||
$registerUserDataProvider(id: string, name: string): void;
|
||||
$deregisterUserDataProvider(id: string): void;
|
||||
}
|
||||
|
||||
export interface MainThreadDiagnosticsShape extends IDisposable {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[] | undefined][]): void;
|
||||
$clear(owner: string): void;
|
||||
@@ -758,11 +752,6 @@ export interface ExtHostConfigurationShape {
|
||||
$acceptConfigurationChanged(data: IConfigurationInitData, eventData: IWorkspaceConfigurationChangeEventData): void;
|
||||
}
|
||||
|
||||
export interface ExtHostUserDataShape {
|
||||
$read(key: string): Promise<IUserData | null>;
|
||||
$write(key: string, content: string, ref: string): Promise<string>;
|
||||
}
|
||||
|
||||
export interface ExtHostDiagnosticsShape {
|
||||
$acceptMarkersChange(data: [UriComponents, IMarkerData[]][]): void;
|
||||
}
|
||||
@@ -1336,7 +1325,6 @@ export const MainContext = {
|
||||
MainThreadCommands: createMainId<MainThreadCommandsShape>('MainThreadCommands'),
|
||||
MainThreadComments: createMainId<MainThreadCommentsShape>('MainThreadComments'),
|
||||
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
|
||||
MainThreadUserData: createMainId<MainThreadUserDataShape>('MainThreadUserData'),
|
||||
MainThreadConsole: createMainId<MainThreadConsoleShape>('MainThreadConsole'),
|
||||
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
|
||||
MainThreadDecorations: createMainId<MainThreadDecorationsShape>('MainThreadDecorations'),
|
||||
@@ -1376,7 +1364,6 @@ export const MainContext = {
|
||||
export const ExtHostContext = {
|
||||
ExtHostCommands: createExtId<ExtHostCommandsShape>('ExtHostCommands'),
|
||||
ExtHostConfiguration: createExtId<ExtHostConfigurationShape>('ExtHostConfiguration'),
|
||||
ExtHostUserData: createExtId<ExtHostUserDataShape>('ExtHostUserData'),
|
||||
ExtHostDiagnostics: createExtId<ExtHostDiagnosticsShape>('ExtHostDiagnostics'),
|
||||
ExtHostDebugService: createExtId<ExtHostDebugServiceShape>('ExtHostDebugService'),
|
||||
ExtHostDecorations: createExtId<ExtHostDecorationsShape>('ExtHostDecorations'),
|
||||
|
||||
@@ -14,8 +14,6 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as vscode from 'vscode';
|
||||
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { UserDataSyncStoreErrorCode } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { markAsUserDataSyncStoreError } from 'vs/workbench/services/userDataSync/common/userDataSyncStores';
|
||||
|
||||
function es5ClassCompat(target: Function): any {
|
||||
///@ts-ignore
|
||||
@@ -2385,28 +2383,6 @@ export class Decoration {
|
||||
bubble?: boolean;
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class UserDataError extends Error {
|
||||
|
||||
static Rejected(message?: string): UserDataError {
|
||||
return new UserDataError(message, UserDataSyncStoreErrorCode.Rejected);
|
||||
}
|
||||
|
||||
constructor(message?: string, code: UserDataSyncStoreErrorCode = UserDataSyncStoreErrorCode.Unknown) {
|
||||
super(message);
|
||||
|
||||
// mark the error as user data provider error so that
|
||||
// we can extract the error code on the receiving side
|
||||
markAsUserDataSyncStoreError(this, code);
|
||||
|
||||
// workaround when extending builtin objects and when compiling to ES5, see:
|
||||
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
||||
if (typeof (<any>Object).setPrototypeOf === 'function') {
|
||||
(<any>Object).setPrototypeOf(this, UserDataError.prototype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum WebviewEditorState {
|
||||
Readonly = 1,
|
||||
Unchanged = 2,
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtHostUserDataShape, MainThreadUserDataShape } from './extHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
import { toDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IUserData } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
|
||||
export class ExtHostUserData implements ExtHostUserDataShape {
|
||||
|
||||
private name: string | null = null;
|
||||
private userDataProvider: vscode.UserDataSyncProvider | null = null;
|
||||
|
||||
constructor(
|
||||
private readonly proxy: MainThreadUserDataShape,
|
||||
private readonly logService: ILogService,
|
||||
) {
|
||||
}
|
||||
|
||||
registerUserDataProvider(id: string, name: string, userDataProvider: vscode.UserDataSyncProvider): vscode.Disposable {
|
||||
if (this.userDataProvider) {
|
||||
this.logService.warn(`A user data provider '${this.name}' already exists hence ignoring the remote user data provider '${name}'.`);
|
||||
return Disposable.None;
|
||||
}
|
||||
this.userDataProvider = userDataProvider;
|
||||
this.name = name;
|
||||
this.proxy.$registerUserDataProvider(id, name);
|
||||
return toDisposable(() => this.proxy.$deregisterUserDataProvider(id));
|
||||
}
|
||||
|
||||
$read(key: string): Promise<IUserData | null> {
|
||||
if (!this.userDataProvider) {
|
||||
throw new Error('No remote user data provider exists.');
|
||||
}
|
||||
return this.userDataProvider.read(key);
|
||||
}
|
||||
|
||||
$write(key: string, content: string, ref: string): Promise<string> {
|
||||
if (!this.userDataProvider) {
|
||||
throw new Error('No remote user data provider exists.');
|
||||
}
|
||||
return this.userDataProvider.write(key, content, ref);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user