diff options
author | Aleksey Kladov <[email protected]> | 2018-09-05 22:59:07 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-05 22:59:07 +0100 |
commit | bb64edf8babe617ca6219e53520ce87a2dd00769 (patch) | |
tree | ba9c8d5866cd7687a07223f91c1ccdf97cb234c3 /crates/libanalysis | |
parent | 47e8b80e9b67d5012fbc860a7763975e99fdf28d (diff) |
introduce variable
Diffstat (limited to 'crates/libanalysis')
-rw-r--r-- | crates/libanalysis/src/imp.rs | 4 | ||||
-rw-r--r-- | crates/libanalysis/src/lib.rs | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs index e3ccffbf0..47b0d79ff 100644 --- a/crates/libanalysis/src/imp.rs +++ b/crates/libanalysis/src/imp.rs | |||
@@ -256,12 +256,14 @@ impl AnalysisImpl { | |||
256 | res | 256 | res |
257 | } | 257 | } |
258 | 258 | ||
259 | pub fn assists(&self, file_id: FileId, offset: TextUnit) -> Vec<SourceChange> { | 259 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { |
260 | let file = self.file_syntax(file_id); | 260 | let file = self.file_syntax(file_id); |
261 | let offset = range.start(); | ||
261 | let actions = vec![ | 262 | let actions = vec![ |
262 | ("flip comma", libeditor::flip_comma(&file, offset).map(|f| f())), | 263 | ("flip comma", libeditor::flip_comma(&file, offset).map(|f| f())), |
263 | ("add `#[derive]`", libeditor::add_derive(&file, offset).map(|f| f())), | 264 | ("add `#[derive]`", libeditor::add_derive(&file, offset).map(|f| f())), |
264 | ("add impl", libeditor::add_impl(&file, offset).map(|f| f())), | 265 | ("add impl", libeditor::add_impl(&file, offset).map(|f| f())), |
266 | ("introduce variable", libeditor::introduce_variable(&file, range).map(|f| f())), | ||
265 | ]; | 267 | ]; |
266 | actions.into_iter() | 268 | actions.into_iter() |
267 | .filter_map(|(name, local_edit)| { | 269 | .filter_map(|(name, local_edit)| { |
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index a8152939b..4e63813f9 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -209,8 +209,8 @@ impl Analysis { | |||
209 | let file = self.file_syntax(file_id); | 209 | let file = self.file_syntax(file_id); |
210 | libeditor::scope_completion(&file, offset) | 210 | libeditor::scope_completion(&file, offset) |
211 | } | 211 | } |
212 | pub fn assists(&self, file_id: FileId, offset: TextUnit) -> Vec<SourceChange> { | 212 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { |
213 | self.imp.assists(file_id, offset) | 213 | self.imp.assists(file_id, range) |
214 | } | 214 | } |
215 | pub fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { | 215 | pub fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { |
216 | self.imp.diagnostics(file_id) | 216 | self.imp.diagnostics(file_id) |