From 2c09301c5382ffff4b7a4207d523dc18c3a5abac Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:31:46 -0700 Subject: [PATCH 01/21] :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..6a54667 --- /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 run build + +test: + override: + - npm test + +machine: + node: + version: 6.3.0 From 469a11deaddd0b89a07fa7699b35a8eacff698d1 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:31:56 -0700 Subject: [PATCH 02/21] :new: Add scripts and devDeps --- package.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 32704dd..0eb8a38 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.0.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 2d9d2990daef3ae39c235b2fa9e013c623860caa Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:11 -0700 Subject: [PATCH 03/21] :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 df8b303b70635b8d0cdf5c1f8491a687421a1fff Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:43 -0700 Subject: [PATCH 04/21] :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 931f9205048fdfa556a76df4e62a336d9f9abcc5 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:32:52 -0700 Subject: [PATCH 05/21] :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 e0af173d33f757433bd9f492a0d6dc84fd60c4c4 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:33:13 -0700 Subject: [PATCH 06/21] :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 84bcfff05e0ebb496573383da5bc5f1a2cce8c61 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 22 Aug 2016 03:33:30 -0700 Subject: [PATCH 07/21] :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 07096d9436ca0e552e650e356b1faf7f226c7d59 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 01:08:55 -0700 Subject: [PATCH 08/21] :minibus: main -> index --- lib/{main.js => index.js} | 0 package.json | 7 ++----- 2 files changed, 2 insertions(+), 5 deletions(-) rename lib/{main.js => index.js} (100%) diff --git a/lib/main.js b/lib/index.js similarity index 100% rename from lib/main.js rename to lib/index.js diff --git a/package.json b/package.json index 0eb8a38..bb2e553 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debugger", - "main": "./lib/main", + "main": "./lib/index", "author": "philippvr", "version": "0.0.0", "license": "MIT", @@ -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 | grep -q '0 errors') && (eslint . )" }, "dependencies": { "atom-package-deps": "^4.0.0", From 9998b37f1f13fcf0f338d92fb82751fa50f90bb7 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 01:09:20 -0700 Subject: [PATCH 09/21] :arrow_up: Bump dep versions --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb2e553..8d66f26 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "devDependencies": { "eslint-config-steelbrain": "^1.0.4", "flow-atom-api": "https://github.com/flow-atom/flow-atom-api.git", - "flow-bin": "^0.30.0", + "flow-bin": "^0.31.1", "jasmine-fix": "^1.0.1" }, "package-deps": [ From fe5f264cdf209b9827c38794f3abaf40fe8bec98 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 01:27:12 -0700 Subject: [PATCH 10/21] :new: Run atom-package-deps properly --- lib/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/index.js b/lib/index.js index 9311078..3545654 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,6 +15,7 @@ module.exports = { activate(): void { this.instance = new DebuggerController() + require('atom-package-deps').install('debugger') // eslint-disable-line }, provideEventDefs(): Object { From e251402611f1ee55a85a7ed8c94898d9b2836535 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 01:29:05 -0700 Subject: [PATCH 11/21] :art: Update author in manifest --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d66f26..10926c0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "debugger", "main": "./lib/index", - "author": "philippvr", + "author": "AtomDebugger", "version": "0.0.0", "license": "MIT", "engines": { From e8926966ce937ec7f9cb528795c7dc8da8b953f2 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 01:30:56 -0700 Subject: [PATCH 12/21] :minibus: debugger-event-defs -> debugger-event-definitions --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10926c0..b81bd5b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "debugger-ui-default" ], "providedServices": { - "debugger-event-defs": { + "debugger-event-definitions": { "versions": { "0.1.0": "provideEventDefs" } From e4d9c0937138b0187a03502c626f58654557c5a6 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 02:35:50 -0700 Subject: [PATCH 13/21] :minibus: lib -> lib-old --- {lib => lib-old}/breakpoint-event.js | 0 {lib => lib-old}/breakpoint.js | 0 {lib => lib-old}/debugger-controller.js | 0 {lib => lib-old}/debugger-proxy.js | 0 {lib => lib-old}/debugger-registry.js | 0 {lib => lib-old}/index.js | 0 {lib => lib-old}/project-config.js | 0 {lib => lib-old}/session-event.js | 0 {lib => lib-old}/stack-frame.js | 0 {lib => lib-old}/target-event.js | 0 {lib => lib-old}/types.js | 0 {lib => lib-old}/variable.js | 0 {lib => lib-old}/view-registry.js | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename {lib => lib-old}/breakpoint-event.js (100%) rename {lib => lib-old}/breakpoint.js (100%) rename {lib => lib-old}/debugger-controller.js (100%) rename {lib => lib-old}/debugger-proxy.js (100%) rename {lib => lib-old}/debugger-registry.js (100%) rename {lib => lib-old}/index.js (100%) rename {lib => lib-old}/project-config.js (100%) rename {lib => lib-old}/session-event.js (100%) rename {lib => lib-old}/stack-frame.js (100%) rename {lib => lib-old}/target-event.js (100%) rename {lib => lib-old}/types.js (100%) rename {lib => lib-old}/variable.js (100%) rename {lib => lib-old}/view-registry.js (100%) diff --git a/lib/breakpoint-event.js b/lib-old/breakpoint-event.js similarity index 100% rename from lib/breakpoint-event.js rename to lib-old/breakpoint-event.js diff --git a/lib/breakpoint.js b/lib-old/breakpoint.js similarity index 100% rename from lib/breakpoint.js rename to lib-old/breakpoint.js diff --git a/lib/debugger-controller.js b/lib-old/debugger-controller.js similarity index 100% rename from lib/debugger-controller.js rename to lib-old/debugger-controller.js diff --git a/lib/debugger-proxy.js b/lib-old/debugger-proxy.js similarity index 100% rename from lib/debugger-proxy.js rename to lib-old/debugger-proxy.js diff --git a/lib/debugger-registry.js b/lib-old/debugger-registry.js similarity index 100% rename from lib/debugger-registry.js rename to lib-old/debugger-registry.js diff --git a/lib/index.js b/lib-old/index.js similarity index 100% rename from lib/index.js rename to lib-old/index.js diff --git a/lib/project-config.js b/lib-old/project-config.js similarity index 100% rename from lib/project-config.js rename to lib-old/project-config.js diff --git a/lib/session-event.js b/lib-old/session-event.js similarity index 100% rename from lib/session-event.js rename to lib-old/session-event.js diff --git a/lib/stack-frame.js b/lib-old/stack-frame.js similarity index 100% rename from lib/stack-frame.js rename to lib-old/stack-frame.js diff --git a/lib/target-event.js b/lib-old/target-event.js similarity index 100% rename from lib/target-event.js rename to lib-old/target-event.js diff --git a/lib/types.js b/lib-old/types.js similarity index 100% rename from lib/types.js rename to lib-old/types.js diff --git a/lib/variable.js b/lib-old/variable.js similarity index 100% rename from lib/variable.js rename to lib-old/variable.js diff --git a/lib/view-registry.js b/lib-old/view-registry.js similarity index 100% rename from lib/view-registry.js rename to lib-old/view-registry.js From fbf1189566a680cee9f890c4defb7e4c7890f6b9 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 02:51:12 -0700 Subject: [PATCH 14/21] :new: Add new package structure --- .eslintrc.json | 5 ++++- decls/atom.js | 24 ++++++++++++++---------- lib/commands.js | 17 +++++++++++++++++ lib/editor.js | 26 ++++++++++++++++++++++++++ lib/editors.js | 40 ++++++++++++++++++++++++++++++++++++++++ lib/index.js | 15 +++++++++++++++ lib/main.js | 28 ++++++++++++++++++++++++++++ package.json | 13 ++++--------- 8 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 lib/commands.js create mode 100644 lib/editor.js create mode 100644 lib/editors.js create mode 100644 lib/index.js create mode 100644 lib/main.js diff --git a/.eslintrc.json b/.eslintrc.json index c755460..e6a4085 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { - "extends": "steelbrain" + "extends": "steelbrain", + "rules": { + "no-duplicate-imports": 0 + } } diff --git a/decls/atom.js b/decls/atom.js index d9d0dea..92d2910 100644 --- a/decls/atom.js +++ b/decls/atom.js @@ -1,12 +1,16 @@ -import { File } from 'sig/1.7.4/File' -import { CompositeDisposable, Disposable, Emitter } from 'event-kit' +/* @flow */ -declare module atom { - - declare var exports: { - File: File, - CompositeDisposable: CompositeDisposable, - Disposable: Disposable, - Emitter: Emitter - }; +declare var atom: Object; +declare module 'atom' { + declare var Point: any; + declare var Range: any; + declare var Panel: any; + declare var TextEditor: any; + declare var TextBuffer: any; + declare var BufferMarker: any; + declare var TextEditorGutter: any; + declare var TextEditorMarker: any; + declare var CompositeDisposable: any; + declare var Disposable: any; + declare var Emitter: any; } diff --git a/lib/commands.js b/lib/commands.js new file mode 100644 index 0000000..f8e46fc --- /dev/null +++ b/lib/commands.js @@ -0,0 +1,17 @@ +/* @flow */ + +import { CompositeDisposable } from 'atom' + +export default class Commands { + subscriptions: CompositeDisposable; + + constructor() { + this.subscriptions = new CompositeDisposable() + } + activate() { + console.log('listen for commands here') + } + dispose() { + this.subscriptions.dispose() + } +} diff --git a/lib/editor.js b/lib/editor.js new file mode 100644 index 0000000..8765926 --- /dev/null +++ b/lib/editor.js @@ -0,0 +1,26 @@ +/* @flow */ + +import { CompositeDisposable, Disposable } from 'atom' +import type { TextEditor } from 'atom' + +export default class Editor { + textEditor: TextEditor; + subscriptions: CompositeDisposable; + + constructor(textEditor: TextEditor) { + this.textEditor = textEditor + this.subscriptions = new CompositeDisposable() + } + onDidDestroy(callback: (() => any)): Disposable { + const subscription = this.textEditor.onDidDestroy(callback) + const disposable = new Disposable(() => { + subscription.dispose() + this.subscriptions.remove(disposable) + }) + this.subscriptions.add(disposable) + return disposable + } + dispose() { + this.subscriptions.dispose() + } +} diff --git a/lib/editors.js b/lib/editors.js new file mode 100644 index 0000000..0403ed3 --- /dev/null +++ b/lib/editors.js @@ -0,0 +1,40 @@ +/* @flow */ + +import { CompositeDisposable, Emitter } from 'atom' +import type { Disposable, TextEditor } from 'atom' + +import Editor from './editor' + +export default class Editors { + emitter: Emitter; + editors: Map; + subscriptions: CompositeDisposable; + + constructor() { + this.emitter = new Emitter() + this.editors = new Map() + this.subscriptions = new CompositeDisposable() + + this.subscriptions.add(this.emitter) + } + activate() { + this.subscriptions.add(atom.workspace.observeTextEditors(textEditor => { + const editor = new Editor(textEditor) + this.editors.set(textEditor, editor) + this.emitter.emit('observe', editor) + editor.onDidDestroy(() => { + this.editors.delete(textEditor) + }) + })) + } + observe(callback: ((editor: Editor) => any)): Disposable { + this.editors.forEach(callback) + return this.emitter.on('observe', callback) + } + dispose() { + for (const editor of this.editors.values()) { + editor.dispose() + } + this.subscriptions.dispose() + } +} diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..0ab4220 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,15 @@ +/* @flow */ + +import AtomDebugger from './main' + +export default { + instance: null, + activate() { + require('atom-package-deps').install('debugger') // eslint-disable-line + this.instance = new AtomDebugger() + this.instance.activate() + }, + deactivate() { + this.instance.dispose() + }, +} diff --git a/lib/main.js b/lib/main.js new file mode 100644 index 0000000..fa2f5a8 --- /dev/null +++ b/lib/main.js @@ -0,0 +1,28 @@ +/* @flow */ + +import { CompositeDisposable } from 'atom' + +import Editors from './editors' +import Commands from './commands' + +export default class AtomDebugger { + editors: Editors; + commands: Commands; + subscriptions: CompositeDisposable; + + constructor() { + this.editors = new Editors() + this.commands = new Commands() + this.subscriptions = new CompositeDisposable() + + this.subscriptions.add(this.editors) + this.subscriptions.add(this.commands) + } + activate() { + this.editors.activate() + this.commands.activate() + } + dispose() { + this.subscriptions.dispose() + } +} diff --git a/package.json b/package.json index b81bd5b..8d17b58 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "version": "0.0.0", "license": "MIT", "engines": { - "atom": ">=1.0.0 <2.0.0" + "atom": ">=1.9.0 <2.0.0" }, "scripts": { "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )" @@ -25,21 +25,16 @@ "debugger-ui-default" ], "providedServices": { - "debugger-event-definitions": { + "debugger": { "versions": { - "0.1.0": "provideEventDefs" + "1.0.0": "provideDebuggerRegistry" } } }, "consumedServices": { "debugger-ui": { "versions": { - "^0.1.0": "consumeView" - } - }, - "debugger": { - "versions": { - "^0.1.0": "consumeDebugger" + "^1.0.0": "consumeView" } } } From 21cdfa777afcdc77e7c08f61575ce51507d5b8d5 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 22:23:17 -0700 Subject: [PATCH 15/21] :new: Add more structure stuff --- lib/commands.js | 27 ++++++++++++++++++++++++++- lib/debugger-delegate.js | 31 +++++++++++++++++++++++++++++++ lib/debugger-registry.js | 37 +++++++++++++++++++++++++++++++++++++ lib/editors.js | 3 +++ lib/index.js | 3 +++ lib/main.js | 4 ++++ lib/types.js | 10 ++++++++++ lib/validate/debugger.js | 5 +++++ 8 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 lib/debugger-delegate.js create mode 100644 lib/debugger-registry.js create mode 100644 lib/types.js create mode 100644 lib/validate/debugger.js diff --git a/lib/commands.js b/lib/commands.js index f8e46fc..849d7ea 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -1,17 +1,42 @@ /* @flow */ import { CompositeDisposable } from 'atom' +import type DebuggerDelegate from './debugger-delegate' export default class Commands { + active: ?DebuggerDelegate; subscriptions: CompositeDisposable; constructor() { + this.active = null this.subscriptions = new CompositeDisposable() } activate() { - console.log('listen for commands here') + this.subscriptions.add(atom.commands.add('atom-text-editor:no([mini])', { + 'debugger:start': () => this.start(), + 'debugger:stop': () => this.stop(), + 'debugger:resume': 'resume', + 'debugger:pause': 'pause', + 'debugger:step-into': 'stepInto', + 'debugger:step-over': 'stepOver', + 'debugger:toggle-breakpoint-at-current-line': 'toggleBreakpointAtCurrentLine', + })) + } + async start() { + if (this.active !== null) { + return + } + } + stop() { + const active = this.active + if (active === null) { + return + } } dispose() { + if (this.active) { + this.stop() + } this.subscriptions.dispose() } } diff --git a/lib/debugger-delegate.js b/lib/debugger-delegate.js new file mode 100644 index 0000000..513757d --- /dev/null +++ b/lib/debugger-delegate.js @@ -0,0 +1,31 @@ +/* @flow */ + +import { Emitter, CompositeDisposable } from 'atom' +import type { Debugger } from './types' + +export default class DebuggerDelegate { + emitter: Emitter; + provider: Debugger; + subscriptions: CompositeDisposable; + + constructor(provider: Debugger) { + this.provider = provider + this.emitter = new Emitter() + this.subscriptions = new CompositeDisposable() + + this.subscriptions.add(this.emitter) + } + get(): Debugger { + return this.provider + } + onDidDestroy(callback: (() => any)) { + return this.emitter.on('did-destroy', callback) + } + dispose() { + if (this.subscriptions.isDisposed()) { + return + } + this.emitter.emit('did-destroy') + this.subscriptions.dispose() + } +} diff --git a/lib/debugger-registry.js b/lib/debugger-registry.js new file mode 100644 index 0000000..3c3bdc9 --- /dev/null +++ b/lib/debugger-registry.js @@ -0,0 +1,37 @@ +/* @flow */ + +import { CompositeDisposable } from 'atom' + +import DebuggerDelegate from './debugger-delegate' +import validateDebugger from './validate/debugger' +import type { Debugger } from './types' + +export default class DebuggerRegistry { + debuggers: Set; + subscriptions: CompositeDisposable; + + constructor() { + this.debuggers = new Set() + this.subscriptions = new CompositeDisposable() + } + register(debugProvider: Debugger): DebuggerDelegate { + if (validateDebugger(debugProvider)) { + throw new Error('Invalid debugger provided') + } + const delegate = new DebuggerDelegate(debugProvider) + this.debuggers.add(delegate) + delegate.onDidDestroy(() => { + this.debuggers.delete(delegate) + }) + return delegate + } + forEach(callback: ((delegate: DebuggerDelegate) => any)) { + this.debuggers.forEach(callback) + } + dispose() { + for (const delegate of this.debuggers) { + delegate.dispose() + } + this.subscriptions.dispose() + } +} diff --git a/lib/editors.js b/lib/editors.js index 0403ed3..39fa030 100644 --- a/lib/editors.js +++ b/lib/editors.js @@ -27,6 +27,9 @@ export default class Editors { }) })) } + get(textEditor: TextEditor): ?Editor { + return this.editors.get(textEditor) + } observe(callback: ((editor: Editor) => any)): Disposable { this.editors.forEach(callback) return this.emitter.on('observe', callback) diff --git a/lib/index.js b/lib/index.js index 0ab4220..a457095 100644 --- a/lib/index.js +++ b/lib/index.js @@ -9,6 +9,9 @@ export default { this.instance = new AtomDebugger() this.instance.activate() }, + provideDebuggerRegistry() { + return this.instance.debuggerRegistry + }, deactivate() { this.instance.dispose() }, diff --git a/lib/main.js b/lib/main.js index fa2f5a8..00b9a44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,19 +4,23 @@ import { CompositeDisposable } from 'atom' import Editors from './editors' import Commands from './commands' +import DebuggerRegistry from './debugger-registry' export default class AtomDebugger { editors: Editors; commands: Commands; + debuggerRegistry: DebuggerRegistry; subscriptions: CompositeDisposable; constructor() { this.editors = new Editors() this.commands = new Commands() + this.debuggerRegistry = new DebuggerRegistry() this.subscriptions = new CompositeDisposable() this.subscriptions.add(this.editors) this.subscriptions.add(this.commands) + this.subscriptions.add(this.debuggerRegistry) } activate() { this.editors.activate() diff --git a/lib/types.js b/lib/types.js new file mode 100644 index 0000000..b609fb7 --- /dev/null +++ b/lib/types.js @@ -0,0 +1,10 @@ +/* @flow */ + +export type Debugger = { + name: string, + grammarScopes: Array, +} + +export type Breakpoint = { + +} diff --git a/lib/validate/debugger.js b/lib/validate/debugger.js new file mode 100644 index 0000000..c5c8c75 --- /dev/null +++ b/lib/validate/debugger.js @@ -0,0 +1,5 @@ +/* @flow */ + +export default function validateDebugger() { + +} From 9cdd4cd88ba8bc2699acffa8e1d3f8b68e95f2c7 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 22:23:32 -0700 Subject: [PATCH 16/21] :fire: Cleanup manifest and dot files --- .eslintrc.json | 3 ++- .flowconfig | 13 ------------- package.json | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e6a4085..c65151c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "extends": "steelbrain", "rules": { - "no-duplicate-imports": 0 + "no-duplicate-imports": 0, + "import/prefer-default-export": 0 } } diff --git a/.flowconfig b/.flowconfig index e243807..6c667b9 100644 --- a/.flowconfig +++ b/.flowconfig @@ -4,19 +4,6 @@ [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 [options] module.system=node diff --git a/package.json b/package.json index 8d17b58..6142a70 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ }, "devDependencies": { "eslint-config-steelbrain": "^1.0.4", - "flow-atom-api": "https://github.com/flow-atom/flow-atom-api.git", "flow-bin": "^0.31.1", "jasmine-fix": "^1.0.1" }, From 08f8f172e87be107bfa010eba555ecaaa46113f5 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 22:27:08 -0700 Subject: [PATCH 17/21] :no_entry: Disallow publishing to npm registry --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 6142a70..1f3a7c7 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "author": "AtomDebugger", "version": "0.0.0", "license": "MIT", + "private": true, "engines": { "atom": ">=1.9.0 <2.0.0" }, From f6a296aedf1b8de902e2706976f15fbd48008ddb Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Fri, 26 Aug 2016 22:29:04 -0700 Subject: [PATCH 18/21] :fire: Cleanup manifest and commands --- lib/commands.js | 12 ++++++------ package.json | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/commands.js b/lib/commands.js index 849d7ea..7e5b108 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -12,14 +12,14 @@ export default class Commands { this.subscriptions = new CompositeDisposable() } activate() { - this.subscriptions.add(atom.commands.add('atom-text-editor:no([mini])', { + this.subscriptions.add(atom.commands.add('atom-text-editor:not([mini])', { 'debugger:start': () => this.start(), 'debugger:stop': () => this.stop(), - 'debugger:resume': 'resume', - 'debugger:pause': 'pause', - 'debugger:step-into': 'stepInto', - 'debugger:step-over': 'stepOver', - 'debugger:toggle-breakpoint-at-current-line': 'toggleBreakpointAtCurrentLine', + // 'debugger:resume': 'resume', + // 'debugger:pause': 'pause', + // 'debugger:step-into': 'stepInto', + // 'debugger:step-over': 'stepOver', + // 'debugger:toggle-breakpoint-at-current-line': 'toggleBreakpointAtCurrentLine', })) } async start() { diff --git a/package.json b/package.json index 1f3a7c7..98d20ee 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,7 @@ "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )" }, "dependencies": { - "atom-package-deps": "^4.0.0", - "season": "^5.2.0", - "underscore-plus": "^1.0.0" + "atom-package-deps": "^4.0.0" }, "devDependencies": { "eslint-config-steelbrain": "^1.0.4", From 1cbbe88c8e169f5690bad7c455cea50525d33bd7 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Sat, 27 Aug 2016 01:13:52 -0700 Subject: [PATCH 19/21] :new: Make basic commands work --- .eslintrc.json | 1 + circle.yml | 1 - lib/commands.js | 31 ++++++++++++++++--- ...ugger-registry.js => delegate-registry.js} | 17 +++++----- lib/{debugger-delegate.js => delegate.js} | 0 lib/index.js | 2 +- lib/main.js | 16 +++++++--- package.json | 4 +++ 8 files changed, 51 insertions(+), 21 deletions(-) rename lib/{debugger-registry.js => delegate-registry.js} (62%) rename lib/{debugger-delegate.js => delegate.js} (100%) diff --git a/.eslintrc.json b/.eslintrc.json index c65151c..9ab6a02 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "extends": "steelbrain", "rules": { + "no-param-reassign": 0, "no-duplicate-imports": 0, "import/prefer-default-export": 0 } diff --git a/circle.yml b/circle.yml index 6a54667..f309cc0 100644 --- a/circle.yml +++ b/circle.yml @@ -10,7 +10,6 @@ dependencies: - npm prune - npm install - apm rebuild - - npm run build test: override: diff --git a/lib/commands.js b/lib/commands.js index 7e5b108..ee92483 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -1,15 +1,19 @@ /* @flow */ -import { CompositeDisposable } from 'atom' -import type DebuggerDelegate from './debugger-delegate' +import { CompositeDisposable, Emitter } from 'atom' +import type DebuggerDelegate from './delegate' export default class Commands { active: ?DebuggerDelegate; + emitter: Emitter; subscriptions: CompositeDisposable; constructor() { this.active = null + this.emitter = new Emitter() this.subscriptions = new CompositeDisposable() + + this.subscriptions.add(this.emitter) } activate() { this.subscriptions.add(atom.commands.add('atom-text-editor:not([mini])', { @@ -22,16 +26,33 @@ export default class Commands { // 'debugger:toggle-breakpoint-at-current-line': 'toggleBreakpointAtCurrentLine', })) } - async start() { - if (this.active !== null) { + start() { + if (this.active) { + return + } + const delegate = this.requestDelegate() + if (!delegate) { return } + this.active = delegate + this.active.get().start() } stop() { const active = this.active - if (active === null) { + if (!active) { return } + active.get().stop() + } + requestDelegate(): ?DebuggerDelegate { + const event = { delegate: null } + this.emitter.emit('request-delegate', event) + return event.delegate + } + onShouldProvideDelegate(callback: (() => ?DebuggerDelegate)): void { + this.emitter.on('request-delegate', function(event) { + event.delegate = event.delegate || callback() + }) } dispose() { if (this.active) { diff --git a/lib/debugger-registry.js b/lib/delegate-registry.js similarity index 62% rename from lib/debugger-registry.js rename to lib/delegate-registry.js index 3c3bdc9..14b4cba 100644 --- a/lib/debugger-registry.js +++ b/lib/delegate-registry.js @@ -2,16 +2,16 @@ import { CompositeDisposable } from 'atom' -import DebuggerDelegate from './debugger-delegate' +import DebuggerDelegate from './delegate' import validateDebugger from './validate/debugger' import type { Debugger } from './types' -export default class DebuggerRegistry { - debuggers: Set; +export default class DelegateRegistry { + delegates: Set; subscriptions: CompositeDisposable; constructor() { - this.debuggers = new Set() + this.delegates = new Set() this.subscriptions = new CompositeDisposable() } register(debugProvider: Debugger): DebuggerDelegate { @@ -19,17 +19,14 @@ export default class DebuggerRegistry { throw new Error('Invalid debugger provided') } const delegate = new DebuggerDelegate(debugProvider) - this.debuggers.add(delegate) + this.delegates.add(delegate) delegate.onDidDestroy(() => { - this.debuggers.delete(delegate) + this.delegates.delete(delegate) }) return delegate } - forEach(callback: ((delegate: DebuggerDelegate) => any)) { - this.debuggers.forEach(callback) - } dispose() { - for (const delegate of this.debuggers) { + for (const delegate of this.delegates) { delegate.dispose() } this.subscriptions.dispose() diff --git a/lib/debugger-delegate.js b/lib/delegate.js similarity index 100% rename from lib/debugger-delegate.js rename to lib/delegate.js diff --git a/lib/index.js b/lib/index.js index a457095..cc367d9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,7 @@ export default { this.instance.activate() }, provideDebuggerRegistry() { - return this.instance.debuggerRegistry + return this.instance.delegateRegistry }, deactivate() { this.instance.dispose() diff --git a/lib/main.js b/lib/main.js index 00b9a44..6b0a651 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,23 +4,31 @@ import { CompositeDisposable } from 'atom' import Editors from './editors' import Commands from './commands' -import DebuggerRegistry from './debugger-registry' +import DelegateRegistry from './delegate-registry' export default class AtomDebugger { editors: Editors; commands: Commands; - debuggerRegistry: DebuggerRegistry; + delegateRegistry: DelegateRegistry; subscriptions: CompositeDisposable; constructor() { this.editors = new Editors() this.commands = new Commands() - this.debuggerRegistry = new DebuggerRegistry() + this.delegateRegistry = new DelegateRegistry() this.subscriptions = new CompositeDisposable() this.subscriptions.add(this.editors) this.subscriptions.add(this.commands) - this.subscriptions.add(this.debuggerRegistry) + this.subscriptions.add(this.delegateRegistry) + + this.commands.onShouldProvideDelegate(() => { + // TODO: Have a good way to choose between the delegate + for (const delegate of this.delegateRegistry.delegates) { + return delegate + } + return null + }) } activate() { this.editors.activate() diff --git a/package.json b/package.json index 98d20ee..6cb811a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "scripts": { "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )" }, + "keywords": [ + "debugger" + ], + "description": "Base debugger with Cow Powers", "dependencies": { "atom-package-deps": "^4.0.0" }, From 15ba1492f4fe7ab543acc0fca169689488de9373 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Sat, 27 Aug 2016 03:12:13 -0700 Subject: [PATCH 20/21] :new: Connect wires with UI Registry --- lib/commands.js | 21 +++++++++++---------- lib/delegate.js | 8 ++++++++ lib/index.js | 13 +++++++++++++ lib/main.js | 14 ++++++++++++-- lib/types.js | 11 +++++++++-- lib/ui-registry.js | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 7 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 lib/ui-registry.js diff --git a/lib/commands.js b/lib/commands.js index ee92483..dbb3295 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -19,11 +19,6 @@ export default class Commands { this.subscriptions.add(atom.commands.add('atom-text-editor:not([mini])', { 'debugger:start': () => this.start(), 'debugger:stop': () => this.stop(), - // 'debugger:resume': 'resume', - // 'debugger:pause': 'pause', - // 'debugger:step-into': 'stepInto', - // 'debugger:step-over': 'stepOver', - // 'debugger:toggle-breakpoint-at-current-line': 'toggleBreakpointAtCurrentLine', })) } start() { @@ -35,14 +30,14 @@ export default class Commands { return } this.active = delegate - this.active.get().start() + this.active.start() } stop() { - const active = this.active - if (!active) { - return + if (this.active) { + this.active.stop() + this.emitter.emit('did-stop', this.active) + this.active = null } - active.get().stop() } requestDelegate(): ?DebuggerDelegate { const event = { delegate: null } @@ -54,6 +49,12 @@ export default class Commands { event.delegate = event.delegate || callback() }) } + onDidStart(callback: ((delegate: DebuggerDelegate) => any)): void { + this.emitter.on('did-start', callback) + } + onDidStop(callback: ((delegate: DebuggerDelegate) => any)): void { + this.emitter.on('did-stop', callback) + } dispose() { if (this.active) { this.stop() diff --git a/lib/delegate.js b/lib/delegate.js index 513757d..0c375cc 100644 --- a/lib/delegate.js +++ b/lib/delegate.js @@ -18,6 +18,14 @@ export default class DebuggerDelegate { get(): Debugger { return this.provider } + // Real stuff -- starts + start() { + console.log('start debugger') + } + stop() { + console.log('stop debugger') + } + // Real stuff -- ends onDidDestroy(callback: (() => any)) { return this.emitter.on('did-destroy', callback) } diff --git a/lib/index.js b/lib/index.js index cc367d9..a36a732 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,8 @@ /* @flow */ +import { Disposable } from 'atom' import AtomDebugger from './main' +import type { UI } from './types' export default { instance: null, @@ -12,6 +14,17 @@ export default { provideDebuggerRegistry() { return this.instance.delegateRegistry }, + consumeUI(ui: UI | Array): Disposable { + const uis = [].concat(ui) + uis.forEach(entry => { + this.instance.uiRegistry.add(entry) + }) + return new Disposable(() => { + uis.forEach(entry => { + this.instance.uiRegistry.delete(entry) + }) + }) + }, deactivate() { this.instance.dispose() }, diff --git a/lib/main.js b/lib/main.js index 6b0a651..ccbe52b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,22 +4,26 @@ import { CompositeDisposable } from 'atom' import Editors from './editors' import Commands from './commands' +import UIRegistry from './ui-registry' import DelegateRegistry from './delegate-registry' export default class AtomDebugger { editors: Editors; commands: Commands; - delegateRegistry: DelegateRegistry; + uiRegistry: UIRegistry; subscriptions: CompositeDisposable; + delegateRegistry: DelegateRegistry; constructor() { this.editors = new Editors() this.commands = new Commands() - this.delegateRegistry = new DelegateRegistry() + this.uiRegistry = new UIRegistry() this.subscriptions = new CompositeDisposable() + this.delegateRegistry = new DelegateRegistry() this.subscriptions.add(this.editors) this.subscriptions.add(this.commands) + this.subscriptions.add(this.uiRegistry) this.subscriptions.add(this.delegateRegistry) this.commands.onShouldProvideDelegate(() => { @@ -29,6 +33,12 @@ export default class AtomDebugger { } return null }) + this.commands.onDidStart(delegate => { + this.uiRegistry.didStart(delegate) + }) + this.commands.onDidStop(delegate => { + this.uiRegistry.didStop(delegate) + }) } activate() { this.editors.activate() diff --git a/lib/types.js b/lib/types.js index b609fb7..1662357 100644 --- a/lib/types.js +++ b/lib/types.js @@ -1,10 +1,17 @@ /* @flow */ +import type Delegate from './delegate' + export type Debugger = { name: string, grammarScopes: Array, + start(): void, + stop(): void, } -export type Breakpoint = { - +export type UI = { + activate(): void, + didStart(delegate: Delegate): void, + didStop(delegate: Delegate): void, + dispose(): void, } diff --git a/lib/ui-registry.js b/lib/ui-registry.js new file mode 100644 index 0000000..c352e0e --- /dev/null +++ b/lib/ui-registry.js @@ -0,0 +1,39 @@ +/* @flow */ + +import type { UI } from './types' +import type Delegate from './delegate' + +export default class UIRegistry { + interfaces: Set; + + constructor() { + this.interfaces = new Set() + } + add(ui: UI): void { + if (!this.interfaces.has(ui)) { + this.interfaces.add(ui) + ui.activate() + } + } + delete(ui: UI): void { + if (this.interfaces.has(ui)) { + this.interfaces.delete(ui) + ui.dispose() + } + } + didStart(delegate: Delegate): void { + for (const entry of this.interfaces) { + entry.didStart(delegate) + } + } + didStop(delegate: Delegate): void { + for (const entry of this.interfaces) { + entry.didStop(delegate) + } + } + dispose() { + for (const entry of this.interfaces) { + entry.dispose() + } + } +} diff --git a/package.json b/package.json index 6cb811a..e6de29a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "consumedServices": { "debugger-ui": { "versions": { - "^1.0.0": "consumeView" + "^1.0.0": "consumeUI" } } } From ff1524b4dfec2085a29ad13d9856f9ed43adde73 Mon Sep 17 00:00:00 2001 From: Steel Brain Date: Mon, 29 Aug 2016 16:14:42 -0700 Subject: [PATCH 21/21] :arrow_up: Address reviewer's comments --- .eslintrc.json | 6 +++--- circle.yml | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9ab6a02..39b031d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,8 @@ { "extends": "steelbrain", "rules": { - "no-param-reassign": 0, - "no-duplicate-imports": 0, - "import/prefer-default-export": 0 + "no-param-reassign": "off", + "no-duplicate-imports": "off", + "import/prefer-default-export": "off" } } diff --git a/circle.yml b/circle.yml index f309cc0..18cdf84 100644 --- a/circle.yml +++ b/circle.yml @@ -17,4 +17,4 @@ test: machine: node: - version: 6.3.0 + version: 6 diff --git a/package.json b/package.json index e6de29a..da2ceea 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "atom": ">=1.9.0 <2.0.0" }, "scripts": { - "test": "(apm test) && (flow check | grep -q '0 errors') && (eslint . )" + "test": "(apm test) && (flow check) && (eslint . )" }, "keywords": [ "debugger"