@@ -50,7 +50,7 @@ impl TryFrom<String> for ClauseType {
50
50
51
51
pub ( crate ) struct CompletionContext < ' a > {
52
52
pub ts_node : Option < tree_sitter:: Node < ' a > > ,
53
- pub tree : Option < & ' a tree_sitter:: Tree > ,
53
+ pub tree : & ' a tree_sitter:: Tree ,
54
54
pub text : & ' a str ,
55
55
pub schema_cache : & ' a SchemaCache ,
56
56
pub position : usize ,
@@ -85,10 +85,7 @@ impl<'a> CompletionContext<'a> {
85
85
}
86
86
87
87
fn gather_info_from_ts_queries ( & mut self ) {
88
- let tree = match self . tree . as_ref ( ) {
89
- None => return ,
90
- Some ( t) => t,
91
- } ;
88
+ let tree = self . tree ;
92
89
93
90
let stmt_range = self . wrapping_statement_range . as_ref ( ) ;
94
91
let sql = self . text ;
@@ -126,11 +123,7 @@ impl<'a> CompletionContext<'a> {
126
123
}
127
124
128
125
fn gather_tree_context ( & mut self ) {
129
- if self . tree . is_none ( ) {
130
- return ;
131
- }
132
-
133
- let mut cursor = self . tree . as_ref ( ) . unwrap ( ) . root_node ( ) . walk ( ) ;
126
+ let mut cursor = self . tree . root_node ( ) . walk ( ) ;
134
127
135
128
/*
136
129
* The head node of any treesitter tree is always the "PROGRAM" node.
@@ -262,7 +255,7 @@ mod tests {
262
255
let params = crate :: CompletionParams {
263
256
position : ( position as u32 ) . into ( ) ,
264
257
text,
265
- tree : Some ( & tree) ,
258
+ tree : & tree,
266
259
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
267
260
} ;
268
261
@@ -294,7 +287,7 @@ mod tests {
294
287
let params = crate :: CompletionParams {
295
288
position : ( position as u32 ) . into ( ) ,
296
289
text,
297
- tree : Some ( & tree) ,
290
+ tree : & tree,
298
291
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
299
292
} ;
300
293
@@ -328,7 +321,7 @@ mod tests {
328
321
let params = crate :: CompletionParams {
329
322
position : ( position as u32 ) . into ( ) ,
330
323
text,
331
- tree : Some ( & tree) ,
324
+ tree : & tree,
332
325
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
333
326
} ;
334
327
@@ -353,7 +346,7 @@ mod tests {
353
346
let params = crate :: CompletionParams {
354
347
position : ( position as u32 ) . into ( ) ,
355
348
text,
356
- tree : Some ( & tree) ,
349
+ tree : & tree,
357
350
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
358
351
} ;
359
352
@@ -381,7 +374,7 @@ mod tests {
381
374
let params = crate :: CompletionParams {
382
375
position : ( position as u32 ) . into ( ) ,
383
376
text,
384
- tree : Some ( & tree) ,
377
+ tree : & tree,
385
378
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
386
379
} ;
387
380
@@ -407,7 +400,7 @@ mod tests {
407
400
let params = crate :: CompletionParams {
408
401
position : ( position as u32 ) . into ( ) ,
409
402
text,
410
- tree : Some ( & tree) ,
403
+ tree : & tree,
411
404
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
412
405
} ;
413
406
@@ -432,7 +425,7 @@ mod tests {
432
425
let params = crate :: CompletionParams {
433
426
position : ( position as u32 ) . into ( ) ,
434
427
text,
435
- tree : Some ( & tree) ,
428
+ tree : & tree,
436
429
schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
437
430
} ;
438
431
0 commit comments