Remove source text where not needed (#1567)

This commit is contained in:
Jonathan Turner 2020-04-10 19:56:48 +12:00 committed by GitHub
parent c86cf31aac
commit 8ac9d781fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 34 additions and 88 deletions

View File

@ -711,7 +711,7 @@ async fn process_line(
None None
}; };
match run_pipeline(pipeline, ctx, input_stream, line).await { match run_pipeline(pipeline, ctx, input_stream).await {
Ok(Some(input)) => { Ok(Some(input)) => {
// Running a pipeline gives us back a stream that we can then // Running a pipeline gives us back a stream that we can then
// work through. At the top level, we just want to pull on the // work through. At the top level, we just want to pull on the
@ -725,7 +725,6 @@ async fn process_line(
ctrl_c: ctx.ctrl_c.clone(), ctrl_c: ctx.ctrl_c.clone(),
commands: ctx.registry.clone(), commands: ctx.registry.clone(),
name: Tag::unknown(), name: Tag::unknown(),
source: Text::from(String::new()),
}; };
if let Ok(mut output_stream) = crate::commands::autoview::autoview(context) { if let Ok(mut output_stream) = crate::commands::autoview::autoview(context) {

View File

@ -32,7 +32,6 @@ impl WholeStreamCommand for Autoview {
commands: registry.clone(), commands: registry.clone(),
shell_manager: args.shell_manager, shell_manager: args.shell_manager,
host: args.host, host: args.host,
source: args.call_info.source,
ctrl_c: args.ctrl_c, ctrl_c: args.ctrl_c,
name: args.call_info.name_tag, name: args.call_info.name_tag,
}) })
@ -42,7 +41,6 @@ impl WholeStreamCommand for Autoview {
pub struct RunnableContextWithoutInput { pub struct RunnableContextWithoutInput {
pub shell_manager: ShellManager, pub shell_manager: ShellManager,
pub host: Arc<parking_lot::Mutex<Box<dyn Host>>>, pub host: Arc<parking_lot::Mutex<Box<dyn Host>>>,
pub source: Text,
pub ctrl_c: Arc<AtomicBool>, pub ctrl_c: Arc<AtomicBool>,
pub commands: CommandRegistry, pub commands: CommandRegistry,
pub name: Tag, pub name: Tag,
@ -53,7 +51,6 @@ impl RunnableContextWithoutInput {
let new_context = RunnableContextWithoutInput { let new_context = RunnableContextWithoutInput {
shell_manager: context.shell_manager, shell_manager: context.shell_manager,
host: context.host, host: context.host,
source: context.source,
ctrl_c: context.ctrl_c, ctrl_c: context.ctrl_c,
commands: context.commands, commands: context.commands,
name: context.name, name: context.name,
@ -289,7 +286,6 @@ fn create_default_command_args(context: &RunnableContextWithoutInput) -> RawComm
named: None, named: None,
span, span,
}, },
source: context.source.clone(),
name_tag: context.name.clone(), name_tag: context.name.clone(),
}, },
} }

View File

@ -9,12 +9,10 @@ pub(crate) fn run_internal_command(
command: InternalCommand, command: InternalCommand,
context: &mut Context, context: &mut Context,
input: Option<InputStream>, input: Option<InputStream>,
source: Text,
) -> Result<Option<InputStream>, ShellError> { ) -> Result<Option<InputStream>, ShellError> {
if log_enabled!(log::Level::Trace) { if log_enabled!(log::Level::Trace) {
trace!(target: "nu::run::internal", "->"); trace!(target: "nu::run::internal", "->");
trace!(target: "nu::run::internal", "{}", command.name); trace!(target: "nu::run::internal", "{}", command.name);
trace!(target: "nu::run::internal", "{}", command.args.debug(&source));
} }
let objects: InputStream = if let Some(input) = input { let objects: InputStream = if let Some(input) = input {
@ -30,7 +28,6 @@ pub(crate) fn run_internal_command(
internal_command?, internal_command?,
Tag::unknown_anchor(command.name_span), Tag::unknown_anchor(command.name_span),
command.args.clone(), command.args.clone(),
&source,
objects, objects,
) )
}; };
@ -70,7 +67,6 @@ pub(crate) fn run_internal_command(
named: None, named: None,
span: Span::unknown() span: Span::unknown()
}, },
source: source.clone(),
name_tag: Tag::unknown_anchor(command.name_span), name_tag: Tag::unknown_anchor(command.name_span),
} }
}; };

View File

@ -4,13 +4,11 @@ use crate::context::Context;
use crate::stream::InputStream; use crate::stream::InputStream;
use nu_errors::ShellError; use nu_errors::ShellError;
use nu_parser::{ClassifiedCommand, ClassifiedPipeline}; use nu_parser::{ClassifiedCommand, ClassifiedPipeline};
use nu_source::Text;
pub(crate) async fn run_pipeline( pub(crate) async fn run_pipeline(
pipeline: ClassifiedPipeline, pipeline: ClassifiedPipeline,
ctx: &mut Context, ctx: &mut Context,
mut input: Option<InputStream>, mut input: Option<InputStream>,
line: &str,
) -> Result<Option<InputStream>, ShellError> { ) -> Result<Option<InputStream>, ShellError> {
let mut iter = pipeline.commands.list.into_iter().peekable(); let mut iter = pipeline.commands.list.into_iter().peekable();
@ -29,9 +27,7 @@ pub(crate) async fn run_pipeline(
(Some(ClassifiedCommand::Error(err)), _) => return Err(err.into()), (Some(ClassifiedCommand::Error(err)), _) => return Err(err.into()),
(_, Some(ClassifiedCommand::Error(err))) => return Err(err.clone().into()), (_, Some(ClassifiedCommand::Error(err))) => return Err(err.clone().into()),
(Some(ClassifiedCommand::Internal(left)), _) => { (Some(ClassifiedCommand::Internal(left)), _) => run_internal_command(left, ctx, input)?,
run_internal_command(left, ctx, input, Text::from(line))?
}
(Some(ClassifiedCommand::External(left)), None) => { (Some(ClassifiedCommand::External(left)), None) => {
run_external_command(left, ctx, input, true).await? run_external_command(left, ctx, input, true).await?

View File

@ -15,7 +15,6 @@ use std::sync::atomic::AtomicBool;
#[derive(Deserialize, Serialize, Debug, Clone)] #[derive(Deserialize, Serialize, Debug, Clone)]
pub struct UnevaluatedCallInfo { pub struct UnevaluatedCallInfo {
pub args: hir::Call, pub args: hir::Call,
pub source: Text,
pub name_tag: Tag, pub name_tag: Tag,
} }
@ -25,7 +24,7 @@ impl UnevaluatedCallInfo {
registry: &CommandRegistry, registry: &CommandRegistry,
scope: &Scope, scope: &Scope,
) -> Result<CallInfo, ShellError> { ) -> Result<CallInfo, ShellError> {
let args = evaluate_args(&self.args, registry, scope, &self.source)?; let args = evaluate_args(&self.args, registry, scope)?;
Ok(CallInfo { Ok(CallInfo {
args, args,
@ -145,10 +144,6 @@ impl CommandArgs {
)) ))
} }
pub fn source(&self) -> Text {
self.call_info.source.clone()
}
pub fn process<'de, T: Deserialize<'de>, O: ToOutputStream>( pub fn process<'de, T: Deserialize<'de>, O: ToOutputStream>(
self, self,
registry: &CommandRegistry, registry: &CommandRegistry,
@ -156,7 +151,6 @@ impl CommandArgs {
) -> Result<RunnableArgs<T, O>, ShellError> { ) -> Result<RunnableArgs<T, O>, ShellError> {
let shell_manager = self.shell_manager.clone(); let shell_manager = self.shell_manager.clone();
let host = self.host.clone(); let host = self.host.clone();
let source = self.source();
let ctrl_c = self.ctrl_c.clone(); let ctrl_c = self.ctrl_c.clone();
let args = self.evaluate_once(registry)?; let args = self.evaluate_once(registry)?;
let call_info = args.call_info.clone(); let call_info = args.call_info.clone();
@ -169,7 +163,6 @@ impl CommandArgs {
context: RunnableContext { context: RunnableContext {
input, input,
commands: registry.clone(), commands: registry.clone(),
source,
shell_manager, shell_manager,
name: name_tag, name: name_tag,
host, host,
@ -193,7 +186,6 @@ impl CommandArgs {
let shell_manager = self.shell_manager.clone(); let shell_manager = self.shell_manager.clone();
let host = self.host.clone(); let host = self.host.clone();
let source = self.source();
let ctrl_c = self.ctrl_c.clone(); let ctrl_c = self.ctrl_c.clone();
let args = self.evaluate_once(registry)?; let args = self.evaluate_once(registry)?;
let call_info = args.call_info.clone(); let call_info = args.call_info.clone();
@ -207,7 +199,6 @@ impl CommandArgs {
context: RunnableContext { context: RunnableContext {
input, input,
commands: registry.clone(), commands: registry.clone(),
source,
shell_manager, shell_manager,
name: name_tag, name: name_tag,
host, host,
@ -229,7 +220,6 @@ pub struct RunnableContext {
pub input: InputStream, pub input: InputStream,
pub shell_manager: ShellManager, pub shell_manager: ShellManager,
pub host: Arc<parking_lot::Mutex<Box<dyn Host>>>, pub host: Arc<parking_lot::Mutex<Box<dyn Host>>>,
pub source: Text,
pub ctrl_c: Arc<AtomicBool>, pub ctrl_c: Arc<AtomicBool>,
pub commands: CommandRegistry, pub commands: CommandRegistry,
pub name: Tag, pub name: Tag,

View File

@ -103,7 +103,6 @@ impl PerItemCommand for Enter {
named: None, named: None,
span: Span::unknown() span: Span::unknown()
}, },
source: raw_args.call_info.source,
name_tag: raw_args.call_info.name_tag, name_tag: raw_args.call_info.name_tag,
}, },
}; };

View File

@ -234,7 +234,6 @@ fn save(
named: None, named: None,
span: Span::unknown() span: Span::unknown()
}, },
source: raw_args.call_info.source,
name_tag: raw_args.call_info.name_tag, name_tag: raw_args.call_info.name_tag,
} }
}; };

View File

@ -30,7 +30,6 @@ impl WholeStreamCommand for Sum {
commands: registry.clone(), commands: registry.clone(),
shell_manager: args.shell_manager, shell_manager: args.shell_manager,
host: args.host, host: args.host,
source: args.call_info.source,
ctrl_c: args.ctrl_c, ctrl_c: args.ctrl_c,
name: args.call_info.name_tag, name: args.call_info.name_tag,
}) })

View File

@ -176,33 +176,22 @@ impl Context {
command: Arc<Command>, command: Arc<Command>,
name_tag: Tag, name_tag: Tag,
args: hir::Call, args: hir::Call,
source: &Text,
input: InputStream, input: InputStream,
) -> OutputStream { ) -> OutputStream {
let command_args = self.command_args(args, input, source, name_tag); let command_args = self.command_args(args, input, name_tag);
command.run(command_args, self.registry()) command.run(command_args, self.registry())
} }
fn call_info(&self, args: hir::Call, source: &Text, name_tag: Tag) -> UnevaluatedCallInfo { fn call_info(&self, args: hir::Call, name_tag: Tag) -> UnevaluatedCallInfo {
UnevaluatedCallInfo { UnevaluatedCallInfo { args, name_tag }
args,
source: source.clone(),
name_tag,
}
} }
fn command_args( fn command_args(&self, args: hir::Call, input: InputStream, name_tag: Tag) -> CommandArgs {
&self,
args: hir::Call,
input: InputStream,
source: &Text,
name_tag: Tag,
) -> CommandArgs {
CommandArgs { CommandArgs {
host: self.host.clone(), host: self.host.clone(),
ctrl_c: self.ctrl_c.clone(), ctrl_c: self.ctrl_c.clone(),
shell_manager: self.shell_manager.clone(), shell_manager: self.shell_manager.clone(),
call_info: self.call_info(args, source, name_tag), call_info: self.call_info(args, name_tag),
input, input,
} }
} }

View File

@ -12,7 +12,7 @@ use nu_protocol::{
Evaluate, EvaluateTrait, Primitive, Scope, ShellTypeName, SpannedTypeName, TaggedDictBuilder, Evaluate, EvaluateTrait, Primitive, Scope, ShellTypeName, SpannedTypeName, TaggedDictBuilder,
UntaggedValue, Value, UntaggedValue, Value,
}; };
use nu_source::{Tag, Text}; use nu_source::Tag;
use nu_value_ext::ValueExt; use nu_value_ext::ValueExt;
use num_bigint::BigInt; use num_bigint::BigInt;
use num_traits::Zero; use num_traits::Zero;
@ -30,7 +30,6 @@ pub struct Operation {
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Hash, Serialize, Deserialize, new)] #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Hash, Serialize, Deserialize, new)]
pub struct Block { pub struct Block {
pub(crate) expressions: Vec<hir::SpannedExpression>, pub(crate) expressions: Vec<hir::SpannedExpression>,
pub(crate) source: Text,
pub(crate) tag: Tag, pub(crate) tag: Tag,
} }
@ -54,7 +53,7 @@ impl EvaluateTrait for Block {
); );
for expr in self.expressions.iter() { for expr in self.expressions.iter() {
last = evaluate_baseline_expr(&expr, &CommandRegistry::empty(), &scope, &self.source) last = evaluate_baseline_expr(&expr, &CommandRegistry::empty(), &scope)
} }
last last

View File

@ -5,20 +5,18 @@ use indexmap::IndexMap;
use nu_errors::ShellError; use nu_errors::ShellError;
use nu_parser::hir; use nu_parser::hir;
use nu_protocol::{EvaluatedArgs, Scope, UntaggedValue, Value}; use nu_protocol::{EvaluatedArgs, Scope, UntaggedValue, Value};
use nu_source::Text;
pub(crate) fn evaluate_args( pub(crate) fn evaluate_args(
call: &hir::Call, call: &hir::Call,
registry: &CommandRegistry, registry: &CommandRegistry,
scope: &Scope, scope: &Scope,
source: &Text,
) -> Result<EvaluatedArgs, ShellError> { ) -> Result<EvaluatedArgs, ShellError> {
let positional: Result<Option<Vec<_>>, _> = call let positional: Result<Option<Vec<_>>, _> = call
.positional .positional
.as_ref() .as_ref()
.map(|p| { .map(|p| {
p.iter() p.iter()
.map(|e| evaluate_baseline_expr(e, registry, scope, source)) .map(|e| evaluate_baseline_expr(e, registry, scope))
.collect() .collect()
}) })
.transpose(); .transpose();
@ -37,10 +35,8 @@ pub(crate) fn evaluate_args(
results.insert(name.clone(), UntaggedValue::boolean(true).into_value(tag)); results.insert(name.clone(), UntaggedValue::boolean(true).into_value(tag));
} }
hir::NamedValue::Value(_, expr) => { hir::NamedValue::Value(_, expr) => {
results.insert( results
name.clone(), .insert(name.clone(), evaluate_baseline_expr(expr, registry, scope)?);
evaluate_baseline_expr(expr, registry, scope, source)?,
);
} }
_ => {} _ => {}

View File

@ -9,20 +9,18 @@ use nu_protocol::{
ColumnPath, Evaluate, Primitive, RangeInclusion, Scope, UnspannedPathMember, UntaggedValue, ColumnPath, Evaluate, Primitive, RangeInclusion, Scope, UnspannedPathMember, UntaggedValue,
Value, Value,
}; };
use nu_source::Text;
pub(crate) fn evaluate_baseline_expr( pub(crate) fn evaluate_baseline_expr(
expr: &SpannedExpression, expr: &SpannedExpression,
registry: &CommandRegistry, registry: &CommandRegistry,
scope: &Scope, scope: &Scope,
source: &Text,
) -> Result<Value, ShellError> { ) -> Result<Value, ShellError> {
let tag = Tag { let tag = Tag {
span: expr.span, span: expr.span,
anchor: None, anchor: None,
}; };
match &expr.expr { match &expr.expr {
Expression::Literal(literal) => Ok(evaluate_literal(literal, expr.span, source)), Expression::Literal(literal) => Ok(evaluate_literal(literal, expr.span)),
Expression::ExternalWord => Err(ShellError::argument_error( Expression::ExternalWord => Err(ShellError::argument_error(
"Invalid external word".spanned(tag.span), "Invalid external word".spanned(tag.span),
ArgumentError::InvalidExternalWord, ArgumentError::InvalidExternalWord,
@ -31,12 +29,12 @@ pub(crate) fn evaluate_baseline_expr(
Expression::Synthetic(hir::Synthetic::String(s)) => { Expression::Synthetic(hir::Synthetic::String(s)) => {
Ok(UntaggedValue::string(s).into_untagged_value()) Ok(UntaggedValue::string(s).into_untagged_value())
} }
Expression::Variable(var) => evaluate_reference(var, scope, source, tag), Expression::Variable(var) => evaluate_reference(var, scope, tag),
Expression::Command(_) => evaluate_command(tag, scope, source), Expression::Command(_) => evaluate_command(tag, scope),
Expression::ExternalCommand(external) => evaluate_external(external, scope, source), Expression::ExternalCommand(external) => evaluate_external(external, scope),
Expression::Binary(binary) => { Expression::Binary(binary) => {
let left = evaluate_baseline_expr(&binary.left, registry, scope, source)?; let left = evaluate_baseline_expr(&binary.left, registry, scope)?;
let right = evaluate_baseline_expr(&binary.right, registry, scope, source)?; let right = evaluate_baseline_expr(&binary.right, registry, scope)?;
trace!("left={:?} right={:?}", left.value, right.value); trace!("left={:?} right={:?}", left.value, right.value);
@ -57,8 +55,8 @@ pub(crate) fn evaluate_baseline_expr(
let left = &range.left; let left = &range.left;
let right = &range.right; let right = &range.right;
let left = evaluate_baseline_expr(left, registry, scope, source)?; let left = evaluate_baseline_expr(left, registry, scope)?;
let right = evaluate_baseline_expr(right, registry, scope, source)?; let right = evaluate_baseline_expr(right, registry, scope)?;
let left_span = left.tag.span; let left_span = left.tag.span;
let right_span = right.tag.span; let right_span = right.tag.span;
@ -77,7 +75,7 @@ pub(crate) fn evaluate_baseline_expr(
let mut exprs = vec![]; let mut exprs = vec![];
for expr in list { for expr in list {
let expr = evaluate_baseline_expr(expr, registry, scope, source)?; let expr = evaluate_baseline_expr(expr, registry, scope)?;
exprs.push(expr); exprs.push(expr);
} }
@ -85,12 +83,11 @@ pub(crate) fn evaluate_baseline_expr(
} }
Expression::Block(block) => Ok(UntaggedValue::Block(Evaluate::new(Block::new( Expression::Block(block) => Ok(UntaggedValue::Block(Evaluate::new(Block::new(
block.clone(), block.clone(),
source.clone(),
tag.clone(), tag.clone(),
))) )))
.into_value(&tag)), .into_value(&tag)),
Expression::Path(path) => { Expression::Path(path) => {
let value = evaluate_baseline_expr(&path.head, registry, scope, source)?; let value = evaluate_baseline_expr(&path.head, registry, scope)?;
let mut item = value; let mut item = value;
for member in &path.tail { for member in &path.tail {
@ -132,7 +129,7 @@ pub(crate) fn evaluate_baseline_expr(
} }
} }
fn evaluate_literal(literal: &hir::Literal, span: Span, source: &Text) -> Value { fn evaluate_literal(literal: &hir::Literal, span: Span) -> Value {
match &literal { match &literal {
hir::Literal::ColumnPath(path) => { hir::Literal::ColumnPath(path) => {
let members = path.iter().map(|member| member.to_path_member()).collect(); let members = path.iter().map(|member| member.to_path_member()).collect();
@ -149,21 +146,16 @@ fn evaluate_literal(literal: &hir::Literal, span: Span, source: &Text) -> Value
hir::Literal::Size(int, unit) => unit.compute(&int).into_value(span), hir::Literal::Size(int, unit) => unit.compute(&int).into_value(span),
hir::Literal::String(string) => UntaggedValue::string(string).into_value(span), hir::Literal::String(string) => UntaggedValue::string(string).into_value(span),
hir::Literal::GlobPattern(pattern) => UntaggedValue::pattern(pattern).into_value(span), hir::Literal::GlobPattern(pattern) => UntaggedValue::pattern(pattern).into_value(span),
hir::Literal::Bare => UntaggedValue::string(span.slice(source)).into_value(span), hir::Literal::Bare(bare) => UntaggedValue::string(bare.clone()).into_value(span),
hir::Literal::Operator(_) => unimplemented!("Not sure what to do with operator yet"), hir::Literal::Operator(_) => unimplemented!("Not sure what to do with operator yet"),
} }
} }
fn evaluate_reference( fn evaluate_reference(name: &hir::Variable, scope: &Scope, tag: Tag) -> Result<Value, ShellError> {
name: &hir::Variable,
scope: &Scope,
source: &Text,
tag: Tag,
) -> Result<Value, ShellError> {
trace!("Evaluating {:?} with Scope {:?}", name, scope); trace!("Evaluating {:?} with Scope {:?}", name, scope);
match name { match name {
hir::Variable::It(_) => Ok(scope.it.value.clone().into_value(tag)), hir::Variable::It(_) => Ok(scope.it.value.clone().into_value(tag)),
hir::Variable::Other(_, span) => match span.slice(source) { hir::Variable::Other(name, _) => match name {
x if x == "$nu" => crate::evaluate::variables::nu(tag), x if x == "$nu" => crate::evaluate::variables::nu(tag),
x => Ok(scope x => Ok(scope
.vars .vars
@ -174,17 +166,13 @@ fn evaluate_reference(
} }
} }
fn evaluate_external( fn evaluate_external(external: &hir::ExternalCommand, _scope: &Scope) -> Result<Value, ShellError> {
external: &hir::ExternalCommand,
_scope: &Scope,
_source: &Text,
) -> Result<Value, ShellError> {
Err(ShellError::syntax_error( Err(ShellError::syntax_error(
"Unexpected external command".spanned(external.name.span), "Unexpected external command".spanned(external.name.span),
)) ))
} }
fn evaluate_command(tag: Tag, _scope: &Scope, _source: &Text) -> Result<Value, ShellError> { fn evaluate_command(tag: Tag, _scope: &Scope) -> Result<Value, ShellError> {
Err(ShellError::syntax_error( Err(ShellError::syntax_error(
"Unexpected command".spanned(tag.span), "Unexpected command".spanned(tag.span),
)) ))

View File

@ -462,7 +462,7 @@ pub enum Literal {
String(String), String(String),
GlobPattern(String), GlobPattern(String),
ColumnPath(Vec<Member>), ColumnPath(Vec<Member>),
Bare, Bare(String),
} }
impl Literal { impl Literal {
@ -488,7 +488,7 @@ impl ShellTypeName for Literal {
Literal::Size(..) => "size", Literal::Size(..) => "size",
Literal::String(..) => "string", Literal::String(..) => "string",
Literal::ColumnPath(..) => "column path", Literal::ColumnPath(..) => "column path",
Literal::Bare => "string", Literal::Bare(_) => "string",
Literal::GlobPattern(_) => "pattern", Literal::GlobPattern(_) => "pattern",
Literal::Operator(_) => "operator", Literal::Operator(_) => "operator",
} }
@ -507,7 +507,7 @@ impl PrettyDebugWithSource for SpannedLiteral {
Literal::ColumnPath(path) => { Literal::ColumnPath(path) => {
b::intersperse_with_source(path.iter(), b::space(), source) b::intersperse_with_source(path.iter(), b::space(), source)
} }
Literal::Bare => b::delimit("b\"", b::primitive(self.span.slice(source)), "\""), Literal::Bare(bare) => b::delimit("b\"", b::primitive(bare), "\""),
Literal::Operator(operator) => b::primitive(format!("{:?}", operator)), Literal::Operator(operator) => b::primitive(format!("{:?}", operator)),
}, },
} }
@ -528,7 +528,7 @@ impl PrettyDebugWithSource for SpannedLiteral {
"column path", "column path",
b::intersperse_with_source(path.iter(), b::space(), source), b::intersperse_with_source(path.iter(), b::space(), source),
), ),
Literal::Bare => b::typed("bare", b::primitive(self.span.slice(source))), Literal::Bare(bare) => b::typed("bare", b::primitive(bare)),
Literal::Operator(operator) => { Literal::Operator(operator) => {
b::typed("operator", b::primitive(format!("{:?}", operator))) b::typed("operator", b::primitive(format!("{:?}", operator)))
} }

View File

@ -33,7 +33,7 @@ pub fn expression_to_flat_shape(e: &SpannedExpression) -> Vec<Spanned<FlatShape>
output output
} }
Expression::Command(command) => vec![FlatShape::InternalCommand.spanned(*command)], Expression::Command(command) => vec![FlatShape::InternalCommand.spanned(*command)],
Expression::Literal(Literal::Bare) => vec![FlatShape::BareMember.spanned(e.span)], Expression::Literal(Literal::Bare(_)) => vec![FlatShape::BareMember.spanned(e.span)],
Expression::Literal(Literal::ColumnPath(_)) => vec![FlatShape::Path.spanned(e.span)], Expression::Literal(Literal::ColumnPath(_)) => vec![FlatShape::Path.spanned(e.span)],
Expression::Literal(Literal::GlobPattern(_)) => { Expression::Literal(Literal::GlobPattern(_)) => {
vec![FlatShape::GlobPattern.spanned(e.span)] vec![FlatShape::GlobPattern.spanned(e.span)]