Document_View.get(text_area) match { case Some(doc_view) => val rendering = Document_View.rendering(doc_view) val range = JEdit_Lib.point_range(text_area.getBuffer, offset)
rendering.breakpoint(range) case None => None
}
}
/* context menu */
def context_menu(text_area: JEditTextArea, offset: Text.Offset): List[JMenuItem] = if (PIDE.session.debugger.is_active() && get_breakpoint(text_area, offset).isDefined) { val context = jEdit.getActionContext() val name = "isabelle.toggle-breakpoint"
List(new EnhancedMenuItem(context.getAction(name).getLabel, name, context))
} else Nil
}
privateval output: Output_Area = new Output_Area(view, root_name = "Threads") { overridedef handle_search(search: Pretty_Text_Area.Search_Results): Unit = {}
overridedef handle_tree_selection(path: TreePath): Unit = ()
overridedef handle_update(): Unit = { val new_snapshot = PIDE.editor.current_node_snapshot(view).getOrElse(current_snapshot) val (new_threads, new_output) = debugger.status(tree_selection())
if (new_threads != current_threads) update_tree(new_threads)
if (new_output != current_output) {
pretty_text_area.update(new_snapshot, Command.Results.empty, new_output)
}
privatedef update_tree(threads: Debugger.Threads): Unit = { val thread_contexts =
(for ((a, b) <- threads.iterator) yield Debugger.Context(a, b)).toList
val new_tree_selection =
tree_selection() match { case Some(c) if thread_contexts.contains(c) => Some(c) case Some(c) if thread_contexts.exists(t => c.thread_name == t.thread_name) =>
Some(c.reset) case _ => thread_contexts.headOption
}
output.tree.init_model { for (thread <- thread_contexts) { val thread_node = Tree_View.Node(thread) for ((_, i) <- thread.debug_states.zipWithIndex) {
thread_node.add(Tree_View.Node(thread.select(i)))
}
output.tree.root.add(thread_node)
}
}
for (i <- Range.inclusive(output.tree.getRowCount - 1, 1, -1)) output.tree.expandRow(i)
new_tree_selection match { case Some(c) => val i =
(for (t <- thread_contexts.iterator.takeWhile(t => c.thread_name != t.thread_name)) yield t.size).sum
output.tree.addSelectionRow(i + c.index + 1) case None =>
}
output.tree.revalidate()
}
def update_vals(): Unit = {
tree_selection() match { case Some(c) if c.stack_state.isDefined =>
debugger.print_vals(c, sml_button.selected, context_field.getText) case Some(c) =>
debugger.clear_output(c.thread_name) case None =>
}
}
/* controls */
privateval break_button = new GUI.Check("Break", init = debugger.is_break()) {
tooltip = "Break running threads at next possible breakpoint" overridedef clicked(state: Boolean): Unit = debugger.set_break(state)
}
privateval continue_button = new GUI.Button("Continue") {
tooltip = "Continue program on current thread, until next breakpoint" overridedef clicked(): Unit = thread_selection().foreach(debugger.continue)
}
privateval step_button = new GUI.Button("Step") {
tooltip = "Single-step in depth-first order" overridedef clicked(): Unit = thread_selection().foreach(debugger.step)
}
privateval step_over_button = new GUI.Button("Step over") {
tooltip = "Single-step within this function" overridedef clicked(): Unit = thread_selection().foreach(debugger.step_over)
}
privateval step_out_button = new GUI.Button("Step out") {
tooltip = "Single-step outside this function" overridedef clicked(): Unit = thread_selection().foreach(debugger.step_out)
}
privateval expression_tooltip = "Isabelle/ML or Standard ML expression" privateval expression_field = new Completion_Popup.History_Text_Field("isabelle-debugger-expression") { overridedef processKeyEvent(evt: KeyEvent): Unit = { if (evt.getID == KeyEvent.KEY_PRESSED && evt.getKeyCode == KeyEvent.VK_ENTER) {
eval_expression()
} super.processKeyEvent(evt)
}
{ val max = getPreferredSize; max.width = Int.MaxValue; setMaximumSize(max) }
setColumns(40)
setToolTipText(expression_tooltip)
setFont(GUI.imitate_font(getFont, scale = 1.2))
} privateval expression_label = new GUI.Label("ML:", expression_field) {
tooltip = expression_tooltip
}
privateval eval_button = new GUI.Button(GUI.Style_HTML.enclose_bold("Eval")) {
tooltip = "Evaluate ML expression within optional context" overridedef clicked(): Unit = eval_expression()
}
privatedef eval_expression(): Unit = {
context_field.addCurrentToHistory()
expression_field.addCurrentToHistory()
tree_selection() match { case Some(c) if c.debug_index.isDefined =>
debugger.eval(c, sml_button.selected, context_field.getText, expression_field.getText) case _ =>
}
}
privateval sml_button = new GUI.Check("SML") {
tooltip = "Official Standard ML instead of Isabelle/ML"
}
overridedef init(): Unit = {
PIDE.session.global_options += main
PIDE.session.debugger_updates += main
debugger.init(dockable)
output.init()
jEdit.propertiesChanged()
}
overridedef exit(): Unit = {
PIDE.session.global_options -= main
PIDE.session.debugger_updates -= main
output.exit()
debugger.exit(dockable)
jEdit.propertiesChanged()
}
}
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.