Make (most) spans mandatory.

Arguments are still optional since they may be constructed for
user-defined arguments.
This commit is contained in:
Natalie Weizenbaum 2016-08-28 14:53:20 -07:00 committed by Natalie Weizenbaum
parent 82aca21682
commit faa86b697c
35 changed files with 114 additions and 129 deletions

View File

@ -17,7 +17,7 @@ class CssAtRule extends CssParentNode {
final FileSpan span;
CssAtRule(this.name, {bool childless: false, this.value, this.span})
CssAtRule(this.name, this.span, {bool childless: false, this.value})
: isChildless = childless;
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>

View File

@ -12,7 +12,7 @@ class CssComment extends CssNode {
final FileSpan span;
CssComment(this.text, {this.span});
CssComment(this.text, this.span);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitComment(this);

View File

@ -18,7 +18,7 @@ class CssDeclaration extends CssNode {
bool get isCustomProperty => name.value.startsWith("--");
CssDeclaration(this.name, this.value, {this.span});
CssDeclaration(this.name, this.value, this.span);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitDeclaration(this);

View File

@ -13,7 +13,7 @@ class CssMediaRule extends CssParentNode {
final FileSpan span;
CssMediaRule(this.queries, {this.span});
CssMediaRule(this.queries, this.span);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitMediaRule(this);

View File

@ -14,7 +14,7 @@ class CssStyleRule extends CssParentNode {
final FileSpan span;
CssStyleRule(this.selector, {this.span});
CssStyleRule(this.selector, this.span);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitStyleRule(this);

View File

@ -10,7 +10,7 @@ import 'node.dart';
class CssStylesheet extends CssParentNode {
final FileSpan span;
CssStylesheet({this.span});
CssStylesheet(this.span);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitStylesheet(this);

View File

@ -11,7 +11,7 @@ class CssValue<T> implements AstNode {
final FileSpan span;
CssValue(this.value, {this.span});
CssValue(this.value, this.span);
String toString() => value.toString();
}

View File

@ -19,13 +19,13 @@ class ArgumentInvocation implements SassNode {
final FileSpan span;
ArgumentInvocation(Iterable<Expression> positional,
Map<String, Expression> named, {this.rest, this.keywordRest, this.span})
Map<String, Expression> named, this.span, {this.rest, this.keywordRest})
: positional = new List.unmodifiable(positional),
named = new Map.unmodifiable(named) {
assert(rest != null || keywordRest == null);
}
ArgumentInvocation.empty({this.span})
ArgumentInvocation.empty(this.span)
: positional = const [],
named = const {},
rest = null,

View File

@ -17,6 +17,6 @@ abstract class CallableDeclaration implements Statement {
final FileSpan span;
CallableDeclaration(this.name, this.arguments, Iterable<Statement> children,
{this.span})
this.span)
: children = new List.unmodifiable(children);
}

View File

@ -12,7 +12,7 @@ class BooleanExpression implements Expression {
final FileSpan span;
BooleanExpression(this.value, {this.span});
BooleanExpression(this.value, this.span);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
visitor.visitBooleanExpression(this);

View File

@ -13,7 +13,7 @@ class ColorExpression implements Expression {
final FileSpan span;
ColorExpression(this.value, {this.span});
ColorExpression(this.value, this.span);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
visitor.visitColorExpression(this);

View File

@ -21,7 +21,7 @@ class ListExpression implements Expression {
final FileSpan span;
ListExpression(Iterable<Expression> contents, ListSeparator separator,
{bool bracketed: false, FileSpan span})
{bool bracketed: false, FileSpan span})
: this._(new List.unmodifiable(contents), separator, bracketed, span);
ListExpression._(List<Expression> contents, this.separator, this.isBracketed,

View File

@ -13,7 +13,7 @@ class MapExpression implements Expression {
final FileSpan span;
MapExpression(Iterable<Pair<Expression, Expression>> pairs, {this.span})
MapExpression(Iterable<Pair<Expression, Expression>> pairs, this.span)
: pairs = new List.unmodifiable(pairs);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>

View File

@ -12,7 +12,7 @@ class NumberExpression implements Expression {
final FileSpan span;
NumberExpression(this.value, {this.span});
NumberExpression(this.value, this.span);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
visitor.visitNumberExpression(this);

View File

@ -15,7 +15,7 @@ class UnaryOperatorExpression implements Expression {
final FileSpan span;
UnaryOperatorExpression(this.operator, this.operand, {this.span});
UnaryOperatorExpression(this.operator, this.operand, this.span);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
visitor.visitUnaryOperatorExpression(this);

View File

@ -12,7 +12,7 @@ class VariableExpression implements Expression {
final FileSpan span;
VariableExpression(this.name, {this.span});
VariableExpression(this.name, this.span);
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
visitor.visitVariableExpression(this);

View File

@ -24,7 +24,7 @@ class Interpolation implements SassNode {
/// Returns the plain text before the interpolation, or the empty string.
String get initialPlain => contents.first is String ? contents.first : '';
Interpolation(Iterable/*(String|Expression)*/ contents, {this.span})
Interpolation(Iterable/*(String|Expression)*/ contents, this.span)
: contents = new List.unmodifiable(contents) {
for (var i = 0; i < this.contents.length; i++) {
if (this.contents[i] is! String && this.contents[i] is! Expression) {

View File

@ -17,7 +17,7 @@ class AtRule implements Statement {
final FileSpan span;
AtRule(this.name, {this.value, Iterable<Statement> children, this.span})
AtRule(this.name, this.span, {this.value, Iterable<Statement> children})
: children = children == null ? null : new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -14,7 +14,7 @@ class Comment implements Statement {
final FileSpan span;
Comment(this.text, {bool silent: false, this.span})
Comment(this.text, this.span, {bool silent: false})
: isSilent = silent;
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -10,7 +10,7 @@ import '../statement.dart';
class Content implements Statement {
final FileSpan span;
Content({this.span});
Content(this.span);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
visitor.visitContent(this);

View File

@ -18,7 +18,7 @@ class Declaration implements Statement {
final FileSpan span;
Declaration(this.name, {this.value, Iterable<Statement> children, this.span})
Declaration(this.name, this.span, {this.value, Iterable<Statement> children})
: children = children == null ? null : new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -13,7 +13,7 @@ class ExtendRule implements Statement {
final FileSpan span;
ExtendRule(this.selector, {this.span});
ExtendRule(this.selector, this.span);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
visitor.visitExtendRule(this);

View File

@ -11,8 +11,8 @@ import '../statement.dart';
class FunctionDeclaration extends CallableDeclaration {
FunctionDeclaration(String name, ArgumentDeclaration arguments,
Iterable<Statement> children, {FileSpan span})
: super(name, arguments, children, span: span);
Iterable<Statement> children, FileSpan span)
: super(name, arguments, children, span);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
visitor.visitFunctionDeclaration(this);

View File

@ -15,7 +15,7 @@ class If implements Statement {
final FileSpan span;
If(this.expression, Iterable<Statement> children, {this.span})
If(this.expression, Iterable<Statement> children, this.span)
: children = new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -18,8 +18,7 @@ class Include implements Statement, CallableInvocation {
final FileSpan span;
Include(this.name, this.arguments, {Iterable<Statement> children,
this.span})
Include(this.name, this.arguments, this.span, {Iterable<Statement> children})
: children = children == null ? null : new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -16,7 +16,7 @@ class MediaRule implements Statement {
final FileSpan span;
MediaRule(Iterable<MediaQuery> queries, Iterable<Statement> children,
{this.span})
this.span)
: queries = new List.unmodifiable(queries),
children = new List.unmodifiable(children);

View File

@ -13,8 +13,8 @@ class MixinDeclaration extends CallableDeclaration {
final bool hasContent;
MixinDeclaration(String name, ArgumentDeclaration arguments,
Iterable<Statement> children, {this.hasContent: false, FileSpan span})
: super(name, arguments, children, span: span);
Iterable<Statement> children, FileSpan span, {this.hasContent: false})
: super(name, arguments, children, span);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
visitor.visitMixinDeclaration(this);

View File

@ -13,7 +13,7 @@ class Return implements Statement {
final FileSpan span;
Return(this.expression, {this.span});
Return(this.expression, this.span);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
visitor.visitReturn(this);

View File

@ -15,7 +15,7 @@ class StyleRule implements Statement {
final FileSpan span;
StyleRule(this.selector, Iterable<Statement> children, {this.span})
StyleRule(this.selector, Iterable<Statement> children, this.span)
: children = new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -12,7 +12,7 @@ class Stylesheet implements Statement {
final FileSpan span;
Stylesheet(Iterable<Statement> children, {this.span})
Stylesheet(Iterable<Statement> children, this.span)
: children = new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>

View File

@ -19,8 +19,8 @@ class VariableDeclaration implements Statement {
final FileSpan span;
VariableDeclaration(this.name, this.expression, {bool guarded: false,
bool global: false, this.span})
VariableDeclaration(this.name, this.expression, this.span,
{bool guarded: false, bool global: false})
: isGuarded = guarded,
isGlobal = global;

View File

@ -25,7 +25,7 @@ class Extender {
final _sources = new Expando<ComplexSelector>();
CssStyleRule addSelector(CssValue<SelectorList> selectorValue,
{FileSpan span}) {
FileSpan span) {
var selector = selectorValue.value;
for (var complex in selector.components) {
for (var component in complex.components) {
@ -38,7 +38,7 @@ class Extender {
}
if (_extensions.isNotEmpty) selector = _extendList(selector, _extensions);
var rule = new CssStyleRule(selectorValue, span: span);
var rule = new CssStyleRule(selectorValue, span);
for (var complex in selector.components) {
for (var component in complex.components) {

View File

@ -53,7 +53,7 @@ class InterpolationBuffer implements StringSink {
Interpolation interpolation([FileSpan span]) {
var contents = _contents.toList();
if (_text.isNotEmpty) contents.add(_text.toString());
return new Interpolation(contents, span: span);
return new Interpolation(contents, span);
}
String toString() => "${_contents.join('')}$_text";

View File

@ -43,7 +43,7 @@ class Parser {
var start = _scanner.state;
var statements = _statements(_topLevelStatement);
_scanner.expectDone();
return new Stylesheet(statements, span: _scanner.spanFrom(start));
return new Stylesheet(statements, _scanner.spanFrom(start));
}
Statement _topLevelStatement() {
@ -92,16 +92,15 @@ class Parser {
_ignoreComments();
}
return new VariableDeclaration(name, expression,
guarded: guarded, global: global, span: _scanner.spanFrom(start));
return new VariableDeclaration(name, expression, _scanner.spanFrom(start),
guarded: guarded, global: global);
}
StyleRule _styleRule() {
var start = _scanner.state;
var selector = _almostAnyValue();
var children = _children(_ruleChild);
return new StyleRule(selector, children,
span: _scanner.spanFrom(start));
return new StyleRule(selector, children, _scanner.spanFrom(start));
}
Statement _ruleChild() {
@ -111,8 +110,7 @@ class Parser {
Expression _declarationExpression() {
if (_scanner.peekChar() == $lbrace) {
return new StringExpression(
new Interpolation([], span: _scanner.emptySpan));
return new StringExpression(new Interpolation([], _scanner.emptySpan));
}
return _expression();
@ -155,7 +153,7 @@ class Parser {
var children = _children(_ruleChild);
return new StyleRule(
buffer.interpolation(_scanner.spanFrom(start)), children,
span: _scanner.spanFrom(start));
_scanner.spanFrom(start));
}
/// Tries to parse a declaration, and returns the value parsed so far if it
@ -195,7 +193,7 @@ class Parser {
if (next != $semicolon && next != $rbrace) {
_scanner.expectChar($semicolon);
}
return new Declaration(name, value: value);
return new Declaration(name, _scanner.spanFrom(start), value: value);
}
if (_scanner.scanChar($colon)) {
@ -204,9 +202,8 @@ class Parser {
var postColonWhitespace = _commentText();
if (_scanner.peekChar() == $lbrace) {
return new Declaration(name,
children: _children(_declarationChild),
span: _scanner.spanFrom(start));
return new Declaration(name, _scanner.spanFrom(start),
children: _children(_declarationChild));
}
midBuffer.write(postColonWhitespace);
@ -241,13 +238,11 @@ class Parser {
return nameBuffer;
}
return new Declaration(
name,
return new Declaration(name, _scanner.spanFrom(start),
value: value,
children: _scanner.peekChar() == $lbrace
? _children(_declarationChild)
: null,
span: _scanner.spanFrom(start));
: null);
}
Declaration _declaration() {
@ -258,19 +253,16 @@ class Parser {
_ignoreComments();
if (_scanner.peekChar() == $lbrace) {
return new Declaration(name,
children: _children(_declarationChild),
span: _scanner.spanFrom(start));
return new Declaration(name, _scanner.spanFrom(start),
children: _children(_declarationChild));
}
var value = _declarationExpression();
return new Declaration(
name,
return new Declaration(name, _scanner.spanFrom(start),
value: value,
children: _scanner.peekChar() == $lbrace
? _children(_declarationChild)
: null,
span: _scanner.spanFrom(start));
: null);
}
Statement _declarationChild() {
@ -340,7 +332,7 @@ class Parser {
Content _content(LineScannerState start) {
if (_inMixin) {
_mixinHasContent = true;
return new Content(span: _scanner.spanFrom(start));
return new Content(_scanner.spanFrom(start));
}
_scanner.error(
@ -351,7 +343,7 @@ class Parser {
}
ExtendRule _extend(LineScannerState start) =>
new ExtendRule(_almostAnyValue(), span: _scanner.spanFrom(start));
new ExtendRule(_almostAnyValue(), _scanner.spanFrom(start));
FunctionDeclaration _functionDeclaration(LineScannerState start) {
var name = _identifier();
@ -368,19 +360,19 @@ class Parser {
var children = _children(_functionAtRule);
// TODO: ensure there aren't duplicate argument names.
return new FunctionDeclaration(name, arguments, children,
span: _scanner.spanFrom(start));
return new FunctionDeclaration(
name, arguments, children, _scanner.spanFrom(start));
}
If _if(LineScannerState start, Statement child()) =>
new If(_expression(), _children(child), span: _scanner.spanFrom(start));
new If(_expression(), _children(child), _scanner.spanFrom(start));
Include _include(LineScannerState start) {
var name = _identifier();
_ignoreComments();
var arguments = _scanner.peekChar() == $lparen
? _argumentInvocation()
: new ArgumentInvocation.empty(span: _scanner.emptySpan);
: new ArgumentInvocation.empty(_scanner.emptySpan);
_ignoreComments();
List<Statement> children;
@ -390,13 +382,12 @@ class Parser {
_inContentBlock = false;
}
return new Include(name, arguments,
children: children, span: _scanner.spanFrom(start));
return new Include(name, arguments, _scanner.spanFrom(start),
children: children);
}
MediaRule _mediaRule(LineScannerState start) =>
new MediaRule(_mediaQueryList(), _children(_ruleChild),
span: _scanner.spanFrom(start));
MediaRule _mediaRule(LineScannerState start) => new MediaRule(
_mediaQueryList(), _children(_ruleChild), _scanner.spanFrom(start));
MixinDeclaration _mixinDeclaration(LineScannerState start) {
var name = _identifier();
@ -417,14 +408,14 @@ class Parser {
var children = _children(_ruleChild);
_inMixin = false;
return new MixinDeclaration(name, arguments, children,
hasContent: _mixinHasContent,
span: _scanner.spanFrom(start));
return new MixinDeclaration(
name, arguments, children, _scanner.spanFrom(start),
hasContent: _mixinHasContent);
}
Return _return(LineScannerState start) {
_ignoreComments();
return new Return(_expression(), span: _scanner.spanFrom(start));
return new Return(_expression(), _scanner.spanFrom(start));
}
AtRule _unknownAtRule(LineScannerState start, String name) {
@ -435,10 +426,9 @@ class Parser {
value = _almostAnyValue();
}
return new AtRule(name,
return new AtRule(name, _scanner.spanFrom(start),
value: value,
children: _scanner.peekChar() == $lbrace ? _children(_ruleChild) : null,
span: _scanner.spanFrom(start));
children: _scanner.peekChar() == $lbrace ? _children(_ruleChild) : null);
}
// This returns [Statement] so that it can be returned within case statements.
@ -472,14 +462,15 @@ class Parser {
break;
}
arguments.add(new Argument(name,
defaultValue: defaultValue, span: _scanner.spanFrom(variableStart)));
arguments.add(new Argument(name, span: _scanner.spanFrom(variableStart),
defaultValue: defaultValue));
if (!_scanner.scanChar($comma)) break;
_ignoreComments();
}
_scanner.expectChar($rparen);
return new ArgumentDeclaration(arguments,
restArgument: restArgument, span: _scanner.spanFrom(start));
restArgument: restArgument,
span: _scanner.spanFrom(start));
}
// ## Expressions
@ -522,8 +513,8 @@ class Parser {
}
_scanner.expectChar($rparen);
return new ArgumentInvocation(positional, named,
rest: rest, keywordRest: keywordRest, span: _scanner.spanFrom(start));
return new ArgumentInvocation(positional, named, _scanner.spanFrom(start),
rest: rest, keywordRest: keywordRest);
}
Expression _expression() {
@ -562,9 +553,9 @@ class Parser {
if (!_scanner.scanChar($comma)) break;
}
return new ListExpression(expressions, ListSeparator.comma,
bracketed: true,
span: _scanner.spanFrom(start));
return new ListExpression(
expressions, ListSeparator.comma,
bracketed: true, span: _scanner.spanFrom(start));
}
Expression _spaceListOrValue() {
@ -632,8 +623,8 @@ class Parser {
_ignoreComments();
if (!_lookingAtExpression()) {
_scanner.expectChar($rparen);
return new ListExpression([], ListSeparator.undecided,
span: _scanner.spanFrom(start));
return new ListExpression(
[], ListSeparator.undecided, span: _scanner.spanFrom(start));
}
var first = _spaceListOrValue();
@ -656,8 +647,8 @@ class Parser {
}
_scanner.expectChar($lparen);
return new ListExpression(expressions, ListSeparator.comma,
span: _scanner.spanFrom(start));
return new ListExpression(
expressions, ListSeparator.comma, span: _scanner.spanFrom(start));
}
MapExpression _map(Expression first, LineScannerState start) {
@ -675,7 +666,7 @@ class Parser {
}
_scanner.expectChar($rparen);
return new MapExpression(pairs, span: _scanner.spanFrom(start));
return new MapExpression(pairs, _scanner.spanFrom(start));
}
UnaryOperatorExpression _unaryOperator() {
@ -688,8 +679,8 @@ class Parser {
_ignoreComments();
var operand = _singleExpression();
return new UnaryOperatorExpression(operator, operand,
span: _scanner.spanFrom(start));
return new UnaryOperatorExpression(
operator, operand, _scanner.spanFrom(start));
}
NumberExpression _number() {
@ -735,13 +726,12 @@ class Parser {
number = number * math.pow(10, exponentSign * exponent);
}
return new NumberExpression(sign * number, span: _scanner.spanFrom(start));
return new NumberExpression(sign * number, _scanner.spanFrom(start));
}
VariableExpression _variable() {
var start = _scanner.state;
return new VariableExpression(_variableName(),
span: _scanner.spanFrom(start));
return new VariableExpression(_variableName(), _scanner.spanFrom(start));
}
StringExpression _string({bool static: false}) {
@ -787,16 +777,14 @@ class Parser {
var first = _scanner.peekChar();
if (first != null && isDigit(first)) {
return new ColorExpression(_hexColorContents(),
span: _scanner.spanFrom(start));
return new ColorExpression(_hexColorContents(), _scanner.spanFrom(start));
}
var afterHash = _scanner.state;
var identifier = _interpolatedIdentifier();
if (_isHexColor(identifier)) {
_scanner.state = afterHash;
return new ColorExpression(_hexColorContents(),
span: _scanner.spanFrom(start));
return new ColorExpression(_hexColorContents(), _scanner.spanFrom(start));
}
var buffer = new InterpolationBuffer();
@ -839,10 +827,10 @@ class Parser {
case "not":
_ignoreComments();
return new UnaryOperatorExpression(
UnaryOperator.not, _singleExpression(), span: identifier.span);
UnaryOperator.not, _singleExpression(), identifier.span);
case "true": return new BooleanExpression(true, span: identifier.span);
case "false": return new BooleanExpression(false, span: identifier.span);
case "true": return new BooleanExpression(true, identifier.span);
case "false": return new BooleanExpression(false, identifier.span);
}
return _scanner.peekChar() == $lparen
@ -1424,8 +1412,7 @@ class Parser {
Interpolation _mediaExpression() {
if (_scanner.peekChar() == $hash) {
var interpolation = _singleInterpolation();
return new Interpolation([interpolation],
span: interpolation.span);
return new Interpolation([interpolation], interpolation.span);
}
var start = _scanner.state;
@ -1484,9 +1471,9 @@ class Parser {
_whitespace();
} while (_scanner.scan("//"));
return new Comment(_scanner.substring(start.position),
silent: true,
span: _scanner.spanFrom(start));
return new Comment(
_scanner.substring(start.position), _scanner.spanFrom(start),
silent: true);
}
Comment _loudComment() {
@ -1496,9 +1483,9 @@ class Parser {
while (_scanner.readChar() != $asterisk) {}
} while (_scanner.readChar() != $slash);
return new Comment(_scanner.substring(start.position),
silent: false,
span: _scanner.spanFrom(start));
return new Comment(
_scanner.substring(start.position), _scanner.spanFrom(start),
silent: false);
}
void _whitespace() {

View File

@ -53,7 +53,7 @@ class PerformVisitor extends StatementVisitor
// ## Statements
CssStylesheet visitStylesheet(Stylesheet node) {
_root = new CssStylesheet(span: node.span);
_root = new CssStylesheet(node.span);
_parent = _root;
super.visitStylesheet(node);
return _root;
@ -61,7 +61,7 @@ class PerformVisitor extends StatementVisitor
void visitComment(Comment node) {
if (node.isSilent) return;
_parent.addChild(new CssComment(node.text, span: node.span));
_parent.addChild(new CssComment(node.text, node.span));
}
void visitContent(Content node) {
@ -78,7 +78,7 @@ class PerformVisitor extends StatementVisitor
void visitDeclaration(Declaration node) {
var name = _interpolationToValue(node.name);
if (_declarationName != null) {
name = new CssValue("$_declarationName-${name.value}", span: name.span);
name = new CssValue("$_declarationName-${name.value}", name.span);
}
var cssValue = node.value == null ? null : _performExpression(node.value);
@ -86,7 +86,7 @@ class PerformVisitor extends StatementVisitor
// will throw an error that we want the user to see.
if (cssValue != null &&
(!cssValue.value.isBlank || cssValue.value is SassList)) {
_parent.addChild(new CssDeclaration(name, cssValue, span: node.span));
_parent.addChild(new CssDeclaration(name, cssValue, node.span));
}
if (node.children != null) {
@ -121,12 +121,12 @@ class PerformVisitor extends StatementVisitor
: _interpolationToValue(node.value, trim: true);
if (node.children == null) {
_parent.addChild(new CssAtRule(node.name,
childless: true, value: value, span: node.span));
_parent.addChild(new CssAtRule(node.name, node.span,
childless: true, value: value));
return;
}
_withParent(new CssAtRule(node.name, value: value, span: node.span), () {
_withParent(new CssAtRule(node.name, node.span, value: value), () {
if (_selector == null) {
super.visitAtRule(node);
} else {
@ -135,7 +135,7 @@ class PerformVisitor extends StatementVisitor
//
// For example, "a {@foo {b: c}}" should produce "@foo {a {b: c}}".
_withParent(
new CssStyleRule(_selector),
new CssStyleRule(_selector, _selector.span),
() => super.visitAtRule(node),
removeIfEmpty: true);
}
@ -197,7 +197,7 @@ class PerformVisitor extends StatementVisitor
: _mergeMediaQueries(_mediaQueries, queryIterable);
if (queries.isEmpty) return;
_withParent(new CssMediaRule(queries, span: node.span), () {
_withParent(new CssMediaRule(queries, node.span), () {
_withMediaQueries(queries, () {
if (_selector == null) {
super.visitMediaRule(node);
@ -208,7 +208,7 @@ class PerformVisitor extends StatementVisitor
// For example, "a {@media screen {b: c}}" should produce
// "@media screen {a {b: c}}".
_withParent(
new CssStyleRule(_selector),
new CssStyleRule(_selector, _selector.span),
() => super.visitMediaRule(node),
removeIfEmpty: true);
}
@ -257,11 +257,11 @@ class PerformVisitor extends StatementVisitor
// TODO: catch errors and re-contextualize them relative to
// [node.selector.span.start].
var selector = new CssValue<SelectorList>(parsedSelector,
span: node.selector.span);
var selector = new CssValue<SelectorList>(
parsedSelector, node.selector.span);
_withParent(
_extender.addSelector(selector, span: node.span),
_extender.addSelector(selector, node.span),
() => _withSelector(selector, () => super.visitStyleRule(node)),
through: (node) => node is CssStyleRule,
removeIfEmpty: true);
@ -523,8 +523,7 @@ class PerformVisitor extends StatementVisitor
CssValue<String> _interpolationToValue(
Interpolation interpolation, {bool trim: false}) {
var result = _performInterpolation(interpolation);
return new CssValue(trim ? result.trim() : result,
span: interpolation.span);
return new CssValue(trim ? result.trim() : result, interpolation.span);
}
String _performInterpolation(Interpolation interpolation) {
@ -535,7 +534,7 @@ class PerformVisitor extends StatementVisitor
}
CssValue<Value> _performExpression(Expression expression) =>
new CssValue(expression.accept(this), span: expression.span);
new CssValue(expression.accept(this), expression.span);
/*=T*/ _withParent/*<S extends CssParentNode, T>*/(
/*=S*/ node, /*=T*/ callback(),