From 80b54959b7d5e1416ffe4e5fa53ae1cfb61a2909 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 16 Nov 2018 14:54:41 -0500 Subject: [PATCH] Add .editorconfig file, standardize formatting I see quite a of bit of inconsistency in the formatting. Let's add a .editorconfig file, so the code we write uses the right whitespacing regardless of the editor we use. I just copied the one I wrote earlier for Theia to get started, but it doesn't have to be identical. I used Theia to auto-format all ts and json files and then tslint --fix to fixup any warnings that it would have inserted. For example, I the Typescript formatter handles quite badly (IMO) wrapping long parameter lists, and produces code that result in a warning according to our current tslint config. The Typescript formatter will do this: ``` export class Bob { constructor(a: number, b: number, c: number, d: number, e: number, f: number) { console.log('Hello'); } } ``` where the second line of parameters is indented with 4 spaces. I think is not very readable, because it's easily confused with the first line of code. I prefer our current tslint setting, which requires it to be aligned like this: ``` export class Bob { constructor(a: number, b: number, c: number, d: number, i e: number, f: number) { console.log('Hello'); } } ``` This means that formatting entire documents will always change the code to look like the first snippet above. It's a minor annoyance, and hopefully there will be a setting for that one day in the Typescript formatter. There is an issue about that here: https://github.com/Microsoft/TypeScript/issues/11629 Signed-off-by: Simon Marchi --- .editorconfig | 12 +++ src/GDBDebugSession.ts | 108 ++++++++++++++------------- src/index.ts | 2 +- src/integration-tests/launch.spec.ts | 2 +- src/mi/breakpoint.ts | 54 +++++++------- src/mi/exec.ts | 8 +- src/mi/target.ts | 8 +- src/mi/thread.ts | 18 ++--- src/mi/var.ts | 88 +++++++++++----------- src/varManager.ts | 38 +++++----- tslint.json | 32 ++++---- 11 files changed, 196 insertions(+), 174 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..3d600b6c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +insert_final_newline = true +end_of_line = lf +indent_style = space + +[*.{js,ts,md}] +indent_size = 4 + +[*.{json,yml}] +indent_size = 2 diff --git a/src/GDBDebugSession.ts b/src/GDBDebugSession.ts index 9cd9b7c4..00aa3f1a 100644 --- a/src/GDBDebugSession.ts +++ b/src/GDBDebugSession.ts @@ -9,8 +9,10 @@ *********************************************************************/ import * as path from 'path'; import { logger } from 'vscode-debugadapter/lib/logger'; -import { Handles, InitializedEvent, Logger, LoggingDebugSession, OutputEvent, Scope, Source, StackFrame, - StoppedEvent, TerminatedEvent, Thread } from 'vscode-debugadapter/lib/main'; +import { + Handles, InitializedEvent, Logger, LoggingDebugSession, OutputEvent, Scope, Source, StackFrame, + StoppedEvent, TerminatedEvent, Thread, +} from 'vscode-debugadapter/lib/main'; import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol'; import { GDBBackend } from './GDBBackend'; import { sendBreakDelete, sendBreakInsert, sendBreakList } from './mi/breakpoint'; @@ -66,7 +68,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected initializeRequest(response: DebugProtocol.InitializeResponse, - args: DebugProtocol.InitializeRequestArguments): void { + args: DebugProtocol.InitializeRequestArguments): void { response.body = response.body || {}; response.body.supportsConfigurationDoneRequest = true; response.body.supportsSetVariable = true; @@ -88,7 +90,7 @@ export class GDBDebugSession extends LoggingDebugSession { await this.gdb.attach(args); - await sendTargetAttachRequest(this.gdb, {pid: args.processId}); + await sendTargetAttachRequest(this.gdb, { pid: args.processId }); this.sendEvent(new OutputEvent(`attached to process ${args.processId}`)); this.sendEvent(new InitializedEvent()); @@ -112,7 +114,7 @@ export class GDBDebugSession extends LoggingDebugSession { this.gdb.sendEnablePrettyPrint(); if (args.arguments) { - await exec.sendExecArguments(this.gdb, {arguments: args.arguments}); + await exec.sendExecArguments(this.gdb, { arguments: args.arguments }); } this.sendEvent(new InitializedEvent()); this.sendResponse(response); @@ -122,7 +124,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, - args: DebugProtocol.SetBreakpointsArguments): Promise { + args: DebugProtocol.SetBreakpointsArguments): Promise { try { // Need to get the list of current breakpoints in the file and then make sure // that we end up with the requested set of breakpoints for that file @@ -160,7 +162,7 @@ export class GDBDebugSession extends LoggingDebugSession { }); for (const vsbp of inserts) { - const gdbbp = await sendBreakInsert(this.gdb, {location: `${file}:${vsbp.line}`}); + const gdbbp = await sendBreakInsert(this.gdb, { location: `${file}:${vsbp.line}` }); actual.push({ id: parseInt(gdbbp.bkpt.number, 10), line: gdbbp.bkpt.line ? parseInt(gdbbp.bkpt.line, 10) : 0, @@ -173,7 +175,7 @@ export class GDBDebugSession extends LoggingDebugSession { }; if (deletes.length > 0) { - await sendBreakDelete(this.gdb, {breakpoints: deletes}); + await sendBreakDelete(this.gdb, { breakpoints: deletes }); } this.sendResponse(response); @@ -183,7 +185,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async configurationDoneRequest(response: DebugProtocol.ConfigurationDoneResponse, - args: DebugProtocol.ConfigurationDoneArguments): Promise { + args: DebugProtocol.ConfigurationDoneArguments): Promise { try { if (this.isAttach) { await exec.sendExecContinue(this.gdb); @@ -222,14 +224,14 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async stackTraceRequest(response: DebugProtocol.StackTraceResponse, - args: DebugProtocol.StackTraceArguments): Promise { + args: DebugProtocol.StackTraceArguments): Promise { try { - const depthResult = await sendStackInfoDepth(this.gdb, {maxDepth: 100}); + const depthResult = await sendStackInfoDepth(this.gdb, { maxDepth: 100 }); const depth = parseInt(depthResult.depth, 10); const levels = args.levels ? (args.levels > depth ? depth : args.levels) : depth; const lowFrame = args.startFrame || 0; const highFrame = lowFrame + levels - 1; - const listResult = await sendStackListFramesRequest(this.gdb, {lowFrame, highFrame}); + const listResult = await sendStackListFramesRequest(this.gdb, { lowFrame, highFrame }); const stack = listResult.stack.map((frame) => { let source; @@ -259,7 +261,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async nextRequest(response: DebugProtocol.NextResponse, - args: DebugProtocol.NextArguments): Promise { + args: DebugProtocol.NextArguments): Promise { try { await exec.sendExecNext(this.gdb); this.sendResponse(response); @@ -269,7 +271,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async stepInRequest(response: DebugProtocol.StepInResponse, - args: DebugProtocol.StepInArguments): Promise { + args: DebugProtocol.StepInArguments): Promise { try { await exec.sendExecStep(this.gdb); this.sendResponse(response); @@ -279,7 +281,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async stepOutRequest(response: DebugProtocol.StepOutResponse, - args: DebugProtocol.StepOutArguments): Promise { + args: DebugProtocol.StepOutArguments): Promise { try { await exec.sendExecFinish(this.gdb); this.sendResponse(response); @@ -289,7 +291,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async continueRequest(response: DebugProtocol.ContinueResponse, - args: DebugProtocol.ContinueArguments): Promise { + args: DebugProtocol.ContinueArguments): Promise { try { await exec.sendExecContinue(this.gdb); this.sendResponse(response); @@ -299,7 +301,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected scopesRequest(response: DebugProtocol.ScopesResponse, - args: DebugProtocol.ScopesArguments): void { + args: DebugProtocol.ScopesArguments): void { const frame: FrameVariableReference = { type: 'frame', frameHandle: args.frameId, @@ -315,7 +317,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async variablesRequest(response: DebugProtocol.VariablesResponse, - args: DebugProtocol.VariablesArguments): Promise { + args: DebugProtocol.VariablesArguments): Promise { const variables = new Array(); response.body = { variables, @@ -336,7 +338,7 @@ export class GDBDebugSession extends LoggingDebugSession { let callStack = false; let numVars = 0; - const stackDepth = await sendStackInfoDepth(this.gdb, {maxDepth: 100}); + const stackDepth = await sendStackInfoDepth(this.gdb, { maxDepth: 100 }); const depth = parseInt(stackDepth.depth, 10); const toDelete = new Array(); @@ -344,7 +346,10 @@ export class GDBDebugSession extends LoggingDebugSession { if (vars) { for (const varobj of vars) { if (varobj.isVar && !varobj.isChild) { - const vup = await sendVarUpdate(this.gdb, {threadId: frame.threadId, name: varobj.varname}); + const vup = await sendVarUpdate(this.gdb, { + threadId: frame.threadId, + name: varobj.varname, + }); const update = vup.changelist[0]; let pushVar = true; if (update) { @@ -369,7 +374,7 @@ export class GDBDebugSession extends LoggingDebugSession { type: 'object', frameHandle: ref.frameHandle, varobjName: varobj.expression, - }) + }) : 0, }); } @@ -405,7 +410,7 @@ export class GDBDebugSession extends LoggingDebugSession { type: 'object', frameHandle: ref.frameHandle, varobjName: varobj.expression, - }) + }) : 0, }); } @@ -417,7 +422,7 @@ export class GDBDebugSession extends LoggingDebugSession { this.sendResponse(response); return; } - const stackDepth = await sendStackInfoDepth(this.gdb, {maxDepth: 100}); + const stackDepth = await sendStackInfoDepth(this.gdb, { maxDepth: 100 }); const depth = parseInt(stackDepth.depth, 10); const varobj = varMgr.getVar(frame.frameId, frame.threadId, depth, ref.varobjName); if (varobj) { @@ -435,7 +440,8 @@ export class GDBDebugSession extends LoggingDebugSession { let childobj = varMgr.getVar(frame.frameId, frame.threadId, depth, name); if (!childobj) { const childvar = await sendVarCreate(this.gdb, { - frame: 'current', expression: name}); + frame: 'current', expression: name, + }); if (childvar) { childobj = varMgr.addVar(frame.frameId, frame.threadId, depth, name, true, true, childvar); @@ -454,7 +460,7 @@ export class GDBDebugSession extends LoggingDebugSession { type: 'object', frameHandle: ref.frameHandle, varobjName: name, - }) + }) : 0, }); } @@ -468,7 +474,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, - args: DebugProtocol.SetVariableArguments): Promise { + args: DebugProtocol.SetVariableArguments): Promise { try { const ref = this.variableHandles.get(args.variablesReference); if (!ref) { @@ -480,25 +486,27 @@ export class GDBDebugSession extends LoggingDebugSession { this.sendResponse(response); return; } - const stackDepth = await sendStackInfoDepth(this.gdb, {maxDepth: 100}); + const stackDepth = await sendStackInfoDepth(this.gdb, { maxDepth: 100 }); const depth = parseInt(stackDepth.depth, 10); const varobj = varMgr.getVar(frame.frameId, frame.threadId, depth, args.name); if (varobj) { - await sendVarAssign(this.gdb, {varname: varobj.varname, expression: args.value}); + await sendVarAssign(this.gdb, { varname: varobj.varname, expression: args.value }); await varMgr.updateVar(this.gdb, frame.frameId, frame.threadId, depth, varobj); - response.body = { value: varobj.value, - type: varobj.type, - variablesReference: parseInt(varobj.numchild, 10) > 0 - ? this.variableHandles.create({ - type: 'object', - frameHandle: ref.frameHandle, - varobjName: varobj.expression }) - : 0, - indexedVariables: parseInt(varobj.numchild, 10), - }; + response.body = { + value: varobj.value, + type: varobj.type, + variablesReference: parseInt(varobj.numchild, 10) > 0 + ? this.variableHandles.create({ + type: 'object', + frameHandle: ref.frameHandle, + varobjName: varobj.expression, + }) + : 0, + indexedVariables: parseInt(varobj.numchild, 10), + }; } else { // we shouldn't hit this case - response.body = {value: args.value}; + response.body = { value: args.value }; } } catch (err) { this.sendErrorResponse(response, 1, err.message); @@ -513,12 +521,12 @@ export class GDBDebugSession extends LoggingDebugSession { // } protected async evaluateRequest(response: DebugProtocol.EvaluateResponse, - args: DebugProtocol.EvaluateArguments): Promise { - response.body = {result: 'Error: could not evaluate expression', variablesReference: 0}; // default response + args: DebugProtocol.EvaluateArguments): Promise { + response.body = { result: 'Error: could not evaluate expression', variablesReference: 0 }; // default response try { switch (args.context) { case 'repl': - response.body = {result: 'placeholder text', variablesReference: 0}; + response.body = { result: 'placeholder text', variablesReference: 0 }; await this.gdb.sendCommand(args.expression); this.sendResponse(response); break; @@ -530,15 +538,15 @@ export class GDBDebugSession extends LoggingDebugSession { return; } try { - const stackDepth = await sendStackInfoDepth(this.gdb, {maxDepth: 100}); + const stackDepth = await sendStackInfoDepth(this.gdb, { maxDepth: 100 }); const depth = parseInt(stackDepth.depth, 10); let varobj = varMgr.getVar(frame.frameId, frame.threadId, depth, args.expression); if (!varobj) { const varCreateResponse = await sendVarCreate(this.gdb, - {expression: args.expression, frame: 'current'}); + { expression: args.expression, frame: 'current' }); varobj = varMgr.addVar(frame.frameId, frame.threadId, depth, args.expression, false, false, varCreateResponse); - } else { + } else { const vup = await sendVarUpdate(this.gdb, { threadId: frame.threadId, name: varobj.varname, @@ -548,12 +556,12 @@ export class GDBDebugSession extends LoggingDebugSession { if (update.in_scope === 'true') { varobj.value = update.value; } else { - varMgr.removeVar(this.gdb, frame.frameId, frame.threadId, depth, + varMgr.removeVar(this.gdb, frame.frameId, frame.threadId, depth, varobj.varname); - await sendVarDelete(this.gdb, {varname: varobj.varname}); + await sendVarDelete(this.gdb, { varname: varobj.varname }); varobj = undefined; const varCreateResponse = await sendVarCreate(this.gdb, - {expression: args.expression, frame: 'current'}); + { expression: args.expression, frame: 'current' }); varobj = varMgr.addVar(frame.frameId, frame.threadId, depth, args.expression, false, false, varCreateResponse); } @@ -568,7 +576,7 @@ export class GDBDebugSession extends LoggingDebugSession { type: 'object', frameHandle: args.frameId, varobjName: varobj.expression, - }) + }) : 0, }; } @@ -586,7 +594,7 @@ export class GDBDebugSession extends LoggingDebugSession { } protected async disconnectRequest(response: DebugProtocol.DisconnectResponse, - args: DebugProtocol.DisconnectArguments): Promise { + args: DebugProtocol.DisconnectArguments): Promise { try { await this.gdb.sendGDBExit(); this.sendResponse(response); diff --git a/src/index.ts b/src/index.ts index 248903b1..76505980 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,4 +15,4 @@ import * as path from 'path'; */ export function getExecPath(): string { return path.join(__dirname, 'debugAdapter.js'); -} \ No newline at end of file +} diff --git a/src/integration-tests/launch.spec.ts b/src/integration-tests/launch.spec.ts index 5d0c0f17..08877be9 100644 --- a/src/integration-tests/launch.spec.ts +++ b/src/integration-tests/launch.spec.ts @@ -56,7 +56,7 @@ describe('launch', function() { source: { path: 'empty.c' }, breakpoints: [{ line: 3, - }] + }], }); await dc.configurationDoneRequest({}); await dc.assertStoppedLocation('breakpoint', {}); diff --git a/src/mi/breakpoint.ts b/src/mi/breakpoint.ts index c8881e02..9c265fa9 100644 --- a/src/mi/breakpoint.ts +++ b/src/mi/breakpoint.ts @@ -7,11 +7,11 @@ * * SPDX-License-Identifier: EPL-2.0 *********************************************************************/ -import {GDBBackend} from '../GDBBackend'; +import { GDBBackend } from '../GDBBackend'; import { MIBreakpointInfo, MIResponse } from './base'; export interface MIBreakInsertResponse extends MIResponse { - bkpt: MIBreakpointInfo; + bkpt: MIBreakpointInfo; } export interface MIBreakDeleteRequest { @@ -22,40 +22,40 @@ export interface MIBreakDeleteResponse extends MIResponse { } export interface MIBreakListResponse extends MIResponse { - BreakpointTable: { - nr_rows: string, - nr_cols: string, - hrd: Array<{ - width: string, - alignment: string, - col_name: string, - colhdr: string, - }>; - body: MIBreakpointInfo[] - }; + BreakpointTable: { + nr_rows: string, + nr_cols: string, + hrd: Array<{ + width: string, + alignment: string, + col_name: string, + colhdr: string, + }>; + body: MIBreakpointInfo[] + }; } export function sendBreakInsert(gdb: GDBBackend, request: { - temporary?: boolean; - hardware?: boolean; - pending?: boolean; - disabled?: boolean; - tracepoint?: boolean; - condition?: string; - ignoreCount?: number; - threadId?: string; - location: string; + temporary?: boolean; + hardware?: boolean; + pending?: boolean; + disabled?: boolean; + tracepoint?: boolean; + condition?: string; + ignoreCount?: number; + threadId?: string; + location: string; }): Promise { - // Todo: lots of options - return gdb.sendCommand(`-break-insert ${request.location}`); + // Todo: lots of options + return gdb.sendCommand(`-break-insert ${request.location}`); } export function sendBreakDelete(gdb: GDBBackend, request: { - breakpoints: string[]; + breakpoints: string[]; }): Promise { - return gdb.sendCommand(`-break-delete ${request.breakpoints.join(' ')}`); + return gdb.sendCommand(`-break-delete ${request.breakpoints.join(' ')}`); } export function sendBreakList(gdb: GDBBackend): Promise { - return gdb.sendCommand('-break-list'); + return gdb.sendCommand('-break-list'); } diff --git a/src/mi/exec.ts b/src/mi/exec.ts index d141ddbf..8c0b1272 100644 --- a/src/mi/exec.ts +++ b/src/mi/exec.ts @@ -7,16 +7,16 @@ * * SPDX-License-Identifier: EPL-2.0 *********************************************************************/ -import {GDBBackend} from '../GDBBackend'; +import { GDBBackend } from '../GDBBackend'; import { MIResponse } from './base'; export function sendExecArguments(gdb: GDBBackend, params: { - arguments: string; + arguments: string; }): Promise { - return gdb.sendCommand(`-exec-arguments ${params.arguments}`); + return gdb.sendCommand(`-exec-arguments ${params.arguments}`); } -export function sendExecRun(gdb: GDBBackend) { +export function sendExecRun(gdb: GDBBackend) { return gdb.sendCommand('-exec-run'); } diff --git a/src/mi/target.ts b/src/mi/target.ts index 940b7192..9d8c7190 100644 --- a/src/mi/target.ts +++ b/src/mi/target.ts @@ -12,13 +12,13 @@ import { MIResponse } from './base'; export function sendTargetAttachRequest(gdb: GDBBackend, params: { pid: string; - }): Promise { - return gdb.sendCommand(`-target-attach ${params.pid}`); +}): Promise { + return gdb.sendCommand(`-target-attach ${params.pid}`); } export function sendTargetSelectRequest(gdb: GDBBackend, params: { type: string; parameters: string[]; - }): Promise { - return gdb.sendCommand(`-target-select ${params.type} ${params.parameters.join(' ')}`); +}): Promise { + return gdb.sendCommand(`-target-select ${params.type} ${params.parameters.join(' ')}`); } diff --git a/src/mi/thread.ts b/src/mi/thread.ts index 27ad44f7..4fa13074 100644 --- a/src/mi/thread.ts +++ b/src/mi/thread.ts @@ -25,14 +25,14 @@ export interface MIThreadInfoResponse extends MIResponse { currentThreadId: string; } -export function sendThreadInfoRequest(gdb: GDBBackend, params: { - threadId?: string; - }): Promise { - let command = '-thread-info'; - if (params.threadId) { - command += ` ${params.threadId}`; - } - return gdb.sendCommand(command); +export function sendThreadInfoRequest(gdb: GDBBackend, params: { + threadId?: string; +}): Promise { + let command = '-thread-info'; + if (params.threadId) { + command += ` ${params.threadId}`; + } + return gdb.sendCommand(command); } export interface MIThreadSelectResponse extends MIResponse { @@ -43,5 +43,5 @@ export interface MIThreadSelectResponse extends MIResponse { export function sendThreadSelectRequest(gdb: GDBBackend, params: { threadId: number; }): Promise { - return gdb.sendCommand(`-thread-select ${params.threadId}`); + return gdb.sendCommand(`-thread-select ${params.threadId}`); } diff --git a/src/mi/var.ts b/src/mi/var.ts index fea7384f..dad7ba9e 100644 --- a/src/mi/var.ts +++ b/src/mi/var.ts @@ -11,29 +11,29 @@ import { GDBBackend } from '../GDBBackend'; import { MIResponse } from './base'; export interface MIVarCreateResponse extends MIResponse { - name: string; - numchild: string; - value: string; - type: string; - 'thread-id'?: string; - has_more?: string; - dynamic?: string; - displayhint?: string; + name: string; + numchild: string; + value: string; + type: string; + 'thread-id'?: string; + has_more?: string; + dynamic?: string; + displayhint?: string; } export interface MIVarListChildrenResponse { - numchild: string; - children: Array<{ - name: string; - exp: string; - numchild: string; - type: string; - value?: string; - 'thread-id'?: string; - frozen?: string; - displayhint?: string; - dynamic?: string; - }>; + numchild: string; + children: Array<{ + name: string; + exp: string; + numchild: string; + type: string; + value?: string; + 'thread-id'?: string; + frozen?: string; + displayhint?: string; + dynamic?: string; + }>; } export interface MIVarUpdateResponse { @@ -51,35 +51,35 @@ export interface MIVarEvalResponse { } export function sendVarCreate(gdb: GDBBackend, params: { - name?: string; - frameAddr?: string; - frame?: 'current' | 'floating'; - expression: string; + name?: string; + frameAddr?: string; + frame?: 'current' | 'floating'; + expression: string; }): Promise { - let command = '-var-create'; - command += ` ${params.name ? params.name : '-'}`; - if (params.frameAddr) { - command += ` ${params.frameAddr}`; - } else if (params.frame) { - switch (params.frame) { - case 'current': - command += ' *'; - break; - case 'floating': - command += ' @'; - break; - } - } - command += ` ${params.expression}`; + let command = '-var-create'; + command += ` ${params.name ? params.name : '-'}`; + if (params.frameAddr) { + command += ` ${params.frameAddr}`; + } else if (params.frame) { + switch (params.frame) { + case 'current': + command += ' *'; + break; + case 'floating': + command += ' @'; + break; + } + } + command += ` ${params.expression}`; - return gdb.sendCommand(command); + return gdb.sendCommand(command); } export function sendVarListChildren(gdb: GDBBackend, params: { - printValues?: 'no-values' | 'all-values' | 'simple-values'; - name: string; - from?: number; - to?: number; + printValues?: 'no-values' | 'all-values' | 'simple-values'; + name: string; + from?: number; + to?: number; }): Promise { let command = '-var-list-children'; if (params.printValues) { diff --git a/src/varManager.ts b/src/varManager.ts index 5e8bccee..68db7761 100644 --- a/src/varManager.ts +++ b/src/varManager.ts @@ -1,16 +1,16 @@ import { GDBBackend } from './GDBBackend'; -import {MIVarCreateResponse} from './mi/var'; +import { MIVarCreateResponse } from './mi/var'; import { sendVarCreate, sendVarDelete, sendVarUpdate } from './mi/var'; export interface VarObjType { - varname: string; - expression: string; - numchild: string; - children: VarObjType[]; - value: string; - type: string; - isVar: boolean; - isChild: boolean; + varname: string; + expression: string; + numchild: string; + children: VarObjType[]; + value: string; + type: string; + isVar: boolean; + isChild: boolean; } const variableMap: Map = new Map(); @@ -42,14 +42,16 @@ export function addVar(frameId: number, threadId: number, depth: number, express vars = []; variableMap.set(getKey(frameId, threadId, depth), vars); } - const varobj: VarObjType = {varname: varCreateResponse.name, expression, numchild: varCreateResponse.numchild, - children: [], value: varCreateResponse.value, type: varCreateResponse.type, isVar, isChild}; + const varobj: VarObjType = { + varname: varCreateResponse.name, expression, numchild: varCreateResponse.numchild, + children: [], value: varCreateResponse.value, type: varCreateResponse.type, isVar, isChild, + }; vars.push(varobj); return varobj; } export async function removeVar(gdb: GDBBackend, frameId: number, threadId: number, depth: number, varname: string) - : Promise { + : Promise { let deleteme: VarObjType | undefined; const vars = variableMap.get(getKey(frameId, threadId, depth)); if (vars) { @@ -59,8 +61,8 @@ export async function removeVar(gdb: GDBBackend, frameId: number, threadId: numb break; } } - if (deleteme) { - await sendVarDelete(gdb, {varname: deleteme.varname}); + if (deleteme) { + await sendVarDelete(gdb, { varname: deleteme.varname }); vars.splice(vars.indexOf(deleteme), 1); for (const child of deleteme.children) { await removeVar(gdb, frameId, threadId, depth, child.varname); @@ -70,9 +72,9 @@ export async function removeVar(gdb: GDBBackend, frameId: number, threadId: numb } export async function updateVar(gdb: GDBBackend, frameId: number, threadId: number, depth: number, varobj: VarObjType) - : Promise { + : Promise { let returnVar = varobj; - const vup = await sendVarUpdate(gdb, {threadId, name: varobj.varname}); + const vup = await sendVarUpdate(gdb, { threadId, name: varobj.varname }); const update = vup.changelist[0]; if (update) { if (update.in_scope === 'true') { @@ -80,8 +82,8 @@ export async function updateVar(gdb: GDBBackend, frameId: number, threadId: numb varobj.isVar = true; } else { removeVar(gdb, frameId, threadId, depth, varobj.varname); - await sendVarDelete(gdb, {varname: varobj.varname}); - const createResponse = await sendVarCreate(gdb, {frame: 'current', expression: varobj.expression}); + await sendVarDelete(gdb, { varname: varobj.varname }); + const createResponse = await sendVarCreate(gdb, { frame: 'current', expression: varobj.expression }); returnVar = addVar(frameId, threadId, depth, varobj.expression, true, false, createResponse); } } diff --git a/tslint.json b/tslint.json index 6ddd087b..f5c371e9 100644 --- a/tslint.json +++ b/tslint.json @@ -1,17 +1,17 @@ { - "defaultSeverity": "warning", - "extends": [ - "tslint:recommended" - ], - "rules": { - "interface-name": false, - "no-empty-interface": false, - "object-literal-sort-keys": false, - "quotemark": [ - true, - "single", - "avoid-template", - "avoid-escape" - ] - } -} \ No newline at end of file + "defaultSeverity": "warning", + "extends": [ + "tslint:recommended" + ], + "rules": { + "interface-name": false, + "no-empty-interface": false, + "object-literal-sort-keys": false, + "quotemark": [ + true, + "single", + "avoid-template", + "avoid-escape" + ] + } +}