File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
crates/pg_completions/src Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1- use crate :: context:: CompletionContext ;
1+ use crate :: context:: { ClauseType , CompletionContext } ;
22
33#[ derive( Debug ) ]
44pub ( crate ) enum CompletionRelevanceData < ' a > {
@@ -33,6 +33,7 @@ impl<'a> CompletionRelevance<'a> {
3333 self . check_matches_query_input ( ctx) ;
3434 self . check_if_catalog ( ctx) ;
3535 self . check_is_invocation ( ctx) ;
36+ self . check_matching_clause_type ( ctx) ;
3637
3738 self . score
3839 }
@@ -60,6 +61,27 @@ impl<'a> CompletionRelevance<'a> {
6061 } ;
6162 }
6263
64+ fn check_matching_clause_type ( & mut self , ctx : & CompletionContext ) {
65+ let clause_type = match ctx. wrapping_clause_type . as_ref ( ) {
66+ None => return ,
67+ Some ( ct) => ct,
68+ } ;
69+
70+ self . score += match self . data {
71+ CompletionRelevanceData :: Table ( _) => match clause_type {
72+ ClauseType :: From => 5 ,
73+ ClauseType :: Update => 15 ,
74+ ClauseType :: Delete => 15 ,
75+ _ => -50 ,
76+ } ,
77+ CompletionRelevanceData :: Function ( _) => match clause_type {
78+ ClauseType :: Select => 5 ,
79+ ClauseType :: From => 0 ,
80+ _ => -50 ,
81+ } ,
82+ }
83+ }
84+
6385 fn check_is_invocation ( & mut self , ctx : & CompletionContext ) {
6486 self . score += match self . data {
6587 CompletionRelevanceData :: Function ( _) => {
You can’t perform that action at this time.
0 commit comments