fmt
This commit is contained in:
parent
d25b8f91c7
commit
d39dbd6697
|
@ -371,7 +371,7 @@ impl TypedExpr {
|
||||||
.find_node(byte_index)
|
.find_node(byte_index)
|
||||||
.or_else(|| then.find_node(byte_index))
|
.or_else(|| then.find_node(byte_index))
|
||||||
.or(Some(Located::Expression(self))),
|
.or(Some(Located::Expression(self))),
|
||||||
|
|
||||||
TypedExpr::Emit { text, then, .. } => text
|
TypedExpr::Emit { text, then, .. } => text
|
||||||
.find_node(byte_index)
|
.find_node(byte_index)
|
||||||
.or_else(|| then.find_node(byte_index))
|
.or_else(|| then.find_node(byte_index))
|
||||||
|
@ -1307,7 +1307,9 @@ impl UntypedExpr {
|
||||||
.map(|e| e.start_byte_index())
|
.map(|e| e.start_byte_index())
|
||||||
.unwrap_or(location.start),
|
.unwrap_or(location.start),
|
||||||
Self::PipeLine { expressions, .. } => expressions.first().start_byte_index(),
|
Self::PipeLine { expressions, .. } => expressions.first().start_byte_index(),
|
||||||
Self::Trace { location, .. } | Self::Emit{ location, .. } | Self::Assignment { location, .. } => location.start,
|
Self::Trace { location, .. }
|
||||||
|
| Self::Emit { location, .. }
|
||||||
|
| Self::Assignment { location, .. } => location.start,
|
||||||
_ => self.location().start,
|
_ => self.location().start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,9 +957,7 @@ impl<'comments> Formatter<'comments> {
|
||||||
kind, text, then, ..
|
kind, text, then, ..
|
||||||
} => self.trace(kind, text, then),
|
} => self.trace(kind, text, then),
|
||||||
|
|
||||||
UntypedExpr::Emit {
|
UntypedExpr::Emit { text, then, .. } => self.emit(text, then),
|
||||||
text, then, ..
|
|
||||||
} => self.emit(text, then),
|
|
||||||
|
|
||||||
UntypedExpr::When {
|
UntypedExpr::When {
|
||||||
subject, clauses, ..
|
subject, clauses, ..
|
||||||
|
@ -1049,23 +1047,18 @@ impl<'comments> Formatter<'comments> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit<'a>(
|
pub fn emit<'a>(&mut self, text: &'a UntypedExpr, then: &'a UntypedExpr) -> Document<'a> {
|
||||||
&mut self,
|
|
||||||
text: &'a UntypedExpr,
|
|
||||||
then: &'a UntypedExpr,
|
|
||||||
) -> Document<'a> {
|
|
||||||
let body = "emit"
|
let body = "emit"
|
||||||
.to_doc()
|
.to_doc()
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(self.wrap_expr(text))
|
.append(self.wrap_expr(text))
|
||||||
.group();
|
.group();
|
||||||
body
|
body.append(if self.pop_empty_lines(then.start_byte_index()) {
|
||||||
.append(if self.pop_empty_lines(then.start_byte_index()) {
|
lines(2)
|
||||||
lines(2)
|
} else {
|
||||||
} else {
|
line()
|
||||||
line()
|
})
|
||||||
})
|
.append(self.expr(then, true))
|
||||||
.append(self.expr(then, true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pattern_constructor<'a>(
|
pub fn pattern_constructor<'a>(
|
||||||
|
|
|
@ -2340,7 +2340,9 @@ fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> {
|
||||||
location: expr.location(),
|
location: expr.location(),
|
||||||
expr: *value.clone(),
|
expr: *value.clone(),
|
||||||
}),
|
}),
|
||||||
UntypedExpr::Trace { then, .. } | UntypedExpr::Emit { then, .. } => assert_no_assignment(then),
|
UntypedExpr::Trace { then, .. } | UntypedExpr::Emit { then, .. } => {
|
||||||
|
assert_no_assignment(then)
|
||||||
|
}
|
||||||
UntypedExpr::Fn { .. }
|
UntypedExpr::Fn { .. }
|
||||||
| UntypedExpr::BinOp { .. }
|
| UntypedExpr::BinOp { .. }
|
||||||
| UntypedExpr::ByteArray { .. }
|
| UntypedExpr::ByteArray { .. }
|
||||||
|
|
Loading…
Reference in New Issue