mirror of
https://github.com/nushell/nushell.git
synced 2025-05-22 23:51:18 +00:00
* Specialize 'Context' to EvaluationContext and CompletionContext * Specialize 'Context' to EvaluationContext and CompletionContext * fmt
38 lines
803 B
Rust
38 lines
803 B
Rust
pub(crate) mod command;
|
|
pub(crate) mod engine;
|
|
pub(crate) mod flag;
|
|
pub(crate) mod matchers;
|
|
pub(crate) mod path;
|
|
|
|
use crate::evaluation_context::EvaluationContext;
|
|
use matchers::Matcher;
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
pub struct Suggestion {
|
|
pub display: String,
|
|
pub replacement: String,
|
|
}
|
|
|
|
pub struct CompletionContext<'a>(&'a EvaluationContext);
|
|
|
|
impl<'a> CompletionContext<'a> {
|
|
pub fn new(a: &'a EvaluationContext) -> CompletionContext<'a> {
|
|
CompletionContext(a)
|
|
}
|
|
}
|
|
|
|
impl<'a> AsRef<EvaluationContext> for CompletionContext<'a> {
|
|
fn as_ref(&self) -> &EvaluationContext {
|
|
self.0
|
|
}
|
|
}
|
|
|
|
pub trait Completer {
|
|
fn complete(
|
|
&self,
|
|
ctx: &CompletionContext<'_>,
|
|
partial: &str,
|
|
matcher: &dyn Matcher,
|
|
) -> Vec<Suggestion>;
|
|
}
|