Skip to main content

Crate dsl_completion

Crate dsl_completion 

Source
Expand description

Context-aware SQL completion engine.

Public entry point is complete: given the source text, parsed statements, resolved scopes, catalog snapshot, and cursor offset, it returns a flat list of Items. The LSP server crate maps each Item onto an LSP CompletionItem; using a plain struct here keeps this crate free of LSP wire dependencies and unit-testable in milliseconds.

Re-exports§

pub use engine::complete;
pub use engine::complete_with_derived;
pub use item::Item;
pub use item::ItemKind;

Modules§

context
Detect what kinds of completion items make sense at the cursor.
contexts
Context-aware special completions.
create_index
CREATE INDEX sub-phase detector.
create_table
CREATE TABLE sub-phase analyzer.
detectors
Phase/context detector functions – one function per SQL sub-construct (CREATE X ... <cursor>, ALTER X ... <cursor>, slot predicates, item-pushing helpers). Extracted from engine.rs in one large batch (was inline there) – pure code motion, no behavior change. Deliberately not yet subdivided by statement family (CREATE vs ALTER vs …); that’s a lower-risk follow-up now that this code has no cross-file coupling left to worry about, only internal reorganization within one file.
engine
Completion engine.
fallback
Text-level fallback scope builder.
item
Crate-local representation of one completion entry.
json_path
JSON key completion for col->'<cursor>' / col->>'<cursor>' chains.
merge
MERGE statement completion.
phase
Phase-aware completion context.
plpgsql_locals
Extract PL/pgSQL function parameters and DECLARE’d locals from the buffer text so completion can surface them inside a function body.
render
Markdown renderers for table and column completion items.
source_tables
Build a synthetic catalog from CREATE TABLE statements in the current file (and a few text-scanned object families) so completion / hover / validation work even offline – before the DB knows about anything, or when there is no DB connection configured at all.
sources
Item producers, one per kind of source data.