From dd9530515cd323f53baf2fb52674adfcd059148a Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 18 Jan 2022 08:49:21 +0100 Subject: [PATCH] fold `createExtHostContextProxyIdentifier` and `createMainContextProxyIdentifier` into one, fyi @alexdima --- .../workbench/api/common/extHost.protocol.ts | 216 +++++++++--------- .../extensions/common/proxyIdentifier.ts | 14 +- .../services/extensions/common/rpcProtocol.ts | 2 +- .../test/common/rpcProtocol.test.ts | 2 +- 4 files changed, 113 insertions(+), 121 deletions(-) diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index fa7a7139bd7..4bc6c4e5805 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -66,7 +66,7 @@ import { InternalTimelineOptions, Timeline, TimelineChangeEvent, TimelineOptions import { TypeHierarchyItem } from 'vs/workbench/contrib/typeHierarchy/common/typeHierarchy'; import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn'; import { ActivationKind, ExtensionHostKind, MissingExtensionDependency } from 'vs/workbench/services/extensions/common/extensions'; -import { createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId, IRPCProtocol, SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; +import { createProxyIdentifier, IRPCProtocol, SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; import { ILanguageStatus } from 'vs/workbench/services/languageStatus/common/languageStatusService'; import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService'; import * as search from 'vs/workbench/services/search/common/search'; @@ -2245,114 +2245,114 @@ export interface MainThreadTestingShape { // --- proxy identifiers export const MainContext = { - MainThreadAuthentication: createMainId('MainThreadAuthentication'), - MainThreadBulkEdits: createMainId('MainThreadBulkEdits'), - MainThreadClipboard: createMainId('MainThreadClipboard'), - MainThreadCommands: createMainId('MainThreadCommands'), - MainThreadComments: createMainId('MainThreadComments'), - MainThreadConfiguration: createMainId('MainThreadConfiguration'), - MainThreadConsole: createMainId('MainThreadConsole'), - MainThreadDebugService: createMainId('MainThreadDebugService'), - MainThreadDecorations: createMainId('MainThreadDecorations'), - MainThreadDiagnostics: createMainId('MainThreadDiagnostics'), - MainThreadDialogs: createMainId('MainThreadDiaglogs'), - MainThreadDocuments: createMainId('MainThreadDocuments'), - MainThreadDocumentContentProviders: createMainId('MainThreadDocumentContentProviders'), - MainThreadTextEditors: createMainId('MainThreadTextEditors'), - MainThreadEditorInsets: createMainId('MainThreadEditorInsets'), - MainThreadEditorTabs: createMainId('MainThreadEditorTabs'), - MainThreadErrors: createMainId('MainThreadErrors'), - MainThreadTreeViews: createMainId('MainThreadTreeViews'), - MainThreadDownloadService: createMainId('MainThreadDownloadService'), - MainThreadKeytar: createMainId('MainThreadKeytar'), - MainThreadLanguageFeatures: createMainId('MainThreadLanguageFeatures'), - MainThreadLanguages: createMainId('MainThreadLanguages'), - MainThreadLogger: createMainId('MainThreadLogger'), - MainThreadMessageService: createMainId('MainThreadMessageService'), - MainThreadOutputService: createMainId('MainThreadOutputService'), - MainThreadProgress: createMainId('MainThreadProgress'), - MainThreadQuickOpen: createMainId('MainThreadQuickOpen'), - MainThreadStatusBar: createMainId('MainThreadStatusBar'), - MainThreadSecretState: createMainId('MainThreadSecretState'), - MainThreadStorage: createMainId('MainThreadStorage'), - MainThreadTelemetry: createMainId('MainThreadTelemetry'), - MainThreadTerminalService: createMainId('MainThreadTerminalService'), - MainThreadWebviews: createMainId('MainThreadWebviews'), - MainThreadWebviewPanels: createMainId('MainThreadWebviewPanels'), - MainThreadWebviewViews: createMainId('MainThreadWebviewViews'), - MainThreadCustomEditors: createMainId('MainThreadCustomEditors'), - MainThreadUrls: createMainId('MainThreadUrls'), - MainThreadUriOpeners: createMainId('MainThreadUriOpeners'), - MainThreadWorkspace: createMainId('MainThreadWorkspace'), - MainThreadFileSystem: createMainId('MainThreadFileSystem'), - MainThreadExtensionService: createMainId('MainThreadExtensionService'), - MainThreadSCM: createMainId('MainThreadSCM'), - MainThreadSearch: createMainId('MainThreadSearch'), - MainThreadTask: createMainId('MainThreadTask'), - MainThreadWindow: createMainId('MainThreadWindow'), - MainThreadLabelService: createMainId('MainThreadLabelService'), - MainThreadNotebook: createMainId('MainThreadNotebook'), - MainThreadNotebookDocuments: createMainId('MainThreadNotebookDocumentsShape'), - MainThreadNotebookEditors: createMainId('MainThreadNotebookEditorsShape'), - MainThreadNotebookKernels: createMainId('MainThreadNotebookKernels'), - MainThreadNotebookRenderers: createMainId('MainThreadNotebookRenderers'), - MainThreadInteractive: createMainId('MainThreadInteractive'), - MainThreadTheming: createMainId('MainThreadTheming'), - MainThreadTunnelService: createMainId('MainThreadTunnelService'), - MainThreadTimeline: createMainId('MainThreadTimeline'), - MainThreadTesting: createMainId('MainThreadTesting'), + MainThreadAuthentication: createProxyIdentifier('MainThreadAuthentication'), + MainThreadBulkEdits: createProxyIdentifier('MainThreadBulkEdits'), + MainThreadClipboard: createProxyIdentifier('MainThreadClipboard'), + MainThreadCommands: createProxyIdentifier('MainThreadCommands'), + MainThreadComments: createProxyIdentifier('MainThreadComments'), + MainThreadConfiguration: createProxyIdentifier('MainThreadConfiguration'), + MainThreadConsole: createProxyIdentifier('MainThreadConsole'), + MainThreadDebugService: createProxyIdentifier('MainThreadDebugService'), + MainThreadDecorations: createProxyIdentifier('MainThreadDecorations'), + MainThreadDiagnostics: createProxyIdentifier('MainThreadDiagnostics'), + MainThreadDialogs: createProxyIdentifier('MainThreadDiaglogs'), + MainThreadDocuments: createProxyIdentifier('MainThreadDocuments'), + MainThreadDocumentContentProviders: createProxyIdentifier('MainThreadDocumentContentProviders'), + MainThreadTextEditors: createProxyIdentifier('MainThreadTextEditors'), + MainThreadEditorInsets: createProxyIdentifier('MainThreadEditorInsets'), + MainThreadEditorTabs: createProxyIdentifier('MainThreadEditorTabs'), + MainThreadErrors: createProxyIdentifier('MainThreadErrors'), + MainThreadTreeViews: createProxyIdentifier('MainThreadTreeViews'), + MainThreadDownloadService: createProxyIdentifier('MainThreadDownloadService'), + MainThreadKeytar: createProxyIdentifier('MainThreadKeytar'), + MainThreadLanguageFeatures: createProxyIdentifier('MainThreadLanguageFeatures'), + MainThreadLanguages: createProxyIdentifier('MainThreadLanguages'), + MainThreadLogger: createProxyIdentifier('MainThreadLogger'), + MainThreadMessageService: createProxyIdentifier('MainThreadMessageService'), + MainThreadOutputService: createProxyIdentifier('MainThreadOutputService'), + MainThreadProgress: createProxyIdentifier('MainThreadProgress'), + MainThreadQuickOpen: createProxyIdentifier('MainThreadQuickOpen'), + MainThreadStatusBar: createProxyIdentifier('MainThreadStatusBar'), + MainThreadSecretState: createProxyIdentifier('MainThreadSecretState'), + MainThreadStorage: createProxyIdentifier('MainThreadStorage'), + MainThreadTelemetry: createProxyIdentifier('MainThreadTelemetry'), + MainThreadTerminalService: createProxyIdentifier('MainThreadTerminalService'), + MainThreadWebviews: createProxyIdentifier('MainThreadWebviews'), + MainThreadWebviewPanels: createProxyIdentifier('MainThreadWebviewPanels'), + MainThreadWebviewViews: createProxyIdentifier('MainThreadWebviewViews'), + MainThreadCustomEditors: createProxyIdentifier('MainThreadCustomEditors'), + MainThreadUrls: createProxyIdentifier('MainThreadUrls'), + MainThreadUriOpeners: createProxyIdentifier('MainThreadUriOpeners'), + MainThreadWorkspace: createProxyIdentifier('MainThreadWorkspace'), + MainThreadFileSystem: createProxyIdentifier('MainThreadFileSystem'), + MainThreadExtensionService: createProxyIdentifier('MainThreadExtensionService'), + MainThreadSCM: createProxyIdentifier('MainThreadSCM'), + MainThreadSearch: createProxyIdentifier('MainThreadSearch'), + MainThreadTask: createProxyIdentifier('MainThreadTask'), + MainThreadWindow: createProxyIdentifier('MainThreadWindow'), + MainThreadLabelService: createProxyIdentifier('MainThreadLabelService'), + MainThreadNotebook: createProxyIdentifier('MainThreadNotebook'), + MainThreadNotebookDocuments: createProxyIdentifier('MainThreadNotebookDocumentsShape'), + MainThreadNotebookEditors: createProxyIdentifier('MainThreadNotebookEditorsShape'), + MainThreadNotebookKernels: createProxyIdentifier('MainThreadNotebookKernels'), + MainThreadNotebookRenderers: createProxyIdentifier('MainThreadNotebookRenderers'), + MainThreadInteractive: createProxyIdentifier('MainThreadInteractive'), + MainThreadTheming: createProxyIdentifier('MainThreadTheming'), + MainThreadTunnelService: createProxyIdentifier('MainThreadTunnelService'), + MainThreadTimeline: createProxyIdentifier('MainThreadTimeline'), + MainThreadTesting: createProxyIdentifier('MainThreadTesting'), }; export const ExtHostContext = { - ExtHostCommands: createExtId('ExtHostCommands'), - ExtHostConfiguration: createExtId('ExtHostConfiguration'), - ExtHostDiagnostics: createExtId('ExtHostDiagnostics'), - ExtHostDebugService: createExtId('ExtHostDebugService'), - ExtHostDecorations: createExtId('ExtHostDecorations'), - ExtHostDocumentsAndEditors: createExtId('ExtHostDocumentsAndEditors'), - ExtHostDocuments: createExtId('ExtHostDocuments'), - ExtHostDocumentContentProviders: createExtId('ExtHostDocumentContentProviders'), - ExtHostDocumentSaveParticipant: createExtId('ExtHostDocumentSaveParticipant'), - ExtHostEditors: createExtId('ExtHostEditors'), - ExtHostTreeViews: createExtId('ExtHostTreeViews'), - ExtHostFileSystem: createExtId('ExtHostFileSystem'), - ExtHostFileSystemInfo: createExtId('ExtHostFileSystemInfo'), - ExtHostFileSystemEventService: createExtId('ExtHostFileSystemEventService'), - ExtHostLanguages: createExtId('ExtHostLanguages'), - ExtHostLanguageFeatures: createExtId('ExtHostLanguageFeatures'), - ExtHostQuickOpen: createExtId('ExtHostQuickOpen'), - ExtHostExtensionService: createExtId('ExtHostExtensionService'), - ExtHostLogLevelServiceShape: createExtId('ExtHostLogLevelServiceShape'), - ExtHostTerminalService: createExtId('ExtHostTerminalService'), - ExtHostSCM: createExtId('ExtHostSCM'), - ExtHostSearch: createExtId('ExtHostSearch'), - ExtHostTask: createExtId('ExtHostTask'), - ExtHostWorkspace: createExtId('ExtHostWorkspace'), - ExtHostWindow: createExtId('ExtHostWindow'), - ExtHostWebviews: createExtId('ExtHostWebviews'), - ExtHostWebviewPanels: createExtId('ExtHostWebviewPanels'), - ExtHostCustomEditors: createExtId('ExtHostCustomEditors'), - ExtHostWebviewViews: createExtId('ExtHostWebviewViews'), - ExtHostEditorInsets: createExtId('ExtHostEditorInsets'), - ExtHostEditorTabs: createExtId('ExtHostEditorTabs'), - ExtHostProgress: createMainId('ExtHostProgress'), - ExtHostComments: createMainId('ExtHostComments'), - ExtHostSecretState: createMainId('ExtHostSecretState'), - ExtHostStorage: createMainId('ExtHostStorage'), - ExtHostUrls: createExtId('ExtHostUrls'), - ExtHostUriOpeners: createExtId('ExtHostUriOpeners'), - ExtHostOutputService: createMainId('ExtHostOutputService'), - ExtHosLabelService: createMainId('ExtHostLabelService'), - ExtHostNotebook: createMainId('ExtHostNotebook'), - ExtHostNotebookDocuments: createMainId('ExtHostNotebookDocuments'), - ExtHostNotebookEditors: createMainId('ExtHostNotebookEditors'), - ExtHostNotebookKernels: createMainId('ExtHostNotebookKernels'), - ExtHostNotebookRenderers: createMainId('ExtHostNotebookRenderers'), - ExtHostInteractive: createMainId('ExtHostInteractive'), - ExtHostTheming: createMainId('ExtHostTheming'), - ExtHostTunnelService: createMainId('ExtHostTunnelService'), - ExtHostAuthentication: createMainId('ExtHostAuthentication'), - ExtHostTimeline: createMainId('ExtHostTimeline'), - ExtHostTesting: createMainId('ExtHostTesting'), - ExtHostTelemetry: createMainId('ExtHostTelemetry'), + ExtHostCommands: createProxyIdentifier('ExtHostCommands'), + ExtHostConfiguration: createProxyIdentifier('ExtHostConfiguration'), + ExtHostDiagnostics: createProxyIdentifier('ExtHostDiagnostics'), + ExtHostDebugService: createProxyIdentifier('ExtHostDebugService'), + ExtHostDecorations: createProxyIdentifier('ExtHostDecorations'), + ExtHostDocumentsAndEditors: createProxyIdentifier('ExtHostDocumentsAndEditors'), + ExtHostDocuments: createProxyIdentifier('ExtHostDocuments'), + ExtHostDocumentContentProviders: createProxyIdentifier('ExtHostDocumentContentProviders'), + ExtHostDocumentSaveParticipant: createProxyIdentifier('ExtHostDocumentSaveParticipant'), + ExtHostEditors: createProxyIdentifier('ExtHostEditors'), + ExtHostTreeViews: createProxyIdentifier('ExtHostTreeViews'), + ExtHostFileSystem: createProxyIdentifier('ExtHostFileSystem'), + ExtHostFileSystemInfo: createProxyIdentifier('ExtHostFileSystemInfo'), + ExtHostFileSystemEventService: createProxyIdentifier('ExtHostFileSystemEventService'), + ExtHostLanguages: createProxyIdentifier('ExtHostLanguages'), + ExtHostLanguageFeatures: createProxyIdentifier('ExtHostLanguageFeatures'), + ExtHostQuickOpen: createProxyIdentifier('ExtHostQuickOpen'), + ExtHostExtensionService: createProxyIdentifier('ExtHostExtensionService'), + ExtHostLogLevelServiceShape: createProxyIdentifier('ExtHostLogLevelServiceShape'), + ExtHostTerminalService: createProxyIdentifier('ExtHostTerminalService'), + ExtHostSCM: createProxyIdentifier('ExtHostSCM'), + ExtHostSearch: createProxyIdentifier('ExtHostSearch'), + ExtHostTask: createProxyIdentifier('ExtHostTask'), + ExtHostWorkspace: createProxyIdentifier('ExtHostWorkspace'), + ExtHostWindow: createProxyIdentifier('ExtHostWindow'), + ExtHostWebviews: createProxyIdentifier('ExtHostWebviews'), + ExtHostWebviewPanels: createProxyIdentifier('ExtHostWebviewPanels'), + ExtHostCustomEditors: createProxyIdentifier('ExtHostCustomEditors'), + ExtHostWebviewViews: createProxyIdentifier('ExtHostWebviewViews'), + ExtHostEditorInsets: createProxyIdentifier('ExtHostEditorInsets'), + ExtHostEditorTabs: createProxyIdentifier('ExtHostEditorTabs'), + ExtHostProgress: createProxyIdentifier('ExtHostProgress'), + ExtHostComments: createProxyIdentifier('ExtHostComments'), + ExtHostSecretState: createProxyIdentifier('ExtHostSecretState'), + ExtHostStorage: createProxyIdentifier('ExtHostStorage'), + ExtHostUrls: createProxyIdentifier('ExtHostUrls'), + ExtHostUriOpeners: createProxyIdentifier('ExtHostUriOpeners'), + ExtHostOutputService: createProxyIdentifier('ExtHostOutputService'), + ExtHosLabelService: createProxyIdentifier('ExtHostLabelService'), + ExtHostNotebook: createProxyIdentifier('ExtHostNotebook'), + ExtHostNotebookDocuments: createProxyIdentifier('ExtHostNotebookDocuments'), + ExtHostNotebookEditors: createProxyIdentifier('ExtHostNotebookEditors'), + ExtHostNotebookKernels: createProxyIdentifier('ExtHostNotebookKernels'), + ExtHostNotebookRenderers: createProxyIdentifier('ExtHostNotebookRenderers'), + ExtHostInteractive: createProxyIdentifier('ExtHostInteractive'), + ExtHostTheming: createProxyIdentifier('ExtHostTheming'), + ExtHostTunnelService: createProxyIdentifier('ExtHostTunnelService'), + ExtHostAuthentication: createProxyIdentifier('ExtHostAuthentication'), + ExtHostTimeline: createProxyIdentifier('ExtHostTimeline'), + ExtHostTesting: createProxyIdentifier('ExtHostTesting'), + ExtHostTelemetry: createProxyIdentifier('ExtHostTelemetry'), }; diff --git a/src/vs/workbench/services/extensions/common/proxyIdentifier.ts b/src/vs/workbench/services/extensions/common/proxyIdentifier.ts index 694af66403d..ff7dde653af 100644 --- a/src/vs/workbench/services/extensions/common/proxyIdentifier.ts +++ b/src/vs/workbench/services/extensions/common/proxyIdentifier.ts @@ -29,12 +29,10 @@ export class ProxyIdentifier { public static count = 0; _proxyIdentifierBrand: void = undefined; - public readonly isMain: boolean; public readonly sid: string; public readonly nid: number; - constructor(isMain: boolean, sid: string) { - this.isMain = isMain; + constructor(sid: string) { this.sid = sid; this.nid = (++ProxyIdentifier.count); } @@ -42,14 +40,8 @@ export class ProxyIdentifier { const identifiers: ProxyIdentifier[] = []; -export function createMainContextProxyIdentifier(identifier: string): ProxyIdentifier { - const result = new ProxyIdentifier(true, identifier); - identifiers[result.nid] = result; - return result; -} - -export function createExtHostContextProxyIdentifier(identifier: string): ProxyIdentifier { - const result = new ProxyIdentifier(false, identifier); +export function createProxyIdentifier(identifier: string): ProxyIdentifier { + const result = new ProxyIdentifier(identifier); identifiers[result.nid] = result; return result; } diff --git a/src/vs/workbench/services/extensions/common/rpcProtocol.ts b/src/vs/workbench/services/extensions/common/rpcProtocol.ts index c0887a2f4a7..9a50650d443 100644 --- a/src/vs/workbench/services/extensions/common/rpcProtocol.ts +++ b/src/vs/workbench/services/extensions/common/rpcProtocol.ts @@ -270,7 +270,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol { for (let i = 0, len = identifiers.length; i < len; i++) { const identifier = identifiers[i]; if (!this._locals[identifier.nid]) { - throw new Error(`Missing actor ${identifier.sid} (isMain: ${identifier.isMain})`); + throw new Error(`Missing proxy instance ${identifier.sid}`); } } } diff --git a/src/vs/workbench/services/extensions/test/common/rpcProtocol.test.ts b/src/vs/workbench/services/extensions/test/common/rpcProtocol.test.ts index f500096ba1a..66e63fc7464 100644 --- a/src/vs/workbench/services/extensions/test/common/rpcProtocol.test.ts +++ b/src/vs/workbench/services/extensions/test/common/rpcProtocol.test.ts @@ -47,7 +47,7 @@ suite('RPCProtocol', () => { let A = new RPCProtocol(a_protocol); let B = new RPCProtocol(b_protocol); - const bIdentifier = new ProxyIdentifier(false, 'bb'); + const bIdentifier = new ProxyIdentifier('bb'); const bInstance = new BClass(); B.set(bIdentifier, bInstance); bProxy = A.getProxy(bIdentifier);