mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:55:40 +02:00
Merge branch 'main' of https://github.com/nushell/engine-q into parse-error
This commit is contained in:
@ -15,6 +15,7 @@ pub enum Expr {
|
||||
Call(Box<Call>),
|
||||
ExternalCall(Vec<u8>, Vec<Vec<u8>>),
|
||||
Operator(Operator),
|
||||
RowCondition(VarId, Box<Expression>),
|
||||
BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs
|
||||
Subexpression(BlockId),
|
||||
Block(BlockId),
|
||||
|
@ -123,6 +123,24 @@ impl EngineState {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
||||
let mut output = vec![];
|
||||
|
||||
for scope in self.scope.iter().rev() {
|
||||
for decl in &scope.decls {
|
||||
if decl.0.starts_with(name) {
|
||||
output.push(decl.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn get_span_contents(&self, span: Span) -> &[u8] {
|
||||
&self.file_contents[span.start..span.end]
|
||||
}
|
||||
|
||||
pub fn get_var(&self, var_id: VarId) -> &Type {
|
||||
self.vars
|
||||
.get(var_id)
|
||||
@ -496,6 +514,24 @@ impl<'a> StateWorkingSet<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
||||
let mut output = vec![];
|
||||
|
||||
for scope in self.delta.scope.iter().rev() {
|
||||
for decl in &scope.decls {
|
||||
if decl.0.starts_with(name) {
|
||||
output.push(decl.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut permanent = self.permanent_state.find_commands_by_prefix(name);
|
||||
|
||||
output.append(&mut permanent);
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn get_block(&self, block_id: BlockId) -> &Block {
|
||||
let num_permanent_blocks = self.permanent_state.num_blocks();
|
||||
if block_id < num_permanent_blocks {
|
||||
|
@ -277,6 +277,24 @@ impl Value {
|
||||
|
||||
Ok(current)
|
||||
}
|
||||
|
||||
pub fn string(s: &str, span: Span) -> Value {
|
||||
Value::String {
|
||||
val: s.into(),
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_true(&self) -> bool {
|
||||
matches!(self, Value::Bool { val: true, .. })
|
||||
}
|
||||
|
||||
pub fn columns(&self) -> Vec<String> {
|
||||
match self {
|
||||
Value::Record { cols, .. } => cols.clone(),
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Value {
|
||||
|
Reference in New Issue
Block a user