Fix analysis.

This commit is contained in:
Natalie Weizenbaum 2016-06-03 16:34:26 -07:00
parent 13e3bd7707
commit f09d2c01b2
3 changed files with 12 additions and 18 deletions

View File

@ -387,8 +387,8 @@ class Parser {
if (first == $plus || first == $minus) _scanner.readChar();
num number = 0;
var first = _scanner.peekChar();
if (!isDigit(first) && first != $dot) _scanner.error("Expected number.");
var second = _scanner.peekChar();
if (!isDigit(second) && second != $dot) _scanner.error("Expected number.");
while (isDigit(_scanner.peekChar())) {
number *= 10;
@ -469,7 +469,7 @@ class Parser {
}
}
return buffer.interpolation(_scanner.spanFrom(start));
return new StringExpression(buffer.interpolation(_scanner.spanFrom(start)));
}
Expression _hexColor() => throw new UnimplementedError();

View File

@ -6,11 +6,10 @@ import 'package:charcode/charcode.dart';
import '../../ast/css/node.dart';
import '../../util/character.dart';
import '../../utils.dart';
import '../../value.dart';
import '../css.dart';
String toCss(AstNode node) {
String toCss(CssNode node) {
var visitor = new _SerializeCssVisitor();
node.accept(visitor);
var result = visitor._buffer.toString();
@ -68,10 +67,11 @@ class _SerializeCssVisitor extends CssVisitor {
_buffer.writeCharCode($semicolon);
}
void visitBoolean(SassBoolean value) => value.value.toString();
void visitBoolean(SassBoolean value) =>
_buffer.write(value.value.toString());
void visitIdentifier(SassIdentifier value) =>
value.text.replaceAll("\n", " ");
_buffer.write(value.text.replaceAll("\n", " "));
void visitList(SassList value) {
if (value.contents.isEmpty) throw "() isn't a valid CSS value";
@ -152,13 +152,6 @@ class _SerializeCssVisitor extends CssVisitor {
return doubleQuote ? '"$buffer"' : "'$buffer'";
}
num _round(num number) {
if (number is double && (number.isInfinite || number.isNaN)) return number;
if (almostEquals(number % 1, 0.0)) return number.round();
return (number * 10 * SassNumber.precision).round() /
(10 * SassNumber.precision);
}
void _writeIndentation() {
for (var i = 0; i < _indentation; i++) {
_buffer.writeCharCode($space);

View File

@ -43,16 +43,17 @@ class PerformVisitor extends StatementVisitor {
void visitDeclaration(Declaration node) {
var name = _performInterpolation(node.name);
var value = _performExpression(node.value);
var cssValue = _performExpression(node.value);
var value = cssValue.value;
// Don't abort for an empty list because converting it to CSS will throw an
// error that we want to user to see.
if (value.value.isBlank &&
!(value.value is SassList && value.value.contents.isEmpty)) {
if (value.isBlank &&
!(value is SassList && value.contents.isEmpty)) {
return;
}
_addChild(new CssDeclaration(name, value, span: node.span));
_addChild(new CssDeclaration(name, cssValue, span: node.span));
}
void visitStyleRule(StyleRule node) {