-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathcomplete.rs
34 lines (27 loc) · 882 Bytes
/
complete.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use pgt_text_size::TextSize;
use crate::{
builder::CompletionBuilder,
context::CompletionContext,
item::CompletionItem,
providers::{complete_columns, complete_functions, complete_tables},
};
pub const LIMIT: usize = 50;
#[derive(Debug)]
pub struct CompletionParams<'a> {
pub position: TextSize,
pub schema: &'a pgt_schema_cache::SchemaCache,
pub text: String,
pub tree: Option<&'a tree_sitter::Tree>,
}
#[tracing::instrument(level = "debug", skip_all, fields(
text = params.text,
position = params.position.to_string()
))]
pub fn complete(params: CompletionParams) -> Vec<CompletionItem> {
let ctx = CompletionContext::new(¶ms);
let mut builder = CompletionBuilder::new();
complete_tables(&ctx, &mut builder);
complete_functions(&ctx, &mut builder);
complete_columns(&ctx, &mut builder);
builder.finish()
}