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 } ;
2
2
3
3
#[ derive( Debug ) ]
4
4
pub ( crate ) enum CompletionRelevanceData < ' a > {
@@ -33,6 +33,7 @@ impl<'a> CompletionRelevance<'a> {
33
33
self . check_matches_query_input ( ctx) ;
34
34
self . check_if_catalog ( ctx) ;
35
35
self . check_is_invocation ( ctx) ;
36
+ self . check_matching_clause_type ( ctx) ;
36
37
37
38
self . score
38
39
}
@@ -60,6 +61,27 @@ impl<'a> CompletionRelevance<'a> {
60
61
} ;
61
62
}
62
63
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
+
63
85
fn check_is_invocation ( & mut self , ctx : & CompletionContext ) {
64
86
self . score += match self . data {
65
87
CompletionRelevanceData :: Function ( _) => {
You can’t perform that action at this time.
0 commit comments