From 171c176833c197bfd1b266940bd2a8c3d4d52cd5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 19:55:32 +0300 Subject: Run cargo fix --- crates/ra_syntax/src/algo/mod.rs | 2 +- crates/ra_syntax/src/algo/visit.rs | 2 +- crates/ra_syntax/src/algo/walk.rs | 2 +- crates/ra_syntax/src/ast/generated.rs | 2 +- crates/ra_syntax/src/ast/mod.rs | 2 +- crates/ra_syntax/src/grammar/mod.rs | 2 +- crates/ra_syntax/src/lexer/comments.rs | 4 ++-- crates/ra_syntax/src/lexer/mod.rs | 2 +- crates/ra_syntax/src/lexer/numbers.rs | 6 +++--- crates/ra_syntax/src/lexer/ptr.rs | 2 +- crates/ra_syntax/src/lexer/strings.rs | 4 ++-- crates/ra_syntax/src/lib.rs | 4 ++-- crates/ra_syntax/src/parser_api.rs | 2 +- crates/ra_syntax/src/parser_impl/event.rs | 2 +- crates/ra_syntax/src/parser_impl/input.rs | 2 +- crates/ra_syntax/src/parser_impl/mod.rs | 4 ++-- crates/ra_syntax/src/reparsing.rs | 16 ++++++++-------- crates/ra_syntax/src/syntax_kinds/mod.rs | 2 +- crates/ra_syntax/src/text_utils.rs | 2 +- crates/ra_syntax/src/token_set.rs | 4 ++-- crates/ra_syntax/src/utils.rs | 2 +- crates/ra_syntax/src/yellow/builder.rs | 2 +- crates/ra_syntax/src/yellow/mod.rs | 14 +++++++------- crates/ra_syntax/src/yellow/syntax_text.rs | 2 +- 24 files changed, 44 insertions(+), 44 deletions(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index a6678093d..e686a5704 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs @@ -1,7 +1,7 @@ pub mod walk; pub mod visit; -use { +use crate::{ SyntaxNodeRef, TextUnit, TextRange, text_utils::{contains_offset_nonstrict, is_subrange}, }; diff --git a/crates/ra_syntax/src/algo/visit.rs b/crates/ra_syntax/src/algo/visit.rs index 9f1c127c7..1ae988a87 100644 --- a/crates/ra_syntax/src/algo/visit.rs +++ b/crates/ra_syntax/src/algo/visit.rs @@ -1,5 +1,5 @@ use std::marker::PhantomData; -use {SyntaxNodeRef, AstNode}; +use crate::{SyntaxNodeRef, AstNode}; pub fn visitor<'a, T>() -> impl Visitor<'a, Output=T> { diff --git a/crates/ra_syntax/src/algo/walk.rs b/crates/ra_syntax/src/algo/walk.rs index 8e294d965..d34415626 100644 --- a/crates/ra_syntax/src/algo/walk.rs +++ b/crates/ra_syntax/src/algo/walk.rs @@ -1,4 +1,4 @@ -use { +use crate::{ SyntaxNodeRef, algo::generate, }; diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 4db1bcbf9..160d186b8 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1,7 +1,7 @@ // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run // Do not edit manually -use { +use crate::{ ast, SyntaxNodeRef, AstNode, SyntaxKind::*, diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs index 12ddc0210..88193a1ed 100644 --- a/crates/ra_syntax/src/ast/mod.rs +++ b/crates/ra_syntax/src/ast/mod.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use itertools::Itertools; -use { +use crate::{ SmolStr, SyntaxNodeRef, SyntaxKind::*, yellow::{RefRoot, SyntaxNodeChildren}, }; diff --git a/crates/ra_syntax/src/grammar/mod.rs b/crates/ra_syntax/src/grammar/mod.rs index 2cb11dc1e..1199ba230 100644 --- a/crates/ra_syntax/src/grammar/mod.rs +++ b/crates/ra_syntax/src/grammar/mod.rs @@ -31,7 +31,7 @@ mod type_args; mod type_params; mod types; -use { +use crate::{ token_set::TokenSet, parser_api::{Marker, CompletedMarker, Parser}, SyntaxKind::{self, *}, diff --git a/crates/ra_syntax/src/lexer/comments.rs b/crates/ra_syntax/src/lexer/comments.rs index eb417c2dc..afe6886a1 100644 --- a/crates/ra_syntax/src/lexer/comments.rs +++ b/crates/ra_syntax/src/lexer/comments.rs @@ -1,6 +1,6 @@ -use lexer::ptr::Ptr; +use crate::lexer::ptr::Ptr; -use SyntaxKind::{self, *}; +use crate::SyntaxKind::{self, *}; pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { if ptr.at_str("!/") { diff --git a/crates/ra_syntax/src/lexer/mod.rs b/crates/ra_syntax/src/lexer/mod.rs index 3e11db88b..9dc0b63d6 100644 --- a/crates/ra_syntax/src/lexer/mod.rs +++ b/crates/ra_syntax/src/lexer/mod.rs @@ -4,7 +4,7 @@ mod numbers; mod ptr; mod strings; -use { +use crate::{ SyntaxKind::{self, *}, TextUnit, }; diff --git a/crates/ra_syntax/src/lexer/numbers.rs b/crates/ra_syntax/src/lexer/numbers.rs index 22e7d4e99..46daf5e52 100644 --- a/crates/ra_syntax/src/lexer/numbers.rs +++ b/crates/ra_syntax/src/lexer/numbers.rs @@ -1,7 +1,7 @@ -use lexer::classes::*; -use lexer::ptr::Ptr; +use crate::lexer::classes::*; +use crate::lexer::ptr::Ptr; -use SyntaxKind::{self, *}; +use crate::SyntaxKind::{self, *}; pub(crate) fn scan_number(c: char, ptr: &mut Ptr) -> SyntaxKind { if c == '0' { diff --git a/crates/ra_syntax/src/lexer/ptr.rs b/crates/ra_syntax/src/lexer/ptr.rs index c9a5354ea..c4708cb1c 100644 --- a/crates/ra_syntax/src/lexer/ptr.rs +++ b/crates/ra_syntax/src/lexer/ptr.rs @@ -1,4 +1,4 @@ -use TextUnit; +use crate::TextUnit; use std::str::Chars; diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs index 5ff483d14..bceacdcac 100644 --- a/crates/ra_syntax/src/lexer/strings.rs +++ b/crates/ra_syntax/src/lexer/strings.rs @@ -1,6 +1,6 @@ -use SyntaxKind::{self, *}; +use crate::SyntaxKind::{self, *}; -use lexer::ptr::Ptr; +use crate::lexer::ptr::Ptr; pub(crate) fn is_string_literal_start(c: char, c1: Option, c2: Option) -> bool { match (c, c1, c2) { diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 703469629..5bb54aba1 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -46,7 +46,7 @@ mod yellow; pub mod utils; pub mod text_utils; -pub use { +pub use crate::{ rowan::{SmolStr, TextRange, TextUnit}, ast::AstNode, lexer::{tokenize, Token}, @@ -55,7 +55,7 @@ pub use { reparsing::AtomEdit, }; -use { +use crate::{ yellow::{GreenNode}, }; diff --git a/crates/ra_syntax/src/parser_api.rs b/crates/ra_syntax/src/parser_api.rs index 772d753af..cc23bb75e 100644 --- a/crates/ra_syntax/src/parser_api.rs +++ b/crates/ra_syntax/src/parser_api.rs @@ -1,4 +1,4 @@ -use { +use crate::{ token_set::TokenSet, parser_impl::ParserImpl, SyntaxKind::{self, ERROR}, diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index 95e5ce4cc..928d2cc7a 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs @@ -8,7 +8,7 @@ //! `start node`, `finish node`, and `FileBuilder` converts //! this stream to a real tree. use std::mem; -use { +use crate::{ TextUnit, TextRange, SmolStr, lexer::Token, parser_impl::Sink, diff --git a/crates/ra_syntax/src/parser_impl/input.rs b/crates/ra_syntax/src/parser_impl/input.rs index c0fe4d488..ac6d900d8 100644 --- a/crates/ra_syntax/src/parser_impl/input.rs +++ b/crates/ra_syntax/src/parser_impl/input.rs @@ -1,4 +1,4 @@ -use {lexer::Token, SyntaxKind, SyntaxKind::EOF, TextRange, TextUnit}; +use crate::{lexer::Token, SyntaxKind, SyntaxKind::EOF, TextRange, TextUnit}; use std::ops::{Add, AddAssign}; diff --git a/crates/ra_syntax/src/parser_impl/mod.rs b/crates/ra_syntax/src/parser_impl/mod.rs index 8d74cef0e..c2a6448e7 100644 --- a/crates/ra_syntax/src/parser_impl/mod.rs +++ b/crates/ra_syntax/src/parser_impl/mod.rs @@ -3,7 +3,7 @@ mod input; use std::cell::Cell; -use { +use crate::{ TextUnit, SmolStr, lexer::Token, parser_api::Parser, @@ -13,7 +13,7 @@ use { }, }; -use SyntaxKind::{self, EOF, TOMBSTONE}; +use crate::SyntaxKind::{self, EOF, TOMBSTONE}; pub(crate) trait Sink { type Tree; diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs index d8b6a6a10..16272fe88 100644 --- a/crates/ra_syntax/src/reparsing.rs +++ b/crates/ra_syntax/src/reparsing.rs @@ -1,14 +1,14 @@ -use algo; -use grammar; -use lexer::{tokenize, Token}; -use yellow::{self, GreenNode, SyntaxNodeRef, SyntaxError}; -use parser_impl; -use parser_api::Parser; -use { +use crate::algo; +use crate::grammar; +use crate::lexer::{tokenize, Token}; +use crate::yellow::{self, GreenNode, SyntaxNodeRef, SyntaxError}; +use crate::parser_impl; +use crate::parser_api::Parser; +use crate::{ TextUnit, TextRange, SyntaxKind::*, }; -use text_utils::replace_range; +use crate::text_utils::replace_range; #[derive(Debug, Clone)] pub struct AtomEdit { diff --git a/crates/ra_syntax/src/syntax_kinds/mod.rs b/crates/ra_syntax/src/syntax_kinds/mod.rs index 332cd13ac..3041e5633 100644 --- a/crates/ra_syntax/src/syntax_kinds/mod.rs +++ b/crates/ra_syntax/src/syntax_kinds/mod.rs @@ -1,7 +1,7 @@ mod generated; use std::fmt; -use SyntaxKind::*; +use crate::SyntaxKind::*; pub use self::generated::SyntaxKind; diff --git a/crates/ra_syntax/src/text_utils.rs b/crates/ra_syntax/src/text_utils.rs index 58ae1e43e..adf26ef30 100644 --- a/crates/ra_syntax/src/text_utils.rs +++ b/crates/ra_syntax/src/text_utils.rs @@ -1,4 +1,4 @@ -use {TextRange, TextUnit}; +use crate::{TextRange, TextUnit}; pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool { range.start() <= offset && offset <= range.end() diff --git a/crates/ra_syntax/src/token_set.rs b/crates/ra_syntax/src/token_set.rs index c83fba81b..d407dfa48 100644 --- a/crates/ra_syntax/src/token_set.rs +++ b/crates/ra_syntax/src/token_set.rs @@ -1,4 +1,4 @@ -use SyntaxKind; +use crate::SyntaxKind; #[derive(Clone, Copy)] pub(crate) struct TokenSet(pub(crate) u128); @@ -29,7 +29,7 @@ macro_rules! token_set_union { #[test] fn token_set_works_for_tokens() { - use SyntaxKind::*; + use crate::SyntaxKind::*; let ts = token_set! { EOF, SHEBANG }; assert!(ts.contains(EOF)); assert!(ts.contains(SHEBANG)); diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs index e274f7471..df1f4b372 100644 --- a/crates/ra_syntax/src/utils.rs +++ b/crates/ra_syntax/src/utils.rs @@ -1,5 +1,5 @@ use std::fmt::Write; -use { +use crate::{ algo::walk::{walk, WalkEvent}, SyntaxKind, File, SyntaxNodeRef }; diff --git a/crates/ra_syntax/src/yellow/builder.rs b/crates/ra_syntax/src/yellow/builder.rs index c307b2bd0..67a1a382b 100644 --- a/crates/ra_syntax/src/yellow/builder.rs +++ b/crates/ra_syntax/src/yellow/builder.rs @@ -1,5 +1,5 @@ use rowan::GreenNodeBuilder; -use { +use crate::{ TextUnit, SmolStr, parser_impl::Sink, yellow::{GreenNode, SyntaxError, RaTypes}, diff --git a/crates/ra_syntax/src/yellow/mod.rs b/crates/ra_syntax/src/yellow/mod.rs index 710320f47..ab9bca0f0 100644 --- a/crates/ra_syntax/src/yellow/mod.rs +++ b/crates/ra_syntax/src/yellow/mod.rs @@ -6,7 +6,7 @@ use std::{ hash::{Hash, Hasher}, }; use rowan::Types; -use {SyntaxKind, TextUnit, TextRange, SmolStr}; +use crate::{SyntaxKind, TextUnit, TextRange, SmolStr}; use self::syntax_text::SyntaxText; pub use rowan::{TreeRoot}; @@ -70,16 +70,16 @@ impl<'a> SyntaxNodeRef<'a> { self.0.leaf_text() } pub fn ancestors(self) -> impl Iterator> { - ::algo::generate(Some(self), |&node| node.parent()) + crate::algo::generate(Some(self), |&node| node.parent()) } pub fn descendants(self) -> impl Iterator> { - ::algo::walk::walk(self).filter_map(|event| match event { - ::algo::walk::WalkEvent::Enter(node) => Some(node), - ::algo::walk::WalkEvent::Exit(_) => None, + crate::algo::walk::walk(self).filter_map(|event| match event { + crate::algo::walk::WalkEvent::Enter(node) => Some(node), + crate::algo::walk::WalkEvent::Exit(_) => None, }) } pub fn siblings(self, direction: Direction) -> impl Iterator> { - ::algo::generate(Some(self), move |&node| match direction { + crate::algo::generate(Some(self), move |&node| match direction { Direction::Next => node.next_sibling(), Direction::Prev => node.prev_sibling(), }) @@ -156,7 +156,7 @@ impl> Iterator for SyntaxNodeChildren { fn has_short_text(kind: SyntaxKind) -> bool { - use SyntaxKind::*; + use crate::SyntaxKind::*; match kind { IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true, _ => false, diff --git a/crates/ra_syntax/src/yellow/syntax_text.rs b/crates/ra_syntax/src/yellow/syntax_text.rs index 0db1049de..ae33b993d 100644 --- a/crates/ra_syntax/src/yellow/syntax_text.rs +++ b/crates/ra_syntax/src/yellow/syntax_text.rs @@ -2,7 +2,7 @@ use std::{ fmt, ops, }; -use { +use crate::{ SyntaxNodeRef, TextRange, TextUnit, text_utils::{intersect, contains_offset_nonstrict}, }; -- cgit v1.2.3 From 94349206483ad78de71e1546d74a355bbdf764c4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:00:54 +0300 Subject: switch base crates to 2018 --- crates/ra_syntax/Cargo.toml | 1 + crates/test_utils/Cargo.toml | 1 + crates/tools/Cargo.toml | 1 + 3 files changed, 3 insertions(+) (limited to 'crates') diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 6345e4725..34bb1c591 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "ra_syntax" version = "0.1.0" authors = ["Aleksey Kladov "] diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index 41316581e..fe0998ab8 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "test_utils" version = "0.1.0" authors = ["Aleksey Kladov "] diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml index d03910986..e2fecc60d 100644 --- a/crates/tools/Cargo.toml +++ b/crates/tools/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "tools" version = "0.1.0" authors = ["Aleksey Kladov "] -- cgit v1.2.3 From 1624bf2d7f8c60620830149ac2f88e94dfdb036e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:05:26 +0300 Subject: switch editor to 2018 --- crates/ra_editor/Cargo.toml | 1 + crates/ra_editor/src/code_actions.rs | 4 ++-- crates/ra_editor/src/completion.rs | 2 +- crates/ra_editor/src/edit.rs | 2 +- crates/ra_editor/src/lib.rs | 2 +- crates/ra_editor/src/line_index.rs | 2 +- crates/ra_editor/src/scope/fn_scope.rs | 4 ++-- crates/ra_editor/src/symbols.rs | 2 +- crates/ra_editor/src/test_utils.rs | 4 ++-- crates/ra_editor/src/typing.rs | 4 ++-- 10 files changed, 14 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/ra_editor/Cargo.toml b/crates/ra_editor/Cargo.toml index 91cefc8d7..7791da156 100644 --- a/crates/ra_editor/Cargo.toml +++ b/crates/ra_editor/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "ra_editor" version = "0.1.0" authors = ["Aleksey Kladov "] diff --git a/crates/ra_editor/src/code_actions.rs b/crates/ra_editor/src/code_actions.rs index 216d592ff..7b0a48c81 100644 --- a/crates/ra_editor/src/code_actions.rs +++ b/crates/ra_editor/src/code_actions.rs @@ -11,7 +11,7 @@ use ra_syntax::{ }, }; -use {EditBuilder, Edit, find_node_at_offset}; +use crate::{EditBuilder, Edit, find_node_at_offset}; #[derive(Debug)] pub struct LocalEdit { @@ -136,7 +136,7 @@ fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option { - let mut scope = scopes.new_scope(scope); + let scope = scopes.new_scope(scope); scopes.add_params_bindings(scope, e.param_list()); if let Some(body) = e.body() { scopes.set_scope(body.syntax(), scope); @@ -256,7 +256,7 @@ pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> O mod tests { use super::*; use ra_syntax::File; - use {find_node_at_offset, test_utils::extract_offset}; + use crate::{find_node_at_offset, test_utils::extract_offset}; fn do_check(code: &str, expected: &[&str]) { let (off, code) = extract_offset(code); diff --git a/crates/ra_editor/src/symbols.rs b/crates/ra_editor/src/symbols.rs index e5cc5ca28..6211ed547 100644 --- a/crates/ra_editor/src/symbols.rs +++ b/crates/ra_editor/src/symbols.rs @@ -6,7 +6,7 @@ use ra_syntax::{ walk::{walk, WalkEvent}, }, }; -use TextRange; +use crate::TextRange; #[derive(Debug, Clone)] pub struct StructureNode { diff --git a/crates/ra_editor/src/test_utils.rs b/crates/ra_editor/src/test_utils.rs index c4ea4db6c..49eb530d5 100644 --- a/crates/ra_editor/src/test_utils.rs +++ b/crates/ra_editor/src/test_utils.rs @@ -1,6 +1,6 @@ use ra_syntax::{File, TextUnit, TextRange}; -pub use _test_utils::*; -use LocalEdit; +pub use crate::_test_utils::*; +use crate::LocalEdit; pub fn check_action Option> ( before: &str, diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 1dc658f9b..542b9e10b 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -10,7 +10,7 @@ use ra_syntax::{ SyntaxKind::*, }; -use {LocalEdit, EditBuilder, find_node_at_offset}; +use crate::{LocalEdit, EditBuilder, find_node_at_offset}; pub fn join_lines(file: &File, range: TextRange) -> LocalEdit { let range = if range.is_empty() { @@ -244,7 +244,7 @@ fn compute_ws(left: SyntaxNodeRef, right: SyntaxNodeRef) -> &'static str { #[cfg(test)] mod tests { use super::*; - use test_utils::{check_action, extract_range, extract_offset, add_cursor}; + use crate::test_utils::{check_action, extract_range, extract_offset, add_cursor}; fn check_join_lines(before: &str, after: &str) { check_action(before, after, |file, offset| { -- cgit v1.2.3 From 2dd6858d03dd9c3f6dced3cc5c33ef3ab9d09157 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:06:02 +0300 Subject: switch ra_cli to 2018 --- crates/ra_cli/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'crates') diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 5e7bf3ed4..0b8d6f3dd 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "ra_cli" version = "0.1.0" authors = ["Aleksey Kladov "] -- cgit v1.2.3 From bb298158ebc7fc62cad1654c76dc582e6dc28f05 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:15:53 +0300 Subject: migrate analysis and server to 2018 --- crates/ra_analysis/Cargo.toml | 1 + crates/ra_analysis/src/db/imp.rs | 4 ++-- crates/ra_analysis/src/db/mod.rs | 6 +++--- crates/ra_analysis/src/descriptors.rs | 4 ++-- crates/ra_analysis/src/imp.rs | 4 ++-- crates/ra_analysis/src/lib.rs | 8 +++++--- crates/ra_analysis/src/module_map.rs | 4 ++-- crates/ra_analysis/src/queries.rs | 4 ++-- crates/ra_analysis/src/roots.rs | 12 ++++++------ crates/ra_analysis/src/symbol_index.rs | 2 +- crates/ra_lsp_server/Cargo.toml | 1 + crates/ra_lsp_server/src/conv.rs | 6 +++--- crates/ra_lsp_server/src/lib.rs | 6 ++++-- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- crates/ra_lsp_server/src/main_loop/mod.rs | 2 +- crates/ra_lsp_server/src/project_model.rs | 2 +- crates/ra_lsp_server/src/server_world.rs | 2 +- crates/ra_lsp_server/src/thread_watcher.rs | 2 +- crates/ra_lsp_server/src/vfs.rs | 2 +- crates/ra_lsp_server/tests/heavy_tests/main.rs | 2 +- crates/ra_lsp_server/tests/heavy_tests/support.rs | 2 +- 21 files changed, 42 insertions(+), 36 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml index a82e1761c..28d95c581 100644 --- a/crates/ra_analysis/Cargo.toml +++ b/crates/ra_analysis/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "ra_analysis" version = "0.1.0" authors = ["Aleksey Kladov "] diff --git a/crates/ra_analysis/src/db/imp.rs b/crates/ra_analysis/src/db/imp.rs index 36f6cf290..7669b6184 100644 --- a/crates/ra_analysis/src/db/imp.rs +++ b/crates/ra_analysis/src/db/imp.rs @@ -7,7 +7,7 @@ use std::{ }; use rustc_hash::FxHashMap; use salsa; -use {FileId, imp::FileResolverImp}; +use crate::{FileId, imp::FileResolverImp}; use super::{State, Query, QueryCtx}; pub(super) type Data = Arc; @@ -51,7 +51,7 @@ pub(crate) trait EvalQuery { type Output; fn query_type(&self) -> salsa::QueryTypeId; fn f(&self) -> salsa::QueryFn; - fn get(&self, &QueryCtx, Self::Params) -> Arc; + fn get(&self, ctx: &QueryCtx, params: Self::Params) -> Arc; } impl EvalQuery for Query diff --git a/crates/ra_analysis/src/db/mod.rs b/crates/ra_analysis/src/db/mod.rs index 22769d112..4eb7d922d 100644 --- a/crates/ra_analysis/src/db/mod.rs +++ b/crates/ra_analysis/src/db/mod.rs @@ -5,7 +5,7 @@ use std::{ }; use im; use salsa; -use {FileId, imp::FileResolverImp}; +use crate::{FileId, imp::FileResolverImp}; #[derive(Debug, Default, Clone)] pub(crate) struct State { @@ -75,8 +75,8 @@ pub(crate) fn file_set(ctx: QueryCtx) -> Arc<(Vec, FileResolverImp)> { impl QueryRegistry { fn new() -> QueryRegistry { let mut reg = QueryRegistry { imp: imp::QueryRegistry::new() }; - ::queries::register_queries(&mut reg); - ::module_map::register_queries(&mut reg); + crate::queries::register_queries(&mut reg); + crate::module_map::register_queries(&mut reg); reg } pub(crate) fn add(&mut self, q: Q, name: &'static str) { diff --git a/crates/ra_analysis/src/descriptors.rs b/crates/ra_analysis/src/descriptors.rs index faf945a41..f26dac875 100644 --- a/crates/ra_analysis/src/descriptors.rs +++ b/crates/ra_analysis/src/descriptors.rs @@ -7,7 +7,7 @@ use ra_syntax::{ ast::{self, NameOwner, AstNode}, text_utils::is_subrange }; -use { +use crate::{ FileId, imp::FileResolverImp, }; @@ -271,4 +271,4 @@ impl FnDescriptor { } res } -} \ No newline at end of file +} diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index aad54b977..26f5e175b 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -17,7 +17,7 @@ use ra_syntax::{ ast::{self, NameOwner, ArgListOwner, Expr}, }; -use { +use crate::{ FileId, FileResolver, Query, Diagnostic, SourceChange, SourceFileEdit, Position, FileSystemEdit, JobToken, CrateGraph, CrateId, roots::{SourceRoot, ReadonlySourceRoot, WritableSourceRoot}, @@ -458,4 +458,4 @@ impl<'a> FnCallNode<'a> { FnCallNode::MethodCallExpr(expr) => expr.arg_list() } } -} \ No newline at end of file +} diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 1aca72ae0..86c66236c 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -29,16 +29,18 @@ use std::{ use relative_path::{RelativePath, RelativePathBuf}; use ra_syntax::{File, TextRange, TextUnit, AtomEdit}; -use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp}; use rustc_hash::FxHashMap; +use crate::imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp}; pub use ra_editor::{ StructureNode, LineIndex, FileSymbol, Runnable, RunnableKind, HighlightedRange, CompletionItem, Fold, FoldKind }; -pub use job::{JobToken, JobHandle}; -pub use descriptors::FnDescriptor; +pub use crate::{ + job::{JobToken, JobHandle}, + descriptors::FnDescriptor, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FileId(pub u32); diff --git a/crates/ra_analysis/src/module_map.rs b/crates/ra_analysis/src/module_map.rs index a21f55fff..c77c5cec6 100644 --- a/crates/ra_analysis/src/module_map.rs +++ b/crates/ra_analysis/src/module_map.rs @@ -1,5 +1,5 @@ use std::sync::Arc; -use { +use crate::{ FileId, db::{ Query, QueryRegistry, QueryCtx, @@ -38,7 +38,7 @@ mod tests { use std::collections::HashMap; use im; use relative_path::{RelativePath, RelativePathBuf}; - use { + use crate::{ db::{Db}, imp::FileResolverImp, FileId, FileResolver, diff --git a/crates/ra_analysis/src/queries.rs b/crates/ra_analysis/src/queries.rs index 062a2f420..613bf1e61 100644 --- a/crates/ra_analysis/src/queries.rs +++ b/crates/ra_analysis/src/queries.rs @@ -1,13 +1,13 @@ use std::sync::Arc; use ra_syntax::File; use ra_editor::LineIndex; -use { +use crate::{ FileId, db::{Query, QueryCtx, QueryRegistry}, symbol_index::SymbolIndex, }; -pub(crate) use db::{file_text, file_set}; +pub(crate) use crate::db::{file_text, file_set}; pub(crate) fn file_syntax(ctx: QueryCtx, file_id: FileId) -> File { (&*ctx.get(FILE_SYNTAX, file_id)).clone() diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 32a8c5bd0..208acc4c2 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs @@ -9,7 +9,7 @@ use rustc_hash::FxHashMap; use ra_editor::LineIndex; use ra_syntax::File; -use { +use crate::{ FileId, imp::FileResolverImp, symbol_index::SymbolIndex, @@ -62,23 +62,23 @@ impl WritableSourceRoot { impl SourceRoot for WritableSourceRoot { fn module_tree(&self) -> Arc { - self.db.make_query(::module_map::module_tree) + self.db.make_query(crate::module_map::module_tree) } fn contains(&self, file_id: FileId) -> bool { self.db.state().file_map.contains_key(&file_id) } fn lines(&self, file_id: FileId) -> Arc { - self.db.make_query(|ctx| ::queries::file_lines(ctx, file_id)) + self.db.make_query(|ctx| crate::queries::file_lines(ctx, file_id)) } fn syntax(&self, file_id: FileId) -> File { - self.db.make_query(|ctx| ::queries::file_syntax(ctx, file_id)) + self.db.make_query(|ctx| crate::queries::file_syntax(ctx, file_id)) } fn symbols<'a>(&'a self, acc: &mut Vec>) { self.db.make_query(|ctx| { - let file_set = ::queries::file_set(ctx); + let file_set = crate::queries::file_set(ctx); let syms = file_set.0.iter() - .map(|file_id| ::queries::file_symbols(ctx, *file_id)); + .map(|file_id| crate::queries::file_symbols(ctx, *file_id)); acc.extend(syms); }); } diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs index ffbb6a29f..e5d83d365 100644 --- a/crates/ra_analysis/src/symbol_index.rs +++ b/crates/ra_analysis/src/symbol_index.rs @@ -9,7 +9,7 @@ use ra_syntax::{ }; use fst::{self, Streamer}; use rayon::prelude::*; -use {Query, FileId, JobToken}; +use crate::{Query, FileId, JobToken}; #[derive(Debug)] pub(crate) struct SymbolIndex { diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 1fe6b2ebe..2b3257117 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "ra_lsp_server" version = "0.1.0" authors = ["Aleksey Kladov "] diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 08a656569..a75b160c5 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -7,7 +7,7 @@ use ra_editor::{LineIndex, LineCol, Edit, AtomEdit}; use ra_syntax::{SyntaxKind, TextUnit, TextRange}; use ra_analysis::{FileId, SourceChange, SourceFileEdit, FileSystemEdit}; -use { +use crate::{ Result, server_world::ServerWorld, req, @@ -299,7 +299,7 @@ pub fn to_location( Ok(loc) } -pub trait MapConvWith<'a>: Sized { +pub trait MapConvWith<'a>: Sized + 'a { type Ctx; type Output; @@ -309,7 +309,7 @@ pub trait MapConvWith<'a>: Sized { } impl<'a, I> MapConvWith<'a> for I - where I: Iterator, + where I: Iterator + 'a, I::Item: ConvWith { type Ctx = ::Ctx; diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index 60652d55e..7224b1476 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs @@ -34,5 +34,7 @@ mod project_model; pub mod thread_watcher; pub type Result = ::std::result::Result; -pub use caps::server_capabilities; -pub use main_loop::main_loop; +pub use crate::{ + main_loop::main_loop, + caps::server_capabilities, +}; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index f65e2a889..1fe78f3d0 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -13,7 +13,7 @@ use ra_syntax::{ text_utils::contains_offset_nonstrict }; -use ::{ +use crate::{ req::{self, Decoration}, Result, conv::{Conv, ConvWith, TryConvWith, MapConvWith, to_location}, server_world::ServerWorld, diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index f4e7cfc33..773501efe 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -16,7 +16,7 @@ use gen_lsp_server::{ }; use rustc_hash::FxHashMap; -use { +use crate::{ req, Result, vfs::{self, FileEvent}, diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index 43e4fd654..c144d9596 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -5,7 +5,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use cargo_metadata::{metadata_run, CargoOpt}; use ra_syntax::SmolStr; -use { +use crate::{ Result, thread_watcher::{Worker, ThreadWatcher}, }; diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index c4cdf83d4..c931afa02 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs @@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; use languageserver_types::Url; use ra_analysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId, LibraryData, FileResolver}; -use { +use crate::{ Result, path_map::{PathMap, Root}, vfs::{FileEvent, FileEventKind}, diff --git a/crates/ra_lsp_server/src/thread_watcher.rs b/crates/ra_lsp_server/src/thread_watcher.rs index 86a3a91e0..3257effcb 100644 --- a/crates/ra_lsp_server/src/thread_watcher.rs +++ b/crates/ra_lsp_server/src/thread_watcher.rs @@ -1,7 +1,7 @@ use std::thread; use crossbeam_channel::{bounded, unbounded, Sender, Receiver}; use drop_bomb::DropBomb; -use Result; +use crate::Result; pub struct Worker { pub inp: Sender, diff --git a/crates/ra_lsp_server/src/vfs.rs b/crates/ra_lsp_server/src/vfs.rs index a1c1783f2..d8f9b1aac 100644 --- a/crates/ra_lsp_server/src/vfs.rs +++ b/crates/ra_lsp_server/src/vfs.rs @@ -5,7 +5,7 @@ use std::{ use walkdir::WalkDir; -use { +use crate::{ thread_watcher::{Worker, ThreadWatcher}, }; diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index dced45f55..7265b5999 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -12,7 +12,7 @@ mod support; use ra_lsp_server::req::{Runnables, RunnablesParams}; -use support::project; +use crate::support::project; const LOG: &'static str = ""; diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 8fe2aa816..d1339f62f 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -25,7 +25,7 @@ use ra_lsp_server::{main_loop, req, thread_watcher::{ThreadWatcher, Worker}}; pub fn project(fixture: &str) -> Server { static INIT: Once = Once::new(); - INIT.call_once(|| Logger::with_env_or_str(::LOG).start().unwrap()); + INIT.call_once(|| Logger::with_env_or_str(crate::LOG).start().unwrap()); let tmp_dir = TempDir::new("test-project") .unwrap(); -- cgit v1.2.3 From 376639c70f94f1f26c7fbd86a9b5adebfa400f44 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:52:56 +0300 Subject: Parse crate paths in expressions --- crates/ra_syntax/src/grammar/expressions/atom.rs | 2 +- .../data/parser/ok/0035_crate_path_in_call.rs | 3 ++ .../data/parser/ok/0035_crate_path_in_call.txt | 41 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs create mode 100644 crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt (limited to 'crates') diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index a720d255f..e21de68c5 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs @@ -30,7 +30,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![ LITERAL_FIRST, token_set![L_CURLY, L_PAREN, L_BRACK, PIPE, MOVE_KW, IF_KW, WHILE_KW, MATCH_KW, UNSAFE_KW, - RETURN_KW, IDENT, SELF_KW, SUPER_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], + RETURN_KW, IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], ]; const EXPR_RECOVERY_SET: TokenSet = diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs new file mode 100644 index 000000000..f1ed30220 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs @@ -0,0 +1,3 @@ +fn main() { + make_query(crate::module_map::module_tree); +} diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt new file mode 100644 index 000000000..364315180 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt @@ -0,0 +1,41 @@ +ROOT@[0; 62) + FN_DEF@[0; 61) + FN_KW@[0; 2) + WHITESPACE@[2; 3) + NAME@[3; 7) + IDENT@[3; 7) "main" + PARAM_LIST@[7; 9) + L_PAREN@[7; 8) + R_PAREN@[8; 9) + WHITESPACE@[9; 10) + BLOCK@[10; 61) + L_CURLY@[10; 11) + WHITESPACE@[11; 16) + EXPR_STMT@[16; 59) + CALL_EXPR@[16; 58) + PATH_EXPR@[16; 26) + PATH@[16; 26) + PATH_SEGMENT@[16; 26) + NAME_REF@[16; 26) + IDENT@[16; 26) "make_query" + ARG_LIST@[26; 58) + L_PAREN@[26; 27) + PATH_EXPR@[27; 57) + PATH@[27; 57) + PATH@[27; 44) + PATH@[27; 32) + PATH_SEGMENT@[27; 32) + CRATE_KW@[27; 32) + COLONCOLON@[32; 34) + PATH_SEGMENT@[34; 44) + NAME_REF@[34; 44) + IDENT@[34; 44) "module_map" + COLONCOLON@[44; 46) + PATH_SEGMENT@[46; 57) + NAME_REF@[46; 57) + IDENT@[46; 57) "module_tree" + R_PAREN@[57; 58) + SEMI@[58; 59) + WHITESPACE@[59; 60) + R_CURLY@[60; 61) + WHITESPACE@[61; 62) -- cgit v1.2.3 From 9a98d8e99acf8acd40b2153847a37551d2a8d0f4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:53:15 +0300 Subject: regenerate --- crates/ra_syntax/src/ast/generated.rs.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index ffa9c4134..5cb7a35ed 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera @@ -3,7 +3,7 @@ the below applies to the result of this template #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run // Do not edit manually -use { +use crate::{ ast, SyntaxNodeRef, AstNode, SyntaxKind::*, -- cgit v1.2.3