aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/tests/heavy_tests/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests/main.rs')
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs69
1 files changed, 68 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 6f37a980d..f61048aaf 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -6,10 +6,11 @@ use std::{
6}; 6};
7 7
8use lsp_types::{ 8use lsp_types::{
9 CodeActionContext, DocumentFormattingParams, FormattingOptions, Position, Range, 9 CodeActionContext, DocumentFormattingParams, FormattingOptions, Position, Range, DidOpenTextDocumentParams, TextDocumentItem, TextDocumentPositionParams
10}; 10};
11use ra_lsp_server::req::{ 11use ra_lsp_server::req::{
12 CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion, 12 CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion,
13 DidOpenTextDocument, OnEnter,
13}; 14};
14use serde_json::json; 15use serde_json::json;
15use tempfile::TempDir; 16use tempfile::TempDir;
@@ -17,6 +18,7 @@ use tempfile::TempDir;
17use crate::support::{project, Project}; 18use crate::support::{project, Project};
18 19
19const LOG: &'static str = ""; 20const LOG: &'static str = "";
21const PROFILE: &'static str = "*@3>100";
20 22
21#[test] 23#[test]
22fn completes_items_from_standard_library() { 24fn completes_items_from_standard_library() {
@@ -341,3 +343,68 @@ fn main() {{}}
341 json!([]), 343 json!([]),
342 ); 344 );
343} 345}
346
347#[test]
348fn diagnostics_dont_block_typing() {
349 let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect();
350 let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect();
351 let server = project(&format!(
352 r#"
353//- Cargo.toml
354[package]
355name = "foo"
356version = "0.0.0"
357
358//- src/lib.rs
359{}
360
361{}
362
363fn main() {{}}
364"#,
365 librs, libs
366 ));
367 server.wait_until_workspace_is_loaded();
368 for i in 0..10 {
369 server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams {
370 text_document: TextDocumentItem {
371 uri: server.doc_id(&format!("src/m{}.rs", i)).uri,
372 language_id: "rust".to_string(),
373 version: 0,
374 text: "/// Docs\nfn foo() {}".to_string(),
375 },
376 });
377 }
378 let start = std::time::Instant::now();
379 server.request::<OnEnter>(
380 TextDocumentPositionParams {
381 text_document: server.doc_id("src/m0.rs"),
382 position: Position { line: 0, character: 5 },
383 },
384 json!({
385 "cursorPosition": {
386 "position": { "character": 4, "line": 1 },
387 "textDocument": { "uri": "file:///[..]src/m0.rs" }
388 },
389 "label": "on enter",
390 "workspaceEdit": {
391 "documentChanges": [
392 {
393 "edits": [
394 {
395 "newText": "\n/// ",
396 "range": {
397 "end": { "character": 5, "line": 0 },
398 "start": { "character": 5, "line": 0 }
399 }
400 }
401 ],
402 "textDocument": { "uri": "file:///[..]src/m0.rs", "version": null }
403 }
404 ]
405 }
406 }),
407 );
408 let elapsed = start.elapsed();
409 assert!(elapsed.as_millis() < 2000, "typing enter took {:?}", elapsed);
410}