From 0b8fbb4fad97d2980f0070a23f5365a5ed887e2a Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Wed, 9 Jan 2019 00:47:12 +0100 Subject: Fix typos in ARCHITECTURE.md and a number of crates specifically: gen_lsp_server, ra_arena, ra_cli, ra_db, ra_hir --- crates/ra_hir/src/code_model_api.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 343d06a5b..66c016180 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -13,8 +13,8 @@ use crate::{ ty::InferenceResult, }; -/// hir::Crate describes a single crate. It's the main inteface with which -/// crate's dependencies interact. Mostly, it should be just a proxy for the +/// hir::Crate describes a single crate. It's the main interface with which +/// a crate's dependencies interact. Mostly, it should be just a proxy for the /// root module. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Crate { @@ -78,6 +78,7 @@ impl Module { pub fn definition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> { self.definition_source_impl(db) } + /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. /// `None` for the crate root. pub fn declaration_source( @@ -91,20 +92,24 @@ impl Module { pub fn krate(&self, db: &impl HirDatabase) -> Cancelable> { self.krate_impl(db) } + /// Topmost parent of this module. Every module has a `crate_root`, but some - /// might miss `krate`. This can happen if a module's file is not included - /// into any module tree of any target from Cargo.toml. + /// might be missing `krate`. This can happen if a module's file is not included + /// in the module tree of any target in Cargo.toml. pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable { self.crate_root_impl(db) } + /// Finds a child module with the specified name. pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { self.child_impl(db, name) } + /// Finds a parent module. pub fn parent(&self, db: &impl HirDatabase) -> Cancelable> { self.parent_impl(db) } + pub fn path_to_root(&self, db: &impl HirDatabase) -> Cancelable> { let mut res = vec![self.clone()]; let mut curr = self.clone(); @@ -114,13 +119,16 @@ impl Module { } Ok(res) } + /// Returns a `ModuleScope`: a set of items, visible in this module. pub fn scope(&self, db: &impl HirDatabase) -> Cancelable { self.scope_impl(db) } + pub fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> Cancelable> { self.resolve_path_impl(db, path) } + pub fn problems( &self, db: &impl HirDatabase, @@ -140,6 +148,7 @@ impl StructField { pub fn name(&self) -> &Name { &self.name } + pub fn type_ref(&self) -> &TypeRef { &self.type_ref } @@ -160,18 +169,21 @@ impl VariantData { _ => &[], } } + pub fn is_struct(&self) -> bool { match self { VariantData::Struct(..) => true, _ => false, } } + pub fn is_tuple(&self) -> bool { match self { VariantData::Tuple(..) => true, _ => false, } } + pub fn is_unit(&self) -> bool { match self { VariantData::Unit => true, -- cgit v1.2.3