diff options
author | Edwin Cheng <[email protected]> | 2020-04-30 11:20:13 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-05-01 13:01:17 +0100 |
commit | bdcf6f56589f8367c8cc82f3f4f045dcaf53748d (patch) | |
tree | 805a0387fa06a0dd73b800cfd52a36a509a08bc2 /crates/ra_assists/src/assist_ctx.rs | |
parent | 1635d22a355b08309661e3d54d22c6bc2b53e5e1 (diff) |
Introduce LowerCtx for path lowering
Diffstat (limited to 'crates/ra_assists/src/assist_ctx.rs')
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index 2fe7c3de3..3155a469b 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | //! This module defines `AssistCtx` -- the API surface that is exposed to assists. | 1 | //! This module defines `AssistCtx` -- the API surface that is exposed to assists. |
2 | use hir::Semantics; | 2 | use hir::Semantics; |
3 | use ra_db::FileRange; | 3 | use ra_db::{FileRange, Upcast}; |
4 | use ra_fmt::{leading_indent, reindent}; | 4 | use ra_fmt::{leading_indent, reindent}; |
5 | use ra_ide_db::RootDatabase; | 5 | use ra_ide_db::RootDatabase; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | algo::{self, find_covering_element, find_node_at_offset}, | 7 | algo::{self, find_covering_element, find_node_at_offset}, |
8 | AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, | 8 | ast, AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, |
9 | TokenAtOffset, | 9 | TextSize, TokenAtOffset, |
10 | }; | 10 | }; |
11 | use ra_text_edit::TextEditBuilder; | 11 | use ra_text_edit::TextEditBuilder; |
12 | 12 | ||
@@ -136,6 +136,9 @@ impl<'a> AssistCtx<'a> { | |||
136 | pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement { | 136 | pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement { |
137 | find_covering_element(self.source_file.syntax(), range) | 137 | find_covering_element(self.source_file.syntax(), range) |
138 | } | 138 | } |
139 | pub(crate) fn lower_path(&self, path: ast::Path) -> Option<hir::Path> { | ||
140 | hir::Path::from_src(path, &hir::Hygiene::new(self.db.upcast(), self.frange.file_id.into())) | ||
141 | } | ||
139 | } | 142 | } |
140 | 143 | ||
141 | pub(crate) struct AssistGroup<'a> { | 144 | pub(crate) struct AssistGroup<'a> { |