diff --git a/src/backend/backend.ts b/src/backend/backend.ts index 54d47cd..0f35d06 100644 --- a/src/backend/backend.ts +++ b/src/backend/backend.ts @@ -84,7 +84,7 @@ export class VariableObject { frozen: boolean; dynamic: boolean; displayhint: string; - has_more: boolean; + hasMore: boolean; id: number; constructor(node: any) { this.name = MINode.valueOf(node, "name"); @@ -97,7 +97,7 @@ export class VariableObject { this.dynamic = !!MINode.valueOf(node, "dynamic"); this.displayhint = MINode.valueOf(node, "displayhint"); // TODO: use has_more when it's > 0 - this.has_more = !!MINode.valueOf(node, "has_more"); + this.hasMore = !!MINode.valueOf(node, "has_more"); } public applyChanges(node: MINode) { @@ -107,7 +107,7 @@ export class VariableObject { } this.dynamic = !!MINode.valueOf(node, "dynamic"); this.displayhint = MINode.valueOf(node, "displayhint"); - this.has_more = !!MINode.valueOf(node, "has_more"); + this.hasMore = !!MINode.valueOf(node, "has_more"); } public isCompound(): boolean { @@ -133,13 +133,13 @@ export interface MIError extends Error { readonly name: string; readonly message: string; readonly source: string; -}; +} export interface MIErrorConstructor { new (message: string, source: string): MIError; readonly prototype: MIError; } -export const MIError: MIErrorConstructor = class MIError { +export const MIError: MIErrorConstructor = class MIError { readonly name: string; readonly message: string; readonly source: string; diff --git a/src/backend/gdb_expansion.ts b/src/backend/gdb_expansion.ts index ae48de4..143e6d5 100644 --- a/src/backend/gdb_expansion.ts +++ b/src/backend/gdb_expansion.ts @@ -1,4 +1,4 @@ -import { MINode } from "./mi_parse" +import { MINode } from "./mi_parse"; const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/; const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-]*/; @@ -75,8 +75,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin name = name.substr(1); } namespace = namespace + pointerCombineChar + name; - } - else + } else namespace = name; } } @@ -99,7 +98,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin value = value.substr(3).trim(); if (value[0] == '}') { value = value.substr(1).trim(); - return "<...>"; + return "<...>"; } } const eqPos = value.indexOf("="); @@ -151,45 +150,35 @@ export function expandValue(variableCreate: Function, value: string, root: strin else if (value.startsWith("true")) { primitive = "true"; value = value.substr(4).trim(); - } - else if (value.startsWith("false")) { + } else if (value.startsWith("false")) { primitive = "false"; value = value.substr(5).trim(); - } - else if (match = nullpointerRegex.exec(value)) { + } else if (match = nullpointerRegex.exec(value)) { primitive = ""; value = value.substr(match[0].length).trim(); - } - else if (match = referenceStringRegex.exec(value)) { + } else if (match = referenceStringRegex.exec(value)) { value = value.substr(match[1].length).trim(); primitive = parseCString(); - } - else if (match = referenceRegex.exec(value)) { + } else if (match = referenceRegex.exec(value)) { primitive = "*" + match[0]; value = value.substr(match[0].length).trim(); - } - else if (match = cppReferenceRegex.exec(value)) { + } else if (match = cppReferenceRegex.exec(value)) { primitive = match[0]; value = value.substr(match[0].length).trim(); - } - else if (match = charRegex.exec(value)) { + } else if (match = charRegex.exec(value)) { primitive = match[1]; value = value.substr(match[0].length - 1); primitive += " " + parseCString(); - } - else if (match = numberRegex.exec(value)) { + } else if (match = numberRegex.exec(value)) { primitive = match[0]; value = value.substr(match[0].length).trim(); - } - else if (match = variableRegex.exec(value)) { + } else if (match = variableRegex.exec(value)) { primitive = match[0]; value = value.substr(match[0].length).trim(); - } - else if (match = errorRegex.exec(value)) { + } else if (match = errorRegex.exec(value)) { primitive = match[0]; value = value.substr(match[0].length).trim(); - } - else { + } else { primitive = value; } return primitive; @@ -225,22 +214,18 @@ export function expandValue(variableCreate: Function, value: string, root: strin if (typeof val == "object") { ref = variableCreate(val); val = "Object"; - } - else if (typeof val == "string" && val.startsWith("*0x")) { + } else if (typeof val == "string" && val.startsWith("*0x")) { if (extra && MINode.valueOf(extra, "arg") == "1") { ref = variableCreate(getNamespace("*(" + name), { arg: true }); val = ""; - } - else { + } else { ref = variableCreate(getNamespace("*" + name)); val = "Object@" + val; } - } - else if (typeof val == "string" && val.startsWith("@0x")) { + } else if (typeof val == "string" && val.startsWith("@0x")) { ref = variableCreate(getNamespace("*&" + name.substr)); val = "Ref" + val; - } - else if (typeof val == "string" && val.startsWith("<...>")) { + } else if (typeof val == "string" && val.startsWith("<...>")) { ref = variableCreate(getNamespace(name)); val = "..."; } @@ -270,4 +255,4 @@ export function expandValue(variableCreate: Function, value: string, root: strin value = value.trim(); return parseValue(); -} \ No newline at end of file +} diff --git a/src/backend/linux/console.ts b/src/backend/linux/console.ts index c3cbea0..bcdfc6b 100644 --- a/src/backend/linux/console.ts +++ b/src/backend/linux/console.ts @@ -1,5 +1,5 @@ -import * as ChildProcess from "child_process" -import * as fs from "fs" +import * as ChildProcess from "child_process"; +import * as fs from "fs"; export function spawnTerminalEmulator(preferedEmulator: string): Thenable { return new Promise((resolve, reject) => { @@ -18,4 +18,4 @@ export function spawnTerminalEmulator(preferedEmulator: string): Thenable { this.emit("debug-ready"); resolve(); }, reject); - } - else { + } else { if (separateConsole !== undefined) { linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => { promises.push(this.sendCommand("inferior-tty-set " + tty)); @@ -81,8 +80,7 @@ export class MI2 extends EventEmitter implements IBackend { resolve(); }, reject); }); - } - else { + } else { Promise.all(promises).then(() => { this.emit("debug-ready"); resolve(); @@ -170,7 +168,7 @@ export class MI2 extends EventEmitter implements IBackend { if (procArgs && procArgs.length && !attach) promises.push(this.sendCommand("exec-arguments " + procArgs)); Promise.all(promises).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); }); @@ -187,8 +185,7 @@ export class MI2 extends EventEmitter implements IBackend { if (ssh) { if (!path.isAbsolute(target)) target = path.join(cwd, target); - } - else { + } else { if (!nativePath.isAbsolute(target)) target = nativePath.join(cwd, target); } @@ -231,7 +228,7 @@ export class MI2 extends EventEmitter implements IBackend { commands.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\"")); } Promise.all(commands).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); }); @@ -256,7 +253,7 @@ export class MI2 extends EventEmitter implements IBackend { this.sendCommand("environment-directory \"" + escape(cwd) + "\""), this.sendCommand("target-select remote " + target) ]).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); }); @@ -298,7 +295,7 @@ export class MI2 extends EventEmitter implements IBackend { } onOutputStderr(lines) { - lines = lines.split('\n'); + lines = lines.split('\n'); lines.forEach(line => { this.log("stderr", line); }); @@ -313,13 +310,12 @@ export class MI2 extends EventEmitter implements IBackend { } onOutput(lines) { - lines = lines.split('\n'); + lines = lines.split('\n'); lines.forEach(line => { if (couldBeOutput(line)) { if (!gdbMatch.exec(line)) this.log("stdout", line); - } - else { + } else { const parsed = parseMI(line); if (this.debugOutput) this.log("log", "GDB -> App: " + JSON.stringify(parsed)); @@ -360,8 +356,7 @@ export class MI2 extends EventEmitter implements IBackend { else if (reason == "exited") { // exit with error code != 0 this.log("stderr", "Program exited with code " + parsed.record("exit-code")); this.emit("exited-normally", parsed); - } - else { + } else { this.log("console", "Not implemented stop reason (assuming exception): " + reason); this.emit("stopped", parsed); } @@ -408,10 +403,9 @@ export class MI2 extends EventEmitter implements IBackend { }, 1000); this.stream.on("exit", function (code) { clearTimeout(to); - }) + }); this.sendRaw("-gdb-exit"); - } - else { + } else { const proc = this.process; const to = setTimeout(() => { process.kill(-proc.pid); @@ -521,8 +515,7 @@ export class MI2 extends EventEmitter implements IBackend { if (match.length != breakpoint.countCondition.length) { this.log("stderr", "Unsupported break count expression: '" + breakpoint.countCondition + "'. Only supports 'X' for breaking once after X times or '>X' for ignoring the first X breaks"); location += "-t "; - } - else if (parseInt(match) != 0) + } else if (parseInt(match) != 0) location += "-t -i " + parseInt(match) + " "; } } @@ -547,13 +540,11 @@ export class MI2 extends EventEmitter implements IBackend { resolve([false, undefined]); } }, reject); - } - else { + } else { this.breakpoints.set(newBrk, bkptNum); resolve([true, newBrk]); } - } - else { + } else { reject(result); } }, reject); @@ -570,8 +561,7 @@ export class MI2 extends EventEmitter implements IBackend { if (result.resultRecords.resultClass == "done") { this.breakpoints.delete(breakpoint); resolve(true); - } - else resolve(false); + } else resolve(false); }); }); } @@ -584,8 +574,7 @@ export class MI2 extends EventEmitter implements IBackend { if (result.resultRecords.resultClass == "done") { this.breakpoints.clear(); resolve(true); - } - else resolve(false); + } else resolve(false); }, () => { resolve(false); }); @@ -600,7 +589,7 @@ export class MI2 extends EventEmitter implements IBackend { const threads = result.result("threads"); const ret: Thread[] = []; return threads.map(element => { - const ret : Thread = { + const ret: Thread = { id: parseInt(MINode.valueOf(element, "id")), targetId: MINode.valueOf(element, "target-id") }; @@ -609,7 +598,7 @@ export class MI2 extends EventEmitter implements IBackend { if (name) { ret.name = name; } - + return ret; }); } @@ -719,7 +708,7 @@ export class MI2 extends EventEmitter implements IBackend { async varUpdate(name: string = "*"): Promise { if (trace) this.log("stderr", "varUpdate"); - return this.sendCommand(`var-update --all-values ${name}`) + return this.sendCommand(`var-update --all-values ${name}`); } async varAssign(name: string, rawValue: string): Promise { @@ -739,8 +728,7 @@ export class MI2 extends EventEmitter implements IBackend { sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable { if (command.startsWith("-")) { return this.sendCommand(command.substr(1)); - } - else { + } else { return this.sendCliCommand(command, threadId, frameLevel); } } @@ -755,12 +743,12 @@ export class MI2 extends EventEmitter implements IBackend { } async sendCliCommand(command: string, threadId: number = 0, frameLevel: number = 0) { - let mi_command = "interpreter-exec "; + let miCommand = "interpreter-exec "; if (threadId != 0) { - mi_command += `--thread ${threadId} --frame ${frameLevel} `; + miCommand += `--thread ${threadId} --frame ${frameLevel} `; } - mi_command += `console "${command.replace(/[\\"']/g, '\\$&')}"`; - await this.sendCommand(mi_command); + miCommand += `console "${command.replace(/[\\"']/g, '\\$&')}"`; + await this.sendCommand(miCommand); } sendCommand(command: string, suppressFailure: boolean = false): Thenable { @@ -771,11 +759,9 @@ export class MI2 extends EventEmitter implements IBackend { if (suppressFailure) { this.log("stderr", `WARNING: Error executing command '${command}'`); resolve(node); - } - else + } else reject(new MIError(node.result("msg") || "Internal error", command)); - } - else + } else resolve(node); }; this.sendRaw(sel + "-" + command); diff --git a/src/backend/mi2/mi2lldb.ts b/src/backend/mi2/mi2lldb.ts index 5cdf788..3144dbf 100644 --- a/src/backend/mi2/mi2lldb.ts +++ b/src/backend/mi2/mi2lldb.ts @@ -1,8 +1,8 @@ -import { MI2, escape } from "./mi2" -import { Breakpoint } from "../backend" -import * as ChildProcess from "child_process" -import { posix } from "path" -import * as nativePath from "path" +import { MI2, escape } from "./mi2"; +import { Breakpoint } from "../backend"; +import * as ChildProcess from "child_process"; +import { posix } from "path"; +import * as nativePath from "path"; const path = posix; export class MI2_LLDB extends MI2 { @@ -10,8 +10,7 @@ export class MI2_LLDB extends MI2 { if (ssh) { if (!path.isAbsolute(target)) target = path.join(cwd, target); - } - else { + } else { if (!nativePath.isAbsolute(target)) target = nativePath.join(cwd, target); } @@ -58,4 +57,4 @@ export class MI2_LLDB extends MI2 { setBreakPointCondition(bkptNum, condition): Thenable { return this.sendCommand("break-condition " + bkptNum + " \"" + escape(condition) + "\" 1"); } -} \ No newline at end of file +} diff --git a/src/backend/mi2/mi2mago.ts b/src/backend/mi2/mi2mago.ts index 43af661..351b13e 100644 --- a/src/backend/mi2/mi2mago.ts +++ b/src/backend/mi2/mi2mago.ts @@ -1,6 +1,6 @@ -import { MI2_LLDB } from "./mi2lldb" -import { Stack } from "../backend" -import { MINode } from "../mi_parse" +import { MI2_LLDB } from "./mi2lldb"; +import { Stack } from "../backend"; +import { MINode } from "../mi_parse"; export class MI2_Mago extends MI2_LLDB { getStack(maxLevels: number, thread: number): Promise { @@ -29,7 +29,7 @@ export class MI2_Mago extends MI2_LLDB { level: level, line: line }); - } + }; stack.forEach(element => { if (element) if (element[0] == "stack") { @@ -42,4 +42,4 @@ export class MI2_Mago extends MI2_LLDB { }, reject); }); } -} \ No newline at end of file +} diff --git a/src/backend/mi_parse.ts b/src/backend/mi_parse.ts index f8556f9..ded0008 100644 --- a/src/backend/mi_parse.ts +++ b/src/backend/mi_parse.ts @@ -39,8 +39,7 @@ function parseString(str: string): string { else if (m = octalMatch.exec(str.substr(i))) { ret.writeUInt8(parseInt(m[0], 8), bufIndex++); i += 2; - } - else + } else bufIndex += ret.write(str[i], bufIndex); escaped = false; } else { @@ -93,8 +92,7 @@ export class MINode implements MIInfo { path = path.substr(target[0].length); if (current.length && typeof current != "string") { const found = []; - for (let i = 0; i < current.length; i++) { - const element = current[i]; + for (const element of current) { if (element[0] == target[1]) { found.push(element[1]); } @@ -105,12 +103,10 @@ export class MINode implements MIInfo { current = found[0]; } else return undefined; } else return undefined; - } - else if (path[0] == '@') { + } else if (path[0] == '@') { current = [current]; path = path.substr(1); - } - else { + } else { target = indexRegex.exec(path); if (target) { path = path.substr(target[0].length); @@ -119,8 +115,7 @@ export class MINode implements MIInfo { current = current[i]; } else if (i == 0) { } else return undefined; - } - else return undefined; + } else return undefined; } path = path.trim(); } while (path); @@ -189,8 +184,7 @@ export function parseMI(output: string): MINode { let str; try { str = parseString(output.substr(0, stringEnd)); - } - catch (e) { + } catch (e) { str = output.substr(0, stringEnd); } output = output.substr(stringEnd); @@ -287,8 +281,7 @@ export function parseMI(output: string): MINode { while (result = parseCommaResult()) asyncRecord.output.push(result); outOfBandRecord.push(asyncRecord); - } - else if (match[3]) { + } else if (match[3]) { const streamRecord = { isStream: true, type: streamRecordType[match[3]], @@ -316,5 +309,5 @@ export function parseMI(output: string): MINode { output = output.replace(newlineRegex, ""); } - return new MINode(token, outOfBandRecord || [], resultRecords); -} \ No newline at end of file + return new MINode(token, outOfBandRecord || [], resultRecords); +} diff --git a/src/frontend/extension.ts b/src/frontend/extension.ts index f8a251f..6d657ee 100644 --- a/src/frontend/extension.ts +++ b/src/frontend/extension.ts @@ -42,8 +42,7 @@ function getMemoryRange(range: string) { if (memoryLocationRegex.exec(length)) length = parseInt(length.substr(2), 16).toString(); return "from=" + encodeURIComponent(from) + "&length=" + encodeURIComponent(length); - } - else if ((index = range.indexOf("-")) != -1) { + } else if ((index = range.indexOf("-")) != -1) { const from = range.substr(0, index); const to = range.substr(index + 1); if (!memoryLocationRegex.exec(from)) @@ -51,8 +50,7 @@ function getMemoryRange(range: string) { if (!memoryLocationRegex.exec(to)) return undefined; return "from=" + encodeURIComponent(from) + "&to=" + encodeURIComponent(to); - } - else if (memoryLocationRegex.exec(range)) + } else if (memoryLocationRegex.exec(range)) return "at=" + encodeURIComponent(range); else return undefined; } @@ -100,18 +98,14 @@ class MemoryContentProvider implements vscode.TextDocumentContentProvider { highlightAt = 64; from = Math.max(loc - 64, 0); to = Math.max(loc + 768, 0); - } - else if (splits[0].split("=")[0] == "from") { + } else if (splits[0].split("=")[0] == "from") { from = parseInt(splits[0].split("=")[1].substr(2), 16); if (splits[1].split("=")[0] == "to") { to = parseInt(splits[1].split("=")[1].substr(2), 16); - } - else if (splits[1].split("=")[0] == "length") { + } else if (splits[1].split("=")[0] == "length") { to = from + parseInt(splits[1].split("=")[1]); - } - else return reject("Invalid Range"); - } - else return reject("Invalid Range"); + } else return reject("Invalid Range"); + } else return reject("Invalid Range"); if (to < from) return reject("Negative Range"); conn.write("examineMemory " + JSON.stringify([from, to - from + 1])); @@ -150,4 +144,4 @@ class MemoryContentProvider implements vscode.TextDocumentContentProvider { }); }); } -} \ No newline at end of file +} diff --git a/src/gdb.ts b/src/gdb.ts index 4dd479a..507f240 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -87,13 +87,12 @@ class GDBDebugSession extends MI2DebugSession { if (this.crashed) this.handlePause(undefined); }, err => { - this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`) + this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`); }); }, err => { - this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`) + this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`); }); - } - else { + } else { this.miDebugger.load(args.cwd, args.target, args.arguments, args.terminal).then(() => { if (args.autorun) args.autorun.forEach(command => { @@ -108,10 +107,10 @@ class GDBDebugSession extends MI2DebugSession { if (this.crashed) this.handlePause(undefined); }, err => { - this.sendErrorResponse(response, 100, `Failed to Start MI Debugger: ${err.toString()}`) + this.sendErrorResponse(response, 100, `Failed to Start MI Debugger: ${err.toString()}`); }); }, err => { - this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`) + this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`); }); } } @@ -151,10 +150,9 @@ class GDBDebugSession extends MI2DebugSession { }, 50); this.sendResponse(response); }, err => { - this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`) + this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`); }); - } - else { + } else { if (args.remote) { this.miDebugger.connect(args.cwd, args.executable, args.target).then(() => { if (args.autorun) @@ -163,10 +161,9 @@ class GDBDebugSession extends MI2DebugSession { }); this.sendResponse(response); }, err => { - this.sendErrorResponse(response, 102, `Failed to attach: ${err.toString()}`) + this.sendErrorResponse(response, 102, `Failed to attach: ${err.toString()}`); }); - } - else { + } else { this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => { if (args.autorun) args.autorun.forEach(command => { @@ -174,7 +171,7 @@ class GDBDebugSession extends MI2DebugSession { }); this.sendResponse(response); }, err => { - this.sendErrorResponse(response, 101, `Failed to attach: ${err.toString()}`) + this.sendErrorResponse(response, 101, `Failed to attach: ${err.toString()}`); }); } } diff --git a/src/lldb.ts b/src/lldb.ts index bbef2dd..789ffc1 100644 --- a/src/lldb.ts +++ b/src/lldb.ts @@ -83,8 +83,7 @@ class LLDBDebugSession extends MI2DebugSession { this.handlePause(undefined); }); }); - } - else { + } else { this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => { if (args.autorun) args.autorun.forEach(command => { diff --git a/src/mibase.ts b/src/mibase.ts index 9c10fe7..c0da00e 100644 --- a/src/mibase.ts +++ b/src/mibase.ts @@ -179,18 +179,16 @@ export class MI2DebugSession extends DebugSession { response.body = { value: res.result("value") }; - } - else { + } else { await this.miDebugger.changeVariable(args.name, args.value); response.body = { value: args.value }; } this.sendResponse(response); - } - catch (err) { + } catch (err) { this.sendErrorResponse(response, 11, `Could not continue: ${err}`); - }; + } } protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments): void { @@ -300,8 +298,7 @@ export class MI2DebugSession extends DebugSession { if (this.isSSH) { file = relative(this.switchCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/")); file = systemPath.resolve(this.trimCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/")); - } - else if (process.platform === "win32") { + } else if (process.platform === "win32") { if (file.startsWith("\\cygdrive\\") || file.startsWith("/cygdrive/")) { file = file[10] + ":" + file.substr(11); // replaces /cygdrive/c/foo/bar.txt with c:/foo/bar.txt } @@ -321,7 +318,7 @@ export class MI2DebugSession extends DebugSession { }; this.sendResponse(response); }, err => { - this.sendErrorResponse(response, 12, `Failed to get Stack Trace: ${err.toString()}`) + this.sendErrorResponse(response, 12, `Failed to get Stack Trace: ${err.toString()}`); }); } @@ -333,8 +330,7 @@ export class MI2DebugSession extends DebugSession { }, msg => { this.sendErrorResponse(response, 2, `Could not continue: ${msg}`); }); - } - else + } else this.sendResponse(response); } @@ -353,8 +349,7 @@ export class MI2DebugSession extends DebugSession { let id: number | string | VariableObject | ExtendedVariable; if (args.variablesReference < VAR_HANDLES_START) { id = args.variablesReference - STACK_HANDLES_START; - } - else { + } else { id = this.variableHandles.get(args.variablesReference); } @@ -369,8 +364,7 @@ export class MI2DebugSession extends DebugSession { let id: number; if (this.variableHandlesReverse.hasOwnProperty(varObj.name)) { id = this.variableHandlesReverse[varObj.name]; - } - else { + } else { id = createVariable(varObj); this.variableHandlesReverse[varObj.name] = id; } @@ -398,29 +392,25 @@ export class MI2DebugSession extends DebugSession { }); const varId = this.variableHandlesReverse[varObjName]; varObj = this.variableHandles.get(varId) as any; - } - catch (err) { + } catch (err) { if (err instanceof MIError && err.message == "Variable object not found") { varObj = await this.miDebugger.varCreate(variable.name, varObjName); const varId = findOrCreateVariable(varObj); varObj.exp = variable.name; varObj.id = varId; - } - else { + } else { throw err; } } variables.push(varObj.toProtocolVariable()); - } - catch (err) { + } catch (err) { variables.push({ name: variable.name, value: `<${err}>`, variablesReference: 0 }); } - } - else { + } else { if (variable.valueStr !== undefined) { let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw); if (expanded) { @@ -447,12 +437,10 @@ export class MI2DebugSession extends DebugSession { variables: variables }; this.sendResponse(response); - } - catch (err) { + } catch (err) { this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`); } - } - else if (typeof id == "string") { + } else if (typeof id == "string") { // Variable members let variable; try { @@ -462,8 +450,7 @@ export class MI2DebugSession extends DebugSession { let expanded = expandValue(createVariable, variable.result("value"), id, variable); if (!expanded) { this.sendErrorResponse(response, 2, `Could not expand variable`); - } - else { + } else { if (typeof expanded[0] == "string") expanded = [ { @@ -477,16 +464,13 @@ export class MI2DebugSession extends DebugSession { }; this.sendResponse(response); } - } - catch (e) { + } catch (e) { this.sendErrorResponse(response, 2, `Could not expand variable: ${e}`); } - } - catch (err) { + } catch (err) { this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`); } - } - else if (typeof id == "object") { + } else if (typeof id == "object") { if (id instanceof VariableObject) { // Variable members let children: VariableObject[]; @@ -500,14 +484,12 @@ export class MI2DebugSession extends DebugSession { response.body = { variables: vars - } + }; this.sendResponse(response); - } - catch (err) { + } catch (err) { this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`); } - } - else if (id instanceof ExtendedVariable) { + } else if (id instanceof ExtendedVariable) { const varReq = id; if (varReq.options.arg) { const strArr = []; @@ -526,16 +508,14 @@ export class MI2DebugSession extends DebugSession { const expanded = expandValue(createVariable, variable.result("value"), varReq.name, variable); if (!expanded) { this.sendErrorResponse(response, 15, `Could not expand variable`); - } - else { + } else { if (typeof expanded == "string") { if (expanded == "") { if (argsPart) argsPart = false; else return submit(); - } - else if (expanded[0] != '"') { + } else if (expanded[0] != '"') { strArr.push({ name: "[err]", value: expanded, @@ -549,8 +529,7 @@ export class MI2DebugSession extends DebugSession { variablesReference: 0 }); addOne(); - } - else { + } else { strArr.push({ name: "[err]", value: expanded, @@ -559,24 +538,20 @@ export class MI2DebugSession extends DebugSession { submit(); } } - } - catch (e) { + } catch (e) { this.sendErrorResponse(response, 14, `Could not expand variable: ${e}`); } }; addOne(); - } - else + } else this.sendErrorResponse(response, 13, `Unimplemented variable request options: ${JSON.stringify(varReq.options)}`); - } - else { + } else { response.body = { variables: id }; this.sendResponse(response); } - } - else { + } else { response.body = { variables: variables }; @@ -647,7 +622,7 @@ export class MI2DebugSession extends DebugSession { response.body = { variablesReference: 0, result: res.result("value") - } + }; this.sendResponse(response); }, msg => { this.sendErrorResponse(response, 7, msg.toString()); @@ -678,6 +653,5 @@ function prettyStringArray(strings) { return strings.join(", "); else return JSON.stringify(strings); - } - else return strings; + } else return strings; } diff --git a/test/gdb_expansion.test.ts b/test/gdb_expansion.test.ts index c91b62a..724f6d5 100644 --- a/test/gdb_expansion.test.ts +++ b/test/gdb_expansion.test.ts @@ -303,4 +303,4 @@ suite("GDB Value Expansion", () => { { name: "floatval2", value: "234.45", variablesReference: 0 } ]); }); -}); \ No newline at end of file +}); diff --git a/test/index.ts b/test/index.ts index 93023b9..0559a38 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1,16 +1,16 @@ -// -// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING // // This file is providing the test runner to use when running extension tests. // By default the test runner in use is Mocha based. -// +// // You can provide your own test runner if you want to override it by exporting // a function run(testRoot: string, clb: (error:Error) => void) that the extension // host can call to run the tests. The test runner is expected to use console.log // to report the results back to the caller. When the tests are finished, return // a possible error to the callback or null if none. -const testRunner = require('vscode/lib/testrunner'); +import * as testRunner from "vscode/lib/testrunner"; // You can directly control Mocha options by uncommenting the following lines // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info @@ -19,4 +19,4 @@ testRunner.configure({ useColors: true // colored output from test results }); -module.exports = testRunner; \ No newline at end of file +module.exports = testRunner; diff --git a/test/mi_parse.test.ts b/test/mi_parse.test.ts index 9360d79..e9dd260 100644 --- a/test/mi_parse.test.ts +++ b/test/mi_parse.test.ts @@ -95,7 +95,7 @@ suite("MI Parse", () => { assert.notEqual(parsed.resultRecords, undefined); assert.equal(parsed.resultRecords.resultClass, "done"); assert.equal(parsed.resultRecords.results.length, 1); - const asm_insns = [ + const asmInsns = [ "asm_insns", [ [ @@ -125,7 +125,7 @@ suite("MI Parse", () => { ] ] ]; - assert.deepEqual(parsed.resultRecords.results[0], asm_insns); + assert.deepEqual(parsed.resultRecords.results[0], asmInsns); assert.equal(parsed.result("asm_insns.src_and_asm_line.line_asm_insn[1].address"), "0x00000000004e7da5"); }); test("valueof children", () => { @@ -158,14 +158,14 @@ suite("MI Parse", () => { ] ] ]; - + assert.equal(MINode.valueOf(obj[0], "@frame.level"), "0"); assert.equal(MINode.valueOf(obj[0], "@frame.addr"), "0x0000000000435f70"); assert.equal(MINode.valueOf(obj[0], "@frame.func"), "D main"); assert.equal(MINode.valueOf(obj[0], "@frame.file"), "source/app.d"); assert.equal(MINode.valueOf(obj[0], "@frame.fullname"), "/path/to/source/app.d"); assert.equal(MINode.valueOf(obj[0], "@frame.line"), "5"); - + assert.equal(MINode.valueOf(obj[1], "@frame.level"), "1"); assert.equal(MINode.valueOf(obj[1], "@frame.addr"), "0x00000000004372d3"); assert.equal(MINode.valueOf(obj[1], "@frame.func"), "rt.dmain2._d_run_main()"); diff --git a/tslint.json b/tslint.json index 92c3442..b1ea9a1 100644 --- a/tslint.json +++ b/tslint.json @@ -3,6 +3,7 @@ "extends": "tslint:recommended", "rules": { "no-null-keyword": true, + "indent": [true, "tabs"], /* Rules in tslint:recommended that we don't follow yet. */ "array-type": false, "arrow-parens": false, @@ -11,8 +12,6 @@ "class-name": false, "comment-format": false, "curly": false, - "eofline": false, - "indent": false, "interface-name": false, "max-classes-per-file": false, "max-line-length": false, @@ -24,24 +23,16 @@ "no-consecutive-blank-lines": false, "no-empty": false, "no-shadowed-variable": false, - "no-trailing-whitespace": false, "no-unnecessary-initializer": false, - "no-var-requires": false, "object-literal-shorthand": false, "object-literal-sort-keys": false, - "one-line": false, "one-variable-per-declaration": false, "only-arrow-functions": false, "ordered-imports": false, - "prefer-for-of": false, "quotemark": false, "radix": false, - "semicolon": false, "space-before-function-paren": false, "trailing-comma": false, - "triple-equals": false, - "typedef-whitespace": false, - "variable-name": false, - "whitespace": false + "triple-equals": false } }