mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
move crate for
This commit is contained in:
parent
842e8001b2
commit
bddd124298
3 changed files with 16 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
use ra_db::FilePosition;
|
||||
use ra_db::{FilePosition, FileId, CrateId};
|
||||
|
||||
use crate::{NavigationTarget, db::RootDatabase};
|
||||
|
||||
|
@ -13,6 +13,19 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
|
|||
vec![nav]
|
||||
}
|
||||
|
||||
/// Returns `Vec` for the same reason as `parent_module`
|
||||
pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
|
||||
let module = match hir::source_binder::module_from_file_id(db, file_id) {
|
||||
Some(it) => it,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
let krate = match module.krate(db) {
|
||||
Some(it) => it,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
vec![krate.crate_id()]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::mock_analysis::analysis_and_position;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue