diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4cca95b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +decls +spec diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..39b031d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "extends": "steelbrain", + "rules": { + "no-param-reassign": "off", + "no-duplicate-imports": "off", + "import/prefer-default-export": "off" + } +} diff --git a/.flowconfig b/.flowconfig index c1450b9..b1246b8 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,21 +1,18 @@ [ignore] -node_modules/**/.* [include] [libs] -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 +decls +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/.gitignore b/.gitignore index 3c3629e..fd4f2b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.DS_Store 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 diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..af3af9f --- /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 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; 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 17e349d..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) { @@ -24,28 +23,27 @@ 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 } } 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 73096a8..20f3097 100644 --- a/lib/types.js +++ b/lib/types.js @@ -2,11 +2,13 @@ /* @flow */ -import DebuggerController from './debugger-controller' -import Breakpoint from './breakpoint' +import type { Disposable } from 'atom' + +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, @@ -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..d065239 100644 --- a/lib/variable-event.js +++ b/lib/variable-event.js @@ -2,16 +2,16 @@ /* @flow */ -import Variable from './variable' +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 } diff --git a/package.json b/package.json index c0e129c..ebc37aa 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,19 @@ "engines": { "atom": ">=1.0.0 <2.0.0" }, + "scripts": { + "test": "(apm test) && (flow check) && (eslint . )" + }, "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" + "@flow-atom/atom": "^1.8.0-rev.0", + "eslint-config-steelbrain": "^1.0.4", + "flow-bin": "^0.30.0", + "jasmine-fix": "^1.0.1" }, "package-deps": [ "debugger-ui-default" 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)