提交 f8870d79 编写于 作者: M Matt Bierner

Formatting and extration

上级 bf4a68a2
...@@ -425,7 +425,7 @@ export function createApiFactory( ...@@ -425,7 +425,7 @@ export function createApiFactory(
return extHostOutputService.createOutputChannel(name); return extHostOutputService.createOutputChannel(name);
}, },
createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel { 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 { createTerminal(nameOrOptions: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
if (typeof nameOrOptions === 'object') { if (typeof nameOrOptions === 'object') {
......
...@@ -12,7 +12,6 @@ import * as vscode from 'vscode'; ...@@ -12,7 +12,6 @@ import * as vscode from 'vscode';
import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewState } from './extHost.protocol'; import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewState } from './extHost.protocol';
import { Disposable } from './extHostTypes'; import { Disposable } from './extHostTypes';
type IconPath = URI | { light: URI, dark: URI }; type IconPath = URI | { light: URI, dark: URI };
export class ExtHostWebview implements vscode.Webview { export class ExtHostWebview implements vscode.Webview {
...@@ -224,8 +223,11 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { ...@@ -224,8 +223,11 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
export class ExtHostWebviews implements ExtHostWebviewsShape { export class ExtHostWebviews implements ExtHostWebviewsShape {
private static webviewHandlePool = 1; private static webviewHandlePool = 1;
private readonly _proxy: MainThreadWebviewsShape; private static newHandle(): WebviewPanelHandle {
return ExtHostWebviews.webviewHandlePool++ + '';
}
private readonly _proxy: MainThreadWebviewsShape;
private readonly _webviewPanels = new Map<WebviewPanelHandle, ExtHostWebviewPanel>(); private readonly _webviewPanels = new Map<WebviewPanelHandle, ExtHostWebviewPanel>();
private readonly _serializers = new Map<string, vscode.WebviewPanelSerializer>(); private readonly _serializers = new Map<string, vscode.WebviewPanelSerializer>();
...@@ -235,22 +237,20 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { ...@@ -235,22 +237,20 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
this._proxy = mainContext.getProxy(MainContext.MainThreadWebviews); this._proxy = mainContext.getProxy(MainContext.MainThreadWebviews);
} }
createWebview( public createWebview(
extensionLocation: URI,
viewType: string, viewType: string,
title: string, title: string,
showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean },
options: (vscode.WebviewPanelOptions & vscode.WebviewOptions) | undefined, options: (vscode.WebviewPanelOptions & vscode.WebviewOptions) = {},
extensionLocation: URI
): vscode.WebviewPanel { ): vscode.WebviewPanel {
options = options || {};
const viewColumn = typeof showOptions === 'object' ? showOptions.viewColumn : showOptions; const viewColumn = typeof showOptions === 'object' ? showOptions.viewColumn : showOptions;
const webviewShowOptions = { const webviewShowOptions = {
viewColumn: typeConverters.ViewColumn.from(viewColumn), viewColumn: typeConverters.ViewColumn.from(viewColumn),
preserveFocus: typeof showOptions === 'object' && !!showOptions.preserveFocus preserveFocus: typeof showOptions === 'object' && !!showOptions.preserveFocus
}; };
const handle = ExtHostWebviews.webviewHandlePool++ + ''; const handle = ExtHostWebviews.newHandle();
this._proxy.$createWebviewPanel(handle, viewType, title, webviewShowOptions, options, extensionLocation); this._proxy.$createWebviewPanel(handle, viewType, title, webviewShowOptions, options, extensionLocation);
const webview = new ExtHostWebview(handle, this._proxy, options); const webview = new ExtHostWebview(handle, this._proxy, options);
...@@ -259,7 +259,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { ...@@ -259,7 +259,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return panel; return panel;
} }
registerWebviewPanelSerializer( public registerWebviewPanelSerializer(
viewType: string, viewType: string,
serializer: vscode.WebviewPanelSerializer serializer: vscode.WebviewPanelSerializer
): vscode.Disposable { ): vscode.Disposable {
...@@ -276,14 +276,20 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { ...@@ -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); const panel = this.getWebviewPanel(handle);
if (panel) { if (panel) {
panel.webview._onMessageEmitter.fire(message); panel.webview._onMessageEmitter.fire(message);
} }
} }
$onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, newState: WebviewPanelViewState): void { public $onDidChangeWebviewPanelViewState(
handle: WebviewPanelHandle,
newState: WebviewPanelViewState
): void {
const panel = this.getWebviewPanel(handle); const panel = this.getWebviewPanel(handle);
if (panel) { if (panel) {
const viewColumn = typeConverters.ViewColumn.to(newState.position); const viewColumn = typeConverters.ViewColumn.to(newState.position);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册