提交 cc80ec81 编写于 作者: I isidor

debug: minor polish

上级 be0c72b9
......@@ -63,27 +63,27 @@ export class Source {
}
}
public get name() {
get name() {
return this.raw.name || resources.basenameOrAuthority(this.uri);
}
public get origin() {
get origin() {
return this.raw.origin;
}
public get presentationHint() {
get presentationHint() {
return this.raw.presentationHint;
}
public get reference() {
get reference() {
return this.raw.sourceReference;
}
public get inMemory() {
get inMemory() {
return this.uri.scheme === DEBUG_SCHEME;
}
public openInEditor(editorService: IEditorService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Thenable<any> {
openInEditor(editorService: IEditorService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Thenable<any> {
return !this.available ? Promise.resolve(null) : editorService.openEditor({
resource: this.uri,
description: this.origin,
......@@ -97,7 +97,7 @@ export class Source {
}, sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
}
public static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId: string, sourceReference: number } {
static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId: string, sourceReference: number } {
let path: string;
let sourceReference: number;
let sessionId: string;
......
......@@ -18,17 +18,17 @@ export class ReplModel {
constructor(private session: IDebugSession) { }
public getReplElements(): ReadonlyArray<IReplElement> {
getReplElements(): ReadonlyArray<IReplElement> {
return this.replElements;
}
public addReplExpression(stackFrame: IStackFrame, name: string): Promise<void> {
addReplExpression(stackFrame: IStackFrame, name: string): Promise<void> {
const expression = new Expression(name);
this.addReplElements([expression]);
return expression.evaluate(this.session, stackFrame, 'repl');
}
public appendToRepl(data: string | IExpression, sev: severity, source?: IReplElementSource): void {
appendToRepl(data: string | IExpression, sev: severity, source?: IReplElementSource): void {
const clearAnsiSequence = '\u001b[2J';
if (typeof data === 'string' && data.indexOf(clearAnsiSequence) >= 0) {
// [2J is the ansi escape sequence for clearing the display http://ascii-table.com/ansi-escape-sequences.php
......@@ -63,7 +63,7 @@ export class ReplModel {
}
}
public logToRepl(sev: severity, args: any[], frame?: { uri: URI, line: number, column: number }) {
logToRepl(sev: severity, args: any[], frame?: { uri: URI, line: number, column: number }) {
let source: IReplElementSource;
if (frame) {
......@@ -141,5 +141,4 @@ export class ReplModel {
this.replElements = [];
}
}
}
......@@ -44,41 +44,38 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
abstract startSession(): Promise<void>;
abstract stopSession(): Promise<void>;
public dispose(): void {
}
abstract sendMessage(message: DebugProtocol.ProtocolMessage): void;
public get onError(): Event<Error> {
get onError(): Event<Error> {
return this._onError.event;
}
public get onExit(): Event<number> {
get onExit(): Event<number> {
return this._onExit.event;
}
public onMessage(callback: (message: DebugProtocol.ProtocolMessage) => void): void {
onMessage(callback: (message: DebugProtocol.ProtocolMessage) => void): void {
if (this.eventCallback) {
this._onError.fire(new Error(`attempt to set more than one 'Message' callback`));
}
this.messageCallback = callback;
}
public onEvent(callback: (event: DebugProtocol.Event) => void): void {
onEvent(callback: (event: DebugProtocol.Event) => void): void {
if (this.eventCallback) {
this._onError.fire(new Error(`attempt to set more than one 'Event' callback`));
}
this.eventCallback = callback;
}
public onRequest(callback: (request: DebugProtocol.Request) => void): void {
onRequest(callback: (request: DebugProtocol.Request) => void): void {
if (this.requestCallback) {
this._onError.fire(new Error(`attempt to set more than one 'Request' callback`));
}
this.requestCallback = callback;
}
public sendResponse(response: DebugProtocol.Response): void {
sendResponse(response: DebugProtocol.Response): void {
if (response.seq > 0) {
this._onError.fire(new Error(`attempt to send more than one response for command ${response.command}`));
} else {
......@@ -86,7 +83,7 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
}
}
public sendRequest(command: string, args: any, clb: (result: DebugProtocol.Response) => void, timeout?: number): void {
sendRequest(command: string, args: any, clb: (result: DebugProtocol.Response) => void, timeout?: number): void {
const request: any = {
command: command
......@@ -122,7 +119,7 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
}
}
public acceptMessage(message: DebugProtocol.ProtocolMessage): void {
acceptMessage(message: DebugProtocol.ProtocolMessage): void {
if (this.messageCallback) {
this.messageCallback(message);
} else {
......@@ -174,6 +171,10 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
});
}, 1000);
}
dispose(): void {
this.cancelPending();
}
}
/**
......@@ -202,7 +203,7 @@ export abstract class StreamDebugAdapter extends AbstractDebugAdapter {
readable.on('data', (data: Buffer) => this.handleData(data));
}
public sendMessage(message: DebugProtocol.ProtocolMessage): void {
sendMessage(message: DebugProtocol.ProtocolMessage): void {
if (this.outputStream) {
const json = JSON.stringify(message);
......@@ -473,7 +474,7 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter {
return result;
}
public static platformAdapterExecutable(extensionDescriptions: IExtensionDescription[], debugType: string): IDebugAdapterExecutable {
static platformAdapterExecutable(extensionDescriptions: IExtensionDescription[], debugType: string): IDebugAdapterExecutable {
const result: IDebuggerContribution = Object.create(null);
debugType = debugType.toLowerCase();
......
......@@ -41,7 +41,7 @@ export class Debugger implements IDebugger {
}
public createDebugAdapter(session: IDebugSession, root: IWorkspaceFolder, config: IConfig, outputService: IOutputService): Promise<IDebugAdapter> {
createDebugAdapter(session: IDebugSession, root: IWorkspaceFolder, config: IConfig, outputService: IOutputService): Promise<IDebugAdapter> {
if (this.inExtHost()) {
return Promise.resolve(this.configurationManager.createDebugAdapter(session, root, config));
} else {
......@@ -92,7 +92,7 @@ export class Debugger implements IDebugger {
});
}
public substituteVariables(folder: IWorkspaceFolder, config: IConfig): Thenable<IConfig> {
substituteVariables(folder: IWorkspaceFolder, config: IConfig): Thenable<IConfig> {
if (this.inExtHost()) {
return this.configurationManager.substituteVariables(this.type, folder, config).then(config => {
return this.configurationResolverService.resolveWithCommands(folder, config, this.variables);
......@@ -102,7 +102,7 @@ export class Debugger implements IDebugger {
}
}
public runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments): Promise<void> {
runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments): Promise<void> {
const config = this.configurationService.getValue<ITerminalSettings>('terminal');
return this.configurationManager.runInTerminal(this.inExtHost() ? this.type : '*', args, config);
}
......@@ -112,27 +112,27 @@ export class Debugger implements IDebugger {
return debugConfigs.extensionHostDebugAdapter || this.configurationManager.needsToRunInExtHost(this.type) || this.extensionDescription.extensionLocation.scheme !== 'file';
}
public get label(): string {
get label(): string {
return this.debuggerContribution.label || this.debuggerContribution.type;
}
public get type(): string {
get type(): string {
return this.debuggerContribution.type;
}
public get variables(): { [key: string]: string } {
get variables(): { [key: string]: string } {
return this.debuggerContribution.variables;
}
public get configurationSnippets(): IJSONSchemaSnippet[] {
get configurationSnippets(): IJSONSchemaSnippet[] {
return this.debuggerContribution.configurationSnippets;
}
public get languages(): string[] {
get languages(): string[] {
return this.debuggerContribution.languages;
}
public merge(secondRawAdapter: IDebuggerContribution, extensionDescription: IExtensionDescription): void {
merge(secondRawAdapter: IDebuggerContribution, extensionDescription: IExtensionDescription): void {
// remember all ext descriptions that are the source of this debugger
this.mergedExtensionDescriptions.push(extensionDescription);
......@@ -144,15 +144,15 @@ export class Debugger implements IDebugger {
objects.mixin(this.debuggerContribution, secondRawAdapter, extensionDescription.isBuiltin);
}
public hasInitialConfiguration(): boolean {
hasInitialConfiguration(): boolean {
return !!this.debuggerContribution.initialConfigurations;
}
public hasConfigurationProvider() {
hasConfigurationProvider(): boolean {
return this.configurationManager.hasDebugConfigurationProvider(this.type);
}
public getInitialConfigurationContent(initialConfigs?: IConfig[]): Promise<string> {
getInitialConfigurationContent(initialConfigs?: IConfig[]): Promise<string> {
// at this point we got some configs from the package.json and/or from registered DebugConfigurationProviders
let initialConfigurations = this.debuggerContribution.initialConfigurations || [];
if (initialConfigs) {
......@@ -185,7 +185,7 @@ export class Debugger implements IDebugger {
}
@memoize
public getCustomTelemetryService(): Thenable<TelemetryService> {
getCustomTelemetryService(): Thenable<TelemetryService> {
if (!this.debuggerContribution.aiKey) {
return Promise.resolve(undefined);
}
......@@ -217,7 +217,7 @@ export class Debugger implements IDebugger {
});
}
public getSchemaAttributes(): IJSONSchema[] {
getSchemaAttributes(): IJSONSchema[] {
if (!this.debuggerContribution.configurationAttributes) {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册