diff options
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r-- | crates/ra_analysis/src/completion.rs | 31 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 74 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 52 | ||||
-rw-r--r-- | crates/ra_analysis/src/mock_analysis.rs | 9 |
4 files changed, 69 insertions, 97 deletions
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs index 766df1d96..7c3476e5c 100644 --- a/crates/ra_analysis/src/completion.rs +++ b/crates/ra_analysis/src/completion.rs | |||
@@ -14,7 +14,7 @@ use crate::{ | |||
14 | descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource}, | 14 | descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource}, |
15 | descriptors::DescriptorDatabase, | 15 | descriptors::DescriptorDatabase, |
16 | input::FilesDatabase, | 16 | input::FilesDatabase, |
17 | Cancelable, FileId, | 17 | Cancelable, FilePosition, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | #[derive(Debug)] | 20 | #[derive(Debug)] |
@@ -29,21 +29,21 @@ pub struct CompletionItem { | |||
29 | 29 | ||
30 | pub(crate) fn resolve_based_completion( | 30 | pub(crate) fn resolve_based_completion( |
31 | db: &db::RootDatabase, | 31 | db: &db::RootDatabase, |
32 | file_id: FileId, | 32 | position: FilePosition, |
33 | offset: TextUnit, | ||
34 | ) -> Cancelable<Option<Vec<CompletionItem>>> { | 33 | ) -> Cancelable<Option<Vec<CompletionItem>>> { |
35 | let source_root_id = db.file_source_root(file_id); | 34 | let source_root_id = db.file_source_root(position.file_id); |
36 | let file = db.file_syntax(file_id); | 35 | let file = db.file_syntax(position.file_id); |
37 | let module_tree = db.module_tree(source_root_id)?; | 36 | let module_tree = db.module_tree(source_root_id)?; |
38 | let module_id = match module_tree.any_module_for_source(ModuleSource::File(file_id)) { | 37 | let module_id = match module_tree.any_module_for_source(ModuleSource::File(position.file_id)) { |
39 | None => return Ok(None), | 38 | None => return Ok(None), |
40 | Some(it) => it, | 39 | Some(it) => it, |
41 | }; | 40 | }; |
42 | let file = { | 41 | let file = { |
43 | let edit = AtomEdit::insert(offset, "intellijRulezz".to_string()); | 42 | let edit = AtomEdit::insert(position.offset, "intellijRulezz".to_string()); |
44 | file.reparse(&edit) | 43 | file.reparse(&edit) |
45 | }; | 44 | }; |
46 | let target_module_id = match find_target_module(&module_tree, module_id, &file, offset) { | 45 | let target_module_id = match find_target_module(&module_tree, module_id, &file, position.offset) |
46 | { | ||
47 | None => return Ok(None), | 47 | None => return Ok(None), |
48 | Some(it) => it, | 48 | Some(it) => it, |
49 | }; | 49 | }; |
@@ -99,18 +99,17 @@ fn crate_path(name_ref: ast::NameRef) -> Option<Vec<ast::NameRef>> { | |||
99 | 99 | ||
100 | pub(crate) fn scope_completion( | 100 | pub(crate) fn scope_completion( |
101 | db: &db::RootDatabase, | 101 | db: &db::RootDatabase, |
102 | file_id: FileId, | 102 | position: FilePosition, |
103 | offset: TextUnit, | ||
104 | ) -> Option<Vec<CompletionItem>> { | 103 | ) -> Option<Vec<CompletionItem>> { |
105 | let original_file = db.file_syntax(file_id); | 104 | let original_file = db.file_syntax(position.file_id); |
106 | // Insert a fake ident to get a valid parse tree | 105 | // Insert a fake ident to get a valid parse tree |
107 | let file = { | 106 | let file = { |
108 | let edit = AtomEdit::insert(offset, "intellijRulezz".to_string()); | 107 | let edit = AtomEdit::insert(position.offset, "intellijRulezz".to_string()); |
109 | original_file.reparse(&edit) | 108 | original_file.reparse(&edit) |
110 | }; | 109 | }; |
111 | let mut has_completions = false; | 110 | let mut has_completions = false; |
112 | let mut res = Vec::new(); | 111 | let mut res = Vec::new(); |
113 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), offset) { | 112 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { |
114 | has_completions = true; | 113 | has_completions = true; |
115 | complete_name_ref(&file, name_ref, &mut res); | 114 | complete_name_ref(&file, name_ref, &mut res); |
116 | // special case, `trait T { fn foo(i_am_a_name_ref) {} }` | 115 | // special case, `trait T { fn foo(i_am_a_name_ref) {} }` |
@@ -129,7 +128,7 @@ pub(crate) fn scope_completion( | |||
129 | _ => (), | 128 | _ => (), |
130 | } | 129 | } |
131 | } | 130 | } |
132 | if let Some(name) = find_node_at_offset::<ast::Name>(file.syntax(), offset) { | 131 | if let Some(name) = find_node_at_offset::<ast::Name>(file.syntax(), position.offset) { |
133 | if is_node::<ast::Param>(name.syntax()) { | 132 | if is_node::<ast::Param>(name.syntax()) { |
134 | has_completions = true; | 133 | has_completions = true; |
135 | param_completions(name.syntax(), &mut res); | 134 | param_completions(name.syntax(), &mut res); |
@@ -383,7 +382,7 @@ mod tests { | |||
383 | 382 | ||
384 | fn check_scope_completion(code: &str, expected_completions: &str) { | 383 | fn check_scope_completion(code: &str, expected_completions: &str) { |
385 | let (analysis, position) = single_file_with_position(code); | 384 | let (analysis, position) = single_file_with_position(code); |
386 | let completions = scope_completion(&analysis.imp.db, position.file_id, position.offset) | 385 | let completions = scope_completion(&analysis.imp.db, position) |
387 | .unwrap() | 386 | .unwrap() |
388 | .into_iter() | 387 | .into_iter() |
389 | .filter(|c| c.snippet.is_none()) | 388 | .filter(|c| c.snippet.is_none()) |
@@ -393,7 +392,7 @@ mod tests { | |||
393 | 392 | ||
394 | fn check_snippet_completion(code: &str, expected_completions: &str) { | 393 | fn check_snippet_completion(code: &str, expected_completions: &str) { |
395 | let (analysis, position) = single_file_with_position(code); | 394 | let (analysis, position) = single_file_with_position(code); |
396 | let completions = scope_completion(&analysis.imp.db, position.file_id, position.offset) | 395 | let completions = scope_completion(&analysis.imp.db, position) |
397 | .unwrap() | 396 | .unwrap() |
398 | .into_iter() | 397 | .into_iter() |
399 | .filter(|c| c.snippet.is_some()) | 398 | .filter(|c| c.snippet.is_some()) |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 86d9cecd2..f2482559f 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -220,16 +220,13 @@ impl AnalysisImpl { | |||
220 | let source_root = self.db.file_source_root(file_id); | 220 | let source_root = self.db.file_source_root(file_id); |
221 | self.db.module_tree(source_root) | 221 | self.db.module_tree(source_root) |
222 | } | 222 | } |
223 | pub fn parent_module( | 223 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
224 | &self, | 224 | let module_tree = self.module_tree(position.file_id)?; |
225 | file_id: FileId, | 225 | let file = self.db.file_syntax(position.file_id); |
226 | offset: TextUnit, | 226 | let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) |
227 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 227 | { |
228 | let module_tree = self.module_tree(file_id)?; | 228 | Some(m) if !m.has_semi() => ModuleSource::new_inline(position.file_id, m), |
229 | let file = self.db.file_syntax(file_id); | 229 | _ => ModuleSource::File(position.file_id), |
230 | let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), offset) { | ||
231 | Some(m) if !m.has_semi() => ModuleSource::new_inline(file_id, m), | ||
232 | _ => ModuleSource::File(file_id), | ||
233 | }; | 230 | }; |
234 | 231 | ||
235 | let res = module_tree | 232 | let res = module_tree |
@@ -269,18 +266,14 @@ impl AnalysisImpl { | |||
269 | pub fn crate_root(&self, crate_id: CrateId) -> FileId { | 266 | pub fn crate_root(&self, crate_id: CrateId) -> FileId { |
270 | self.db.crate_graph().crate_roots[&crate_id] | 267 | self.db.crate_graph().crate_roots[&crate_id] |
271 | } | 268 | } |
272 | pub fn completions( | 269 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { |
273 | &self, | ||
274 | file_id: FileId, | ||
275 | offset: TextUnit, | ||
276 | ) -> Cancelable<Option<Vec<CompletionItem>>> { | ||
277 | let mut res = Vec::new(); | 270 | let mut res = Vec::new(); |
278 | let mut has_completions = false; | 271 | let mut has_completions = false; |
279 | if let Some(scope_based) = scope_completion(&self.db, file_id, offset) { | 272 | if let Some(scope_based) = scope_completion(&self.db, position) { |
280 | res.extend(scope_based); | 273 | res.extend(scope_based); |
281 | has_completions = true; | 274 | has_completions = true; |
282 | } | 275 | } |
283 | if let Some(scope_based) = resolve_based_completion(&self.db, file_id, offset)? { | 276 | if let Some(scope_based) = resolve_based_completion(&self.db, position)? { |
284 | res.extend(scope_based); | 277 | res.extend(scope_based); |
285 | has_completions = true; | 278 | has_completions = true; |
286 | } | 279 | } |
@@ -289,18 +282,19 @@ impl AnalysisImpl { | |||
289 | } | 282 | } |
290 | pub fn approximately_resolve_symbol( | 283 | pub fn approximately_resolve_symbol( |
291 | &self, | 284 | &self, |
292 | file_id: FileId, | 285 | position: FilePosition, |
293 | offset: TextUnit, | ||
294 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 286 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
295 | let module_tree = self.module_tree(file_id)?; | 287 | let module_tree = self.module_tree(position.file_id)?; |
296 | let file = self.db.file_syntax(file_id); | 288 | let file = self.db.file_syntax(position.file_id); |
297 | let syntax = file.syntax(); | 289 | let syntax = file.syntax(); |
298 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { | 290 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { |
299 | // First try to resolve the symbol locally | 291 | // First try to resolve the symbol locally |
300 | return if let Some((name, range)) = resolve_local_name(&self.db, file_id, name_ref) { | 292 | return if let Some((name, range)) = |
293 | resolve_local_name(&self.db, position.file_id, name_ref) | ||
294 | { | ||
301 | let mut vec = vec![]; | 295 | let mut vec = vec![]; |
302 | vec.push(( | 296 | vec.push(( |
303 | file_id, | 297 | position.file_id, |
304 | FileSymbol { | 298 | FileSymbol { |
305 | name, | 299 | name, |
306 | node_range: range, | 300 | node_range: range, |
@@ -313,10 +307,10 @@ impl AnalysisImpl { | |||
313 | self.index_resolve(name_ref) | 307 | self.index_resolve(name_ref) |
314 | }; | 308 | }; |
315 | } | 309 | } |
316 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, offset) { | 310 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { |
317 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | 311 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { |
318 | if module.has_semi() { | 312 | if module.has_semi() { |
319 | let file_ids = self.resolve_module(&*module_tree, file_id, module); | 313 | let file_ids = self.resolve_module(&*module_tree, position.file_id, module); |
320 | 314 | ||
321 | let res = file_ids | 315 | let res = file_ids |
322 | .into_iter() | 316 | .into_iter() |
@@ -341,16 +335,17 @@ impl AnalysisImpl { | |||
341 | Ok(vec![]) | 335 | Ok(vec![]) |
342 | } | 336 | } |
343 | 337 | ||
344 | pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { | 338 | pub fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> { |
345 | let file = self.db.file_syntax(file_id); | 339 | let file = self.db.file_syntax(position.file_id); |
346 | let syntax = file.syntax(); | 340 | let syntax = file.syntax(); |
347 | 341 | ||
348 | // Find the binding associated with the offset | 342 | // Find the binding associated with the offset |
349 | let maybe_binding = find_node_at_offset::<ast::BindPat>(syntax, offset).or_else(|| { | 343 | let maybe_binding = |
350 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, offset)?; | 344 | find_node_at_offset::<ast::BindPat>(syntax, position.offset).or_else(|| { |
351 | let resolved = resolve_local_name(&self.db, file_id, name_ref)?; | 345 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, position.offset)?; |
352 | find_node_at_offset::<ast::BindPat>(syntax, resolved.1.end()) | 346 | let resolved = resolve_local_name(&self.db, position.file_id, name_ref)?; |
353 | }); | 347 | find_node_at_offset::<ast::BindPat>(syntax, resolved.1.end()) |
348 | }); | ||
354 | 349 | ||
355 | let binding = match maybe_binding { | 350 | let binding = match maybe_binding { |
356 | None => return Vec::new(), | 351 | None => return Vec::new(), |
@@ -359,11 +354,11 @@ impl AnalysisImpl { | |||
359 | 354 | ||
360 | let decl = DeclarationDescriptor::new(binding); | 355 | let decl = DeclarationDescriptor::new(binding); |
361 | 356 | ||
362 | let mut ret = vec![(file_id, decl.range)]; | 357 | let mut ret = vec![(position.file_id, decl.range)]; |
363 | ret.extend( | 358 | ret.extend( |
364 | decl.find_all_refs() | 359 | decl.find_all_refs() |
365 | .into_iter() | 360 | .into_iter() |
366 | .map(|ref_desc| (file_id, ref_desc.range)), | 361 | .map(|ref_desc| (position.file_id, ref_desc.range)), |
367 | ); | 362 | ); |
368 | 363 | ||
369 | ret | 364 | ret |
@@ -457,14 +452,13 @@ impl AnalysisImpl { | |||
457 | 452 | ||
458 | pub fn resolve_callable( | 453 | pub fn resolve_callable( |
459 | &self, | 454 | &self, |
460 | file_id: FileId, | 455 | position: FilePosition, |
461 | offset: TextUnit, | ||
462 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { | 456 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { |
463 | let file = self.db.file_syntax(file_id); | 457 | let file = self.db.file_syntax(position.file_id); |
464 | let syntax = file.syntax(); | 458 | let syntax = file.syntax(); |
465 | 459 | ||
466 | // Find the calling expression and it's NameRef | 460 | // Find the calling expression and it's NameRef |
467 | let calling_node = match FnCallNode::with_node(syntax, offset) { | 461 | let calling_node = match FnCallNode::with_node(syntax, position.offset) { |
468 | Some(node) => node, | 462 | Some(node) => node, |
469 | None => return Ok(None), | 463 | None => return Ok(None), |
470 | }; | 464 | }; |
@@ -499,7 +493,7 @@ impl AnalysisImpl { | |||
499 | if let Some(ref arg_list) = calling_node.arg_list() { | 493 | if let Some(ref arg_list) = calling_node.arg_list() { |
500 | let start = arg_list.syntax().range().start(); | 494 | let start = arg_list.syntax().range().start(); |
501 | 495 | ||
502 | let range_search = TextRange::from_to(start, offset); | 496 | let range_search = TextRange::from_to(start, position.offset); |
503 | let mut commas: usize = arg_list | 497 | let mut commas: usize = arg_list |
504 | .syntax() | 498 | .syntax() |
505 | .text() | 499 | .text() |
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 | ||
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs index a7134a0e6..8e8f969f4 100644 --- a/crates/ra_analysis/src/mock_analysis.rs +++ b/crates/ra_analysis/src/mock_analysis.rs | |||
@@ -1,16 +1,9 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::TextUnit; | ||
4 | use relative_path::{RelativePath, RelativePathBuf}; | 3 | use relative_path::{RelativePath, RelativePathBuf}; |
5 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; | 4 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; |
6 | 5 | ||
7 | use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FileResolver}; | 6 | use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FileResolver, FilePosition}; |
8 | |||
9 | #[derive(Debug)] | ||
10 | pub struct FilePosition { | ||
11 | pub file_id: FileId, | ||
12 | pub offset: TextUnit, | ||
13 | } | ||
14 | 7 | ||
15 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis | 8 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis |
16 | /// from a set of in-memory files. | 9 | /// from a set of in-memory files. |