unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.LSP.Completion

Synopsis

Documentation

completionHandler :: TRequestMessage 'Method_TextDocumentCompletion -> (Either ResponseError (MessageResult 'Method_TextDocumentCompletion) -> Lsp ()) -> Lsp () Source #

completionItemResolveHandler :: TRequestMessage 'Method_CompletionItemResolve -> (Either ResponseError CompletionItem -> Lsp ()) -> Lsp () Source #

Called to resolve additional details for a completion item that the user is considering.

namesToCompletionTree :: Names -> CompletionTree Source #

Generate a completion tree from a set of names. A completion tree is a suffix tree over the path segments of each name it contains. The goal is to allow fast completion of names by any partial path suffix.

The tree is generated by building a trie where all possible suffixes of a name are reachable from the root of the trie, with sharing over subtrees to improve memory residency.

Currently we don't "summarize" all of the children of a node in the node itself, and instead you have to crawl all the children to get the actual completions.

TODO: Would it be worthwhile to perform compression or include child summaries on the suffix tree? I suspect most namespace trees won't actually compress very well since each node is likely to have terms/types at it.

E.g. From the names: * alpha.beta.Nat * alpha.Text * foxtrot.Text

It will generate a tree like the following, where each bullet is a possible completion:

. ├── foxtrot │   └── Text │   └── * foxtrot.Text (##Text) ├── beta │   └── Nat │   └── * alpha.beta.Nat (##Nat) ├── alpha │   ├── beta │   │   └── Nat │   │   └── * alpha.beta.Nat (##Nat) │   └── Text │   └── * alpha.Text (##Text) ├── Text │   ├── * foxtrot.Text (##Text) │   └── * alpha.Text (##Text) └── Nat └── * alpha.beta.Nat (##Nat)