Skip to content

Commit daadc3a

Browse files
oltolmWebFreak001
authored andcommitted
small cleanup
1 parent be19c27 commit daadc3a

3 files changed

Lines changed: 28 additions & 32 deletions

File tree

src/backend/backend.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,29 +141,25 @@ export interface MIError extends Error {
141141
readonly source: string;
142142
}
143143
export interface MIErrorConstructor {
144-
new (message: string, source: string): MIError;
144+
new(message: string, source: string): MIError;
145145
readonly prototype: MIError;
146146
}
147147

148-
export const MIError: MIErrorConstructor = <any> class MIError {
149-
readonly name: string;
150-
readonly message: string;
151-
readonly source: string;
148+
export const MIError: MIErrorConstructor = class MIError {
149+
private readonly _message: string;
150+
private readonly _source: string;
152151
public constructor(message: string, source: string) {
153-
Object.defineProperty(this, 'name', {
154-
get: () => (this.constructor as any).name,
155-
});
156-
Object.defineProperty(this, 'message', {
157-
get: () => message,
158-
});
159-
Object.defineProperty(this, 'source', {
160-
get: () => source,
161-
});
152+
this._message = message;
153+
this._source = source;
162154
Error.captureStackTrace(this, this.constructor);
163155
}
164156

157+
get name() { return this.constructor.name; }
158+
get message() { return this._message; }
159+
get source() { return this._source; }
160+
165161
public toString() {
166-
return `${this.message} (from ${this.source})`;
162+
return `${this.message} (from ${this._source})`;
167163
}
168164
};
169165
Object.setPrototypeOf(MIError as any, Object.create(Error.prototype));

src/backend/mi2/mi2.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,23 @@ export class MI2 extends EventEmitter implements IBackend {
314314
}
315315
}
316316

317-
onOutputStderr(lines) {
318-
lines = <string[]> lines.split('\n');
317+
onOutputStderr(str: string) {
318+
let lines = str.split('\n');
319319
lines.forEach(line => {
320320
this.log("stderr", line);
321321
});
322322
}
323323

324-
onOutputPartial(line) {
324+
onOutputPartial(line: string) {
325325
if (couldBeOutput(line)) {
326326
this.logNoNewLine("stdout", line);
327327
return true;
328328
}
329329
return false;
330330
}
331331

332-
onOutput(lines) {
333-
lines = <string[]> lines.split('\n');
332+
onOutput(str: string) {
333+
let lines = str.split('\n');
334334
lines.forEach(line => {
335335
if (couldBeOutput(line)) {
336336
if (!gdbMatch.exec(line))
@@ -391,13 +391,13 @@ export class MI2 extends EventEmitter implements IBackend {
391391
case "solib-event":
392392
case "syscall-entry":
393393
case "syscall-return":
394-
// TODO: inform the user
394+
// TODO: inform the user
395395
this.emit("step-end", parsed);
396396
break;
397397
case "fork":
398398
case "vfork":
399399
case "exec":
400-
// TODO: inform the user, possibly add second inferior
400+
// TODO: inform the user, possibly add second inferior
401401
this.emit("step-end", parsed);
402402
break;
403403
case "signal-received":
@@ -410,10 +410,10 @@ export class MI2 extends EventEmitter implements IBackend {
410410
this.log("stderr", "Program exited with code " + parsed.record("exit-code"));
411411
this.emit("exited-normally", parsed);
412412
break;
413-
// case "exited-signalled": // consider handling that explicit possible
414-
// this.log("stderr", "Program exited because of signal " + parsed.record("signal"));
415-
// this.emit("stopped", parsed);
416-
// break;
413+
// case "exited-signalled": // consider handling that explicit possible
414+
// this.log("stderr", "Program exited because of signal " + parsed.record("signal"));
415+
// this.emit("stopped", parsed);
416+
// break;
417417

418418
default:
419419
this.log("console", "Not implemented stop reason (assuming exception): " + reason);
@@ -570,7 +570,7 @@ export class MI2 extends EventEmitter implements IBackend {
570570
return Promise.all(promisses);
571571
}
572572

573-
setBreakPointCondition(bkptNum, condition): Thenable<any> {
573+
setBreakPointCondition(bkptNum: number, condition: string): Thenable<any> {
574574
if (trace)
575575
this.log("stderr", "setBreakPointCondition");
576576
return this.sendCommand("break-condition " + bkptNum + " " + condition);
@@ -802,7 +802,7 @@ export class MI2 extends EventEmitter implements IBackend {
802802
const ret: RegisterValue[] = nodes.map(node => {
803803
const index = parseInt(MINode.valueOf(node, "number"));
804804
const value = MINode.valueOf(node, "value");
805-
return {index: index, value: value};
805+
return { index: index, value: value };
806806
});
807807
return ret;
808808
}

src/backend/mi2/mi2lldb.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as ChildProcess from "child_process";
44
import * as path from "path";
55

66
export class MI2_LLDB extends MI2 {
7-
protected initCommands(target: string, cwd: string, attach: boolean = false) {
7+
protected override initCommands(target: string, cwd: string, attach: boolean = false) {
88
// We need to account for the possibility of the path type used by the debugger being different
99
// than the path type where the extension is running (e.g., SSH from Linux to Windows machine).
1010
// Since the CWD is expected to be an absolute path in the debugger's environment, we can test
@@ -35,7 +35,7 @@ export class MI2_LLDB extends MI2 {
3535
return cmds;
3636
}
3737

38-
attach(cwd: string, executable: string, target: string, autorun: string[]): Thenable<any> {
38+
override attach(cwd: string, executable: string, target: string, autorun: string[]): Thenable<any> {
3939
return new Promise((resolve, reject) => {
4040
const args = this.preargs.concat(this.extraargs || []);
4141
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
@@ -54,11 +54,11 @@ export class MI2_LLDB extends MI2 {
5454
});
5555
}
5656

57-
setBreakPointCondition(bkptNum, condition): Thenable<any> {
57+
override setBreakPointCondition(bkptNum: number, condition: string): Thenable<any> {
5858
return this.sendCommand("break-condition " + bkptNum + " \"" + escape(condition) + "\" 1");
5959
}
6060

61-
goto(filename: string, line: number): Thenable<Boolean> {
61+
override goto(filename: string, line: number): Thenable<Boolean> {
6262
return new Promise((resolve, reject) => {
6363
// LLDB parses the file differently than GDB...
6464
// GDB doesn't allow quoting only the file but only the whole argument

0 commit comments

Comments
 (0)