diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-19 19:18:41 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-19 19:18:41 +0100 |
commit | cd9b222ba0555424d73d549eac43d9aaf1765d7d (patch) | |
tree | 88eea12084b65ba7b0f808cc2c626c7b57c7ac53 /crates/ra_ide_api/src/completion/completion_context.rs | |
parent | 44bab3621d74f1aec922300a3b3f4476907ba2ac (diff) | |
parent | 2867c40925e8f7b440ff50a421a2d3726b9ff334 (diff) |
Merge #1853
1853: Introduce FromSource trait r=matklad a=viorina
The idea is to provide an ability to get HIR from AST in a more general way than it's possible using `source_binder`.
It also could help with #1622 fixing.
Co-authored-by: Ekaterina Babshukova <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 7139947b3..59bd3689b 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::source_binder; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | algo::{find_covering_element, find_node_at_offset}, | 2 | algo::{find_covering_element, find_node_at_offset}, |
4 | ast, AstNode, Parse, SourceFile, | 3 | ast, AstNode, Parse, SourceFile, |
@@ -47,7 +46,11 @@ impl<'a> CompletionContext<'a> { | |||
47 | original_parse: &'a Parse<ast::SourceFile>, | 46 | original_parse: &'a Parse<ast::SourceFile>, |
48 | position: FilePosition, | 47 | position: FilePosition, |
49 | ) -> Option<CompletionContext<'a>> { | 48 | ) -> Option<CompletionContext<'a>> { |
50 | let module = source_binder::module_from_position(db, position); | 49 | let src = hir::ModuleSource::from_position(db, position); |
50 | let module = hir::Module::from_definition( | ||
51 | db, | ||
52 | hir::Source { file_id: position.file_id.into(), ast: src }, | ||
53 | ); | ||
51 | let token = | 54 | let token = |
52 | original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; | 55 | original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; |
53 | let analyzer = | 56 | let analyzer = |