src/Tools/VSCode/src/server.scala
changeset 64648 5d7f741aaccb
parent 64646 805c5e6fa430
child 64649 d67c3094a0c2
equal deleted inserted replaced
64647:bbfcef118acb 64648:5d7f741aaccb
   232       }
   232       }
   233     channel.write(Protocol.Hover.reply(id, result))
   233     channel.write(Protocol.Hover.reply(id, result))
   234   }
   234   }
   235 
   235 
   236 
   236 
       
   237   /* goto definition */
       
   238 
       
   239   def goto_definition(id: Protocol.Id, uri: String, pos: Line.Position)
       
   240   {
       
   241     val result =
       
   242       (for {
       
   243         model <- state.value.models.get(uri)
       
   244         rendering = model.rendering(options)
       
   245         offset <- model.doc.offset(pos, text_length)
       
   246       } yield rendering.hyperlinks(Text.Range(offset, offset + 1))) getOrElse Nil
       
   247     channel.log("hyperlinks = " + result)
       
   248     channel.write(Protocol.GotoDefinition.reply(id, result))
       
   249   }
       
   250 
       
   251 
   237   /* main loop */
   252   /* main loop */
   238 
   253 
   239   def start()
   254   def start()
   240   {
   255   {
   241     channel.log("Server started " + Date.now())
   256     channel.log("Server started " + Date.now())
   252           case Protocol.DidChangeTextDocument(uri, version, List(Protocol.TextDocumentContent(text))) =>
   267           case Protocol.DidChangeTextDocument(uri, version, List(Protocol.TextDocumentContent(text))) =>
   253             update_document(uri, text)
   268             update_document(uri, text)
   254           case Protocol.DidCloseTextDocument(uri) => channel.log("CLOSE " + uri)
   269           case Protocol.DidCloseTextDocument(uri) => channel.log("CLOSE " + uri)
   255           case Protocol.DidSaveTextDocument(uri) => channel.log("SAVE " + uri)
   270           case Protocol.DidSaveTextDocument(uri) => channel.log("SAVE " + uri)
   256           case Protocol.Hover(id, uri, pos) => hover(id, uri, pos)
   271           case Protocol.Hover(id, uri, pos) => hover(id, uri, pos)
       
   272           case Protocol.GotoDefinition(id, uri, pos) => goto_definition(id, uri, pos)
   257           case _ => channel.log("### IGNORED")
   273           case _ => channel.log("### IGNORED")
   258         }
   274         }
   259       }
   275       }
   260       catch { case exn: Throwable => channel.log("*** ERROR: " + Exn.message(exn)) }
   276       catch { case exn: Throwable => channel.log("*** ERROR: " + Exn.message(exn)) }
   261     }
   277     }