Create a format that reads and writes as a different type.
Create a format that reads and writes as a different type. Most useful for providing different types in the JsonRpc library, even though the serialized form is the same.
Since the library expects non-overlapping types in the MessageFormat structure, you can work around that using this little helper function
case class TextDocumentCompletionCommand(positionParams: TextDocumentPositionParams) extends ServerCommand case class TextDocumentDefinitionCommand(positionParams: TextDocumentPositionParams) extends ServerCommand object ServerCommand extends CommandCompanion[ServerCommand] { override val CommandFormats = { implicit val positionParamsFormat = Json.format[TextDocumentPositionParams] Message.MessageFormats( .. "textDocument/completion" -> valueFormat(TextDocumentCompletionCommand)(_.positionParams), "textDocument/definition" -> valueFormat(TextDocumentDefinitionCommand)(_.positionParams), )
Utility for messages that use the same parameter type in different requests.
The JsonRpc library expects non-overlapping types in a command server object, but the language server re-uses such parameters in different requests.
https://github.com/dhpcs/play-json-rpc/issues/2