aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/descriptors/module
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/descriptors/module')
-rw-r--r--crates/ra_analysis/src/descriptors/module/mod.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs
index cfdffcdbc..a7e41e3db 100644
--- a/crates/ra_analysis/src/descriptors/module/mod.rs
+++ b/crates/ra_analysis/src/descriptors/module/mod.rs
@@ -14,11 +14,11 @@ use relative_path::RelativePathBuf;
14 14
15use crate::{ 15use crate::{
16 db::SyntaxDatabase, syntax_ptr::SyntaxPtr, FileId, FilePosition, Cancelable, 16 db::SyntaxDatabase, syntax_ptr::SyntaxPtr, FileId, FilePosition, Cancelable,
17 descriptors::DescriptorDatabase, 17 descriptors::{Path, PathKind, DescriptorDatabase},
18 input::SourceRootId 18 input::SourceRootId
19}; 19};
20 20
21pub(crate) use self::{nameres::ModuleScope}; 21pub(crate) use self::nameres::ModuleScope;
22 22
23/// `ModuleDescriptor` is API entry point to get all the information 23/// `ModuleDescriptor` is API entry point to get all the information
24/// about a particular module. 24/// about a particular module.
@@ -131,6 +131,19 @@ impl ModuleDescriptor {
131 Ok(res) 131 Ok(res)
132 } 132 }
133 133
134 pub(crate) fn resolve_path(&self, path: Path) -> Option<ModuleDescriptor> {
135 let mut curr = match path.kind {
136 PathKind::Crate => self.crate_root(),
137 PathKind::Self_ | PathKind::Plain => self.clone(),
138 PathKind::Super => self.parent()?,
139 };
140 let segments = path.segments;
141 for name in segments {
142 curr = curr.child(&name)?;
143 }
144 Some(curr)
145 }
146
134 pub fn problems(&self, db: &impl DescriptorDatabase) -> Vec<(SyntaxNode, Problem)> { 147 pub fn problems(&self, db: &impl DescriptorDatabase) -> Vec<(SyntaxNode, Problem)> {
135 self.module_id.problems(&self.tree, db) 148 self.module_id.problems(&self.tree, db)
136 } 149 }