Repository: rust-analyzer/rust-analyzer
Pull request #2528 (2019-12-11 16:38:05)

Revert "Support LSP 3.15"


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 3c567376e4..caa52fb69d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -620,7 +620,7 @@ dependencies = [
 
 [[package]]
 name = "lsp-types"
-version = "0.63.0"
+version = "0.61.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1048,7 +1048,7 @@ dependencies = [
  "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "lsp-types 0.63.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lsp-types 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ra_ide 0.1.0",
  "ra_prof 0.1.0",
@@ -1839,7 +1839,7 @@ dependencies = [
 "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586"
 "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
 "checksum lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ba36405bd742139ab79c246ca5adb7fde2fe1a0f495e2c8e2f607b607dedb12"
-"checksum lsp-types 0.63.0 (registry+https://github.com/rust-lang/crates.io-index)" = "031d6b53a686f8eef69138f5b834b7eadadb0dd86f4c888504476ee1b17ae8d7"
+"checksum lsp-types 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa3268fbe8beb2795c2fb327bf44f4f3d24f5fe9ebc18d7e2980afd444d72bcf"
 "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
 "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
 "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index c50cb8031d..41672eaffe 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -14,7 +14,7 @@ serde_json = "1.0.34"
 serde = { version = "1.0.83", features = ["derive"] }
 crossbeam-channel = "0.4"
 log = "0.4.3"
-lsp-types = { version = "0.63.0", features = ["proposed"] }
+lsp-types = { version = "0.61.0", features = ["proposed"] }
 rustc-hash = "1.0"
 parking_lot = "0.10.0"
 jod-thread = "0.1.0"
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs
index 4cb259360b..eea0965edb 100644
--- a/crates/ra_lsp_server/src/caps.rs
+++ b/crates/ra_lsp_server/src/caps.rs
@@ -5,7 +5,7 @@ use lsp_types::{
     DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability,
     ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities,
     SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind,
-    TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions,
+    TextDocumentSyncOptions, TypeDefinitionProviderCapability,
 };
 
 pub fn server_capabilities() -> ServerCapabilities {
@@ -21,14 +21,10 @@ pub fn server_capabilities() -> ServerCapabilities {
         completion_provider: Some(CompletionOptions {
             resolve_provider: None,
             trigger_characters: Some(vec![":".to_string(), ".".to_string()]),
-            work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
         }),
         signature_help_provider: Some(SignatureHelpOptions {
             trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]),
-            retrigger_characters: None,
-            work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
         }),
-        declaration_provider: None,
         definition_provider: Some(true),
         type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)),
         implementation_provider: Some(ImplementationProviderCapability::Simple(true)),
@@ -48,7 +44,6 @@ pub fn server_capabilities() -> ServerCapabilities {
         folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)),
         rename_provider: Some(RenameProviderCapability::Options(RenameOptions {
             prepare_provider: Some(true),
-            work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
         })),
         document_link_provider: None,
         color_provider: None,
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 158cac0be1..83845f1e00 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -520,8 +520,7 @@ fn on_notification(
             if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) {
                 subs.remove_sub(FileId(file_id.0));
             }
-            let params =
-                req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None };
+            let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() };
             let not = notification_new::<req::PublishDiagnostics>(params);
             msg_sender.send(not.into()).unwrap();
             return Ok(());
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 5b64b27cd2..4095836344 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -648,7 +648,6 @@ pub fn handle_code_action(
             diagnostics: None,
             edit: None,
             command: Some(command),
-            is_preferred: None,
         };
         res.push(action.into());
     }
@@ -671,7 +670,6 @@ pub fn handle_code_action(
             diagnostics: None,
             edit: None,
             command: Some(command),
-            is_preferred: None,
         };
         res.push(action.into());
     }
@@ -830,10 +828,9 @@ pub fn publish_diagnostics(
             source: Some("rust-analyzer".to_string()),
             message: d.message,
             related_information: None,
-            tags: None,
         })
         .collect();
-    Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None })
+    Ok(req::PublishDiagnosticsParams { uri, diagnostics })
 }
 
 pub fn publish_decorations(
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index 2777ced247..9e4ce0eb3c 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -9,7 +9,7 @@ export class TextDocumentContentProvider
     public syntaxTree: string = 'Not available';
 
     public provideTextDocumentContent(
-        _uri: vscode.Uri,
+        uri: vscode.Uri,
     ): vscode.ProviderResult<string> {
         const editor = vscode.window.activeTextEditor;
         if (editor == null) {
diff --git a/editors/code/src/commands/expand_macro.ts b/editors/code/src/commands/expand_macro.ts
index 17c78280a8..842898020b 100644
--- a/editors/code/src/commands/expand_macro.ts
+++ b/editors/code/src/commands/expand_macro.ts
@@ -11,7 +11,7 @@ export class ExpandMacroContentProvider
     public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
 
     public provideTextDocumentContent(
-        _uri: vscode.Uri,
+        uri: vscode.Uri,
     ): vscode.ProviderResult<string> {
         async function handle() {
             const editor = vscode.window.activeTextEditor;
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index cf980e2578..9b1c6643d4 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -73,7 +73,7 @@ function createTask(spec: Runnable): vscode.Task {
 }
 
 let prevRunnable: RunnableQuickPick | undefined;
-export async function handle(): Promise<vscode.TaskExecution | undefined> {
+export async function handle() {
     const editor = vscode.window.activeTextEditor;
     if (editor == null || editor.document.languageId !== 'rust') {
         return;
@@ -105,14 +105,12 @@ export async function handle(): Promise<vscode.TaskExecution | undefined> {
         items.push(new RunnableQuickPick(r));
     }
     const item = await vscode.window.showQuickPick(items);
-    if (!item) {
-        return;
+    if (item) {
+        item.detail = 'rerun';
+        prevRunnable = item;
+        const task = createTask(item.runnable);
+        return await vscode.tasks.executeTask(task);
     }
-
-    item.detail = 'rerun';
-    prevRunnable = item;
-    const task = createTask(item.runnable);
-    return await vscode.tasks.executeTask(task);
 }
 
 export async function handleSingle(runnable: Runnable) {
@@ -180,7 +178,7 @@ export async function startCargoWatch(
         }
 
         const label = 'install-cargo-watch';
-        const taskFinished = new Promise((resolve, _reject) => {
+        const taskFinished = new Promise((resolve, reject) => {
             const disposable = vscode.tasks.onDidEndTask(({ execution }) => {
                 if (execution.task.name === label) {
                     disposable.dispose();
diff --git a/editors/code/tsconfig.json b/editors/code/tsconfig.json
index 5e11c37751..9ad2e967b2 100644
--- a/editors/code/tsconfig.json
+++ b/editors/code/tsconfig.json
@@ -1,16 +1,13 @@
 {
     "compilerOptions": {
         "module": "commonjs",
-        "target": "es2018",
+        "target": "es6",
         "outDir": "out",
-        "lib": ["es2018"],
+        "lib": ["es6"],
         "sourceMap": true,
         "rootDir": "src",
         "strict": true,
-        "noUnusedLocals": true,
-        "noUnusedParameters": true,
-        "noImplicitReturns": true,
-        "noFallthroughCasesInSwitch": true
+        "noUnusedLocals": true
     },
     "exclude": ["node_modules", ".vscode-test"]
 }
diff --git a/editors/code/tslint.json b/editors/code/tslint.json
index b69c5574d2..bdeb4895ee 100644
--- a/editors/code/tslint.json
+++ b/editors/code/tslint.json
@@ -4,8 +4,6 @@
     "rules": {
         "quotemark": [true, "single"],
         "interface-name": false,
-        "object-literal-sort-keys": false,
-        // Allow `_bar` to sort with tsc's `noUnusedParameters` option
-        "variable-name": [true, "allow-leading-underscore"]
+        "object-literal-sort-keys": false
     }
 }


Test patch:
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index dff63a12d4..cfbf16ea5f 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -4,8 +4,7 @@ use std::{collections::HashMap, time::Instant};
 
 use lsp_types::{
     CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions,
-    PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams,
-    WorkDoneProgressParams,
+    Position, Range, TextDocumentItem, TextDocumentPositionParams,
 };
 use ra_lsp_server::req::{
     CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument,
@@ -49,8 +48,6 @@ use std::collections::Spam;
             Position::new(0, 23),
         ),
         context: None,
-        partial_result_params: PartialResultParams::default(),
-        work_done_progress_params: WorkDoneProgressParams::default(),
     });
     assert!(format!("{}", res).contains("HashMap"));
     eprintln!("completion took {:?}", completion_start.elapsed());
@@ -214,12 +211,8 @@ pub use std::collections::HashMap;
             options: FormattingOptions {
                 tab_size: 4,
                 insert_spaces: false,
-                insert_final_newline: None,
-                trim_final_newlines: None,
-                trim_trailing_whitespace: None,
                 properties: HashMap::new(),
             },
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([
             {
@@ -279,11 +272,7 @@ pub use std::collections::HashMap;
                 tab_size: 4,
                 insert_spaces: false,
                 properties: HashMap::new(),
-                insert_final_newline: None,
-                trim_final_newlines: None,
-                trim_trailing_whitespace: None,
             },
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([
             {
@@ -336,8 +325,6 @@ fn main() {}
             text_document: server.doc_id("src/lib.rs"),
             range: Range::new(Position::new(0, 4), Position::new(0, 7)),
             context: empty_context(),
-            partial_result_params: PartialResultParams::default(),
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([
           {
@@ -369,8 +356,6 @@ fn main() {}
             text_document: server.doc_id("src/lib.rs"),
             range: Range::new(Position::new(2, 4), Position::new(2, 7)),
             context: empty_context(),
-            partial_result_params: PartialResultParams::default(),
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([]),
     );
@@ -419,8 +404,6 @@ fn main() {{}}
             text_document: server.doc_id("src/lib.rs"),
             range: Range::new(Position::new(0, 4), Position::new(0, 7)),
             context: empty_context(),
-            partial_result_params: PartialResultParams::default(),
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([
           {
@@ -452,8 +435,6 @@ fn main() {{}}
             text_document: server.doc_id("src/lib.rs"),
             range: Range::new(Position::new(2, 4), Position::new(2, 7)),
             context: empty_context(),
-            partial_result_params: PartialResultParams::default(),
-            work_done_progress_params: WorkDoneProgressParams::default(),
         },
         json!([]),
     );
diff --git a/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts b/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
index 2b25eb705d..96ec8c614d 100644
--- a/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
+++ b/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
@@ -114,8 +114,7 @@ describe('SuggestedFix', () => {
 
             const edit = codeAction.edit;
             if (!edit) {
-                assert.fail('Code Action edit unexpectedly missing');
-                return;
+                return assert.fail('Code Action edit unexpectedly missing');
             }
 
             const editEntries = edit.entries();
diff --git a/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts b/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
index ef09013f41..4c1467b576 100644
--- a/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
+++ b/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
@@ -53,8 +53,7 @@ describe('SuggestedFixCollection', () => {
 
         const { diagnostics } = codeAction;
         if (!diagnostics) {
-            assert.fail('Diagnostics unexpectedly missing');
-            return;
+            return assert.fail('Diagnostics unexpectedly missing');
         }
 
         assert.strictEqual(diagnostics.length, 1);
@@ -115,8 +114,7 @@ describe('SuggestedFixCollection', () => {
         const { diagnostics } = codeAction;
 
         if (!diagnostics) {
-            assert.fail('Diagnostics unexpectedly missing');
-            return;
+            return assert.fail('Diagnostics unexpectedly missing');
         }
 
         // We should be associated with both diagnostics
diff --git a/editors/code/src/test/utils/diagnotics/rust.test.ts b/editors/code/src/test/utils/diagnotics/rust.test.ts
index 0222dbbaa0..cee59061f3 100644
--- a/editors/code/src/test/utils/diagnotics/rust.test.ts
+++ b/editors/code/src/test/utils/diagnotics/rust.test.ts
@@ -120,8 +120,7 @@ describe('mapRustDiagnosticToVsCode', () => {
         // One related information for the original definition
         const relatedInformation = diagnostic.relatedInformation;
         if (!relatedInformation) {
-            assert.fail('Related information unexpectedly undefined');
-            return;
+            return assert.fail('Related information unexpectedly undefined');
         }
         assert.strictEqual(relatedInformation.length, 1);
         const [related] = relatedInformation;
@@ -155,8 +154,7 @@ describe('mapRustDiagnosticToVsCode', () => {
         // One related information for the lint definition
         const relatedInformation = diagnostic.relatedInformation;
         if (!relatedInformation) {
-            assert.fail('Related information unexpectedly undefined');
-            return;
+            return assert.fail('Related information unexpectedly undefined');
         }
         assert.strictEqual(relatedInformation.length, 1);
         const [related] = relatedInformation;