src/Tools/VSCode/src/server.scala
changeset 65983 d8c5603c1732
parent 65977 c51b74be23b6
child 66052 39eb61b1fa51
equal deleted inserted replaced
65982:5b8fafde7d64 65983:d8c5603c1732
   103       rendering = model.rendering()
   103       rendering = model.rendering()
   104       offset <- model.content.doc.offset(node_pos.pos)
   104       offset <- model.content.doc.offset(node_pos.pos)
   105     } yield (rendering, offset)
   105     } yield (rendering, offset)
   106 
   106 
   107   private val dynamic_output = Dynamic_Output(this)
   107   private val dynamic_output = Dynamic_Output(this)
   108   private val dynamic_preview = Dynamic_Preview(this)
       
   109 
   108 
   110 
   109 
   111   /* input from client or file-system */
   110   /* input from client or file-system */
   112 
   111 
   113   private val delay_input: Standard_Thread.Delay =
   112   private val delay_input: Standard_Thread.Delay =
   172   private def update_caret(caret: Option[(JFile, Line.Position)])
   171   private def update_caret(caret: Option[(JFile, Line.Position)])
   173   {
   172   {
   174     resources.update_caret(caret)
   173     resources.update_caret(caret)
   175     delay_caret_update.invoke()
   174     delay_caret_update.invoke()
   176     delay_input.invoke()
   175     delay_input.invoke()
       
   176   }
       
   177 
       
   178 
       
   179   /* preview */
       
   180 
       
   181   private lazy val preview = new Preview(resources)
       
   182 
       
   183   private lazy val delay_preview: Standard_Thread.Delay =
       
   184     Standard_Thread.delay_last(options.seconds("vscode_output_delay"), channel.Error_Logger)
       
   185     {
       
   186       if (preview.flush(channel)) delay_preview.invoke()
       
   187     }
       
   188 
       
   189   private def request_preview(file: JFile, column: Int)
       
   190   {
       
   191     preview.request(file, column)
       
   192     delay_preview.invoke()
   177   }
   193   }
   178 
   194 
   179 
   195 
   180   /* output to client */
   196   /* output to client */
   181 
   197 
   249 
   265 
   250       session.commands_changed += prover_output
   266       session.commands_changed += prover_output
   251       session.all_messages += syslog
   267       session.all_messages += syslog
   252 
   268 
   253       dynamic_output.init()
   269       dynamic_output.init()
   254       dynamic_preview.init()
       
   255 
   270 
   256       var session_phase: Session.Consumer[Session.Phase] = null
   271       var session_phase: Session.Consumer[Session.Phase] = null
   257       session_phase =
   272       session_phase =
   258         Session.Consumer(getClass.getName) {
   273         Session.Consumer(getClass.getName) {
   259           case Session.Ready =>
   274           case Session.Ready =>
   279       case Some(session) =>
   294       case Some(session) =>
   280         session.commands_changed -= prover_output
   295         session.commands_changed -= prover_output
   281         session.all_messages -= syslog
   296         session.all_messages -= syslog
   282 
   297 
   283         dynamic_output.exit()
   298         dynamic_output.exit()
   284         dynamic_preview.exit()
       
   285 
   299 
   286         delay_load.revoke()
   300         delay_load.revoke()
   287         file_watcher.shutdown()
   301         file_watcher.shutdown()
   288         delay_input.revoke()
   302         delay_input.revoke()
   289         delay_output.revoke()
   303         delay_output.revoke()
   290         delay_caret_update.revoke()
   304         delay_caret_update.revoke()
       
   305         delay_preview.revoke()
   291 
   306 
   292         val rc = session.stop()
   307         val rc = session.stop()
   293         if (rc == 0) reply("") else reply("Prover shutdown failed: return code " + rc)
   308         if (rc == 0) reply("") else reply("Prover shutdown failed: return code " + rc)
   294         None
   309         None
   295       case None =>
   310       case None =>
   380           case Protocol.Completion(id, node_pos) => completion(id, node_pos)
   395           case Protocol.Completion(id, node_pos) => completion(id, node_pos)
   381           case Protocol.Hover(id, node_pos) => hover(id, node_pos)
   396           case Protocol.Hover(id, node_pos) => hover(id, node_pos)
   382           case Protocol.GotoDefinition(id, node_pos) => goto_definition(id, node_pos)
   397           case Protocol.GotoDefinition(id, node_pos) => goto_definition(id, node_pos)
   383           case Protocol.DocumentHighlights(id, node_pos) => document_highlights(id, node_pos)
   398           case Protocol.DocumentHighlights(id, node_pos) => document_highlights(id, node_pos)
   384           case Protocol.Caret_Update(caret) => update_caret(caret)
   399           case Protocol.Caret_Update(caret) => update_caret(caret)
       
   400           case Protocol.Preview_Request(file, column) => request_preview(file, column)
   385           case _ => log("### IGNORED")
   401           case _ => log("### IGNORED")
   386         }
   402         }
   387       }
   403       }
   388       catch { case exn: Throwable => channel.log_error_message(Exn.message(exn)) }
   404       catch { case exn: Throwable => channel.log_error_message(Exn.message(exn)) }
   389     }
   405     }