mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 17:23:15 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -21,12 +21,28 @@ import { IInitData, IEnvironment, IWorkspaceData, MainContext } from 'vs/workben
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import * as watchdog from 'native-watchdog';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { ExtensionActivatedByEvent } from 'vs/workbench/api/node/extHostExtensionActivator';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { createLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
// const nativeExit = process.exit.bind(process);
|
||||
process.exit = function () {
|
||||
const err = new Error('An extension called process.exit() and this was prevented.');
|
||||
console.warn(err.stack);
|
||||
};
|
||||
function patchProcess(allowExit: boolean) {
|
||||
process.exit = function (code) {
|
||||
if (allowExit) {
|
||||
exit(code);
|
||||
} else {
|
||||
const err = new Error('An extension called process.exit() and this was prevented.');
|
||||
console.warn(err.stack);
|
||||
}
|
||||
};
|
||||
|
||||
process.crash = function () {
|
||||
const err = new Error('An extension called process.crash() and this was prevented.');
|
||||
console.warn(err.stack);
|
||||
};
|
||||
}
|
||||
export function exit(code?: number) {
|
||||
//nativeExit(code);
|
||||
|
||||
@@ -61,16 +77,28 @@ export class ExtensionHostMain {
|
||||
private _environment: IEnvironment;
|
||||
private _extensionService: ExtHostExtensionService;
|
||||
private _extHostConfiguration: ExtHostConfiguration;
|
||||
private _logService: ILogService;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(rpcProtocol: RPCProtocol, initData: IInitData) {
|
||||
this._environment = initData.environment;
|
||||
this._workspace = initData.workspace;
|
||||
|
||||
const allowExit = !!this._environment.extensionTestsPath; // to support other test frameworks like Jasmin that use process.exit (https://github.com/Microsoft/vscode/issues/37708)
|
||||
patchProcess(allowExit);
|
||||
|
||||
// services
|
||||
const threadService = new ExtHostThreadService(rpcProtocol);
|
||||
const extHostWorkspace = new ExtHostWorkspace(threadService, initData.workspace);
|
||||
const environmentService = new EnvironmentService(initData.args, initData.execPath);
|
||||
this._logService = createLogService(`exthost${initData.windowId}`, environmentService);
|
||||
this.disposables.push(this._logService);
|
||||
|
||||
this._logService.info('extension host started');
|
||||
this._logService.trace('initData', initData);
|
||||
|
||||
this._extHostConfiguration = new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration);
|
||||
this._extensionService = new ExtHostExtensionService(initData, threadService, extHostWorkspace, this._extHostConfiguration);
|
||||
this._extensionService = new ExtHostExtensionService(initData, threadService, extHostWorkspace, this._extHostConfiguration, this._logService);
|
||||
|
||||
// error forwarding and stack trace scanning
|
||||
const extensionErrors = new WeakMap<Error, IExtensionDescription>();
|
||||
@@ -91,11 +119,16 @@ export class ExtensionHostMain {
|
||||
return `${error.name || 'Error'}: ${error.message || ''}${stackTraceMessage}`;
|
||||
};
|
||||
});
|
||||
const mainThreadExtensions = threadService.get(MainContext.MainThreadExtensionService);
|
||||
const mainThreadErrors = threadService.get(MainContext.MainThreadErrors);
|
||||
errors.setUnexpectedErrorHandler(err => {
|
||||
const data = errors.transformErrorForSerialization(err);
|
||||
const extension = extensionErrors.get(err);
|
||||
mainThreadErrors.$onUnexpectedError(data, extension && extension.id);
|
||||
if (extension) {
|
||||
mainThreadExtensions.$onExtensionRuntimeError(extension.id, data);
|
||||
} else {
|
||||
mainThreadErrors.$onUnexpectedError(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Configure the watchdog to kill our process if the JS event loop is unresponsive for more than 10s
|
||||
@@ -107,7 +140,10 @@ export class ExtensionHostMain {
|
||||
public start(): TPromise<void> {
|
||||
return this._extensionService.onExtensionAPIReady()
|
||||
.then(() => this.handleEagerExtensions())
|
||||
.then(() => this.handleExtensionTests());
|
||||
.then(() => this.handleExtensionTests())
|
||||
.then(() => {
|
||||
this._logService.info(`eager extensions activated`);
|
||||
});
|
||||
}
|
||||
|
||||
public terminate(): void {
|
||||
@@ -117,6 +153,8 @@ export class ExtensionHostMain {
|
||||
}
|
||||
this._isTerminating = true;
|
||||
|
||||
this.disposables = dispose(this.disposables);
|
||||
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
// TODO: write to log once we have one
|
||||
});
|
||||
@@ -199,7 +237,7 @@ export class ExtensionHostMain {
|
||||
if (await pfs.exists(join(uri.fsPath, fileName))) {
|
||||
// the file was found
|
||||
return (
|
||||
this._extensionService.activateById(extensionId, true)
|
||||
this._extensionService.activateById(extensionId, new ExtensionActivatedByEvent(true, `workspaceContains:${fileName}`))
|
||||
.done(null, err => console.error(err))
|
||||
);
|
||||
}
|
||||
@@ -241,7 +279,7 @@ export class ExtensionHostMain {
|
||||
if (result.limitHit) {
|
||||
// a file was found matching one of the glob patterns
|
||||
return (
|
||||
this._extensionService.activateById(extensionId, true)
|
||||
this._extensionService.activateById(extensionId, new ExtensionActivatedByEvent(true, `workspaceContains:${globPatterns.join(',')}`))
|
||||
.done(null, err => console.error(err))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ function connectToRenderer(protocol: IMessagePassingProtocol): TPromise<IRendere
|
||||
});
|
||||
}
|
||||
|
||||
patchExecArgv();
|
||||
|
||||
createExtHostProtocol().then(protocol => {
|
||||
// connect to main side
|
||||
return connectToRenderer(protocol);
|
||||
@@ -129,3 +131,18 @@ createExtHostProtocol().then(protocol => {
|
||||
onTerminate = () => extensionHostMain.terminate();
|
||||
return extensionHostMain.start();
|
||||
}).done(null, err => console.error(err));
|
||||
|
||||
|
||||
|
||||
function patchExecArgv() {
|
||||
// when encountering the prevent-inspect flag we delete this
|
||||
// and the prior flag
|
||||
if (process.env.VSCODE_PREVENT_FOREIGN_INSPECT) {
|
||||
for (let i = 0; i < process.execArgv.length; i++) {
|
||||
if (process.execArgv[i].match(/--inspect-brk=\d+|--inspect=\d+/)) {
|
||||
process.execArgv.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user