@@ -50,7 +50,7 @@ impl TryFrom<String> for ClauseType {
5050
5151pub ( crate ) struct CompletionContext < ' a > {
5252 pub ts_node : Option < tree_sitter:: Node < ' a > > ,
53- pub tree : Option < & ' a tree_sitter:: Tree > ,
53+ pub tree : & ' a tree_sitter:: Tree ,
5454 pub text : & ' a str ,
5555 pub schema_cache : & ' a SchemaCache ,
5656 pub position : usize ,
@@ -85,10 +85,7 @@ impl<'a> CompletionContext<'a> {
8585 }
8686
8787 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 ;
9289
9390 let stmt_range = self . wrapping_statement_range . as_ref ( ) ;
9491 let sql = self . text ;
@@ -126,11 +123,7 @@ impl<'a> CompletionContext<'a> {
126123 }
127124
128125 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 ( ) ;
134127
135128 /*
136129 * The head node of any treesitter tree is always the "PROGRAM" node.
@@ -262,7 +255,7 @@ mod tests {
262255 let params = crate :: CompletionParams {
263256 position : ( position as u32 ) . into ( ) ,
264257 text,
265- tree : Some ( & tree) ,
258+ tree : & tree,
266259 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
267260 } ;
268261
@@ -294,7 +287,7 @@ mod tests {
294287 let params = crate :: CompletionParams {
295288 position : ( position as u32 ) . into ( ) ,
296289 text,
297- tree : Some ( & tree) ,
290+ tree : & tree,
298291 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
299292 } ;
300293
@@ -328,7 +321,7 @@ mod tests {
328321 let params = crate :: CompletionParams {
329322 position : ( position as u32 ) . into ( ) ,
330323 text,
331- tree : Some ( & tree) ,
324+ tree : & tree,
332325 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
333326 } ;
334327
@@ -353,7 +346,7 @@ mod tests {
353346 let params = crate :: CompletionParams {
354347 position : ( position as u32 ) . into ( ) ,
355348 text,
356- tree : Some ( & tree) ,
349+ tree : & tree,
357350 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
358351 } ;
359352
@@ -381,7 +374,7 @@ mod tests {
381374 let params = crate :: CompletionParams {
382375 position : ( position as u32 ) . into ( ) ,
383376 text,
384- tree : Some ( & tree) ,
377+ tree : & tree,
385378 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
386379 } ;
387380
@@ -407,7 +400,7 @@ mod tests {
407400 let params = crate :: CompletionParams {
408401 position : ( position as u32 ) . into ( ) ,
409402 text,
410- tree : Some ( & tree) ,
403+ tree : & tree,
411404 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
412405 } ;
413406
@@ -432,7 +425,7 @@ mod tests {
432425 let params = crate :: CompletionParams {
433426 position : ( position as u32 ) . into ( ) ,
434427 text,
435- tree : Some ( & tree) ,
428+ tree : & tree,
436429 schema : & pgt_schema_cache:: SchemaCache :: default ( ) ,
437430 } ;
438431
0 commit comments