aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-25 08:09:26 +0000
committerGitHub <[email protected]>2020-03-25 08:09:26 +0000
commit8a73a8937d67db97072a11a40f0c3ed963e18e1b (patch)
tree7bfffa2750b044f47b67d7b9e89c14c1a1089505 /crates/ra_hir/src
parent6ad1a0711631d8017791a6dfe85bbe205d6c7414 (diff)
parentd606521723d2635a21e6dd821b314f8e3127cbf9 (diff)
Merge #3707
3707: Add ItemScope::visibility_of r=matklad a=edwin0cheng ~This PR implements `HasVisibility` for various constructs and change `Definition::search_scope` to use `Visibility` directly instead of depends on ad-hoc string parsing.~ This PR added `visibility_of` in `ItemScope` and `Module` and use it directly directly instead of depends on ad-hoc string parsing. And also add a FIXME to indicate that there is a bug which do not search child-submodules in other files recursively in `Definition::search_scope`. I will submit another PR to fix that bug after this is merged. cc @flodiebold Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/lib.rs2
2 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index c5cfd875f..3f0ebca0d 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -234,6 +234,10 @@ impl Module {
234 .collect() 234 .collect()
235 } 235 }
236 236
237 pub fn visibility_of(self, db: &dyn HirDatabase, def: &ModuleDef) -> Option<Visibility> {
238 db.crate_def_map(self.id.krate)[self.id.local_id].scope.visbility_of(def.clone().into())
239 }
240
237 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 241 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
238 let _p = profile("Module::diagnostics"); 242 let _p = profile("Module::diagnostics");
239 let crate_def_map = db.crate_def_map(self.id.krate); 243 let crate_def_map = db.crate_def_map(self.id.krate);
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 713d45f48..5af7e5d6d 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -54,7 +54,7 @@ pub use crate::{
54 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, 54 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency,
55 DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, 55 DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs,
56 HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, 56 HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct,
57 StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, 57 StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
58 }, 58 },
59 has_source::HasSource, 59 has_source::HasSource,
60 semantics::{original_range, PathResolution, Semantics, SemanticsScope}, 60 semantics::{original_range, PathResolution, Semantics, SemanticsScope},