mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 09:35:38 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -18,6 +18,8 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { IProcessEnvironment } from 'vs/base/common/platform';
|
||||
import { env as processEnv } from 'vs/base/common/process';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
/**
|
||||
* This interface represents a single command line argument split into a "prefix" and a "path" half.
|
||||
@@ -37,7 +39,7 @@ interface ILaunchVSCodeArguments {
|
||||
/**
|
||||
* Encapsulates the DebugAdapter lifecycle and some idiosyncrasies of the Debug Adapter Protocol.
|
||||
*/
|
||||
export class RawDebugSession {
|
||||
export class RawDebugSession implements IDisposable {
|
||||
|
||||
private allThreadsContinued = true;
|
||||
private _readyForBreakpoints = false;
|
||||
@@ -70,6 +72,8 @@ export class RawDebugSession {
|
||||
private readonly _onDidExitAdapter: Emitter<AdapterEndEvent>;
|
||||
private debugAdapter: IDebugAdapter | null;
|
||||
|
||||
private toDispose: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
debugAdapter: IDebugAdapter,
|
||||
dbgr: IDebugger,
|
||||
@@ -96,18 +100,18 @@ export class RawDebugSession {
|
||||
|
||||
this._onDidExitAdapter = new Emitter<AdapterEndEvent>();
|
||||
|
||||
this.debugAdapter.onError(err => {
|
||||
this.toDispose.push(this.debugAdapter.onError(err => {
|
||||
this.shutdown(err);
|
||||
});
|
||||
}));
|
||||
|
||||
this.debugAdapter.onExit(code => {
|
||||
this.toDispose.push(this.debugAdapter.onExit(code => {
|
||||
if (code !== 0) {
|
||||
this.shutdown(new Error(`exit code: ${code}`));
|
||||
} else {
|
||||
// normal exit
|
||||
this.shutdown();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
this.debugAdapter.onEvent(event => {
|
||||
switch (event.event) {
|
||||
@@ -341,9 +345,9 @@ export class RawDebugSession {
|
||||
return Promise.reject(new Error('restartFrame not supported'));
|
||||
}
|
||||
|
||||
completions(args: DebugProtocol.CompletionsArguments): Promise<DebugProtocol.CompletionsResponse> {
|
||||
completions(args: DebugProtocol.CompletionsArguments, token: CancellationToken): Promise<DebugProtocol.CompletionsResponse> {
|
||||
if (this.capabilities.supportsCompletionsRequest) {
|
||||
return this.send<DebugProtocol.CompletionsResponse>('completions', args);
|
||||
return this.send<DebugProtocol.CompletionsResponse>('completions', args, token);
|
||||
}
|
||||
return Promise.reject(new Error('completions not supported'));
|
||||
}
|
||||
@@ -384,8 +388,8 @@ export class RawDebugSession {
|
||||
return Promise.reject(new Error('configurationDone not supported'));
|
||||
}
|
||||
|
||||
stackTrace(args: DebugProtocol.StackTraceArguments): Promise<DebugProtocol.StackTraceResponse> {
|
||||
return this.send<DebugProtocol.StackTraceResponse>('stackTrace', args);
|
||||
stackTrace(args: DebugProtocol.StackTraceArguments, token: CancellationToken): Promise<DebugProtocol.StackTraceResponse> {
|
||||
return this.send<DebugProtocol.StackTraceResponse>('stackTrace', args, token);
|
||||
}
|
||||
|
||||
exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): Promise<DebugProtocol.ExceptionInfoResponse> {
|
||||
@@ -395,12 +399,12 @@ export class RawDebugSession {
|
||||
return Promise.reject(new Error('exceptionInfo not supported'));
|
||||
}
|
||||
|
||||
scopes(args: DebugProtocol.ScopesArguments): Promise<DebugProtocol.ScopesResponse> {
|
||||
return this.send<DebugProtocol.ScopesResponse>('scopes', args);
|
||||
scopes(args: DebugProtocol.ScopesArguments, token: CancellationToken): Promise<DebugProtocol.ScopesResponse> {
|
||||
return this.send<DebugProtocol.ScopesResponse>('scopes', args, token);
|
||||
}
|
||||
|
||||
variables(args: DebugProtocol.VariablesArguments): Promise<DebugProtocol.VariablesResponse> {
|
||||
return this.send<DebugProtocol.VariablesResponse>('variables', args);
|
||||
variables(args: DebugProtocol.VariablesArguments, token?: CancellationToken): Promise<DebugProtocol.VariablesResponse> {
|
||||
return this.send<DebugProtocol.VariablesResponse>('variables', args, token);
|
||||
}
|
||||
|
||||
source(args: DebugProtocol.SourceArguments): Promise<DebugProtocol.SourceResponse> {
|
||||
@@ -463,18 +467,21 @@ export class RawDebugSession {
|
||||
return Promise.reject(new Error('goto is not supported'));
|
||||
}
|
||||
|
||||
cancel(args: DebugProtocol.CancelArguments): Promise<DebugProtocol.CancelResponse> {
|
||||
return this.send('cancel', args);
|
||||
}
|
||||
|
||||
custom(request: string, args: any): Promise<DebugProtocol.Response> {
|
||||
return this.send(request, args);
|
||||
}
|
||||
|
||||
//---- private
|
||||
|
||||
|
||||
private shutdown(error?: Error, restart = false): Promise<any> {
|
||||
if (!this.inShutdown) {
|
||||
this.inShutdown = true;
|
||||
if (this.debugAdapter) {
|
||||
return this.send('disconnect', { restart }, 500).then(() => {
|
||||
return this.send('disconnect', { restart }, undefined, 500).then(() => {
|
||||
this.stopAdapter(error);
|
||||
}, () => {
|
||||
// ignore error
|
||||
@@ -583,15 +590,17 @@ export class RawDebugSession {
|
||||
|
||||
const v = args[key];
|
||||
if (v) {
|
||||
if (Array.isArray(v)) {
|
||||
v.push(value);
|
||||
} else {
|
||||
args[key] = [v, value];
|
||||
}
|
||||
v.push(value);
|
||||
} else {
|
||||
args[key] = value;
|
||||
args[key] = [value];
|
||||
}
|
||||
} else if (key === 'extensionDevelopmentPath') {
|
||||
const v = args[key];
|
||||
if (v) {
|
||||
v.push(value);
|
||||
} else {
|
||||
args[key] = [value];
|
||||
}
|
||||
|
||||
} else {
|
||||
(<any>args)[key] = value;
|
||||
}
|
||||
@@ -619,20 +628,34 @@ export class RawDebugSession {
|
||||
return this.windowsService.openExtensionDevelopmentHostWindow(args, env);
|
||||
}
|
||||
|
||||
private send<R extends DebugProtocol.Response>(command: string, args: any, timeout?: number): Promise<R> {
|
||||
private send<R extends DebugProtocol.Response>(command: string, args: any, token?: CancellationToken, timeout?: number): Promise<R> {
|
||||
return new Promise<R>((completeDispatch, errorDispatch) => {
|
||||
if (!this.debugAdapter) {
|
||||
errorDispatch(new Error('no debug adapter found'));
|
||||
return;
|
||||
}
|
||||
this.debugAdapter.sendRequest(command, args, (response: R) => {
|
||||
let cancelationListener: IDisposable;
|
||||
const requestId = this.debugAdapter.sendRequest(command, args, (response: R) => {
|
||||
if (cancelationListener) {
|
||||
cancelationListener.dispose();
|
||||
}
|
||||
|
||||
if (response.success) {
|
||||
completeDispatch(response);
|
||||
} else {
|
||||
errorDispatch(response);
|
||||
}
|
||||
}, timeout);
|
||||
}).then(response => response, err => Promise.reject(this.handleErrorResponse(err)));
|
||||
|
||||
if (token) {
|
||||
cancelationListener = token.onCancellationRequested(() => {
|
||||
cancelationListener.dispose();
|
||||
if (this.capabilities.supportsCancelRequest) {
|
||||
this.cancel({ requestId });
|
||||
}
|
||||
});
|
||||
}
|
||||
}).then(undefined, err => Promise.reject(this.handleErrorResponse(err)));
|
||||
}
|
||||
|
||||
private handleErrorResponse(errorResponse: DebugProtocol.Response): Error {
|
||||
@@ -696,4 +719,8 @@ export class RawDebugSession {
|
||||
this.customTelemetryService.publicLog('debugProtocolErrorResponse', { error: telemetryMessage });
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
dispose(this.toDispose);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user