From e7647caf6e6cafa0b476477256a8e7458259b5b9 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:31:46 -0700 Subject: [PATCH 01/11] :new: Add CI config --- circle.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 circle.yml diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..dc92fcf --- /dev/null +++ b/circle.yml @@ -0,0 +1,21 @@ +dependencies: + override: + - curl -L https://atom.io/download/deb -o atom-amd64.deb + - sudo dpkg --install atom-amd64.deb || true + - sudo apt-get update + - sudo apt-get -f install + - node --version + - npm --version + - atom --version + - npm prune + - npm install + - apm rebuild + - npm build + +test: + override: + - npm test + +machine: + node: + version: 6.3.0 From 4bba6e4169be4aba464485d096b74d47f10d5579 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:31:56 -0700 Subject: [PATCH 02/11] :new: Add scripts and devDeps --- package.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c0e129c..0dbcee2 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,22 @@ "engines": { "atom": ">=1.0.0 <2.0.0" }, + "scripts": { + "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )", + "clean": "rm -rf lib", + "build": "npm run clean; babel src --out-dir lib", + "watch": "npm run clean; babel src --out-dir lib --watch" + }, "dependencies": { "atom-package-deps": "^4.3.0", "season": "^5.2.0", "underscore-plus": "^1.0.0" }, "devDependencies": { - "flow-atom-api": "https://github.com/flow-atom/flow-atom-api.git" + "eslint-config-steelbrain": "^1.0.4", + "flow-atom-api": "https://github.com/flow-atom/flow-atom-api.git", + "flow-bin": "^0.30.0", + "jasmine-fix": "^1.0.1" }, "package-deps": [ "debugger-ui-default" From b35e39c974b30daabfb76fa20bea8e1715ecb2ef Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:11 -0700 Subject: [PATCH 03/11] :new: Add ESLint config --- .eslintignore | 1 + .eslintrc.json | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 .eslintignore create mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..18fd55a --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +decls diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..c755460 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "steelbrain" +} From 37d2cad70975fe840ded6a076193ec5b7b8b4de9 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:43 -0700 Subject: [PATCH 04/11] :fire: Cleanup flow config --- .flowconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.flowconfig b/.flowconfig index c1450b9..e243807 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,9 +1,9 @@ [ignore] -node_modules/**/.* [include] [libs] +decls interface node_modules/flow-atom-api/sig/v1.7.4 node_modules/flow-atom-api/node_modules/flow-json/sig @@ -19,3 +19,4 @@ node_modules/flow-atom-api/node_modules/flow-electron-api/sig/v1.1.1 node_modules/flow-atom-api/node_modules/iflow-jquery/index.js.flow [options] +module.system=node From 52a223e8ec2ced560c28ff9ba9f60a270511e351 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:52 -0700 Subject: [PATCH 05/11] :minibus: interface -> decls --- {interface => decls}/atom.js | 0 decls/jasmine.js | 9 +++++++++ 2 files changed, 9 insertions(+) rename {interface => decls}/atom.js (100%) create mode 100644 decls/jasmine.js diff --git a/interface/atom.js b/decls/atom.js similarity index 100% rename from interface/atom.js rename to decls/atom.js diff --git a/decls/jasmine.js b/decls/jasmine.js new file mode 100644 index 0000000..7d563f1 --- /dev/null +++ b/decls/jasmine.js @@ -0,0 +1,9 @@ +/* @flow */ + +declare function it(name: string, callback: (() => void)): void; +declare function fit(name: string, callback: (() => void)): void; +declare function expect(value: any): Object; +declare function describe(name: string, callback: (() => void)): void; +declare function fdescribe(name: string, callback: (() => void)): void; +declare function beforeEach(callback: (() => void)): void; +declare function afterEach(callback: (() => void)): void; From 905c816dd5e7baabc19f3cf91ed88b8a6ad3af26 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:33:13 -0700 Subject: [PATCH 06/11] :no_entry: Git ignore .DS_Store files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e..fd4f2b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.DS_Store From a0804c2a6751d08e91f1c69f3544a1f0833486e7 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:33:30 -0700 Subject: [PATCH 07/11] :memo: Change LICENSE to AtomDebugger Team --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c44cd17..6eddd75 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Philipp von Radziewsky +Copyright (c) 2016 AtomDebugger Team (Philipp von Radziewsky & Steel Brain) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 00403fa5c505bf79b38c033af66dbd5367dfb5fd Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 29 Aug 2016 16:14:42 -0700 Subject: [PATCH 08/11] :arrow_up: Address reviewer's comments --- .eslintrc.json | 7 ++++++- circle.yml | 2 +- package.json | 5 +---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c755460..39b031d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,8 @@ { - "extends": "steelbrain" + "extends": "steelbrain", + "rules": { + "no-param-reassign": "off", + "no-duplicate-imports": "off", + "import/prefer-default-export": "off" + } } diff --git a/circle.yml b/circle.yml index dc92fcf..af3af9f 100644 --- a/circle.yml +++ b/circle.yml @@ -18,4 +18,4 @@ test: machine: node: - version: 6.3.0 + version: 6 diff --git a/package.json b/package.json index 0dbcee2..f881c30 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,7 @@ "atom": ">=1.0.0 <2.0.0" }, "scripts": { - "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )", - "clean": "rm -rf lib", - "build": "npm run clean; babel src --out-dir lib", - "watch": "npm run clean; babel src --out-dir lib --watch" + "test": "(apm test) && (flow check) && (eslint . )" }, "dependencies": { "atom-package-deps": "^4.3.0", From 673cd60c4786402855178984022854bdbabed365 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Mon, 21 Nov 2016 18:21:37 +1300 Subject: [PATCH 09/11] Add onTargetEvent to test debugger stub. --- spec/debugger-stub.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/debugger-stub.js b/spec/debugger-stub.js index a521282..ac18192 100644 --- a/spec/debugger-stub.js +++ b/spec/debugger-stub.js @@ -25,6 +25,10 @@ export default class DebbugerStub { return this.emitter.on('breakpoint', callback) } + onTargetEvent(callback) { + return this.emitter.on('target', callback) + } + /* For tests */ emitSessionEvent(notification) { this.emitter.emit('session', notification) From fd5d0b0db8a2a59ece7df1a3cae3b9c186f04138 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Tue, 22 Nov 2016 09:38:32 +1300 Subject: [PATCH 10/11] Fix flow errors --- .flowconfig | 22 +++++++++------------- lib/project-config.js | 2 +- lib/types.js | 8 +++++--- lib/variable-event.js | 2 +- package.json | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.flowconfig b/.flowconfig index e243807..b1246b8 100644 --- a/.flowconfig +++ b/.flowconfig @@ -4,19 +4,15 @@ [libs] decls -interface -node_modules/flow-atom-api/sig/v1.7.4 -node_modules/flow-atom-api/node_modules/flow-json/sig -node_modules/flow-atom-api/node_modules/flow-json-schema/sig -node_modules/flow-atom-api/node_modules/flow-atom-event-kit/sig/v1.5.0 -node_modules/flow-atom-api/node_modules/flow-atom-first-mate/sig/v5.1.1 -node_modules/flow-atom-api/node_modules/flow-atom-keymap/sig/v6.3.2 -node_modules/flow-atom-api/node_modules/flow-atom-node/sig -node_modules/flow-atom-api/node_modules/flow-atom-oniguruma/sig/v6.1.0 -node_modules/flow-atom-api/node_modules/flow-atom-pathwatcher/sig/v6.2.4 -node_modules/flow-atom-api/node_modules/flow-atom-text-buffer/sig/v8.5.0 -node_modules/flow-atom-api/node_modules/flow-electron-api/sig/v1.1.1 -node_modules/flow-atom-api/node_modules/iflow-jquery/index.js.flow +node_modules/@flow-atom/atom/sig/v1.8.0/ +node_modules/@flow-atom/keymap/sig/v6.3.2/ +node_modules/@flow-atom/electron/sig/v0.37.8/ +node_modules/@flow-atom/oniguruma/sig/v6.1.0/ +node_modules/@flow-atom/event-kit/sig/v2.0.0/ +node_modules/@flow-atom/pathwatcher/sig/v6.7.0/ +node_modules/@flow-atom/first-mate/sig/v5.1.1/ +node_modules/@flow-atom/text-buffer/sig/v9.2.2/ +node_modules/iflow-jquery/index.js.flow [options] module.system=node diff --git a/lib/project-config.js b/lib/project-config.js index 17e349d..54aba7b 100644 --- a/lib/project-config.js +++ b/lib/project-config.js @@ -24,7 +24,7 @@ export default class ProjectConfig { this.data = CSON.readFileSync(cfg.getPath()) } catch (parseError) { this.data = null - atom.notifications.addError("The file " + cfg.getPath + " could not be parsed") + atom.notifications.addError(`The file ${cfg.getPath()} could not be parsed`) return } } diff --git a/lib/types.js b/lib/types.js index 73096a8..dec92de 100644 --- a/lib/types.js +++ b/lib/types.js @@ -2,6 +2,8 @@ /* @flow */ +import type { Disposable } from 'atom' + import DebuggerController from './debugger-controller' import Breakpoint from './breakpoint' @@ -24,11 +26,11 @@ export type Debugger = { name(): string, - onSessionEvent(callback: Function): void, + onSessionEvent(callback: Function): Disposable, - onBreakpointEvent(callback: Function): void, + onBreakpointEvent(callback: Function): Disposable, - onTargetEvent(callback: Function): void, + onTargetEvent(callback: Function): Disposable, start(target: DebuggerTarget): void, diff --git a/lib/variable-event.js b/lib/variable-event.js index 7e5526a..78047e1 100644 --- a/lib/variable-event.js +++ b/lib/variable-event.js @@ -2,7 +2,7 @@ /* @flow */ -import Variable from './variable' +import type { Variable } from './variable' export type VariableEventType = 'updated' | 'left-scope' | 'entered-scope' diff --git a/package.json b/package.json index f881c30..ebc37aa 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "underscore-plus": "^1.0.0" }, "devDependencies": { + "@flow-atom/atom": "^1.8.0-rev.0", "eslint-config-steelbrain": "^1.0.4", - "flow-atom-api": "https://github.com/flow-atom/flow-atom-api.git", "flow-bin": "^0.30.0", "jasmine-fix": "^1.0.1" }, From e9026be0831b3fdab50fb21a805d8175f44b17c7 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Tue, 22 Nov 2016 10:55:01 +1300 Subject: [PATCH 11/11] Fix ESLint errors --- .eslintignore | 1 + lib/breakpoint-event.js | 19 +++--- lib/breakpoint.js | 24 ++++---- lib/debugger-controller.js | 36 +++++------ lib/debugger-proxy.js | 119 +++++++++++++++---------------------- lib/debugger-registry.js | 32 ++++------ lib/main.js | 25 ++++---- lib/project-config.js | 8 +-- lib/session-event.js | 24 ++++---- lib/target-event.js | 9 ++- lib/types.js | 6 +- lib/variable-event.js | 4 +- lib/view-registry.js | 14 ++--- 13 files changed, 137 insertions(+), 184 deletions(-) diff --git a/.eslintignore b/.eslintignore index 18fd55a..4cca95b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ decls +spec diff --git a/lib/breakpoint-event.js b/lib/breakpoint-event.js index 3ec4402..700c7bf 100644 --- a/lib/breakpoint-event.js +++ b/lib/breakpoint-event.js @@ -4,23 +4,22 @@ import Breakpoint from './breakpoint' -export type BreakpointEventType = 'inserted' | 'removed' | 'enabled' | - 'disabled' | 'moved' | - 'condition-added' | 'condition-removed' +export type BreakpointEventType = 'inserted' | 'removed' | 'enabled' | + 'disabled' | 'moved' | + 'condition-added' | 'condition-removed' export default class BreakpointEvent { - type: BreakpointEventType; + type: BreakpointEventType; breakpoint: Breakpoint; - bufferRow: ?number; + bufferRow: ?number; - constructor( - type: BreakpointEventType, breakpoint: Breakpoint, bufferRow?: number) { - - this.type = type + constructor(type: BreakpointEventType, + breakpoint: Breakpoint, + bufferRow?: number) { + this.type = type this.breakpoint = breakpoint if (type === 'moved') { - if (bufferRow == null || typeof bufferRow !== 'number') { throw new Error('bufferRow must be a number') } diff --git a/lib/breakpoint.js b/lib/breakpoint.js index 3777bfb..2546829 100644 --- a/lib/breakpoint.js +++ b/lib/breakpoint.js @@ -3,24 +3,23 @@ /* @flow */ export type FunctionBreakpoint = { function: string } -export type LineBreakpoint = { filePath: string, bufferRow: number } +export type LineBreakpoint = { filePath: string, bufferRow: number } export type BreakpointLocation = LineBreakpoint | FunctionBreakpoint export default class Breakpoint { - location: BreakpointLocation; - enabled: boolean; - condition: ?string; + location: BreakpointLocation; + enabled: boolean; + condition: ?string; activeBufferRow: ?number; constructor(location: BreakpointLocation, condition?: string) { - if (!location.function && (!location.filePath || !location.bufferRow)) { throw new TypeError('location must be BreakpointLocation') } - this.location = location - this.condition = (condition) ? condition : null - this.enabled = true + this.location = location + this.condition = condition || null + this.enabled = true this.activeBufferRow = null } @@ -33,14 +32,12 @@ export default class Breakpoint { } equals(other: Breakpoint): bool { - if (this.location.function && other.location.function) { - return (this.location.function === other.location.function) } else if (this.location.filePath && other.location.filePath) { - const same_file = (this.location.filePath === other.location.filePath) + const sameFile = (this.location.filePath === other.location.filePath) - if (same_file && this.location.bufferRow && other.location.bufferRow) { + if (sameFile && this.location.bufferRow && other.location.bufferRow) { return (this.location.bufferRow === other.location.bufferRow) } } @@ -49,9 +46,8 @@ export default class Breakpoint { } toHumanized(): string { - if (this.location.filePath && this.location.bufferRow) { - return this.location.filePath + ':' + (this.location.bufferRow+1) + return `${this.location.filePath}:${this.location.bufferRow + 1}` } return '?' diff --git a/lib/debugger-controller.js b/lib/debugger-controller.js index 5dcb667..0f7f28f 100644 --- a/lib/debugger-controller.js +++ b/lib/debugger-controller.js @@ -2,20 +2,20 @@ /* @flow */ -import Breakpoint from './breakpoint' -import DebuggerRegistry from './debugger-registry' -import ProjectConfig from './project-config' -import ViewRegistry from './view-registry' +import Breakpoint from './breakpoint' +import DebuggerRegistry from './debugger-registry' +import ProjectConfig from './project-config' +import ViewRegistry from './view-registry' import type { Debugger, DebuggerView } from './types' export default class DebuggerController { debuggerRegistry: DebuggerRegistry; - viewRegistry: ViewRegistry; + viewRegistry: ViewRegistry; constructor() { this.debuggerRegistry = new DebuggerRegistry() - this.viewRegistry = new ViewRegistry(this) + this.viewRegistry = new ViewRegistry(this) atom.commands.add('atom-text-editor', { 'debugger:start': () => { this.start() }, @@ -24,7 +24,7 @@ export default class DebuggerController { 'debugger:pause': () => { this.pause() }, 'debugger:step-into': () => { this.stepInto() }, 'debugger:step-over': () => { this.stepOver() }, - 'debugger:toggle-breakpoint-at-current-line': () => { this.toggleBreakpoint() } + 'debugger:toggle-breakpoint-at-current-line': () => { this.toggleBreakpoint() }, }) } @@ -33,7 +33,7 @@ export default class DebuggerController { } addView(view: DebuggerView): void { - this.viewRegistry.add(view); + this.viewRegistry.add(view) } deleteView(view: DebuggerView): void { @@ -42,46 +42,40 @@ export default class DebuggerController { /* Commands */ start(): void { - let proxy = this.debuggerRegistry.getDebuggerProxy() - let config + const proxy = this.debuggerRegistry.getDebuggerProxy() if (proxy.getActiveDebugger() != null) { - atom.notifications.addError( 'There is a session in progress. Please, exit first.') return } - config = new ProjectConfig() + const config = new ProjectConfig() config.tryLoad() if (!config.data) { - atom.notifications.addError('The project has no config.') return } if (!config.data.target) { - atom.notifications.addError('The project has no target set.') return } if (!config.data.debugger) { - atom.notifications.addError('The project has no debugger set.') return } const target = config.data.target - const debug = this.debuggerRegistry.get(config.data.debugger) + const debug = this.debuggerRegistry.get(config.data.debugger) if (!debug) { - atom.notifications.addFatalError('The debugger is unknown.') return @@ -117,14 +111,14 @@ export default class DebuggerController { return } - let breakpoint = new Breakpoint({ - filePath: activeEditor.getPath(), - bufferRow: activeEditor.getCursorBufferPosition().row + const breakpoint = new Breakpoint({ + filePath: activeEditor.getPath(), + bufferRow: activeEditor.getCursorBufferPosition().row, }) const debug = this.debuggerRegistry.getDebuggerProxy() - if (debug.removeBreakpoint(breakpoint) == false) { + if (debug.removeBreakpoint(breakpoint) === false) { debug.insertBreakpoint(breakpoint) } } diff --git a/lib/debugger-proxy.js b/lib/debugger-proxy.js index b8e968b..1442f8d 100644 --- a/lib/debugger-proxy.js +++ b/lib/debugger-proxy.js @@ -2,29 +2,30 @@ /* @flow */ -import Breakpoint from './breakpoint' -import BreakpointEvent from './breakpoint-event' -import SessionEvent from './session-event' -import TargetEvent from './target-event' +import { CompositeDisposable, Disposable, Emitter } from 'atom' +import _ from 'underscore-plus' -import type { BreakpointLocation } from './breakpoint' -import type { Debugger, DebuggerTarget } from './types' -import type { StackFrame } from './stack-frame' -import type { Variable } from './variable' +import Breakpoint from './breakpoint' +import BreakpointEvent from './breakpoint-event' +import SessionEvent from './session-event' +import TargetEvent from './target-event' + +import type { BreakpointLocation } from './breakpoint' +import type { Debugger, DebuggerTarget } from './types' +import type { StackFrame } from './stack-frame' +import type { Variable } from './variable' -import { CompositeDisposable, Disposable, Emitter } from 'atom' -import _ from 'underscore-plus' export default class DebuggerProxy { - emitter: Emitter; - breakpoints: Array; - activeDebugger: ?Debugger; + emitter: Emitter; + breakpoints: Array; + activeDebugger: ?Debugger; activeSubscriptions: CompositeDisposable; constructor() { - this.emitter = new Emitter() - this.breakpoints = [] - this.activeDebugger = null + this.emitter = new Emitter() + this.breakpoints = [] + this.activeDebugger = null this.activeSubscriptions = new CompositeDisposable() } @@ -33,22 +34,18 @@ export default class DebuggerProxy { } startSession(target: DebuggerTarget, debug: Debugger): void { - this.activeSubscriptions.add(debug.onBreakpointEvent(event => { - this.emitter.emit('breakpoint', event) - if (event.type == 'moved') { - + if (event.type === 'moved') { event.breakpoint.activeBufferRow = event.bufferRow } })) - this.activeSubscriptions.add(debug.onSessionEvent( (event) => { - + this.activeSubscriptions.add(debug.onSessionEvent((event) => { this.emitter.emit('session', event) - if (event.type != 'terminated') { + if (event.type !== 'terminated') { return } @@ -56,8 +53,7 @@ export default class DebuggerProxy { this.activeSubscriptions.dispose() this.activeSubscriptions = new CompositeDisposable() - for (let breakpoint of this.breakpoints) { - + for (const breakpoint of this.breakpoints) { if (!breakpoint.activeBufferRow) { continue } @@ -68,13 +64,13 @@ export default class DebuggerProxy { throw new Error('BreakpointLocation.bufferRow must be a number') } - let evt = new BreakpointEvent('moved', breakpoint, location.bufferRow) + const evt = new BreakpointEvent('moved', breakpoint, location.bufferRow) this.emitter.emit('breakpoint', evt) breakpoint.activeBufferRow = null } })) - this.activeSubscriptions.add(debug.onTargetEvent( (event) => { + this.activeSubscriptions.add(debug.onTargetEvent((event) => { this.emitter.emit('target', event) })) @@ -83,8 +79,7 @@ export default class DebuggerProxy { } insertBreakpoint(breakpoint: Breakpoint): boolean { - - if (_.find(this.breakpoints, (val) => { return breakpoint.equals(val) })) { + if (_.find(this.breakpoints, (val) => breakpoint.equals(val))) { return false } @@ -94,17 +89,15 @@ export default class DebuggerProxy { } findBreakpoint(location: BreakpointLocation): ?Breakpoint { - const breakpoint = new Breakpoint(location) - const comparator = (value) => { return value.isEqual(breakpoint) } + const comparator = (value) => value.isEqual(breakpoint) return _.find(this.breakpoints, comparator) } removeBreakpoint(breakpoint: Breakpoint): boolean { - - let comparator = (val) => { return breakpoint.equals(val) } - let entry = _.find(this.breakpoints, comparator) + const comparator = (val) => breakpoint.equals(val) + const entry = _.find(this.breakpoints, comparator) if (entry === undefined) { return false @@ -116,9 +109,8 @@ export default class DebuggerProxy { } enableBreakpoint(breakpoint: Breakpoint): boolean { - - let comparator = (val) => { return breakpoint.equals(val) } - let entry = _.find(this.breakpoints, comparator) + const comparator = (val) => breakpoint.equals(val) + const entry = _.find(this.breakpoints, comparator) if (entry === undefined || entry.isEnabled()) { return false @@ -130,11 +122,10 @@ export default class DebuggerProxy { } disableBreakpoint(breakpoint: Breakpoint): boolean { + const comparator = (val) => breakpoint.equals(val) + const entry = _.find(this.breakpoints, comparator) - let comparator = (val) => { return breakpoint.equals(val) } - let entry = _.find(this.breakpoints, comparator) - - if (entry === undefined || entry.isEnabled() == false) { + if (entry === undefined || entry.isEnabled() === false) { return false } @@ -144,9 +135,8 @@ export default class DebuggerProxy { } setBreakpointCondition(breakpoint: Breakpoint, condition: string): boolean { - - let comparator = (val) => { return breakpoint.equals(val) } - let entry = _.find(this.breakpoints, comparator) + const comparator = (val) => breakpoint.equals(val) + const entry = _.find(this.breakpoints, comparator) if (entry === undefined || (entry.condition && entry.condition === condition)) { @@ -159,25 +149,22 @@ export default class DebuggerProxy { } clearBreakpointCondition(breakpoint: Breakpoint): boolean { - - let comparator = (val) => { return breakpoint.equals(val) } - let entry = _.find(this.breakpoints, comparator) - let evt + const comparator = (val) => breakpoint.equals(val) + const entry = _.find(this.breakpoints, comparator) if (entry === undefined || !entry.condition) { return false } entry.condition = null - evt = new BreakpointEvent('condition-removed', entry) + const evt = new BreakpointEvent('condition-removed', entry) this.emitter.emit('breakpoint', evt) return true } stop(): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.stop() @@ -185,8 +172,7 @@ export default class DebuggerProxy { } resume(): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.resume() @@ -194,8 +180,7 @@ export default class DebuggerProxy { } pause(): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.pause() @@ -203,8 +188,7 @@ export default class DebuggerProxy { } stepInto(): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.stepInto() @@ -212,8 +196,7 @@ export default class DebuggerProxy { } stepOver(): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.stepOver() @@ -221,30 +204,27 @@ export default class DebuggerProxy { } getCallStack(): Promise> { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { return debug.getCallStack() } - throw Error("No Session in progress") + throw Error('No Session in progress') } getSelectedFrame(): Promise { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { return debug.getSelectedFrame() } - throw Error("No Session in progress") + throw Error('No Session in progress') } setSelectedFrame(level: number): void { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { debug.setSelectedFrame(level) @@ -252,14 +232,13 @@ export default class DebuggerProxy { } getVariableList(): Promise> { - - let debug = this.getActiveDebugger() + const debug = this.getActiveDebugger() if (debug) { return debug.getVariableList() } - throw Error("No Session in progress") + throw Error('No Session in progress') } onBreakpointEvent(callback: ((event: BreakpointEvent) => void)): Disposable { diff --git a/lib/debugger-registry.js b/lib/debugger-registry.js index 1b8f696..91e9a39 100644 --- a/lib/debugger-registry.js +++ b/lib/debugger-registry.js @@ -2,23 +2,21 @@ /* @flow */ -import Breakpoint from './breakpoint' -import DebuggerProxy from './debugger-proxy' -import type { Debugger } from './types' -import { CompositeDisposable, Disposable, Emitter } from 'atom' +import { CompositeDisposable, Emitter } from 'atom' +import DebuggerProxy from './debugger-proxy' +import type { Debugger } from './types' export default class DebuggerRegistry { - proxy: DebuggerProxy; + proxy: DebuggerProxy; subscriptions: CompositeDisposable; - emitter: Emitter; - debuggers: Set; + emitter: Emitter; + debuggers: Set; constructor() { - - this.proxy = new DebuggerProxy() + this.proxy = new DebuggerProxy() this.subscriptions = new CompositeDisposable() - this.emitter = new Emitter() - this.debuggers = new Set() + this.emitter = new Emitter() + this.debuggers = new Set() } dispose(): void { @@ -26,19 +24,16 @@ export default class DebuggerRegistry { } add(debug: Debugger): void { - this.debuggers.add(debug) } has(name: string): boolean { - if (!name) { return false } - for (let debug of this.debuggers.values()) { - - if (debug.name() == name) { + for (const debug of this.debuggers.values()) { + if (debug.name() === name) { return true } } @@ -47,9 +42,8 @@ export default class DebuggerRegistry { } get(name: string): Debugger { - - for (let debug of this.debuggers.values()) { - if (debug.name() == name) { + for (const debug of this.debuggers.values()) { + if (debug.name() === name) { return debug } } diff --git a/lib/main.js b/lib/main.js index 9186dc2..c0143eb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -2,14 +2,13 @@ /* @flow */ -import Breakpoint from './breakpoint' -import BreakpointEvent from './breakpoint-event' -import DebuggerController from './debugger-controller' -import SessionEvent from './session-event' -import TargetEvent from './target-event' -import VariableEvent from './variable-event' -import type { Debugger, DebuggerView } from './types' -import { Disposable } from 'atom' +import { Disposable } from 'atom' +import BreakpointEvent from './breakpoint-event' +import DebuggerController from './debugger-controller' +import SessionEvent from './session-event' +import TargetEvent from './target-event' +import VariableEvent from './variable-event' +import type { Debugger, DebuggerView } from './types' module.exports = { instance: DebuggerController, @@ -20,10 +19,10 @@ module.exports = { provideEventDefs(): Object { return { - 'BreakpointEvent': BreakpointEvent, - 'SessionEvent': SessionEvent, - 'TargetEvent': TargetEvent, - 'VariableEvent': VariableEvent + BreakpointEvent, + SessionEvent, + TargetEvent, + VariableEvent, } }, @@ -41,5 +40,5 @@ module.exports = { return new Disposable(() => { this.instance.deleteDebugger(debug) }) - } + }, } diff --git a/lib/project-config.js b/lib/project-config.js index 54aba7b..71f0c76 100644 --- a/lib/project-config.js +++ b/lib/project-config.js @@ -3,7 +3,7 @@ /* @flow */ import { File } from 'atom' -import CSON from 'season' +import CSON from 'season' export default class ProjectConfig { data: ?Object; @@ -13,7 +13,6 @@ export default class ProjectConfig { } tryLoad(): void { - const cfg = this.findConfigFile() if (!cfg) { @@ -30,22 +29,21 @@ export default class ProjectConfig { } findConfigFile(): ?File { - const activeEditor = atom.workspace.getActiveTextEditor() if (!activeEditor) { return null } - const activeFile = new File(activeEditor.getPath()) + const activeFile = new File(activeEditor.getPath()) const activeDirectories = atom.project.getDirectories().filter(directory => directory.contains(activeFile.getPath())) let path = activeFile + const matcher = (directory => directory.getPath() === path.getPath()) do { path = path.getParent() - let matcher = (directory => directory.getPath() === path.getPath()) if (activeDirectories.find(matcher)) { const configFile = path.getFile('.debugger.cson') diff --git a/lib/session-event.js b/lib/session-event.js index 1954357..d30e783 100644 --- a/lib/session-event.js +++ b/lib/session-event.js @@ -2,27 +2,24 @@ /* @flow */ -export type SessionEventType = 'launched' | 'will-terminate' | - 'terminated' | 'resumed' | 'suspended' +export type SessionEventType = 'launched' | 'will-terminate' | + 'terminated' | 'resumed' | 'suspended' export type SessionTerminationReason = 'normally' | 'interrupt' -export type SessionSuspensionReason = 'breakpoint' | 'step' +export type SessionSuspensionReason = 'breakpoint' | 'step' export type ExecutionLine = { filePath: string, bufferRow: number } export default class SessionEvent { - type: SessionEventType; - reason: SessionTerminationReason | SessionSuspensionReason; + type: SessionEventType; + reason: SessionTerminationReason | SessionSuspensionReason; executionLine: ExecutionLine; - constructor( - type: SessionEventType, - reason?: SessionTerminationReason | SessionSuspensionReason, - executionLine?: ExecutionLine) { - + constructor(type: SessionEventType, + reason?: SessionTerminationReason | SessionSuspensionReason, + executionLine?: ExecutionLine) { this.type = type - if (type == 'terminated' || type == 'suspended') { - + if (type === 'terminated' || type === 'suspended') { if (!reason && typeof reason !== 'string') { throw new Error('reason must be a string') } @@ -30,8 +27,7 @@ export default class SessionEvent { this.reason = reason } - if (type == 'suspended') { - + if (type === 'suspended') { if (!executionLine) { throw new Error('executionLine must be an ExecutionLine') } diff --git a/lib/target-event.js b/lib/target-event.js index 48c26ba..631aff9 100644 --- a/lib/target-event.js +++ b/lib/target-event.js @@ -5,12 +5,11 @@ export type TargetEventType = 'output' export default class TargetEvent { - type: TargetEventType; - message: string; + type:TargetEventType; + message: string; - constructor(type: TargetEventType, message: string) { - - this.type = type + constructor(type: TargetEventType, message: string) { + this.type = type this.message = message } } diff --git a/lib/types.js b/lib/types.js index dec92de..20f3097 100644 --- a/lib/types.js +++ b/lib/types.js @@ -4,11 +4,11 @@ import type { Disposable } from 'atom' -import DebuggerController from './debugger-controller' -import Breakpoint from './breakpoint' +import DebuggerController from './debugger-controller' +import Breakpoint from './breakpoint' import type { StackFrame } from './stack-frame' -import type { Variable } from './variable' +import type { Variable } from './variable' export type DebuggerTarget = { filePath: string, diff --git a/lib/variable-event.js b/lib/variable-event.js index 78047e1..d065239 100644 --- a/lib/variable-event.js +++ b/lib/variable-event.js @@ -7,11 +7,11 @@ import type { Variable } from './variable' export type VariableEventType = 'updated' | 'left-scope' | 'entered-scope' export default class VariableEvent { - type: VariableEventType; + type: VariableEventType; variable: Variable; constructor(type: VariableEventType, variable: Variable) { - this.type = type + this.type = type this.variable = variable } } diff --git a/lib/view-registry.js b/lib/view-registry.js index 5abb755..22da696 100644 --- a/lib/view-registry.js +++ b/lib/view-registry.js @@ -2,23 +2,22 @@ /* @flow */ -import DebuggerController from './debugger-controller' -import type { DebuggerView } from './types' import { CompositeDisposable } from 'atom' +import DebuggerController from './debugger-controller' +import type { DebuggerView } from './types' export default class ViewRegistry { - controller: DebuggerController; - providers: Set; + controller: DebuggerController; + providers: Set; subscriptions: CompositeDisposable; constructor(controller: DebuggerController) { - this.controller = controller; - this.providers = new Set() + this.controller = controller + this.providers = new Set() this.subscriptions = new CompositeDisposable() } add(view: DebuggerView) { - if (this.providers.has(view)) { return } @@ -29,7 +28,6 @@ export default class ViewRegistry { } delete(view: DebuggerView): boolean { - if (!this.providers.has(view)) { return false }