diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-05 13:38:39 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-05 13:38:39 +0000 |
commit | 4c0bd068da39e74c66104206e27c270454e3562e (patch) | |
tree | 25e6c7005e04c3a63344f23a003614409cfda4c9 /crates/ra_ide | |
parent | ace661bb10dbfd596a444c235f80fa43a2845239 (diff) | |
parent | d15f300268fa955f8e9c04d51ca1dc528766f742 (diff) |
Merge #2474
2474: Move `ModuleSource`, create `ModuleOrigin` r=matklad a=ice1000
As title. This comes right after #2473
Co-authored-by: ice1000 <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 42 | ||||
-rw-r--r-- | crates/ra_ide/src/parent_module.rs | 5 |
2 files changed, 17 insertions, 30 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index f920d3db6..add11fbc3 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -231,34 +231,20 @@ impl ToNav for hir::Module { | |||
231 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { | 231 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { |
232 | let src = self.definition_source(db); | 232 | let src = self.definition_source(db); |
233 | let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 233 | let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
234 | match &src.value { | 234 | let syntax = match &src.value { |
235 | ModuleSource::SourceFile(node) => { | 235 | ModuleSource::SourceFile(node) => node.syntax(), |
236 | let frange = original_range(db, src.with_value(node.syntax())); | 236 | ModuleSource::Module(node) => node.syntax(), |
237 | 237 | }; | |
238 | NavigationTarget::from_syntax( | 238 | let frange = original_range(db, src.with_value(syntax)); |
239 | frange.file_id, | 239 | NavigationTarget::from_syntax( |
240 | name, | 240 | frange.file_id, |
241 | None, | 241 | name, |
242 | frange.range, | 242 | None, |
243 | node.syntax().kind(), | 243 | frange.range, |
244 | None, | 244 | syntax.kind(), |
245 | None, | 245 | None, |
246 | ) | 246 | None, |
247 | } | 247 | ) |
248 | ModuleSource::Module(node) => { | ||
249 | let frange = original_range(db, src.with_value(node.syntax())); | ||
250 | |||
251 | NavigationTarget::from_syntax( | ||
252 | frange.file_id, | ||
253 | name, | ||
254 | None, | ||
255 | frange.range, | ||
256 | node.syntax().kind(), | ||
257 | node.doc_comment_text(), | ||
258 | node.short_label(), | ||
259 | ) | ||
260 | } | ||
261 | } | ||
262 | } | 248 | } |
263 | } | 249 | } |
264 | 250 | ||
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 616d69fce..aef3fa3df 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_db::{CrateId, FileId, FilePosition}; | 3 | use ra_db::{CrateId, FileId, FilePosition, SourceDatabase}; |
4 | 4 | ||
5 | use crate::{db::RootDatabase, NavigationTarget}; | 5 | use crate::{db::RootDatabase, NavigationTarget}; |
6 | 6 | ||
@@ -21,7 +21,8 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na | |||
21 | 21 | ||
22 | /// Returns `Vec` for the same reason as `parent_module` | 22 | /// Returns `Vec` for the same reason as `parent_module` |
23 | pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | 23 | pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { |
24 | let src = hir::ModuleSource::from_file_id(db, file_id); | 24 | let source_file = db.parse(file_id).tree(); |
25 | let src = hir::ModuleSource::SourceFile(source_file); | ||
25 | let module = | 26 | let module = |
26 | match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src }) | 27 | match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src }) |
27 | { | 28 | { |