mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -170,14 +170,10 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
|
||||
this._startExtensionHostProcess(false, Array.from(this._allRequestedActivateEvents.keys()));
|
||||
}
|
||||
|
||||
public startExtensionHost(): void {
|
||||
protected startExtensionHost(): void {
|
||||
this._startExtensionHostProcess(false, Array.from(this._allRequestedActivateEvents.keys()));
|
||||
}
|
||||
|
||||
public stopExtensionHost(): void {
|
||||
this._stopExtensionHostProcess();
|
||||
}
|
||||
|
||||
public activateByEvent(activationEvent: string): Promise<void> {
|
||||
if (this._installedExtensionsReady.isOpen()) {
|
||||
// Extensions have been scanned and interpreted
|
||||
|
||||
@@ -17,9 +17,9 @@ export class ExtensionDescriptionRegistry {
|
||||
public readonly onDidChange = this._onDidChange.event;
|
||||
|
||||
private _extensionDescriptions: IExtensionDescription[];
|
||||
private _extensionsMap: Map<string, IExtensionDescription>;
|
||||
private _extensionsArr: IExtensionDescription[];
|
||||
private _activationMap: Map<string, IExtensionDescription[]>;
|
||||
private _extensionsMap!: Map<string, IExtensionDescription>;
|
||||
private _extensionsArr!: IExtensionDescription[];
|
||||
private _activationMap!: Map<string, IExtensionDescription[]>;
|
||||
|
||||
constructor(extensionDescriptions: IExtensionDescription[]) {
|
||||
this._extensionDescriptions = extensionDescriptions;
|
||||
|
||||
@@ -5,20 +5,23 @@
|
||||
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { Counter } from 'vs/base/common/numbers';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI, setUriThrowOnMissingScheme } from 'vs/base/common/uri';
|
||||
import { IURITransformer } from 'vs/base/common/uriIpc';
|
||||
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IInitData, MainContext, MainThreadConsoleShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostConfiguration } from 'vs/workbench/api/common/extHostConfiguration';
|
||||
import { ExtHostExtensionService, IHostUtils } from 'vs/workbench/api/node/extHostExtensionService';
|
||||
import { ExtHostLogService } from 'vs/workbench/api/common/extHostLogService';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
|
||||
import { RPCProtocol } from 'vs/workbench/services/extensions/common/rpcProtocol';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { getSingletonServiceDescriptors } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtHostRpcService, ExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { IURITransformerService, URITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { IExtHostExtensionService, IHostUtils } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
|
||||
// we don't (yet) throw when extensions parse
|
||||
// uris that have no scheme
|
||||
@@ -40,11 +43,8 @@ export class ExtensionHostMain {
|
||||
|
||||
private _isTerminating: boolean;
|
||||
private readonly _hostUtils: IHostUtils;
|
||||
private readonly _extensionService: ExtHostExtensionService;
|
||||
private readonly _extHostLogService: ExtHostLogService;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
private _searchRequestIdProvider: Counter;
|
||||
private readonly _extensionService: IExtHostExtensionService;
|
||||
private readonly _disposables = new DisposableStore();
|
||||
|
||||
constructor(
|
||||
protocol: IMessagePassingProtocol,
|
||||
@@ -59,32 +59,31 @@ export class ExtensionHostMain {
|
||||
const rpcProtocol = new RPCProtocol(protocol, null, uriTransformer);
|
||||
|
||||
// ensure URIs are transformed and revived
|
||||
initData = this.transform(initData, rpcProtocol);
|
||||
initData = ExtensionHostMain._transform(initData, rpcProtocol);
|
||||
|
||||
// allow to patch console
|
||||
consolePatchFn(rpcProtocol.getProxy(MainContext.MainThreadConsole));
|
||||
|
||||
// services
|
||||
this._extHostLogService = new ExtHostLogService(logServiceFn(initData), initData.logsLocation.fsPath);
|
||||
this.disposables.push(this._extHostLogService);
|
||||
const extHostLogService = new ExtHostLogService(logServiceFn(initData), initData.logsLocation.fsPath);
|
||||
this._disposables.add(extHostLogService);
|
||||
|
||||
this._searchRequestIdProvider = new Counter();
|
||||
const extHostWorkspace = new ExtHostWorkspace(rpcProtocol, this._extHostLogService, this._searchRequestIdProvider, withNullAsUndefined(initData.workspace));
|
||||
// bootstrap services
|
||||
const services = new ServiceCollection(...getSingletonServiceDescriptors());
|
||||
services.set(IExtHostInitDataService, { _serviceBrand: undefined, ...initData });
|
||||
services.set(IExtHostRpcService, new ExtHostRpcService(rpcProtocol));
|
||||
services.set(ILogService, extHostLogService);
|
||||
services.set(IURITransformerService, new URITransformerService(uriTransformer));
|
||||
services.set(IHostUtils, hostUtils);
|
||||
|
||||
this._extHostLogService.info('extension host started');
|
||||
this._extHostLogService.trace('initData', initData);
|
||||
const instaService: IInstantiationService = new InstantiationService(services, true);
|
||||
|
||||
const extHostConfiguraiton = new ExtHostConfiguration(rpcProtocol.getProxy(MainContext.MainThreadConfiguration), extHostWorkspace);
|
||||
this._extensionService = new ExtHostExtensionService(
|
||||
hostUtils,
|
||||
initData,
|
||||
rpcProtocol,
|
||||
extHostWorkspace,
|
||||
extHostConfiguraiton,
|
||||
initData.environment,
|
||||
this._extHostLogService,
|
||||
uriTransformer
|
||||
);
|
||||
extHostLogService.info('extension host started');
|
||||
extHostLogService.trace('initData', initData);
|
||||
|
||||
// todo@joh -> not soo nice...
|
||||
this._extensionService = instaService.invokeFunction(accessor => accessor.get(IExtHostExtensionService));
|
||||
this._extensionService.initialize();
|
||||
|
||||
// error forwarding and stack trace scanning
|
||||
Error.stackTraceLimit = 100; // increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
@@ -127,7 +126,7 @@ export class ExtensionHostMain {
|
||||
}
|
||||
this._isTerminating = true;
|
||||
|
||||
this.disposables = dispose(this.disposables);
|
||||
this._disposables.dispose();
|
||||
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
// TODO: write to log once we have one
|
||||
@@ -141,7 +140,7 @@ export class ExtensionHostMain {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private transform(initData: IInitData, rpcProtocol: RPCProtocol): IInitData {
|
||||
private static _transform(initData: IInitData, rpcProtocol: RPCProtocol): IInitData {
|
||||
initData.extensions.forEach((ext) => (<any>ext).extensionLocation = URI.revive(rpcProtocol.transformIncomingURIs(ext.extensionLocation)));
|
||||
initData.environment.appRoot = URI.revive(rpcProtocol.transformIncomingURIs(initData.environment.appRoot));
|
||||
initData.environment.appSettingsHome = URI.revive(rpcProtocol.transformIncomingURIs(initData.environment.appSettingsHome));
|
||||
@@ -154,9 +154,13 @@ export class ExtensionHostProcessManager extends Disposable {
|
||||
private async _measureUp(proxy: ExtHostExtensionServiceShape): Promise<number> {
|
||||
const SIZE = 10 * 1024 * 1024; // 10MB
|
||||
|
||||
let b = Buffer.alloc(SIZE, Math.random() % 256);
|
||||
let buff = VSBuffer.alloc(SIZE);
|
||||
let value = Math.ceil(Math.random() * 256);
|
||||
for (let i = 0; i < buff.byteLength; i++) {
|
||||
buff.writeUInt8(i, value);
|
||||
}
|
||||
const sw = StopWatch.create(true);
|
||||
await proxy.$test_up(VSBuffer.wrap(b));
|
||||
await proxy.$test_up(buff);
|
||||
sw.stop();
|
||||
return ExtensionHostProcessManager._convert(SIZE, sw.elapsed());
|
||||
}
|
||||
|
||||
@@ -219,16 +219,6 @@ export interface IExtensionService {
|
||||
*/
|
||||
restartExtensionHost(): void;
|
||||
|
||||
/**
|
||||
* Starts the extension host.
|
||||
*/
|
||||
startExtensionHost(): void;
|
||||
|
||||
/**
|
||||
* Stops the extension host.
|
||||
*/
|
||||
stopExtensionHost(): void;
|
||||
|
||||
/**
|
||||
* Modify the environment of the remote extension host
|
||||
* @param env New properties for the remote extension host
|
||||
@@ -282,8 +272,6 @@ export class NullExtensionService implements IExtensionService {
|
||||
getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
|
||||
getInspectPort(): number { return 0; }
|
||||
restartExtensionHost(): void { }
|
||||
startExtensionHost(): void { }
|
||||
stopExtensionHost(): void { }
|
||||
async setRemoteEnvironment(_env: { [key: string]: string | null }): Promise<void> { }
|
||||
canAddExtension(): boolean { return false; }
|
||||
canRemoveExtension(): boolean { return false; }
|
||||
|
||||
@@ -20,6 +20,9 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContribution, Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
const THIRTY_SECONDS = 30 * 1000;
|
||||
@@ -48,7 +51,7 @@ export interface IExtensionUrlHandler {
|
||||
*
|
||||
* It also makes sure the user confirms opening URLs directed towards extensions.
|
||||
*/
|
||||
export class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
|
||||
readonly _serviceBrand: any;
|
||||
|
||||
@@ -67,7 +70,6 @@ export class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
@IExtensionGalleryService private readonly galleryService: IExtensionGalleryService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
|
||||
) {
|
||||
const interval = setInterval(() => this.garbageCollect(), THIRTY_SECONDS);
|
||||
const urlToHandleValue = this.storageService.get(URL_TO_HANDLE, StorageScope.WORKSPACE);
|
||||
@@ -80,6 +82,9 @@ export class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
urlService.registerHandler(this),
|
||||
toDisposable(() => clearInterval(interval))
|
||||
);
|
||||
|
||||
const cache = ExtensionUrlBootstrapHandler.cache;
|
||||
setTimeout(() => cache.forEach(uri => this.handleURL(uri)));
|
||||
}
|
||||
|
||||
async handleURL(uri: URI, confirmed?: boolean): Promise<boolean> {
|
||||
@@ -333,3 +338,33 @@ export class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
}
|
||||
|
||||
registerSingleton(IExtensionUrlHandler, ExtensionUrlHandler);
|
||||
|
||||
/**
|
||||
* This class handles URLs before `ExtensionUrlHandler` is instantiated.
|
||||
* More info: https://github.com/microsoft/vscode/issues/73101
|
||||
*/
|
||||
class ExtensionUrlBootstrapHandler implements IWorkbenchContribution, IURLHandler {
|
||||
|
||||
private static _cache: URI[] = [];
|
||||
private static disposable: IDisposable;
|
||||
|
||||
static get cache(): URI[] {
|
||||
ExtensionUrlBootstrapHandler.disposable.dispose();
|
||||
|
||||
const result = ExtensionUrlBootstrapHandler._cache;
|
||||
ExtensionUrlBootstrapHandler._cache = [];
|
||||
return result;
|
||||
}
|
||||
|
||||
constructor(@IURLService urlService: IURLService) {
|
||||
ExtensionUrlBootstrapHandler.disposable = urlService.registerHandler(this);
|
||||
}
|
||||
|
||||
handleURL(uri: URI): Promise<boolean> {
|
||||
ExtensionUrlBootstrapHandler._cache.push(uri);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionUrlBootstrapHandler, LifecyclePhase.Ready);
|
||||
|
||||
@@ -20,10 +20,10 @@ export interface IRPCProtocol {
|
||||
assertRegistered(identifiers: ProxyIdentifier<any>[]): void;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export class ProxyIdentifier<T> {
|
||||
public static count = 0;
|
||||
_proxyIdentifierBrand: void;
|
||||
_suppressCompilerUnusedWarning: T;
|
||||
|
||||
public readonly isMain: boolean;
|
||||
public readonly sid: string;
|
||||
|
||||
@@ -183,6 +183,7 @@ export class RemoteExtensionHostClient extends Disposable implements IExtensionH
|
||||
const r: IInitData = {
|
||||
commit: this._productService.commit,
|
||||
version: this._productService.version,
|
||||
vscodeVersion: this._productService.vscodeVersion, // {{SQL CARBON EDIT}} add vscode version
|
||||
parentPid: remoteExtensionHostData.pid,
|
||||
environment: {
|
||||
isExtensionDevelopmentDebug,
|
||||
|
||||
@@ -48,8 +48,8 @@ function getExtraDevSystemExtensionsRoot(): string {
|
||||
export class CachedExtensionScanner {
|
||||
|
||||
public readonly scannedExtensions: Promise<IExtensionDescription[]>;
|
||||
private _scannedExtensionsResolve: (result: IExtensionDescription[]) => void;
|
||||
private _scannedExtensionsReject: (err: any) => void;
|
||||
private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void;
|
||||
private _scannedExtensionsReject!: (err: any) => void;
|
||||
public readonly translationConfig: Promise<Translations>;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -87,6 +87,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
|
||||
this._terminating = false;
|
||||
|
||||
this._namedPipeServer = null;
|
||||
this._inspectPort = null;
|
||||
this._extensionHostProcess = null;
|
||||
this._extensionHostConnection = null;
|
||||
this._messageProtocol = null;
|
||||
@@ -388,6 +389,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
|
||||
const r: IInitData = {
|
||||
commit: product.commit,
|
||||
version: pkg.version,
|
||||
vscodeVersion: product.vscodeVersion, // {{SQL CARBON EDIT}} add vscode version
|
||||
parentPid: process.pid,
|
||||
environment: {
|
||||
isExtensionDevelopmentDebug: this._isExtensionDevDebug,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
|
||||
import { ExtensionHostDebugChannelClient, ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
|
||||
|
||||
export class ExtensionHostDebugService extends ExtensionHostDebugChannelClient {
|
||||
|
||||
constructor(
|
||||
@IMainProcessService readonly windowService: IMainProcessService,
|
||||
) {
|
||||
super(windowService.getChannel(ExtensionHostDebugBroadcastChannel.ChannelName));
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IExtensionHostDebugService, ExtensionHostDebugService, true);
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as nativeWatchdog from 'native-watchdog';
|
||||
import * as net from 'net';
|
||||
import * as minimist from 'minimist';
|
||||
import * as minimist from 'vscode-minimist';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';
|
||||
@@ -14,14 +14,15 @@ import { NodeSocket, WebSocketNodeSocket } from 'vs/base/parts/ipc/node/ipc.net'
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import { IInitData, MainThreadConsoleShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { MessageType, createMessageOfType, isMessageOfType, IExtHostSocketMessage, IExtHostReadyMessage } from 'vs/workbench/services/extensions/common/extensionHostProtocol';
|
||||
import { ExtensionHostMain, IExitFn, ILogServiceFn } from 'vs/workbench/services/extensions/node/extensionHostMain';
|
||||
import { ExtensionHostMain, IExitFn, ILogServiceFn } from 'vs/workbench/services/extensions/common/extensionHostMain';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { ExtensionHostLogFileName } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IURITransformer, URITransformer, IRawURITransformer } from 'vs/base/common/uriIpc';
|
||||
import { exists } from 'vs/base/node/pfs';
|
||||
import { realpath } from 'vs/base/node/extpath';
|
||||
import { IHostUtils } from 'vs/workbench/api/node/extHostExtensionService';
|
||||
import { IHostUtils } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import 'vs/workbench/api/node/extHost.services';
|
||||
|
||||
interface ParsedExtHostArgs {
|
||||
uriTransformerPath?: string;
|
||||
@@ -312,6 +313,7 @@ export async function startExtensionHostProcess(): Promise<void> {
|
||||
|
||||
// host abstraction
|
||||
const hostUtils = new class NodeHost implements IHostUtils {
|
||||
_serviceBrand: undefined;
|
||||
exit(code: number) { nativeExit(code); }
|
||||
exists(path: string) { return exists(path); }
|
||||
realpath(path: string) { return realpath(path); }
|
||||
|
||||
@@ -413,7 +413,7 @@ class ExtensionManifestValidator extends ExtensionManifestHandler {
|
||||
|
||||
export class ExtensionScannerInput {
|
||||
|
||||
public mtime: number;
|
||||
public mtime: number | undefined;
|
||||
|
||||
constructor(
|
||||
public readonly ourVersion: string,
|
||||
@@ -613,4 +613,4 @@ export class ExtensionScanner {
|
||||
return resultArr;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
|
||||
suite('RPCProtocol', () => {
|
||||
|
||||
class MessagePassingProtocol implements IMessagePassingProtocol {
|
||||
private _pair: MessagePassingProtocol;
|
||||
private _pair?: MessagePassingProtocol;
|
||||
|
||||
private readonly _onMessage = new Emitter<VSBuffer>();
|
||||
public readonly onMessage: Event<VSBuffer> = this._onMessage.event;
|
||||
@@ -25,7 +25,7 @@ suite('RPCProtocol', () => {
|
||||
|
||||
public send(buffer: VSBuffer): void {
|
||||
process.nextTick(() => {
|
||||
this._pair._onMessage.fire(buffer);
|
||||
this._pair!._onMessage.fire(buffer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user