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