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
14 changed files with 34 additions and 88 deletions

View File

@ -462,7 +462,7 @@ pub enum Literal {
String(String),
GlobPattern(String),
ColumnPath(Vec<Member>),
Bare,
Bare(String),
}
impl Literal {
@ -488,7 +488,7 @@ impl ShellTypeName for Literal {
Literal::Size(..) => "size",
Literal::String(..) => "string",
Literal::ColumnPath(..) => "column path",
Literal::Bare => "string",
Literal::Bare(_) => "string",
Literal::GlobPattern(_) => "pattern",
Literal::Operator(_) => "operator",
}
@ -507,7 +507,7 @@ impl PrettyDebugWithSource for SpannedLiteral {
Literal::ColumnPath(path) => {
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)),
},
}
@ -528,7 +528,7 @@ impl PrettyDebugWithSource for SpannedLiteral {
"column path",
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) => {
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
}
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::GlobPattern(_)) => {
vec![FlatShape::GlobPattern.spanned(e.span)]