first cut of option-less open, #13807

This commit is contained in:
Johannes Rieken
2017-08-21 10:35:11 +02:00
parent d51605bed8
commit 891e6843e8
6 changed files with 79 additions and 0 deletions

View File

@@ -52,6 +52,7 @@ import * as languageConfiguration from 'vs/editor/common/modes/languageConfigura
import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
import { ExtHostThreadService } from "vs/workbench/services/thread/node/extHostThreadService";
import { ProxyIdentifier } from "vs/workbench/services/thread/common/threadService";
import { ExtHostDialogs } from "vs/workbench/api/node/extHostDialogs";
export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode;
@@ -105,6 +106,7 @@ export function createApiFactory(
// Other instances
const extHostMessageService = new ExtHostMessageService(threadService);
const extHostDialogs = new ExtHostDialogs(threadService);
const extHostStatusBar = new ExtHostStatusBar(threadService);
const extHostProgress = new ExtHostProgress(threadService.get(MainContext.MainThreadProgress));
const extHostOutputService = new ExtHostOutputService(threadService);
@@ -368,6 +370,9 @@ export function createApiFactory(
sampleFunction: proposedApiFunction(extension, () => {
return extHostMessageService.showMessage(extension.id, Severity.Info, 'Hello Proposed Api!', {}, []);
}),
showOpenDialog: proposedApiFunction(extension, () => {
return extHostDialogs.showOpenDialog();
})
};
// namespace: workspace

View File

@@ -113,6 +113,10 @@ export interface MainThreadDiagnosticsShape extends IDisposable {
$clear(owner: string): TPromise<any>;
}
export interface MainThreadDiaglogsShape extends IDisposable {
$showOpenDialog(): TPromise<string[]>;
}
export interface MainThreadDocumentContentProvidersShape extends IDisposable {
$registerTextContentProvider(handle: number, scheme: string): void;
$unregisterTextContentProvider(handle: number): void;
@@ -532,6 +536,7 @@ export const MainContext = {
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics'),
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs'),
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments'),
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders'),
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors'),

View File

@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MainContext, MainThreadDiaglogsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import URI from "vs/base/common/uri";
export class ExtHostDialogs {
private readonly _proxy: MainThreadDiaglogsShape;
constructor(mainContext: IMainContext) {
this._proxy = mainContext.get(MainContext.MainThreadDialogs);
}
showOpenDialog(): Thenable<URI[]> {
return this._proxy.$showOpenDialog().then(filepaths => {
if (!filepaths) {
return undefined;
}
return filepaths.map(URI.file);
});
}
}