formatting
R=sigmund@google.com
Review URL: https://codereview.chromium.org//998843003
diff --git a/example/call_parser.dart b/example/call_parser.dart
index 6271057..3248f7f 100644
--- a/example/call_parser.dart
+++ b/example/call_parser.dart
@@ -9,9 +9,12 @@
* 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 parseCss(String cssInput, {List errors, List opts}) =>
- css.parse(cssInput, errors: errors, options: opts == null ?
- ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts);
+StyleSheet parseCss(String cssInput, {List errors, List opts}) => css.parse(
+ cssInput,
+ errors: errors,
+ options: opts == null
+ ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
+ : opts);
// Pretty printer for CSS.
var emitCss = new CssPrinter();
@@ -25,14 +28,14 @@
print('1. Good CSS, parsed CSS emitted:');
print(' =============================');
var stylesheet = parseCss(
- '@import "support/at-charset-019.css"; div { color: red; }'
- 'button[type] { background-color: red; }'
- '.foo { '
+ '@import "support/at-charset-019.css"; div { color: red; }'
+ 'button[type] { background-color: red; }'
+ '.foo { '
'color: red; left: 20px; top: 20px; width: 100px; height:200px'
- '}'
- '#div {'
+ '}'
+ '#div {'
'color : #00F578; border-color: #878787;'
- '}', errors: errors);
+ '}', errors: errors);
if (!errors.isEmpty) {
print("Got ${errors.length} errors.\n");
@@ -46,10 +49,9 @@
// 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");
@@ -63,7 +65,7 @@
// Parse a stylesheet that warns (checks) problematic CSS.
print('3. Detect CSS problem with checking on:');
print(' ===================================');
- stylesheetError = parseCss( '# div1 { color: red; }', errors: errors);
+ stylesheetError = parseCss('# div1 { color: red; }', errors: errors);
if (!errors.isEmpty) {
print("Detected ${errors.length} problem in checked mode.\n");
@@ -86,5 +88,4 @@
} else {
print(prettyPrint(selectorAst));
}
-
}
diff --git a/lib/css.dart b/lib/css.dart
index 73400bc..590e835 100644
--- a/lib/css.dart
+++ b/lib/css.dart
@@ -39,16 +39,16 @@
var file = new SourceFile(contents, url: path.toUri(inputPath));
// Parse the CSS.
- var tree = _time('Parse $filename',
- () => new Parser(file, contents).parse(), verbose);
+ var tree = _time(
+ 'Parse $filename', () => new Parser(file, contents).parse(), verbose);
- _time('Analyzer $filename',
- () => new Analyzer([tree], messages), verbose).run();
+ _time('Analyzer $filename', () => new Analyzer([tree], messages), verbose)
+ .run();
// Emit the processed CSS.
var emitter = new CssPrinter();
- _time('Codegen $filename',
- () => emitter.visitTree(tree, pretty: true), verbose);
+ _time('Codegen $filename', () => emitter.visitTree(tree, pretty: true),
+ verbose);
// Write the contents to a file.
var outPath = path.join(path.dirname(inputPath), '_$filename');
@@ -76,6 +76,8 @@
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 dce31b6..e0aa338 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -20,7 +20,6 @@
part 'src/tokenizer.dart';
part 'src/tokenkind.dart';
-
/** Used for parser lookup ahead (used for nested selectors Less support). */
class ParserState extends TokenizerState {
final Token peekToken;
@@ -47,10 +46,7 @@
// TODO(terry): Remove nested name parameter.
/** Parse and analyze the CSS file. */
StyleSheet compile(input, {List<Message> errors, List<String> options,
- bool nested: true,
- bool polyfill: false,
- List<StyleSheet> includes: null}) {
-
+ bool nested: true, bool polyfill: false, List<StyleSheet> includes: null}) {
if (includes == null) {
includes = [];
}
@@ -76,7 +72,6 @@
/** Analyze the CSS file. */
void analyze(List<StyleSheet> styleSheets,
{List<Message> errors, List<String> options}) {
-
_createMessages(errors: errors, options: options);
new Analyzer(styleSheets, messages).run();
}
@@ -107,8 +102,7 @@
_createMessages(errors: errors);
var file = new SourceFile(source);
- return (new _Parser(file, source)
- ..tokenizer.inSelector = true)
+ return (new _Parser(file, source)..tokenizer.inSelector = true)
.parseSelector();
}
@@ -119,10 +113,9 @@
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) {
@@ -163,8 +156,8 @@
final _Parser _parser;
// TODO(jmesserly): having file and text is redundant.
- Parser(SourceFile file, String text, {int start: 0, String baseUrl}) :
- _parser = new _Parser(file, text, start: start, baseUrl: baseUrl);
+ Parser(SourceFile file, String text, {int start: 0, String baseUrl})
+ : _parser = new _Parser(file, text, start: start, baseUrl: baseUrl);
StyleSheet parse() => _parser.parse();
}
@@ -263,7 +256,7 @@
return _peekToken.kind;
}
- Token _next({unicodeRange : false}) {
+ Token _next({unicodeRange: false}) {
_previousToken = _peekToken;
_peekToken = tokenizer.next(unicodeRange: unicodeRange);
return _previousToken;
@@ -289,7 +282,7 @@
_previousToken = markedData.previousToken;
}
- bool _maybeEat(int kind, {unicodeRange : false}) {
+ bool _maybeEat(int kind, {unicodeRange: false}) {
if (_peekToken.kind == kind) {
_previousToken = _peekToken;
_peekToken = tokenizer.next(unicodeRange: unicodeRange);
@@ -299,7 +292,7 @@
}
}
- void _eat(int kind, {unicodeRange : false}) {
+ void _eat(int kind, {unicodeRange: false}) {
if (!_maybeEat(kind, unicodeRange: unicodeRange)) {
_errorExpected(TokenKind.kindToString(kind));
}
@@ -399,8 +392,7 @@
var unaryOp = TokenKind.matchMediaOperator(op, 0, opLen);
if (unaryOp != -1) {
if (isChecked) {
- if (startQuery &&
- unaryOp != TokenKind.MEDIA_OP_NOT ||
+ if (startQuery && unaryOp != TokenKind.MEDIA_OP_NOT ||
unaryOp != TokenKind.MEDIA_OP_ONLY) {
_warning("Only the unary operators NOT and ONLY allowed",
_makeSpan(start));
@@ -448,13 +440,13 @@
// Grammar: '(' S* media_feature S* [ ':' S* expr ]? ')' S*
if (_maybeEat(TokenKind.LPAREN)) {
if (_peekIdentifier()) {
- var feature = identifier(); // Media feature.
+ var feature = identifier(); // Media feature.
while (_maybeEat(TokenKind.COLON)) {
var startExpr = _peekToken.span;
var exprs = processExpr();
if (_maybeEat(TokenKind.RPAREN)) {
- return new MediaExpression(andOperator, feature, exprs,
- _makeSpan(startExpr));
+ return new MediaExpression(
+ andOperator, feature, exprs, _makeSpan(startExpr));
} else if (isChecked) {
_warning("Missing parenthesis around media expression",
_makeSpan(start));
@@ -589,10 +581,10 @@
// TODO(terry): Normalize pseudoPage to lowercase.
if (isChecked &&
!(pseudoPage.name == 'left' ||
- pseudoPage.name == 'right' ||
- pseudoPage.name == 'first')) {
- _warning("Pseudo page must be left, top or first",
- pseudoPage.span);
+ pseudoPage.name == 'right' ||
+ pseudoPage.name == 'first')) {
+ _warning(
+ "Pseudo page must be left, top or first", pseudoPage.span);
return null;
}
}
@@ -600,8 +592,8 @@
String pseudoName = pseudoPage is Identifier ? pseudoPage.name : '';
String ident = name is Identifier ? name.name : '';
- return new PageDirective(ident, pseudoName,
- processMarginsDeclarations(), _makeSpan(start));
+ return new PageDirective(
+ ident, pseudoName, processMarginsDeclarations(), _makeSpan(start));
case TokenKind.DIRECTIVE_CHARSET:
// @charset S* STRING S* ';'
@@ -640,7 +632,7 @@
if (tokId == TokenKind.DIRECTIVE_MS_KEYFRAMES && isChecked) {
_warning('@-ms-keyframes should be @keyframes', _makeSpan(start));
}
- // TODO(terry): End of workaround.
+ // TODO(terry): End of workaround.
/* Key frames grammar:
*
@@ -676,9 +668,8 @@
selectors.add(term);
} while (_maybeEat(TokenKind.COMMA));
- keyframe.add(new KeyFrameBlock(selectors, processDeclarations(),
- _makeSpan(start)));
-
+ keyframe.add(new KeyFrameBlock(
+ selectors, processDeclarations(), _makeSpan(start)));
} while (!_maybeEat(TokenKind.RBRACE) && !isPrematureEndOfFile());
return keyframe;
@@ -753,14 +744,14 @@
}
}
- return new NamespaceDirective(prefix != null ? prefix.name : '',
- namespaceUri, _makeSpan(start));
+ return new NamespaceDirective(
+ prefix != null ? prefix.name : '', namespaceUri, _makeSpan(start));
case TokenKind.DIRECTIVE_MIXIN:
return processMixin();
case TokenKind.DIRECTIVE_INCLUDE:
- return processInclude( _makeSpan(start));
+ return processInclude(_makeSpan(start));
case TokenKind.DIRECTIVE_CONTENT:
// TODO(terry): TBD
@@ -823,16 +814,14 @@
var declGroup = processDeclarations(checkBrace: false);
var decls = [];
if (declGroup.declarations.any((decl) {
- return decl is Declaration &&
- decl is! IncludeMixinAtDeclaration;
+ return decl is Declaration && decl is! IncludeMixinAtDeclaration;
})) {
var newDecls = [];
productions.forEach((include) {
// If declGroup has items that are declarations then we assume
// this mixin is a declaration mixin not a top-level mixin.
if (include is IncludeDirective) {
- newDecls.add(new IncludeMixinAtDeclaration(include,
- include.span));
+ newDecls.add(new IncludeMixinAtDeclaration(include, include.span));
} else {
_warning("Error mixing of top-level vs declarations mixins",
_makeSpan(include.span));
@@ -845,33 +834,34 @@
// not a declaration group (anything else is a ruleset). Make it a
// list of productions, not a declaration group.
for (var decl in declGroup.declarations) {
- productions.add(decl is IncludeMixinAtDeclaration ?
- decl.include : decl);
- };
+ productions
+ .add(decl is IncludeMixinAtDeclaration ? decl.include : decl);
+ }
+ ;
declGroup.declarations.clear();
}
if (declGroup.declarations.isNotEmpty) {
if (productions.isEmpty) {
- mixinDirective = new MixinDeclarationDirective(name.name, params,
- false, declGroup, _makeSpan(start));
+ mixinDirective = new MixinDeclarationDirective(
+ name.name, params, false, declGroup, _makeSpan(start));
break;
} else {
for (var decl in declGroup.declarations) {
- productions.add(decl is IncludeMixinAtDeclaration ?
- decl.include : decl);
+ productions
+ .add(decl is IncludeMixinAtDeclaration ? decl.include : decl);
}
}
} else {
- mixinDirective = new MixinRulesetDirective(name.name, params,
- false, productions, _makeSpan(start));
+ mixinDirective = new MixinRulesetDirective(
+ name.name, params, false, productions, _makeSpan(start));
break;
}
}
if (productions.isNotEmpty) {
- mixinDirective = new MixinRulesetDirective(name.name, params,
- false, productions, _makeSpan(start));
+ mixinDirective = new MixinRulesetDirective(
+ name.name, params, false, productions, _makeSpan(start));
}
_eat(TokenKind.RBRACE);
@@ -994,8 +984,8 @@
selectorGroup = processSelectorGroup();
}
if (selectorGroup != null) {
- return new RuleSet(selectorGroup, processDeclarations(),
- selectorGroup.span);
+ return new RuleSet(
+ selectorGroup, processDeclarations(), selectorGroup.span);
}
}
@@ -1031,7 +1021,8 @@
// Look a head do we have a nested selector instead of a declaration?
SelectorGroup selGroup = processSelectorGroup();
- var nestedSelector = selGroup != null && _peekKind(TokenKind.LBRACE) &&
+ var nestedSelector = selGroup != null &&
+ _peekKind(TokenKind.LBRACE) &&
messages.messages.isEmpty;
if (!nestedSelector) {
@@ -1053,7 +1044,7 @@
if (checkBrace) _eat(TokenKind.LBRACE);
List decls = [];
- List dartStyles = []; // List of latest styles exposed to Dart.
+ List dartStyles = []; // List of latest styles exposed to Dart.
do {
var selectorGroup = _nestedSelector();
@@ -1111,7 +1102,7 @@
_eat(TokenKind.LBRACE);
List<Declaration> decls = [];
- List dartStyles = []; // List of latest styles exposed to Dart.
+ List dartStyles = []; // List of latest styles exposed to Dart.
do {
switch (_peek()) {
@@ -1142,8 +1133,8 @@
var declGroup = processDeclarations();
if (declGroup != null) {
- groups.add(new MarginGroup(marginSym, declGroup.declarations,
- _makeSpan(start)));
+ groups.add(new MarginGroup(
+ marginSym, declGroup.declarations, _makeSpan(start)));
}
break;
default:
@@ -1248,7 +1239,7 @@
_eat(TokenKind.AMPERSAND);
thisOperator = true;
break;
- }
+ }
// Check if WHITESPACE existed between tokens if so we're descendent.
if (combinatorType == TokenKind.COMBINATOR_NONE && !forceCombinatorNone) {
@@ -1259,19 +1250,20 @@
}
var span = _makeSpan(start);
- var simpleSel = thisOperator ?
- new ElementSelector(new ThisOperator(span), span) : simpleSelector();
+ var simpleSel = thisOperator
+ ? new ElementSelector(new ThisOperator(span), span)
+ : simpleSelector();
if (simpleSel == null &&
(combinatorType == TokenKind.COMBINATOR_PLUS ||
- combinatorType == TokenKind.COMBINATOR_GREATER ||
- combinatorType == TokenKind.COMBINATOR_TILDE)) {
+ combinatorType == TokenKind.COMBINATOR_GREATER ||
+ combinatorType == TokenKind.COMBINATOR_TILDE)) {
// For "+ &", "~ &" or "> &" a selector sequence with no name is needed
// so that the & will have a combinator too. This is needed to
// disambiguate selector expressions:
// .foo&:hover combinator before & is NONE
// .foo & combinator before & is DESCDENDANT
// .foo > & combinator before & is GREATER
- simpleSel = new ElementSelector(new Identifier("", span), span);
+ simpleSel = new ElementSelector(new Identifier("", span), span);
}
if (simpleSel != null) {
return new SimpleSelectorSequence(simpleSel, span, combinatorType);
@@ -1342,8 +1334,8 @@
break;
}
- return new NamespaceSelector(first,
- new ElementSelector(element, element.span), _makeSpan(start));
+ return new NamespaceSelector(
+ first, new ElementSelector(element, element.span), _makeSpan(start));
} else if (first != null) {
return new ElementSelector(first, _makeSpan(start));
} else {
@@ -1353,7 +1345,8 @@
}
bool _anyWhiteSpaceBeforePeekToken(int kind) {
- if (_previousToken != null && _peekToken != null &&
+ if (_previousToken != null &&
+ _peekToken != null &&
_previousToken.kind == kind) {
// If end of previous token isn't same as the start of peek token then
// there's something between these tokens probably whitespace.
@@ -1434,7 +1427,6 @@
// Functional pseudo?
if (_peekToken.kind == TokenKind.LPAREN) {
-
if (!pseudoElement && pseudoName.name.toLowerCase() == 'not') {
_eat(TokenKind.LPAREN);
@@ -1466,9 +1458,9 @@
}
_eat(TokenKind.RPAREN);
- return (pseudoElement) ?
- new PseudoElementFunctionSelector(pseudoName, expr, span) :
- new PseudoClassFunctionSelector(pseudoName, expr, span);
+ return (pseudoElement)
+ ? new PseudoElementFunctionSelector(pseudoName, expr, span)
+ : new PseudoClassFunctionSelector(pseudoName, expr, span);
}
}
@@ -1478,9 +1470,9 @@
// pseudo-class. However, CSS2.1 allows for : to specify old
// pseudo-elements (:first-line, :first-letter, :before and :after) any
// new pseudo-elements defined would require a ::.
- return pseudoElement ?
- new PseudoElementSelector(pseudoName, _makeSpan(start)) :
- new PseudoClassSelector(pseudoName, _makeSpan(start));
+ return pseudoElement
+ ? new PseudoElementSelector(pseudoName, _makeSpan(start))
+ : new PseudoClassSelector(pseudoName, _makeSpan(start));
}
/**
@@ -1531,7 +1523,7 @@
value = '"${_escapeString(value)}"';
return new LiteralTerm(value, value, _makeSpan(start));
case TokenKind.IDENTIFIER:
- value = identifier(); // Snarf up the ident we'll remap, maybe.
+ value = identifier(); // Snarf up the ident we'll remap, maybe.
break;
default:
keepParsing = false;
@@ -1582,17 +1574,17 @@
int op;
switch (_peek()) {
- case TokenKind.EQUALS:
- case TokenKind.INCLUDES: // ~=
- case TokenKind.DASH_MATCH: // |=
- case TokenKind.PREFIX_MATCH: // ^=
- case TokenKind.SUFFIX_MATCH: // $=
- case TokenKind.SUBSTRING_MATCH: // *=
- op = _peek();
- _next();
- break;
- default:
- op = TokenKind.NO_MATCH;
+ case TokenKind.EQUALS:
+ case TokenKind.INCLUDES: // ~=
+ case TokenKind.DASH_MATCH: // |=
+ case TokenKind.PREFIX_MATCH: // ^=
+ case TokenKind.SUFFIX_MATCH: // $=
+ case TokenKind.SUBSTRING_MATCH: // *=
+ op = _peek();
+ _next();
+ break;
+ default:
+ op = TokenKind.NO_MATCH;
}
var value;
@@ -1654,8 +1646,9 @@
// Handle !important (prio)
var importantPriority = _maybeEat(TokenKind.IMPORTANT);
- decl = new Declaration(propertyIdent, exprs, dartComposite,
- _makeSpan(start), important: importantPriority, ie7: ie7);
+ decl = new Declaration(
+ propertyIdent, exprs, dartComposite, _makeSpan(start),
+ important: importantPriority, ie7: ie7);
} else if (_peekToken.kind == TokenKind.VAR_DEFINITION) {
_next();
var definedName;
@@ -1698,7 +1691,7 @@
}
/** List of styles exposed to the Dart UI framework. */
- static const int _fontPartFont= 0;
+ static const int _fontPartFont = 0;
static const int _fontPartVariant = 1;
static const int _fontPartWeight = 2;
static const int _fontPartSize = 3;
@@ -1729,46 +1722,46 @@
static const int _paddingPartBottom = 28;
static const Map<String, int> _stylesToDart = const {
- 'font': _fontPartFont,
- 'font-family': _fontPartFamily,
- 'font-size': _fontPartSize,
- 'font-style': _fontPartStyle,
- 'font-variant': _fontPartVariant,
- 'font-weight': _fontPartWeight,
- 'line-height': _lineHeightPart,
- 'margin': _marginPartMargin,
- 'margin-left': _marginPartLeft,
- 'margin-right': _marginPartRight,
- 'margin-top': _marginPartTop,
- 'margin-bottom': _marginPartBottom,
- 'border': _borderPartBorder,
- 'border-left': _borderPartLeft,
- 'border-right': _borderPartRight,
- 'border-top': _borderPartTop,
- 'border-bottom': _borderPartBottom,
- 'border-width': _borderPartWidth,
- 'border-left-width': _borderPartLeftWidth,
- 'border-top-width': _borderPartTopWidth,
- 'border-right-width': _borderPartRightWidth,
- 'border-bottom-width': _borderPartBottomWidth,
- 'height': _heightPart,
- 'width': _widthPart,
- 'padding': _paddingPartPadding,
- 'padding-left': _paddingPartLeft,
- 'padding-top': _paddingPartTop,
- 'padding-right': _paddingPartRight,
- 'padding-bottom': _paddingPartBottom
+ 'font': _fontPartFont,
+ 'font-family': _fontPartFamily,
+ 'font-size': _fontPartSize,
+ 'font-style': _fontPartStyle,
+ 'font-variant': _fontPartVariant,
+ 'font-weight': _fontPartWeight,
+ 'line-height': _lineHeightPart,
+ 'margin': _marginPartMargin,
+ 'margin-left': _marginPartLeft,
+ 'margin-right': _marginPartRight,
+ 'margin-top': _marginPartTop,
+ 'margin-bottom': _marginPartBottom,
+ 'border': _borderPartBorder,
+ 'border-left': _borderPartLeft,
+ 'border-right': _borderPartRight,
+ 'border-top': _borderPartTop,
+ 'border-bottom': _borderPartBottom,
+ 'border-width': _borderPartWidth,
+ 'border-left-width': _borderPartLeftWidth,
+ 'border-top-width': _borderPartTopWidth,
+ 'border-right-width': _borderPartRightWidth,
+ 'border-bottom-width': _borderPartBottomWidth,
+ 'height': _heightPart,
+ 'width': _widthPart,
+ 'padding': _paddingPartPadding,
+ 'padding-left': _paddingPartLeft,
+ 'padding-top': _paddingPartTop,
+ 'padding-right': _paddingPartRight,
+ 'padding-bottom': _paddingPartBottom
};
static const Map<String, int> _nameToFontWeight = const {
- 'bold' : FontWeight.bold,
- 'normal' : FontWeight.normal
+ 'bold': FontWeight.bold,
+ 'normal': FontWeight.normal
};
static int _findStyle(String styleName) => _stylesToDart[styleName];
- DartStyleExpression _styleForDart(Identifier property, Expressions exprs,
- List dartStyles) {
+ DartStyleExpression _styleForDart(
+ Identifier property, Expressions exprs, List dartStyles) {
var styleType = _findStyle(property.name.toLowerCase());
if (styleType != null) {
return buildDartStyleNode(styleType, exprs, dartStyles);
@@ -1786,9 +1779,8 @@
return fontExpr;
}
- DartStyleExpression buildDartStyleNode(int styleType, Expressions exprs,
- List dartStyles) {
-
+ DartStyleExpression buildDartStyleNode(
+ int styleType, Expressions exprs, List dartStyles) {
switch (styleType) {
/*
* Properties in order:
@@ -1798,9 +1790,9 @@
* The font-size and font-family values are required. If other values are
* missing; a default, if it exist, will be used.
*/
- case _fontPartFont:
- var processor = new ExpressionsProcessor(exprs);
- return _mergeFontStyles(processor.processFont(), dartStyles);
+ case _fontPartFont:
+ var processor = new ExpressionsProcessor(exprs);
+ return _mergeFontStyles(processor.processFont(), dartStyles);
case _fontPartFamily:
var processor = new ExpressionsProcessor(exprs);
@@ -1844,8 +1836,7 @@
// https://github.com/dart-lang/csslib/issues/1
var expr = exprs.expressions[0];
if (expr is NumberTerm) {
- var fontExpr = new FontExpression(expr.span,
- weight: expr.value);
+ var fontExpr = new FontExpression(expr.span, weight: expr.value);
return _mergeFontStyles(fontExpr, dartStyles);
} else if (expr is LiteralTerm) {
int weight = _nameToFontWeight[expr.value.toString()];
@@ -1864,7 +1855,7 @@
// TODO(terry): Need to handle other units and LiteralTerm normal
// See https://github.com/dart-lang/csslib/issues/2.
if (unitTerm.unit == TokenKind.UNIT_LENGTH_PX ||
- unitTerm.unit == TokenKind.UNIT_LENGTH_PT) {
+ unitTerm.unit == TokenKind.UNIT_LENGTH_PT) {
var fontExpr = new FontExpression(expr.span,
lineHeight: new LineHeight(expr.value, inPixels: true));
return _mergeFontStyles(fontExpr, dartStyles);
@@ -1899,8 +1890,8 @@
}
break;
case _paddingPartPadding:
- return new PaddingExpression.boxEdge(exprs.span,
- processFourNums(exprs));
+ return new PaddingExpression.boxEdge(
+ exprs.span, processFourNums(exprs));
case _marginPartLeft:
case _marginPartTop:
case _marginPartRight:
@@ -2000,7 +1991,7 @@
bottom = top;
right = marginValue(exprs.expressions[1]);
left = right;
- break;
+ break;
case 3:
top = marginValue(exprs.expressions[0]);
right = marginValue(exprs.expressions[1]);
@@ -2046,28 +2037,29 @@
var opStart = _peekToken.span;
switch (_peek()) {
- case TokenKind.SLASH:
- op = new OperatorSlash(_makeSpan(opStart));
- break;
- case TokenKind.COMMA:
- op = new OperatorComma(_makeSpan(opStart));
- break;
- case TokenKind.BACKSLASH:
- // Backslash outside of string; detected IE8 or older signaled by \9 at
- // end of an expression.
- var ie8Start = _peekToken.span;
+ case TokenKind.SLASH:
+ op = new OperatorSlash(_makeSpan(opStart));
+ break;
+ case TokenKind.COMMA:
+ op = new OperatorComma(_makeSpan(opStart));
+ break;
+ case TokenKind.BACKSLASH:
+ // Backslash outside of string; detected IE8 or older signaled by \9 at
+ // end of an expression.
+ var ie8Start = _peekToken.span;
- _next();
- if (_peekKind(TokenKind.INTEGER)) {
- var numToken = _next();
- var value = int.parse(numToken.text);
- if (value == 9) {
- op = new IE8Term(_makeSpan(ie8Start));
- } else if (isChecked) {
- _warning("\$value is not valid in an expression", _makeSpan(start));
+ _next();
+ if (_peekKind(TokenKind.INTEGER)) {
+ var numToken = _next();
+ var value = int.parse(numToken.text);
+ if (value == 9) {
+ op = new IE8Term(_makeSpan(ie8Start));
+ } else if (isChecked) {
+ _warning(
+ "\$value is not valid in an expression", _makeSpan(start));
+ }
}
- }
- break;
+ break;
}
if (expr != null) {
@@ -2120,165 +2112,167 @@
//
processTerm([bool ieFilter = false]) {
var start = _peekToken.span;
- Token t; // token for term's value
- var value; // value of term (numeric values)
+ Token t; // token for term's value
+ var value; // value of term (numeric values)
var unary = "";
switch (_peek()) {
- case TokenKind.HASH:
- this._eat(TokenKind.HASH);
- if (!_anyWhiteSpaceBeforePeekToken(TokenKind.HASH)) {
- String hexText;
- if (_peekKind(TokenKind.INTEGER)) {
- String hexText1 = _peekToken.text;
- _next();
- if (_peekIdentifier()) {
- hexText = '$hexText1${identifier().name}';
- } else {
- hexText = hexText1;
+ case TokenKind.HASH:
+ this._eat(TokenKind.HASH);
+ if (!_anyWhiteSpaceBeforePeekToken(TokenKind.HASH)) {
+ String hexText;
+ if (_peekKind(TokenKind.INTEGER)) {
+ String hexText1 = _peekToken.text;
+ _next();
+ if (_peekIdentifier()) {
+ hexText = '$hexText1${identifier().name}';
+ } else {
+ hexText = hexText1;
+ }
+ } else if (_peekIdentifier()) {
+ hexText = identifier().name;
}
- } else if (_peekIdentifier()) {
- hexText = identifier().name;
+ if (hexText != null) {
+ return _parseHex(hexText, _makeSpan(start));
+ }
}
- if (hexText != null) {
- return _parseHex(hexText, _makeSpan(start));
- }
- }
- if (isChecked) {
- _warning("Expected hex number", _makeSpan(start));
- }
- // Construct the bad hex value with a #<space>number.
- return _parseHex(" ${processTerm().text}", _makeSpan(start));
- case TokenKind.INTEGER:
- t = _next();
- value = int.parse("${unary}${t.text}");
- break;
- case TokenKind.DOUBLE:
- t = _next();
- value = double.parse("${unary}${t.text}");
- break;
- case TokenKind.SINGLE_QUOTE:
- value = processQuotedString(false);
- value = "'${_escapeString(value, single: true)}'";
- return new LiteralTerm(value, value, _makeSpan(start));
- case TokenKind.DOUBLE_QUOTE:
- value = processQuotedString(false);
- value = '"${_escapeString(value)}"';
- return new LiteralTerm(value, value, _makeSpan(start));
- case TokenKind.LPAREN:
- _next();
-
- GroupTerm group = new GroupTerm(_makeSpan(start));
-
- var term;
- do {
- term = processTerm();
- if (term != null && term is LiteralTerm) {
- group.add(term);
- }
- } while (term != null && !_maybeEat(TokenKind.RPAREN) &&
- !isPrematureEndOfFile());
-
- return group;
- case TokenKind.LBRACK:
- _next();
-
- var term = processTerm();
- if (!(term is NumberTerm)) {
- _error('Expecting a positive number', _makeSpan(start));
- }
-
- _eat(TokenKind.RBRACK);
-
- return new ItemTerm(term.value, term.text, _makeSpan(start));
- case TokenKind.IDENTIFIER:
- var nameValue = identifier(); // Snarf up the ident we'll remap, maybe.
-
- if (!ieFilter && _maybeEat(TokenKind.LPAREN)) {
- // FUNCTION
- return processFunction(nameValue);
- } if (ieFilter) {
- if (_maybeEat(TokenKind.COLON) &&
- nameValue.name.toLowerCase() == 'progid') {
- // IE filter:progid:
- return processIEFilter(start);
- } else {
- // Handle filter:<name> where name is any filter e.g., alpha, chroma,
- // Wave, blur, etc.
- return processIEFilter(start);
- }
- }
-
- // TODO(terry): Need to have a list of known identifiers today only
- // 'from' is special.
- if (nameValue.name == 'from') {
- return new LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
- }
-
- // What kind of identifier is it, named color?
- var colorEntry = TokenKind.matchColorName(nameValue.name);
- if (colorEntry == null) {
if (isChecked) {
- var propName = nameValue.name;
- var errMsg = TokenKind.isPredefinedName(propName) ?
- "Improper use of property value ${propName}" :
- "Unknown property value ${propName}";
- _warning(errMsg, _makeSpan(start));
+ _warning("Expected hex number", _makeSpan(start));
}
- return new LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
- }
-
- // Yes, process the color as an RGB value.
- var rgbColor =
- TokenKind.decimalToHex(TokenKind.colorValue(colorEntry), 6);
- return _parseHex(rgbColor, _makeSpan(start));
- case TokenKind.UNICODE_RANGE:
- var first;
- var second;
- var firstNumber;
- var secondNumber;
- _eat(TokenKind.UNICODE_RANGE, unicodeRange: true);
- if (_maybeEat(TokenKind.HEX_INTEGER, unicodeRange: true)) {
- first = _previousToken.text;
- firstNumber = int.parse('0x$first');
- if (firstNumber > MAX_UNICODE) {
- _error("unicode range must be less than 10FFFF", _makeSpan(start));
- }
- if (_maybeEat(TokenKind.MINUS, unicodeRange: true)) {
- if (_maybeEat(TokenKind.HEX_INTEGER, unicodeRange: true)) {
- second = _previousToken.text;
- secondNumber = int.parse('0x$second');
- if (secondNumber > MAX_UNICODE) {
- _error("unicode range must be less than 10FFFF",
- _makeSpan(start));
- }
- if (firstNumber > secondNumber) {
- _error("unicode first range can not be greater than last",
- _makeSpan(start));
- }
- }
- }
- } else if (_maybeEat(TokenKind.HEX_RANGE, unicodeRange: true)) {
- first = _previousToken.text;
- }
-
- return new UnicodeRangeTerm(first, second, _makeSpan(start));
- case TokenKind.AT:
- if (messages.options.lessSupport) {
+ // Construct the bad hex value with a #<space>number.
+ return _parseHex(" ${processTerm().text}", _makeSpan(start));
+ case TokenKind.INTEGER:
+ t = _next();
+ value = int.parse("${unary}${t.text}");
+ break;
+ case TokenKind.DOUBLE:
+ t = _next();
+ value = double.parse("${unary}${t.text}");
+ break;
+ case TokenKind.SINGLE_QUOTE:
+ value = processQuotedString(false);
+ value = "'${_escapeString(value, single: true)}'";
+ return new LiteralTerm(value, value, _makeSpan(start));
+ case TokenKind.DOUBLE_QUOTE:
+ value = processQuotedString(false);
+ value = '"${_escapeString(value)}"';
+ return new LiteralTerm(value, value, _makeSpan(start));
+ case TokenKind.LPAREN:
_next();
- var expr = processExpr();
- if (isChecked && expr.expressions.length > 1) {
- _error("only @name for Less syntax", _peekToken.span);
+ GroupTerm group = new GroupTerm(_makeSpan(start));
+
+ var term;
+ do {
+ term = processTerm();
+ if (term != null && term is LiteralTerm) {
+ group.add(term);
+ }
+ } while (term != null &&
+ !_maybeEat(TokenKind.RPAREN) &&
+ !isPrematureEndOfFile());
+
+ return group;
+ case TokenKind.LBRACK:
+ _next();
+
+ var term = processTerm();
+ if (!(term is NumberTerm)) {
+ _error('Expecting a positive number', _makeSpan(start));
}
- var param = expr.expressions[0];
- var varUsage = new VarUsage(param.text, [], _makeSpan(start));
- expr.expressions[0] = varUsage;
- return expr.expressions;
- }
- break;
+ _eat(TokenKind.RBRACK);
+
+ return new ItemTerm(term.value, term.text, _makeSpan(start));
+ case TokenKind.IDENTIFIER:
+ var nameValue = identifier(); // Snarf up the ident we'll remap, maybe.
+
+ if (!ieFilter && _maybeEat(TokenKind.LPAREN)) {
+ // FUNCTION
+ return processFunction(nameValue);
+ }
+ if (ieFilter) {
+ if (_maybeEat(TokenKind.COLON) &&
+ nameValue.name.toLowerCase() == 'progid') {
+ // IE filter:progid:
+ return processIEFilter(start);
+ } else {
+ // Handle filter:<name> where name is any filter e.g., alpha, chroma,
+ // Wave, blur, etc.
+ return processIEFilter(start);
+ }
+ }
+
+ // TODO(terry): Need to have a list of known identifiers today only
+ // 'from' is special.
+ if (nameValue.name == 'from') {
+ return new LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
+ }
+
+ // What kind of identifier is it, named color?
+ var colorEntry = TokenKind.matchColorName(nameValue.name);
+ if (colorEntry == null) {
+ if (isChecked) {
+ var propName = nameValue.name;
+ var errMsg = TokenKind.isPredefinedName(propName)
+ ? "Improper use of property value ${propName}"
+ : "Unknown property value ${propName}";
+ _warning(errMsg, _makeSpan(start));
+ }
+ return new LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
+ }
+
+ // Yes, process the color as an RGB value.
+ var rgbColor =
+ TokenKind.decimalToHex(TokenKind.colorValue(colorEntry), 6);
+ return _parseHex(rgbColor, _makeSpan(start));
+ case TokenKind.UNICODE_RANGE:
+ var first;
+ var second;
+ var firstNumber;
+ var secondNumber;
+ _eat(TokenKind.UNICODE_RANGE, unicodeRange: true);
+ if (_maybeEat(TokenKind.HEX_INTEGER, unicodeRange: true)) {
+ first = _previousToken.text;
+ firstNumber = int.parse('0x$first');
+ if (firstNumber > MAX_UNICODE) {
+ _error("unicode range must be less than 10FFFF", _makeSpan(start));
+ }
+ if (_maybeEat(TokenKind.MINUS, unicodeRange: true)) {
+ if (_maybeEat(TokenKind.HEX_INTEGER, unicodeRange: true)) {
+ second = _previousToken.text;
+ secondNumber = int.parse('0x$second');
+ if (secondNumber > MAX_UNICODE) {
+ _error(
+ "unicode range must be less than 10FFFF", _makeSpan(start));
+ }
+ if (firstNumber > secondNumber) {
+ _error("unicode first range can not be greater than last",
+ _makeSpan(start));
+ }
+ }
+ }
+ } else if (_maybeEat(TokenKind.HEX_RANGE, unicodeRange: true)) {
+ first = _previousToken.text;
+ }
+
+ return new UnicodeRangeTerm(first, second, _makeSpan(start));
+ case TokenKind.AT:
+ if (messages.options.lessSupport) {
+ _next();
+
+ var expr = processExpr();
+ if (isChecked && expr.expressions.length > 1) {
+ _error("only @name for Less syntax", _peekToken.span);
+ }
+
+ var param = expr.expressions[0];
+ var varUsage = new VarUsage(param.text, [], _makeSpan(start));
+ expr.expressions[0] = varUsage;
+ return expr.expressions;
+ }
+ break;
}
return processDimension(t, value, _makeSpan(start));
@@ -2290,76 +2284,76 @@
var unitType = this._peek();
switch (unitType) {
- case TokenKind.UNIT_EM:
- term = new EmTerm(value, t.text, span);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_EX:
- term = new ExTerm(value, t.text, span);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_LENGTH_PX:
- case TokenKind.UNIT_LENGTH_CM:
- case TokenKind.UNIT_LENGTH_MM:
- case TokenKind.UNIT_LENGTH_IN:
- case TokenKind.UNIT_LENGTH_PT:
- case TokenKind.UNIT_LENGTH_PC:
- term = new LengthTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_ANGLE_DEG:
- case TokenKind.UNIT_ANGLE_RAD:
- case TokenKind.UNIT_ANGLE_GRAD:
- case TokenKind.UNIT_ANGLE_TURN:
- term = new AngleTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_TIME_MS:
- case TokenKind.UNIT_TIME_S:
- term = new TimeTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_FREQ_HZ:
- case TokenKind.UNIT_FREQ_KHZ:
- term = new FreqTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.PERCENT:
- term = new PercentageTerm(value, t.text, span);
- _next(); // Skip the %
- break;
- case TokenKind.UNIT_FRACTION:
- term = new FractionTerm(value, t.text, span);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_RESOLUTION_DPI:
- case TokenKind.UNIT_RESOLUTION_DPCM:
- case TokenKind.UNIT_RESOLUTION_DPPX:
- term = new ResolutionTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_CH:
- term = new ChTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_REM:
- term = new RemTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- case TokenKind.UNIT_VIEWPORT_VW:
- case TokenKind.UNIT_VIEWPORT_VH:
- case TokenKind.UNIT_VIEWPORT_VMIN:
- case TokenKind.UNIT_VIEWPORT_VMAX:
- term = new ViewportTerm(value, t.text, span, unitType);
- _next(); // Skip the unit
- break;
- default:
- if (value != null && t != null) {
- term = (value is Identifier)
- ? new LiteralTerm(value, value.name, span)
- : new NumberTerm(value, t.text, span);
- }
- break;
+ case TokenKind.UNIT_EM:
+ term = new EmTerm(value, t.text, span);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_EX:
+ term = new ExTerm(value, t.text, span);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_LENGTH_PX:
+ case TokenKind.UNIT_LENGTH_CM:
+ case TokenKind.UNIT_LENGTH_MM:
+ case TokenKind.UNIT_LENGTH_IN:
+ case TokenKind.UNIT_LENGTH_PT:
+ case TokenKind.UNIT_LENGTH_PC:
+ term = new LengthTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_ANGLE_DEG:
+ case TokenKind.UNIT_ANGLE_RAD:
+ case TokenKind.UNIT_ANGLE_GRAD:
+ case TokenKind.UNIT_ANGLE_TURN:
+ term = new AngleTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_TIME_MS:
+ case TokenKind.UNIT_TIME_S:
+ term = new TimeTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_FREQ_HZ:
+ case TokenKind.UNIT_FREQ_KHZ:
+ term = new FreqTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.PERCENT:
+ term = new PercentageTerm(value, t.text, span);
+ _next(); // Skip the %
+ break;
+ case TokenKind.UNIT_FRACTION:
+ term = new FractionTerm(value, t.text, span);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_RESOLUTION_DPI:
+ case TokenKind.UNIT_RESOLUTION_DPCM:
+ case TokenKind.UNIT_RESOLUTION_DPPX:
+ term = new ResolutionTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_CH:
+ term = new ChTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_REM:
+ term = new RemTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ case TokenKind.UNIT_VIEWPORT_VW:
+ case TokenKind.UNIT_VIEWPORT_VH:
+ case TokenKind.UNIT_VIEWPORT_VMIN:
+ case TokenKind.UNIT_VIEWPORT_VMAX:
+ term = new ViewportTerm(value, t.text, span, unitType);
+ _next(); // Skip the unit
+ break;
+ default:
+ if (value != null && t != null) {
+ term = (value is Identifier)
+ ? new LiteralTerm(value, value.name, span)
+ : new NumberTerm(value, t.text, span);
+ }
+ break;
}
return term;
@@ -2377,27 +2371,27 @@
tokenizer._skipWhitespace = false;
switch (_peek()) {
- case TokenKind.SINGLE_QUOTE:
- stopToken = TokenKind.SINGLE_QUOTE;
- _next(); // Skip the SINGLE_QUOTE.
- start = _peekToken.span;
- break;
- case TokenKind.DOUBLE_QUOTE:
- stopToken = TokenKind.DOUBLE_QUOTE;
- _next(); // Skip the DOUBLE_QUOTE.
- start = _peekToken.span;
- break;
- default:
- if (urlString) {
- if (_peek() == TokenKind.LPAREN) {
- _next(); // Skip the LPAREN.
- start = _peekToken.span;
+ case TokenKind.SINGLE_QUOTE:
+ stopToken = TokenKind.SINGLE_QUOTE;
+ _next(); // Skip the SINGLE_QUOTE.
+ start = _peekToken.span;
+ break;
+ case TokenKind.DOUBLE_QUOTE:
+ stopToken = TokenKind.DOUBLE_QUOTE;
+ _next(); // Skip the DOUBLE_QUOTE.
+ start = _peekToken.span;
+ break;
+ default:
+ if (urlString) {
+ if (_peek() == TokenKind.LPAREN) {
+ _next(); // Skip the LPAREN.
+ start = _peekToken.span;
+ }
+ stopToken = TokenKind.RPAREN;
+ } else {
+ _error('unexpected string', _makeSpan(start));
}
- stopToken = TokenKind.RPAREN;
- } else {
- _error('unexpected string', _makeSpan(start));
- }
- break;
+ break;
}
// Gobble up everything until we hit our stop token.
@@ -2410,7 +2404,7 @@
// All characters between quotes is the string.
if (stopToken != TokenKind.RPAREN) {
- _next(); // Skip the SINGLE_QUOTE or DOUBLE_QUOTE;
+ _next(); // Skip the SINGLE_QUOTE or DOUBLE_QUOTE;
}
return stringValue.toString();
@@ -2438,8 +2432,8 @@
case TokenKind.RPAREN:
_eat(TokenKind.RPAREN);
if (--parens == 0) {
- var tok = tokenizer.makeIEFilter(startAfterProgidColon.start.offset,
- _peekToken.start);
+ var tok = tokenizer.makeIEFilter(
+ startAfterProgidColon.start.offset, _peekToken.start);
return new LiteralTerm(tok.text, tok.text, tok.span);
}
break;
@@ -2459,53 +2453,53 @@
var name = func.name;
switch (name) {
- case 'url':
- // URI term sucks up everything inside of quotes(' or ") or between parens
- var urlParam = processQuotedString(true);
+ case 'url':
+ // URI term sucks up everything inside of quotes(' or ") or between parens
+ var urlParam = processQuotedString(true);
- // TODO(terry): Better error messge and checking for mismatched quotes.
- if (_peek() == TokenKind.END_OF_FILE) {
- _error("problem parsing URI", _peekToken.span);
- }
+ // TODO(terry): Better error messge and checking for mismatched quotes.
+ if (_peek() == TokenKind.END_OF_FILE) {
+ _error("problem parsing URI", _peekToken.span);
+ }
- if (_peek() == TokenKind.RPAREN) {
- _next();
- }
+ if (_peek() == TokenKind.RPAREN) {
+ _next();
+ }
- return new UriTerm(urlParam, _makeSpan(start));
- case 'calc':
- // TODO(terry): Implement expression handling...
- break;
- case 'var':
- // TODO(terry): Consider handling var in IE specific filter/progid. This
- // will require parsing entire IE specific syntax e.g.,
- // param = value or progid:com_id, etc. for example:
- //
- // var-blur: Blur(Add = 0, Direction = 225, Strength = 10);
- // var-gradient: progid:DXImageTransform.Microsoft.gradient"
- // (GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');
- var expr = processExpr();
- if (!_maybeEat(TokenKind.RPAREN)) {
- _error("problem parsing var expected ), ", _peekToken.span);
- }
- if (isChecked &&
- expr.expressions.where((e) => e is OperatorComma).length > 1) {
- _error("too many parameters to var()", _peekToken.span);
- }
+ return new UriTerm(urlParam, _makeSpan(start));
+ case 'calc':
+ // TODO(terry): Implement expression handling...
+ break;
+ case 'var':
+ // TODO(terry): Consider handling var in IE specific filter/progid. This
+ // will require parsing entire IE specific syntax e.g.,
+ // param = value or progid:com_id, etc. for example:
+ //
+ // var-blur: Blur(Add = 0, Direction = 225, Strength = 10);
+ // var-gradient: progid:DXImageTransform.Microsoft.gradient"
+ // (GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');
+ var expr = processExpr();
+ if (!_maybeEat(TokenKind.RPAREN)) {
+ _error("problem parsing var expected ), ", _peekToken.span);
+ }
+ if (isChecked &&
+ expr.expressions.where((e) => e is OperatorComma).length > 1) {
+ _error("too many parameters to var()", _peekToken.span);
+ }
- var paramName = expr.expressions[0].text;
+ var paramName = expr.expressions[0].text;
- // [0] - var name, [1] - OperatorComma, [2] - default value.
- var defaultValues = expr.expressions.length >= 3
- ? expr.expressions.sublist(2) : [];
- return new VarUsage(paramName, defaultValues, _makeSpan(start));
- default:
- var expr = processExpr();
- if (!_maybeEat(TokenKind.RPAREN)) {
- _error("problem parsing function expected ), ", _peekToken.span);
- }
+ // [0] - var name, [1] - OperatorComma, [2] - default value.
+ var defaultValues =
+ expr.expressions.length >= 3 ? expr.expressions.sublist(2) : [];
+ return new VarUsage(paramName, defaultValues, _makeSpan(start));
+ default:
+ var expr = processExpr();
+ if (!_maybeEat(TokenKind.RPAREN)) {
+ _error("problem parsing function expected ), ", _peekToken.span);
+ }
- return new FunctionTerm(name, name, expr, _makeSpan(start));
+ return new FunctionTerm(name, name, expr, _makeSpan(start));
}
return null;
@@ -2527,11 +2521,11 @@
// TODO(terry): Move this to base <= 36 and into shared code.
static int _hexDigit(int c) {
- if (c >= 48/*0*/ && c <= 57/*9*/) {
+ if (c >= 48 /*0*/ && c <= 57 /*9*/) {
return c - 48;
- } else if (c >= 97/*a*/ && c <= 102/*f*/) {
+ } else if (c >= 97 /*a*/ && c <= 102 /*f*/) {
return c - 87;
- } else if (c >= 65/*A*/ && c <= 70/*F*/) {
+ } else if (c >= 65 /*A*/ && c <= 70 /*F*/) {
return c - 55;
} else {
return -1;
@@ -2541,7 +2535,7 @@
HexColorTerm _parseHex(String hexText, SourceSpan span) {
var hexValue = 0;
- for (var i = 0; i < hexText.length; i++) {
+ for (var i = 0; i < hexText.length; i++) {
var digit = _hexDigit(hexText.codeUnitAt(i));
if (digit < 0) {
_warning('Bad hex number', span);
@@ -2689,8 +2683,12 @@
var code = text.codeUnitAt(i);
String replace = null;
switch (code) {
- case 34/*'"'*/: if (!single) replace = r'\"'; break;
- case 39/*"'"*/: if (single) replace = r"\'"; break;
+ case 34 /*'"'*/ :
+ if (!single) replace = r'\"';
+ break;
+ case 39 /*"'"*/ :
+ if (single) replace = r"\'";
+ break;
}
if (replace != null && result == null) {
diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart
index da1a9fa..1341bc2 100644
--- a/lib/src/analyzer.dart
+++ b/lib/src/analyzer.dart
@@ -4,7 +4,6 @@
part of csslib.parser;
-
// TODO(terry): Add optimizing phase to remove duplicated selectors in the same
// selector group (e.g., .btn, .btn { color: red; }). Also, look
// at simplifying selectors expressions too (much harder).
@@ -34,12 +33,12 @@
// possibly combine in one walk.
void run() {
// Expand top-level @include.
- _styleSheets.forEach((styleSheet) =>
- TopLevelIncludes.expand(_messages, _styleSheets));
+ _styleSheets.forEach(
+ (styleSheet) => TopLevelIncludes.expand(_messages, _styleSheets));
// Expand @include in declarations.
- _styleSheets.forEach((styleSheet) =>
- DeclarationIncludes.expand(_messages, _styleSheets));
+ _styleSheets.forEach(
+ (styleSheet) => DeclarationIncludes.expand(_messages, _styleSheets));
// Remove all @mixin and @include
_styleSheets.forEach((styleSheet) => MixinsAndIncludes.remove(styleSheet));
@@ -47,13 +46,13 @@
// Expand any nested selectors using selector desendant combinator to
// signal CSS inheritance notation.
_styleSheets.forEach((styleSheet) => new ExpandNestedSelectors()
- ..visitStyleSheet(styleSheet)
- ..flatten(styleSheet));
+ ..visitStyleSheet(styleSheet)
+ ..flatten(styleSheet));
// Expand any @extend.
_styleSheets.forEach((styleSheet) {
- var allExtends = new AllExtends()..visitStyleSheet(styleSheet);
- new InheritExtends(_messages, allExtends)..visitStyleSheet(styleSheet);
+ var allExtends = new AllExtends()..visitStyleSheet(styleSheet);
+ new InheritExtends(_messages, allExtends)..visitStyleSheet(styleSheet);
});
}
}
@@ -215,8 +214,8 @@
_parentRuleSet = oldParent;
// Remove nested rules; they're all flatten and in the _expandedRuleSets.
- node.declarationGroup.declarations.removeWhere((declaration) =>
- declaration is RuleSet);
+ node.declarationGroup.declarations
+ .removeWhere((declaration) => declaration is RuleSet);
_nestedSelectorGroup = oldNestedSelectorGroups;
@@ -305,8 +304,8 @@
var newSequences = [];
var first = sequences.first;
- newSequences.add(new SimpleSelectorSequence(first.simpleSelector,
- first.span, TokenKind.COMBINATOR_DESCENDANT));
+ newSequences.add(new SimpleSelectorSequence(
+ first.simpleSelector, first.span, TokenKind.COMBINATOR_DESCENDANT));
newSequences.addAll(sequences.skip(1));
return newSequences;
@@ -407,8 +406,8 @@
* Look for the [ruleSet] inside of an @media directive; if found then replace
* with the [newRules]. If [ruleSet] is found and replaced return true.
*/
- static bool replace(StyleSheet styleSheet, RuleSet ruleSet,
- List<RuleSet>newRules) {
+ static bool replace(
+ StyleSheet styleSheet, RuleSet ruleSet, List<RuleSet> newRules) {
var visitor = new _MediaRulesReplacer(ruleSet, newRules);
visitor.visitStyleSheet(styleSheet);
return visitor._foundAndReplaced;
@@ -459,8 +458,8 @@
if (map.containsKey(node.name)) {
var mixinDef = map[node.name];
if (mixinDef is MixinRulesetDirective) {
- _TopLevelIncludeReplacer.replace(_messages, _styleSheet, node,
- mixinDef.rulesets);
+ _TopLevelIncludeReplacer.replace(
+ _messages, _styleSheet, node, mixinDef.rulesets);
} else if (currDef is MixinRulesetDirective && _anyRulesets(currDef)) {
// currDef is MixinRulesetDirective
MixinRulesetDirective mixinRuleset = currDef;
@@ -519,7 +518,7 @@
* with the [newRules]. If [ruleSet] is found and replaced return true.
*/
static bool replace(Messages messages, StyleSheet styleSheet,
- IncludeDirective include, List<RuleSet>newRules) {
+ IncludeDirective include, List<RuleSet> newRules) {
var visitor = new _TopLevelIncludeReplacer(messages, include, newRules);
visitor.visitStyleSheet(styleSheet);
return visitor._foundAndReplaced;
@@ -555,13 +554,12 @@
* can be an include in a declaration or an include directive (top-level).
*/
int _findInclude(List list, var node) {
- IncludeDirective matchNode = (node is IncludeMixinAtDeclaration) ?
- node.include : node;
+ IncludeDirective matchNode =
+ (node is IncludeMixinAtDeclaration) ? node.include : node;
var index = 0;
for (var item in list) {
- var includeNode = (item is IncludeMixinAtDeclaration) ?
- item.include : item;
+ var includeNode = (item is IncludeMixinAtDeclaration) ? item.include : item;
if (includeNode == matchNode) return index;
index++;
}
@@ -724,8 +722,8 @@
rulesets.every((rule) => rule is IncludeDirective || rule is NoOp);
CallMixin _createCallDeclMixin(MixinDefinition mixinDef) {
- callMap.putIfAbsent(mixinDef.name, () =>
- callMap[mixinDef.name] = new CallMixin(mixinDef, varDefs));
+ callMap.putIfAbsent(mixinDef.name,
+ () => callMap[mixinDef.name] = new CallMixin(mixinDef, varDefs));
return callMap[mixinDef.name];
}
@@ -750,8 +748,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",
@@ -763,22 +761,22 @@
var rulesets = [];
if (origRulesets.every((ruleset) => ruleset is IncludeDirective)) {
origRulesets.forEach((ruleset) {
- rulesets.add(new IncludeMixinAtDeclaration(ruleset,
- ruleset.span));
+ rulesets
+ .add(new IncludeMixinAtDeclaration(ruleset, ruleset.span));
});
_IncludeReplacer.replace(_styleSheet, node, rulesets);
}
}
}
- if ( mixinDef.definedArgs.length > 0 && node.include.args.length > 0) {
+ if (mixinDef.definedArgs.length > 0 && node.include.args.length > 0) {
var callMixin = _createCallDeclMixin(mixinDef);
mixinDef = callMixin.transform(node.include.args);
}
if (mixinDef is MixinDeclarationDirective) {
- _IncludeReplacer.replace(_styleSheet, node,
- mixinDef.declarations.declarations);
+ _IncludeReplacer.replace(
+ _styleSheet, node, mixinDef.declarations.declarations);
}
} else {
_messages.warning("Undefined mixin ${node.include.name}", node.span);
@@ -792,11 +790,11 @@
var mixinDef = map[node.name];
if (currDef is MixinDeclarationDirective &&
mixinDef is MixinDeclarationDirective) {
- _IncludeReplacer.replace(_styleSheet, node,
- mixinDef.declarations.declarations);
+ _IncludeReplacer.replace(
+ _styleSheet, node, mixinDef.declarations.declarations);
} else if (currDef is MixinDeclarationDirective) {
- var decls = (currDef as MixinDeclarationDirective)
- .declarations.declarations;
+ var decls =
+ (currDef as MixinDeclarationDirective).declarations.declarations;
var index = _findInclude(decls, node);
if (index != -1) {
decls.replaceRange(index, index + 1, [new NoOp()]);
@@ -835,7 +833,7 @@
varDefs[node.definedName] = node;
}
super.visitVarDefinition(node);
- }
+ }
void visitVarDefinitionDirective(VarDefinitionDirective node) {
visitVarDefinition(node.def);
@@ -852,8 +850,8 @@
* Look for the [ruleSet] inside of a @media directive; if found then replace
* with the [newRules].
*/
- static void replace(StyleSheet ss, var include,
- List<Declaration> newDeclarations) {
+ static void replace(
+ StyleSheet ss, var include, List<Declaration> newDeclarations) {
var visitor = new _IncludeReplacer(include, newDeclarations);
visitor.visitStyleSheet(ss);
}
@@ -973,12 +971,14 @@
InheritExtends(this._messages, this._allExtends);
void visitSelectorGroup(SelectorGroup node) {
- for (var selectorsIndex = 0; selectorsIndex < node.selectors.length;
+ for (var selectorsIndex = 0;
+ selectorsIndex < node.selectors.length;
selectorsIndex++) {
var selectors = node.selectors[selectorsIndex];
var isLastNone = false;
var selectorName = "";
- for (var index = 0; index < selectors.simpleSelectorSequences.length;
+ for (var index = 0;
+ index < selectors.simpleSelectorSequences.length;
index++) {
var simpleSeq = selectors.simpleSelectorSequences[index];
var namePart = simpleSeq.simpleSelector.toString();
@@ -1001,8 +1001,8 @@
newSelectors.simpleSelectorSequences[index].combinator;
newSeq.simpleSelectorSequences[0].combinator = orgCombinator;
- newSelectors.simpleSelectorSequences.replaceRange(index,
- index + 1, newSeq.simpleSelectorSequences);
+ newSelectors.simpleSelectorSequences.replaceRange(
+ index, index + 1, newSeq.simpleSelectorSequences);
node.selectors.add(newSelectors);
}
isLastNone = false;
diff --git a/lib/src/css_printer.dart b/lib/src/css_printer.dart
index 9a80ee1..125b5ae 100644
--- a/lib/src/css_printer.dart
+++ b/lib/src/css_printer.dart
@@ -272,7 +272,6 @@
}
}
-
void visitSelectorGroup(SelectorGroup node) {
var selectors = node.selectors;
var selectorsLength = selectors.length;
diff --git a/lib/src/messages.dart b/lib/src/messages.dart
index 92f8451..d8abcab 100644
--- a/lib/src/messages.dart
+++ b/lib/src/messages.dart
@@ -47,14 +47,17 @@
final bool useColors;
Message(this.level, this.message, {SourceSpan span, bool useColors: false})
- : this.span = span, this.useColors = useColors;
+ : this.span = span,
+ this.useColors = useColors;
String toString() {
var output = new StringBuffer();
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) {
@@ -87,8 +90,8 @@
/** Report a compile-time CSS error. */
void error(String message, SourceSpan span) {
- var msg = new Message(Level.SEVERE, message, span: span,
- useColors: options.useColors);
+ var msg = new Message(Level.SEVERE, message,
+ span: span, useColors: options.useColors);
messages.add(msg);
@@ -100,8 +103,8 @@
if (options.warningsAsErrors) {
error(message, span);
} else {
- var msg = new Message(Level.WARNING, message, span: span,
- useColors: options.useColors);
+ var msg = new Message(Level.WARNING, message,
+ span: span, useColors: options.useColors);
messages.add(msg);
}
@@ -109,8 +112,8 @@
/** Report and informational message about what the compiler is doing. */
void info(String message, SourceSpan span) {
- var msg = new Message(Level.INFO, message, span: span,
- useColors: options.useColors);
+ var msg = new Message(Level.INFO, message,
+ span: span, useColors: options.useColors);
messages.add(msg);
@@ -120,8 +123,11 @@
/** Merge [newMessages] to this message lsit. */
void mergeMessages(Messages newMessages) {
messages.addAll(newMessages.messages);
- newMessages.messages.where((message) =>
- message.level.value == Level.SEVERE || options.verbose)
- .forEach((message) { printHandler(message); });
+ newMessages.messages
+ .where(
+ (message) => message.level.value == Level.SEVERE || options.verbose)
+ .forEach((message) {
+ printHandler(message);
+ });
}
}
diff --git a/lib/src/options.dart b/lib/src/options.dart
index a344a39..0ebb5b4 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -44,38 +44,48 @@
factory PreprocessorOptions() => parse(['']);
PreprocessorOptions.fromArgs(ArgResults args)
- : warningsAsErrors = args['warnings_as_errors'],
- throwOnWarnings = args['throw_on_warnings'],
- throwOnErrors = args['throw_on_errors'],
- verbose = args['verbose'],
- checked = args['checked'],
- lessSupport = args['less'],
- useColors = args['colors'],
- polyfill = args['polyfill'],
- inputFile = args.rest.length > 0 ? args.rest[0] : null;
+ : warningsAsErrors = args['warnings_as_errors'],
+ throwOnWarnings = args['throw_on_warnings'],
+ throwOnErrors = args['throw_on_errors'],
+ verbose = args['verbose'],
+ checked = args['checked'],
+ lessSupport = args['less'],
+ useColors = args['colors'],
+ polyfill = args['polyfill'],
+ inputFile = args.rest.length > 0 ? args.rest[0] : null;
// tool.dart [options...] <css file>
static PreprocessorOptions parse(List<String> arguments) {
var parser = new ArgParser()
- ..addFlag('verbose', abbr: 'v', defaultsTo: false, negatable: false,
+ ..addFlag('verbose',
+ abbr: 'v',
+ defaultsTo: false,
+ negatable: false,
help: 'Display detail info')
- ..addFlag('checked', defaultsTo: false, negatable: false,
+ ..addFlag('checked',
+ defaultsTo: false,
+ negatable: false,
help: 'Validate CSS values invalid value display a warning message')
- ..addFlag('less', defaultsTo: true, negatable: true,
+ ..addFlag('less',
+ defaultsTo: true,
+ negatable: true,
help: 'Supports subset of Less syntax')
- ..addFlag('suppress_warnings', defaultsTo: true,
- help: 'Warnings not displayed')
- ..addFlag('warnings_as_errors', defaultsTo: false,
- help: 'Warning handled as errors')
- ..addFlag('throw_on_errors', defaultsTo: false,
- help: 'Throw on errors encountered')
- ..addFlag('throw_on_warnings', defaultsTo: false,
- help: 'Throw on warnings encountered')
- ..addFlag('colors', defaultsTo: true,
- help: 'Display errors/warnings in colored text')
- ..addFlag('polyfill', defaultsTo: false,
- help: 'Generate polyfill for new CSS features')
- ..addFlag('help', abbr: 'h', defaultsTo: false, negatable: false,
+ ..addFlag('suppress_warnings',
+ defaultsTo: true, help: 'Warnings not displayed')
+ ..addFlag('warnings_as_errors',
+ defaultsTo: false, help: 'Warning handled as errors')
+ ..addFlag('throw_on_errors',
+ defaultsTo: false, help: 'Throw on errors encountered')
+ ..addFlag('throw_on_warnings',
+ defaultsTo: false, help: 'Throw on warnings encountered')
+ ..addFlag('colors',
+ defaultsTo: true, help: 'Display errors/warnings in colored text')
+ ..addFlag('polyfill',
+ defaultsTo: false, help: 'Generate polyfill for new CSS features')
+ ..addFlag('help',
+ abbr: 'h',
+ defaultsTo: false,
+ negatable: false,
help: 'Displays this help message');
try {
@@ -96,5 +106,4 @@
print('Usage: css [options...] input.css');
print(parser.getUsage());
}
-
}
diff --git a/lib/src/polyfill.dart b/lib/src/polyfill.dart
index 95749b9..bdd8330 100644
--- a/lib/src/polyfill.dart
+++ b/lib/src/polyfill.dart
@@ -41,15 +41,14 @@
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) {
@@ -75,7 +74,7 @@
// Replace with latest variable definition.
varDefs[node.definedName] = node;
super.visitVarDefinition(node);
- }
+ }
void visitVarDefinitionDirective(VarDefinitionDirective node) {
visitVarDefinition(node.def);
@@ -110,7 +109,7 @@
super.visitVarDefinition(node);
currVarDefinition = null;
- }
+ }
void visitVarDefinitionDirective(VarDefinitionDirective node) {
visitVarDefinition(node.def);
@@ -149,7 +148,7 @@
terminalDefaults.addAll(resolveUsageTerminal(defaultValue));
}
expressions.replaceRange(index, index + 1, terminalDefaults);
- } else if (node.defaultValues.isNotEmpty){
+ } else if (node.defaultValues.isNotEmpty) {
// No VarDefinition but default value is a terminal expression; use it.
expressions.replaceRange(index, index + 1, node.defaultValues);
} else {
@@ -199,8 +198,7 @@
return result;
}
- _resolveVarUsage(List<Expression> expressions, int index,
- VarDefinition def) {
+ _resolveVarUsage(List<Expression> expressions, int index, VarDefinition def) {
var defExpressions = (def.expression as Expressions).expressions;
expressions.replaceRange(index, index + 1, defExpressions);
}
@@ -224,8 +222,8 @@
}
/** Find terminal definition (non VarUsage implies real CSS value). */
-VarDefinition _findTerminalVarDefinition(Map<String, VarDefinition> varDefs,
- VarDefinition varDef) {
+VarDefinition _findTerminalVarDefinition(
+ Map<String, VarDefinition> varDefs, VarDefinition varDef) {
var expressions = varDef.expression as Expressions;
for (var expr in expressions.expressions) {
if (expr is VarUsage) {
diff --git a/lib/src/property.dart b/lib/src/property.dart
index 5219c25..7e12352 100644
--- a/lib/src/property.dart
+++ b/lib/src/property.dart
@@ -29,7 +29,6 @@
String get cssExpression;
}
-
/**
* Base interface for Color, HSL and RGB.
*/
@@ -47,7 +46,6 @@
int get argbValue;
}
-
/**
* General purpse Color class. Represent a color as an ARGB value that can be
* converted to and from num, hex string, hsl, hsla, rgb, rgba and SVG pre-
@@ -68,8 +66,7 @@
* Color.gold, where ff is red intensity, d7 is green intensity, and 00 is
* blue intensity.
*/
- Color(int rgb, [num alpha]) :
- this._argb = Color._rgbToArgbString(rgb, alpha);
+ Color(int rgb, [num alpha]) : this._argb = Color._rgbToArgbString(rgb, alpha);
/**
* RGB takes three values. The [red], [green], and [blue] parameters are
@@ -81,18 +78,16 @@
* internally be mapped to an int between '0' and '255' like the other color
* 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),
+ 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);
/**
* Creates a new color from a CSS color string. For more information, see
* <https://developer.mozilla.org/en/CSS/color>.
*/
- Color.css(String color) :
- this._argb = Color._convertCssToArgb(color);
+ Color.css(String color) : this._argb = Color._convertCssToArgb(color);
// TODO(jmesserly): I found the use of percents a bit suprising.
/**
@@ -109,8 +104,8 @@
* foreground).
*/
Color.createHsla(num hueDegree, num saturationPercent, num lightnessPercent,
- [num alpha]) :
- this._argb = new Hsla(Color._clamp(hueDegree, 0, 360) / 360,
+ [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();
@@ -130,10 +125,9 @@
* completely transparent foreground and 1 is a completely
* 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),
+ 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();
/**
@@ -151,7 +145,7 @@
// create the CSS from the normalized value.
String get cssExpression {
if (_argb.length == 6) {
- return "#$_argb"; // RGB only, no alpha blending.
+ return "#$_argb"; // RGB only, no alpha blending.
} else {
num alpha = Color.hexToInt(_argb.substring(0, 2));
String a = (alpha / 255).toStringAsPrecision(2);
@@ -246,7 +240,7 @@
String color = value.trim().replaceAll("\\s", "");
if (color[0] == '#') {
String v = color.substring(1);
- Color.hexToInt(v); // Valid hexadecimal, throws if not.
+ Color.hexToInt(v); // Valid hexadecimal, throws if not.
return v;
} else if (color.length > 0 && color[color.length - 1] == ')') {
int type;
@@ -266,7 +260,7 @@
throw new UnsupportedError('CSS property not implemented');
}
- color = color.substring(0, color.length - 1); // Strip close paren.
+ color = color.substring(0, color.length - 1); // Strip close paren.
var args = <num>[];
List<String> params = color.split(",");
@@ -281,8 +275,7 @@
case _hslCss:
return new Hsla(args[0], args[1], args[2]).toHexArgbString();
case _hslaCss:
- return new Hsla(args[0], args[1], args[2],
- args[3]).toHexArgbString();
+ return new Hsla(args[0], args[1], args[2], args[3]).toHexArgbString();
default:
// Type not defined UnsupportedOperationException should have thrown.
assert(true);
@@ -297,8 +290,9 @@
String rHex = Color._numAs2DigitHex(Color._clamp(r, 0, 255));
String gHex = Color._numAs2DigitHex(Color._clamp(g, 0, 255));
String bHex = Color._numAs2DigitHex(Color._clamp(b, 0, 255));
- String aHex = (a != null) ?
- Color._numAs2DigitHex((Color._clamp(a, 0, 1) * 255).round()) : "";
+ String aHex = (a != null)
+ ? Color._numAs2DigitHex((Color._clamp(a, 0, 1) * 255).round())
+ : "";
// TODO(terry) 15.toRadixString(16) return 'F' on Dartium not f as in JS.
// bug: <http://code.google.com/p/dart/issues/detail?id=2670>
@@ -361,7 +355,7 @@
Color._clamp(((1 - delta) * v + (delta * 255)).round(), 0, 255);
// Predefined CSS colors see <http://www.w3.org/TR/css3-color/>
- static final Color transparent = const Color.hex("00ffffff"); // Alpha 0.0
+ static final Color transparent = const Color.hex("00ffffff"); // Alpha 0.0
static final Color aliceBlue = const Color.hex("0f08ff");
static final Color antiqueWhite = const Color.hex("0faebd7");
static final Color aqua = const Color.hex("00ffff");
@@ -511,7 +505,6 @@
static final Color yellowGreen = const Color.hex("9acd32");
}
-
/**
* Rgba class for users that want to interact with a color as a RGBA value.
*/
@@ -523,22 +516,22 @@
final int b;
final num a;
- Rgba(int red, int green, int blue, [num alpha]) :
- this.r = Color._clamp(red, 0, 255),
- this.g = Color._clamp(green, 0, 255),
- this.b = Color._clamp(blue, 0, 255),
- this.a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
+ Rgba(int red, int green, int blue, [num alpha])
+ : this.r = Color._clamp(red, 0, 255),
+ this.g = Color._clamp(green, 0, 255),
+ this.b = Color._clamp(blue, 0, 255),
+ this.a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
factory Rgba.fromString(String hexValue) =>
- new Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
+ new Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
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 */
- ((value.toInt() & 0xff))); /* b */
+ return new Rgba(((value.toInt() & 0xff000000) >> 0x18), /* a */
+ ((value.toInt() & 0xff0000) >> 0x10), /* r */
+ ((value.toInt() & 0xff00) >> 8), /* g */
+ ((value.toInt() & 0xff))); /* b */
}
factory Rgba.fromHsla(Hsla hsla) {
@@ -569,9 +562,9 @@
}
num var1 = 2 * l - var2;
- r = (255 * Rgba._hueToRGB(var1, var2, h + (1/3))).round().toInt();
+ r = (255 * Rgba._hueToRGB(var1, var2, h + (1 / 3))).round().toInt();
g = (255 * Rgba._hueToRGB(var1, var2, h)).round().toInt();
- b = (255 * Rgba._hueToRGB(var1, var2, h - (1/3))).round().toInt();
+ b = (255 * Rgba._hueToRGB(var1, var2, h - (1 / 3))).round().toInt();
}
return new Rgba(r, g, b, a);
@@ -632,7 +625,6 @@
int get hashCode => toHexArgbString().hashCode;
}
-
/**
* Hsl class support to interact with a color as a hsl with hue, saturation, and
* lightness with optional alpha blending. The hue is a ratio of 360 degrees
@@ -640,10 +632,10 @@
* (1 == 100%) and alpha is a 0..1 fraction.
*/
class Hsla implements _StyleProperty, ColorBase {
- final num _h; // Value from 0..1
- final num _s; // Value from 0..1
- final num _l; // Value from 0..1
- final num _a; // Value from 0..1
+ final num _h; // Value from 0..1
+ final num _s; // Value from 0..1
+ final num _l; // Value from 0..1
+ final num _a; // Value from 0..1
/**
* [hue] is a 0..1 fraction of 360 degrees (360 == 0).
@@ -651,11 +643,11 @@
* [lightness] is a 0..1 fraction (100% == 1).
* [alpha] is a 0..1 fraction, alpha blending between 0..1, 1 == 100% opaque.
*/
- Hsla(num hue, num saturation, num lightness, [num alpha]) :
- this._h = (hue == 1) ? 0 : Color._clamp(hue, 0, 1),
- this._s = Color._clamp(saturation, 0, 1),
- this._l = Color._clamp(lightness, 0, 1),
- this._a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
+ Hsla(num hue, num saturation, num lightness, [num alpha])
+ : this._h = (hue == 1) ? 0 : Color._clamp(hue, 0, 1),
+ this._s = Color._clamp(saturation, 0, 1),
+ this._l = Color._clamp(lightness, 0, 1),
+ this._a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
factory Hsla.fromString(String hexValue) {
Rgba rgba = new Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
@@ -682,7 +674,7 @@
}
factory Hsla.fromRgba(Rgba rgba) =>
- _createFromRgba(rgba.r, rgba.g, rgba.b, rgba.a);
+ _createFromRgba(rgba.r, rgba.g, rgba.b, rgba.a);
static Hsla _createFromRgba(num r, num g, num b, num a) {
// Convert RGB to hsl.
@@ -701,7 +693,7 @@
num maxRgb = math.max(r, math.max(g, b));
l = (maxRgb + minRgb) / 2;
if (l <= 0) {
- return new Hsla(0, 0, l); // Black;
+ return new Hsla(0, 0, l); // Black;
}
num vm = maxRgb - minRgb;
@@ -709,7 +701,7 @@
if (s > 0) {
s /= (l < 0.5) ? (maxRgb + minRgb) : (2 - maxRgb - minRgb);
} else {
- return new Hsla(0, 0, l); // White
+ return new Hsla(0, 0, l); // White
}
num r2, g2, b2;
@@ -765,9 +757,9 @@
bool operator ==(other) => Color.equal(this, other);
- String get cssExpression => (_a == null) ?
- "hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)" :
- "hsla($hueDegrees,$saturationPercentage,$lightnessPercentage,$_a)";
+ String get cssExpression => (_a == null)
+ ? "hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)"
+ : "hsla($hueDegrees,$saturationPercentage,$lightnessPercentage,$_a)";
String toHexArgbString() => new Rgba.fromHsla(this).toHexArgbString();
@@ -785,7 +777,6 @@
int get hashCode => toHexArgbString().hashCode;
}
-
/** X,Y position. */
class PointXY implements _StyleProperty {
final num x, y;
@@ -796,7 +787,6 @@
}
}
-
// TODO(terry): Implement style and color.
/**
* Supports border for measuring with layout.
@@ -810,22 +800,25 @@
const Border([this.top, this.left, this.bottom, this.right]);
// TODO(terry): Consider using Size or width and height.
- Border.uniform(num amount) :
- top = amount, left = amount, bottom = amount, right = amount;
+ Border.uniform(num amount)
+ : top = amount,
+ left = amount,
+ bottom = amount,
+ right = amount;
int get width => left + right;
int get height => top + bottom;
String get cssExpression {
- return (top == left && bottom == right && top == right) ? "${left}px" :
- "${top != null ? '$top' : '0'}px ${
+ return (top == left && bottom == right && top == right)
+ ? "${left}px"
+ : "${top != null ? '$top' : '0'}px ${
right != null ? '$right' : '0'}px ${
bottom != null ? '$bottom' : '0'}px ${
left != null ? '$left' : '0'}px";
}
}
-
/** Font style constants. */
class FontStyle {
/** Font style [normal] default. */
@@ -842,7 +835,6 @@
static const String oblique = "oblique";
}
-
/** Font variant constants. */
class FontVariant {
/** Font style [normal] default. */
@@ -851,7 +843,6 @@
static const String smallCaps = "small-caps";
}
-
/** Font weight constants values 100, 200, 300, 400, 500, 600, 700, 800, 900. */
class FontWeight {
/** Font weight normal [default] */
@@ -870,7 +861,6 @@
static const int wt900 = 900;
}
-
/** Generic font family names. */
class FontGeneric {
/** Generic family sans-serif font (w/o serifs). */
@@ -885,7 +875,6 @@
static const String fantasy = "fantasy";
}
-
/**
* List of most common font families across different platforms. Use the
* collection names in the Font class (e.g., Font.SANS_SERIF, Font.FONT_SERIF,
@@ -945,7 +934,7 @@
class LineHeight {
final num height;
final bool inPixels;
- const LineHeight(this.height, {this.inPixels : true});
+ const LineHeight(this.height, {this.inPixels: true});
}
// TODO(terry): Support @font-face fule.
@@ -954,31 +943,41 @@
*/
class Font implements _StyleProperty {
/** Collection of most common sans-serif fonts in order. */
- static const List<String> sansSerif = const [FontFamily.arial,
- FontFamily.verdana,
- FontFamily.geneva,
- FontFamily.helvetica,
- FontGeneric.sansSerif];
+ static const List<String> sansSerif = const [
+ FontFamily.arial,
+ FontFamily.verdana,
+ FontFamily.geneva,
+ FontFamily.helvetica,
+ FontGeneric.sansSerif
+ ];
/** Collection of most common serif fonts in order. */
- static const List<String> serif = const [FontFamily.georgia,
- FontFamily.timesNewRoman,
- FontFamily.times,
- FontGeneric.serif];
+ static const List<String> serif = const [
+ FontFamily.georgia,
+ FontFamily.timesNewRoman,
+ FontFamily.times,
+ FontGeneric.serif
+ ];
/** Collection of most common monospace fonts in order. */
- static const List<String> monospace = const [FontFamily.courierNew,
- FontFamily.courier,
- FontGeneric.monospace];
+ static const List<String> monospace = const [
+ FontFamily.courierNew,
+ FontFamily.courier,
+ FontGeneric.monospace
+ ];
/** Collection of most common cursive fonts in order. */
- static const List<String> cursive = const [FontFamily.textile,
- FontFamily.appleChancery,
- FontFamily.zaphChancery,
- FontGeneric.fantasy];
+ static const List<String> cursive = const [
+ FontFamily.textile,
+ FontFamily.appleChancery,
+ FontFamily.zaphChancery,
+ FontGeneric.fantasy
+ ];
/** Collection of most common fantasy fonts in order. */
- static const List<String> fantasy = const [FontFamily.comicSansMs,
- FontFamily.impact,
- FontFamily.webdings,
- FontGeneric.fantasy];
+ static const List<String> fantasy = const [
+ FontFamily.comicSansMs,
+ FontFamily.impact,
+ FontFamily.webdings,
+ FontGeneric.fantasy
+ ];
// TODO(terry): Should support the values xx-small, small, large, xx-large,
// etc. (mapped to a pixel sized font)?
@@ -1028,7 +1027,7 @@
* pixels, if not specified it's 1.2 the font size.
*/
const Font({this.size, this.family, this.weight, this.style, this.variant,
- this.lineHeight});
+ this.lineHeight});
/**
* Merge the two fonts and return the result. See [Style.merge] for
@@ -1041,12 +1040,12 @@
}
Font._merge(Font a, Font b)
- : size = _mergeVal(a.size, b.size),
- family = _mergeVal(a.family, b.family),
- weight = _mergeVal(a.weight, b.weight),
- style = _mergeVal(a.style, b.style),
- variant = _mergeVal(a.variant, b.variant),
- lineHeight = _mergeVal(a.lineHeight, b.lineHeight);
+ : size = _mergeVal(a.size, b.size),
+ family = _mergeVal(a.family, b.family),
+ weight = _mergeVal(a.weight, b.weight),
+ style = _mergeVal(a.style, b.style),
+ variant = _mergeVal(a.variant, b.variant),
+ lineHeight = _mergeVal(a.lineHeight, b.lineHeight);
/**
* Shorthand CSS format for font is:
@@ -1069,9 +1068,12 @@
return '${size}px $_fontsAsString';
}
- Font scale(num ratio) =>
- new Font(size: size * ratio, family: family, weight: weight, style: style,
- variant: variant);
+ Font scale(num ratio) => new Font(
+ size: size * ratio,
+ family: family,
+ weight: weight,
+ style: style,
+ variant: variant);
/**
* The lineHeight, provides an indirect means to specify the leading. The
@@ -1102,8 +1104,12 @@
bool operator ==(other) {
if (other is! Font) return false;
Font o = other;
- return o.size == size && o.family == family && o.weight == weight &&
- o.lineHeight == lineHeight && o.style == style && o.variant == variant;
+ return o.size == size &&
+ o.family == family &&
+ o.weight == weight &&
+ o.lineHeight == lineHeight &&
+ o.style == style &&
+ o.variant == variant;
}
// TODO(terry): This is fragile should probably just iterate through the list
@@ -1152,14 +1158,17 @@
* <https://developer.mozilla.org/en/CSS/border-width>
* <https://developer.mozilla.org/en/CSS/padding>.
*/
- const BoxEdge.clockwiseFromTop(this.top, this.right, this.bottom, this.left);
+ const BoxEdge.clockwiseFromTop(this.top, this.right, this.bottom, this.left);
/**
* This is a helper to creates a box edge with the same [left], [top]
* [right], and [bottom] widths.
*/
const BoxEdge.uniform(num size)
- : top = size, left = size, bottom = size, right = size;
+ : top = size,
+ left = size,
+ bottom = size,
+ right = size;
/**
* Takes a possibly null box edge, with possibly null metrics, and fills
@@ -1202,10 +1211,10 @@
}
BoxEdge._merge(BoxEdge x, BoxEdge y)
- : left = _mergeVal(x.left, y.left),
- top = _mergeVal(x.top, y.top),
- right = _mergeVal(x.right, y.right),
- bottom = _mergeVal(x.bottom, y.bottom);
+ : left = _mergeVal(x.left, y.left),
+ top = _mergeVal(x.top, y.top),
+ right = _mergeVal(x.right, y.right),
+ bottom = _mergeVal(x.bottom, y.bottom);
/**
* The total size of the horizontal edges. Equal to [left] + [right], where
diff --git a/lib/src/token.dart b/lib/src/token.dart
index b78fbcc..e30484d 100644
--- a/lib/src/token.dart
+++ b/lib/src/token.dart
@@ -61,6 +61,5 @@
class IdentifierToken extends Token {
final String text;
- IdentifierToken(this.text, int kind, FileSpan span)
- : super(kind, span);
+ IdentifierToken(this.text, int kind, FileSpan span) : super(kind, span);
}
diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart
index 8d929ab..ed616d2 100644
--- a/lib/src/tokenizer.dart
+++ b/lib/src/tokenizer.dart
@@ -15,8 +15,7 @@
/** CDATA keyword. */
final List CDATA_NAME = 'CDATA'.codeUnits;
- Tokenizer(SourceFile file, String text, bool skipWhitespace,
- [int index = 0])
+ Tokenizer(SourceFile file, String text, bool skipWhitespace, [int index = 0])
: super(file, text, skipWhitespace, index);
Token next({unicodeRange: false}) {
@@ -44,12 +43,12 @@
Token ident = finishIdentifier();
// Is it a directive?
- int tokId = TokenKind.matchDirectives(_text, _startIndex,
- _index - _startIndex);
+ int tokId = TokenKind.matchDirectives(
+ _text, _startIndex, _index - _startIndex);
if (tokId == -1) {
// No, is it a margin directive?
- tokId = TokenKind.matchMarginDirectives(_text, _startIndex,
- _index - _startIndex);
+ tokId = TokenKind.matchMarginDirectives(
+ _text, _startIndex, _index - _startIndex);
}
if (tokId != -1) {
@@ -63,7 +62,7 @@
}
return _finishToken(TokenKind.AT);
case TokenChar.DOT:
- int start = _startIndex; // Start where the dot started.
+ int start = _startIndex; // Start where the dot started.
if (maybeEatDigit()) {
// looks like a number dot followed by digit(s).
Token number = finishNumber();
@@ -116,19 +115,19 @@
return _finishToken(TokenKind.GREATER);
case TokenChar.TILDE:
if (_maybeEatChar(TokenChar.EQUALS)) {
- return _finishToken(TokenKind.INCLUDES); // ~=
+ return _finishToken(TokenKind.INCLUDES); // ~=
}
return _finishToken(TokenKind.TILDE);
case TokenChar.ASTERISK:
if (_maybeEatChar(TokenChar.EQUALS)) {
- return _finishToken(TokenKind.SUBSTRING_MATCH); // *=
+ return _finishToken(TokenKind.SUBSTRING_MATCH); // *=
}
return _finishToken(TokenKind.ASTERISK);
case TokenChar.AMPERSAND:
return _finishToken(TokenKind.AMPERSAND);
case TokenChar.NAMESPACE:
if (_maybeEatChar(TokenChar.EQUALS)) {
- return _finishToken(TokenKind.DASH_MATCH); // |=
+ return _finishToken(TokenKind.DASH_MATCH); // |=
}
return _finishToken(TokenKind.NAMESPACE);
case TokenChar.COLON:
@@ -146,7 +145,7 @@
case TokenChar.SLASH:
if (_maybeEatChar(TokenChar.ASTERISK)) return finishMultiLineComment();
return _finishToken(TokenKind.SLASH);
- case TokenChar.LESS: // <!--
+ case TokenChar.LESS: // <!--
if (_maybeEatChar(TokenChar.BANG)) {
if (_maybeEatChar(TokenChar.MINUS) &&
_maybeEatChar(TokenChar.MINUS)) {
@@ -167,12 +166,12 @@
return _finishToken(TokenKind.EQUALS);
case TokenChar.CARET:
if (_maybeEatChar(TokenChar.EQUALS)) {
- return _finishToken(TokenKind.PREFIX_MATCH); // ^=
+ return _finishToken(TokenKind.PREFIX_MATCH); // ^=
}
return _finishToken(TokenKind.CARET);
case TokenChar.DOLLAR:
if (_maybeEatChar(TokenChar.EQUALS)) {
- return _finishToken(TokenKind.SUFFIX_MATCH); // $=
+ return _finishToken(TokenKind.SUFFIX_MATCH); // $=
}
return _finishToken(TokenKind.DOLLAR);
case TokenChar.BANG:
@@ -207,8 +206,8 @@
(_peekChar() == UNICODE_PLUS)) {
// Unicode range: U+uNumber[-U+uNumber]
// uNumber = 0..10FFFF
- _nextChar(); // Skip +
- _startIndex = _index; // Starts at the number
+ _nextChar(); // Skip +
+ _startIndex = _index; // Starts at the number
return _finishToken(TokenKind.UNICODE_RANGE);
} else if (varDef(ch)) {
return _finishToken(TokenKind.VAR_DEFINITION);
@@ -224,13 +223,17 @@
}
bool varDef(int ch) {
- return ch == 'v'.codeUnitAt(0) && _maybeEatChar('a'.codeUnitAt(0)) &&
- _maybeEatChar('r'.codeUnitAt(0)) && _maybeEatChar('-'.codeUnitAt(0));
+ return ch == 'v'.codeUnitAt(0) &&
+ _maybeEatChar('a'.codeUnitAt(0)) &&
+ _maybeEatChar('r'.codeUnitAt(0)) &&
+ _maybeEatChar('-'.codeUnitAt(0));
}
bool varUsage(int ch) {
- return ch == 'v'.codeUnitAt(0) && _maybeEatChar('a'.codeUnitAt(0)) &&
- _maybeEatChar('r'.codeUnitAt(0)) && (_peekChar() == '-'.codeUnitAt(0));
+ return ch == 'v'.codeUnitAt(0) &&
+ _maybeEatChar('a'.codeUnitAt(0)) &&
+ _maybeEatChar('r'.codeUnitAt(0)) &&
+ (_peekChar() == '-'.codeUnitAt(0));
}
Token _errorToken([String message = null]) {
@@ -246,8 +249,9 @@
tokId = TokenKind.matchUnits(_text, _startIndex, _index - _startIndex);
}
if (tokId == -1) {
- tokId = (_text.substring(_startIndex, _index) == '!important') ?
- TokenKind.IMPORTANT : -1;
+ tokId = (_text.substring(_startIndex, _index) == '!important')
+ ? TokenKind.IMPORTANT
+ : -1;
}
return tokId >= 0 ? tokId : TokenKind.IDENTIFIER;
@@ -270,7 +274,7 @@
// if followed by hexadecimal digits, create the appropriate character.
// otherwise, include the character in the identifier and don't treat it
// specially.
- if (ch == 92/*\*/) {
+ if (ch == 92 /*\*/) {
int startHex = ++_index;
eatHexDigits(startHex + 6);
if (_index != startHex) {
@@ -282,8 +286,10 @@
// if we stopped the hex because of a whitespace char, skip it
ch = _text.codeUnitAt(_index);
if (_index - startHex != 6 &&
- (ch == TokenChar.SPACE || ch == TokenChar.TAB ||
- ch == TokenChar.RETURN || ch == TokenChar.NEWLINE)) {
+ (ch == TokenChar.SPACE ||
+ ch == TokenChar.TAB ||
+ ch == TokenChar.RETURN ||
+ ch == TokenChar.NEWLINE)) {
_index++;
}
} else {
@@ -291,9 +297,10 @@
if (_index == _text.length) break;
chars.add(_text.codeUnitAt(_index++));
}
- } else if (_index < validateFrom || (inSelectorExpression
- ? TokenizerHelpers.isIdentifierPartExpr(ch)
- : TokenizerHelpers.isIdentifierPart(ch))) {
+ } else if (_index < validateFrom ||
+ (inSelectorExpression
+ ? TokenizerHelpers.isIdentifierPartExpr(ch)
+ : TokenizerHelpers.isIdentifierPart(ch))) {
chars.add(ch);
_index++;
} else {
@@ -311,7 +318,7 @@
Token finishNumber() {
eatDigits();
- if (_peekChar() == 46/*.*/) {
+ if (_peekChar() == 46 /*.*/) {
// Handle the case of 1.toString().
_nextChar();
if (TokenizerHelpers.isDigit(_peekChar())) {
@@ -326,8 +333,8 @@
}
bool maybeEatDigit() {
- if (_index < _text.length
- && TokenizerHelpers.isDigit(_text.codeUnitAt(_index))) {
+ if (_index < _text.length &&
+ TokenizerHelpers.isDigit(_text.codeUnitAt(_index))) {
_index += 1;
return true;
}
@@ -342,17 +349,17 @@
void eatHexDigits(int end) {
end = math.min(end, _text.length);
while (_index < end) {
- if (TokenizerHelpers.isHexDigit(_text.codeUnitAt(_index))) {
- _index += 1;
- } else {
- return;
- }
+ if (TokenizerHelpers.isHexDigit(_text.codeUnitAt(_index))) {
+ _index += 1;
+ } else {
+ return;
+ }
}
}
bool maybeEatHexDigit() {
- if (_index < _text.length
- && TokenizerHelpers.isHexDigit(_text.codeUnitAt(_index))) {
+ if (_index < _text.length &&
+ TokenizerHelpers.isHexDigit(_text.codeUnitAt(_index))) {
_index += 1;
return true;
}
@@ -360,8 +367,7 @@
}
bool maybeEatQuestionMark() {
- if (_index < _text.length &&
- _text.codeUnitAt(_index) == QUESTION_MARK) {
+ if (_index < _text.length && _text.codeUnitAt(_index) == QUESTION_MARK) {
_index += 1;
return true;
}
@@ -370,11 +376,11 @@
void eatQuestionMarks() {
while (_index < _text.length) {
- if (_text.codeUnitAt(_index) == QUESTION_MARK) {
- _index += 1;
- } else {
- return;
- }
+ if (_text.codeUnitAt(_index) == QUESTION_MARK) {
+ _index += 1;
+ } else {
+ return;
+ }
}
}
@@ -388,8 +394,8 @@
int ch = _nextChar();
if (ch == 0) {
return _finishToken(TokenKind.INCOMPLETE_COMMENT);
- } else if (ch == 42/*'*'*/) {
- if (_maybeEatChar(47/*'/'*/)) {
+ } else if (ch == 42 /*'*'*/) {
+ if (_maybeEatChar(47 /*'/'*/)) {
if (_skipWhitespace) {
return next();
} else {
@@ -411,7 +417,6 @@
}
return _errorToken();
}
-
}
/** Static helper methods. */
@@ -421,12 +426,13 @@
}
static bool isDigit(int c) {
- return (c >= 48/*0*/ && c <= 57/*9*/);
+ return (c >= 48 /*0*/ && c <= 57 /*9*/);
}
static bool isHexDigit(int c) {
- return (isDigit(c) || (c >= 97/*a*/ && c <= 102/*f*/)
- || (c >= 65/*A*/ && c <= 70/*F*/));
+ return (isDigit(c) ||
+ (c >= 97 /*a*/ && c <= 102 /*f*/) ||
+ (c >= 65 /*A*/ && c <= 70 /*F*/));
}
static bool isIdentifierPart(int c) {
@@ -435,12 +441,13 @@
/** Pseudo function expressions identifiers can't have a minus sign. */
static bool isIdentifierStartExpr(int c) {
- return ((c >= 97/*a*/ && c <= 122/*z*/) || (c >= 65/*A*/ && c <= 90/*Z*/) ||
+ return ((c >= 97 /*a*/ && c <= 122 /*z*/) ||
+ (c >= 65 /*A*/ && c <= 90 /*Z*/) ||
// Note: Unicode 10646 chars U+00A0 or higher are allowed, see:
// 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 5501e6c..7999a8f 100644
--- a/lib/src/tokenizer_base.dart
+++ b/lib/src/tokenizer_base.dart
@@ -12,11 +12,11 @@
final bool inSelectorExpression;
final bool inSelector;
- TokenizerState(TokenizerBase base) :
- index = base._index,
- startIndex = base._startIndex,
- inSelectorExpression = base.inSelectorExpression,
- inSelector = base.inSelector;
+ TokenizerState(TokenizerBase base)
+ : index = base._index,
+ startIndex = base._startIndex,
+ inSelectorExpression = base.inSelectorExpression,
+ inSelector = base.inSelector;
}
/**
@@ -141,7 +141,6 @@
return _finishToken(TokenKind.WHITESPACE);
}
}
-
}
return _finishToken(TokenKind.END_OF_FILE);
}
@@ -181,11 +180,11 @@
}
static int _hexDigit(int c) {
- if(c >= 48/*0*/ && c <= 57/*9*/) {
+ if (c >= 48 /*0*/ && c <= 57 /*9*/) {
return c - 48;
- } else if (c >= 97/*a*/ && c <= 102/*f*/) {
+ } else if (c >= 97 /*a*/ && c <= 102 /*f*/) {
return c - 87;
- } else if (c >= 65/*A*/ && c <= 70/*F*/) {
+ } else if (c >= 65 /*A*/ && c <= 70 /*F*/) {
return c - 55;
} else {
return -1;
@@ -241,7 +240,7 @@
}
Token finishNumberExtra(int kind) {
- if (_maybeEatChar(101/*e*/) || _maybeEatChar(69/*E*/)) {
+ if (_maybeEatChar(101 /*e*/) || _maybeEatChar(69 /*E*/)) {
kind = TokenKind.DOUBLE;
_maybeEatChar(TokenKind.MINUS);
_maybeEatChar(TokenKind.PLUS);
@@ -276,8 +275,8 @@
} else {
s = _text.substring(_startIndex + 2, _index - 1);
}
- return new LiteralToken(TokenKind.STRING,
- _file.span(_startIndex, _index), s);
+ return new LiteralToken(
+ TokenKind.STRING, _file.span(_startIndex, _index), s);
}
Token finishMultilineString(int quote) {
@@ -382,22 +381,22 @@
final ch = _nextChar();
int hexValue;
switch (ch) {
- case 110/*n*/:
+ case 110 /*n*/ :
return TokenChar.NEWLINE;
- case 114/*r*/:
+ case 114 /*r*/ :
return TokenChar.RETURN;
- case 102/*f*/:
+ case 102 /*f*/ :
return TokenChar.FF;
- case 98/*b*/:
+ case 98 /*b*/ :
return TokenChar.BACKSPACE;
- case 116/*t*/:
+ case 116 /*t*/ :
return TokenChar.TAB;
- case 118/*v*/:
+ case 118 /*v*/ :
return TokenChar.FF;
- case 120/*x*/:
+ case 120 /*x*/ :
hexValue = readHex(2);
break;
- case 117/*u*/:
+ case 117 /*u*/ :
if (_maybeEatChar(TokenChar.LBRACE)) {
hexValue = readHex();
if (!_maybeEatChar(TokenChar.RBRACE)) {
@@ -407,7 +406,8 @@
hexValue = readHex(4);
}
break;
- default: return ch;
+ default:
+ return ch;
}
if (hexValue == -1) return -1;
@@ -417,7 +417,7 @@
// are not legal Unicode values.
if (hexValue < 0xD800 || hexValue > 0xDFFF && hexValue <= 0xFFFF) {
return hexValue;
- } else if (hexValue <= 0x10FFFF){
+ } else if (hexValue <= 0x10FFFF) {
messages.error('unicode values greater than 2 bytes not implemented yet',
_file.span(_startIndex, _startIndex + 1));
return -1;
diff --git a/lib/src/tokenkind.dart b/lib/src/tokenkind.dart
index 67bce33..8e976bf 100644
--- a/lib/src/tokenkind.dart
+++ b/lib/src/tokenkind.dart
@@ -8,44 +8,44 @@
// e.g., ASTERISK or they're CSS e.g., PSEUDO, COMBINATOR_*.
class TokenKind {
// Common shared tokens used in TokenizerBase.
- static const int UNUSED = 0; // Unused place holder...
- static const int END_OF_FILE = 1; // EOF
- static const int LPAREN = 2; // (
- static const int RPAREN = 3; // )
- static const int LBRACK = 4; // [
- static const int RBRACK = 5; // ]
- static const int LBRACE = 6; // {
- static const int RBRACE = 7; // }
- static const int DOT = 8; // .
- static const int SEMICOLON = 9; // ;
+ static const int UNUSED = 0; // Unused place holder...
+ static const int END_OF_FILE = 1; // EOF
+ static const int LPAREN = 2; // (
+ static const int RPAREN = 3; // )
+ static const int LBRACK = 4; // [
+ static const int RBRACK = 5; // ]
+ static const int LBRACE = 6; // {
+ static const int RBRACE = 7; // }
+ static const int DOT = 8; // .
+ static const int SEMICOLON = 9; // ;
// Unique tokens for CSS.
- static const int AT = 10; // @
- static const int HASH = 11; // #
- static const int PLUS = 12; // +
- static const int GREATER = 13; // >
- static const int TILDE = 14; // ~
- static const int ASTERISK = 15; // *
- static const int NAMESPACE = 16; // |
- static const int COLON = 17; // :
- static const int PRIVATE_NAME = 18; // _ prefix private class or id
- static const int COMMA = 19; // ,
+ static const int AT = 10; // @
+ static const int HASH = 11; // #
+ static const int PLUS = 12; // +
+ static const int GREATER = 13; // >
+ static const int TILDE = 14; // ~
+ static const int ASTERISK = 15; // *
+ static const int NAMESPACE = 16; // |
+ static const int COLON = 17; // :
+ static const int PRIVATE_NAME = 18; // _ prefix private class or id
+ static const int COMMA = 19; // ,
static const int SPACE = 20;
- static const int TAB = 21; // /t
- static const int NEWLINE = 22; // /n
- static const int RETURN = 23; // /r
- static const int PERCENT = 24; // %
- static const int SINGLE_QUOTE = 25; // '
- static const int DOUBLE_QUOTE = 26; // "
- static const int SLASH = 27; // /
- static const int EQUALS = 28; // =
- static const int CARET = 30; // ^
- static const int DOLLAR = 31; // $
- static const int LESS = 32; // <
- static const int BANG = 33; // !
- static const int MINUS = 34; // -
- static const int BACKSLASH = 35; // \
- static const int AMPERSAND = 36; // &
+ static const int TAB = 21; // /t
+ static const int NEWLINE = 22; // /n
+ static const int RETURN = 23; // /r
+ static const int PERCENT = 24; // %
+ static const int SINGLE_QUOTE = 25; // '
+ static const int DOUBLE_QUOTE = 26; // "
+ static const int SLASH = 27; // /
+ static const int EQUALS = 28; // =
+ static const int CARET = 30; // ^
+ static const int DOLLAR = 31; // $
+ static const int LESS = 32; // <
+ static const int BANG = 33; // !
+ static const int MINUS = 34; // -
+ static const int BACKSLASH = 35; // \
+ static const int AMPERSAND = 36; // &
// WARNING: Tokens from this point and above must have the corresponding ASCII
// character in the TokenChar list at the bottom of this file. The
@@ -75,41 +75,41 @@
/** [TokenKind] representing incomplete comment tokens. */
static const int INCOMPLETE_COMMENT = 67;
- static const int VAR_DEFINITION = 400; // var-NNN-NNN
- static const int VAR_USAGE = 401; // var(NNN-NNN [,default])
+ static const int VAR_DEFINITION = 400; // var-NNN-NNN
+ static const int VAR_USAGE = 401; // var(NNN-NNN [,default])
// Synthesized Tokens (no character associated with TOKEN).
static const int STRING = 500;
static const int STRING_PART = 501;
static const int NUMBER = 502;
static const int HEX_NUMBER = 503;
- static const int HTML_COMMENT = 504; // <!--
- static const int IMPORTANT = 505; // !important
- static const int CDATA_START = 506; // <![CDATA[
- static const int CDATA_END = 507; // ]]>
+ static const int HTML_COMMENT = 504; // <!--
+ static const int IMPORTANT = 505; // !important
+ static const int CDATA_START = 506; // <![CDATA[
+ static const int CDATA_END = 507; // ]]>
// U+uNumber[-U+uNumber]
// uNumber = 0..10FFFF | ?[?]*
static const int UNICODE_RANGE = 508;
- static const int HEX_RANGE = 509; // ? in the hex range
+ static const int HEX_RANGE = 509; // ? in the hex range
static const int IDENTIFIER = 511;
// Uniquely synthesized tokens for CSS.
static const int SELECTOR_EXPRESSION = 512;
static const int COMBINATOR_NONE = 513;
static const int COMBINATOR_DESCENDANT = 514; // Space combinator
- static const int COMBINATOR_PLUS = 515; // + combinator
- static const int COMBINATOR_GREATER = 516; // > combinator
- static const int COMBINATOR_TILDE = 517; // ~ combinator
+ static const int COMBINATOR_PLUS = 515; // + combinator
+ static const int COMBINATOR_GREATER = 516; // > combinator
+ static const int COMBINATOR_TILDE = 517; // ~ combinator
- static const int UNARY_OP_NONE = 518; // No unary operator present.
+ static const int UNARY_OP_NONE = 518; // No unary operator present.
// Attribute match types:
- static const int INCLUDES = 530; // '~='
- static const int DASH_MATCH = 531; // '|='
- static const int PREFIX_MATCH = 532; // '^='
- static const int SUFFIX_MATCH = 533; // '$='
- static const int SUBSTRING_MATCH = 534; // '*='
- static const int NO_MATCH = 535; // No operator.
+ static const int INCLUDES = 530; // '~='
+ static const int DASH_MATCH = 531; // '|='
+ static const int PREFIX_MATCH = 532; // '^='
+ static const int SUFFIX_MATCH = 533; // '$='
+ static const int SUBSTRING_MATCH = 534; // '*='
+ static const int NO_MATCH = 535; // No operator.
// Unit types:
static const int UNIT_EM = 600;
@@ -133,8 +133,8 @@
static const int UNIT_RESOLUTION_DPI = 618;
static const int UNIT_RESOLUTION_DPCM = 619;
static const int UNIT_RESOLUTION_DPPX = 620;
- static const int UNIT_CH = 621; // Measure of "0" U+0030 glyph.
- static const int UNIT_REM = 622; // computed value ‘font-size’ on root elem.
+ static const int UNIT_CH = 621; // Measure of "0" U+0030 glyph.
+ static const int UNIT_REM = 622; // computed value ‘font-size’ on root elem.
static const int UNIT_VIEWPORT_VW = 623;
static const int UNIT_VIEWPORT_VH = 624;
static const int UNIT_VIEWPORT_VMIN = 625;
@@ -161,9 +161,9 @@
static const int DIRECTIVE_EXTEND = 657;
// Media query operators
- static const int MEDIA_OP_ONLY = 665; // Unary.
- static const int MEDIA_OP_NOT = 666; // Unary.
- static const int MEDIA_OP_AND = 667; // Binary.
+ static const int MEDIA_OP_ONLY = 665; // Unary.
+ static const int MEDIA_OP_NOT = 666; // Unary.
+ static const int MEDIA_OP_AND = 667; // Binary.
// Directives inside of a @page (margin sym).
static const int MARGIN_DIRECTIVE_TOPLEFTCORNER = 670;
@@ -184,259 +184,280 @@
static const int MARGIN_DIRECTIVE_RIGHTBOTTOM = 685;
// Simple selector type.
- static const int CLASS_NAME = 700; // .class
- static const int ELEMENT_NAME = 701; // tagName
- static const int HASH_NAME = 702; // #elementId
- static const int ATTRIBUTE_NAME = 703; // [attrib]
- static const int PSEUDO_ELEMENT_NAME = 704; // ::pseudoElement
- static const int PSEUDO_CLASS_NAME = 705; // :pseudoClass
- static const int NEGATION = 706; // NOT
+ static const int CLASS_NAME = 700; // .class
+ static const int ELEMENT_NAME = 701; // tagName
+ static const int HASH_NAME = 702; // #elementId
+ static const int ATTRIBUTE_NAME = 703; // [attrib]
+ static const int PSEUDO_ELEMENT_NAME = 704; // ::pseudoElement
+ static const int PSEUDO_CLASS_NAME = 705; // :pseudoClass
+ static const int NEGATION = 706; // NOT
static const List<Map<int, String>> _DIRECTIVES = const [
- const {'type': TokenKind.DIRECTIVE_IMPORT, 'value' : 'import'},
- const {'type': TokenKind.DIRECTIVE_MEDIA, 'value' : 'media'},
- const {'type': TokenKind.DIRECTIVE_PAGE, 'value' : 'page'},
- const {'type': TokenKind.DIRECTIVE_CHARSET, 'value' : 'charset'},
- const {'type': TokenKind.DIRECTIVE_STYLET, 'value' : 'stylet'},
- const {'type': TokenKind.DIRECTIVE_KEYFRAMES, 'value' : 'keyframes'},
- const {'type': TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES,
- 'value' : '-webkit-keyframes'},
- const {'type': TokenKind.DIRECTIVE_MOZ_KEYFRAMES,
- 'value' : '-moz-keyframes'},
- const {'type': TokenKind.DIRECTIVE_MS_KEYFRAMES, 'value' : '-ms-keyframes'},
- const {'type': TokenKind.DIRECTIVE_O_KEYFRAMES, 'value' : '-o-keyframes'},
- const {'type': TokenKind.DIRECTIVE_FONTFACE, 'value' : 'font-face'},
- const {'type': TokenKind.DIRECTIVE_NAMESPACE, 'value' : 'namespace'},
- const {'type': TokenKind.DIRECTIVE_HOST, 'value' : 'host'},
- const {'type': TokenKind.DIRECTIVE_MIXIN, 'value' : 'mixin'},
- const {'type': TokenKind.DIRECTIVE_INCLUDE, 'value' : 'include'},
- const {'type': TokenKind.DIRECTIVE_CONTENT, 'value' : 'content'},
- const {'type': TokenKind.DIRECTIVE_EXTEND, 'value' : 'extend'},
+ const {'type': TokenKind.DIRECTIVE_IMPORT, 'value': 'import'},
+ const {'type': TokenKind.DIRECTIVE_MEDIA, 'value': 'media'},
+ const {'type': TokenKind.DIRECTIVE_PAGE, 'value': 'page'},
+ const {'type': TokenKind.DIRECTIVE_CHARSET, 'value': 'charset'},
+ const {'type': TokenKind.DIRECTIVE_STYLET, 'value': 'stylet'},
+ const {'type': TokenKind.DIRECTIVE_KEYFRAMES, 'value': 'keyframes'},
+ const {
+ 'type': TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES,
+ 'value': '-webkit-keyframes'
+ },
+ const {
+ 'type': TokenKind.DIRECTIVE_MOZ_KEYFRAMES,
+ 'value': '-moz-keyframes'
+ },
+ const {'type': TokenKind.DIRECTIVE_MS_KEYFRAMES, 'value': '-ms-keyframes'},
+ const {'type': TokenKind.DIRECTIVE_O_KEYFRAMES, 'value': '-o-keyframes'},
+ const {'type': TokenKind.DIRECTIVE_FONTFACE, 'value': 'font-face'},
+ const {'type': TokenKind.DIRECTIVE_NAMESPACE, 'value': 'namespace'},
+ const {'type': TokenKind.DIRECTIVE_HOST, 'value': 'host'},
+ const {'type': TokenKind.DIRECTIVE_MIXIN, 'value': 'mixin'},
+ const {'type': TokenKind.DIRECTIVE_INCLUDE, 'value': 'include'},
+ const {'type': TokenKind.DIRECTIVE_CONTENT, 'value': 'content'},
+ const {'type': TokenKind.DIRECTIVE_EXTEND, 'value': 'extend'},
];
static const List<Map<int, String>> MEDIA_OPERATORS = const [
- const {'type': TokenKind.MEDIA_OP_ONLY, 'value' : 'only'},
- const {'type': TokenKind.MEDIA_OP_NOT, 'value' : 'not'},
- const {'type': TokenKind.MEDIA_OP_AND, 'value' : 'and'},
-];
+ const {'type': TokenKind.MEDIA_OP_ONLY, 'value': 'only'},
+ const {'type': TokenKind.MEDIA_OP_NOT, 'value': 'not'},
+ const {'type': TokenKind.MEDIA_OP_AND, 'value': 'and'},
+ ];
static const List<Map<int, String>> MARGIN_DIRECTIVES = const [
- const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFTCORNER,
- 'value' : 'top-left-corner'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFT,
- 'value' : 'top-left'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_TOPCENTER,
- 'value' : 'top-center'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHT,
- 'value' : 'top-right'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHTCORNER,
- 'value' : 'top-right-corner'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFTCORNER,
- 'value' : 'bottom-left-corner'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFT,
- 'value' : 'bottom-left'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMCENTER,
- 'value' : 'bottom-center'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHT,
- 'value' : 'bottom-right'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER,
- 'value' : 'bottom-right-corner'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTTOP,
- 'value' : 'left-top'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTMIDDLE,
- 'value' : 'left-middle'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTBOTTOM,
- 'value' : 'right-bottom'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTTOP,
- 'value' : 'right-top'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTMIDDLE,
- 'value' : 'right-middle'},
- const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTBOTTOM,
- 'value' : 'right-bottom'},
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFTCORNER,
+ 'value': 'top-left-corner'
+ },
+ const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFT, 'value': 'top-left'},
+ const {'type': TokenKind.MARGIN_DIRECTIVE_TOPCENTER, 'value': 'top-center'},
+ const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHT, 'value': 'top-right'},
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHTCORNER,
+ 'value': 'top-right-corner'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFTCORNER,
+ 'value': 'bottom-left-corner'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFT,
+ 'value': 'bottom-left'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMCENTER,
+ 'value': 'bottom-center'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHT,
+ 'value': 'bottom-right'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER,
+ 'value': 'bottom-right-corner'
+ },
+ const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTTOP, 'value': 'left-top'},
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_LEFTMIDDLE,
+ 'value': 'left-middle'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_LEFTBOTTOM,
+ 'value': 'right-bottom'
+ },
+ const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTTOP, 'value': 'right-top'},
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_RIGHTMIDDLE,
+ 'value': 'right-middle'
+ },
+ const {
+ 'type': TokenKind.MARGIN_DIRECTIVE_RIGHTBOTTOM,
+ 'value': 'right-bottom'
+ },
];
static const List<Map> _UNITS = const [
- const {'unit': TokenKind.UNIT_EM, 'value' : 'em'},
- const {'unit': TokenKind.UNIT_EX, 'value' : 'ex'},
- const {'unit': TokenKind.UNIT_LENGTH_PX, 'value' : 'px'},
- const {'unit': TokenKind.UNIT_LENGTH_CM, 'value' : 'cm'},
- const {'unit': TokenKind.UNIT_LENGTH_MM, 'value' : 'mm'},
- const {'unit': TokenKind.UNIT_LENGTH_IN, 'value' : 'in'},
- const {'unit': TokenKind.UNIT_LENGTH_PT, 'value' : 'pt'},
- const {'unit': TokenKind.UNIT_LENGTH_PC, 'value' : 'pc'},
- const {'unit': TokenKind.UNIT_ANGLE_DEG, 'value' : 'deg'},
- const {'unit': TokenKind.UNIT_ANGLE_RAD, 'value' : 'rad'},
- const {'unit': TokenKind.UNIT_ANGLE_GRAD, 'value' : 'grad'},
- const {'unit': TokenKind.UNIT_ANGLE_TURN, 'value' : 'turn'},
- const {'unit': TokenKind.UNIT_TIME_MS, 'value' : 'ms'},
- const {'unit': TokenKind.UNIT_TIME_S, 'value' : 's'},
- const {'unit': TokenKind.UNIT_FREQ_HZ, 'value' : 'hz'},
- const {'unit': TokenKind.UNIT_FREQ_KHZ, 'value' : 'khz'},
- const {'unit': TokenKind.UNIT_FRACTION, 'value' : 'fr'},
- const {'unit': TokenKind.UNIT_RESOLUTION_DPI, 'value' : 'dpi'},
- const {'unit': TokenKind.UNIT_RESOLUTION_DPCM, 'value' : 'dpcm'},
- const {'unit': TokenKind.UNIT_RESOLUTION_DPPX, 'value' : 'dppx'},
- const {'unit': TokenKind.UNIT_CH, 'value' : 'ch'},
- const {'unit': TokenKind.UNIT_REM, 'value' : 'rem'},
- const {'unit': TokenKind.UNIT_VIEWPORT_VW, 'value' : 'vw'},
- const {'unit': TokenKind.UNIT_VIEWPORT_VH, 'value' : 'vh'},
- const {'unit': TokenKind.UNIT_VIEWPORT_VMIN, 'value' : 'vmin'},
- const {'unit': TokenKind.UNIT_VIEWPORT_VMAX, 'value' : 'vmax'},
- ];
+ const {'unit': TokenKind.UNIT_EM, 'value': 'em'},
+ const {'unit': TokenKind.UNIT_EX, 'value': 'ex'},
+ const {'unit': TokenKind.UNIT_LENGTH_PX, 'value': 'px'},
+ const {'unit': TokenKind.UNIT_LENGTH_CM, 'value': 'cm'},
+ const {'unit': TokenKind.UNIT_LENGTH_MM, 'value': 'mm'},
+ const {'unit': TokenKind.UNIT_LENGTH_IN, 'value': 'in'},
+ const {'unit': TokenKind.UNIT_LENGTH_PT, 'value': 'pt'},
+ const {'unit': TokenKind.UNIT_LENGTH_PC, 'value': 'pc'},
+ const {'unit': TokenKind.UNIT_ANGLE_DEG, 'value': 'deg'},
+ const {'unit': TokenKind.UNIT_ANGLE_RAD, 'value': 'rad'},
+ const {'unit': TokenKind.UNIT_ANGLE_GRAD, 'value': 'grad'},
+ const {'unit': TokenKind.UNIT_ANGLE_TURN, 'value': 'turn'},
+ const {'unit': TokenKind.UNIT_TIME_MS, 'value': 'ms'},
+ const {'unit': TokenKind.UNIT_TIME_S, 'value': 's'},
+ const {'unit': TokenKind.UNIT_FREQ_HZ, 'value': 'hz'},
+ const {'unit': TokenKind.UNIT_FREQ_KHZ, 'value': 'khz'},
+ const {'unit': TokenKind.UNIT_FRACTION, 'value': 'fr'},
+ const {'unit': TokenKind.UNIT_RESOLUTION_DPI, 'value': 'dpi'},
+ const {'unit': TokenKind.UNIT_RESOLUTION_DPCM, 'value': 'dpcm'},
+ const {'unit': TokenKind.UNIT_RESOLUTION_DPPX, 'value': 'dppx'},
+ const {'unit': TokenKind.UNIT_CH, 'value': 'ch'},
+ const {'unit': TokenKind.UNIT_REM, 'value': 'rem'},
+ const {'unit': TokenKind.UNIT_VIEWPORT_VW, 'value': 'vw'},
+ const {'unit': TokenKind.UNIT_VIEWPORT_VH, 'value': 'vh'},
+ const {'unit': TokenKind.UNIT_VIEWPORT_VMIN, 'value': 'vmin'},
+ const {'unit': TokenKind.UNIT_VIEWPORT_VMAX, 'value': 'vmax'},
+ ];
// Some more constants:
- static const int ASCII_UPPER_A = 65; // ASCII value for uppercase A
- static const int ASCII_UPPER_Z = 90; // ASCII value for uppercase Z
+ static const int ASCII_UPPER_A = 65; // ASCII value for uppercase A
+ static const int ASCII_UPPER_Z = 90; // ASCII value for uppercase Z
// Extended color keywords:
static const List<Map> _EXTENDED_COLOR_NAMES = const [
- const {'name' : 'aliceblue', 'value' : 0xF08FF},
- const {'name' : 'antiquewhite', 'value' : 0xFAEBD7},
- const {'name' : 'aqua', 'value' : 0x00FFFF},
- const {'name' : 'aquamarine', 'value' : 0x7FFFD4},
- const {'name' : 'azure', 'value' : 0xF0FFFF},
- const {'name' : 'beige', 'value' : 0xF5F5DC},
- const {'name' : 'bisque', 'value' : 0xFFE4C4},
- const {'name' : 'black', 'value' : 0x000000},
- const {'name' : 'blanchedalmond', 'value' : 0xFFEBCD},
- const {'name' : 'blue', 'value' : 0x0000FF},
- const {'name' : 'blueviolet', 'value' : 0x8A2BE2},
- const {'name' : 'brown', 'value' : 0xA52A2A},
- const {'name' : 'burlywood', 'value' : 0xDEB887},
- const {'name' : 'cadetblue', 'value' : 0x5F9EA0},
- const {'name' : 'chartreuse', 'value' : 0x7FFF00},
- const {'name' : 'chocolate', 'value' : 0xD2691E},
- const {'name' : 'coral', 'value' : 0xFF7F50},
- const {'name' : 'cornflowerblue', 'value' : 0x6495ED},
- const {'name' : 'cornsilk', 'value' : 0xFFF8DC},
- const {'name' : 'crimson', 'value' : 0xDC143C},
- const {'name' : 'cyan', 'value' : 0x00FFFF},
- const {'name' : 'darkblue', 'value' : 0x00008B},
- const {'name' : 'darkcyan', 'value' : 0x008B8B},
- const {'name' : 'darkgoldenrod', 'value' : 0xB8860B},
- const {'name' : 'darkgray', 'value' : 0xA9A9A9},
- const {'name' : 'darkgreen', 'value' : 0x006400},
- const {'name' : 'darkgrey', 'value' : 0xA9A9A9},
- const {'name' : 'darkkhaki', 'value' : 0xBDB76B},
- const {'name' : 'darkmagenta', 'value' : 0x8B008B},
- const {'name' : 'darkolivegreen', 'value' : 0x556B2F},
- const {'name' : 'darkorange', 'value' : 0xFF8C00},
- const {'name' : 'darkorchid', 'value' : 0x9932CC},
- const {'name' : 'darkred', 'value' : 0x8B0000},
- const {'name' : 'darksalmon', 'value' : 0xE9967A},
- const {'name' : 'darkseagreen', 'value' : 0x8FBC8F},
- const {'name' : 'darkslateblue', 'value' : 0x483D8B},
- const {'name' : 'darkslategray', 'value' : 0x2F4F4F},
- const {'name' : 'darkslategrey', 'value' : 0x2F4F4F},
- const {'name' : 'darkturquoise', 'value' : 0x00CED1},
- const {'name' : 'darkviolet', 'value' : 0x9400D3},
- const {'name' : 'deeppink', 'value' : 0xFF1493},
- const {'name' : 'deepskyblue', 'value' : 0x00BFFF},
- const {'name' : 'dimgray', 'value' : 0x696969},
- const {'name' : 'dimgrey', 'value' : 0x696969},
- const {'name' : 'dodgerblue', 'value' : 0x1E90FF},
- const {'name' : 'firebrick', 'value' : 0xB22222},
- const {'name' : 'floralwhite', 'value' : 0xFFFAF0},
- const {'name' : 'forestgreen', 'value' : 0x228B22},
- const {'name' : 'fuchsia', 'value' : 0xFF00FF},
- const {'name' : 'gainsboro', 'value' : 0xDCDCDC},
- const {'name' : 'ghostwhite', 'value' : 0xF8F8FF},
- const {'name' : 'gold', 'value' : 0xFFD700},
- const {'name' : 'goldenrod', 'value' : 0xDAA520},
- const {'name' : 'gray', 'value' : 0x808080},
- const {'name' : 'green', 'value' : 0x008000},
- const {'name' : 'greenyellow', 'value' : 0xADFF2F},
- const {'name' : 'grey', 'value' : 0x808080},
- const {'name' : 'honeydew', 'value' : 0xF0FFF0},
- const {'name' : 'hotpink', 'value' : 0xFF69B4},
- const {'name' : 'indianred', 'value' : 0xCD5C5C},
- const {'name' : 'indigo', 'value' : 0x4B0082},
- const {'name' : 'ivory', 'value' : 0xFFFFF0},
- const {'name' : 'khaki', 'value' : 0xF0E68C},
- const {'name' : 'lavender', 'value' : 0xE6E6FA},
- const {'name' : 'lavenderblush', 'value' : 0xFFF0F5},
- const {'name' : 'lawngreen', 'value' : 0x7CFC00},
- const {'name' : 'lemonchiffon', 'value' : 0xFFFACD},
- const {'name' : 'lightblue', 'value' : 0xADD8E6},
- const {'name' : 'lightcoral', 'value' : 0xF08080},
- const {'name' : 'lightcyan', 'value' : 0xE0FFFF},
- const {'name' : 'lightgoldenrodyellow', 'value' : 0xFAFAD2},
- const {'name' : 'lightgray', 'value' : 0xD3D3D3},
- const {'name' : 'lightgreen', 'value' : 0x90EE90},
- const {'name' : 'lightgrey', 'value' : 0xD3D3D3},
- const {'name' : 'lightpink', 'value' : 0xFFB6C1},
- const {'name' : 'lightsalmon', 'value' : 0xFFA07A},
- const {'name' : 'lightseagreen', 'value' : 0x20B2AA},
- const {'name' : 'lightskyblue', 'value' : 0x87CEFA},
- const {'name' : 'lightslategray', 'value' : 0x778899},
- const {'name' : 'lightslategrey', 'value' : 0x778899},
- const {'name' : 'lightsteelblue', 'value' : 0xB0C4DE},
- const {'name' : 'lightyellow', 'value' : 0xFFFFE0},
- const {'name' : 'lime', 'value' : 0x00FF00},
- const {'name' : 'limegreen', 'value' : 0x32CD32},
- const {'name' : 'linen', 'value' : 0xFAF0E6},
- const {'name' : 'magenta', 'value' : 0xFF00FF},
- const {'name' : 'maroon', 'value' : 0x800000},
- const {'name' : 'mediumaquamarine', 'value' : 0x66CDAA},
- const {'name' : 'mediumblue', 'value' : 0x0000CD},
- const {'name' : 'mediumorchid', 'value' : 0xBA55D3},
- const {'name' : 'mediumpurple', 'value' : 0x9370DB},
- const {'name' : 'mediumseagreen', 'value' : 0x3CB371},
- const {'name' : 'mediumslateblue', 'value' : 0x7B68EE},
- const {'name' : 'mediumspringgreen', 'value' : 0x00FA9A},
- const {'name' : 'mediumturquoise', 'value' : 0x48D1CC},
- const {'name' : 'mediumvioletred', 'value' : 0xC71585},
- const {'name' : 'midnightblue', 'value' : 0x191970},
- const {'name' : 'mintcream', 'value' : 0xF5FFFA},
- const {'name' : 'mistyrose', 'value' : 0xFFE4E1},
- const {'name' : 'moccasin', 'value' : 0xFFE4B5},
- const {'name' : 'navajowhite', 'value' : 0xFFDEAD},
- const {'name' : 'navy', 'value' : 0x000080},
- const {'name' : 'oldlace', 'value' : 0xFDF5E6},
- const {'name' : 'olive', 'value' : 0x808000},
- const {'name' : 'olivedrab', 'value' : 0x6B8E23},
- const {'name' : 'orange', 'value' : 0xFFA500},
- const {'name' : 'orangered', 'value' : 0xFF4500},
- const {'name' : 'orchid', 'value' : 0xDA70D6},
- const {'name' : 'palegoldenrod', 'value' : 0xEEE8AA},
- const {'name' : 'palegreen', 'value' : 0x98FB98},
- const {'name' : 'paleturquoise', 'value' : 0xAFEEEE},
- const {'name' : 'palevioletred', 'value' : 0xDB7093},
- const {'name' : 'papayawhip', 'value' : 0xFFEFD5},
- const {'name' : 'peachpuff', 'value' : 0xFFDAB9},
- const {'name' : 'peru', 'value' : 0xCD853F},
- const {'name' : 'pink', 'value' : 0xFFC0CB},
- const {'name' : 'plum', 'value' : 0xDDA0DD},
- const {'name' : 'powderblue', 'value' : 0xB0E0E6},
- const {'name' : 'purple', 'value' : 0x800080},
- const {'name' : 'red', 'value' : 0xFF0000},
- const {'name' : 'rosybrown', 'value' : 0xBC8F8F},
- const {'name' : 'royalblue', 'value' : 0x4169E1},
- const {'name' : 'saddlebrown', 'value' : 0x8B4513},
- const {'name' : 'salmon', 'value' : 0xFA8072},
- const {'name' : 'sandybrown', 'value' : 0xF4A460},
- const {'name' : 'seagreen', 'value' : 0x2E8B57},
- const {'name' : 'seashell', 'value' : 0xFFF5EE},
- const {'name' : 'sienna', 'value' : 0xA0522D},
- const {'name' : 'silver', 'value' : 0xC0C0C0},
- const {'name' : 'skyblue', 'value' : 0x87CEEB},
- const {'name' : 'slateblue', 'value' : 0x6A5ACD},
- const {'name' : 'slategray', 'value' : 0x708090},
- const {'name' : 'slategrey', 'value' : 0x708090},
- const {'name' : 'snow', 'value' : 0xFFFAFA},
- const {'name' : 'springgreen', 'value' : 0x00FF7F},
- const {'name' : 'steelblue', 'value' : 0x4682B4},
- const {'name' : 'tan', 'value' : 0xD2B48C},
- const {'name' : 'teal', 'value' : 0x008080},
- const {'name' : 'thistle', 'value' : 0xD8BFD8},
- const {'name' : 'tomato', 'value' : 0xFF6347},
- const {'name' : 'turquoise', 'value' : 0x40E0D0},
- const {'name' : 'violet', 'value' : 0xEE82EE},
- const {'name' : 'wheat', 'value' : 0xF5DEB3},
- const {'name' : 'white', 'value' : 0xFFFFFF},
- const {'name' : 'whitesmoke', 'value' : 0xF5F5F5},
- const {'name' : 'yellow', 'value' : 0xFFFF00},
- const {'name' : 'yellowgreen', 'value' : 0x9ACD32},
+ const {'name': 'aliceblue', 'value': 0xF08FF},
+ const {'name': 'antiquewhite', 'value': 0xFAEBD7},
+ const {'name': 'aqua', 'value': 0x00FFFF},
+ const {'name': 'aquamarine', 'value': 0x7FFFD4},
+ const {'name': 'azure', 'value': 0xF0FFFF},
+ const {'name': 'beige', 'value': 0xF5F5DC},
+ const {'name': 'bisque', 'value': 0xFFE4C4},
+ const {'name': 'black', 'value': 0x000000},
+ const {'name': 'blanchedalmond', 'value': 0xFFEBCD},
+ const {'name': 'blue', 'value': 0x0000FF},
+ const {'name': 'blueviolet', 'value': 0x8A2BE2},
+ const {'name': 'brown', 'value': 0xA52A2A},
+ const {'name': 'burlywood', 'value': 0xDEB887},
+ const {'name': 'cadetblue', 'value': 0x5F9EA0},
+ const {'name': 'chartreuse', 'value': 0x7FFF00},
+ const {'name': 'chocolate', 'value': 0xD2691E},
+ const {'name': 'coral', 'value': 0xFF7F50},
+ const {'name': 'cornflowerblue', 'value': 0x6495ED},
+ const {'name': 'cornsilk', 'value': 0xFFF8DC},
+ const {'name': 'crimson', 'value': 0xDC143C},
+ const {'name': 'cyan', 'value': 0x00FFFF},
+ const {'name': 'darkblue', 'value': 0x00008B},
+ const {'name': 'darkcyan', 'value': 0x008B8B},
+ const {'name': 'darkgoldenrod', 'value': 0xB8860B},
+ const {'name': 'darkgray', 'value': 0xA9A9A9},
+ const {'name': 'darkgreen', 'value': 0x006400},
+ const {'name': 'darkgrey', 'value': 0xA9A9A9},
+ const {'name': 'darkkhaki', 'value': 0xBDB76B},
+ const {'name': 'darkmagenta', 'value': 0x8B008B},
+ const {'name': 'darkolivegreen', 'value': 0x556B2F},
+ const {'name': 'darkorange', 'value': 0xFF8C00},
+ const {'name': 'darkorchid', 'value': 0x9932CC},
+ const {'name': 'darkred', 'value': 0x8B0000},
+ const {'name': 'darksalmon', 'value': 0xE9967A},
+ const {'name': 'darkseagreen', 'value': 0x8FBC8F},
+ const {'name': 'darkslateblue', 'value': 0x483D8B},
+ const {'name': 'darkslategray', 'value': 0x2F4F4F},
+ const {'name': 'darkslategrey', 'value': 0x2F4F4F},
+ const {'name': 'darkturquoise', 'value': 0x00CED1},
+ const {'name': 'darkviolet', 'value': 0x9400D3},
+ const {'name': 'deeppink', 'value': 0xFF1493},
+ const {'name': 'deepskyblue', 'value': 0x00BFFF},
+ const {'name': 'dimgray', 'value': 0x696969},
+ const {'name': 'dimgrey', 'value': 0x696969},
+ const {'name': 'dodgerblue', 'value': 0x1E90FF},
+ const {'name': 'firebrick', 'value': 0xB22222},
+ const {'name': 'floralwhite', 'value': 0xFFFAF0},
+ const {'name': 'forestgreen', 'value': 0x228B22},
+ const {'name': 'fuchsia', 'value': 0xFF00FF},
+ const {'name': 'gainsboro', 'value': 0xDCDCDC},
+ const {'name': 'ghostwhite', 'value': 0xF8F8FF},
+ const {'name': 'gold', 'value': 0xFFD700},
+ const {'name': 'goldenrod', 'value': 0xDAA520},
+ const {'name': 'gray', 'value': 0x808080},
+ const {'name': 'green', 'value': 0x008000},
+ const {'name': 'greenyellow', 'value': 0xADFF2F},
+ const {'name': 'grey', 'value': 0x808080},
+ const {'name': 'honeydew', 'value': 0xF0FFF0},
+ const {'name': 'hotpink', 'value': 0xFF69B4},
+ const {'name': 'indianred', 'value': 0xCD5C5C},
+ const {'name': 'indigo', 'value': 0x4B0082},
+ const {'name': 'ivory', 'value': 0xFFFFF0},
+ const {'name': 'khaki', 'value': 0xF0E68C},
+ const {'name': 'lavender', 'value': 0xE6E6FA},
+ const {'name': 'lavenderblush', 'value': 0xFFF0F5},
+ const {'name': 'lawngreen', 'value': 0x7CFC00},
+ const {'name': 'lemonchiffon', 'value': 0xFFFACD},
+ const {'name': 'lightblue', 'value': 0xADD8E6},
+ const {'name': 'lightcoral', 'value': 0xF08080},
+ const {'name': 'lightcyan', 'value': 0xE0FFFF},
+ const {'name': 'lightgoldenrodyellow', 'value': 0xFAFAD2},
+ const {'name': 'lightgray', 'value': 0xD3D3D3},
+ const {'name': 'lightgreen', 'value': 0x90EE90},
+ const {'name': 'lightgrey', 'value': 0xD3D3D3},
+ const {'name': 'lightpink', 'value': 0xFFB6C1},
+ const {'name': 'lightsalmon', 'value': 0xFFA07A},
+ const {'name': 'lightseagreen', 'value': 0x20B2AA},
+ const {'name': 'lightskyblue', 'value': 0x87CEFA},
+ const {'name': 'lightslategray', 'value': 0x778899},
+ const {'name': 'lightslategrey', 'value': 0x778899},
+ const {'name': 'lightsteelblue', 'value': 0xB0C4DE},
+ const {'name': 'lightyellow', 'value': 0xFFFFE0},
+ const {'name': 'lime', 'value': 0x00FF00},
+ const {'name': 'limegreen', 'value': 0x32CD32},
+ const {'name': 'linen', 'value': 0xFAF0E6},
+ const {'name': 'magenta', 'value': 0xFF00FF},
+ const {'name': 'maroon', 'value': 0x800000},
+ const {'name': 'mediumaquamarine', 'value': 0x66CDAA},
+ const {'name': 'mediumblue', 'value': 0x0000CD},
+ const {'name': 'mediumorchid', 'value': 0xBA55D3},
+ const {'name': 'mediumpurple', 'value': 0x9370DB},
+ const {'name': 'mediumseagreen', 'value': 0x3CB371},
+ const {'name': 'mediumslateblue', 'value': 0x7B68EE},
+ const {'name': 'mediumspringgreen', 'value': 0x00FA9A},
+ const {'name': 'mediumturquoise', 'value': 0x48D1CC},
+ const {'name': 'mediumvioletred', 'value': 0xC71585},
+ const {'name': 'midnightblue', 'value': 0x191970},
+ const {'name': 'mintcream', 'value': 0xF5FFFA},
+ const {'name': 'mistyrose', 'value': 0xFFE4E1},
+ const {'name': 'moccasin', 'value': 0xFFE4B5},
+ const {'name': 'navajowhite', 'value': 0xFFDEAD},
+ const {'name': 'navy', 'value': 0x000080},
+ const {'name': 'oldlace', 'value': 0xFDF5E6},
+ const {'name': 'olive', 'value': 0x808000},
+ const {'name': 'olivedrab', 'value': 0x6B8E23},
+ const {'name': 'orange', 'value': 0xFFA500},
+ const {'name': 'orangered', 'value': 0xFF4500},
+ const {'name': 'orchid', 'value': 0xDA70D6},
+ const {'name': 'palegoldenrod', 'value': 0xEEE8AA},
+ const {'name': 'palegreen', 'value': 0x98FB98},
+ const {'name': 'paleturquoise', 'value': 0xAFEEEE},
+ const {'name': 'palevioletred', 'value': 0xDB7093},
+ const {'name': 'papayawhip', 'value': 0xFFEFD5},
+ const {'name': 'peachpuff', 'value': 0xFFDAB9},
+ const {'name': 'peru', 'value': 0xCD853F},
+ const {'name': 'pink', 'value': 0xFFC0CB},
+ const {'name': 'plum', 'value': 0xDDA0DD},
+ const {'name': 'powderblue', 'value': 0xB0E0E6},
+ const {'name': 'purple', 'value': 0x800080},
+ const {'name': 'red', 'value': 0xFF0000},
+ const {'name': 'rosybrown', 'value': 0xBC8F8F},
+ const {'name': 'royalblue', 'value': 0x4169E1},
+ const {'name': 'saddlebrown', 'value': 0x8B4513},
+ const {'name': 'salmon', 'value': 0xFA8072},
+ const {'name': 'sandybrown', 'value': 0xF4A460},
+ const {'name': 'seagreen', 'value': 0x2E8B57},
+ const {'name': 'seashell', 'value': 0xFFF5EE},
+ const {'name': 'sienna', 'value': 0xA0522D},
+ const {'name': 'silver', 'value': 0xC0C0C0},
+ const {'name': 'skyblue', 'value': 0x87CEEB},
+ const {'name': 'slateblue', 'value': 0x6A5ACD},
+ const {'name': 'slategray', 'value': 0x708090},
+ const {'name': 'slategrey', 'value': 0x708090},
+ const {'name': 'snow', 'value': 0xFFFAFA},
+ const {'name': 'springgreen', 'value': 0x00FF7F},
+ const {'name': 'steelblue', 'value': 0x4682B4},
+ const {'name': 'tan', 'value': 0xD2B48C},
+ const {'name': 'teal', 'value': 0x008080},
+ const {'name': 'thistle', 'value': 0xD8BFD8},
+ const {'name': 'tomato', 'value': 0xFF6347},
+ const {'name': 'turquoise', 'value': 0x40E0D0},
+ const {'name': 'violet', 'value': 0xEE82EE},
+ const {'name': 'wheat', 'value': 0xF5DEB3},
+ const {'name': 'white', 'value': 0xFFFFFF},
+ const {'name': 'whitesmoke', 'value': 0xF5F5F5},
+ const {'name': 'yellow', 'value': 0xFFFF00},
+ const {'name': 'yellowgreen', 'value': 0x9ACD32},
];
// TODO(terry): Should used Dart mirroring for parameter values and types
@@ -448,41 +469,36 @@
// List of valid CSS functions:
static const List<Map<String, Object>> _FUNCTIONS = const [
- const {'name' : 'counter', 'info' : const {'params' : 2, 'expr' : false}},
- const {'name' : 'attr', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'calc', 'info' : const {'params' : 1, 'expr' : true}},
- const {'name' : 'min', 'info' : const {'params' : 2, 'expr' : true}},
- const {'name' : 'max', 'info' : const {'params' : 2, 'expr' : true}},
+ const {'name': 'counter', 'info': const {'params': 2, 'expr': false}},
+ const {'name': 'attr', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'calc', 'info': const {'params': 1, 'expr': true}},
+ const {'name': 'min', 'info': const {'params': 2, 'expr': true}},
+ const {'name': 'max', 'info': const {'params': 2, 'expr': true}},
// 2D functions:
- const {'name' : 'translateX',
- 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'translateY',
- 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'translate', 'info' : const {'params' : 2, 'expr' : false}},
- const {'name' : 'rotate', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'scaleX', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'scaleY', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'scale', 'info' : const {'params' : 2, 'expr' : false}},
- const {'name' : 'skewX', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'skewY', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'skew', 'info' : const {'params' : 2, 'expr' : false}},
- const {'name' : 'matrix', 'info' : const {'params' : 6, 'expr' : false}},
+ const {'name': 'translateX', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'translateY', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'translate', 'info': const {'params': 2, 'expr': false}},
+ const {'name': 'rotate', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'scaleX', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'scaleY', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'scale', 'info': const {'params': 2, 'expr': false}},
+ const {'name': 'skewX', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'skewY', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'skew', 'info': const {'params': 2, 'expr': false}},
+ const {'name': 'matrix', 'info': const {'params': 6, 'expr': false}},
// 3D functions:
- const {'name' : 'matrix3d', 'info' : const {'params' : 16, 'expr' : false}},
- const {'name' : 'translate3d',
- 'info' : const {'params' : 3, 'expr' : false}},
- const {'name' : 'translateZ',
- 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'scale3d', 'info' : const {'params' : 3, 'expr' : false}},
- const {'name' : 'scaleZ', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'rotate3d', 'info' : const {'params' : 3, 'expr' : false}},
- const {'name' : 'rotateX', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'rotateY', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'rotateZ', 'info' : const {'params' : 1, 'expr' : false}},
- const {'name' : 'perspective',
- 'info' : const {'params' : 1, 'expr' : false}},
+ const {'name': 'matrix3d', 'info': const {'params': 16, 'expr': false}},
+ const {'name': 'translate3d', 'info': const {'params': 3, 'expr': false}},
+ const {'name': 'translateZ', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'scale3d', 'info': const {'params': 3, 'expr': false}},
+ const {'name': 'scaleZ', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'rotate3d', 'info': const {'params': 3, 'expr': false}},
+ const {'name': 'rotateX', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'rotateY', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'rotateZ', 'info': const {'params': 1, 'expr': false}},
+ const {'name': 'perspective', 'info': const {'params': 1, 'expr': false}},
];
/**
@@ -503,8 +519,8 @@
}
/** Return the token that matches the unit ident found. */
- static int matchList(var identList, String tokenField, String text,
- int offset, int length) {
+ static int matchList(
+ var identList, String tokenField, String text, int offset, int length) {
for (final entry in identList) {
String ident = entry['value'];
@@ -515,9 +531,10 @@
int identChar = ident.codeUnitAt(i);
int char = text.codeUnitAt(idx++);
// Compare lowercase to lowercase then check if char is uppercase.
- match = match && (char == identChar ||
- ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
- (char + 32) == identChar));
+ match = match &&
+ (char == identChar ||
+ ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
+ (char + 32) == identChar));
if (!match) {
break;
}
@@ -530,7 +547,7 @@
}
}
- return -1; // Not a unit token.
+ return -1; // Not a unit token.
}
/** Return the token that matches the unit ident found. */
@@ -563,7 +580,6 @@
return null;
}
-
/** Return the unit token as its pretty name. */
static String unitToString(int unitTokenToFind) {
if (unitTokenToFind == TokenKind.PERCENT) {
@@ -577,7 +593,7 @@
}
}
- return '<BAD UNIT>'; // Not a unit token.
+ return '<BAD UNIT>'; // Not a unit token.
}
/**
@@ -586,8 +602,8 @@
*/
static Map matchColorName(String text) {
var name = text.toLowerCase();
- return _EXTENDED_COLOR_NAMES.
- firstWhere((e) => e['name'] == name, orElse: () => null);
+ return _EXTENDED_COLOR_NAMES.firstWhere((e) => e['name'] == name,
+ orElse: () => null);
}
/** Return RGB value as [int] from a color entry in _EXTENDED_COLOR_NAMES. */
@@ -633,49 +649,84 @@
}
static String kindToString(int kind) {
- switch(kind) {
- case TokenKind.UNUSED: return "ERROR";
- case TokenKind.END_OF_FILE: return "end of file";
- case TokenKind.LPAREN: return "(";
- case TokenKind.RPAREN: return ")";
- case TokenKind.LBRACK: return "[";
- case TokenKind.RBRACK: return "]";
- case TokenKind.LBRACE: return "{";
- case TokenKind.RBRACE: return "}";
- case TokenKind.DOT: return ".";
- case TokenKind.SEMICOLON: return ";";
- case TokenKind.AT: return "@";
- case TokenKind.HASH: return "#";
- case TokenKind.PLUS: return "+";
- case TokenKind.GREATER: return ">";
- case TokenKind.TILDE: return "~";
- case TokenKind.ASTERISK: return "*";
- case TokenKind.NAMESPACE: return "|";
- case TokenKind.COLON: return ":";
- case TokenKind.PRIVATE_NAME: return "_";
- case TokenKind.COMMA: return ",";
- case TokenKind.SPACE: return " ";
- case TokenKind.TAB: return "\t";
- case TokenKind.NEWLINE: return "\n";
- case TokenKind.RETURN: return "\r";
- case TokenKind.PERCENT: return "%";
- case TokenKind.SINGLE_QUOTE: return "'";
- case TokenKind.DOUBLE_QUOTE: return "\"";
- case TokenKind.SLASH: return "/";
- case TokenKind.EQUALS: return '=';
- case TokenKind.CARET: return '^';
- case TokenKind.DOLLAR: return '\$';
- case TokenKind.LESS: return '<';
- case TokenKind.BANG: return '!';
- case TokenKind.MINUS: return '-';
- case TokenKind.BACKSLASH: return '\\';
+ switch (kind) {
+ case TokenKind.UNUSED:
+ return "ERROR";
+ case TokenKind.END_OF_FILE:
+ return "end of file";
+ case TokenKind.LPAREN:
+ return "(";
+ case TokenKind.RPAREN:
+ return ")";
+ case TokenKind.LBRACK:
+ return "[";
+ case TokenKind.RBRACK:
+ return "]";
+ case TokenKind.LBRACE:
+ return "{";
+ case TokenKind.RBRACE:
+ return "}";
+ case TokenKind.DOT:
+ return ".";
+ case TokenKind.SEMICOLON:
+ return ";";
+ case TokenKind.AT:
+ return "@";
+ case TokenKind.HASH:
+ return "#";
+ case TokenKind.PLUS:
+ return "+";
+ case TokenKind.GREATER:
+ return ">";
+ case TokenKind.TILDE:
+ return "~";
+ case TokenKind.ASTERISK:
+ return "*";
+ case TokenKind.NAMESPACE:
+ return "|";
+ case TokenKind.COLON:
+ return ":";
+ case TokenKind.PRIVATE_NAME:
+ return "_";
+ case TokenKind.COMMA:
+ return ",";
+ case TokenKind.SPACE:
+ return " ";
+ case TokenKind.TAB:
+ return "\t";
+ case TokenKind.NEWLINE:
+ return "\n";
+ case TokenKind.RETURN:
+ return "\r";
+ case TokenKind.PERCENT:
+ return "%";
+ case TokenKind.SINGLE_QUOTE:
+ return "'";
+ case TokenKind.DOUBLE_QUOTE:
+ return "\"";
+ case TokenKind.SLASH:
+ return "/";
+ case TokenKind.EQUALS:
+ return '=';
+ case TokenKind.CARET:
+ return '^';
+ case TokenKind.DOLLAR:
+ return '\$';
+ case TokenKind.LESS:
+ return '<';
+ case TokenKind.BANG:
+ return '!';
+ case TokenKind.MINUS:
+ return '-';
+ case TokenKind.BACKSLASH:
+ return '\\';
default:
throw "Unknown TOKEN";
}
}
static bool isKindIdentifier(int kind) {
- switch(kind) {
+ switch (kind) {
// Synthesized tokens.
case TokenKind.DIRECTIVE_IMPORT:
case TokenKind.DIRECTIVE_MEDIA:
@@ -716,7 +767,7 @@
}
static bool isIdentifier(int kind) {
- return kind == IDENTIFIER ;
+ return kind == IDENTIFIER;
}
}
diff --git a/lib/src/tree.dart b/lib/src/tree.dart
index 37d0741..5dad435 100644
--- a/lib/src/tree.dart
+++ b/lib/src/tree.dart
@@ -11,7 +11,7 @@
class Identifier extends TreeNode {
String name;
- Identifier(this.name, SourceSpan span): super(span);
+ Identifier(this.name, SourceSpan span) : super(span);
Identifier clone() => new Identifier(name, span);
@@ -21,7 +21,7 @@
}
class Wildcard extends TreeNode {
- Wildcard(SourceSpan span): super(span);
+ Wildcard(SourceSpan span) : super(span);
Wildcard clone() => new Wildcard(span);
visit(VisitorBase visitor) => visitor.visitWildcard(this);
@@ -29,7 +29,7 @@
}
class ThisOperator extends TreeNode {
- ThisOperator(SourceSpan span): super(span);
+ ThisOperator(SourceSpan span) : super(span);
ThisOperator clone() => new ThisOperator(span);
visit(VisitorBase visitor) => visitor.visitThisOperator(this);
@@ -37,7 +37,7 @@
}
class Negation extends TreeNode {
- Negation(SourceSpan span): super(span);
+ Negation(SourceSpan span) : super(span);
Negation clone() => new Negation(span);
visit(VisitorBase visitor) => visitor.visitNegation(this);
@@ -48,14 +48,14 @@
class CssComment extends TreeNode {
final String comment;
- CssComment(this.comment, SourceSpan span): super(span);
+ CssComment(this.comment, SourceSpan span) : super(span);
CssComment clone() => new CssComment(comment, span);
visit(VisitorBase visitor) => visitor.visitCssComment(this);
}
// CDO/CDC (Comment Definition Open <!-- and Comment Definition Close -->).
class CommentDefinition extends CssComment {
- CommentDefinition(String comment, SourceSpan span): super(comment, span);
+ CommentDefinition(String comment, SourceSpan span) : super(comment, span);
CommentDefinition clone() => new CommentDefinition(comment, span);
visit(VisitorBase visitor) => visitor.visitCommentDefinition(this);
}
@@ -63,7 +63,7 @@
class SelectorGroup extends TreeNode {
final List<Selector> selectors;
- SelectorGroup(this.selectors, SourceSpan span): super(span);
+ SelectorGroup(this.selectors, SourceSpan span) : super(span);
SelectorGroup clone() => new SelectorGroup(selectors, span);
@@ -80,9 +80,8 @@
int get length => simpleSelectorSequences.length;
Selector clone() {
- var simpleSequences = simpleSelectorSequences
- .map((ss) => ss.clone())
- .toList();
+ var simpleSequences =
+ simpleSelectorSequences.map((ss) => ss.clone()).toList();
return new Selector(simpleSequences, span);
}
@@ -97,7 +96,8 @@
SimpleSelectorSequence(this.simpleSelector, SourceSpan span,
[int combinator = TokenKind.COMBINATOR_NONE])
- : combinator = combinator, super(span);
+ : combinator = combinator,
+ super(span);
bool get isCombinatorNone => combinator == TokenKind.COMBINATOR_NONE;
bool get isCombinatorPlus => combinator == TokenKind.COMBINATOR_PLUS;
@@ -106,11 +106,11 @@
bool get isCombinatorDescendant =>
combinator == TokenKind.COMBINATOR_DESCENDANT;
- String get _combinatorToString =>
- isCombinatorDescendant ? ' ' :
- isCombinatorPlus ? ' + ' :
- isCombinatorGreater ? ' > ' :
- isCombinatorTilde ? ' ~ ' : '';
+ String get _combinatorToString => isCombinatorDescendant
+ ? ' '
+ : isCombinatorPlus
+ ? ' + '
+ : isCombinatorGreater ? ' > ' : isCombinatorTilde ? ' ~ ' : '';
SimpleSelectorSequence clone() =>
new SimpleSelectorSequence(simpleSelector, span, combinator);
@@ -149,7 +149,7 @@
// namespace|element
class NamespaceSelector extends SimpleSelector {
- final _namespace; // null, Wildcard or Identifier
+ final _namespace; // null, Wildcard or Identifier
NamespaceSelector(this._namespace, var name, SourceSpan span)
: super(name, span);
@@ -173,8 +173,8 @@
final int _op;
final _value;
- AttributeSelector(Identifier name, this._op, this._value,
- SourceSpan span) : super(name, span);
+ AttributeSelector(Identifier name, this._op, this._value, SourceSpan span)
+ : super(name, span);
int get operatorKind => _op;
@@ -182,38 +182,38 @@
String matchOperator() {
switch (_op) {
- case TokenKind.EQUALS:
- return '=';
- case TokenKind.INCLUDES:
- return '~=';
- case TokenKind.DASH_MATCH:
- return '|=';
- case TokenKind.PREFIX_MATCH:
- return '^=';
- case TokenKind.SUFFIX_MATCH:
- return '\$=';
- case TokenKind.SUBSTRING_MATCH:
- return '*=';
- case TokenKind.NO_MATCH:
- return '';
+ case TokenKind.EQUALS:
+ return '=';
+ case TokenKind.INCLUDES:
+ return '~=';
+ case TokenKind.DASH_MATCH:
+ return '|=';
+ case TokenKind.PREFIX_MATCH:
+ return '^=';
+ case TokenKind.SUFFIX_MATCH:
+ return '\$=';
+ case TokenKind.SUBSTRING_MATCH:
+ return '*=';
+ case TokenKind.NO_MATCH:
+ return '';
}
}
// Return the TokenKind for operator used by visitAttributeSelector.
String matchOperatorAsTokenString() {
switch (_op) {
- case TokenKind.EQUALS:
- return 'EQUALS';
- case TokenKind.INCLUDES:
- return 'INCLUDES';
- case TokenKind.DASH_MATCH:
- return 'DASH_MATCH';
- case TokenKind.PREFIX_MATCH:
- return 'PREFIX_MATCH';
- case TokenKind.SUFFIX_MATCH:
- return 'SUFFIX_MATCH';
- case TokenKind.SUBSTRING_MATCH:
- return 'SUBSTRING_MATCH';
+ case TokenKind.EQUALS:
+ return 'EQUALS';
+ case TokenKind.INCLUDES:
+ return 'INCLUDES';
+ case TokenKind.DASH_MATCH:
+ return 'DASH_MATCH';
+ case TokenKind.PREFIX_MATCH:
+ return 'PREFIX_MATCH';
+ case TokenKind.SUFFIX_MATCH:
+ return 'SUFFIX_MATCH';
+ case TokenKind.SUBSTRING_MATCH:
+ return 'SUBSTRING_MATCH';
}
}
@@ -284,16 +284,15 @@
PseudoClassFunctionSelector clone() =>
new PseudoClassFunctionSelector(_name, expression, span);
- visit(VisitorBase visitor) =>
- visitor.visitPseudoClassFunctionSelector(this);
+ visit(VisitorBase visitor) => visitor.visitPseudoClassFunctionSelector(this);
}
// ::pseudoElementFunction(expression)
class PseudoElementFunctionSelector extends PseudoElementSelector {
final SelectorExpression expression;
- PseudoElementFunctionSelector(Identifier name, this.expression,
- SourceSpan span)
+ PseudoElementFunctionSelector(
+ Identifier name, this.expression, SourceSpan span)
: super(name, span);
PseudoElementFunctionSelector clone() =>
@@ -306,7 +305,7 @@
class SelectorExpression extends TreeNode {
final List<Expression> expressions;
- SelectorExpression(this.expressions, SourceSpan span): super(span);
+ SelectorExpression(this.expressions, SourceSpan span) : super(span);
SelectorExpression clone() {
return new SelectorExpression(
@@ -387,8 +386,8 @@
class Directive extends TreeNode {
Directive(SourceSpan span) : super(span);
- bool get isBuiltIn => true; // Known CSS directive?
- bool get isExtension => false; // SCSS extension?
+ bool get isBuiltIn => true; // Known CSS directive?
+ bool get isExtension => false; // SCSS extension?
Directive clone() => new Directive(span);
visit(VisitorBase visitor) => visitor.visitDirective(this);
@@ -424,8 +423,8 @@
final Identifier _mediaFeature;
final Expressions exprs;
- MediaExpression(this.andOperator, this._mediaFeature, this.exprs,
- SourceSpan span)
+ MediaExpression(
+ this.andOperator, this._mediaFeature, this.exprs, SourceSpan span)
: super(span);
String get mediaFeature => _mediaFeature.name;
@@ -455,8 +454,8 @@
final Identifier _mediaType;
final List<MediaExpression> expressions;
- MediaQuery(this._mediaUnary, this._mediaType, this.expressions,
- SourceSpan span)
+ MediaQuery(
+ this._mediaUnary, this._mediaType, this.expressions, SourceSpan span)
: super(span);
bool get hasMediaType => _mediaType != null;
@@ -519,8 +518,9 @@
final String _pseudoPage;
final List<DeclarationGroup> _declsMargin;
- PageDirective(this._ident, this._pseudoPage, this._declsMargin,
- SourceSpan span) : super(span);
+ PageDirective(
+ this._ident, this._pseudoPage, this._declsMargin, SourceSpan span)
+ : super(span);
PageDirective clone() {
var cloneDeclsMargin = [];
@@ -553,7 +553,8 @@
final List<KeyFrameBlock> _blocks;
KeyFrameDirective(this._keyframeName, this.name, SourceSpan span)
- : _blocks = [], super(span);
+ : _blocks = [],
+ super(span);
add(KeyFrameBlock block) {
_blocks.add(block);
@@ -564,9 +565,12 @@
case TokenKind.DIRECTIVE_KEYFRAMES:
case TokenKind.DIRECTIVE_MS_KEYFRAMES:
return '@keyframes';
- case TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES: return '@-webkit-keyframes';
- case TokenKind.DIRECTIVE_MOZ_KEYFRAMES: return '@-moz-keyframes';
- case TokenKind.DIRECTIVE_O_KEYFRAMES: return '@-o-keyframes';
+ case TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES:
+ return '@-webkit-keyframes';
+ case TokenKind.DIRECTIVE_MOZ_KEYFRAMES:
+ return '@-moz-keyframes';
+ case TokenKind.DIRECTIVE_O_KEYFRAMES:
+ return '@-o-keyframes';
}
}
@@ -607,7 +611,7 @@
final List<RuleSet> rulesets;
StyletDirective(this.dartClassName, this.rulesets, SourceSpan span)
- : super(span);
+ : super(span);
bool get isBuiltIn => false;
bool get isExtension => true;
@@ -675,8 +679,8 @@
final List<RuleSet> rulesets;
MixinRulesetDirective(String name, List<VarDefinitionDirective> args,
- bool varArgs, this.rulesets, SourceSpan span) :
- super(name, args, varArgs, span);
+ bool varArgs, this.rulesets, SourceSpan span)
+ : super(name, args, varArgs, span);
MixinRulesetDirective clone() {
var clonedArgs = [];
@@ -687,8 +691,8 @@
for (var ruleset in rulesets) {
clonedRulesets.add(ruleset.clone());
}
- return new MixinRulesetDirective(name, clonedArgs, varArgs, clonedRulesets,
- span);
+ return new MixinRulesetDirective(
+ name, clonedArgs, varArgs, clonedRulesets, span);
}
visit(VisitorBase visitor) => visitor.visitMixinRulesetDirective(this);
@@ -697,17 +701,17 @@
class MixinDeclarationDirective extends MixinDefinition {
final DeclarationGroup declarations;
- MixinDeclarationDirective(String name, List<VarDefinitionDirective> args,
- bool varArgs, this.declarations, SourceSpan span) :
- super(name, args, varArgs, span);
+ MixinDeclarationDirective(String name, List<VarDefinitionDirective> args,
+ bool varArgs, this.declarations, SourceSpan span)
+ : super(name, args, varArgs, span);
MixinDeclarationDirective clone() {
var clonedArgs = [];
for (var arg in definedArgs) {
clonedArgs.add(arg.clone());
}
- return new MixinDeclarationDirective(name, clonedArgs, varArgs,
- declarations.clone(), span);
+ return new MixinDeclarationDirective(
+ name, clonedArgs, varArgs, declarations.clone(), span);
}
visit(VisitorBase visitor) => visitor.visitMixinDeclarationDirective(this);
@@ -758,16 +762,18 @@
final bool isIE7;
Declaration(this._property, this._expression, this.dartStyle, SourceSpan span,
- {important: false, ie7: false})
- : this.important = important, this.isIE7 = ie7, super(span);
+ {important: false, ie7: false})
+ : this.important = important,
+ this.isIE7 = ie7,
+ super(span);
String get property => isIE7 ? '*${_property.name}' : _property.name;
Expression get expression => _expression;
bool get hasDartStyle => dartStyle != null;
- Declaration clone() =>
- new Declaration(_property.clone(), _expression.clone(), dartStyle, span,
+ Declaration clone() => new Declaration(
+ _property.clone(), _expression.clone(), dartStyle, span,
important: important);
visit(VisitorBase visitor) => visitor.visitDeclaration(this);
@@ -787,9 +793,8 @@
String get definedName => _property.name;
- VarDefinition clone() =>
- new VarDefinition(_property.clone(),
- expression != null ? expression.clone() : null, span);
+ VarDefinition clone() => new VarDefinition(
+ _property.clone(), expression != null ? expression.clone() : null, span);
visit(VisitorBase visitor) => visitor.visitVarDefinition(this);
}
@@ -810,15 +815,14 @@
IncludeMixinAtDeclaration clone() =>
new IncludeMixinAtDeclaration(include.clone(), span);
- visit(VisitorBase visitor) =>
- visitor.visitIncludeMixinAtDeclaration(this);
+ visit(VisitorBase visitor) => visitor.visitIncludeMixinAtDeclaration(this);
}
class ExtendDeclaration extends Declaration {
final List<TreeNode> selectors;
- ExtendDeclaration(this.selectors, SourceSpan span) :
- super(null, null, null, span);
+ ExtendDeclaration(this.selectors, SourceSpan span)
+ : super(null, null, null, span);
ExtendDeclaration clone() {
var newSelector = selectors.map((s) => s.clone()).toList();
@@ -843,12 +847,12 @@
}
class MarginGroup extends DeclarationGroup {
- final int margin_sym; // TokenType for for @margin sym.
+ final int margin_sym; // TokenType for for @margin sym.
MarginGroup(this.margin_sym, List<Declaration> decls, SourceSpan span)
: super(decls, span);
MarginGroup clone() =>
- new MarginGroup(margin_sym, super.clone() as dynamic, span);
+ new MarginGroup(margin_sym, super.clone() as dynamic, span);
visit(VisitorBase visitor) => visitor.visitMarginGroup(this);
}
@@ -942,7 +946,8 @@
class LengthTerm extends UnitTerm {
LengthTerm(value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(this.unit == TokenKind.UNIT_LENGTH_PX ||
this.unit == TokenKind.UNIT_LENGTH_CM ||
this.unit == TokenKind.UNIT_LENGTH_MM ||
@@ -974,7 +979,8 @@
class AngleTerm extends UnitTerm {
AngleTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(this.unit == TokenKind.UNIT_ANGLE_DEG ||
this.unit == TokenKind.UNIT_ANGLE_RAD ||
this.unit == TokenKind.UNIT_ANGLE_GRAD ||
@@ -987,7 +993,8 @@
class TimeTerm extends UnitTerm {
TimeTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(this.unit == TokenKind.UNIT_ANGLE_DEG ||
this.unit == TokenKind.UNIT_TIME_MS ||
this.unit == TokenKind.UNIT_TIME_S);
@@ -999,7 +1006,8 @@
class FreqTerm extends UnitTerm {
FreqTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(unit == TokenKind.UNIT_FREQ_HZ || unit == TokenKind.UNIT_FREQ_KHZ);
}
@@ -1023,7 +1031,8 @@
class ResolutionTerm extends UnitTerm {
ResolutionTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(unit == TokenKind.UNIT_RESOLUTION_DPI ||
unit == TokenKind.UNIT_RESOLUTION_DPCM ||
unit == TokenKind.UNIT_RESOLUTION_DPPX);
@@ -1035,7 +1044,8 @@
class ChTerm extends UnitTerm {
ChTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(unit == TokenKind.UNIT_CH);
}
@@ -1045,7 +1055,8 @@
class RemTerm extends UnitTerm {
RemTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(unit == TokenKind.UNIT_REM);
}
@@ -1055,7 +1066,8 @@
class ViewportTerm extends UnitTerm {
ViewportTerm(var value, String t, SourceSpan span,
- [int unit = TokenKind.UNIT_LENGTH_PX]) : super(value, t, span, unit) {
+ [int unit = TokenKind.UNIT_LENGTH_PX])
+ : super(value, t, span, unit) {
assert(unit == TokenKind.UNIT_VIEWPORT_VW ||
unit == TokenKind.UNIT_VIEWPORT_VH ||
unit == TokenKind.UNIT_VIEWPORT_VMIN ||
@@ -1067,7 +1079,7 @@
}
/** Type to signal a bad hex value for HexColorTerm.value. */
-class BAD_HEX_VALUE { }
+class BAD_HEX_VALUE {}
class HexColorTerm extends LiteralTerm {
HexColorTerm(var value, String t, SourceSpan span) : super(value, t, span);
@@ -1100,7 +1112,9 @@
class GroupTerm extends Expression {
final List<LiteralTerm> _terms;
- GroupTerm(SourceSpan span) : _terms = [], super(span);
+ GroupTerm(SourceSpan span)
+ : _terms = [],
+ super(span);
void add(LiteralTerm term) {
_terms.add(term);
@@ -1120,7 +1134,7 @@
class Expressions extends Expression {
final List<Expression> expressions = [];
- Expressions(SourceSpan span): super(span);
+ Expressions(SourceSpan span) : super(span);
void add(Expression expression) {
expressions.add(expression);
@@ -1141,7 +1155,7 @@
final Expression x;
final Expression y;
- BinaryExpression(this.op, this.x, this.y, SourceSpan span): super(span);
+ BinaryExpression(this.op, this.x, this.y, SourceSpan span) : super(span);
BinaryExpression clone() =>
new BinaryExpression(op, x.clone(), y.clone(), span);
@@ -1152,7 +1166,7 @@
final Token op;
final Expression self;
- UnaryExpression(this.op, this.self, SourceSpan span): super(span);
+ UnaryExpression(this.op, this.self, SourceSpan span) : super(span);
UnaryExpression clone() => new UnaryExpression(op, self.clone(), span);
visit(VisitorBase visitor) => visitor.visitUnaryExpression(this);
@@ -1200,10 +1214,14 @@
// 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}) :
- font = new Font(size : size is LengthTerm ? size.value : size,
- family: family, weight: weight, style: style, variant: variant,
- lineHeight: lineHeight),
+ 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),
super(DartStyleExpression.fontStyle, span);
FontExpression merged(DartStyleExpression newFontExpr) {
@@ -1224,10 +1242,13 @@
: font = new Font.merge(x.font, y.font),
super(DartStyleExpression.fontStyle, span);
- FontExpression clone() =>
- new FontExpression(span, size: font.size, family: font.family,
- weight: font.weight, style: font.style, variant: font.variant,
- lineHeight: font.lineHeight);
+ FontExpression clone() => new FontExpression(span,
+ size: font.size,
+ family: font.family,
+ weight: font.weight,
+ style: font.style,
+ variant: font.variant,
+ lineHeight: font.lineHeight);
visit(VisitorBase visitor) => visitor.visitFontExpression(this);
}
@@ -1241,8 +1262,7 @@
visit(VisitorBase visitor) => visitor.visitBoxExpression(this);
String get formattedBoxEdge {
- if (box.top == box.left && box.top == box.bottom &&
- box.top== box.right) {
+ if (box.top == box.left && box.top == box.bottom && box.top == box.right) {
return '.uniform(${box.top})';
} else {
var left = box.left == null ? 0 : box.left;
@@ -1259,13 +1279,14 @@
/** 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);
merged(DartStyleExpression newMarginExpr) {
- if (newMarginExpr is MarginExpression && this.isMargin &&
+ if (newMarginExpr is MarginExpression &&
+ this.isMargin &&
newMarginExpr.isMargin) {
return new MarginExpression.merge(this, newMarginExpr);
}
@@ -1280,13 +1301,12 @@
return new MarginExpression._merge(x, y, y.span);
}
- MarginExpression._merge(MarginExpression x, MarginExpression y,
- SourceSpan span)
+ MarginExpression._merge(
+ MarginExpression x, MarginExpression y, SourceSpan span)
: super(x._styleType, span, new BoxEdge.merge(x.box, y.box));
- MarginExpression clone() =>
- new MarginExpression(span, top: box.top, right: box.right,
- bottom: box.bottom, left: box.left);
+ MarginExpression clone() => new MarginExpression(span,
+ top: box.top, right: box.right, bottom: box.bottom, left: box.left);
visit(VisitorBase visitor) => visitor.visitMarginExpression(this);
}
@@ -1295,13 +1315,15 @@
/** 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);
merged(DartStyleExpression newBorderExpr) {
- if (newBorderExpr is BorderExpression && this.isBorder && newBorderExpr.isBorder) {
+ if (newBorderExpr is BorderExpression &&
+ this.isBorder &&
+ newBorderExpr.isBorder) {
return new BorderExpression.merge(this, newBorderExpr);
}
@@ -1315,14 +1337,13 @@
return new BorderExpression._merge(x, y, y.span);
}
- BorderExpression._merge(BorderExpression x, BorderExpression y,
- SourceSpan span)
+ 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);
+ BorderExpression clone() => new BorderExpression(span,
+ top: box.top, right: box.right, bottom: box.bottom, left: box.left);
visit(VisitorBase visitor) => visitor.visitBorderExpression(this);
}
@@ -1334,7 +1355,9 @@
: super(DartStyleExpression.heightStyle, span);
merged(DartStyleExpression newHeightExpr) {
- if (newHeightExpr is DartStyleExpression && this.isHeight && newHeightExpr.isHeight) {
+ if (newHeightExpr is DartStyleExpression &&
+ this.isHeight &&
+ newHeightExpr.isHeight) {
return newHeightExpr;
}
@@ -1352,7 +1375,8 @@
: super(DartStyleExpression.widthStyle, span);
merged(DartStyleExpression newWidthExpr) {
- if (newWidthExpr is WidthExpression && this.isWidth &&
+ if (newWidthExpr is WidthExpression &&
+ this.isWidth &&
newWidthExpr.isWidth) {
return newWidthExpr;
}
@@ -1368,13 +1392,14 @@
/** 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);
merged(DartStyleExpression newPaddingExpr) {
- if (newPaddingExpr is PaddingExpression && this.isPadding &&
+ if (newPaddingExpr is PaddingExpression &&
+ this.isPadding &&
newPaddingExpr.isPadding) {
return new PaddingExpression.merge(this, newPaddingExpr);
}
@@ -1389,13 +1414,12 @@
return new PaddingExpression._merge(x, y, y.span);
}
- PaddingExpression._merge(PaddingExpression x, PaddingExpression y,
- SourceSpan span)
+ 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);
+ PaddingExpression clone() => new PaddingExpression(span,
+ top: box.top, right: box.right, bottom: box.bottom, left: box.left);
visit(VisitorBase visitor) => visitor.visitPaddingExpression(this);
}
diff --git a/lib/src/tree_base.dart b/lib/src/tree_base.dart
index 35aef13..095b493 100644
--- a/lib/src/tree_base.dart
+++ b/lib/src/tree_base.dart
@@ -29,7 +29,7 @@
/** The base type for expressions. */
abstract class Expression extends TreeNode {
- Expression(SourceSpan span): super(span);
+ Expression(SourceSpan span) : super(span);
}
/** Simple class to provide a textual dump of trees for debugging. */
@@ -39,7 +39,7 @@
VisitorBase printer;
void write(String s) {
- for (int i=0; i < depth; i++) {
+ for (int i = 0; i < depth; i++) {
buf.write(' ');
}
buf.write(s);
diff --git a/lib/src/tree_printer.dart b/lib/src/tree_printer.dart
index 3a8b748..8cb4de8 100644
--- a/lib/src/tree_printer.dart
+++ b/lib/src/tree_printer.dart
@@ -17,7 +17,9 @@
class _TreePrinter extends Visitor {
final TreeOutput output;
final bool useSpan;
- _TreePrinter(this.output, this.useSpan) { output.printer = this; }
+ _TreePrinter(this.output, this.useSpan) {
+ output.printer = this;
+ }
void visitTree(StyleSheet tree) => visitStylesheet(tree);
@@ -244,8 +246,8 @@
void visitSelector(Selector node) {
heading('Selector', node);
output.depth++;
- output.writeNodeList('simpleSelectorsSequences',
- node.simpleSelectorSequences);
+ output.writeNodeList(
+ 'simpleSelectorsSequences', node.simpleSelectorSequences);
output.depth--;
}
@@ -370,7 +372,7 @@
output.depth++;
output.writeValue('value', node.text);
output.depth--;
- }
+ }
void visitHexColorTerm(HexColorTerm node) {
heading('HexColorTerm', node);
diff --git a/lib/src/validate.dart b/lib/src/validate.dart
index bc3a6ad..d45cd95 100644
--- a/lib/src/validate.dart
+++ b/lib/src/validate.dart
@@ -40,9 +40,9 @@
// Perfect just one element id returns matches of -1.
return -1;
} else if (selector.isCombinatorDescendant()) {
- String tooMany = selector.simpleSelector.toString();
- throw new CssSelectorException(
- 'Use of Id selector must be singleton starting at $tooMany');
+ String tooMany = selector.simpleSelector.toString();
+ throw new CssSelectorException(
+ 'Use of Id selector must be singleton starting at $tooMany');
} else {
String error = selector.simpleSelector.toString();
throw new CssSelectorException(
@@ -53,9 +53,9 @@
// Validate the @{css expression} only .class and #elementId are valid inside
// of @{...}.
static template(List<Selector> selectors) {
- var errorSelector; // signal which selector didn't match.
- bool found = false; // signal if a selector is matched.
- int matches = 0; // < 0 IdSelectors, > 0 ClassSelector
+ var errorSelector; // signal which selector didn't match.
+ bool found = false; // signal if a selector is matched.
+ int matches = 0; // < 0 IdSelectors, > 0 ClassSelector
// At most one selector group (any number of simple selector sequences).
assert(selectors.length <= 1);
@@ -73,20 +73,19 @@
for (final className in classes) {
if (selector.simpleSelector.name == className) {
matches = _classNameCheck(selector, matches);
- found = true; // .class found.
+ found = true; // .class found.
break;
}
for (final className2 in classes) {
print(className2);
}
}
-
} else {
// Don't check any class name that is prefixed with an underscore.
// However, signal as found and bump up matches; it's a valid class
// name.
matches = _classNameCheck(selector, matches);
- found = true; // ._class are always okay.
+ found = true; // ._class are always okay.
}
} else if (simpleSelector is IdSelector) {
// Any element id starting with an underscore is a private element id
@@ -95,7 +94,7 @@
for (final id in ids) {
if (simpleSelector.name == id) {
matches = _elementIdCheck(selector, matches);
- found = true; // #id found.
+ found = true; // #id found.
break;
}
}
@@ -103,7 +102,7 @@
// Don't check any element ID that is prefixed with an underscore.
// Signal as found and bump up matches; it's a valid element ID.
matches = _elementIdCheck(selector, matches);
- found = true; // #_id are always okay
+ found = true; // #_id are always okay
}
} else {
String badSelector = simpleSelector.toString();
@@ -124,4 +123,3 @@
selector.simpleSelectorSequences.length);
}
}
-
diff --git a/lib/visitor.dart b/lib/visitor.dart
index 154d235..fa0f8d2 100644
--- a/lib/visitor.dart
+++ b/lib/visitor.dart
@@ -126,15 +126,15 @@
_visitNodeList(ss.topLevels);
}
- void visitNoOp(NoOp node) { }
+ void visitNoOp(NoOp node) {}
- void visitTopLevelProduction(TopLevelProduction node) { }
+ void visitTopLevelProduction(TopLevelProduction node) {}
- void visitDirective(Directive node) { }
+ void visitDirective(Directive node) {}
- void visitCssComment(CssComment node) { }
+ void visitCssComment(CssComment node) {}
- void visitCommentDefinition(CommentDefinition node) { }
+ void visitCommentDefinition(CommentDefinition node) {}
void visitMediaExpression(MediaExpression node) {
visitExpressions(node.exprs);
@@ -171,7 +171,7 @@
}
}
- void visitCharsetDirective(CharsetDirective node) { }
+ void visitCharsetDirective(CharsetDirective node) {}
void visitImportDirective(ImportDirective node) {
for (var mediaQuery in node.mediaQueries) {
@@ -197,7 +197,7 @@
_visitNodeList(node.rulesets);
}
- void visitNamespaceDirective(NamespaceDirective node) { }
+ void visitNamespaceDirective(NamespaceDirective node) {}
void visitVarDefinitionDirective(VarDefinitionDirective node) {
visitVarDefinition(node.def);
@@ -207,7 +207,7 @@
_visitNodeList(node.rulesets);
}
- void visitMixinDefinition(MixinDefinition node) { }
+ void visitMixinDefinition(MixinDefinition node) {}
void visitMixinDeclarationDirective(MixinDeclarationDirective node) {
visitDeclarationGroup(node.declarations);
@@ -303,15 +303,15 @@
_visitNodeList(node.expressions);
}
- void visitUnicodeRangeTerm(UnicodeRangeTerm node) { }
+ void visitUnicodeRangeTerm(UnicodeRangeTerm node) {}
- void visitLiteralTerm(LiteralTerm node) { }
+ void visitLiteralTerm(LiteralTerm node) {}
- void visitHexColorTerm(HexColorTerm node) { }
+ void visitHexColorTerm(HexColorTerm node) {}
- void visitNumberTerm(NumberTerm node) { }
+ void visitNumberTerm(NumberTerm node) {}
- void visitUnitTerm(UnitTerm node) { }
+ void visitUnitTerm(UnitTerm node) {}
void visitLengthTerm(LengthTerm node) {
visitUnitTerm(node);
@@ -380,15 +380,15 @@
visitNumberTerm(node);
}
- void visitIE8Term(IE8Term node) { }
+ void visitIE8Term(IE8Term node) {}
- void visitOperatorSlash(OperatorSlash node) { }
+ void visitOperatorSlash(OperatorSlash node) {}
- void visitOperatorComma(OperatorComma node) { }
+ void visitOperatorComma(OperatorComma node) {}
- void visitOperatorPlus(OperatorPlus node) { }
+ void visitOperatorPlus(OperatorPlus node) {}
- void visitOperatorMinus(OperatorMinus node) { }
+ void visitOperatorMinus(OperatorMinus node) {}
void visitVarUsage(VarUsage node) {
_visitNodeList(node.defaultValues);
@@ -408,15 +408,15 @@
throw UnimplementedError;
}
- void visitIdentifier(Identifier node) { }
+ void visitIdentifier(Identifier node) {}
- void visitWildcard(Wildcard node) { }
+ void visitWildcard(Wildcard node) {}
- void visitThisOperator(ThisOperator node) { }
+ void visitThisOperator(ThisOperator node) {}
- void visitNegation(Negation node) { }
+ void visitNegation(Negation node) {}
- void visitDartStyleExpression(DartStyleExpression node) { }
+ void visitDartStyleExpression(DartStyleExpression node) {}
void visitFontExpression(FontExpression node) {
// TODO(terry): TBD
diff --git a/pubspec.yaml b/pubspec.yaml
index 7bb6317..b168432 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: csslib
-version: 0.11.0+4
+version: 0.11.1-dev
author: Polymer.dart Team <web-ui-dev@dartlang.org>
description: A library for parsing CSS.
homepage: https://github.com/dart-lang/csslib
diff --git a/test/big_1_test.dart b/test/big_1_test.dart
index 5210115..ed1c271 100644
--- a/test/big_1_test.dart
+++ b/test/big_1_test.dart
@@ -7,7 +7,7 @@
import 'package:unittest/unittest.dart';
import 'testing.dart';
-var options = ['--warnings_as_errors', '--no-colors', 'memory'];
+var options = ['--warnings_as_errors', '--no-colors', 'memory'];
compilePolyfillAndValidate(String input, String generated) {
var errors = [];
diff --git a/test/compiler_test.dart b/test/compiler_test.dart
index 8d63f8b..a7cdf4a 100644
--- a/test/compiler_test.dart
+++ b/test/compiler_test.dart
@@ -516,10 +516,10 @@
var errors = [];
var input = '<![CDATA[.foo { '
'color: red; left: 20px; top: 20px; width: 100px; height:200px'
- '}'
- '#div {'
+ '}'
+ '#div {'
'color : #00F578; border-color: #878787;'
- '}]]>';
+ '}]]>';
var stylesheet = parse(UTF8.encode(input), errors: errors);
@@ -584,8 +584,8 @@
div:nth-child(2n) { color : red; }
''';
- var stylesheet = parseCss(input, errors: errors,
- opts: ['--no-colors', 'memory']);
+ var stylesheet =
+ parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -647,16 +647,16 @@
var errors = [];
var input = '@host { '
':scope {'
- 'white-space: nowrap;'
- 'overflow-style: marquee-line;'
- 'overflow-x: marquee;'
+ 'white-space: nowrap;'
+ 'overflow-style: marquee-line;'
+ 'overflow-x: marquee;'
'}'
'* { color: red; }'
'*:hover { font-weight: bold; }'
':nth-child(odd) { color: blue; }'
- '}';
- var stylesheet = parseCss(input, errors: errors,
- opts: ['--no-colors', 'memory']);
+ '}';
+ var stylesheet =
+ parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -684,10 +684,10 @@
var errors = [];
var input = '.foo { '
'color: red; left: 20px; top: 20px; width: 100px; height:200px'
- '}'
- '#div {'
+ '}'
+ '#div {'
'color : #00F578; border-color: #878787;'
- '}';
+ '}';
var stylesheet = parseCss(input, errors: errors);
expect(stylesheet != null, true);
diff --git a/test/declaration_test.dart b/test/declaration_test.dart
index 857df48..0cf012c 100644
--- a/test/declaration_test.dart
+++ b/test/declaration_test.dart
@@ -7,7 +7,6 @@
import 'package:unittest/unittest.dart';
import 'testing.dart';
-
/** CSS compiler options no checks in in memory style sheet. */
List options = ['--no-colors', 'memory'];
@@ -365,7 +364,7 @@
}
}''';
generated =
- '''@media handheld AND (min-width:20em), screen AND (min-width:20em) {
+ '''@media handheld AND (min-width:20em), screen AND (min-width:20em) {
#id {
color: #f00;
}
@@ -481,8 +480,7 @@
url(basic-sans-serif.ttf) format("opentype"),
local(Gentium Bold);
}''';
- final String generated2 =
- '@font-face {\n'
+ final String generated2 = '@font-face {\n'
' src: url("ideal-sans-serif.woff") '
'format("woff"), url("basic-sans-serif.ttf") '
'format("opentype"), local(Gentium Bold);\n}';
@@ -563,8 +561,7 @@
}
''';
- final String generated =
- '@import "simple.css"; '
+ final String generated = '@import "simple.css"; '
'@import "test.css" print; '
'@import "test.css" screen, print; '
'@import "http://google.com/maps/maps.css";\n'
@@ -715,36 +712,32 @@
void testIE() {
var errors = [];
- final String input =
-".test {\n"
-" filter: progid:DXImageTransform.Microsoft.gradient"
-"(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n"
-"}";
- final String generated =
-".test {\n"
-" filter: progid:DXImageTransform.Microsoft.gradient"
-"(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n"
-"}";
+ final String input = ".test {\n"
+ " filter: progid:DXImageTransform.Microsoft.gradient"
+ "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n"
+ "}";
+ final String generated = ".test {\n"
+ " filter: progid:DXImageTransform.Microsoft.gradient"
+ "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n"
+ "}";
- var stylesheet = parseCss(input, errors: errors, opts: options);
+ var stylesheet = parseCss(input, errors: errors, opts: options);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(stylesheet), generated);
- final String input2 =
-".test {\n"
-" filter: progid:DXImageTransform.Microsoft.gradient"
-"(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n"
-" progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n"
-"}";
+ final String input2 = ".test {\n"
+ " filter: progid:DXImageTransform.Microsoft.gradient"
+ "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n"
+ " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n"
+ "}";
- final String generated2 =
-".test {\n"
-" filter: progid:DXImageTransform.Microsoft.gradient"
-"(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n"
-" progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n"
-"}";
+ final String generated2 = ".test {\n"
+ " filter: progid:DXImageTransform.Microsoft.gradient"
+ "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n"
+ " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n"
+ "}";
stylesheet = parseCss(input2, errors: errors..clear(), opts: options);
diff --git a/test/error_test.dart b/test/error_test.dart
index f48906c..363bf3d 100644
--- a/test/error_test.dart
+++ b/test/error_test.dart
@@ -223,7 +223,6 @@
.foobar {
color: # 123 fff;
}''');
-
}
void testBadUnicode() {
@@ -239,7 +238,7 @@
expect(errors.isEmpty, false);
expect(errors[0].toString(),
'error on line 3, column 20: unicode first range can not be greater than '
- 'last\n'
+ 'last\n'
' unicode-range: U+400-200;\n'
' ^^^^^^^');
diff --git a/test/extend_test.dart b/test/extend_test.dart
index 7136c45..ed24b35 100644
--- a/test/extend_test.dart
+++ b/test/extend_test.dart
@@ -7,7 +7,7 @@
import 'package:unittest/unittest.dart';
import 'testing.dart';
-var options = ['--warnings_as_errors', '--no-colors', 'memory'];
+var options = ['--warnings_as_errors', '--no-colors', 'memory'];
compileAndValidate(String input, String generated) {
var errors = [];
@@ -215,13 +215,13 @@
color: blue;
}
''', '.btn + .btn, '
- 'input.second + label + .btn, '
- '.btn + input.second + label, '
+ 'input.second + label + .btn, '
+ '.btn + input.second + label, '
'input.second + label + input.second + label, '
'input.second + label + input.second + label {\n'
- ' margin-left: 5px;\n}\n'
- 'input.second + label {\n'
- ' color: #00f;\n}');
+ ' margin-left: 5px;\n}\n'
+ 'input.second + label {\n'
+ ' color: #00f;\n}');
}
main() {
diff --git a/test/mixin_test.dart b/test/mixin_test.dart
index 6d3b71e..5e32723 100644
--- a/test/mixin_test.dart
+++ b/test/mixin_test.dart
@@ -496,7 +496,6 @@
expect(prettyPrint(stylesheet), generated);
}
-
void undefinedTopLevel() {
final errors = [];
final input = r'''
diff --git a/test/nested_test.dart b/test/nested_test.dart
index ef7cb46..c72666e 100644
--- a/test/nested_test.dart
+++ b/test/nested_test.dart
@@ -159,9 +159,9 @@
color: #f00;
}
'''
-'html button span, body button span, html div span, body div span, '
-'html button a, body button a, html div a, body div a, html button ul, '
-r'''body button ul, html div ul, body div ul {
+ 'html button span, body button span, html div span, body div span, '
+ 'html button a, body button a, html div a, body div a, html button ul, '
+ r'''body button ul, html div ul, body div ul {
height: 200;
}
html table, body table {
@@ -215,8 +215,7 @@
div > span[attr="foo"] { color: yellow; }
''';
- final generated =
-r'''div span {
+ final generated = r'''div span {
color: #008000;
}
#header {
diff --git a/test/selector_test.dart b/test/selector_test.dart
index 3f764e7..43a5a35 100644
--- a/test/selector_test.dart
+++ b/test/selector_test.dart
@@ -27,8 +27,8 @@
expect(errors.isEmpty, true, reason: errors.toString());
expect('.foobar .a-story .xyzzy', compactOuptut(selectorAst));
- selectorAst = selector('.foobar .xyzzy .a-story .b-story',
- errors: errors..clear());
+ selectorAst =
+ selector('.foobar .xyzzy .a-story .b-story', errors: errors..clear());
expect(errors.isEmpty, true, reason: errors.toString());
expect('.foobar .xyzzy .a-story .b-story', compactOuptut(selectorAst));
@@ -56,7 +56,7 @@
expect(errors.isEmpty, false);
expect(errors[0].toString(),
'error on line 1, column 9: name must start with a alpha character, but '
- 'found a number\n'
+ 'found a number\n'
'.foobar .1a-story .xyzzy\n'
' ^^');
}
diff --git a/test/testing.dart b/test/testing.dart
index 002c452..b9a6738 100644
--- a/test/testing.dart
+++ b/test/testing.dart
@@ -18,10 +18,12 @@
* 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 parseCss(String cssInput, {List<Message> errors,
- List<String> opts}) =>
- parse(cssInput, errors: errors, options: opts == null ?
- ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts);
+StyleSheet parseCss(String cssInput,
+ {List<Message> errors, List<String> opts}) => parse(cssInput,
+ errors: errors,
+ options: opts == null
+ ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
+ : opts);
/**
* Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
@@ -29,13 +31,16 @@
* tests (by default) will ensure that the CSS is really valid.
*/
StyleSheet compileCss(String cssInput, {List<Message> errors, List<String> opts,
- bool polyfill: false, List<StyleSheet> includes: null}) =>
- compile(cssInput, errors: errors, options: opts == null ?
- ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts,
- polyfill: polyfill, includes: includes);
+ bool polyfill: false, List<StyleSheet> includes: null}) => compile(cssInput,
+ errors: errors,
+ options: opts == null
+ ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
+ : opts,
+ polyfill: polyfill,
+ includes: includes);
-StyleSheet polyFillCompileCss(input, {List<Message> errors,
- List<String> opts}) =>
+StyleSheet polyFillCompileCss(input,
+ {List<Message> errors, List<String> opts}) =>
compileCss(input, errors: errors, polyfill: true, opts: opts);
/** CSS emitter walks the style sheet tree and emits readable CSS. */
diff --git a/test/var_test.dart b/test/var_test.dart
index 0ec2852..17349b8 100644
--- a/test/var_test.dart
+++ b/test/var_test.dart
@@ -393,27 +393,27 @@
var errorStrings = [
'error on line 5, column 14: Variable is not defined.\n'
- ' var-a: var(b);\n'
- ' ^^',
+ ' var-a: var(b);\n'
+ ' ^^',
'error on line 6, column 14: Variable is not defined.\n'
- ' var-b: var(c);\n'
- ' ^^',
+ ' var-b: var(c);\n'
+ ' ^^',
'error on line 9, column 16: Variable is not defined.\n'
- ' var-one: var(two);\n'
- ' ^^^^',
+ ' var-one: var(two);\n'
+ ' ^^^^',
'error on line 12, column 17: Variable is not defined.\n'
- ' var-four: var(five);\n'
- ' ^^^^^',
+ ' var-four: var(five);\n'
+ ' ^^^^^',
'error on line 13, column 17: Variable is not defined.\n'
- ' var-five: var(six);\n'
- ' ^^^^',
+ ' var-five: var(six);\n'
+ ' ^^^^',
'error on line 16, column 18: Variable is not defined.\n'
- ' var-def-1: var(def-2);\n'
- ' ^^^^^^',
+ ' var-def-1: var(def-2);\n'
+ ' ^^^^^^',
'error on line 17, column 18: Variable is not defined.\n'
- ' var-def-2: var(def-3);\n'
- ' ^^^^^^',
- ];
+ ' var-def-2: var(def-3);\n'
+ ' ^^^^^^',
+ ];
var generated = r''':root {
var-color-background: #f00;
@@ -445,8 +445,8 @@
compileAndValidate(input, generated);
- var stylesheet = polyFillCompileCss(input, errors: errors..clear(),
- opts: options);
+ var stylesheet =
+ polyFillCompileCss(input, errors: errors..clear(), opts: options);
expect(stylesheet != null, true);
@@ -644,8 +644,8 @@
color: var(color-foreground);
}''';
- var stylesheet = parseCss(input, errors: errors,
- opts: ['--no-colors', 'memory']);
+ var stylesheet =
+ parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -670,8 +670,8 @@
color: var(color-foreground);
}''';
- stylesheet = parseCss(input, errors: errors..clear(),
- opts: ['--no-colors', 'memory']);
+ stylesheet =
+ parseCss(input, errors: errors..clear(), opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -699,8 +699,8 @@
color: var(color-foreground);
}''';
- var stylesheet = parseCss(input, errors: errors,
- opts: ['--no-colors', 'memory']);
+ var stylesheet =
+ parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -725,8 +725,8 @@
color: var(color-foreground);
}''';
- stylesheet = parseCss(input, errors: errors..clear(),
- opts: ['--no-colors', 'memory']);
+ stylesheet =
+ parseCss(input, errors: errors..clear(), opts: ['--no-colors', 'memory']);
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
@@ -854,8 +854,8 @@
border-color: var(a3);
}''';
- var stylesheet2 = compileCss(file2Input, includes: [stylesheet1],
- errors: errors..clear(), opts: options);
+ var stylesheet2 = compileCss(file2Input,
+ includes: [stylesheet1], errors: errors..clear(), opts: options);
expect(stylesheet2 != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(stylesheet2), generated2);
@@ -870,8 +870,8 @@
.test-1a {
color: #000;
}''';
- var styleSheet1Polyfill = compileCss(file1Input, errors: errors..clear(),
- polyfill: true, opts: options);
+ var styleSheet1Polyfill = compileCss(file1Input,
+ errors: errors..clear(), polyfill: true, opts: options);
expect(styleSheet1Polyfill != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(styleSheet1Polyfill), generatedPolyfill1);
@@ -883,8 +883,11 @@
background-color: #0b0;
border-color: #fff;
}''';
- var styleSheet2Polyfill = compileCss(file2Input, includes: [stylesheet1],
- errors: errors..clear(), polyfill: true, opts: options);
+ var styleSheet2Polyfill = compileCss(file2Input,
+ includes: [stylesheet1],
+ errors: errors..clear(),
+ polyfill: true,
+ opts: options);
expect(styleSheet2Polyfill != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(styleSheet2Polyfill), generatedPolyfill2);
@@ -900,8 +903,10 @@
border-color: #fff;
}''';
var stylesheetPolyfill = compileCss(input,
- includes: [stylesheet1, stylesheet2], errors: errors..clear(),
- polyfill: true, opts: options);
+ includes: [stylesheet1, stylesheet2],
+ errors: errors..clear(),
+ polyfill: true,
+ opts: options);
expect(stylesheetPolyfill != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
diff --git a/test/visitor_test.dart b/test/visitor_test.dart
index 451b687..1777748 100644
--- a/test/visitor_test.dart
+++ b/test/visitor_test.dart
@@ -43,7 +43,7 @@
var clsVisits = new ClassVisitor(['foobar'])..visitTree(s);
expect(clsVisits.matches, true);
- in1= '''
+ in1 = '''
.foobar1 { }
.xyzzy .foo #my-div { color: red; }
div.hello { font: arial; }
@@ -54,8 +54,8 @@
expect(s != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- clsVisits =
- new ClassVisitor(['foobar1', 'xyzzy', 'foo', 'hello'])..visitTree(s);
+ clsVisits = new ClassVisitor(['foobar1', 'xyzzy', 'foo', 'hello'])
+ ..visitTree(s);
expect(clsVisits.matches, true);
expect(prettyPrint(s), r'''
@@ -80,7 +80,7 @@
}
String polyfillPrint(String prefix, StyleSheet ss) =>
- (new PolyfillEmitter(prefix)..visitTree(ss, pretty: true)).toString();
+ (new PolyfillEmitter(prefix)..visitTree(ss, pretty: true)).toString();
void testPolyFill() {
var errors = [];