Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance #3

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "steelbrain"
"extends": "steelbrain",
"rules": {
"no-duplicate-imports": 0
}
}
24 changes: 14 additions & 10 deletions decls/atom.js
Original file line number Diff line number Diff line change
@@ -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;
}
17 changes: 17 additions & 0 deletions lib/commands.js
Original file line number Diff line number Diff line change
@@ -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()
}
}
26 changes: 26 additions & 0 deletions lib/editor.js
Original file line number Diff line number Diff line change
@@ -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()
}
}
40 changes: 40 additions & 0 deletions lib/editors.js
Original file line number Diff line number Diff line change
@@ -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<TextEditor, Editor>;
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()
}
}
15 changes: 15 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* @flow */

import AtomDebugger from './main'

export default {
instance: null,
activate() {
require('atom-package-deps').install('debugger') // eslint-disable-line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package shouldn't depend on itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the package is not depending on itself 😉
It's just telling atom-package-deps the name of the current package to install dependencies of

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I should check before making comments. 😊

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the keen eye 😄

this.instance = new AtomDebugger()
this.instance.activate()
},
deactivate() {
this.instance.dispose()
},
}
28 changes: 28 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -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()
}
}
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 . )"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will hide any errors from flow check, just remove the grep -q '0 errors' part and you will get the output. flow already exits with a non-zero code (2) if it finds issues so you aren't gaining anything with passing it into grep.

Expand All @@ -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"
}
}
}
Expand Down