]> git.lizzy.rs Git - rust.git/commitdiff
Merge #4161
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Tue, 28 Apr 2020 20:12:44 +0000 (20:12 +0000)
committerGitHub <noreply@github.com>
Tue, 28 Apr 2020 20:12:44 +0000 (20:12 +0000)
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 <kjeremy@gmail.com>
Cargo.lock
crates/ra_flycheck/Cargo.toml
crates/rust-analyzer/Cargo.toml
crates/rust-analyzer/src/conv.rs
crates/rust-analyzer/src/main_loop/handlers.rs
crates/rust-analyzer/src/req.rs
crates/rust-analyzer/tests/heavy_tests/main.rs

index 367ff3f82812ec0449a44c2dea7d7e683a515c82..e933598fb92c5eba7b2369035e2b4818254637b3 100644 (file)
@@ -68,9 +68,9 @@ dependencies = [
 
 [[package]]
 name = "base64"
-version = "0.11.0"
+version = "0.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
+checksum = "7d5ca2cd0adc3f48f9e9ea5a6bbdf9ccc0bfade884847e484d452414c7ccffb3"
 
 [[package]]
 name = "bitflags"
@@ -645,9 +645,9 @@ dependencies = [
 
 [[package]]
 name = "lsp-types"
-version = "0.73.0"
+version = "0.74.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93d0cf64ea141b43d9e055f6b9df13f0bce32b103d84237509ce0a571ab9b159"
+checksum = "820f746e5716ab9a2d664794636188bd003023b72e55404ee27105dc22869922"
 dependencies = [
  "base64",
  "bitflags",
index 76e5cada4f1543f1c1c3a972369c67dda2ecf550..324c33d9dd28dd554e23af4c5b8c6521a1b5f0d5 100644 (file)
@@ -6,7 +6,7 @@ authors = ["rust-analyzer developers"]
 
 [dependencies]
 crossbeam-channel = "0.4.0"
-lsp-types = { version = "0.73.0", features = ["proposed"] }
+lsp-types = { version = "0.74.0", features = ["proposed"] }
 log = "0.4.8"
 cargo_metadata = "0.9.1"
 serde_json = "1.0.48"
index cee0248b62c545f55917a151e33fd313db08ca1a..514d6d1a940e07d9db5f4039d04708c9f74d158f 100644 (file)
@@ -20,7 +20,7 @@ globset = "0.4.4"
 itertools = "0.9.0"
 jod-thread = "0.1.0"
 log = "0.4.8"
-lsp-types = { version = "0.73.0", features = ["proposed"] }
+lsp-types = { version = "0.74.0", features = ["proposed"] }
 parking_lot = "0.10.0"
 pico-args = "0.3.1"
 rand = { version = "0.7.3", features = ["small_rng"] }
index ffe3ea84d759a25fbf959aaf11a87c74c7d950d8..7be5ebcdb5a0d13599cc5a8d628c48186cc46936 100644 (file)
@@ -150,7 +150,7 @@ fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionIte
             detail: self.detail().map(|it| it.to_string()),
             filter_text: Some(self.lookup().to_string()),
             kind: self.kind().map(|it| it.conv()),
-            text_edit: Some(text_edit),
+            text_edit: Some(text_edit.into()),
             additional_text_edits: Some(additional_text_edits),
             documentation: self.documentation().map(|it| it.conv()),
             deprecated: Some(self.deprecated()),
index 6caaf5f88d30c35de585e9406d9b002ae8830bc1..8db2dfa0c861f7a0fb9591967c15ccdb86a2ba9c 100644 (file)
@@ -326,10 +326,10 @@ fn exec_query(world: &WorldSnapshot, query: Query) -> Result<Vec<SymbolInformati
 
 pub fn handle_goto_definition(
     world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
+    params: req::GotoDefinitionParams,
 ) -> Result<Option<req::GotoDefinitionResponse>> {
     let _p = profile("handle_goto_definition");
-    let position = params.try_conv_with(&world)?;
+    let position = params.text_document_position_params.try_conv_with(&world)?;
     let nav_info = match world.analysis().goto_definition(position)? {
         None => return Ok(None),
         Some(it) => it,
@@ -340,10 +340,10 @@ pub fn handle_goto_definition(
 
 pub fn handle_goto_implementation(
     world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
+    params: req::GotoImplementationParams,
 ) -> Result<Option<req::GotoImplementationResponse>> {
     let _p = profile("handle_goto_implementation");
-    let position = params.try_conv_with(&world)?;
+    let position = params.text_document_position_params.try_conv_with(&world)?;
     let nav_info = match world.analysis().goto_implementation(position)? {
         None => return Ok(None),
         Some(it) => it,
@@ -354,10 +354,10 @@ pub fn handle_goto_implementation(
 
 pub fn handle_goto_type_definition(
     world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
+    params: req::GotoTypeDefinitionParams,
 ) -> Result<Option<req::GotoTypeDefinitionResponse>> {
     let _p = profile("handle_goto_type_definition");
-    let position = params.try_conv_with(&world)?;
+    let position = params.text_document_position_params.try_conv_with(&world)?;
     let nav_info = match world.analysis().goto_type_definition(position)? {
         None => return Ok(None),
         Some(it) => it,
@@ -487,10 +487,10 @@ pub fn handle_folding_range(
 
 pub fn handle_signature_help(
     world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
+    params: req::SignatureHelpParams,
 ) -> Result<Option<req::SignatureHelp>> {
     let _p = profile("handle_signature_help");
-    let position = params.try_conv_with(&world)?;
+    let position = params.text_document_position_params.try_conv_with(&world)?;
     if let Some(call_info) = world.analysis().call_info(position)? {
         let concise = !world.config.call_info_full;
         let mut active_parameter = call_info.active_parameter.map(|it| it as i64);
@@ -509,12 +509,9 @@ pub fn handle_signature_help(
     }
 }
 
-pub fn handle_hover(
-    world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
-) -> Result<Option<Hover>> {
+pub fn handle_hover(world: WorldSnapshot, params: req::HoverParams) -> Result<Option<Hover>> {
     let _p = profile("handle_hover");
-    let position = params.try_conv_with(&world)?;
+    let position = params.text_document_position_params.try_conv_with(&world)?;
     let info = match world.analysis().hover(position)? {
         None => return Ok(None),
         Some(info) => info,
@@ -878,8 +875,14 @@ pub fn handle_code_lens(
             .map(|it| {
                 let range = it.node_range.conv_with(&line_index);
                 let pos = range.start;
-                let lens_params =
-                    req::TextDocumentPositionParams::new(params.text_document.clone(), pos);
+                let lens_params = req::GotoImplementationParams {
+                    text_document_position_params: req::TextDocumentPositionParams::new(
+                        params.text_document.clone(),
+                        pos,
+                    ),
+                    work_done_progress_params: Default::default(),
+                    partial_result_params: Default::default(),
+                };
                 CodeLens {
                     range,
                     command: None,
@@ -894,7 +897,7 @@ pub fn handle_code_lens(
 #[derive(Debug, Serialize, Deserialize)]
 #[serde(rename_all = "camelCase")]
 enum CodeLensResolveData {
-    Impls(req::TextDocumentPositionParams),
+    Impls(req::GotoImplementationParams),
 }
 
 pub 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
                 title,
                 command: "rust-analyzer.showReferences".into(),
                 arguments: Some(vec![
-                    to_value(&lens_params.text_document.uri).unwrap(),
+                    to_value(&lens_params.text_document_position_params.text_document.uri).unwrap(),
                     to_value(code_lens.range.start).unwrap(),
                     to_value(locations).unwrap(),
                 ]),
@@ -944,16 +947,16 @@ pub fn handle_code_lens_resolve(world: WorldSnapshot, code_lens: CodeLens) -> Re
 
 pub fn handle_document_highlight(
     world: WorldSnapshot,
-    params: req::TextDocumentPositionParams,
+    params: req::DocumentHighlightParams,
 ) -> Result<Option<Vec<DocumentHighlight>>> {
     let _p = profile("handle_document_highlight");
-    let file_id = params.text_document.try_conv_with(&world)?;
+    let file_id = params.text_document_position_params.text_document.try_conv_with(&world)?;
     let line_index = world.analysis().file_line_index(file_id)?;
 
-    let refs = match world
-        .analysis()
-        .find_all_refs(params.try_conv_with(&world)?, Some(SearchScope::single_file(file_id)))?
-    {
+    let refs = match world.analysis().find_all_refs(
+        params.text_document_position_params.try_conv_with(&world)?,
+        Some(SearchScope::single_file(file_id)),
+    )? {
         None => return Ok(None),
         Some(refs) => refs,
     };
index ae34488929f688c3569f4a2e5bdbbc140ea2ef1b..0dae6bad4ff2333d0d82aea3a62df8bd70dcaa4e 100644 (file)
@@ -8,14 +8,15 @@
     notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
     CodeLensParams, CompletionParams, CompletionResponse, ConfigurationItem, ConfigurationParams,
     DiagnosticTag, DidChangeConfigurationParams, DidChangeWatchedFilesParams,
-    DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams,
-    DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType,
-    PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken,
-    PublishDiagnosticsParams, ReferenceParams, Registration, RegistrationParams, SelectionRange,
-    SelectionRangeParams, SemanticTokensParams, SemanticTokensRangeParams,
+    DidChangeWatchedFilesRegistrationOptions, DocumentHighlightParams,
+    DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse,
+    FileSystemWatcher, GotoDefinitionParams, GotoDefinitionResponse, Hover, HoverParams,
+    InitializeResult, MessageType, PartialResultParams, ProgressParams, ProgressParamsValue,
+    ProgressToken, PublishDiagnosticsParams, ReferenceParams, Registration, RegistrationParams,
+    SelectionRange, SelectionRangeParams, SemanticTokensParams, SemanticTokensRangeParams,
     SemanticTokensRangeResult, SemanticTokensResult, ServerCapabilities, ShowMessageParams,
-    SignatureHelp, SymbolKind, TextDocumentEdit, TextDocumentPositionParams, TextEdit,
-    WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams,
+    SignatureHelp, SignatureHelpParams, SymbolKind, TextDocumentEdit, TextDocumentPositionParams,
+    TextEdit, WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams,
 };
 use std::path::PathBuf;
 
index f6245ddd47ac96039bd2268c1d47a243752577c1..07b8114c613996d15b47ccaf92c4c23ef49f80bc 100644 (file)
@@ -4,8 +4,8 @@
 
 use lsp_types::{
     CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions,
-    PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams,
-    WorkDoneProgressParams,
+    GotoDefinitionParams, HoverParams, PartialResultParams, Position, Range, TextDocumentItem,
+    TextDocumentPositionParams, WorkDoneProgressParams,
 };
 use rust_analyzer::req::{
     CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument,
@@ -610,10 +610,14 @@ fn main() {
     })
     .server();
     server.wait_until_workspace_is_loaded();
-    let res = server.send_request::<GotoDefinition>(TextDocumentPositionParams::new(
-        server.doc_id("src/main.rs"),
-        Position::new(2, 15),
-    ));
+    let res = server.send_request::<GotoDefinition>(GotoDefinitionParams {
+        text_document_position_params: TextDocumentPositionParams::new(
+            server.doc_id("src/main.rs"),
+            Position::new(2, 15),
+        ),
+        work_done_progress_params: Default::default(),
+        partial_result_params: Default::default(),
+    });
     assert!(format!("{}", res).contains("hello.rs"));
 }
 
@@ -692,10 +696,13 @@ pub fn foo(_input: TokenStream) -> TokenStream {
     .root("bar")
     .server();
     server.wait_until_workspace_is_loaded();
-    let res = server.send_request::<HoverRequest>(TextDocumentPositionParams::new(
-        server.doc_id("foo/src/main.rs"),
-        Position::new(7, 9),
-    ));
+    let res = server.send_request::<HoverRequest>(HoverParams {
+        text_document_position_params: TextDocumentPositionParams::new(
+            server.doc_id("foo/src/main.rs"),
+            Position::new(7, 9),
+        ),
+        work_done_progress_params: Default::default(),
+    });
 
     let value = res.get("contents").unwrap().get("value").unwrap().to_string();
     assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#)