aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-23 13:39:53 +0000
committerAleksey Kladov <[email protected]>2019-11-23 13:39:53 +0000
commite5bcb69e4f88c7536b1039a881816cb8f1c1f867 (patch)
tree85f8b45861da7737b73e5961c53e7297045f2a5c /crates/ra_hir/src/code_model
parent3bdb0349061a8a62c8490336efe7549c5525bb90 (diff)
Hide ImportId
Diffstat (limited to 'crates/ra_hir/src/code_model')
-rw-r--r--crates/ra_hir/src/code_model/src.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs
index 09bacf579..ceb3daa27 100644
--- a/crates/ra_hir/src/code_model/src.rs
+++ b/crates/ra_hir/src/code_model/src.rs
@@ -8,7 +8,7 @@ use crate::{
8 db::{AstDatabase, DefDatabase, HirDatabase}, 8 db::{AstDatabase, DefDatabase, HirDatabase},
9 ids::AstItemDef, 9 ids::AstItemDef,
10 Const, Enum, EnumVariant, FieldSource, Function, HasBody, MacroDef, Module, ModuleSource, 10 Const, Enum, EnumVariant, FieldSource, Function, HasBody, MacroDef, Module, ModuleSource,
11 Static, Struct, StructField, Trait, TypeAlias, Union, 11 Static, Struct, StructField, Trait, TypeAlias, Union, Import
12}; 12};
13 13
14pub use hir_expand::Source; 14pub use hir_expand::Source;
@@ -113,6 +113,16 @@ impl HasSource for MacroDef {
113 Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } 113 Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
114 } 114 }
115} 115}
116impl HasSource for Import {
117 type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
118
119 /// Returns the syntax of the last path segment corresponding to this import
120 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<Self::Ast> {
121 let src = self.parent.definition_source(db);
122 let (_, source_map) = db.raw_items_with_source_map(src.file_id);
123 src.with_value(source_map.get(&src.value, self.id))
124 }
125}
116 126
117pub trait HasBodySource: HasBody + HasSource 127pub trait HasBodySource: HasBody + HasSource
118where 128where