Skip to content

Commit

Permalink
Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmcmullin committed Nov 22, 2016
1 parent fd5d0b0 commit e9026be
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 184 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
decls
spec
19 changes: 9 additions & 10 deletions lib/breakpoint-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
24 changes: 10 additions & 14 deletions lib/breakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
}
}
Expand All @@ -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 '?'
Expand Down
36 changes: 15 additions & 21 deletions lib/debugger-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
Expand All @@ -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() },
})
}

Expand All @@ -33,7 +33,7 @@ export default class DebuggerController {
}

addView(view: DebuggerView): void {
this.viewRegistry.add(view);
this.viewRegistry.add(view)
}

deleteView(view: DebuggerView): void {
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
Loading

0 comments on commit e9026be

Please sign in to comment.