提交 bef346d6 编写于 作者: A Alex Dima

Have the marshalling kind be a property of the proxy identifier (#36972)

上级 367dd104
......@@ -8,7 +8,8 @@ import {
createMainContextProxyIdentifier as createMainId,
createExtHostContextProxyIdentifier as createExtId,
ProxyIdentifier,
IRPCProtocol
IRPCProtocol,
ProxyType
} from 'vs/workbench/services/extensions/node/proxyIdentifier';
import * as vscode from 'vscode';
......@@ -664,56 +665,56 @@ export interface ExtHostWindowShape {
// --- proxy identifiers
export const MainContext = {
MainThreadCommands: <ProxyIdentifier<MainThreadCommandsShape>>createMainId<MainThreadCommandsShape>('MainThreadCommands'),
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
MainThreadDecorations: createMainId<MainThreadDecorationsShape>('MainThreadDecorations'),
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics'),
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs'),
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments'),
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders'),
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors'),
MainThreadErrors: createMainId<MainThreadErrorsShape>('MainThreadErrors'),
MainThreadTreeViews: createMainId<MainThreadTreeViewsShape>('MainThreadTreeViews'),
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeaturesShape>('MainThreadLanguageFeatures'),
MainThreadLanguages: createMainId<MainThreadLanguagesShape>('MainThreadLanguages'),
MainThreadMessageService: createMainId<MainThreadMessageServiceShape>('MainThreadMessageService'),
MainThreadOutputService: createMainId<MainThreadOutputServiceShape>('MainThreadOutputService'),
MainThreadProgress: createMainId<MainThreadProgressShape>('MainThreadProgress'),
MainThreadQuickOpen: createMainId<MainThreadQuickOpenShape>('MainThreadQuickOpen'),
MainThreadStatusBar: createMainId<MainThreadStatusBarShape>('MainThreadStatusBar'),
MainThreadStorage: createMainId<MainThreadStorageShape>('MainThreadStorage'),
MainThreadTelemetry: createMainId<MainThreadTelemetryShape>('MainThreadTelemetry'),
MainThreadTerminalService: createMainId<MainThreadTerminalServiceShape>('MainThreadTerminalService'),
MainThreadWorkspace: createMainId<MainThreadWorkspaceShape>('MainThreadWorkspace'),
MainThreadFileSystem: createMainId<MainThreadFileSystemShape>('MainThreadFileSystem'),
MainThreadExtensionService: createMainId<MainThreadExtensionServiceShape>('MainThreadExtensionService'),
MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM'),
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask'),
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'),
MainThreadCommands: <ProxyIdentifier<MainThreadCommandsShape>>createMainId<MainThreadCommandsShape>('MainThreadCommands', ProxyType.CustomMarshaller),
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration', ProxyType.CustomMarshaller),
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService', ProxyType.CustomMarshaller),
MainThreadDecorations: createMainId<MainThreadDecorationsShape>('MainThreadDecorations', ProxyType.CustomMarshaller),
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics', ProxyType.CustomMarshaller),
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs', ProxyType.CustomMarshaller),
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments', ProxyType.CustomMarshaller),
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders', ProxyType.CustomMarshaller),
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors', ProxyType.CustomMarshaller),
MainThreadErrors: createMainId<MainThreadErrorsShape>('MainThreadErrors', ProxyType.CustomMarshaller),
MainThreadTreeViews: createMainId<MainThreadTreeViewsShape>('MainThreadTreeViews', ProxyType.CustomMarshaller),
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeaturesShape>('MainThreadLanguageFeatures', ProxyType.CustomMarshaller),
MainThreadLanguages: createMainId<MainThreadLanguagesShape>('MainThreadLanguages', ProxyType.CustomMarshaller),
MainThreadMessageService: createMainId<MainThreadMessageServiceShape>('MainThreadMessageService', ProxyType.CustomMarshaller),
MainThreadOutputService: createMainId<MainThreadOutputServiceShape>('MainThreadOutputService', ProxyType.CustomMarshaller),
MainThreadProgress: createMainId<MainThreadProgressShape>('MainThreadProgress', ProxyType.CustomMarshaller),
MainThreadQuickOpen: createMainId<MainThreadQuickOpenShape>('MainThreadQuickOpen', ProxyType.CustomMarshaller),
MainThreadStatusBar: createMainId<MainThreadStatusBarShape>('MainThreadStatusBar', ProxyType.CustomMarshaller),
MainThreadStorage: createMainId<MainThreadStorageShape>('MainThreadStorage', ProxyType.CustomMarshaller),
MainThreadTelemetry: createMainId<MainThreadTelemetryShape>('MainThreadTelemetry', ProxyType.CustomMarshaller),
MainThreadTerminalService: createMainId<MainThreadTerminalServiceShape>('MainThreadTerminalService', ProxyType.CustomMarshaller),
MainThreadWorkspace: createMainId<MainThreadWorkspaceShape>('MainThreadWorkspace', ProxyType.CustomMarshaller),
MainThreadFileSystem: createMainId<MainThreadFileSystemShape>('MainThreadFileSystem', ProxyType.CustomMarshaller),
MainThreadExtensionService: createMainId<MainThreadExtensionServiceShape>('MainThreadExtensionService', ProxyType.CustomMarshaller),
MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM', ProxyType.CustomMarshaller),
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask', ProxyType.CustomMarshaller),
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow', ProxyType.CustomMarshaller),
};
export const ExtHostContext = {
ExtHostCommands: createExtId<ExtHostCommandsShape>('ExtHostCommands'),
ExtHostConfiguration: createExtId<ExtHostConfigurationShape>('ExtHostConfiguration'),
ExtHostDiagnostics: createExtId<ExtHostDiagnosticsShape>('ExtHostDiagnostics'),
ExtHostDebugService: createExtId<ExtHostDebugServiceShape>('ExtHostDebugService'),
ExtHostDecorations: createExtId<ExtHostDecorationsShape>('ExtHostDecorations'),
ExtHostDocumentsAndEditors: createExtId<ExtHostDocumentsAndEditorsShape>('ExtHostDocumentsAndEditors'),
ExtHostDocuments: createExtId<ExtHostDocumentsShape>('ExtHostDocuments'),
ExtHostDocumentContentProviders: createExtId<ExtHostDocumentContentProvidersShape>('ExtHostDocumentContentProviders'),
ExtHostDocumentSaveParticipant: createExtId<ExtHostDocumentSaveParticipantShape>('ExtHostDocumentSaveParticipant'),
ExtHostEditors: createExtId<ExtHostEditorsShape>('ExtHostEditors'),
ExtHostTreeViews: createExtId<ExtHostTreeViewsShape>('ExtHostTreeViews'),
ExtHostFileSystem: createExtId<ExtHostFileSystemShape>('ExtHostFileSystem'),
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventServiceShape>('ExtHostFileSystemEventService'),
ExtHostHeapService: createExtId<ExtHostHeapServiceShape>('ExtHostHeapMonitor'),
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeaturesShape>('ExtHostLanguageFeatures'),
ExtHostQuickOpen: createExtId<ExtHostQuickOpenShape>('ExtHostQuickOpen'),
ExtHostExtensionService: createExtId<ExtHostExtensionServiceShape>('ExtHostExtensionService'),
ExtHostTerminalService: createExtId<ExtHostTerminalServiceShape>('ExtHostTerminalService'),
ExtHostSCM: createExtId<ExtHostSCMShape>('ExtHostSCM'),
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask'),
ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace'),
ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow'),
ExtHostCommands: createExtId<ExtHostCommandsShape>('ExtHostCommands', ProxyType.CustomMarshaller),
ExtHostConfiguration: createExtId<ExtHostConfigurationShape>('ExtHostConfiguration', ProxyType.CustomMarshaller),
ExtHostDiagnostics: createExtId<ExtHostDiagnosticsShape>('ExtHostDiagnostics', ProxyType.CustomMarshaller),
ExtHostDebugService: createExtId<ExtHostDebugServiceShape>('ExtHostDebugService', ProxyType.CustomMarshaller),
ExtHostDecorations: createExtId<ExtHostDecorationsShape>('ExtHostDecorations', ProxyType.CustomMarshaller),
ExtHostDocumentsAndEditors: createExtId<ExtHostDocumentsAndEditorsShape>('ExtHostDocumentsAndEditors', ProxyType.CustomMarshaller),
ExtHostDocuments: createExtId<ExtHostDocumentsShape>('ExtHostDocuments', ProxyType.CustomMarshaller),
ExtHostDocumentContentProviders: createExtId<ExtHostDocumentContentProvidersShape>('ExtHostDocumentContentProviders', ProxyType.CustomMarshaller),
ExtHostDocumentSaveParticipant: createExtId<ExtHostDocumentSaveParticipantShape>('ExtHostDocumentSaveParticipant', ProxyType.CustomMarshaller),
ExtHostEditors: createExtId<ExtHostEditorsShape>('ExtHostEditors', ProxyType.CustomMarshaller),
ExtHostTreeViews: createExtId<ExtHostTreeViewsShape>('ExtHostTreeViews', ProxyType.CustomMarshaller),
ExtHostFileSystem: createExtId<ExtHostFileSystemShape>('ExtHostFileSystem', ProxyType.CustomMarshaller),
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventServiceShape>('ExtHostFileSystemEventService', ProxyType.CustomMarshaller),
ExtHostHeapService: createExtId<ExtHostHeapServiceShape>('ExtHostHeapMonitor', ProxyType.CustomMarshaller),
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeaturesShape>('ExtHostLanguageFeatures', ProxyType.CustomMarshaller),
ExtHostQuickOpen: createExtId<ExtHostQuickOpenShape>('ExtHostQuickOpen', ProxyType.CustomMarshaller),
ExtHostExtensionService: createExtId<ExtHostExtensionServiceShape>('ExtHostExtensionService', ProxyType.CustomMarshaller),
ExtHostTerminalService: createExtId<ExtHostTerminalServiceShape>('ExtHostTerminalService', ProxyType.CustomMarshaller),
ExtHostSCM: createExtId<ExtHostSCMShape>('ExtHostSCM', ProxyType.CustomMarshaller),
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask', ProxyType.CustomMarshaller),
ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace', ProxyType.CustomMarshaller),
ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow', ProxyType.CustomMarshaller),
};
......@@ -6,20 +6,10 @@
export interface IRPCProtocol {
/**
* Returns a proxy to an object addressable/named in the extension host process.
* > **Note:** Arguments or results of type `URI` or `RegExp` will be serialized/deserialized automatically,
* > but this has a performance cost, as each argument/result must be visited.
* >
* > Use `getFast` for a proxy where such arguments are not automatically serialized/deserialized.
* Returns a proxy to an object addressable/named in the extension host process or in the renderer process.
*/
getProxy<T>(identifier: ProxyIdentifier<T>): T;
/**
* Returns a proxy to an object addressable/named in the extension host process.
* > **Note:** Arguments or results of type `URI` or `RegExp` will **not** be serialized/deserialized automatically.
*/
getFastProxy<T>(identifier: ProxyIdentifier<T>): T;
/**
* Register manually created instance.
*/
......@@ -35,19 +25,31 @@ export class ProxyIdentifier<T> {
_proxyIdentifierBrand: void;
_suppressCompilerUnusedWarning: T;
isMain: boolean;
id: string;
public readonly isMain: boolean;
public readonly id: string;
public readonly isFancy: boolean;
constructor(isMain: boolean, id: string) {
constructor(isMain: boolean, id: string, isFancy: boolean) {
this.isMain = isMain;
this.id = id;
this.isFancy = isFancy;
}
}
export function createMainContextProxyIdentifier<T>(identifier: string): ProxyIdentifier<T> {
return new ProxyIdentifier(true, 'm' + identifier);
export const enum ProxyType {
NativeJSON = 0,
CustomMarshaller = 1
}
/**
* Using `isFancy` indicates that arguments or results of type `URI` or `RegExp`
* will be serialized/deserialized automatically, but this has a performance cost,
* as each argument/result must be visited.
*/
export function createMainContextProxyIdentifier<T>(identifier: string, type: ProxyType = ProxyType.NativeJSON): ProxyIdentifier<T> {
return new ProxyIdentifier(true, 'm' + identifier, type === ProxyType.CustomMarshaller);
}
export function createExtHostContextProxyIdentifier<T>(identifier: string): ProxyIdentifier<T> {
return new ProxyIdentifier(false, 'e' + identifier);
export function createExtHostContextProxyIdentifier<T>(identifier: string, type: ProxyType = ProxyType.NativeJSON): ProxyIdentifier<T> {
return new ProxyIdentifier(false, 'e' + identifier, type === ProxyType.CustomMarshaller);
}
......@@ -46,14 +46,7 @@ export class RPCProtocol implements IRPCProtocol {
public getProxy<T>(identifier: ProxyIdentifier<T>): T {
if (!this._proxies[identifier.id]) {
this._proxies[identifier.id] = this._createProxy(identifier.id, true);
}
return this._proxies[identifier.id];
}
public getFastProxy<T>(identifier: ProxyIdentifier<T>): T {
if (!this._proxies[identifier.id]) {
this._proxies[identifier.id] = this._createProxy(identifier.id, false);
this._proxies[identifier.id] = this._createProxy(identifier.id, identifier.isFancy);
}
return this._proxies[identifier.id];
}
......
......@@ -16,7 +16,6 @@ suite('ExtHostDocumentsAndEditors', () => {
setup(function () {
editors = new ExtHostDocumentsAndEditors({
getProxy: () => { return undefined; },
getFastProxy: () => { return undefined; },
set: undefined,
assertRegistered: undefined
});
......
......@@ -13,9 +13,6 @@ export function OneGetThreadService(thing: any): IRPCProtocol {
getProxy<T>(): T {
return thing;
},
getFastProxy<T>(): T {
return thing;
},
set<T, R extends T>(identifier: ProxyIdentifier<T>, value: R): R {
return value;
},
......@@ -124,15 +121,6 @@ export class TestThreadService extends AbstractTestThreadService implements IRPC
}
getProxy<T>(identifier: ProxyIdentifier<T>): T {
return this._get(identifier);
}
getFastProxy<T>(identifier: ProxyIdentifier<T>): T {
return this._get(identifier);
}
_get<T>(identifier: ProxyIdentifier<T>): T {
let id = identifier.id;
if (this._locals[id]) {
return this._locals[id];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册