mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
Merge #2430
2430: rename ra_ide_api -> ra_ide r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
360f6b7bb3
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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" }
|
||||
|
@ -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;
|
||||
|
@ -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" }
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<Name> {
|
||||
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<Module> {
|
||||
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<Item = Module> {
|
||||
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<Module> {
|
||||
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<Import>)> {
|
||||
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<ModuleDef> {
|
||||
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<ImplBlock> {
|
||||
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 {
|
||||
|
@ -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<ModuleSource> {
|
||||
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<Source<ast::Module>> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,13 +262,12 @@ impl Module {
|
||||
|
||||
let original_file = src.file_id.original_file(db);
|
||||
|
||||
let (krate, module_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))
|
||||
})?;
|
||||
Some(Module { id: ModuleId { 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_id = crate_def_map.modules_for_file(original_file).next()?;
|
||||
Some((crate_id, local_id))
|
||||
})?;
|
||||
Some(Module { id: ModuleId { krate, local_id } })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
};
|
||||
|
@ -82,7 +82,7 @@ impl Expander {
|
||||
}
|
||||
|
||||
fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) => {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
};
|
||||
@ -682,8 +682,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 };
|
||||
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();
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<DefWithBodyId> = 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);
|
||||
});
|
||||
});
|
||||
|
@ -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" }
|
||||
|
@ -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.
|
||||
//!
|
@ -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();
|
||||
@ -332,8 +332,7 @@ fn bar() {
|
||||
"#
|
||||
.trim(),
|
||||
);
|
||||
let dst_file =
|
||||
project_dir().join("crates/ra_ide_api/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();
|
@ -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" }
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
0
editors/code/src/utils/terminateProcess.sh
Executable file → Normal file
0
editors/code/src/utils/terminateProcess.sh
Executable file → Normal file
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user