aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/lib.rs')
-rw-r--r--crates/ra_ide_api/src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 95de9bcb8..9f3b18d9d 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -326,7 +326,7 @@ impl Analysis {
326 326
327 /// Gets the syntax tree of the file. 327 /// Gets the syntax tree of the file.
328 pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> { 328 pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> {
329 self.db.parse(file_id).tree 329 self.db.parse(file_id).tree().to_owned()
330 } 330 }
331 331
332 /// Gets the file's `LineIndex`: data structure to convert between absolute 332 /// Gets the file's `LineIndex`: data structure to convert between absolute
@@ -343,7 +343,8 @@ impl Analysis {
343 /// Returns position of the matching brace (all types of braces are 343 /// Returns position of the matching brace (all types of braces are
344 /// supported). 344 /// supported).
345 pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> { 345 pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> {
346 let file = self.db.parse(position.file_id).tree; 346 let parse = self.db.parse(position.file_id);
347 let file = parse.tree();
347 matching_brace::matching_brace(&file, position.offset) 348 matching_brace::matching_brace(&file, position.offset)
348 } 349 }
349 350
@@ -356,10 +357,10 @@ impl Analysis {
356 /// Returns an edit to remove all newlines in the range, cleaning up minor 357 /// Returns an edit to remove all newlines in the range, cleaning up minor
357 /// stuff like trailing commas. 358 /// stuff like trailing commas.
358 pub fn join_lines(&self, frange: FileRange) -> SourceChange { 359 pub fn join_lines(&self, frange: FileRange) -> SourceChange {
359 let file = self.db.parse(frange.file_id).tree; 360 let parse = self.db.parse(frange.file_id);
360 let file_edit = SourceFileEdit { 361 let file_edit = SourceFileEdit {
361 file_id: frange.file_id, 362 file_id: frange.file_id,
362 edit: join_lines::join_lines(&file, frange.range), 363 edit: join_lines::join_lines(parse.tree(), frange.range),
363 }; 364 };
364 SourceChange::source_file_edit("join lines", file_edit) 365 SourceChange::source_file_edit("join lines", file_edit)
365 } 366 }
@@ -374,7 +375,8 @@ impl Analysis {
374 /// this works when adding `let =`. 375 /// this works when adding `let =`.
375 // FIXME: use a snippet completion instead of this hack here. 376 // FIXME: use a snippet completion instead of this hack here.
376 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { 377 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
377 let file = self.db.parse(position.file_id).tree; 378 let parse = self.db.parse(position.file_id);
379 let file = parse.tree();
378 let edit = typing::on_eq_typed(&file, position.offset)?; 380 let edit = typing::on_eq_typed(&file, position.offset)?;
379 Some(SourceChange::source_file_edit( 381 Some(SourceChange::source_file_edit(
380 "add semicolon", 382 "add semicolon",
@@ -390,14 +392,14 @@ impl Analysis {
390 /// Returns a tree representation of symbols in the file. Useful to draw a 392 /// Returns a tree representation of symbols in the file. Useful to draw a
391 /// file outline. 393 /// file outline.
392 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { 394 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
393 let file = self.db.parse(file_id).tree; 395 let parse = self.db.parse(file_id);
394 file_structure(&file) 396 file_structure(parse.tree())
395 } 397 }
396 398
397 /// Returns the set of folding ranges. 399 /// Returns the set of folding ranges.
398 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { 400 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
399 let file = self.db.parse(file_id).tree; 401 let parse = self.db.parse(file_id);
400 folding_ranges::folding_ranges(&file) 402 folding_ranges::folding_ranges(parse.tree())
401 } 403 }
402 404
403 /// Fuzzy searches for a symbol. 405 /// Fuzzy searches for a symbol.