From d9a36a736bfb91578a36505e7237212959bb55fe Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 27 Nov 2019 21:31:51 +0300 Subject: [PATCH 1/3] Rename module_id -> local_id --- crates/ra_hir/src/code_model.rs | 20 +++++++++---------- crates/ra_hir/src/code_model/src.rs | 4 ++-- crates/ra_hir/src/from_source.rs | 8 ++++---- crates/ra_hir_def/src/attr.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/docs.rs | 2 +- crates/ra_hir_def/src/lang_item.rs | 4 ++-- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 14 ++++++------- .../ra_hir_def/src/nameres/path_resolution.rs | 16 +++++++-------- crates/ra_hir_def/src/resolver.rs | 6 +++--- crates/ra_hir_ty/src/test_db.rs | 4 ++-- crates/ra_hir_ty/src/tests.rs | 10 +++++----- 13 files changed, 47 insertions(+), 47 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 87c78d98e14..5a3e24e9e46 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -174,15 +174,15 @@ pub use hir_def::attr::Attrs; impl Module { pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module { - Module { id: ModuleId { krate: krate.crate_id, module_id: crate_module_id } } + Module { id: ModuleId { krate: krate.crate_id, local_id: crate_module_id } } } /// Name of this module. pub fn name(self, db: &impl DefDatabase) -> Option { let def_map = db.crate_def_map(self.id.krate); - let parent = def_map[self.id.module_id].parent?; + let parent = def_map[self.id.local_id].parent?; def_map[parent].children.iter().find_map(|(name, module_id)| { - if *module_id == self.id.module_id { + if *module_id == self.id.local_id { Some(name.clone()) } else { None @@ -206,14 +206,14 @@ impl Module { /// Finds a child module with the specified name. pub fn child(self, db: &impl DefDatabase, name: &Name) -> Option { let def_map = db.crate_def_map(self.id.krate); - let child_id = def_map[self.id.module_id].children.get(name)?; + let child_id = def_map[self.id.local_id].children.get(name)?; Some(self.with_module_id(*child_id)) } /// Iterates over all child modules. pub fn children(self, db: &impl DefDatabase) -> impl Iterator { let def_map = db.crate_def_map(self.id.krate); - let children = def_map[self.id.module_id] + let children = def_map[self.id.local_id] .children .iter() .map(|(_, module_id)| self.with_module_id(*module_id)) @@ -224,7 +224,7 @@ impl Module { /// Finds a parent module. pub fn parent(self, db: &impl DefDatabase) -> Option { let def_map = db.crate_def_map(self.id.krate); - let parent_id = def_map[self.id.module_id].parent?; + let parent_id = def_map[self.id.local_id].parent?; Some(self.with_module_id(parent_id)) } @@ -240,7 +240,7 @@ impl Module { /// Returns a `ModuleScope`: a set of items, visible in this module. pub fn scope(self, db: &impl HirDatabase) -> Vec<(Name, ScopeDef, Option)> { - db.crate_def_map(self.id.krate)[self.id.module_id] + db.crate_def_map(self.id.krate)[self.id.local_id] .scope .entries() .map(|(name, res)| { @@ -250,7 +250,7 @@ impl Module { } pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) { - db.crate_def_map(self.id.krate).add_diagnostics(db, self.id.module_id, sink); + db.crate_def_map(self.id.krate).add_diagnostics(db, self.id.local_id, sink); for decl in self.declarations(db) { match decl { crate::ModuleDef::Function(f) => f.diagnostics(db, sink), @@ -275,12 +275,12 @@ impl Module { pub fn declarations(self, db: &impl DefDatabase) -> Vec { let def_map = db.crate_def_map(self.id.krate); - def_map[self.id.module_id].scope.declarations().map(ModuleDef::from).collect() + def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() } pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec { let def_map = db.crate_def_map(self.id.krate); - def_map[self.id.module_id].impls.iter().copied().map(ImplBlock::from).collect() + def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect() } fn with_module_id(self, module_id: LocalModuleId) -> Module { diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 076d86f2b9c..bf3ee08341e 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs @@ -22,7 +22,7 @@ impl Module { /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. pub fn definition_source(self, db: &impl DefDatabase) -> Source { let def_map = db.crate_def_map(self.id.krate); - let src = def_map[self.id.module_id].definition_source(db); + let src = def_map[self.id.local_id].definition_source(db); src.map(|it| match it { Either::A(it) => ModuleSource::SourceFile(it), Either::B(it) => ModuleSource::Module(it), @@ -33,7 +33,7 @@ impl Module { /// `None` for the crate root. pub fn declaration_source(self, db: &impl DefDatabase) -> Option> { let def_map = db.crate_def_map(self.id.krate); - def_map[self.id.module_id].declaration_source(db) + def_map[self.id.local_id].declaration_source(db) } } diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 95db7161bf8..7756ca80e7e 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -262,13 +262,13 @@ impl Module { let original_file = src.file_id.original_file(db); - let (krate, module_id) = + let (krate, local_id) = db.relevant_crates(original_file).iter().find_map(|&crate_id| { let crate_def_map = db.crate_def_map(crate_id); - let local_module_id = crate_def_map.modules_for_file(original_file).next()?; - Some((crate_id, local_module_id)) + let local_id = crate_def_map.modules_for_file(original_file).next()?; + Some((crate_id, local_id)) })?; - Some(Module { id: ModuleId { krate, module_id } }) + Some(Module { id: ModuleId { krate, local_id } }) } } diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 298608e27cd..fffb22201d6 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -35,7 +35,7 @@ impl Attrs { match def { AttrDefId::ModuleId(module) => { let def_map = db.crate_def_map(module.krate); - let src = match def_map[module.module_id].declaration_source(db) { + let src = match def_map[module.local_id].declaration_source(db) { Some(it) => it, None => return Attrs::default(), }; diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 78a532bdd6c..a57a0176d47 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -82,7 +82,7 @@ impl Expander { } fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option { - self.crate_def_map.resolve_path(db, self.module.module_id, path).0.take_macros() + self.crate_def_map.resolve_path(db, self.module.local_id, path).0.take_macros() } } diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 4749b642f0d..34ed9b7a5ee 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -36,7 +36,7 @@ impl Documentation { match def { AttrDefId::ModuleId(module) => { let def_map = db.crate_def_map(module.krate); - let src = def_map[module.module_id].declaration_source(db)?; + let src = def_map[module.local_id].declaration_source(db)?; docs_from_ast(&src.value) } AttrDefId::StructFieldId(it) => { diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index f15c23db9df..f4fdbdcfc74 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs @@ -41,7 +41,7 @@ impl LangItems { crate_def_map .modules .iter() - .filter_map(|(module_id, _)| db.module_lang_items(ModuleId { krate, module_id })) + .filter_map(|(local_id, _)| db.module_lang_items(ModuleId { krate, local_id })) .for_each(|it| lang_items.items.extend(it.items.iter().map(|(k, v)| (k.clone(), *v)))); Arc::new(lang_items) @@ -80,7 +80,7 @@ impl LangItems { fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) { // Look for impl targets let def_map = db.crate_def_map(module.krate); - let module_data = &def_map[module.module_id]; + let module_data = &def_map[module.local_id]; for &impl_block in module_data.impls.iter() { self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) } diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index ddf464c6051..bc553089694 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -50,7 +50,7 @@ impl_arena_id!(LocalImportId); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ModuleId { pub krate: CrateId, - pub module_id: LocalModuleId, + pub local_id: LocalModuleId, } /// An ID of a module, **local** to a specific crate diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index ea3abfdae27..6cd14026bc8 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -37,7 +37,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); def_map.extern_prelude.insert( dep.as_name(), - ModuleId { krate: dep.crate_id, module_id: dep_def_map.root }.into(), + ModuleId { krate: dep.crate_id, local_id: dep_def_map.root }.into(), ); // look for the prelude @@ -323,7 +323,7 @@ where tested_by!(glob_across_crates); // glob import from other crate => we can just import everything once let item_map = self.db.crate_def_map(m.krate); - let scope = &item_map[m.module_id].scope; + let scope = &item_map[m.local_id].scope; // Module scoped macros is included let items = scope @@ -337,7 +337,7 @@ where // glob import from same crate => we do an initial // import, and then need to propagate any further // additions - let scope = &self.def_map[m.module_id].scope; + let scope = &self.def_map[m.local_id].scope; // Module scoped macros is included let items = scope @@ -349,7 +349,7 @@ where self.update(module_id, Some(import_id), &items); // record the glob import in case we add further items self.glob_imports - .entry(m.module_id) + .entry(m.local_id) .or_default() .push((module_id, import_id)); } @@ -590,7 +590,7 @@ where raw::RawItemKind::Impl(imp) => { let module = ModuleId { krate: self.def_collector.def_map.krate, - module_id: self.module_id, + local_id: self.module_id, }; let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); @@ -673,7 +673,7 @@ where modules[self.module_id].children.insert(name.clone(), res); let resolution = Resolution { def: PerNs::types( - ModuleId { krate: self.def_collector.def_map.krate, module_id: res }.into(), + ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), ), import: None, }; @@ -683,7 +683,7 @@ where fn define_def(&mut self, def: &raw::DefData) { let module = - ModuleId { krate: self.def_collector.def_map.krate, module_id: self.module_id }; + ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); let name = def.name.clone(); diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 9455f22bbd6..b72c55bd10e 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs @@ -74,19 +74,19 @@ impl CrateDefMap { PathKind::DollarCrate(krate) => { if krate == self.krate { tested_by!(macro_dollar_crate_self); - PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) + PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) } else { let def_map = db.crate_def_map(krate); - let module = ModuleId { krate, module_id: def_map.root }; + let module = ModuleId { krate, local_id: def_map.root }; tested_by!(macro_dollar_crate_other); PerNs::types(module.into()) } } PathKind::Crate => { - PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) + PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) } PathKind::Self_ => { - PerNs::types(ModuleId { krate: self.krate, module_id: original_module }.into()) + PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into()) } // plain import or absolute path in 2015: crate-relative with // fallback to extern prelude (with the simplification in @@ -113,7 +113,7 @@ impl CrateDefMap { } PathKind::Super => { if let Some(p) = self.modules[original_module].parent { - PerNs::types(ModuleId { krate: self.krate, module_id: p }.into()) + PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) } else { log::debug!("super path in root module"); return ResolvePathResult::empty(ReachedFixedPoint::Yes); @@ -160,7 +160,7 @@ impl CrateDefMap { Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; log::debug!("resolving {:?} in other crate", path); let defp_map = db.crate_def_map(module.krate); - let (def, s) = defp_map.resolve_path(db, module.module_id, &path); + let (def, s) = defp_map.resolve_path(db, module.local_id, &path); return ResolvePathResult::with( def, ReachedFixedPoint::Yes, @@ -169,7 +169,7 @@ impl CrateDefMap { } // Since it is a qualified path here, it should not contains legacy macros - match self[module.module_id].scope.get(&segment.name) { + match self[module.local_id].scope.get(&segment.name) { Some(res) => res.def, _ => { log::debug!("path segment {:?} not found", segment.name); @@ -254,7 +254,7 @@ impl CrateDefMap { keep = db.crate_def_map(prelude.krate); &keep }; - def_map[prelude.module_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) + def_map[prelude.local_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) } else { PerNs::none() } diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 5155365ccbb..0847f6dcf45 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -325,7 +325,7 @@ impl Resolver { if let Scope::ModuleScope(m) = scope { if let Some(prelude) = m.crate_def_map.prelude { let prelude_def_map = db.crate_def_map(prelude.krate); - traits.extend(prelude_def_map[prelude.module_id].scope.traits()); + traits.extend(prelude_def_map[prelude.local_id].scope.traits()); } traits.extend(m.crate_def_map[m.module_id].scope.traits()); } @@ -402,7 +402,7 @@ impl Scope { }); if let Some(prelude) = m.crate_def_map.prelude { let prelude_def_map = db.crate_def_map(prelude.krate); - prelude_def_map[prelude.module_id].scope.entries().for_each(|(name, res)| { + prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, res)| { f(name.clone(), ScopeDef::PerNs(res.def)); }); } @@ -492,7 +492,7 @@ pub trait HasResolver: Copy { impl HasResolver for ModuleId { fn resolver(self, db: &impl DefDatabase) -> Resolver { let def_map = db.crate_def_map(self.krate); - Resolver::default().push_module_scope(def_map, self.module_id) + Resolver::default().push_module_scope(def_map, self.local_id) } } diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 8743570085c..1dc9793f950 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -73,9 +73,9 @@ impl TestDB { pub fn module_for_file(&self, file_id: FileId) -> ModuleId { for &krate in self.relevant_crates(file_id).iter() { let crate_def_map = self.crate_def_map(krate); - for (module_id, data) in crate_def_map.modules.iter() { + for (local_id, data) in crate_def_map.modules.iter() { if data.definition == Some(file_id) { - return ModuleId { krate, module_id }; + return ModuleId { krate, local_id }; } } } diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index c1744663a6a..c8461b447ad 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -4677,7 +4677,7 @@ fn type_at_pos(db: &TestDB, pos: FilePosition) -> String { let module = db.module_for_file(pos.file_id); let crate_def_map = db.crate_def_map(module.krate); - for decl in crate_def_map[module.module_id].scope.declarations() { + for decl in crate_def_map[module.local_id].scope.declarations() { if let ModuleDefId::FunctionId(func) = decl { let (_body, source_map) = db.body_with_source_map(func.into()); if let Some(expr_id) = source_map.node_expr(Source::new(pos.file_id.into(), &expr)) { @@ -4753,7 +4753,7 @@ fn infer(content: &str) -> String { let crate_def_map = db.crate_def_map(module.krate); let mut defs: Vec = Vec::new(); - visit_module(&db, &crate_def_map, module.module_id, &mut |it| defs.push(it)); + visit_module(&db, &crate_def_map, module.local_id, &mut |it| defs.push(it)); defs.sort_by_key(|def| match def { DefWithBodyId::FunctionId(it) => { it.lookup(&db).ast_id.to_node(&db).syntax().text_range().start() @@ -4796,7 +4796,7 @@ fn visit_module( } } } - ModuleDefId::ModuleId(it) => visit_module(db, crate_def_map, it.module_id, cb), + ModuleDefId::ModuleId(it) => visit_module(db, crate_def_map, it.local_id, cb), _ => (), } } @@ -4844,7 +4844,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() { let events = db.log_executed(|| { let module = db.module_for_file(pos.file_id); let crate_def_map = db.crate_def_map(module.krate); - visit_module(&db, &crate_def_map, module.module_id, &mut |def| { + visit_module(&db, &crate_def_map, module.local_id, &mut |def| { db.infer(def); }); }); @@ -4866,7 +4866,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() { let events = db.log_executed(|| { let module = db.module_for_file(pos.file_id); let crate_def_map = db.crate_def_map(module.krate); - visit_module(&db, &crate_def_map, module.module_id, &mut |def| { + visit_module(&db, &crate_def_map, module.local_id, &mut |def| { db.infer(def); }); }); From 757e593b253b4df7e6fc8bf15a4d4f34c9d484c5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 27 Nov 2019 21:32:33 +0300 Subject: [PATCH 2/3] rename ra_ide_api -> ra_ide --- Cargo.lock | 8 +++---- README.md | 2 +- crates/ra_batch/Cargo.toml | 2 +- crates/ra_batch/src/lib.rs | 2 +- crates/ra_cli/Cargo.toml | 2 +- crates/ra_cli/src/analysis_bench.rs | 2 +- crates/ra_cli/src/main.rs | 2 +- crates/ra_db/src/lib.rs | 2 +- crates/{ra_ide_api => ra_ide}/Cargo.toml | 4 ++-- crates/{ra_ide_api => ra_ide}/src/assists.rs | 0 .../{ra_ide_api => ra_ide}/src/call_info.rs | 0 crates/{ra_ide_api => ra_ide}/src/change.rs | 0 .../{ra_ide_api => ra_ide}/src/completion.rs | 0 .../src/completion/complete_dot.rs | 0 .../src/completion/complete_fn_param.rs | 0 .../src/completion/complete_keyword.rs | 0 .../complete_macro_in_item_position.rs | 0 .../src/completion/complete_path.rs | 0 .../src/completion/complete_pattern.rs | 0 .../src/completion/complete_postfix.rs | 0 .../src/completion/complete_record_literal.rs | 0 .../src/completion/complete_record_pattern.rs | 0 .../src/completion/complete_scope.rs | 0 .../src/completion/complete_snippet.rs | 0 .../src/completion/completion_context.rs | 0 .../src/completion/completion_item.rs | 0 .../src/completion/presentation.rs | 0 crates/{ra_ide_api => ra_ide}/src/db.rs | 0 .../{ra_ide_api => ra_ide}/src/diagnostics.rs | 0 crates/{ra_ide_api => ra_ide}/src/display.rs | 0 .../src/display/function_signature.rs | 0 .../src/display/navigation_target.rs | 0 .../src/display/short_label.rs | 0 .../src/display/structure.rs | 0 crates/{ra_ide_api => ra_ide}/src/expand.rs | 0 .../src/expand_macro.rs | 0 .../src/extend_selection.rs | 0 .../src/feature_flags.rs | 0 .../src/folding_ranges.rs | 0 .../src/goto_definition.rs | 0 .../src/goto_type_definition.rs | 0 crates/{ra_ide_api => ra_ide}/src/hover.rs | 0 crates/{ra_ide_api => ra_ide}/src/impls.rs | 0 .../{ra_ide_api => ra_ide}/src/inlay_hints.rs | 0 .../{ra_ide_api => ra_ide}/src/join_lines.rs | 0 crates/{ra_ide_api => ra_ide}/src/lib.rs | 2 +- .../{ra_ide_api => ra_ide}/src/line_index.rs | 0 .../src/line_index_utils.rs | 0 crates/{ra_ide_api => ra_ide}/src/marks.rs | 0 .../src/matching_brace.rs | 0 .../src/mock_analysis.rs | 0 .../src/parent_module.rs | 0 .../{ra_ide_api => ra_ide}/src/references.rs | 0 .../src/references/classify.rs | 0 .../src/references/name_definition.rs | 0 .../src/references/rename.rs | 0 .../src/references/search_scope.rs | 0 .../{ra_ide_api => ra_ide}/src/runnables.rs | 0 .../src/snapshots/highlighting.html | 0 .../src/snapshots/rainbow_highlighting.html | 0 .../src/source_change.rs | 0 crates/{ra_ide_api => ra_ide}/src/status.rs | 0 .../src/symbol_index.rs | 0 .../src/syntax_highlighting.rs | 4 ++-- .../{ra_ide_api => ra_ide}/src/syntax_tree.rs | 0 .../{ra_ide_api => ra_ide}/src/test_utils.rs | 0 crates/{ra_ide_api => ra_ide}/src/typing.rs | 0 .../{ra_ide_api => ra_ide}/src/wasm_shims.rs | 0 crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/cargo_target_spec.rs | 2 +- crates/ra_lsp_server/src/conv.rs | 6 ++--- crates/ra_lsp_server/src/lib.rs | 2 +- crates/ra_lsp_server/src/main_loop.rs | 2 +- .../ra_lsp_server/src/main_loop/handlers.rs | 6 ++--- .../src/main_loop/subscriptions.rs | 2 +- crates/ra_lsp_server/src/world.rs | 2 +- docs/dev/README.md | 2 +- docs/dev/architecture.md | 12 +++++----- docs/dev/guide.md | 24 +++++++++---------- editors/code/src/utils/terminateProcess.sh | 0 xtask/tests/tidy-tests/docs.rs | 2 +- 81 files changed, 48 insertions(+), 48 deletions(-) rename crates/{ra_ide_api => ra_ide}/Cargo.toml (91%) rename crates/{ra_ide_api => ra_ide}/src/assists.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/call_info.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/change.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_dot.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_fn_param.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_keyword.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_macro_in_item_position.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_path.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_pattern.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_postfix.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_record_literal.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_record_pattern.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_scope.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/complete_snippet.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/completion_context.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/completion_item.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/completion/presentation.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/db.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/diagnostics.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/display.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/display/function_signature.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/display/navigation_target.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/display/short_label.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/display/structure.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/expand.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/expand_macro.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/extend_selection.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/feature_flags.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/folding_ranges.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/goto_definition.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/goto_type_definition.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/hover.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/impls.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/inlay_hints.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/join_lines.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/lib.rs (99%) rename crates/{ra_ide_api => ra_ide}/src/line_index.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/line_index_utils.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/marks.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/matching_brace.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/mock_analysis.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/parent_module.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/references.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/references/classify.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/references/name_definition.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/references/rename.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/references/search_scope.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/runnables.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/snapshots/highlighting.html (100%) rename crates/{ra_ide_api => ra_ide}/src/snapshots/rainbow_highlighting.html (100%) rename crates/{ra_ide_api => ra_ide}/src/source_change.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/status.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/symbol_index.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/syntax_highlighting.rs (98%) rename crates/{ra_ide_api => ra_ide}/src/syntax_tree.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/test_utils.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/typing.rs (100%) rename crates/{ra_ide_api => ra_ide}/src/wasm_shims.rs (100%) mode change 100755 => 100644 editors/code/src/utils/terminateProcess.sh diff --git a/Cargo.lock b/Cargo.lock index 0f7a45d6cb7..b0a0e841c83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -906,7 +906,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "ra_db 0.1.0", "ra_hir 0.1.0", - "ra_ide_api 0.1.0", + "ra_ide 0.1.0", "ra_project_model 0.1.0", "ra_vfs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "ra_vfs_glob 0.1.0", @@ -932,7 +932,7 @@ dependencies = [ "ra_batch 0.1.0", "ra_db 0.1.0", "ra_hir 0.1.0", - "ra_ide_api 0.1.0", + "ra_ide 0.1.0", "ra_prof 0.1.0", "ra_syntax 0.1.0", ] @@ -1027,7 +1027,7 @@ dependencies = [ ] [[package]] -name = "ra_ide_api" +name = "ra_ide" version = "0.1.0" dependencies = [ "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1065,7 +1065,7 @@ dependencies = [ "lsp-server 0.3.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_api 0.1.0", + "ra_ide 0.1.0", "ra_prof 0.1.0", "ra_project_model 0.1.0", "ra_syntax 0.1.0", diff --git a/README.md b/README.md index ea1c25d7f12..74c971c0d3d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 ## Quick Links -* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide_api/ +* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ ## License diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml index 35626d77d2d..3bf351fe377 100644 --- a/crates/ra_batch/Cargo.toml +++ b/crates/ra_batch/Cargo.toml @@ -15,6 +15,6 @@ crossbeam-channel = "0.4.0" ra_vfs = "0.5.0" ra_vfs_glob = { path = "../ra_vfs_glob" } ra_db = { path = "../ra_db" } -ra_ide_api = { path = "../ra_ide_api" } +ra_ide = { path = "../ra_ide" } ra_hir = { path = "../ra_hir" } ra_project_model = { path = "../ra_project_model" } diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index cb389eb2612..2c9645c00a3 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs @@ -6,7 +6,7 @@ use rustc_hash::FxHashMap; use crossbeam_channel::{unbounded, Receiver}; use ra_db::{CrateGraph, FileId, SourceRootId}; -use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; +use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; use ra_vfs_glob::RustPackageFilterBuilder; diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 3bb47599792..c7e0d0f0f33 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -10,7 +10,7 @@ pico-args = "0.3.0" flexi_logger = "0.14.0" ra_syntax = { path = "../ra_syntax" } -ra_ide_api = { path = "../ra_ide_api" } +ra_ide = { path = "../ra_ide" } ra_batch = { path = "../ra_batch" } ra_hir = { path = "../ra_hir" } ra_db = { path = "../ra_db" } diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 34105af57f3..5485a38ff27 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs @@ -10,7 +10,7 @@ use ra_db::{ salsa::{Database, Durability}, FileId, SourceDatabaseExt, }; -use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; +use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; use crate::Result; diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 08f35314770..fe847e61129 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -9,7 +9,7 @@ use std::{error::Error, fmt::Write, io::Read}; use flexi_logger::Logger; use pico_args::Arguments; -use ra_ide_api::{file_structure, Analysis}; +use ra_ide::{file_structure, Analysis}; use ra_prof::profile; use ra_syntax::{AstNode, SourceFile}; diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index e8852531bfb..21341b7697d 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_db defines basic database traits. The concrete DB is defined by ra_ide_api. +//! ra_db defines basic database traits. The concrete DB is defined by ra_ide. mod cancellation; mod input; pub mod fixture; diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide/Cargo.toml similarity index 91% rename from crates/ra_ide_api/Cargo.toml rename to crates/ra_ide/Cargo.toml index 15346f38812..e6383dd3528 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2018" -name = "ra_ide_api" +name = "ra_ide" version = "0.1.0" authors = ["rust-analyzer developers"] @@ -32,7 +32,7 @@ ra_prof = { path = "../ra_prof" } test_utils = { path = "../test_utils" } ra_assists = { path = "../ra_assists" } -# ra_ide_api should depend only on the top-level `hir` package. if you need +# ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/ra_ide_api/src/assists.rs b/crates/ra_ide/src/assists.rs similarity index 100% rename from crates/ra_ide_api/src/assists.rs rename to crates/ra_ide/src/assists.rs diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide/src/call_info.rs similarity index 100% rename from crates/ra_ide_api/src/call_info.rs rename to crates/ra_ide/src/call_info.rs diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide/src/change.rs similarity index 100% rename from crates/ra_ide_api/src/change.rs rename to crates/ra_ide/src/change.rs diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide/src/completion.rs similarity index 100% rename from crates/ra_ide_api/src/completion.rs rename to crates/ra_ide/src/completion.rs diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_dot.rs rename to crates/ra_ide/src/completion/complete_dot.rs diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_fn_param.rs rename to crates/ra_ide/src/completion/complete_fn_param.rs diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_keyword.rs rename to crates/ra_ide/src/completion/complete_keyword.rs diff --git a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide/src/completion/complete_macro_in_item_position.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs rename to crates/ra_ide/src/completion/complete_macro_in_item_position.rs diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_path.rs rename to crates/ra_ide/src/completion/complete_path.rs diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide/src/completion/complete_pattern.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_pattern.rs rename to crates/ra_ide/src/completion/complete_pattern.rs diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_postfix.rs rename to crates/ra_ide/src/completion/complete_postfix.rs diff --git a/crates/ra_ide_api/src/completion/complete_record_literal.rs b/crates/ra_ide/src/completion/complete_record_literal.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_record_literal.rs rename to crates/ra_ide/src/completion/complete_record_literal.rs diff --git a/crates/ra_ide_api/src/completion/complete_record_pattern.rs b/crates/ra_ide/src/completion/complete_record_pattern.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_record_pattern.rs rename to crates/ra_ide/src/completion/complete_record_pattern.rs diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_scope.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_scope.rs rename to crates/ra_ide/src/completion/complete_scope.rs diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide/src/completion/complete_snippet.rs similarity index 100% rename from crates/ra_ide_api/src/completion/complete_snippet.rs rename to crates/ra_ide/src/completion/complete_snippet.rs diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs similarity index 100% rename from crates/ra_ide_api/src/completion/completion_context.rs rename to crates/ra_ide/src/completion/completion_context.rs diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs similarity index 100% rename from crates/ra_ide_api/src/completion/completion_item.rs rename to crates/ra_ide/src/completion/completion_item.rs diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs similarity index 100% rename from crates/ra_ide_api/src/completion/presentation.rs rename to crates/ra_ide/src/completion/presentation.rs diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide/src/db.rs similarity index 100% rename from crates/ra_ide_api/src/db.rs rename to crates/ra_ide/src/db.rs diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs similarity index 100% rename from crates/ra_ide_api/src/diagnostics.rs rename to crates/ra_ide/src/diagnostics.rs diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide/src/display.rs similarity index 100% rename from crates/ra_ide_api/src/display.rs rename to crates/ra_ide/src/display.rs diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs similarity index 100% rename from crates/ra_ide_api/src/display/function_signature.rs rename to crates/ra_ide/src/display/function_signature.rs diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs similarity index 100% rename from crates/ra_ide_api/src/display/navigation_target.rs rename to crates/ra_ide/src/display/navigation_target.rs diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs similarity index 100% rename from crates/ra_ide_api/src/display/short_label.rs rename to crates/ra_ide/src/display/short_label.rs diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs similarity index 100% rename from crates/ra_ide_api/src/display/structure.rs rename to crates/ra_ide/src/display/structure.rs diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide/src/expand.rs similarity index 100% rename from crates/ra_ide_api/src/expand.rs rename to crates/ra_ide/src/expand.rs diff --git a/crates/ra_ide_api/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs similarity index 100% rename from crates/ra_ide_api/src/expand_macro.rs rename to crates/ra_ide/src/expand_macro.rs diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs similarity index 100% rename from crates/ra_ide_api/src/extend_selection.rs rename to crates/ra_ide/src/extend_selection.rs diff --git a/crates/ra_ide_api/src/feature_flags.rs b/crates/ra_ide/src/feature_flags.rs similarity index 100% rename from crates/ra_ide_api/src/feature_flags.rs rename to crates/ra_ide/src/feature_flags.rs diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs similarity index 100% rename from crates/ra_ide_api/src/folding_ranges.rs rename to crates/ra_ide/src/folding_ranges.rs diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs similarity index 100% rename from crates/ra_ide_api/src/goto_definition.rs rename to crates/ra_ide/src/goto_definition.rs diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs similarity index 100% rename from crates/ra_ide_api/src/goto_type_definition.rs rename to crates/ra_ide/src/goto_type_definition.rs diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide/src/hover.rs similarity index 100% rename from crates/ra_ide_api/src/hover.rs rename to crates/ra_ide/src/hover.rs diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide/src/impls.rs similarity index 100% rename from crates/ra_ide_api/src/impls.rs rename to crates/ra_ide/src/impls.rs diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs similarity index 100% rename from crates/ra_ide_api/src/inlay_hints.rs rename to crates/ra_ide/src/inlay_hints.rs diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs similarity index 100% rename from crates/ra_ide_api/src/join_lines.rs rename to crates/ra_ide/src/join_lines.rs diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide/src/lib.rs similarity index 99% rename from crates/ra_ide_api/src/lib.rs rename to crates/ra_ide/src/lib.rs index cb6c24eaa58..d1bff4a761e 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_ide_api crate provides "ide-centric" APIs for the rust-analyzer. That is, +//! ra_ide crate provides "ide-centric" APIs for the rust-analyzer. That is, //! it generally operates with files and text ranges, and returns results as //! Strings, suitable for displaying to the human. //! diff --git a/crates/ra_ide_api/src/line_index.rs b/crates/ra_ide/src/line_index.rs similarity index 100% rename from crates/ra_ide_api/src/line_index.rs rename to crates/ra_ide/src/line_index.rs diff --git a/crates/ra_ide_api/src/line_index_utils.rs b/crates/ra_ide/src/line_index_utils.rs similarity index 100% rename from crates/ra_ide_api/src/line_index_utils.rs rename to crates/ra_ide/src/line_index_utils.rs diff --git a/crates/ra_ide_api/src/marks.rs b/crates/ra_ide/src/marks.rs similarity index 100% rename from crates/ra_ide_api/src/marks.rs rename to crates/ra_ide/src/marks.rs diff --git a/crates/ra_ide_api/src/matching_brace.rs b/crates/ra_ide/src/matching_brace.rs similarity index 100% rename from crates/ra_ide_api/src/matching_brace.rs rename to crates/ra_ide/src/matching_brace.rs diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs similarity index 100% rename from crates/ra_ide_api/src/mock_analysis.rs rename to crates/ra_ide/src/mock_analysis.rs diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs similarity index 100% rename from crates/ra_ide_api/src/parent_module.rs rename to crates/ra_ide/src/parent_module.rs diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide/src/references.rs similarity index 100% rename from crates/ra_ide_api/src/references.rs rename to crates/ra_ide/src/references.rs diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs similarity index 100% rename from crates/ra_ide_api/src/references/classify.rs rename to crates/ra_ide/src/references/classify.rs diff --git a/crates/ra_ide_api/src/references/name_definition.rs b/crates/ra_ide/src/references/name_definition.rs similarity index 100% rename from crates/ra_ide_api/src/references/name_definition.rs rename to crates/ra_ide/src/references/name_definition.rs diff --git a/crates/ra_ide_api/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs similarity index 100% rename from crates/ra_ide_api/src/references/rename.rs rename to crates/ra_ide/src/references/rename.rs diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide/src/references/search_scope.rs similarity index 100% rename from crates/ra_ide_api/src/references/search_scope.rs rename to crates/ra_ide/src/references/search_scope.rs diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide/src/runnables.rs similarity index 100% rename from crates/ra_ide_api/src/runnables.rs rename to crates/ra_ide/src/runnables.rs diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html similarity index 100% rename from crates/ra_ide_api/src/snapshots/highlighting.html rename to crates/ra_ide/src/snapshots/highlighting.html diff --git a/crates/ra_ide_api/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html similarity index 100% rename from crates/ra_ide_api/src/snapshots/rainbow_highlighting.html rename to crates/ra_ide/src/snapshots/rainbow_highlighting.html diff --git a/crates/ra_ide_api/src/source_change.rs b/crates/ra_ide/src/source_change.rs similarity index 100% rename from crates/ra_ide_api/src/source_change.rs rename to crates/ra_ide/src/source_change.rs diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide/src/status.rs similarity index 100% rename from crates/ra_ide_api/src/status.rs rename to crates/ra_ide/src/status.rs diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide/src/symbol_index.rs similarity index 100% rename from crates/ra_ide_api/src/symbol_index.rs rename to crates/ra_ide/src/symbol_index.rs diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs similarity index 98% rename from crates/ra_ide_api/src/syntax_highlighting.rs rename to crates/ra_ide/src/syntax_highlighting.rs index 10165a9bbc9..2c568a747e8 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -306,7 +306,7 @@ fn main() { "# .trim(), ); - let dst_file = project_dir().join("crates/ra_ide_api/src/snapshots/highlighting.html"); + let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlighting.html"); let actual_html = &analysis.highlight_as_html(file_id, false).unwrap(); let expected_html = &read_text(&dst_file); std::fs::write(dst_file, &actual_html).unwrap(); @@ -333,7 +333,7 @@ fn bar() { .trim(), ); let dst_file = - project_dir().join("crates/ra_ide_api/src/snapshots/rainbow_highlighting.html"); + project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html"); let actual_html = &analysis.highlight_as_html(file_id, true).unwrap(); let expected_html = &read_text(&dst_file); std::fs::write(dst_file, &actual_html).unwrap(); diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs similarity index 100% rename from crates/ra_ide_api/src/syntax_tree.rs rename to crates/ra_ide/src/syntax_tree.rs diff --git a/crates/ra_ide_api/src/test_utils.rs b/crates/ra_ide/src/test_utils.rs similarity index 100% rename from crates/ra_ide_api/src/test_utils.rs rename to crates/ra_ide/src/test_utils.rs diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide/src/typing.rs similarity index 100% rename from crates/ra_ide_api/src/typing.rs rename to crates/ra_ide/src/typing.rs diff --git a/crates/ra_ide_api/src/wasm_shims.rs b/crates/ra_ide/src/wasm_shims.rs similarity index 100% rename from crates/ra_ide_api/src/wasm_shims.rs rename to crates/ra_ide/src/wasm_shims.rs diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 58b9cfaa00b..21aef842ce6 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -22,7 +22,7 @@ jod-thread = "0.1.0" ra_vfs = "0.5.0" ra_syntax = { path = "../ra_syntax" } ra_text_edit = { path = "../ra_text_edit" } -ra_ide_api = { path = "../ra_ide_api" } +ra_ide = { path = "../ra_ide" } lsp-server = "0.3.0" ra_project_model = { path = "../ra_project_model" } ra_prof = { path = "../ra_prof" } diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index d996b53de43..c4a9e71018f 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_ide_api::{FileId, RunnableKind}; +use ra_ide::{FileId, RunnableKind}; use ra_project_model::{self, ProjectWorkspace, TargetKind}; use crate::{world::WorldSnapshot, Result}; diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 94ed619faec..b13093cfe65 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -6,7 +6,7 @@ use lsp_types::{ SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit, }; -use ra_ide_api::{ +use ra_ide::{ translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, Fold, FoldKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo, Severity, SourceChange, SourceFileEdit, @@ -173,7 +173,7 @@ impl ConvWith<&LineIndex> for Range { } } -impl Conv for ra_ide_api::Documentation { +impl Conv for ra_ide::Documentation { type Output = lsp_types::Documentation; fn conv(self) -> Documentation { Documentation::MarkupContent(MarkupContent { @@ -183,7 +183,7 @@ impl Conv for ra_ide_api::Documentation { } } -impl Conv for ra_ide_api::FunctionSignature { +impl Conv for ra_ide::FunctionSignature { type Output = lsp_types::SignatureInformation; fn conv(self) -> Self::Output { use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation}; diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index 9c36402b0b9..2ca149fd56b 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs @@ -1,6 +1,6 @@ //! Implementation of the LSP for rust-analyzer. //! -//! This crate takes Rust-specific analysis results from ra_ide_api and +//! This crate takes Rust-specific analysis results from ra_ide and //! translates into LSP types. //! //! It also is the root of all state. `world` module defines the bulk of the diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 0dc0aeee864..83845f1e006 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -9,7 +9,7 @@ use std::{error::Error, fmt, panic, path::PathBuf, sync::Arc, time::Instant}; use crossbeam_channel::{select, unbounded, RecvError, Sender}; use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response}; use lsp_types::{ClientCapabilities, NumberOrString}; -use ra_ide_api::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; +use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; use ra_prof::profile; use ra_vfs::{VfsTask, Watch}; use relative_path::RelativePathBuf; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index e552f2106de..c81fa7f679c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -9,7 +9,7 @@ use lsp_types::{ Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, }; -use ra_ide_api::{ +use ra_ide::{ AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope, }; use ra_prof::profile; @@ -162,7 +162,7 @@ pub fn handle_on_type_formatting( let line_index = world.analysis().file_line_index(position.file_id)?; let line_endings = world.file_line_endings(position.file_id); - // in `ra_ide_api`, the `on_type` invariant is that + // in `ra_ide`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. position.offset = position.offset - TextUnit::of_char('.'); let char_typed = params.ch.chars().next().unwrap_or('\0'); @@ -894,7 +894,7 @@ pub fn handle_inlay_hints( label: api_type.label.to_string(), range: api_type.range.conv_with(&line_index), kind: match api_type.kind { - ra_ide_api::InlayKind::TypeHint => InlayKind::TypeHint, + ra_ide::InlayKind::TypeHint => InlayKind::TypeHint, }, }) .collect()) diff --git a/crates/ra_lsp_server/src/main_loop/subscriptions.rs b/crates/ra_lsp_server/src/main_loop/subscriptions.rs index 3856263b0a9..609b2adcc99 100644 --- a/crates/ra_lsp_server/src/main_loop/subscriptions.rs +++ b/crates/ra_lsp_server/src/main_loop/subscriptions.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_ide_api::FileId; +use ra_ide::FileId; use rustc_hash::FxHashSet; #[derive(Default, Debug)] diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 9bdea70c745..927449b45da 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -9,7 +9,7 @@ use crossbeam_channel::{unbounded, Receiver}; use lsp_server::ErrorCode; use lsp_types::Url; use parking_lot::RwLock; -use ra_ide_api::{ +use ra_ide::{ Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, SourceRootId, }; diff --git a/docs/dev/README.md b/docs/dev/README.md index 0823ca09ab1..0f64d7e5f8c 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -14,7 +14,7 @@ To learn more about how rust-analyzer works, see We also publish rustdoc docs to pages: -https://rust-analyzer.github.io/rust-analyzer/ra_ide_api/ +https://rust-analyzer.github.io/rust-analyzer/ra_ide/ Various organizational and process issues are discussed in this document. diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 6fd396dee6e..629645757a1 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -106,7 +106,7 @@ guessing a HIR for a particular source position. Underneath, HIR works on top of salsa, using a `HirDatabase` trait. -### `crates/ra_ide_api` +### `crates/ra_ide` A stateful library for analyzing many Rust files as they change. `AnalysisHost` is a mutable entity (clojure's atom) which holds the current state, incorporates @@ -124,11 +124,11 @@ offsets and strings as output. This works on top of rich code model powered by ### `crates/ra_lsp_server` -An LSP implementation which wraps `ra_ide_api` into a language server protocol. +An LSP implementation which wraps `ra_ide` into a language server protocol. ### `ra_vfs` -Although `hir` and `ra_ide_api` don't do any IO, we need to be able to read +Although `hir` and `ra_ide` don't do any IO, we need to be able to read files from disk at the end of the day. This is what `ra_vfs` does. It also manages overlays: "dirty" files in the editor, whose "true" contents is different from data on disk. This is more or less the single really @@ -162,13 +162,13 @@ disk. For this reason, we try to avoid writing too many tests on this boundary: in a statically typed language, it's hard to make an error in the protocol itself if messages are themselves typed. -The middle, and most important, boundary is `ra_ide_api`. Unlike -`ra_lsp_server`, which exposes API, `ide_api` uses Rust API and is intended to +The middle, and most important, boundary is `ra_ide`. Unlike +`ra_lsp_server`, which exposes API, `ide` uses Rust API and is intended to use by various tools. Typical test creates an `AnalysisHost`, calls some `Analysis` functions and compares the results against expectation. The innermost and most elaborate boundary is `hir`. It has a much richer -vocabulary of types than `ide_api`, but the basic testing setup is the same: we +vocabulary of types than `ide`, but the basic testing setup is the same: we create a database, run some queries, assert result. For comparisons, we use [insta](https://github.com/mitsuhiko/insta/) library for diff --git a/docs/dev/guide.md b/docs/dev/guide.md index abbe4c15424..c163a74b31d 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md @@ -40,8 +40,8 @@ terms of files and offsets, and **not** in terms of Rust concepts like structs, traits, etc. The "typed" API with Rust specific types is slightly lower in the stack, we'll talk about it later. -[`AnalysisHost`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L265-L284 -[`Analysis`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L291-L478 +[`AnalysisHost`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/lib.rs#L265-L284 +[`Analysis`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/lib.rs#L291-L478 The reason for this separation of `Analysis` and `AnalysisHost` is that we want to apply changes "uniquely", but we might also want to fork an `Analysis` and send it to @@ -69,7 +69,7 @@ the `AnalysisHost::apply_change` method, which accepts a single argument, a "transaction", so it suffices to study its methods to understand all of the input data. -[`AnalysisChange`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L119-L167 +[`AnalysisChange`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/lib.rs#L119-L167 The `(add|change|remove)_file` methods control the set of the input files, where each file has an integer id (`FileId`, picked by the client), text (`String`) @@ -253,7 +253,7 @@ All analyzer information is stored in a salsa database. `Analysis` and `AnalysisHost` types are newtype wrappers for [`RootDatabase`] -- a salsa database. -[`RootDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/db.rs#L88-L134 +[`RootDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/db.rs#L88-L134 Salsa input queries are defined in [`FilesDatabase`] (which is a part of `RootDatabase`). They closely mirror the familiar `AnalysisChange` structure: @@ -565,11 +565,11 @@ the type to completion. [schedule it on the threadpool]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L428 [catch]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L436-L442 [the handler]: https://salsa.zulipchat.com/#narrow/stream/181542-rfcs.2Fsalsa-query-group/topic/design.20next.20steps -[ask analysis for completion]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L439-L444 -[completion implementation]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L46-L62 -[`CompletionContext`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L14-L37 -["IntelliJ Trick"]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L72-L75 -[find an ancestor `fn` node]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L116-L120 -[semantic model]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L123 -[series of independent completion routines]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L52-L59 -[`complete_dot`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/complete_dot.rs#L6-L22 +[ask analysis for completion]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/lib.rs#L439-L444 +[completion implementation]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion.rs#L46-L62 +[`CompletionContext`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion/completion_context.rs#L14-L37 +["IntelliJ Trick"]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion/completion_context.rs#L72-L75 +[find an ancestor `fn` node]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion/completion_context.rs#L116-L120 +[semantic model]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion/completion_context.rs#L123 +[series of independent completion routines]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion.rs#L52-L59 +[`complete_dot`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide/src/completion/complete_dot.rs#L6-L22 diff --git a/editors/code/src/utils/terminateProcess.sh b/editors/code/src/utils/terminateProcess.sh old mode 100755 new mode 100644 diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs index e0653b460f2..8a005d6c4dc 100644 --- a/xtask/tests/tidy-tests/docs.rs +++ b/xtask/tests/tidy-tests/docs.rs @@ -74,7 +74,7 @@ fn no_docs_comments() { "ra_db", "ra_hir", "ra_hir_expand", - "ra_ide_api", + "ra_ide", "ra_lsp_server", "ra_mbe", "ra_parser", From 27b362b05910c81fd5b28f6cd5d2c075311032f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 27 Nov 2019 21:44:38 +0300 Subject: [PATCH 3/3] Reformat --- crates/ra_hir/src/from_source.rs | 11 +++++------ crates/ra_hir_def/src/nameres/collector.rs | 3 +-- crates/ra_ide/src/syntax_highlighting.rs | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 7756ca80e7e..9f7c22b2118 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -262,12 +262,11 @@ impl Module { let original_file = src.file_id.original_file(db); - let (krate, local_id) = - db.relevant_crates(original_file).iter().find_map(|&crate_id| { - let crate_def_map = db.crate_def_map(crate_id); - let local_id = crate_def_map.modules_for_file(original_file).next()?; - Some((crate_id, local_id)) - })?; + let (krate, local_id) = db.relevant_crates(original_file).iter().find_map(|&crate_id| { + let crate_def_map = db.crate_def_map(crate_id); + let local_id = crate_def_map.modules_for_file(original_file).next()?; + Some((crate_id, local_id)) + })?; Some(Module { id: ModuleId { krate, local_id } }) } } diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 6cd14026bc8..603b497380a 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -682,8 +682,7 @@ where } fn define_def(&mut self, def: &raw::DefData) { - let module = - ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; + let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); let name = def.name.clone(); diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 2c568a747e8..9a3e4c82f65 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -332,8 +332,7 @@ fn bar() { "# .trim(), ); - let dst_file = - project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html"); + let dst_file = project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html"); let actual_html = &analysis.highlight_as_html(file_id, true).unwrap(); let expected_html = &read_text(&dst_file); std::fs::write(dst_file, &actual_html).unwrap();