Add which command, add external completions, and builtin var completions (#782)

* Add which and external completions

* WIP

* Finish up external and var completions

* fix windows
This commit is contained in:
JT
2022-01-20 13:02:53 -05:00
committed by GitHub
parent d4b6b4b09a
commit 33ffb2c39a
9 changed files with 490 additions and 101 deletions

View File

@ -344,6 +344,34 @@ impl EngineState {
}
}
pub fn find_aliases(&self, name: &str) -> Vec<Vec<Span>> {
let mut output = vec![];
for frame in &self.scope {
if let Some(alias) = frame.aliases.get(name.as_bytes()) {
output.push(alias.clone());
}
}
output
}
pub fn find_custom_commands(&self, name: &str) -> Vec<Block> {
let mut output = vec![];
for frame in &self.scope {
if let Some(decl_id) = frame.decls.get(name.as_bytes()) {
let decl = self.get_decl(*decl_id);
if let Some(block_id) = decl.get_block_id() {
output.push(self.get_block(block_id).clone());
}
}
}
output
}
pub fn find_decl(&self, name: &[u8]) -> Option<DeclId> {
let mut visibility: Visibility = Visibility::new();