Format Dart files with dartfmt
dartfmt: https://github.com/dart-lang/dart_style
diff --git a/example/call_parser.dart b/example/call_parser.dart
index 3ae5889..c77cf03 100644
--- a/example/call_parser.dart
+++ b/example/call_parser.dart
@@ -41,7 +41,8 @@
'}'
'#div {'
'color : #00F578; border-color: #878787;'
- '}', errors: errors);
+ '}',
+ errors: errors);
if (!errors.isEmpty) {
print("Got ${errors.length} errors.\n");
@@ -55,9 +56,11 @@
// Parse a stylesheet with errors
print('2. Catch severe syntax errors:');
print(' ===========================');
- var stylesheetError = parseCss('.foo #%^&*asdf{ '
+ var stylesheetError = parseCss(
+ '.foo #%^&*asdf{ '
'color: red; left: 20px; top: 20px; width: 100px; height:200px'
- '}', errors: errors);
+ '}',
+ errors: errors);
if (!errors.isEmpty) {
print("Got ${errors.length} errors.\n");
diff --git a/lib/css.dart b/lib/css.dart
index 65d386d..a6539cf 100644
--- a/lib/css.dart
+++ b/lib/css.dart
@@ -76,8 +76,6 @@
buf.write(' -- ');
if (duration < 10) buf.write(' ');
if (duration < 100) buf.write(' ');
- buf
- ..write(duration)
- ..write(' ms');
+ buf..write(duration)..write(' ms');
print(buf.toString());
}
diff --git a/lib/parser.dart b/lib/parser.dart
index d1a5af1..66e5abc 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -47,8 +47,12 @@
// TODO(terry): Remove nested name parameter.
/** Parse and analyze the CSS file. */
-StyleSheet compile(input, {List<Message> errors, PreprocessorOptions options,
- bool nested: true, bool polyfill: false, List<StyleSheet> includes: null}) {
+StyleSheet compile(input,
+ {List<Message> errors,
+ PreprocessorOptions options,
+ bool nested: true,
+ bool polyfill: false,
+ List<StyleSheet> includes: null}) {
if (includes == null) {
includes = [];
}
@@ -115,9 +119,10 @@
var file = new SourceFile(source);
return (new _Parser(file, source)
- // TODO(jmesserly): this fix should be applied to the parser. It's tricky
- // because by the time the flag is set one token has already been fetched.
- ..tokenizer.inSelector = true).processSelectorGroup();
+ // TODO(jmesserly): this fix should be applied to the parser. It's tricky
+ // because by the time the flag is set one token has already been fetched.
+ ..tokenizer.inSelector = true)
+ .processSelectorGroup();
}
String _inputAsString(input) {
@@ -2266,8 +2271,8 @@
}
var param = expr.expressions[0];
- var varUsage = new VarUsage(
- (param as LiteralTerm).text, [], _makeSpan(start));
+ var varUsage =
+ new VarUsage((param as LiteralTerm).text, [], _makeSpan(start));
expr.expressions[0] = varUsage;
return expr.expressions;
}
@@ -2465,8 +2470,7 @@
var token = _peek();
if (token == TokenKind.LPAREN)
left++;
- else if (token == TokenKind.RPAREN)
- left--;
+ else if (token == TokenKind.RPAREN) left--;
matchingParens = left == 0;
if (!matchingParens) stringValue.write(_next().text);
@@ -2544,7 +2548,8 @@
// [0] - var name, [1] - OperatorComma, [2] - default value.
var defaultValues = expr.expressions.length >= 3
- ? expr.expressions.sublist(2) : <Expression>[];
+ ? expr.expressions.sublist(2)
+ : <Expression>[];
return new VarUsage(paramName, defaultValues, _makeSpan(start));
default:
var expr = processExpr();
diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart
index 4d3e3c8..7c7372c 100644
--- a/lib/src/analyzer.dart
+++ b/lib/src/analyzer.dart
@@ -262,7 +262,6 @@
List<SimpleSelectorSequence> _mergeNestedSelector(
List<SimpleSelectorSequence> parent,
List<SimpleSelectorSequence> current) {
-
// If any & operator then the parent selector will be substituted otherwise
// the parent selector is pre-pended to the current selector.
var hasThis = current.any((s) => s.simpleSelector.isThis);
@@ -746,8 +745,8 @@
if (!_allIncludes(mixinDef.rulesets) && currDeclGroup != null) {
var index = _findInclude(currDeclGroup.declarations, node);
if (index != -1) {
- currDeclGroup.declarations.replaceRange(
- index, index + 1, [new NoOp()]);
+ currDeclGroup.declarations
+ .replaceRange(index, index + 1, [new NoOp()]);
}
_messages.warning(
"Using top-level mixin ${node.include.name} as a declaration",
diff --git a/lib/src/messages.dart b/lib/src/messages.dart
index 595bf6c..420c243 100644
--- a/lib/src/messages.dart
+++ b/lib/src/messages.dart
@@ -55,9 +55,7 @@
bool colors = useColors && _ERROR_COLORS.containsKey(level);
var levelColor = colors ? _ERROR_COLORS[level] : null;
if (colors) output.write(levelColor);
- output
- ..write(_ERROR_LABEL[level])
- ..write(' ');
+ output..write(_ERROR_LABEL[level])..write(' ');
if (colors) output.write(NO_COLOR);
if (span == null) {
diff --git a/lib/src/options.dart b/lib/src/options.dart
index 95e8a2f..c80370b 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -40,10 +40,16 @@
/** File to process by the compiler. */
final String inputFile;
- const PreprocessorOptions({this.verbose: false, this.checked: false,
- this.lessSupport: true, this.warningsAsErrors: false,
- this.throwOnErrors: false, this.throwOnWarnings: false,
- this.useColors: true, this.polyfill: false, this.inputFile});
+ const PreprocessorOptions(
+ {this.verbose: false,
+ this.checked: false,
+ this.lessSupport: true,
+ this.warningsAsErrors: false,
+ this.throwOnErrors: false,
+ this.throwOnWarnings: false,
+ this.useColors: true,
+ this.polyfill: false,
+ this.inputFile});
PreprocessorOptions.fromArgs(ArgResults args)
: warningsAsErrors = args['warnings_as_errors'],
diff --git a/lib/src/polyfill.dart b/lib/src/polyfill.dart
index 69f9e6d..9bdcbe2 100644
--- a/lib/src/polyfill.dart
+++ b/lib/src/polyfill.dart
@@ -40,14 +40,17 @@
void processVarDefinitions(List<StyleSheet> includes) {
for (var include in includes) {
_allVarDefinitions = (new _VarDefinitionsIncludes(_allVarDefinitions)
- ..visitTree(include)).varDefs;
+ ..visitTree(include))
+ .varDefs;
}
}
void processVars(StyleSheet styleSheet) {
// Build list of all var definitions.
- var mainStyleSheetVarDefs = (new _VarDefAndUsage(
- this._messages, _allVarDefinitions)..visitTree(styleSheet)).varDefs;
+ var mainStyleSheetVarDefs =
+ (new _VarDefAndUsage(this._messages, _allVarDefinitions)
+ ..visitTree(styleSheet))
+ .varDefs;
// Resolve all definitions to a non-VarUsage (terminal expression).
mainStyleSheetVarDefs.forEach((key, value) {
diff --git a/lib/src/property.dart b/lib/src/property.dart
index b4beaee..2cc39fa 100644
--- a/lib/src/property.dart
+++ b/lib/src/property.dart
@@ -79,9 +79,11 @@
* components.
*/
Color.createRgba(int red, int green, int blue, [num alpha])
- : this._argb = Color.convertToHexString(Color._clamp(red, 0, 255),
- Color._clamp(green, 0, 255), Color._clamp(blue, 0, 255),
- alpha != null ? Color._clamp(alpha, 0, 1) : alpha);
+ : this._argb = Color.convertToHexString(
+ Color._clamp(red, 0, 255),
+ Color._clamp(green, 0, 255),
+ Color._clamp(blue, 0, 255),
+ alpha != null ? Color._clamp(alpha, 0, 1) : alpha);
/**
* Creates a new color from a CSS color string. For more information, see
@@ -105,10 +107,12 @@
*/
Color.createHsla(num hueDegree, num saturationPercent, num lightnessPercent,
[num alpha])
- : this._argb = new Hsla(Color._clamp(hueDegree, 0, 360) / 360,
- Color._clamp(saturationPercent, 0, 100) / 100,
- Color._clamp(lightnessPercent, 0, 100) / 100,
- alpha != null ? Color._clamp(alpha, 0, 1) : alpha).toHexArgbString();
+ : this._argb = new Hsla(
+ Color._clamp(hueDegree, 0, 360) / 360,
+ Color._clamp(saturationPercent, 0, 100) / 100,
+ Color._clamp(lightnessPercent, 0, 100) / 100,
+ alpha != null ? Color._clamp(alpha, 0, 1) : alpha)
+ .toHexArgbString();
/**
* The hslaRaw takes three values. The [hue] degree on the color wheel; '0'
@@ -126,9 +130,12 @@
* opaque foreground.
*/
Color.hslaRaw(num hue, num saturation, num lightness, [num alpha])
- : this._argb = new Hsla(Color._clamp(hue, 0, 1),
- Color._clamp(saturation, 0, 1), Color._clamp(lightness, 0, 1),
- alpha != null ? Color._clamp(alpha, 0, 1) : alpha).toHexArgbString();
+ : this._argb = new Hsla(
+ Color._clamp(hue, 0, 1),
+ Color._clamp(saturation, 0, 1),
+ Color._clamp(lightness, 0, 1),
+ alpha != null ? Color._clamp(alpha, 0, 1) : alpha)
+ .toHexArgbString();
/**
* Generate a real constant for pre-defined colors (no leading #).
@@ -529,9 +536,13 @@
factory Rgba.fromColor(Color color) => color.rgba;
factory Rgba.fromArgbValue(num value) {
- return new Rgba(((value.toInt() & 0xff000000) >> 0x18), /* a */
- ((value.toInt() & 0xff0000) >> 0x10), /* r */
- ((value.toInt() & 0xff00) >> 8), /* g */
+ return new Rgba(
+ ((value.toInt() & 0xff000000) >> 0x18),
+ /* a */
+ ((value.toInt() & 0xff0000) >> 0x10),
+ /* r */
+ ((value.toInt() & 0xff00) >> 8),
+ /* g */
((value.toInt() & 0xff))); /* b */
}
@@ -1029,7 +1040,12 @@
* [FontVariant], and [lineHeight] extra space (leading) around the font in
* pixels, if not specified it's 1.2 the font size.
*/
- const Font({this.size, this.family, this.weight, this.style, this.variant,
+ const Font(
+ {this.size,
+ this.family,
+ this.weight,
+ this.style,
+ this.variant,
this.lineHeight});
/**
diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart
index a972590..063ac34 100644
--- a/lib/src/tokenizer.dart
+++ b/lib/src/tokenizer.dart
@@ -445,7 +445,9 @@
// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
// http://www.w3.org/TR/CSS21/syndata.html#characters
// Also, escaped character should be allowed.
- c == 95 /*_*/ || c >= 0xA0 || c == 92 /*\*/);
+ c == 95 /*_*/ ||
+ c >= 0xA0 ||
+ c == 92 /*\*/);
}
/** Pseudo function expressions identifiers can't have a minus sign. */
diff --git a/lib/src/tokenizer_base.dart b/lib/src/tokenizer_base.dart
index 663c987..ccdd7be 100644
--- a/lib/src/tokenizer_base.dart
+++ b/lib/src/tokenizer_base.dart
@@ -55,8 +55,7 @@
int _index = 0;
int _startIndex = 0;
- TokenizerBase(this._file, this._text, this._inString,
- [this._index = 0]);
+ TokenizerBase(this._file, this._text, this._inString, [this._index = 0]);
Token next();
int getIdentifierKind();
diff --git a/lib/src/tree.dart b/lib/src/tree.dart
index c187903..a6a64fc 100644
--- a/lib/src/tree.dart
+++ b/lib/src/tree.dart
@@ -489,6 +489,7 @@
}
return new MediaQuery(_mediaUnary, _mediaType, cloneExpressions, span);
}
+
visit(VisitorBase visitor) => visitor.visitMediaQuery(this);
}
@@ -599,6 +600,7 @@
}
return new KeyFrameDirective(_keyframeName, cloneBlocks, span);
}
+
visit(VisitorBase visitor) => visitor.visitKeyFrameDirective(this);
}
@@ -696,8 +698,8 @@
class MixinRulesetDirective extends MixinDefinition {
final List<TreeNode> rulesets;
- MixinRulesetDirective(String name, List<TreeNode> args,
- bool varArgs, this.rulesets, SourceSpan span)
+ MixinRulesetDirective(String name, List<TreeNode> args, bool varArgs,
+ this.rulesets, SourceSpan span)
: super(name, args, varArgs, span);
MixinRulesetDirective clone() {
@@ -719,8 +721,8 @@
class MixinDeclarationDirective extends MixinDefinition {
final DeclarationGroup declarations;
- MixinDeclarationDirective(String name, List<TreeNode> args,
- bool varArgs, this.declarations, SourceSpan span)
+ MixinDeclarationDirective(String name, List<TreeNode> args, bool varArgs,
+ this.declarations, SourceSpan span)
: super(name, args, varArgs, span);
MixinDeclarationDirective clone() {
@@ -788,9 +790,9 @@
bool get hasDartStyle => dartStyle != null;
- Declaration clone() => new Declaration(
- _property.clone(), _expression.clone(), dartStyle, span,
- important: important);
+ Declaration clone() =>
+ new Declaration(_property.clone(), _expression.clone(), dartStyle, span,
+ important: important);
visit(VisitorBase visitor) => visitor.visitDeclaration(this);
}
@@ -1163,6 +1165,7 @@
}
return clonedExprs;
}
+
visit(VisitorBase visitor) => visitor.visitExpressions(this);
}
@@ -1229,15 +1232,20 @@
// font-style font-variant font-weight font-size/line-height font-family
// TODO(terry): Only px/pt for now need to handle all possible units to
// support calc expressions on units.
- FontExpression(SourceSpan span, {dynamic size, List<String> family,
- int weight, String style, String variant, LineHeight lineHeight})
+ FontExpression(SourceSpan span,
+ {dynamic size,
+ List<String> family,
+ int weight,
+ String style,
+ String variant,
+ LineHeight lineHeight})
: font = new Font(
- size: size is LengthTerm ? size.value : size,
- family: family,
- weight: weight,
- style: style,
- variant: variant,
- lineHeight: lineHeight),
+ size: size is LengthTerm ? size.value : size,
+ family: family,
+ weight: weight,
+ style: style,
+ variant: variant,
+ lineHeight: lineHeight),
super(DartStyleExpression.fontStyle, span);
FontExpression merged(DartStyleExpression newFontExpr) {
@@ -1295,7 +1303,7 @@
/** Margin expression ripped apart. */
MarginExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.marginStyle, span,
- new BoxEdge(left, top, right, bottom));
+ new BoxEdge(left, top, right, bottom));
MarginExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.marginStyle, span, box);
@@ -1331,7 +1339,7 @@
/** Border expression ripped apart. */
BorderExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.borderStyle, span,
- new BoxEdge(left, top, right, bottom));
+ new BoxEdge(left, top, right, bottom));
BorderExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.borderStyle, span, box);
@@ -1356,7 +1364,7 @@
BorderExpression._merge(
BorderExpression x, BorderExpression y, SourceSpan span)
: super(DartStyleExpression.borderStyle, span,
- new BoxEdge.merge(x.box, y.box));
+ new BoxEdge.merge(x.box, y.box));
BorderExpression clone() => new BorderExpression(span,
top: box.top, right: box.right, bottom: box.bottom, left: box.left);
@@ -1408,7 +1416,7 @@
/** Padding expression ripped apart. */
PaddingExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.paddingStyle, span,
- new BoxEdge(left, top, right, bottom));
+ new BoxEdge(left, top, right, bottom));
PaddingExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.paddingStyle, span, box);
@@ -1433,7 +1441,7 @@
PaddingExpression._merge(
PaddingExpression x, PaddingExpression y, SourceSpan span)
: super(DartStyleExpression.paddingStyle, span,
- new BoxEdge.merge(x.box, y.box));
+ new BoxEdge.merge(x.box, y.box));
PaddingExpression clone() => new PaddingExpression(span,
top: box.top, right: box.right, bottom: box.bottom, left: box.left);
diff --git a/lib/src/tree_base.dart b/lib/src/tree_base.dart
index 51207e1..3ead0bf 100644
--- a/lib/src/tree_base.dart
+++ b/lib/src/tree_base.dart
@@ -59,16 +59,21 @@
}
String toValue(value) {
- if (value == null) return 'null';
- else if (value is Identifier) return value.name;
- else return value.toString();
+ if (value == null)
+ return 'null';
+ else if (value is Identifier)
+ return value.name;
+ else
+ return value.toString();
}
void writeNode(String label, TreeNode node) {
write('${label}: ');
depth += 1;
- if (node != null) node.visit(printer);
- else writeln('null');
+ if (node != null)
+ node.visit(printer);
+ else
+ writeln('null');
depth -= 1;
}
diff --git a/lib/visitor.dart b/lib/visitor.dart
index b6babbd..1123493 100644
--- a/lib/visitor.dart
+++ b/lib/visitor.dart
@@ -302,8 +302,7 @@
visitPseudoElementFunctionSelector(PseudoElementFunctionSelector node) =>
visitSimpleSelector(node);
- visitNegationSelector(NegationSelector node) =>
- visitSimpleSelector(node);
+ visitNegationSelector(NegationSelector node) => visitSimpleSelector(node);
visitSelectorExpression(SelectorExpression node) {
_visitNodeList(node.expressions);
diff --git a/test/compiler_test.dart b/test/compiler_test.dart
index 5faabe2..e64af7f 100644
--- a/test/compiler_test.dart
+++ b/test/compiler_test.dart
@@ -533,7 +533,9 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foo {
color: #f00;
left: 20px;
@@ -595,7 +597,9 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
html:lang(fr-ca) {
quotes: '" ' ' "';
}
@@ -665,7 +669,9 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
@host {
:scope {
white-space: nowrap;
@@ -691,7 +697,9 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
a {
foo: '{"text" : "a\\\""}';
}''');
@@ -713,7 +721,9 @@
walkTree(stylesheet);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foo {
color: #f00;
left: 20px;
diff --git a/test/error_test.dart b/test/error_test.dart
index 9815b1b..1060d83 100644
--- a/test/error_test.dart
+++ b/test/error_test.dart
@@ -21,13 +21,17 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unknown property value bolder
.foobar { font-weight: bolder; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
font-weight: bolder;
}''');
@@ -38,12 +42,16 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unknown property value lighter
.foobar { font-weight: lighter; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
font-weight: lighter;
}''');
@@ -54,12 +62,16 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unknown property value inherit
.foobar { font-weight: inherit; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
font-weight: inherit;
}''');
@@ -77,12 +89,16 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unexpected value for line-height
.foobar { line-height: 120%; }
^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
line-height: 120%;
}''');
@@ -93,12 +109,16 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unexpected unit for line-height
.foobar { line-height: 20cm; }
^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
line-height: 20cm;
}''');
@@ -109,12 +129,16 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 24: Unknown property value inherit
.foobar { line-height: inherit; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
line-height: inherit;
}''');
@@ -129,12 +153,16 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 1: Not a valid ID selector expected #id
# foo { color: #ff00ff; }
^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
# foo {
color: #f0f;
}''');
@@ -144,12 +172,16 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 1: Not a valid class selector expected .className
. foo { color: #ff00ff; }
^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
. foo {
color: #f0f;
}''');
@@ -164,12 +196,16 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 18: Bad hex number
.foobar { color: #AH787; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
color: #AH787;
}''');
@@ -179,13 +215,17 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 18: Unknown property value redder
.foobar { color: redder; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
color: redder;
}''');
@@ -195,13 +235,17 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 18: Expected hex number
.foobar { color: # ffffff; }
^''');
expect(stylesheet != null, true);
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
color: # ffffff;
}''');
@@ -211,7 +255,9 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(), r'''
+ expect(
+ errors[0].toString(),
+ r'''
error on line 1, column 18: Expected hex number
.foobar { color: # 123fff; }
^''');
@@ -220,7 +266,9 @@
// Formating is off with an extra space. However, the entire value is bad
// and isn't processed anyway.
- expect(prettyPrint(stylesheet), r'''
+ expect(
+ prettyPrint(stylesheet),
+ r'''
.foobar {
color: # 123 fff;
}''');
@@ -237,7 +285,8 @@
parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(),
+ expect(
+ errors[0].toString(),
'error on line 3, column 20: unicode first range can not be greater than '
'last\n'
' unicode-range: U+400-200;\n'
@@ -252,7 +301,8 @@
parseCss(input2, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(errors[0].toString(),
+ expect(
+ errors[0].toString(),
'error on line 3, column 20: unicode range must be less than 10FFFF\n'
' unicode-range: U+12FFFF;\n'
' ^^^^^^');
diff --git a/test/extend_test.dart b/test/extend_test.dart
index afec062..184a8b4 100644
--- a/test/extend_test.dart
+++ b/test/extend_test.dart
@@ -18,7 +18,8 @@
}
void simpleExtend() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.error {
border: 1px red;
background-color: #fdd;
@@ -27,7 +28,9 @@
@extend .error;
border-width: 3px;
}
-''', r'''.error, .seriousError {
+''',
+ r'''
+.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
}
@@ -37,7 +40,8 @@
}
void complexSelectors() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -49,7 +53,9 @@
@extend .error;
border-width: 3px;
}
-''', r'''.error, .seriousError {
+''',
+ r'''
+.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
}
@@ -60,14 +66,17 @@
border-width: 3px;
}''');
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
a:hover {
text-decoration: underline;
}
.hoverlink {
@extend a:hover;
}
-''', r'''a:hover, .hoverlink {
+''',
+ r'''
+a:hover, .hoverlink {
text-decoration: underline;
}
.hoverlink {
@@ -75,7 +84,8 @@
}
void multipleExtends() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -89,7 +99,9 @@
@extend .attention;
border-width: 3px;
}
-''', r'''.error, .seriousError {
+''',
+ r'''
+.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
}
@@ -103,7 +115,8 @@
}
void chaining() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -120,7 +133,9 @@
left: 10%;
right: 10%;
}
-''', r'''.error, .seriousError, .criticalError {
+''',
+ r'''
+.error, .seriousError, .criticalError {
border: 1px #f00;
background-color: #fdd;
}
@@ -137,7 +152,8 @@
}
void nestedSelectors() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
a {
color: blue;
&:hover {
@@ -148,7 +164,9 @@
#fake-links .link {
@extend a;
}
-''', r'''a, #fake-links .link {
+''',
+ r'''
+a, #fake-links .link {
color: #00f;
}
a:hover, #fake-links .link:hover {
@@ -159,7 +177,8 @@
}
void nestedMulty() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.btn {
display: inline-block;
}
@@ -171,7 +190,9 @@
@extend .btn;
}
}
-''', r'''.btn, input[type="checkbox"].toggle-button label {
+''',
+ r'''
+.btn, input[type="checkbox"].toggle-button label {
display: inline-block;
}
input[type="checkbox"].toggle-button {
@@ -182,14 +203,16 @@
}
void nWayExtends() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.btn > .btn {
margin-left: 5px;
}
input.second + label {
@extend .btn;
}
-''', '.btn > .btn, '
+''',
+ '.btn > .btn, '
'input.second + label > .btn, '
'.btn > input.second + label, '
'input.second + label > input.second + label, '
@@ -206,7 +229,8 @@
// input.second + label {
// color: blue;
// }
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
.btn + .btn {
margin-left: 5px;
}
@@ -214,7 +238,8 @@
@extend .btn;
color: blue;
}
-''', '.btn + .btn, '
+''',
+ '.btn + .btn, '
'input.second + label + .btn, '
'.btn + input.second + label, '
'input.second + label + input.second + label, '
diff --git a/test/mixin_test.dart b/test/mixin_test.dart
index 71dcc50..375054c 100644
--- a/test/mixin_test.dart
+++ b/test/mixin_test.dart
@@ -26,7 +26,8 @@
}
void topLevelMixin() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin silly-links {
a {
color: blue;
@@ -35,14 +36,17 @@
}
@include silly-links;
-''', r'''a {
+''',
+ r'''
+a {
color: #00f;
background-color: #f00;
}''');
}
void topLevelMixinTwoIncludes() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
a {
color: blue;
@@ -57,7 +61,9 @@
}
@include a;
@include b;
-''', r'''a {
+''',
+ r'''
+a {
color: #00f;
background-color: #f00;
}
@@ -69,7 +75,8 @@
/** Tests top-level mixins that includes another mixin. */
void topLevelMixinMultiRulesets() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
a {
color: blue;
@@ -91,7 +98,9 @@
}
@include a;
@include c;
-''', r'''a {
+''',
+ r'''
+a {
color: #00f;
background-color: #f00;
}
@@ -106,7 +115,8 @@
}
void topLevelMixinDeeplyNestedRulesets() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
a {
color: blue;
@@ -146,7 +156,9 @@
@include d;
}
@include c;
-''', r'''a {
+''',
+ r'''
+a {
color: #00f;
background-color: #f00;
}
@@ -171,7 +183,8 @@
/** Tests selector groups and other combinators. */
void topLevelMixinSelectors() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
a, b {
color: blue;
@@ -184,7 +197,9 @@
}
@include a;
-''', r'''a, b {
+''',
+ r'''
+a, b {
color: #00f;
background-color: #f00;
}
@@ -195,20 +210,24 @@
}
void declSimpleMixin() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin div-border {
border: 2px dashed red;
}
div {
@include div-border;
}
-''', r'''div {
+''',
+ r'''
+div {
border: 2px dashed #f00;
}''');
}
void declMixinTwoIncludes() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -219,14 +238,17 @@
@include div-border;
@include div-color;
}
-''', r'''div {
+''',
+ r'''
+div {
border: 2px dashed #f00;
color: #00f;
}''');
}
void declMixinNestedIncludes() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -245,7 +267,9 @@
@include div-border;
@include div-color;
}
-''', r'''div {
+''',
+ r'''
+div {
border: 2px dashed #f00;
padding: .5em;
color: #00f;
@@ -254,7 +278,8 @@
}
void declMixinDeeperNestedIncludes() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -272,7 +297,9 @@
@include div-border;
@include div-color;
}
-''', r'''div {
+''',
+ r'''
+div {
border: 2px dashed #f00;
padding: .5em;
margin: 5px;
@@ -280,7 +307,8 @@
}
void mixinArg() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin div-border-1 {
border: 2px dashed red;
}
@@ -309,7 +337,9 @@
div-4 {
@include div-border-2;
}
-''', r'''div-1 {
+''',
+ r'''
+div-1 {
margin-left: 10px;
margin-right: 100px;
border: 2px dashed #f00;
@@ -328,7 +358,8 @@
}
void mixinArgs() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin box-shadow(@shadows...) {
-moz-box-shadow: @shadows;
-webkit-box-shadow: @shadows;
@@ -337,7 +368,8 @@
.shadows {
@include box-shadow(0px 4px 5px #666, 2px 6px 10px #999);
-}''', r'''
+}''',
+ r'''
.shadowed {
-moz-box-shadow: 0px 4px 5px #666, 2px 6px 10px #999;
-webkit-box-shadow: 0px 4px 5px #666, 2px 6px 10px #999;
@@ -347,7 +379,8 @@
}
void mixinManyArgs() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin border(@border-values) {
border: @border-values
}
@@ -355,12 +388,14 @@
.primary {
@include border(3px solid green);
}
-''', r'''
+''',
+ r'''
.primary {
border: 3px solid #008000;
}''');
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin setup(@border-color, @border-style, @border-size, @color) {
border: @border-size @border-style @border-color;
color: @color;
@@ -369,14 +404,16 @@
.primary {
@include setup(red, solid, 5px, blue);
}
-''', r'''
+''',
+ r'''
.primary {
border: 5px solid #f00;
color: #00f;
}''');
// Test passing a declaration that is multiple parameters.
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin colors(@text, @background, @border) {
color: @text;
background-color: @background;
@@ -387,7 +424,9 @@
.primary {
@include colors(@values);
}
-''', r'''var-values: #f00, #0f0, #00f;
+''',
+ r'''
+var-values: #f00, #0f0, #00f;
.primary {
color: #f00;
@@ -395,7 +434,8 @@
border-color: #00f;
}''');
- compilePolyfillAndValidate(r'''
+ compilePolyfillAndValidate(
+ r'''
@mixin colors(@text, @background, @border) {
color: @text;
background-color: @background;
@@ -406,7 +446,9 @@
.primary {
@include colors(@values);
}
-''', r'''.primary {
+''',
+ r'''
+.primary {
color: #f00;
background-color: #0f0;
border-color: #00f;
@@ -481,7 +523,8 @@
}
''';
- var generated = r'''div {
+ var generated = r'''
+div {
border: 2px dashed #f00;
}''';
@@ -547,7 +590,8 @@
}
void includeGrammar() {
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
foo { color: red }
}
@@ -558,14 +602,17 @@
}
@include b;
-''', r'''foo {
+''',
+ r'''
+foo {
color: #f00;
}
foo {
color: #f00;
}''');
- compileAndValidate(r'''
+ compileAndValidate(
+ r'''
@mixin a {
color: red
}
@@ -574,7 +621,9 @@
@include a;
@include a
}
-''', r'''foo {
+''',
+ r'''
+foo {
color: #f00;
color: #f00;
}''');
diff --git a/test/selector_test.dart b/test/selector_test.dart
index 6249d31..dff4415 100644
--- a/test/selector_test.dart
+++ b/test/selector_test.dart
@@ -56,7 +56,8 @@
// Test for invalid class name (can't start with number).
selector('.foobar .1a-story .xyzzy', errors: errors);
expect(errors.isEmpty, false);
- expect(errors[0].toString(),
+ expect(
+ errors[0].toString(),
'error on line 1, column 9: name must start with a alpha character, but '
'found a number\n'
'.foobar .1a-story .xyzzy\n'
diff --git a/test/testing.dart b/test/testing.dart
index de2aab1..6807576 100644
--- a/test/testing.dart
+++ b/test/testing.dart
@@ -30,24 +30,26 @@
* tests (by default) will ensure that the CSS is really valid.
*/
StyleSheet parseCss(String cssInput,
- {List<Message> errors, PreprocessorOptions opts}) => parse(cssInput,
+ {List<Message> errors, PreprocessorOptions opts}) =>
+ parse(cssInput,
errors: errors,
- options: opts == null
- ? simpleOptionsWithCheckedAndWarningsAsErrors
- : opts);
+ options:
+ opts == null ? simpleOptionsWithCheckedAndWarningsAsErrors : opts);
/**
* Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
* CSS will allow any property/value pairs regardless of validity; all of our
* tests (by default) will ensure that the CSS is really valid.
*/
-StyleSheet compileCss(String cssInput, {List<Message> errors,
- PreprocessorOptions opts, bool polyfill: false,
- List<StyleSheet> includes: null}) => compile(cssInput,
+StyleSheet compileCss(String cssInput,
+ {List<Message> errors,
+ PreprocessorOptions opts,
+ bool polyfill: false,
+ List<StyleSheet> includes: null}) =>
+ compile(cssInput,
errors: errors,
- options: opts == null
- ? simpleOptionsWithCheckedAndWarningsAsErrors
- : opts,
+ options:
+ opts == null ? simpleOptionsWithCheckedAndWarningsAsErrors : opts,
polyfill: polyfill,
includes: includes);
diff --git a/test/var_test.dart b/test/var_test.dart
index c75de56..3c53169 100644
--- a/test/var_test.dart
+++ b/test/var_test.dart
@@ -26,7 +26,8 @@
}
void simpleVar() {
- final input = ''':root {
+ final input = '''
+:root {
var-color-background: red;
var-color-foreground: blue;
@@ -40,7 +41,8 @@
}
''';
- final generated = ''':root {
+ final generated = '''
+:root {
var-color-background: #f00;
var-color-foreground: #00f;
var-c: #0f0;
@@ -52,7 +54,8 @@
background: var(color-background);
}''';
- final generatedPolyfill = ''':root {
+ final generatedPolyfill = '''
+:root {
}
.testIt {
color: #00f;
@@ -64,7 +67,8 @@
}
void expressionsVar() {
- final input = ''':root {
+ final input = '''
+:root {
var-color-background: red;
var-color-foreground: blue;
@@ -129,7 +133,8 @@
}
''';
- final generated = ''':root {
+ final generated = '''
+:root {
var-color-background: #f00;
var-color-foreground: #00f;
var-c: #0f0;
@@ -186,7 +191,8 @@
compileAndValidate(input, generated);
- var generatedPolyfill = r''':root {
+ var generatedPolyfill = r'''
+:root {
}
.testIt {
color: #00f;
@@ -272,7 +278,8 @@
}
''';
- final generated = ''':root {
+ final generated = '''
+:root {
var-color-background: #f00;
var-color-foreground: #00f;
var-a: var(b, #0a0);
@@ -310,7 +317,8 @@
compileAndValidate(input, generated);
- var generatedPolyfill = r''':root {
+ var generatedPolyfill = r'''
+:root {
}
.test {
background-color: #ffa500;
@@ -342,7 +350,8 @@
void undefinedVars() {
final errors = <Message>[];
- final input = ''':root {
+ final input = '''
+:root {
var-color-background: red;
var-color-foreground: blue;
@@ -375,7 +384,8 @@
}
''';
- final generatedPolyfill = ''':root {
+ final generatedPolyfill = '''
+:root {
}
.testIt {
color: #00f;
@@ -413,7 +423,8 @@
' ^^^^^^',
];
- var generated = r''':root {
+ var generated = r'''
+:root {
var-color-background: #f00;
var-color-foreground: #00f;
var-a: var(b);
@@ -451,7 +462,8 @@
expect(errors.length, errorStrings.length, reason: errors.toString());
testBitMap = 0;
- outer: for (var error in errors) {
+ outer:
+ for (var error in errors) {
var errorString = error.toString();
for (int i = 0; i < errorStrings.length; i++) {
if (errorString == errorStrings[i]) {
@@ -466,7 +478,8 @@
}
parserVar() {
- final input = ''':root {
+ final input = '''
+:root {
var-color-background: red;
var-color-foreground: blue;
@@ -531,7 +544,8 @@
}
''';
- final generated = ''':root {
+ final generated = '''
+:root {
var-color-background: #f00;
var-color-foreground: #00f;
var-c: #0f0;
@@ -588,7 +602,8 @@
compileAndValidate(input, generated);
- var generatedPolyfill = r''':root {
+ var generatedPolyfill = r'''
+:root {
}
.testIt {
color: #00f;
@@ -659,7 +674,8 @@
color: @color-foreground;
}
''';
- final generated2 = '''var-color-background: #f00;
+ final generated2 = '''
+var-color-background: #f00;
var-color-foreground: #00f;
.test {
@@ -687,7 +703,8 @@
color: var(color-foreground);
}
''';
- final generated = '''var-color-background: #f00;
+ final generated = '''
+var-color-background: #f00;
var-color-foreground: #00f;
.test {
@@ -712,7 +729,8 @@
color: @color-foreground;
}
''';
- final generated2 = '''var-color-background: #f00;
+ final generated2 = '''
+var-color-background: #f00;
var-color-foreground: #00f;
.test {
@@ -730,20 +748,24 @@
}
void polyfill() {
- compilePolyfillAndValidate(r'''
+ compilePolyfillAndValidate(
+ r'''
@color-background: red;
@color-foreground: blue;
.test {
background-color: @color-background;
color: @color-foreground;
-}''', r'''.test {
+}''',
+ r'''
+.test {
background-color: #f00;
color: #00f;
}''');
}
void testIndirects() {
- compilePolyfillAndValidate('''
+ compilePolyfillAndValidate(
+ '''
:root {
var-redef: #0f0;
@@ -760,7 +782,9 @@
}
.test-1 {
color: @redef;
-}''', r''':root {
+}''',
+ r'''
+:root {
}
.test {
background-color: #fff;
@@ -817,7 +841,8 @@
}
''';
- var generated1 = r''':root {
+ var generated1 = r'''
+:root {
var-redef: #0f0;
var-a1: #fff;
var-a2: var(a1);
@@ -838,7 +863,8 @@
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(stylesheet1), generated1);
- var generated2 = r''':root {
+ var generated2 = r'''
+:root {
var-redef: #0b0;
var-b3: var(a3);
}
@@ -854,7 +880,8 @@
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(stylesheet2), generated2);
- var generatedPolyfill1 = r''':root {
+ var generatedPolyfill1 = r'''
+:root {
}
.test-1 {
background-color: #fff;
@@ -870,7 +897,8 @@
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(styleSheet1Polyfill), generatedPolyfill1);
- var generatedPolyfill2 = r''':root {
+ var generatedPolyfill2 = r'''
+:root {
}
.test-2 {
color: #fff;
@@ -889,7 +917,8 @@
// Make sure includes didn't change.
expect(prettyPrint(stylesheet1), generated1);
- var generatedPolyfill = r''':root {
+ var generatedPolyfill = r'''
+:root {
}
.test-main {
color: #fff;
diff --git a/test/visitor_test.dart b/test/visitor_test.dart
index 02784c4..16071c7 100644
--- a/test/visitor_test.dart
+++ b/test/visitor_test.dart
@@ -60,7 +60,9 @@
..visitTree(s);
expect(clsVisits.matches, true);
- expect(prettyPrint(s), r'''
+ expect(
+ prettyPrint(s),
+ r'''
.foobar1 {
}
.xyzzy .foo #my-div {