Skip to content

Commit e341b9c

Browse files
committed
Tons of lint errors from change in TSC version and Language server. No meaningful changes
1 parent 9da528b commit e341b9c

File tree

6 files changed

+259
-212
lines changed

6 files changed

+259
-212
lines changed

src/backend/mi2/mi2.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { IBackend, Stack, Variable, VariableObject, MIError,
2-
OurInstructionBreakpoint, OurDataBreakpoint, OurSourceBreakpoint } from '../backend';
1+
import {
2+
IBackend, Stack, Variable, VariableObject, MIError,
3+
OurInstructionBreakpoint, OurDataBreakpoint, OurSourceBreakpoint
4+
} from '../backend';
35
import * as ChildProcess from 'child_process';
46
import { EventEmitter } from 'events';
57
import { parseMI, MINode } from '../mi_parse';
@@ -46,7 +48,7 @@ function couldBeOutput(line: string) {
4648
const trace = false;
4749

4850
export class MI2 extends EventEmitter implements IBackend {
49-
public debugOutput: ADAPTER_DEBUG_MODE;
51+
public debugOutput: ADAPTER_DEBUG_MODE = ADAPTER_DEBUG_MODE.NONE;
5052
public interruptMode: GDBInterruptMode = GDBInterruptMode.EXEC_INTERRUPT;
5153
public procEnv: any;
5254
protected currentToken: number = 1;
@@ -441,7 +443,7 @@ export class MI2 extends EventEmitter implements IBackend {
441443
// program is in paused state
442444
try {
443445
startKillTimeout(500);
444-
await new Promise(() => setTimeout(() => {}, 50)); // For some people delay was needed. Doesn't hurt I guess
446+
await new Promise(() => setTimeout(() => { }, 50)); // For some people delay was needed. Doesn't hurt I guess
445447
if (!this.exited) {
446448
await this.sendCommand('target-disconnect'); // Yes, this can fail
447449
}
@@ -763,7 +765,7 @@ export class MI2 extends EventEmitter implements IBackend {
763765
},
764766
(reason) => {
765767
// Just delete the breakpoint we just created as the condition creation failed
766-
this.sendCommand(`break-delete ${bkptNum}`).then((x) => {}, (e) => {});
768+
this.sendCommand(`break-delete ${bkptNum}`).then((x) => { }, (e) => { });
767769
reject(reason); // Use this reason as reason for failing to create the breakpoint
768770
});
769771
} else {
@@ -970,29 +972,29 @@ export class MI2 extends EventEmitter implements IBackend {
970972
return omg;
971973
}
972974

973-
public static getThreadFrameStr(threadId: number, frameId: number): string {
975+
public static getThreadFrameStr(threadId: number | undefined, frameId: number | undefined): string {
974976
const th = ((threadId !== undefined) && (threadId > 0)) ? `--thread ${threadId} ` : '';
975977
const fr = ((frameId !== undefined) && (frameId >= 0)) ? `--frame ${frameId}` : '';
976978
return th + fr;
977979
}
978980

979981
// Pass negative threadId/frameId to specify no context or current context
980-
public async varUpdate(name: string = '*', threadId: number, frameId: number): Promise<MINode> {
982+
public async varUpdate(name: string = '*', threadId: number | undefined, frameId: number | undefined): Promise<MINode> {
981983
if (trace) {
982984
this.log('stderr', 'varUpdate');
983985
}
984986
return this.sendCommand(`var-update ${MI2.getThreadFrameStr(threadId, frameId)} --all-values ${name}`);
985987
}
986988

987989
// Pass negative threadId/frameId to specify no context or current context
988-
public async varAssign(name: string, rawValue: string, threadId: number, frameId: number): Promise<MINode> {
990+
public async varAssign(name: string, rawValue: string, threadId: number | undefined, frameId: number | undefined): Promise<MINode> {
989991
if (trace) {
990992
this.log('stderr', 'varAssign');
991993
}
992994
return this.sendCommand(`var-assign ${MI2.getThreadFrameStr(threadId, frameId)} ${name} ${rawValue}`);
993995
}
994996

995-
public async exprAssign(expr: string, rawValue: string, threadId: number, frameId: number): Promise<MINode> {
997+
public async exprAssign(expr: string, rawValue: string, threadId: number | undefined, frameId: number | undefined): Promise<MINode> {
996998
if (trace) {
997999
this.log('stderr', 'exprAssign');
9981000
}

src/backend/server.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { greenFormat } from '../frontend/ansi-helpers';
1010

1111
export let GdbPid = -1;
1212

13-
let ServerLogFilePath: string = null;
13+
let ServerLogFilePath: string | null = null;
1414
export function getServerLogFilePath(): string {
1515
if (!ServerLogFilePath) {
1616
const tmpDirName = os.tmpdir();
@@ -39,19 +39,19 @@ export function ServerConsoleLog(str: string, usePid?: number) {
3939

4040
let currentServers: GDBServer[] = [];
4141
export class GDBServer extends EventEmitter {
42-
private process: ChildProcess.ChildProcess;
42+
private process: ChildProcess.ChildProcess | null = null;
4343
private outBuffer: string = '';
4444
private errBuffer: string = '';
45-
protected consoleSocket: net.Socket = null;
46-
private initResolve: (result: boolean) => void;
47-
private initReject: (error: any) => void;
45+
protected consoleSocket: net.Socket | null = null;
46+
private initResolve: ((result: boolean) => void) | null = null;
47+
private initReject: ((error: any) => void) | null = null;
4848
public static readonly SERVER_TIMEOUT = 10 * 60 * 1000;
4949
public static readonly LOCALHOST = '0.0.0.0';
50-
public pid: number = -1;
50+
public pid: number | undefined = -1;
5151

5252
constructor(
53-
private cwd: string, private application: string, private args: string[],
54-
private initMatch: RegExp, private port: number | undefined, private consolePort: number) {
53+
private cwd: string | null, private application: string | null, private args: string[],
54+
private initMatch: RegExp | null, private port: number | undefined, private consolePort: number) {
5555
super();
5656
}
5757

@@ -66,11 +66,13 @@ export class GDBServer extends EventEmitter {
6666
ServerConsoleLog('GDBServer: Could not connect to console: ' + e);
6767
reject(e);
6868
}
69-
this.process = ChildProcess.spawn(this.application, this.args, { cwd: this.cwd });
69+
this.process = ChildProcess.spawn(this.application, this.args, { cwd: this.cwd || undefined });
7070
currentServers.push(this);
7171
this.pid = this.process.pid;
72-
this.process.stdout.on('data', this.onStdout.bind(this));
73-
this.process.stderr.on('data', this.onStderr.bind(this));
72+
if (this.process.stdout && this.process.stderr) {
73+
this.process.stdout.on('data', this.onStdout.bind(this));
74+
this.process.stderr.on('data', this.onStderr.bind(this));
75+
}
7476
this.process.on('exit', this.onExit.bind(this));
7577
this.process.on('error', this.onError.bind(this));
7678

@@ -109,7 +111,7 @@ export class GDBServer extends EventEmitter {
109111
return !!this.process;
110112
}
111113

112-
private exitTimeout: NodeJS.Timeout = null;
114+
private exitTimeout: NodeJS.Timeout | null = null;
113115
private killInProgress = false;
114116
public exit(): void {
115117
if (this.process && !this.killInProgress) {
@@ -123,7 +125,7 @@ export class GDBServer extends EventEmitter {
123125
}
124126
}
125127

126-
private onExit(code, signal) {
128+
private onExit(code: any, signal: any) {
127129
if (this.exitTimeout) {
128130
clearTimeout(this.exitTimeout);
129131
this.exitTimeout = null;
@@ -138,7 +140,7 @@ export class GDBServer extends EventEmitter {
138140
}, 10);
139141
}
140142

141-
private onError(err) {
143+
private onError(err: any) {
142144
if (this.initReject) {
143145
this.initReject(err);
144146
this.initReject = null;
@@ -148,7 +150,7 @@ export class GDBServer extends EventEmitter {
148150
this.emit('launcherror', err);
149151
}
150152

151-
private onStdout(data) {
153+
private onStdout(data: any) {
152154
this.sendToConsole(data); // Send it without any processing or buffering
153155
if (this.initResolve) {
154156
if (typeof data === 'string') {
@@ -172,7 +174,7 @@ export class GDBServer extends EventEmitter {
172174
}
173175
}
174176

175-
private onStderr(data) {
177+
private onStderr(data: any) {
176178
this.sendToConsole(data); // Send it without any processing or buffering
177179
if (this.initResolve) {
178180
if (typeof data === 'string') {
@@ -201,7 +203,9 @@ export class GDBServer extends EventEmitter {
201203
const socket = new net.Socket();
202204
socket.on('data', (data) => {
203205
try {
204-
this.process.stdin.write(data, 'utf8');
206+
if (this.process && this.process.stdin) {
207+
this.process.stdin.write(data, 'utf8');
208+
}
205209
} catch (e) {
206210
console.error(`stdin write failed ${e}`);
207211
}
@@ -227,7 +231,8 @@ export class GDBServer extends EventEmitter {
227231

228232
// It is possible that the server is not ready
229233
socket.connect(this.consolePort, '127.0.0.1', () => {
230-
socket.write(greenFormat(quoteShellCmdLine([this.application, ...this.args]) + '\n'));
234+
const app = this.application || '';
235+
socket.write(greenFormat(quoteShellCmdLine([app, ...this.args]) + '\n'));
231236
this.consoleSocket = socket;
232237
resolve();
233238
});
@@ -260,7 +265,7 @@ export class GDBServer extends EventEmitter {
260265
// are in server mode (as in when in debug) it does not do that because we are always running.
261266
//
262267
// See GDBDebugSession.disconnectRequest()
263-
process.on('exit', (code, signal) => {
268+
process.on('exit', (code: any, signal: any) => {
264269
if (currentServers.length > 0) {
265270
ServerConsoleLog(`Debug Adapter crashed or killed by VSCode? code=${code} signal=${signal}`);
266271
for (const p of [...currentServers]) {

0 commit comments

Comments
 (0)