@@ -326,7 +326,7 @@ impl Analysis {
326
326
327
327
/// Gets the syntax tree of the file.
328
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
332
/// Gets the file's `LineIndex`: data structure to convert between absolute
@@ -343,7 +343,8 @@ impl Analysis {
343
343
/// Returns position of the matching brace (all types of braces are
344
344
/// supported).
345
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
348
matching_brace:: matching_brace ( & file, position. offset )
348
349
}
349
350
@@ -356,10 +357,10 @@ impl Analysis {
356
357
/// Returns an edit to remove all newlines in the range, cleaning up minor
357
358
/// stuff like trailing commas.
358
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
361
let file_edit = SourceFileEdit {
361
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
365
SourceChange :: source_file_edit ( "join lines" , file_edit)
365
366
}
@@ -374,7 +375,8 @@ impl Analysis {
374
375
/// this works when adding `let =`.
375
376
// FIXME: use a snippet completion instead of this hack here.
376
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
380
let edit = typing:: on_eq_typed ( & file, position. offset ) ?;
379
381
Some ( SourceChange :: source_file_edit (
380
382
"add semicolon" ,
@@ -390,14 +392,14 @@ impl Analysis {
390
392
/// Returns a tree representation of symbols in the file. Useful to draw a
391
393
/// file outline.
392
394
pub fn file_structure ( & self , file_id : FileId ) -> Vec < StructureNode > {
393
- let file = self . db . parse ( file_id) . tree ;
394
- file_structure ( & file )
395
+ let parse = self . db . parse ( file_id) ;
396
+ file_structure ( parse . tree ( ) )
395
397
}
396
398
397
399
/// Returns the set of folding ranges.
398
400
pub fn folding_ranges ( & self , file_id : FileId ) -> Vec < Fold > {
399
- let file = self . db . parse ( file_id) . tree ;
400
- folding_ranges:: folding_ranges ( & file )
401
+ let parse = self . db . parse ( file_id) ;
402
+ folding_ranges:: folding_ranges ( parse . tree ( ) )
401
403
}
402
404
403
405
/// Fuzzy searches for a symbol.
0 commit comments