aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-28 21:12:44 +0100
committerGitHub <[email protected]>2020-04-28 21:12:44 +0100
commit07f690ddf601eeff639ac83e0c9f5db1a895a47b (patch)
treea9d15523d01dbc0123d6393a83a29ae321b01a5b
parentdb441de0a8dfbac2ae9e10d8ff73e5eaf5e48a56 (diff)
parent61f1c0a99007e2f2e04715437239069736134e52 (diff)
Merge #4161
4161: lsp-types 0.74 r=kjeremy a=kjeremy * Fixes a bunch of param types to take partial progress into account. * Will allow us to support insert/replace text in completions Co-authored-by: kjeremy <[email protected]>
-rw-r--r--Cargo.lock8
-rw-r--r--crates/ra_flycheck/Cargo.toml2
-rw-r--r--crates/rust-analyzer/Cargo.toml2
-rw-r--r--crates/rust-analyzer/src/conv.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs49
-rw-r--r--crates/rust-analyzer/src/req.rs15
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs27
7 files changed, 58 insertions, 47 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 367ff3f82..e933598fb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,9 +68,9 @@ dependencies = [
68 68
69[[package]] 69[[package]]
70name = "base64" 70name = "base64"
71version = "0.11.0" 71version = "0.12.0"
72source = "registry+https://github.com/rust-lang/crates.io-index" 72source = "registry+https://github.com/rust-lang/crates.io-index"
73checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" 73checksum = "7d5ca2cd0adc3f48f9e9ea5a6bbdf9ccc0bfade884847e484d452414c7ccffb3"
74 74
75[[package]] 75[[package]]
76name = "bitflags" 76name = "bitflags"
@@ -645,9 +645,9 @@ dependencies = [
645 645
646[[package]] 646[[package]]
647name = "lsp-types" 647name = "lsp-types"
648version = "0.73.0" 648version = "0.74.0"
649source = "registry+https://github.com/rust-lang/crates.io-index" 649source = "registry+https://github.com/rust-lang/crates.io-index"
650checksum = "93d0cf64ea141b43d9e055f6b9df13f0bce32b103d84237509ce0a571ab9b159" 650checksum = "820f746e5716ab9a2d664794636188bd003023b72e55404ee27105dc22869922"
651dependencies = [ 651dependencies = [
652 "base64", 652 "base64",
653 "bitflags", 653 "bitflags",
diff --git a/crates/ra_flycheck/Cargo.toml b/crates/ra_flycheck/Cargo.toml
index 76e5cada4..324c33d9d 100644
--- a/crates/ra_flycheck/Cargo.toml
+++ b/crates/ra_flycheck/Cargo.toml
@@ -6,7 +6,7 @@ authors = ["rust-analyzer developers"]
6 6
7[dependencies] 7[dependencies]
8crossbeam-channel = "0.4.0" 8crossbeam-channel = "0.4.0"
9lsp-types = { version = "0.73.0", features = ["proposed"] } 9lsp-types = { version = "0.74.0", features = ["proposed"] }
10log = "0.4.8" 10log = "0.4.8"
11cargo_metadata = "0.9.1" 11cargo_metadata = "0.9.1"
12serde_json = "1.0.48" 12serde_json = "1.0.48"
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index cee0248b6..514d6d1a9 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -20,7 +20,7 @@ globset = "0.4.4"
20itertools = "0.9.0" 20itertools = "0.9.0"
21jod-thread = "0.1.0" 21jod-thread = "0.1.0"
22log = "0.4.8" 22log = "0.4.8"
23lsp-types = { version = "0.73.0", features = ["proposed"] } 23lsp-types = { version = "0.74.0", features = ["proposed"] }
24parking_lot = "0.10.0" 24parking_lot = "0.10.0"
25pico-args = "0.3.1" 25pico-args = "0.3.1"
26rand = { version = "0.7.3", features = ["small_rng"] } 26rand = { version = "0.7.3", features = ["small_rng"] }
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs
index ffe3ea84d..7be5ebcdb 100644
--- a/crates/rust-analyzer/src/conv.rs
+++ b/crates/rust-analyzer/src/conv.rs
@@ -150,7 +150,7 @@ impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
150 detail: self.detail().map(|it| it.to_string()), 150 detail: self.detail().map(|it| it.to_string()),
151 filter_text: Some(self.lookup().to_string()), 151 filter_text: Some(self.lookup().to_string()),
152 kind: self.kind().map(|it| it.conv()), 152 kind: self.kind().map(|it| it.conv()),
153 text_edit: Some(text_edit), 153 text_edit: Some(text_edit.into()),
154 additional_text_edits: Some(additional_text_edits), 154 additional_text_edits: Some(additional_text_edits),
155 documentation: self.documentation().map(|it| it.conv()), 155 documentation: self.documentation().map(|it| it.conv()),
156 deprecated: Some(self.deprecated()), 156 deprecated: Some(self.deprecated()),
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 6caaf5f88..8db2dfa0c 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -326,10 +326,10 @@ pub fn handle_workspace_symbol(
326 326
327pub fn handle_goto_definition( 327pub fn handle_goto_definition(
328 world: WorldSnapshot, 328 world: WorldSnapshot,
329 params: req::TextDocumentPositionParams, 329 params: req::GotoDefinitionParams,
330) -> Result<Option<req::GotoDefinitionResponse>> { 330) -> Result<Option<req::GotoDefinitionResponse>> {
331 let _p = profile("handle_goto_definition"); 331 let _p = profile("handle_goto_definition");
332 let position = params.try_conv_with(&world)?; 332 let position = params.text_document_position_params.try_conv_with(&world)?;
333 let nav_info = match world.analysis().goto_definition(position)? { 333 let nav_info = match world.analysis().goto_definition(position)? {
334 None => return Ok(None), 334 None => return Ok(None),
335 Some(it) => it, 335 Some(it) => it,
@@ -340,10 +340,10 @@ pub fn handle_goto_definition(
340 340
341pub fn handle_goto_implementation( 341pub fn handle_goto_implementation(
342 world: WorldSnapshot, 342 world: WorldSnapshot,
343 params: req::TextDocumentPositionParams, 343 params: req::GotoImplementationParams,
344) -> Result<Option<req::GotoImplementationResponse>> { 344) -> Result<Option<req::GotoImplementationResponse>> {
345 let _p = profile("handle_goto_implementation"); 345 let _p = profile("handle_goto_implementation");
346 let position = params.try_conv_with(&world)?; 346 let position = params.text_document_position_params.try_conv_with(&world)?;
347 let nav_info = match world.analysis().goto_implementation(position)? { 347 let nav_info = match world.analysis().goto_implementation(position)? {
348 None => return Ok(None), 348 None => return Ok(None),
349 Some(it) => it, 349 Some(it) => it,
@@ -354,10 +354,10 @@ pub fn handle_goto_implementation(
354 354
355pub fn handle_goto_type_definition( 355pub fn handle_goto_type_definition(
356 world: WorldSnapshot, 356 world: WorldSnapshot,
357 params: req::TextDocumentPositionParams, 357 params: req::GotoTypeDefinitionParams,
358) -> Result<Option<req::GotoTypeDefinitionResponse>> { 358) -> Result<Option<req::GotoTypeDefinitionResponse>> {
359 let _p = profile("handle_goto_type_definition"); 359 let _p = profile("handle_goto_type_definition");
360 let position = params.try_conv_with(&world)?; 360 let position = params.text_document_position_params.try_conv_with(&world)?;
361 let nav_info = match world.analysis().goto_type_definition(position)? { 361 let nav_info = match world.analysis().goto_type_definition(position)? {
362 None => return Ok(None), 362 None => return Ok(None),
363 Some(it) => it, 363 Some(it) => it,
@@ -487,10 +487,10 @@ pub fn handle_folding_range(
487 487
488pub fn handle_signature_help( 488pub fn handle_signature_help(
489 world: WorldSnapshot, 489 world: WorldSnapshot,
490 params: req::TextDocumentPositionParams, 490 params: req::SignatureHelpParams,
491) -> Result<Option<req::SignatureHelp>> { 491) -> Result<Option<req::SignatureHelp>> {
492 let _p = profile("handle_signature_help"); 492 let _p = profile("handle_signature_help");
493 let position = params.try_conv_with(&world)?; 493 let position = params.text_document_position_params.try_conv_with(&world)?;
494 if let Some(call_info) = world.analysis().call_info(position)? { 494 if let Some(call_info) = world.analysis().call_info(position)? {
495 let concise = !world.config.call_info_full; 495 let concise = !world.config.call_info_full;
496 let mut active_parameter = call_info.active_parameter.map(|it| it as i64); 496 let mut active_parameter = call_info.active_parameter.map(|it| it as i64);
@@ -509,12 +509,9 @@ pub fn handle_signature_help(
509 } 509 }
510} 510}
511 511
512pub fn handle_hover( 512pub fn handle_hover(world: WorldSnapshot, params: req::HoverParams) -> Result<Option<Hover>> {
513 world: WorldSnapshot,
514 params: req::TextDocumentPositionParams,
515) -> Result<Option<Hover>> {
516 let _p = profile("handle_hover"); 513 let _p = profile("handle_hover");
517 let position = params.try_conv_with(&world)?; 514 let position = params.text_document_position_params.try_conv_with(&world)?;
518 let info = match world.analysis().hover(position)? { 515 let info = match world.analysis().hover(position)? {
519 None => return Ok(None), 516 None => return Ok(None),
520 Some(info) => info, 517 Some(info) => info,
@@ -878,8 +875,14 @@ pub fn handle_code_lens(
878 .map(|it| { 875 .map(|it| {
879 let range = it.node_range.conv_with(&line_index); 876 let range = it.node_range.conv_with(&line_index);
880 let pos = range.start; 877 let pos = range.start;
881 let lens_params = 878 let lens_params = req::GotoImplementationParams {
882 req::TextDocumentPositionParams::new(params.text_document.clone(), pos); 879 text_document_position_params: req::TextDocumentPositionParams::new(
880 params.text_document.clone(),
881 pos,
882 ),
883 work_done_progress_params: Default::default(),
884 partial_result_params: Default::default(),
885 };
883 CodeLens { 886 CodeLens {
884 range, 887 range,
885 command: None, 888 command: None,
@@ -894,7 +897,7 @@ pub fn handle_code_lens(
894#[derive(Debug, Serialize, Deserialize)] 897#[derive(Debug, Serialize, Deserialize)]
895#[serde(rename_all = "camelCase")] 898#[serde(rename_all = "camelCase")]
896enum CodeLensResolveData { 899enum CodeLensResolveData {
897 Impls(req::TextDocumentPositionParams), 900 Impls(req::GotoImplementationParams),
898} 901}
899 902
900pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Result<CodeLens> { 903pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Result<CodeLens> {
@@ -927,7 +930,7 @@ pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Re
927 title, 930 title,
928 command: "rust-analyzer.showReferences".into(), 931 command: "rust-analyzer.showReferences".into(),
929 arguments: Some(vec![ 932 arguments: Some(vec![
930 to_value(&lens_params.text_document.uri).unwrap(), 933 to_value(&lens_params.text_document_position_params.text_document.uri).unwrap(),
931 to_value(code_lens.range.start).unwrap(), 934 to_value(code_lens.range.start).unwrap(),
932 to_value(locations).unwrap(), 935 to_value(locations).unwrap(),
933 ]), 936 ]),
@@ -944,16 +947,16 @@ pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Re
944 947
945pub fn handle_document_highlight( 948pub fn handle_document_highlight(
946 world: WorldSnapshot, 949 world: WorldSnapshot,
947 params: req::TextDocumentPositionParams, 950 params: req::DocumentHighlightParams,
948) -> Result<Option<Vec<DocumentHighlight>>> { 951) -> Result<Option<Vec<DocumentHighlight>>> {
949 let _p = profile("handle_document_highlight"); 952 let _p = profile("handle_document_highlight");
950 let file_id = params.text_document.try_conv_with(&world)?; 953 let file_id = params.text_document_position_params.text_document.try_conv_with(&world)?;
951 let line_index = world.analysis().file_line_index(file_id)?; 954 let line_index = world.analysis().file_line_index(file_id)?;
952 955
953 let refs = match world 956 let refs = match world.analysis().find_all_refs(
954 .analysis() 957 params.text_document_position_params.try_conv_with(&world)?,
955 .find_all_refs(params.try_conv_with(&world)?, Some(SearchScope::single_file(file_id)))? 958 Some(SearchScope::single_file(file_id)),
956 { 959 )? {
957 None => return Ok(None), 960 None => return Ok(None),
958 Some(refs) => refs, 961 Some(refs) => refs,
959 }; 962 };
diff --git a/crates/rust-analyzer/src/req.rs b/crates/rust-analyzer/src/req.rs
index ae3448892..0dae6bad4 100644
--- a/crates/rust-analyzer/src/req.rs
+++ b/crates/rust-analyzer/src/req.rs
@@ -8,14 +8,15 @@ pub use lsp_types::{
8 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, 8 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
9 CodeLensParams, CompletionParams, CompletionResponse, ConfigurationItem, ConfigurationParams, 9 CodeLensParams, CompletionParams, CompletionResponse, ConfigurationItem, ConfigurationParams,
10 DiagnosticTag, DidChangeConfigurationParams, DidChangeWatchedFilesParams, 10 DiagnosticTag, DidChangeConfigurationParams, DidChangeWatchedFilesParams,
11 DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams, 11 DidChangeWatchedFilesRegistrationOptions, DocumentHighlightParams,
12 DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType, 12 DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse,
13 PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken, 13 FileSystemWatcher, GotoDefinitionParams, GotoDefinitionResponse, Hover, HoverParams,
14 PublishDiagnosticsParams, ReferenceParams, Registration, RegistrationParams, SelectionRange, 14 InitializeResult, MessageType, PartialResultParams, ProgressParams, ProgressParamsValue,
15 SelectionRangeParams, SemanticTokensParams, SemanticTokensRangeParams, 15 ProgressToken, PublishDiagnosticsParams, ReferenceParams, Registration, RegistrationParams,
16 SelectionRange, SelectionRangeParams, SemanticTokensParams, SemanticTokensRangeParams,
16 SemanticTokensRangeResult, SemanticTokensResult, ServerCapabilities, ShowMessageParams, 17 SemanticTokensRangeResult, SemanticTokensResult, ServerCapabilities, ShowMessageParams,
17 SignatureHelp, SymbolKind, TextDocumentEdit, TextDocumentPositionParams, TextEdit, 18 SignatureHelp, SignatureHelpParams, SymbolKind, TextDocumentEdit, TextDocumentPositionParams,
18 WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams, 19 TextEdit, WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams,
19}; 20};
20use std::path::PathBuf; 21use std::path::PathBuf;
21 22
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index f6245ddd4..07b8114c6 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -4,8 +4,8 @@ use std::{collections::HashMap, path::PathBuf, time::Instant};
4 4
5use lsp_types::{ 5use lsp_types::{
6 CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, 6 CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions,
7 PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, 7 GotoDefinitionParams, HoverParams, PartialResultParams, Position, Range, TextDocumentItem,
8 WorkDoneProgressParams, 8 TextDocumentPositionParams, WorkDoneProgressParams,
9}; 9};
10use rust_analyzer::req::{ 10use rust_analyzer::req::{
11 CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, 11 CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument,
@@ -610,10 +610,14 @@ fn main() { message(); }
610 }) 610 })
611 .server(); 611 .server();
612 server.wait_until_workspace_is_loaded(); 612 server.wait_until_workspace_is_loaded();
613 let res = server.send_request::<GotoDefinition>(TextDocumentPositionParams::new( 613 let res = server.send_request::<GotoDefinition>(GotoDefinitionParams {
614 server.doc_id("src/main.rs"), 614 text_document_position_params: TextDocumentPositionParams::new(
615 Position::new(2, 15), 615 server.doc_id("src/main.rs"),
616 )); 616 Position::new(2, 15),
617 ),
618 work_done_progress_params: Default::default(),
619 partial_result_params: Default::default(),
620 });
617 assert!(format!("{}", res).contains("hello.rs")); 621 assert!(format!("{}", res).contains("hello.rs"));
618} 622}
619 623
@@ -692,10 +696,13 @@ pub fn foo(_input: TokenStream) -> TokenStream {
692 .root("bar") 696 .root("bar")
693 .server(); 697 .server();
694 server.wait_until_workspace_is_loaded(); 698 server.wait_until_workspace_is_loaded();
695 let res = server.send_request::<HoverRequest>(TextDocumentPositionParams::new( 699 let res = server.send_request::<HoverRequest>(HoverParams {
696 server.doc_id("foo/src/main.rs"), 700 text_document_position_params: TextDocumentPositionParams::new(
697 Position::new(7, 9), 701 server.doc_id("foo/src/main.rs"),
698 )); 702 Position::new(7, 9),
703 ),
704 work_done_progress_params: Default::default(),
705 });
699 706
700 let value = res.get("contents").unwrap().get("value").unwrap().to_string(); 707 let value = res.get("contents").unwrap().get("value").unwrap().to_string();
701 assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#) 708 assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#)