Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tests/issues.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
mod support;

use tokio::io::{AsyncBufRead, AsyncWrite};

use lsp_types::{
DocumentSymbolParams, DocumentSymbolResponse, PublishDiagnosticsParams, TextDocumentIdentifier,
};

async fn document_symbols(
stdin: &mut (dyn AsyncWrite + std::marker::Unpin + Send),
stdout: &mut (dyn AsyncBufRead + std::marker::Unpin + Send),
id: u64,
uri: &str,
) -> DocumentSymbolResponse {
support::run_method_call::<lsp_types::lsp_request!("textDocument/documentSymbol")>(
stdin,
stdout,
id,
DocumentSymbolParams {
text_document: TextDocumentIdentifier {
uri: support::test_url(uri),
},
work_done_progress_params: Default::default(),
partial_result_params: Default::default(),
},
)
.await
.unwrap()
}

#[test]
fn issue_40() {
support::send_rpc(|stdin, stdout| {
Box::pin(async move {
let text = r#"
type U = (Int, Int)

()
"#;
support::did_open(stdin, "test.glu", text).await;

let diagnostic: PublishDiagnosticsParams =
support::expect_notification(&mut *stdout).await;

assert_eq!(diagnostic.uri, support::test_url("test.glu"));

document_symbols(stdin, stdout, 1, "test.glu").await;
})
});
}
16 changes: 16 additions & 0 deletions tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ where
.await
}

pub async fn run_method_call<T>(
writer: &mut (dyn AsyncWrite + std::marker::Unpin + Send),
reader: &mut (dyn AsyncBufRead + std::marker::Unpin + Send),
id: u64,
value: T::Params,
) -> T::Result
where
T: lsp_types::request::Request,
{
let call = method_call(T::METHOD, id, value);

write_message(writer, call).await.unwrap();

expect_response(reader).await
}

pub fn method_call<T>(method: &str, id: u64, value: T) -> Call
where
T: Serialize,
Expand Down