From 2ac4ce50011faa4ea9edc63000c241564ab04194 Mon Sep 17 00:00:00 2001 From: Jens Hausdorf Date: Fri, 11 Jan 2019 18:38:54 +0100 Subject: [PATCH 1/2] Fix https://github.com/rust-lang/rls/issues/1231 --- src/actions/mod.rs | 10 -- src/lib.rs | 10 -- src/lsp_data.rs | 10 -- src/main.rs | 10 -- tests/fixtures/common/src/main.rs | 9 - .../find_all_refs_no_cfg_test/src/main.rs | 9 - tests/fixtures/workspace_symbol/src/main.rs | 10 -- .../workspace_symbol_duplicates/src/main.rs | 10 -- .../workspace_symbol_duplicates/src/shared.rs | 10 -- tests/support/harness.rs | 10 -- tests/support/mod.rs | 10 -- tests/support/paths.rs | 10 -- tests/tests.rs | 162 ++++++++---------- tests/tests_old.rs | 10 -- 14 files changed, 76 insertions(+), 214 deletions(-) diff --git a/src/actions/mod.rs b/src/actions/mod.rs index 2c3150ecb63..0c0ed16123f 100644 --- a/src/actions/mod.rs +++ b/src/actions/mod.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Actions that the RLS can perform: responding to requests, watching files, //! etc. diff --git a/src/lib.rs b/src/lib.rs index 615f178c219..1d366fef6ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! The Rust Language Server. //! //! The RLS provides a server that runs in the background, providing IDEs, diff --git a/src/lsp_data.rs b/src/lsp_data.rs index 3f933134f2d..62090a0aea9 100644 --- a/src/lsp_data.rs +++ b/src/lsp_data.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Types, helpers, and conversions to and from LSP and `racer` types. use std::error::Error; diff --git a/src/main.rs b/src/main.rs index a054615618d..ccc6607641a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! The Rust Language Server. //! //! The RLS provides a server that runs in the background, providing IDEs, diff --git a/tests/fixtures/common/src/main.rs b/tests/fixtures/common/src/main.rs index 442dd8c70ad..cc080b6ec9e 100644 --- a/tests/fixtures/common/src/main.rs +++ b/tests/fixtures/common/src/main.rs @@ -1,12 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. struct Bar { x: u64, } diff --git a/tests/fixtures/find_all_refs_no_cfg_test/src/main.rs b/tests/fixtures/find_all_refs_no_cfg_test/src/main.rs index 80334eec64f..3e28c011e43 100644 --- a/tests/fixtures/find_all_refs_no_cfg_test/src/main.rs +++ b/tests/fixtures/find_all_refs_no_cfg_test/src/main.rs @@ -1,12 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. struct Bar { x: u64, } diff --git a/tests/fixtures/workspace_symbol/src/main.rs b/tests/fixtures/workspace_symbol/src/main.rs index 8c122e7bee6..12332a0f0a1 100644 --- a/tests/fixtures/workspace_symbol/src/main.rs +++ b/tests/fixtures/workspace_symbol/src/main.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - mod x { pub fn nemo() {} } diff --git a/tests/fixtures/workspace_symbol_duplicates/src/main.rs b/tests/fixtures/workspace_symbol_duplicates/src/main.rs index 3926f6996d0..fc450be19d0 100644 --- a/tests/fixtures/workspace_symbol_duplicates/src/main.rs +++ b/tests/fixtures/workspace_symbol_duplicates/src/main.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[path="shared.rs"] mod a; #[path="shared.rs"] diff --git a/tests/fixtures/workspace_symbol_duplicates/src/shared.rs b/tests/fixtures/workspace_symbol_duplicates/src/shared.rs index 30c1525a7f6..6d441ae8179 100644 --- a/tests/fixtures/workspace_symbol_duplicates/src/shared.rs +++ b/tests/fixtures/workspace_symbol_duplicates/src/shared.rs @@ -1,12 +1,2 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(unused)] struct Frobnicator; diff --git a/tests/support/harness.rs b/tests/support/harness.rs index d8f4bcc2e32..d7a76a8d49a 100644 --- a/tests/support/harness.rs +++ b/tests/support/harness.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::expect_fun_call)] use std::collections::HashMap; diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 4d3b3d4aef4..b52c0127fad 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use serde_json::{self, json}; use std::env; diff --git a/tests/support/paths.rs b/tests/support/paths.rs index d76f6271ae7..6a56849e0cb 100644 --- a/tests/support/paths.rs +++ b/tests/support/paths.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unknown_lints)] use std::cell::Cell; diff --git a/tests/tests.rs b/tests/tests.rs index 50f3303c4ca..5d795d4b84e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use serde_json::{self, json}; use std::io::Write; @@ -307,27 +297,27 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() { rls.notify( "textDocument/didChange", Some(json!({ - "contentChanges": [ - { - "range": { - "start": { - "line": 1, - "character": 38, - }, - "end": { - "line": 1, - "character": 41, - } + "contentChanges": [ + { + "range": { + "start": { + "line": 1, + "character": 38, }, - "rangeLength": 3, - "text": "u64" - } - ], - "textDocument": { - "uri": format!("file://{}/library/src/lib.rs", root_path.display()), - "version": 0 + "end": { + "line": 1, + "character": 41, + } + }, + "rangeLength": 3, + "text": "u64" } - })), + ], + "textDocument": { + "uri": format!("file://{}/library/src/lib.rs", root_path.display()), + "version": 0 + } + })), ) .unwrap(); @@ -362,27 +352,27 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() { rls.notify( "textDocument/didChange", Some(json!({ - "contentChanges": [ - { - "range": { - "start": { - "line": 1, - "character": 38, - }, - "end": { - "line": 1, - "character": 41, - } + "contentChanges": [ + { + "range": { + "start": { + "line": 1, + "character": 38, }, - "rangeLength": 3, - "text": "u32" - } - ], - "textDocument": { - "uri": format!("file://{}/library/src/lib.rs", root_path.display()), - "version": 1 + "end": { + "line": 1, + "character": 41, + } + }, + "rangeLength": 3, + "text": "u32" } - })), + ], + "textDocument": { + "uri": format!("file://{}/library/src/lib.rs", root_path.display()), + "version": 1 + } + })), ) .unwrap(); @@ -478,27 +468,27 @@ fn cmd_implicit_workspace_pick_up_lib_changes() { rls.notify( "textDocument/didChange", Some(json!({ - "contentChanges": [ - { - "range": { - "start": { - "line": 1, - "character": 23, - }, - "end": { - "line": 1, - "character": 26, - } + "contentChanges": [ + { + "range": { + "start": { + "line": 1, + "character": 23, }, - "rangeLength": 3, - "text": "bar" - } - ], - "textDocument": { - "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), - "version": 0 + "end": { + "line": 1, + "character": 26, + } + }, + "rangeLength": 3, + "text": "bar" } - })), + ], + "textDocument": { + "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), + "version": 0 + } + })), ) .unwrap(); @@ -520,27 +510,27 @@ fn cmd_implicit_workspace_pick_up_lib_changes() { rls.notify( "textDocument/didChange", Some(json!({ - "contentChanges": [ - { - "range": { - "start": { - "line": 1, - "character": 23, - }, - "end": { - "line": 1, - "character": 26, - } + "contentChanges": [ + { + "range": { + "start": { + "line": 1, + "character": 23, }, - "rangeLength": 3, - "text": "foo" - } - ], - "textDocument": { - "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), - "version": 1 + "end": { + "line": 1, + "character": 26, + } + }, + "rangeLength": 3, + "text": "foo" } - })), + ], + "textDocument": { + "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), + "version": 1 + } + })), ) .unwrap(); diff --git a/tests/tests_old.rs b/tests/tests_old.rs index e9f97852b71..d8510bc3e5f 100644 --- a/tests/tests_old.rs +++ b/tests/tests_old.rs @@ -1,13 +1,3 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::cyclomatic_complexity)] use rls::actions::{notifications, requests}; From 16e888138055a0c994f96ed6eea176dc23002e58 Mon Sep 17 00:00:00 2001 From: Jens Hausdorf Date: Sat, 12 Jan 2019 11:22:19 +0100 Subject: [PATCH 2/2] Fix tests --- tests/tests_old.rs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/tests_old.rs b/tests/tests_old.rs index d8510bc3e5f..d9a34f7d19e 100644 --- a/tests/tests_old.rs +++ b/tests/tests_old.rs @@ -134,7 +134,7 @@ fn test_goto_def() { text_document: TextDocumentIdentifier::new(url), position: env .cache - .mk_ls_position(src(&source_file_path, 22, "world")), + .mk_ls_position(src(&source_file_path, 13, "world")), }, ).to_string(), ]; @@ -162,7 +162,7 @@ fn test_goto_def() { expect_message( &mut server, results, - ExpectedMessage::new(Some(11)).expect_contains(r#""start":{"line":20,"character":8}"#), + ExpectedMessage::new(Some(11)).expect_contains(r#""start":{"line":11,"character":8}"#), ); } @@ -184,7 +184,7 @@ fn test_hover() { text_document: TextDocumentIdentifier::new(url), position: env .cache - .mk_ls_position(src(&source_file_path, 22, "world")), + .mk_ls_position(src(&source_file_path, 13, "world")), }, ).to_string(), ]; @@ -228,7 +228,7 @@ fn test_hover_after_src_line_change() { let world_src_pos = env .cache - .mk_ls_position(src(&source_file_path, 21, "world")); + .mk_ls_position(src(&source_file_path, 12, "world")); let world_src_pos_after = Position { line: world_src_pos.line + 1, ..world_src_pos @@ -251,11 +251,11 @@ fn test_hover_after_src_line_change() { content_changes: vec![TextDocumentContentChangeEvent { range: Some(Range { start: Position { - line: 19, + line: 10, character: 15, }, end: Position { - line: 19, + line: 10, character: 15, }, }), @@ -361,7 +361,7 @@ fn test_workspace_symbol() { .expect_contains(r#"main.rs"#) .expect_contains(r#""name":"nemo""#) .expect_contains(r#""kind":12"#) - .expect_contains(r#""range":{"start":{"line":11,"character":11},"end":{"line":11,"character":15}}"#) + .expect_contains(r#""range":{"start":{"line":1,"character":11},"end":{"line":1,"character":15}}"#) .expect_contains(r#""containerName":"x""#) // in foo.rs @@ -421,8 +421,8 @@ fn test_workspace_symbol_duplicates() { "kind": 23, "location": { "range": { - "end": { "line": 11, "character": 18 }, - "start": { "line": 11, "character": 7 } + "end": { "line": 1, "character": 18 }, + "start": { "line": 1, "character": 7 } }, "uri": "shared.rs" }, @@ -447,7 +447,7 @@ fn test_find_all_refs() { 42, ReferenceParams { text_document: TextDocumentIdentifier::new(url), - position: env.cache.mk_ls_position(src(&source_file_path, 10, "Bar")), + position: env.cache.mk_ls_position(src(&source_file_path, 1, "Bar")), context: ReferenceContext { include_declaration: true, }, @@ -479,11 +479,11 @@ fn test_find_all_refs() { results, ExpectedMessage::new(Some(42)) .expect_contains( - r#"{"start":{"line":9,"character":7},"end":{"line":9,"character":10}}"#, + r#"{"start":{"line":0,"character":7},"end":{"line":0,"character":10}}"#, ).expect_contains( - r#"{"start":{"line":15,"character":14},"end":{"line":15,"character":17}}"#, + r#"{"start":{"line":6,"character":14},"end":{"line":6,"character":17}}"#, ).expect_contains( - r#"{"start":{"line":23,"character":15},"end":{"line":23,"character":18}}"#, + r#"{"start":{"line":14,"character":15},"end":{"line":14,"character":18}}"#, ), ); } @@ -505,7 +505,7 @@ fn test_find_all_refs_no_cfg_test() { 42, ReferenceParams { text_document: TextDocumentIdentifier::new(url), - position: env.cache.mk_ls_position(src(&source_file_path, 10, "Bar")), + position: env.cache.mk_ls_position(src(&source_file_path, 1, "Bar")), context: ReferenceContext { include_declaration: true, }, @@ -536,9 +536,9 @@ fn test_find_all_refs_no_cfg_test() { results, ExpectedMessage::new(Some(42)) .expect_contains( - r#"{"start":{"line":9,"character":7},"end":{"line":9,"character":10}}"#, + r#"{"start":{"line":0,"character":7},"end":{"line":0,"character":10}}"#, ).expect_contains( - r#"{"start":{"line":22,"character":15},"end":{"line":22,"character":18}}"#, + r#"{"start":{"line":13,"character":15},"end":{"line":13,"character":18}}"#, ), ); } @@ -593,7 +593,7 @@ fn test_highlight() { text_document: TextDocumentIdentifier::new(url), position: env .cache - .mk_ls_position(src(&source_file_path, 22, "world")), + .mk_ls_position(src(&source_file_path, 13, "world")), }, ).to_string(), ]; @@ -621,9 +621,9 @@ fn test_highlight() { results, ExpectedMessage::new(Some(42)) .expect_contains( - r#"{"start":{"line":20,"character":8},"end":{"line":20,"character":13}}"#, + r#"{"start":{"line":11,"character":8},"end":{"line":11,"character":13}}"#, ).expect_contains( - r#"{"start":{"line":21,"character":27},"end":{"line":21,"character":32}}"#, + r#"{"start":{"line":12,"character":27},"end":{"line":12,"character":32}}"#, ), ); } @@ -646,7 +646,7 @@ fn test_rename() { text_document: text_doc, position: env .cache - .mk_ls_position(src(&source_file_path, 22, "world")), + .mk_ls_position(src(&source_file_path, 13, "world")), new_name: "foo".to_owned(), }, ).to_string(), @@ -676,9 +676,9 @@ fn test_rename() { results, ExpectedMessage::new(Some(42)) .expect_contains( - r#"{"start":{"line":20,"character":8},"end":{"line":20,"character":13}}"#, + r#"{"start":{"line":11,"character":8},"end":{"line":11,"character":13}}"#, ).expect_contains( - r#"{"start":{"line":21,"character":27},"end":{"line":21,"character":32}}"#, + r#"{"start":{"line":12,"character":27},"end":{"line":12,"character":32}}"#, ).expect_contains(r#"{"changes""#), ); } @@ -1744,7 +1744,7 @@ fn fail_uninitialized_request() { text_document: TextDocumentIdentifier::new(url), position: env .cache - .mk_ls_position(src(&source_file_path, 22, "world")), + .mk_ls_position(src(&source_file_path, 13, "world")), }, ).to_string(), initialize(1, root_path.as_os_str().to_str().map(|x| x.to_owned())).to_string(),