diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-26 19:26:07 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-26 19:26:07 +0100 |
commit | e7da5816d67fadc056ee43310f9d04164c2617d9 (patch) | |
tree | 854e94856b4d120d156b67e790d7f2ba74e14610 /crates/hir/src/code_model.rs | |
parent | 7e012ae8b54705bc254154cdff3a503cce3299a7 (diff) | |
parent | f8a59adf5e9633aa5d10efcdbf70b408d280ef01 (diff) |
Merge #5895
5895: Tease apart orthogonal concerns in markdown link rewriting
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir/src/code_model.rs')
-rw-r--r-- | crates/hir/src/code_model.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index c2ee20dbb..c2fc819e7 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -196,6 +196,16 @@ impl ModuleDef { | |||
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> { | ||
200 | let mut segments = Vec::new(); | ||
201 | segments.push(self.name(db)?.to_string()); | ||
202 | for m in self.module(db)?.path_to_root(db) { | ||
203 | segments.extend(m.name(db).map(|it| it.to_string())) | ||
204 | } | ||
205 | segments.reverse(); | ||
206 | Some(segments.join("::")) | ||
207 | } | ||
208 | |||
199 | pub fn definition_visibility(&self, db: &dyn HirDatabase) -> Option<Visibility> { | 209 | pub fn definition_visibility(&self, db: &dyn HirDatabase) -> Option<Visibility> { |
200 | let module = match self { | 210 | let module = match self { |
201 | ModuleDef::Module(it) => it.parent(db)?, | 211 | ModuleDef::Module(it) => it.parent(db)?, |