src/Tools/VSCode/src/protocol.scala
changeset 64651 ea5620f7b0d8
parent 64649 d67c3094a0c2
child 64675 c557279d93f2
equal deleted inserted replaced
64650:011629dda937 64651:ea5620f7b0d8
    80       }
    80       }
    81   }
    81   }
    82 
    82 
    83   class RequestTextDocumentPosition(name: String)
    83   class RequestTextDocumentPosition(name: String)
    84   {
    84   {
    85     def unapply(json: JSON.T): Option[(Id, Line.Position_Node)] =
    85     def unapply(json: JSON.T): Option[(Id, Line.Node_Position)] =
    86       json match {
    86       json match {
    87         case RequestMessage(id, method, Some(TextDocumentPosition(pos_node))) if method == name =>
    87         case RequestMessage(id, method, Some(TextDocumentPosition(node_pos))) if method == name =>
    88           Some((id, pos_node))
    88           Some((id, node_pos))
    89         case _ => None
    89         case _ => None
    90       }
    90       }
    91   }
    91   }
    92 
    92 
    93 
    93 
   176       }
   176       }
   177   }
   177   }
   178 
   178 
   179   object Location
   179   object Location
   180   {
   180   {
   181     def apply(loc: Line.Range_Node): JSON.T =
   181     def apply(loc: Line.Node_Range): JSON.T =
   182       Map("uri" -> loc.name, "range" -> Range(loc.range))
   182       Map("uri" -> loc.name, "range" -> Range(loc.range))
   183 
   183 
   184     def unapply(json: JSON.T): Option[Line.Range_Node] =
   184     def unapply(json: JSON.T): Option[Line.Node_Range] =
   185       for {
   185       for {
   186         uri <- JSON.string(json, "uri")
   186         uri <- JSON.string(json, "uri")
   187         range_json <- JSON.value(json, "range")
   187         range_json <- JSON.value(json, "range")
   188         range <- Range.unapply(range_json)
   188         range <- Range.unapply(range_json)
   189       } yield Line.Range_Node(range, uri)
   189       } yield Line.Node_Range(uri, range)
   190   }
   190   }
   191 
   191 
   192   object TextDocumentPosition
   192   object TextDocumentPosition
   193   {
   193   {
   194     def unapply(json: JSON.T): Option[Line.Position_Node] =
   194     def unapply(json: JSON.T): Option[Line.Node_Position] =
   195       for {
   195       for {
   196         doc <- JSON.value(json, "textDocument")
   196         doc <- JSON.value(json, "textDocument")
   197         uri <- JSON.string(doc, "uri")
   197         uri <- JSON.string(doc, "uri")
   198         pos_json <- JSON.value(json, "position")
   198         pos_json <- JSON.value(json, "position")
   199         pos <- Position.unapply(pos_json)
   199         pos <- Position.unapply(pos_json)
   200       } yield Line.Position_Node(pos, uri)
   200       } yield Line.Node_Position(uri, pos)
   201   }
   201   }
   202 
   202 
   203 
   203 
   204   /* diagnostic messages */
   204   /* diagnostic messages */
   205 
   205 
   306 
   306 
   307   /* goto definition request */
   307   /* goto definition request */
   308 
   308 
   309   object GotoDefinition extends RequestTextDocumentPosition("textDocument/definition")
   309   object GotoDefinition extends RequestTextDocumentPosition("textDocument/definition")
   310   {
   310   {
   311     def reply(id: Id, result: List[Line.Range_Node]): JSON.T =
   311     def reply(id: Id, result: List[Line.Node_Range]): JSON.T =
   312       ResponseMessage(id, Some(result.map(Location.apply(_))))
   312       ResponseMessage(id, Some(result.map(Location.apply(_))))
   313   }
   313   }
   314 }
   314 }