From f8870d79d62d38b8587ff10ef226735891287815 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 24 Jul 2018 15:17:14 -0700 Subject: [PATCH] Formatting and extration --- src/vs/workbench/api/node/extHost.api.impl.ts | 2 +- src/vs/workbench/api/node/extHostWebview.ts | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 4ca5751ecef..7f33441ca83 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -425,7 +425,7 @@ export function createApiFactory( return extHostOutputService.createOutputChannel(name); }, createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel { - return extHostWebviews.createWebview(viewType, title, showOptions, options, extension.extensionLocation); + return extHostWebviews.createWebview(extension.extensionLocation, viewType, title, showOptions, options); }, createTerminal(nameOrOptions: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[]): vscode.Terminal { if (typeof nameOrOptions === 'object') { diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index 78fb98240ea..54a4f910bb3 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -12,7 +12,6 @@ import * as vscode from 'vscode'; import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewState } from './extHost.protocol'; import { Disposable } from './extHostTypes'; - type IconPath = URI | { light: URI, dark: URI }; export class ExtHostWebview implements vscode.Webview { @@ -224,8 +223,11 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { export class ExtHostWebviews implements ExtHostWebviewsShape { private static webviewHandlePool = 1; - private readonly _proxy: MainThreadWebviewsShape; + private static newHandle(): WebviewPanelHandle { + return ExtHostWebviews.webviewHandlePool++ + ''; + } + private readonly _proxy: MainThreadWebviewsShape; private readonly _webviewPanels = new Map(); private readonly _serializers = new Map(); @@ -235,22 +237,20 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { this._proxy = mainContext.getProxy(MainContext.MainThreadWebviews); } - createWebview( + public createWebview( + extensionLocation: URI, viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, - options: (vscode.WebviewPanelOptions & vscode.WebviewOptions) | undefined, - extensionLocation: URI + options: (vscode.WebviewPanelOptions & vscode.WebviewOptions) = {}, ): vscode.WebviewPanel { - options = options || {}; - const viewColumn = typeof showOptions === 'object' ? showOptions.viewColumn : showOptions; const webviewShowOptions = { viewColumn: typeConverters.ViewColumn.from(viewColumn), preserveFocus: typeof showOptions === 'object' && !!showOptions.preserveFocus }; - const handle = ExtHostWebviews.webviewHandlePool++ + ''; + const handle = ExtHostWebviews.newHandle(); this._proxy.$createWebviewPanel(handle, viewType, title, webviewShowOptions, options, extensionLocation); const webview = new ExtHostWebview(handle, this._proxy, options); @@ -259,7 +259,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { return panel; } - registerWebviewPanelSerializer( + public registerWebviewPanelSerializer( viewType: string, serializer: vscode.WebviewPanelSerializer ): vscode.Disposable { @@ -276,14 +276,20 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { }); } - $onMessage(handle: WebviewPanelHandle, message: any): void { + public $onMessage( + handle: WebviewPanelHandle, + message: any + ): void { const panel = this.getWebviewPanel(handle); if (panel) { panel.webview._onMessageEmitter.fire(message); } } - $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, newState: WebviewPanelViewState): void { + public $onDidChangeWebviewPanelViewState( + handle: WebviewPanelHandle, + newState: WebviewPanelViewState + ): void { const panel = this.getWebviewPanel(handle); if (panel) { const viewColumn = typeConverters.ViewColumn.to(newState.position); -- GitLab