diff options
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 3bbe61917..0ea9ebee7 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -119,7 +119,7 @@ impl AnalysisHost { | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | #[derive(Debug)] | 122 | #[derive(Clone, Copy, Debug)] |
123 | pub struct FilePosition { | 123 | pub struct FilePosition { |
124 | pub file_id: FileId, | 124 | pub file_id: FileId, |
125 | pub offset: TextUnit, | 125 | pub offset: TextUnit, |
@@ -224,18 +224,18 @@ impl Analysis { | |||
224 | let file = self.imp.file_syntax(file_id); | 224 | let file = self.imp.file_syntax(file_id); |
225 | SourceChange::from_local_edit(file_id, "join lines", ra_editor::join_lines(&file, range)) | 225 | SourceChange::from_local_edit(file_id, "join lines", ra_editor::join_lines(&file, range)) |
226 | } | 226 | } |
227 | pub fn on_enter(&self, file_id: FileId, offset: TextUnit) -> Option<SourceChange> { | 227 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { |
228 | let file = self.imp.file_syntax(file_id); | 228 | let file = self.imp.file_syntax(position.file_id); |
229 | let edit = ra_editor::on_enter(&file, offset)?; | 229 | let edit = ra_editor::on_enter(&file, position.offset)?; |
230 | let res = SourceChange::from_local_edit(file_id, "on enter", edit); | 230 | let res = SourceChange::from_local_edit(position.file_id, "on enter", edit); |
231 | Some(res) | 231 | Some(res) |
232 | } | 232 | } |
233 | pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option<SourceChange> { | 233 | pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { |
234 | let file = self.imp.file_syntax(file_id); | 234 | let file = self.imp.file_syntax(position.file_id); |
235 | Some(SourceChange::from_local_edit( | 235 | Some(SourceChange::from_local_edit( |
236 | file_id, | 236 | position.file_id, |
237 | "add semicolon", | 237 | "add semicolon", |
238 | ra_editor::on_eq_typed(&file, offset)?, | 238 | ra_editor::on_eq_typed(&file, position.offset)?, |
239 | )) | 239 | )) |
240 | } | 240 | } |
241 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { | 241 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { |
@@ -251,24 +251,15 @@ impl Analysis { | |||
251 | } | 251 | } |
252 | pub fn approximately_resolve_symbol( | 252 | pub fn approximately_resolve_symbol( |
253 | &self, | 253 | &self, |
254 | file_id: FileId, | 254 | position: FilePosition, |
255 | offset: TextUnit, | ||
256 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 255 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
257 | self.imp.approximately_resolve_symbol(file_id, offset) | 256 | self.imp.approximately_resolve_symbol(position) |
258 | } | 257 | } |
259 | pub fn find_all_refs( | 258 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |
260 | &self, | 259 | Ok(self.imp.find_all_refs(position)) |
261 | file_id: FileId, | ||
262 | offset: TextUnit, | ||
263 | ) -> Cancelable<Vec<(FileId, TextRange)>> { | ||
264 | Ok(self.imp.find_all_refs(file_id, offset)) | ||
265 | } | 260 | } |
266 | pub fn parent_module( | 261 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
267 | &self, | 262 | self.imp.parent_module(position) |
268 | file_id: FileId, | ||
269 | offset: TextUnit, | ||
270 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | ||
271 | self.imp.parent_module(file_id, offset) | ||
272 | } | 263 | } |
273 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { | 264 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { |
274 | self.imp.crate_for(file_id) | 265 | self.imp.crate_for(file_id) |
@@ -284,12 +275,8 @@ impl Analysis { | |||
284 | let file = self.imp.file_syntax(file_id); | 275 | let file = self.imp.file_syntax(file_id); |
285 | Ok(ra_editor::highlight(&file)) | 276 | Ok(ra_editor::highlight(&file)) |
286 | } | 277 | } |
287 | pub fn completions( | 278 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { |
288 | &self, | 279 | self.imp.completions(position) |
289 | file_id: FileId, | ||
290 | offset: TextUnit, | ||
291 | ) -> Cancelable<Option<Vec<CompletionItem>>> { | ||
292 | self.imp.completions(file_id, offset) | ||
293 | } | 280 | } |
294 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Cancelable<Vec<SourceChange>> { | 281 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Cancelable<Vec<SourceChange>> { |
295 | Ok(self.imp.assists(file_id, range)) | 282 | Ok(self.imp.assists(file_id, range)) |
@@ -299,10 +286,9 @@ impl Analysis { | |||
299 | } | 286 | } |
300 | pub fn resolve_callable( | 287 | pub fn resolve_callable( |
301 | &self, | 288 | &self, |
302 | file_id: FileId, | 289 | position: FilePosition, |
303 | offset: TextUnit, | ||
304 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { | 290 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { |
305 | self.imp.resolve_callable(file_id, offset) | 291 | self.imp.resolve_callable(position) |
306 | } | 292 | } |
307 | } | 293 | } |
308 | 294 | ||