Fix StringExpression.toInterpolation().

This commit is contained in:
Natalie Weizenbaum 2016-10-18 16:02:09 -07:00
parent 0f6f44f939
commit dd4a9165a2

View File

@ -42,13 +42,12 @@ class StringExpression implements Expression {
/// quoted strings. /// quoted strings.
/// ///
/// If [static] is true, this escapes any `#{` sequences in the string. If /// If [static] is true, this escapes any `#{` sequences in the string. If
/// [quote] is passed and this is a quoted string, it uses that character as /// [quote] is passed, it uses that character as the quote mark; otherwise, it
/// the quote mark; otherwise, it determines the best quote to add by looking /// determines the best quote to add by looking at the string.
/// at the string.
Interpolation asInterpolation({bool static: false, int quote}) { Interpolation asInterpolation({bool static: false, int quote}) {
if (!hasQuotes) return text; if (!hasQuotes) return text;
quote ??= hasQuotes ? null : _bestQuote(); quote ??= hasQuotes ? _bestQuote() : null;
var buffer = new InterpolationBuffer(); var buffer = new InterpolationBuffer();
if (quote != null) buffer.writeCharCode(quote); if (quote != null) buffer.writeCharCode(quote);
for (var value in text.contents) { for (var value in text.contents) {