tuned signature;
authorwenzelm
Mon, 12 Aug 2013 12:06:48 +0200
changeset 52974 908e8a36e975
parent 52973 d5f7fa1498b7
child 52975 457c006f91bb
tuned signature;
src/Pure/PIDE/editor.scala
src/Tools/jEdit/src/document_model.scala
src/Tools/jEdit/src/isabelle.scala
src/Tools/jEdit/src/jedit_editor.scala
src/Tools/jEdit/src/plugin.scala
src/Tools/jEdit/src/query_operation.scala
--- a/src/Pure/PIDE/editor.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Pure/PIDE/editor.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -10,9 +10,11 @@
 abstract class Editor[Context]
 {
   def session: Session
+  def flush(): Unit
   def current_context: Context
   def current_node(context: Context): Option[Document.Node.Name]
   def current_snapshot(context: Context): Option[Document.Snapshot]
+  def node_snapshot(name: Document.Node.Name): Document.Snapshot
   def current_command(context: Context, snapshot: Document.Snapshot): Option[(Command, Text.Offset)]
 }
 
--- a/src/Tools/jEdit/src/document_model.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Tools/jEdit/src/document_model.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -99,7 +99,7 @@
     if (_node_required != b) {
       _node_required = b
       PIDE.options_changed()
-      PIDE.flush_buffers()
+      PIDE.editor.flush()
     }
   }
 
--- a/src/Tools/jEdit/src/isabelle.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Tools/jEdit/src/isabelle.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -70,7 +70,7 @@
     if (continuous_checking != b) {
       PIDE.options.bool(CONTINUOUS_CHECKING) = b
       PIDE.options_changed()
-      PIDE.flush_buffers()
+      PIDE.editor.flush()
     }
   }
 
--- a/src/Tools/jEdit/src/jedit_editor.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Tools/jEdit/src/jedit_editor.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -17,6 +17,23 @@
 {
   def session: Session = PIDE.session
 
+  def flush()
+  {
+    Swing_Thread.require()
+
+    session.update(
+      (List.empty[Document.Edit_Text] /: JEdit_Lib.jedit_buffers().toList) {
+        case (edits, buffer) =>
+          JEdit_Lib.buffer_lock(buffer) {
+            PIDE.document_model(buffer) match {
+              case Some(model) => model.flushed_edits() ::: edits
+              case None => edits
+            }
+          }
+      }
+    )
+  }
+
   def current_context: View =
     Swing_Thread.require { jEdit.getActiveView() }
 
@@ -26,6 +43,20 @@
   def current_snapshot(view: View): Option[Document.Snapshot] =
     Swing_Thread.require { PIDE.document_model(view.getBuffer).map(_.snapshot()) }
 
+  def node_snapshot(name: Document.Node.Name): Document.Snapshot =
+  {
+    Swing_Thread.require()
+
+    JEdit_Lib.jedit_buffer(name.node) match {
+      case Some(buffer) =>
+        PIDE.document_model(buffer) match {
+          case Some(model) => model.snapshot
+          case None => session.snapshot(name)
+        }
+      case None => session.snapshot(name)
+    }
+  }
+
   def current_command(view: View, snapshot: Document.Snapshot): Option[(Command, Text.Offset)] =
   {
     Swing_Thread.require()
--- a/src/Tools/jEdit/src/plugin.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Tools/jEdit/src/plugin.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -52,20 +52,6 @@
 
   /* document model and view */
 
-  def document_snapshot(name: Document.Node.Name): Document.Snapshot =
-  {
-    Swing_Thread.require()
-
-    JEdit_Lib.jedit_buffer(name.node) match {
-      case Some(buffer) =>
-        document_model(buffer) match {
-          case Some(model) => model.snapshot
-          case None => session.snapshot(name)
-        }
-      case None => session.snapshot(name)
-    }
-  }
-
   def document_model(buffer: Buffer): Option[Document_Model] = Document_Model(buffer)
   def document_view(text_area: JEditTextArea): Option[Document_View] = Document_View(text_area)
 
@@ -133,23 +119,6 @@
       Document_View.exit(text_area)
     }
   }
-
-  def flush_buffers()
-  {
-    Swing_Thread.require()
-
-    session.update(
-      (List.empty[Document.Edit_Text] /: JEdit_Lib.jedit_buffers().toList) {
-        case (edits, buffer) =>
-          JEdit_Lib.buffer_lock(buffer) {
-            document_model(buffer) match {
-              case Some(model) => model.flushed_edits() ::: edits
-              case None => edits
-            }
-          }
-      }
-    )
-  }
 }
 
 
--- a/src/Tools/jEdit/src/query_operation.scala	Mon Aug 12 11:56:12 2013 +0200
+++ b/src/Tools/jEdit/src/query_operation.scala	Mon Aug 12 12:06:48 2013 +0200
@@ -78,7 +78,7 @@
     val (snapshot, state, removed) =
       current_location match {
         case Some(cmd) =>
-          val snapshot = PIDE.document_snapshot(cmd.node_name)
+          val snapshot = editor.node_snapshot(cmd.node_name)
           val state = snapshot.state.command_state(snapshot.version, cmd)
           val removed = !snapshot.version.nodes(cmd.node_name).commands.contains(cmd)
           (snapshot, state, removed)
@@ -139,7 +139,7 @@
           consume_status(new_status)
           if (new_status == Query_Operation.Status.FINISHED) {
             remove_overlay()
-            PIDE.flush_buffers()
+            editor.flush()
           }
         }
       }
@@ -171,7 +171,7 @@
           case None =>
         }
         consume_status(current_status)
-        PIDE.flush_buffers()
+        editor.flush()
       case None =>
     }
   }
@@ -182,7 +182,7 @@
 
     current_location match {
       case Some(command) =>
-        val snapshot = PIDE.document_snapshot(command.node_name)
+        val snapshot = editor.node_snapshot(command.node_name)
         val commands = snapshot.node.commands
         if (commands.contains(command)) {
           // FIXME revert offset (!?)