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

WIP: Breakpoint UI #275

Merged
merged 29 commits into from Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
40b30ea
breakpoint stuff
pfitzseb Dec 16, 2016
60f6f5e
actually works now
pfitzseb Dec 19, 2016
b7241c6
properly handle file state
pfitzseb Dec 20, 2016
84c469c
refactor, better debug messages
pfitzseb Dec 20, 2016
9f30ce1
clean the breakpoint registry up
pfitzseb Dec 20, 2016
201e748
clean up
pfitzseb Dec 20, 2016
07c60cb
make this a bit more robust
pfitzseb Dec 20, 2016
13c020f
fix clearall
pfitzseb Dec 21, 2016
562c35e
cleanup
pfitzseb Dec 28, 2016
b1363f2
cleanup again
pfitzseb Jan 6, 2017
4397d1b
atom terminology consistency
MikeInnes Jan 19, 2017
e99eb32
more correct
MikeInnes Jan 19, 2017
308631c
remove this for now, just to simplify things
MikeInnes Jan 19, 2017
4b9fdad
don't send this message to next client
MikeInnes Jan 19, 2017
ed9cc4c
don't need our own copy of breakpoints
MikeInnes Jan 19, 2017
e303281
temporarily use dummy bps
MikeInnes Jan 19, 2017
0bdd6cc
use new apis
MikeInnes Jan 20, 2017
4c39ad0
clean client api code
MikeInnes Jan 20, 2017
10eb4c4
style tweak
MikeInnes Jan 22, 2017
7f1258e
fix
MikeInnes Jan 22, 2017
f5a7df7
require client for breakpoints
MikeInnes Jan 22, 2017
2029a89
completions timeout
MikeInnes Jan 25, 2017
9b2a3b1
fix end highlighting
MikeInnes Jan 27, 2017
8ecf9ae
control over working state
MikeInnes Feb 9, 2017
fd597d2
temp lazy view fix
MikeInnes Feb 9, 2017
6bf6102
fix bp line numbers
MikeInnes Feb 9, 2017
dd509c7
catch breakpoint setting issues
MikeInnes Feb 9, 2017
72be8f5
fix bp error handling
MikeInnes Feb 13, 2017
10aa211
catch this error
MikeInnes Feb 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/package/commands.coffee
Expand Up @@ -81,8 +81,9 @@ module.exports =
"julia-client:clear-console": => juno.runtime.console.reset()
'julia-client:open-plot-pane': => @withInk -> juno.runtime.plots.open()
'julia-client:open-workspace': => @withInk -> juno.runtime.workspace.open()
'julia-client:settings': ->
atom.workspace.open('atom://config/packages/julia-client')
'julia-client:settings': -> atom.workspace.open('atom://config/packages/julia-client')
'julia-debug:clear-all-breakpoints': => juno.runtime.debugger.clearall()
'julia-debug:get-all-breakpoints': => juno.runtime.debugger.getBPs()
'julia-debug:step-to-next-line': => juno.runtime.debugger.nextline()
'julia-debug:step-to-next-expression': => juno.runtime.debugger.stepexpr()
'julia-debug:step-into-function': => juno.runtime.debugger.stepin()
Expand Down
6 changes: 5 additions & 1 deletion lib/runtime/completions.coffee
Expand Up @@ -15,6 +15,9 @@ module.exports =
filterSuggestions: true
excludeLowerPriority: false

sleep: (n) ->
new Promise((resolve) -> setTimeout(resolve, n*1000))

getTextEditorSelector: -> 'atom-text-editor'

rawCompletions: ({editor, bufferPosition: {row, column}, activatedManually}) ->
Expand All @@ -41,9 +44,10 @@ module.exports =

getSuggestions: (data) ->
return [] unless client.isActive() and @validScope data.scopeDescriptor
@rawCompletions(data).then ({completions, prefix, mod}) =>
cs = @rawCompletions(data).then ({completions, prefix, mod}) =>
return @fromCache mod, prefix if not completions?
@processCompletions completions, prefix
Promise.race([cs, @sleep(1).then(->[])])

cache: {}

Expand Down
87 changes: 56 additions & 31 deletions lib/runtime/debugger.js
@@ -1,34 +1,34 @@
'use babel'
/** @jsx etch.dom */

import { CompositeDisposable } from 'atom'
import { views } from '../ui'
import { client } from '../connection'

import workspace from './workspace'

let {nextline, stepin, finish, stepexpr} =
client.import(['nextline', 'stepin', 'finish', 'stepexpr'])
let {addsourcebp, removesourcebp, getbps, loadgallium} =
client.import(['addsourcebp', 'removesourcebp', 'getbps', 'loadgallium'])

let ink, active, stepper, subs
let ink, active, stepper, subs, breakpoints

export function activate() {
subs = new CompositeDisposable
subs = new CompositeDisposable()

client.handle({
debugmode: state => debugmode(state),
stepto: (file, line, text) => stepto(file, line, text)
})

subs.add(client.onDetached(() => debugmode(false)))
subs.add(client.onDetached(() => {
debugmode(false)
clearbps()
}))
}

export function deactivate() {
breakpoints.destroy()
subs.dispose()
}

function activeError() {
if (!active) {
atom.notifications.addError("You need to be debugging to do that.", {
atom.notifications.addError('You need to be debugging to do that.', {
detail: 'You can start debugging by setting a breakpoint,\nor by calling `@step f(args...)`.',
dismissable: true
})
Expand All @@ -46,32 +46,57 @@ function debugmode(a) {
}
}

function stepto(file, line, text) {
stepper.goto(file, line-1)
stepper.setText(views.render(text))
workspace.update()
client.handle({
debugmode,
stepto(file, line, text) {
stepper.goto(file, line - 1)
stepper.setText(views.render(text))
workspace.update()
},
working() { client.ipc.loading.working() },
doneWorking() { client.ipc.loading.done() }
})

export function finish() { requireDebugging(() => client.import('finish')()) }
export function nextline() { requireDebugging(() => client.import('nextline')()) }
export function stepexpr() { requireDebugging(() => client.import('stepexpr')()) }
export function stepin() { requireDebugging(() => client.import('stepin')()) }

function bufferForFile(file) {
for (let ed of atom.workspace.getTextEditors()) {
if (ed.getBuffer().getPath() === file)
return ed.getBuffer()
}
return
}

export function nextline() { requireDebugging(() => nextline()) }
export function stepin() { requireDebugging(() => stepin()) }
export function finish() { requireDebugging(() => finish()) }
export function stepexpr() { requireDebugging(() => stepexpr()) }
function bp(file, line) {
client.require(async () => {
let bp = breakpoints.toggle(file, line)
try {
await loadgallium()
let response = await ((bp ? addsourcebp : removesourcebp)(file, line+1))
} catch (e) {
console.error('Setting breakpoint:', e)
breakpoints.toggle(file, line)
}
})
}

let breakpoints = []
export function clearbps() {
breakpoints.clear()
if (client.isActive()) client.import('clearbps')()
}

function bp(file, line) {
let existing
if ((existing = ink.breakpoints.get(file, line, breakpoints)[0]) != null) {
breakpoints = breakpoints.filter(x => x !== existing)
existing.destroy()
} else {
let thebp = ink.breakpoints.add(file, line)
breakpoints.push(thebp)
}
export function getBPs() {
console.log(getbps())
}

export function togglebp(ed = atom.workspace.getActiveTextEditor()) {
if (!ed) return
if (!ed || !ed.getPath()) {
atom.notifications.addError('Need a saved file to add a breakpoint')
return
}
ed.getCursors().map((cursor) =>
bp(ed.getPath(), cursor.getBufferPosition().row))
}
Expand All @@ -85,5 +110,5 @@ export function consumeInk(i) {
{icon: 'sign-in', command: 'julia-debug:step-into-function'}
]
})
subs.add(ink.breakpoints.addScope('source.julia'))
breakpoints = new ink.breakpoints('source.julia')
}
5 changes: 4 additions & 1 deletion lib/ui/views.coffee
Expand Up @@ -30,7 +30,10 @@ module.exports = views =

lazy: ({head, id}, opts) ->
conn = client.conn
opts.registerLazy id
if opts.registerLazy?
opts.registerLazy id
else
console.warn 'Unregistered lazy view'
view = @ink.tree.treeView @render(head, opts), [],
onToggle: once =>
return unless client.conn == conn
Expand Down
2 changes: 1 addition & 1 deletion styles/julia-client.less
Expand Up @@ -22,7 +22,7 @@
}

atom-text-editor.editor {
.keyword.control.end.julia {
.syntax--keyword.syntax--end {
opacity: 0.5;
}
}