aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-24 12:20:59 +0000
committerAleksey Kladov <[email protected]>2019-11-24 12:20:59 +0000
commit151180057b0304ee4dee75401e8f1aaa7aaaec21 (patch)
treef61f810aa5f0c9cda0f07bd15d8f03b2d3b5ee83 /crates/ra_hir_def/src
parente0b06cb672b7aae770fea24e4a5efdbec8cbf5c6 (diff)
Simplify
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/lib.rs15
1 files changed, 0 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 89f1ceb58..f60feb5fa 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -94,25 +94,10 @@ impl<'a, DB> LocationCtx<&'a DB> {
94 } 94 }
95} 95}
96 96
97impl<'a, DB: AstDatabase + InternDatabase> LocationCtx<&'a DB> {
98 pub fn to_def<N, DEF>(self, ast: &N) -> DEF
99 where
100 N: AstNode,
101 DEF: AstItemDef<N>,
102 {
103 DEF::from_ast(self, ast)
104 }
105}
106
107pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone { 97pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone {
108 fn intern(db: &impl InternDatabase, loc: ItemLoc<N>) -> Self; 98 fn intern(db: &impl InternDatabase, loc: ItemLoc<N>) -> Self;
109 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<N>; 99 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<N>;
110 100
111 fn from_ast(ctx: LocationCtx<&(impl AstDatabase + InternDatabase)>, ast: &N) -> Self {
112 let items = ctx.db.ast_id_map(ctx.file_id);
113 let item_id = items.ast_id(ast);
114 Self::from_ast_id(ctx, item_id)
115 }
116 fn from_ast_id(ctx: LocationCtx<&impl InternDatabase>, ast_id: FileAstId<N>) -> Self { 101 fn from_ast_id(ctx: LocationCtx<&impl InternDatabase>, ast_id: FileAstId<N>) -> Self {
117 let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) }; 102 let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) };
118 Self::intern(ctx.db, loc) 103 Self::intern(ctx.db, loc)