use std::io::Cursor;
fn framed(body: &str) -> String {
format!("Content-Length: {}\r\n\r\n{body}", body.len())
}
fn main() {
let conversation: String = [
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}"#,
r#"{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///example.xml","text":"<a><b></a>"}}}"#,
r#"{"jsonrpc":"2.0","id":2,"method":"shutdown"}"#,
r#"{"jsonrpc":"2.0","method":"exit"}"#,
]
.iter()
.map(|m| framed(m))
.collect();
let mut replies = Vec::new();
oxml_lsp::lsp::serve(Cursor::new(conversation.into_bytes()), &mut replies);
let text = String::from_utf8(replies).expect("replies are utf-8");
println!("{}", text.replace('\r', ""));
assert!(
text.contains("publishDiagnostics"),
"the server should have pushed diagnostics"
);
}