mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
use either for uses
This commit is contained in:
parent
b863272899
commit
1cd184d653
6 changed files with 40 additions and 44 deletions
|
@ -4,7 +4,7 @@ use ra_db::{CrateId, SourceRootId, Edition};
|
|||
use ra_syntax::{ast::self, TreeArc};
|
||||
|
||||
use crate::{
|
||||
Name, ScopesWithSourceMap, Ty, HirFileId, ImportSource,
|
||||
Name, ScopesWithSourceMap, Ty, HirFileId, Either,
|
||||
HirDatabase, DefDatabase,
|
||||
type_ref::TypeRef,
|
||||
nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
|
||||
|
@ -117,8 +117,14 @@ impl Module {
|
|||
}
|
||||
|
||||
/// Returns the syntax of the last path segment corresponding to this import
|
||||
pub fn import_source(&self, db: &impl HirDatabase, import: ImportId) -> ImportSource {
|
||||
self.import_source_impl(db, import)
|
||||
pub fn import_source(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
import: ImportId,
|
||||
) -> Either<TreeArc<ast::UseTree>, TreeArc<ast::ExternCrateItem>> {
|
||||
let (file_id, source) = self.definition_source(db);
|
||||
let (_, source_map) = db.raw_items_with_source_map(file_id);
|
||||
source_map.get(&source, import)
|
||||
}
|
||||
|
||||
/// Returns the crate this module is part of.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue