|
|
|
|
@@ -3,7 +3,6 @@
|
|
|
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
import * as nls from 'vs/nls';
|
|
|
|
|
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
|
|
|
|
import * as errors from 'vs/base/common/errors';
|
|
|
|
|
import { Emitter, Event } from 'vs/base/common/event';
|
|
|
|
|
@@ -37,7 +36,7 @@ import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionS
|
|
|
|
|
import { ExtHostFileSystem } from 'vs/workbench/api/common/extHostFileSystem';
|
|
|
|
|
import { ExtHostFileSystemEventService } from 'vs/workbench/api/common/extHostFileSystemEventService';
|
|
|
|
|
import { ExtHostHeapService } from 'vs/workbench/api/common/extHostHeapService';
|
|
|
|
|
import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguageFeatures';
|
|
|
|
|
import { ExtHostLanguageFeatures, ISchemeTransformer } from 'vs/workbench/api/common/extHostLanguageFeatures';
|
|
|
|
|
import { ExtHostLanguages } from 'vs/workbench/api/common/extHostLanguages';
|
|
|
|
|
import { ExtHostLogService } from 'vs/workbench/api/common/extHostLogService';
|
|
|
|
|
import { ExtHostMessageService } from 'vs/workbench/api/common/extHostMessageService';
|
|
|
|
|
@@ -69,8 +68,6 @@ import { CLIServer } from 'vs/workbench/api/node/extHostCLIServer';
|
|
|
|
|
import { withNullAsUndefined } from 'vs/base/common/types';
|
|
|
|
|
import { values } from 'vs/base/common/collections';
|
|
|
|
|
import { Schemas } from 'vs/base/common/network';
|
|
|
|
|
import { IURITransformer } from 'vs/base/common/uriIpc';
|
|
|
|
|
import { ExtHostEditorInsets } from 'vs/workbench/api/common/extHostCodeInsets';
|
|
|
|
|
|
|
|
|
|
export interface IExtensionApiFactory {
|
|
|
|
|
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
|
|
|
|
|
@@ -95,7 +92,8 @@ export function createApiFactory(
|
|
|
|
|
extensionService: ExtHostExtensionService,
|
|
|
|
|
extHostLogService: ExtHostLogService,
|
|
|
|
|
extHostStorage: ExtHostStorage,
|
|
|
|
|
uriTransformer: IURITransformer | null
|
|
|
|
|
schemeTransformer: ISchemeTransformer | null,
|
|
|
|
|
outputChannelName: string
|
|
|
|
|
): IExtensionApiFactory {
|
|
|
|
|
|
|
|
|
|
// Addressable instances
|
|
|
|
|
@@ -113,9 +111,8 @@ export function createApiFactory(
|
|
|
|
|
const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands, extHostLogService));
|
|
|
|
|
rpcProtocol.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace);
|
|
|
|
|
rpcProtocol.set(ExtHostContext.ExtHostConfiguration, extHostConfiguration);
|
|
|
|
|
const extHostEditorInsets = rpcProtocol.set(ExtHostContext.ExtHostEditorInsets, new ExtHostEditorInsets(rpcProtocol.getProxy(MainContext.MainThreadEditorInsets), extHostEditors));
|
|
|
|
|
const extHostDiagnostics = rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(rpcProtocol));
|
|
|
|
|
const extHostLanguageFeatures = rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, new ExtHostLanguageFeatures(rpcProtocol, uriTransformer, extHostDocuments, extHostCommands, extHostHeapService, extHostDiagnostics, extHostLogService));
|
|
|
|
|
const extHostLanguageFeatures = rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, new ExtHostLanguageFeatures(rpcProtocol, schemeTransformer, extHostDocuments, extHostCommands, extHostHeapService, extHostDiagnostics, extHostLogService));
|
|
|
|
|
const extHostFileSystem = rpcProtocol.set(ExtHostContext.ExtHostFileSystem, new ExtHostFileSystem(rpcProtocol, extHostLanguageFeatures));
|
|
|
|
|
const extHostFileSystemEvent = rpcProtocol.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService(rpcProtocol, extHostDocumentsAndEditors));
|
|
|
|
|
const extHostQuickOpen = rpcProtocol.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(rpcProtocol, extHostWorkspace, extHostCommands));
|
|
|
|
|
@@ -124,7 +121,7 @@ export function createApiFactory(
|
|
|
|
|
// const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(rpcProtocol, extHostWorkspace, extensionService, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService, extHostCommands));
|
|
|
|
|
const extHostSCM = rpcProtocol.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(rpcProtocol, extHostCommands, extHostLogService));
|
|
|
|
|
const extHostComment = rpcProtocol.set(ExtHostContext.ExtHostComments, new ExtHostComments(rpcProtocol, extHostCommands, extHostDocuments));
|
|
|
|
|
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, uriTransformer, extHostLogService));
|
|
|
|
|
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, schemeTransformer, extHostLogService));
|
|
|
|
|
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, new ExtHostTask(rpcProtocol, extHostWorkspace, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService));
|
|
|
|
|
const extHostWindow = rpcProtocol.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(rpcProtocol));
|
|
|
|
|
rpcProtocol.set(ExtHostContext.ExtHostExtensionService, extensionService);
|
|
|
|
|
@@ -157,7 +154,6 @@ export function createApiFactory(
|
|
|
|
|
const extHostLanguages = new ExtHostLanguages(rpcProtocol, extHostDocuments);
|
|
|
|
|
|
|
|
|
|
// Register an output channel for exthost log
|
|
|
|
|
const outputChannelName = initData.remoteAuthority ? nls.localize('remote extension host Log', "Remote Extension Host") : nls.localize('extension host Log', "Extension Host");
|
|
|
|
|
extHostOutputService.createOutputChannelFromLogFile(outputChannelName, extHostLogService.logFile);
|
|
|
|
|
|
|
|
|
|
// Register API-ish commands
|
|
|
|
|
@@ -167,7 +163,7 @@ export function createApiFactory(
|
|
|
|
|
|
|
|
|
|
// Check document selectors for being overly generic. Technically this isn't a problem but
|
|
|
|
|
// in practice many extensions say they support `fooLang` but need fs-access to do so. Those
|
|
|
|
|
// extension should specify then the `file`-scheme, e.g. `{ scheme: 'fooLang', language: 'fooLang' }`
|
|
|
|
|
// extension should specify then the `file`-scheme, e.g `{ scheme: 'fooLang', language: 'fooLang' }`
|
|
|
|
|
// We only inform once, it is not a warning because we just want to raise awareness and because
|
|
|
|
|
// we cannot say if the extension is doing it right or wrong...
|
|
|
|
|
const checkSelector = (function () {
|
|
|
|
|
@@ -243,7 +239,7 @@ export function createApiFactory(
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// namespace: env
|
|
|
|
|
const env: typeof vscode.env = {
|
|
|
|
|
const env: typeof vscode.env = Object.freeze({
|
|
|
|
|
get machineId() { return initData.telemetryInfo.machineId; },
|
|
|
|
|
get sessionId() { return initData.telemetryInfo.sessionId; },
|
|
|
|
|
get language() { return initData.environment.appLanguage; },
|
|
|
|
|
@@ -264,11 +260,7 @@ export function createApiFactory(
|
|
|
|
|
openExternal(uri: URI) {
|
|
|
|
|
return extHostWindow.openUri(uri, { allowTunneling: !!initData.remoteAuthority });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (!initData.environment.extensionTestsLocationURI) {
|
|
|
|
|
// allow to patch env-function when running tests
|
|
|
|
|
Object.freeze(env);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// namespace: extensions
|
|
|
|
|
const extensions: typeof vscode.extensions = {
|
|
|
|
|
@@ -313,6 +305,10 @@ export function createApiFactory(
|
|
|
|
|
registerCodeLensProvider(selector: vscode.DocumentSelector, provider: vscode.CodeLensProvider): vscode.Disposable {
|
|
|
|
|
return extHostLanguageFeatures.registerCodeLensProvider(extension, checkSelector(selector), provider);
|
|
|
|
|
},
|
|
|
|
|
registerCodeInsetProvider(selector: vscode.DocumentSelector, provider: vscode.CodeInsetProvider): vscode.Disposable {
|
|
|
|
|
checkProposedApiEnabled(extension);
|
|
|
|
|
return extHostLanguageFeatures.registerCodeInsetProvider(extension, checkSelector(selector), provider);
|
|
|
|
|
},
|
|
|
|
|
registerDefinitionProvider(selector: vscode.DocumentSelector, provider: vscode.DefinitionProvider): vscode.Disposable {
|
|
|
|
|
return extHostLanguageFeatures.registerDefinitionProvider(extension, checkSelector(selector), provider);
|
|
|
|
|
},
|
|
|
|
|
@@ -474,10 +470,7 @@ export function createApiFactory(
|
|
|
|
|
return extHostDialogs.showSaveDialog(options);
|
|
|
|
|
},
|
|
|
|
|
createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem {
|
|
|
|
|
const id = extension.identifier.value;
|
|
|
|
|
const name = nls.localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name);
|
|
|
|
|
|
|
|
|
|
return extHostStatusBar.createStatusBarEntry(id, name, <number>position, priority);
|
|
|
|
|
return extHostStatusBar.createStatusBarEntry(extension.identifier, <number>position, priority);
|
|
|
|
|
},
|
|
|
|
|
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): vscode.Disposable {
|
|
|
|
|
return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
|
|
|
|
|
@@ -495,14 +488,9 @@ export function createApiFactory(
|
|
|
|
|
createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel {
|
|
|
|
|
return extHostWebviews.createWebviewPanel(extension, viewType, title, showOptions, options);
|
|
|
|
|
},
|
|
|
|
|
createWebviewTextEditorInset(editor: vscode.TextEditor, range: vscode.Range, options: vscode.WebviewOptions): vscode.WebviewEditorInset {
|
|
|
|
|
checkProposedApiEnabled(extension);
|
|
|
|
|
return extHostEditorInsets.createWebviewEditorInset(editor, range, options);
|
|
|
|
|
},
|
|
|
|
|
createTerminal(nameOrOptions?: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
|
|
|
|
if (typeof nameOrOptions === 'object') {
|
|
|
|
|
nameOrOptions.runInBackground = nameOrOptions.runInBackground && extension.enableProposedApi;
|
|
|
|
|
return extHostTerminalService.createTerminalFromOptions(nameOrOptions);
|
|
|
|
|
return extHostTerminalService.createTerminalFromOptions(<vscode.TerminalOptions>nameOrOptions);
|
|
|
|
|
}
|
|
|
|
|
return extHostTerminalService.createTerminal(<string>nameOrOptions, shellPath, shellArgs);
|
|
|
|
|
},
|
|
|
|
|
|