Enable lints, fix formatting, test on oldest supported SDK (#89)
diff --git a/.gitignore b/.gitignore
index a6867f2..79f51c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,3 @@
-# Don’t commit the following directories created by pub.
-.pub/
-build/
-packages
+.dart_tool
.packages
-
-# Or the files created by dart2js.
-*.dart.js
-*.js_
-*.js.deps
-*.js.map
-
-# Include when developing application packages.
pubspec.lock
diff --git a/.travis.yml b/.travis.yml
index afad71a..8681e29 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,20 @@
language: dart
dart:
+ - 2.0.0
- dev
dart_task:
- test: --platform vm
- test: --platform firefox -j 1
- - dartanalyzer
matrix:
include:
- dart: dev
+ dartanalyzer: --fatal-infos --fatal-warnings .
+ - dart: stable
+ dartanalyzer: --fatal-warnings .
+ - dart: dev
dart_task: dartfmt
# Only building master means that we don't run two builds for each pull request.
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..9d14291
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,9 @@
+include: package:pedantic/analysis_options.yaml
+
+linter:
+ rules:
+ - prefer_equal_for_default_values
+ - prefer_generic_function_type_aliases
+ - slash_for_doc_comments
+ - unnecessary_const
+ - unnecessary_new
diff --git a/bin/css.dart b/bin/css.dart
index f64faac..1aae7a8 100644
--- a/bin/css.dart
+++ b/bin/css.dart
@@ -3,6 +3,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// ignore: deprecated_member_use_from_same_package
import 'package:csslib/css.dart' as css;
void main(List<String> args) => css.main(args);
diff --git a/example/call_parser.dart b/example/call_parser.dart
index fc6b33c..fc299d9 100644
--- a/example/call_parser.dart
+++ b/example/call_parser.dart
@@ -4,7 +4,7 @@
import 'package:csslib/parser.dart' as css;
import 'package:csslib/visitor.dart';
-const _default = const css.PreprocessorOptions(
+const _default = css.PreprocessorOptions(
useColors: false,
checked: true,
warningsAsErrors: true,
@@ -20,7 +20,7 @@
}
// Pretty printer for CSS.
-var emitCss = new CssPrinter();
+var emitCss = CssPrinter();
String prettyPrint(StyleSheet ss) =>
(emitCss..visitTree(ss, pretty: true)).toString();
diff --git a/lib/css.dart b/lib/css.dart
index f47b4f1..ac6510b 100644
--- a/lib/css.dart
+++ b/lib/css.dart
@@ -20,7 +20,7 @@
var options = _parseOptions(arguments);
if (options == null) return;
- messages = new Messages(options: options);
+ messages = Messages(options: options);
_time('Total time spent on ${options.inputFile}', () {
_compile(options.inputFile, options.verbose);
@@ -36,24 +36,24 @@
try {
// Read the file.
var filename = path.basename(inputPath);
- var contents = new File(inputPath).readAsStringSync();
- var file = new SourceFile.fromString(contents, url: path.toUri(inputPath));
+ var contents = File(inputPath).readAsStringSync();
+ var file = SourceFile.fromString(contents, url: path.toUri(inputPath));
// Parse the CSS.
- StyleSheet tree = _time(
- 'Parse $filename', () => new Parser(file, contents).parse(), verbose);
+ StyleSheet tree =
+ _time('Parse $filename', () => Parser(file, contents).parse(), verbose);
- _time('Analyzer $filename', () => new Analyzer([tree], messages), verbose)
+ _time('Analyzer $filename', () => Analyzer([tree], messages), verbose)
.run();
// Emit the processed CSS.
- var emitter = new CssPrinter();
+ var emitter = CssPrinter();
_time('Codegen $filename', () => emitter.visitTree(tree, pretty: true),
verbose);
// Write the contents to a file.
var outPath = path.join(path.dirname(inputPath), '_$filename');
- new File(outPath).writeAsStringSync(emitter.toString());
+ File(outPath).writeAsStringSync(emitter.toString());
} catch (e) {
messages.error('error processing $inputPath. Original message:\n $e', null);
}
@@ -61,7 +61,7 @@
T _time<T>(String message, T Function() callback, bool printTime) {
if (!printTime) return callback();
- final watch = new Stopwatch();
+ final watch = Stopwatch();
watch.start();
var result = callback();
watch.stop();
@@ -71,7 +71,7 @@
}
void _printMessage(String message, int duration) {
- var buf = new StringBuffer();
+ var buf = StringBuffer();
buf.write(message);
for (int i = message.length; i < 60; i++) buf.write(' ');
buf.write(' -- ');
@@ -81,7 +81,7 @@
print(buf.toString());
}
-PreprocessorOptions _fromArgs(ArgResults args) => new PreprocessorOptions(
+PreprocessorOptions _fromArgs(ArgResults args) => PreprocessorOptions(
warningsAsErrors: args['warnings_as_errors'],
throwOnWarnings: args['throw_on_warnings'],
throwOnErrors: args['throw_on_errors'],
@@ -90,11 +90,11 @@
lessSupport: args['less'],
useColors: args['colors'],
polyfill: args['polyfill'],
- inputFile: args.rest.length > 0 ? args.rest[0] : null);
+ inputFile: args.rest.isNotEmpty ? args.rest[0] : null);
// tool.dart [options...] <css file>
PreprocessorOptions _parseOptions(List<String> arguments) {
- var parser = new ArgParser()
+ var parser = ArgParser()
..addFlag('verbose',
abbr: 'v',
defaultsTo: false,
@@ -128,7 +128,7 @@
try {
var results = parser.parse(arguments);
- if (results['help'] || results.rest.length == 0) {
+ if (results['help'] || results.rest.isEmpty) {
_showUsage(parser);
return null;
}
diff --git a/lib/parser.dart b/lib/parser.dart
index 511f204..7680683 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -43,10 +43,10 @@
if (errors == null) errors = [];
if (options == null) {
- options = new PreprocessorOptions(useColors: false, inputFile: 'memory');
+ options = PreprocessorOptions(useColors: false, inputFile: 'memory');
}
- messages = new Messages(options: options, printHandler: errors.add);
+ messages = Messages(options: options, printHandler: errors.add);
}
/// CSS checked mode enabled.
@@ -57,9 +57,9 @@
StyleSheet compile(input,
{List<Message> errors,
PreprocessorOptions options,
- bool nested: true,
- bool polyfill: false,
- List<StyleSheet> includes: null}) {
+ bool nested = true,
+ bool polyfill = false,
+ List<StyleSheet> includes}) {
if (includes == null) {
includes = [];
}
@@ -68,14 +68,14 @@
_createMessages(errors: errors, options: options);
- var file = new SourceFile.fromString(source);
+ var file = SourceFile.fromString(source);
- var tree = new _Parser(file, source).parse();
+ var tree = _Parser(file, source).parse();
analyze([tree], errors: errors, options: options);
if (polyfill) {
- var processCss = new PolyFill(messages);
+ var processCss = PolyFill(messages);
processCss.process(tree, includes: includes);
}
@@ -86,7 +86,7 @@
void analyze(List<StyleSheet> styleSheets,
{List<Message> errors, PreprocessorOptions options}) {
_createMessages(errors: errors, options: options);
- new Analyzer(styleSheets, messages).run();
+ Analyzer(styleSheets, messages).run();
}
/// Parse the [input] CSS stylesheet into a tree. The [input] can be a [String],
@@ -97,8 +97,8 @@
_createMessages(errors: errors, options: options);
- var file = new SourceFile.fromString(source);
- return new _Parser(file, source).parse();
+ var file = SourceFile.fromString(source);
+ return _Parser(file, source).parse();
}
/// Parse the [input] CSS selector into a tree. The [input] can be a [String],
@@ -110,9 +110,8 @@
_createMessages(errors: errors);
- var file = new SourceFile.fromString(source);
- return (new _Parser(file, source)..tokenizer.inSelector = true)
- .parseSelector();
+ var file = SourceFile.fromString(source);
+ return (_Parser(file, source)..tokenizer.inSelector = true).parseSelector();
}
SelectorGroup parseSelectorGroup(input, {List<Message> errors}) {
@@ -120,8 +119,8 @@
_createMessages(errors: errors);
- var file = new SourceFile.fromString(source);
- return (new _Parser(file, source)
+ var file = SourceFile.fromString(source);
+ return (_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.
@@ -149,10 +148,10 @@
// See encoding helpers at: package:html5lib/lib/src/char_encodings.dart
// These helpers can decode in different formats given an encoding name
// (mostly unicode, ascii, windows-1252 which is html5 default encoding).
- source = new String.fromCharCodes(input as List<int>);
+ source = String.fromCharCodes(input as List<int>);
} else {
// TODO(terry): Support RandomAccessFile using console.
- throw new ArgumentError("'source' must be a String or "
+ throw ArgumentError("'source' must be a String or "
"List<int> (of bytes). RandomAccessFile not supported from this "
"simple interface");
}
@@ -168,14 +167,14 @@
// TODO(jmesserly): having file and text is redundant.
// TODO(rnystrom): baseUrl isn't used. Remove from API.
- Parser(SourceFile file, String text, {int start: 0, String baseUrl})
- : _parser = new _Parser(file, text, start: start);
+ Parser(SourceFile file, String text, {int start = 0, String baseUrl})
+ : _parser = _Parser(file, text, start: start);
StyleSheet parse() => _parser.parse();
}
// CSS2.1 pseudo-elements which were defined with a single ':'.
-final _legacyPseudoElements = new Set<String>.from(const [
+final _legacyPseudoElements = Set<String>.from(const [
'after',
'before',
'first-letter',
@@ -193,9 +192,9 @@
Token _previousToken;
Token _peekToken;
- _Parser(SourceFile file, String text, {int start: 0})
+ _Parser(SourceFile file, String text, {int start = 0})
: this.file = file,
- tokenizer = new Tokenizer(file, text, true, start) {
+ tokenizer = Tokenizer(file, text, true, start) {
_peekToken = tokenizer.next();
}
@@ -216,7 +215,7 @@
checkEndOfFile();
- return new StyleSheet(productions, _makeSpan(start));
+ return StyleSheet(productions, _makeSpan(start));
}
/// Main entry point for parsing a simple selector sequence.
@@ -233,7 +232,7 @@
checkEndOfFile();
- return new StyleSheet.selector(productions, _makeSpan(start));
+ return StyleSheet.selector(productions, _makeSpan(start));
}
/// Generate an error if [file] has not been completely consumed.
@@ -264,7 +263,7 @@
return _peekToken.kind;
}
- Token _next({bool unicodeRange: false}) {
+ Token _next({bool unicodeRange = false}) {
_previousToken = _peekToken;
_peekToken = tokenizer.next(unicodeRange: unicodeRange);
return _previousToken;
@@ -280,8 +279,7 @@
}
/// Marks the parser/tokenizer look ahead to support Less nested selectors.
- ParserState get _mark =>
- new ParserState(_peekToken, _previousToken, tokenizer);
+ ParserState get _mark => ParserState(_peekToken, _previousToken, tokenizer);
/// Restores the parser/tokenizer state to state remembered by _mark.
void _restore(ParserState markedData) {
@@ -290,7 +288,7 @@
_previousToken = markedData.previousToken;
}
- bool _maybeEat(int kind, {bool unicodeRange: false}) {
+ bool _maybeEat(int kind, {bool unicodeRange = false}) {
if (_peekToken.kind == kind) {
_previousToken = _peekToken;
_peekToken = tokenizer.next(unicodeRange: unicodeRange);
@@ -300,7 +298,7 @@
}
}
- void _eat(int kind, {bool unicodeRange: false}) {
+ void _eat(int kind, {bool unicodeRange = false}) {
if (!_maybeEat(kind, unicodeRange: unicodeRange)) {
_errorExpected(TokenKind.kindToString(kind));
}
@@ -421,8 +419,8 @@
exprs.add(expr);
}
- if (unaryOp != -1 || type != null || exprs.length > 0) {
- return new MediaQuery(unaryOp, type, exprs, _makeSpan(start));
+ if (unaryOp != -1 || type != null || exprs.isNotEmpty) {
+ return MediaQuery(unaryOp, type, exprs, _makeSpan(start));
}
return null;
}
@@ -436,10 +434,9 @@
var feature = identifier(); // Media feature.
var exprs = _maybeEat(TokenKind.COLON)
? processExpr()
- : new Expressions(_makeSpan(_peekToken.span));
+ : Expressions(_makeSpan(_peekToken.span));
if (_maybeEat(TokenKind.RPAREN)) {
- return new MediaExpression(
- andOperator, feature, exprs, _makeSpan(start));
+ return MediaExpression(andOperator, feature, exprs, _makeSpan(start));
} else if (isChecked) {
_warning(
"Missing parenthesis around media expression", _makeSpan(start));
@@ -500,7 +497,7 @@
_error('missing import string', _peekToken.span);
}
- return new ImportDirective(importStr.trim(), medias, _makeSpan(start));
+ return ImportDirective(importStr.trim(), medias, _makeSpan(start));
case TokenKind.DIRECTIVE_MEDIA:
_next();
@@ -522,7 +519,7 @@
} else {
_error('expected { after media before ruleset', _peekToken.span);
}
- return new MediaDirective(media, rules, _makeSpan(start));
+ return MediaDirective(media, rules, _makeSpan(start));
case TokenKind.DIRECTIVE_HOST:
_next();
@@ -541,7 +538,7 @@
} else {
_error('expected { after host before ruleset', _peekToken.span);
}
- return new HostDirective(rules, _makeSpan(start));
+ return HostDirective(rules, _makeSpan(start));
case TokenKind.DIRECTIVE_PAGE:
// @page S* IDENT? pseudo_page?
@@ -585,7 +582,7 @@
String pseudoName = pseudoPage is Identifier ? pseudoPage.name : '';
String ident = name is Identifier ? name.name : '';
- return new PageDirective(
+ return PageDirective(
ident, pseudoName, processMarginsDeclarations(), _makeSpan(start));
case TokenKind.DIRECTIVE_CHARSET:
@@ -598,7 +595,7 @@
_warning('missing character encoding string', _makeSpan(start));
}
- return new CharsetDirective(charEncoding, _makeSpan(start));
+ return CharsetDirective(charEncoding, _makeSpan(start));
// TODO(terry): Workaround Dart2js bug continue not implemented in switch
// see https://code.google.com/p/dart/issues/detail?id=8270
@@ -647,10 +644,10 @@
_eat(TokenKind.LBRACE);
- var keyframe = new KeyFrameDirective(tokId, name, _makeSpan(start));
+ var keyframe = KeyFrameDirective(tokId, name, _makeSpan(start));
do {
- Expressions selectors = new Expressions(_makeSpan(start));
+ Expressions selectors = Expressions(_makeSpan(start));
do {
var term = processTerm();
@@ -660,7 +657,7 @@
selectors.add(term);
} while (_maybeEat(TokenKind.COMMA));
- keyframe.add(new KeyFrameBlock(
+ keyframe.add(KeyFrameBlock(
selectors, processDeclarations(), _makeSpan(start)));
} while (!_maybeEat(TokenKind.RBRACE) && !isPrematureEndOfFile());
@@ -668,7 +665,7 @@
case TokenKind.DIRECTIVE_FONTFACE:
_next();
- return new FontFaceDirective(processDeclarations(), _makeSpan(start));
+ return FontFaceDirective(processDeclarations(), _makeSpan(start));
case TokenKind.DIRECTIVE_STYLET:
// Stylet grammar:
@@ -698,7 +695,7 @@
_eat(TokenKind.RBRACE);
- return new StyletDirective(name, productions, _makeSpan(start));
+ return StyletDirective(name, productions, _makeSpan(start));
case TokenKind.DIRECTIVE_NAMESPACE:
// Namespace grammar:
@@ -733,7 +730,7 @@
}
}
- return new NamespaceDirective(
+ return NamespaceDirective(
prefix != null ? prefix.name : '', namespaceUri, _makeSpan(start));
case TokenKind.DIRECTIVE_MIXIN:
@@ -812,7 +809,7 @@
// 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(IncludeMixinAtDeclaration(include, include.span));
} else {
_warning("Error mixing of top-level vs declarations mixins",
_makeSpan(include.span));
@@ -834,7 +831,7 @@
if (declGroup.declarations.isNotEmpty) {
if (productions.isEmpty) {
- mixinDirective = new MixinDeclarationDirective(
+ mixinDirective = MixinDeclarationDirective(
name.name, params, false, declGroup, _makeSpan(start));
break;
} else {
@@ -844,14 +841,14 @@
}
}
} else {
- mixinDirective = new MixinRulesetDirective(
+ mixinDirective = MixinRulesetDirective(
name.name, params, false, productions, _makeSpan(start));
break;
}
}
if (productions.isNotEmpty) {
- mixinDirective = new MixinRulesetDirective(
+ mixinDirective = MixinRulesetDirective(
name.name, params, false, productions, _makeSpan(start));
}
@@ -863,7 +860,7 @@
/// Returns a VarDefinitionDirective or VarDefinition if a varaible otherwise
/// return the token id of a directive or -1 if neither.
dynamic // VarDefinitionDirective | VarDefinition | int
- processVariableOrDirective({bool mixinParameter: false}) {
+ processVariableOrDirective({bool mixinParameter = false}) {
var start = _peekToken.span;
var tokId = _peek();
@@ -902,8 +899,7 @@
}
var span = _makeSpan(start);
- return new VarDefinitionDirective(
- new VarDefinition(name, exprs, span), span);
+ return VarDefinitionDirective(VarDefinition(name, exprs, span), span);
} else if (isChecked) {
_error('unexpected directive @$_peekToken', _peekToken.span);
}
@@ -918,13 +914,13 @@
exprs = processExpr();
}
- return new VarDefinition(definedName, exprs, _makeSpan(start));
+ return VarDefinition(definedName, exprs, _makeSpan(start));
}
return tokId;
}
- IncludeDirective processInclude(SourceSpan span, {bool eatSemiColon: true}) {
+ IncludeDirective processInclude(SourceSpan span, {bool eatSemiColon = true}) {
// Stylet grammar:
//
// @include IDENT [(args,...)];
@@ -965,7 +961,7 @@
_eat(TokenKind.SEMICOLON);
}
- return new IncludeDirective(name.name, params, span);
+ return IncludeDirective(name.name, params, span);
}
DocumentDirective processDocumentDirective() {
@@ -995,9 +991,9 @@
_eat(TokenKind.RPAREN);
- var arguments = new Expressions(_makeSpan(argumentSpan))
- ..add(new LiteralTerm(argument, argument, argumentSpan));
- function = new FunctionTerm(
+ var arguments = Expressions(_makeSpan(argumentSpan))
+ ..add(LiteralTerm(argument, argument, argumentSpan));
+ function = FunctionTerm(
ident.name, ident.name, arguments, _makeSpan(ident.span));
} else {
function = processFunction(ident);
@@ -1009,7 +1005,7 @@
_eat(TokenKind.LBRACE);
var groupRuleBody = processGroupRuleBody();
_eat(TokenKind.RBRACE);
- return new DocumentDirective(functions, groupRuleBody, _makeSpan(start));
+ return DocumentDirective(functions, groupRuleBody, _makeSpan(start));
}
SupportsDirective processSupportsDirective() {
@@ -1019,7 +1015,7 @@
_eat(TokenKind.LBRACE);
var groupRuleBody = processGroupRuleBody();
_eat(TokenKind.RBRACE);
- return new SupportsDirective(condition, groupRuleBody, _makeSpan(start));
+ return SupportsDirective(condition, groupRuleBody, _makeSpan(start));
}
SupportsCondition processSupportsCondition() {
@@ -1057,9 +1053,9 @@
}
if (clauseType == ClauseType.conjunction) {
- return new SupportsConjunction(conditions, _makeSpan(start));
+ return SupportsConjunction(conditions, _makeSpan(start));
} else if (clauseType == ClauseType.disjunction) {
- return new SupportsDisjunction(conditions, _makeSpan(start));
+ return SupportsDisjunction(conditions, _makeSpan(start));
} else {
return conditions.first;
}
@@ -1071,7 +1067,7 @@
if (text != 'not') return null;
_next(); // 'not'
var condition = processSupportsConditionInParens();
- return new SupportsNegation(condition, _makeSpan(start));
+ return SupportsNegation(condition, _makeSpan(start));
}
SupportsConditionInParens processSupportsConditionInParens() {
@@ -1081,19 +1077,19 @@
var condition = processSupportsCondition();
if (condition != null) {
_eat(TokenKind.RPAREN);
- return new SupportsConditionInParens.nested(condition, _makeSpan(start));
+ return SupportsConditionInParens.nested(condition, _makeSpan(start));
}
// Otherwise, parse a declaration.
var declaration = processDeclaration([]);
_eat(TokenKind.RPAREN);
- return new SupportsConditionInParens(declaration, _makeSpan(start));
+ return SupportsConditionInParens(declaration, _makeSpan(start));
}
ViewportDirective processViewportDirective() {
var start = _peekToken.span;
var name = _next().text;
var declarations = processDeclarations();
- return new ViewportDirective(name, declarations, _makeSpan(start));
+ return ViewportDirective(name, declarations, _makeSpan(start));
}
TreeNode processRule([SelectorGroup selectorGroup]) {
@@ -1106,8 +1102,7 @@
selectorGroup = processSelectorGroup();
}
if (selectorGroup != null) {
- return new RuleSet(
- selectorGroup, processDeclarations(), selectorGroup.span);
+ return RuleSet(selectorGroup, processDeclarations(), selectorGroup.span);
}
return null;
}
@@ -1173,7 +1168,7 @@
}
}
- DeclarationGroup processDeclarations({bool checkBrace: true}) {
+ DeclarationGroup processDeclarations({bool checkBrace = true}) {
var start = _peekToken.span;
if (checkBrace) _eat(TokenKind.LBRACE);
@@ -1220,14 +1215,14 @@
// declarations.
for (var decl in decls) {
if (decl is Declaration) {
- if (decl.hasDartStyle && dartStyles.indexOf(decl.dartStyle) < 0) {
+ if (decl.hasDartStyle && !dartStyles.contains(decl.dartStyle)) {
// Dart style not live, ignore these styles in this Declarations.
decl.dartStyle = null;
}
}
}
- return new DeclarationGroup(decls, _makeSpan(start));
+ return DeclarationGroup(decls, _makeSpan(start));
}
List<DeclarationGroup> processMarginsDeclarations() {
@@ -1270,7 +1265,7 @@
var declGroup = processDeclarations();
if (declGroup != null) {
- groups.add(new MarginGroup(
+ groups.add(MarginGroup(
marginSym, declGroup.declarations, _makeSpan(start)));
}
break;
@@ -1304,14 +1299,14 @@
// Fixup declaration to only have dartStyle that are live for this set of
// declarations.
for (var decl in decls) {
- if (decl.hasDartStyle && dartStyles.indexOf(decl.dartStyle) < 0) {
+ if (decl.hasDartStyle && !dartStyles.contains(decl.dartStyle)) {
// Dart style not live, ignore these styles in this Declarations.
decl.dartStyle = null;
}
}
- if (decls.length > 0) {
- groups.add(new DeclarationGroup(decls, _makeSpan(start)));
+ if (decls.isNotEmpty) {
+ groups.add(DeclarationGroup(decls, _makeSpan(start)));
}
return groups;
@@ -1328,8 +1323,8 @@
}
} while (_maybeEat(TokenKind.COMMA));
- if (selectors.length > 0) {
- return new SelectorGroup(selectors, _makeSpan(start));
+ if (selectors.isNotEmpty) {
+ return SelectorGroup(selectors, _makeSpan(start));
}
return null;
}
@@ -1350,7 +1345,7 @@
if (simpleSequences.isEmpty) return null;
- return new Selector(simpleSequences, _makeSpan(start));
+ return Selector(simpleSequences, _makeSpan(start));
}
/// Same as [processSelector] but reports an error for each combinator.
@@ -1421,7 +1416,7 @@
var span = _makeSpan(start);
var simpleSel = thisOperator
- ? new ElementSelector(new ThisOperator(span), span)
+ ? ElementSelector(ThisOperator(span), span)
: simpleSelector();
if (simpleSel == null &&
(combinatorType == TokenKind.COMBINATOR_PLUS ||
@@ -1433,10 +1428,10 @@
// .foo&:hover combinator before & is NONE
// .foo & combinator before & is DESCDENDANT
// .foo > & combinator before & is GREATER
- simpleSel = new ElementSelector(new Identifier("", span), span);
+ simpleSel = ElementSelector(Identifier("", span), span);
}
if (simpleSel != null) {
- return new SimpleSelectorSequence(simpleSel, span, combinatorType);
+ return SimpleSelectorSequence(simpleSel, span, combinatorType);
}
return null;
}
@@ -1469,7 +1464,7 @@
case TokenKind.ASTERISK:
// Mark as universal namespace.
var tok = _next();
- first = new Wildcard(_makeSpan(tok.span));
+ first = Wildcard(_makeSpan(tok.span));
break;
case TokenKind.IDENTIFIER:
first = identifier();
@@ -1492,7 +1487,7 @@
case TokenKind.ASTERISK:
// Mark as universal element
var tok = _next();
- element = new Wildcard(_makeSpan(tok.span));
+ element = Wildcard(_makeSpan(tok.span));
break;
case TokenKind.IDENTIFIER:
element = identifier();
@@ -1503,10 +1498,10 @@
break;
}
- return new NamespaceSelector(
- first, new ElementSelector(element, element.span), _makeSpan(start));
+ return NamespaceSelector(
+ first, ElementSelector(element, element.span), _makeSpan(start));
} else if (first != null) {
- return new ElementSelector(first, _makeSpan(start));
+ return ElementSelector(first, _makeSpan(start));
} else {
// Check for HASH | class | attrib | pseudo | negation
return simpleSelectorTail();
@@ -1544,7 +1539,7 @@
// Generate bad selector id (normalized).
id.name = " ${id.name}";
}
- return new IdSelector(id, _makeSpan(start));
+ return IdSelector(id, _makeSpan(start));
}
return null;
case TokenKind.DOT:
@@ -1561,7 +1556,7 @@
// Generate bad selector class (normalized).
id.name = " ${id.name}";
}
- return new ClassSelector(id, _makeSpan(start));
+ return ClassSelector(id, _makeSpan(start));
case TokenKind.COLON:
// :pseudo-class ::pseudo-element
return processPseudoSelector(start);
@@ -1602,7 +1597,7 @@
var negArg = simpleSelector();
_eat(TokenKind.RPAREN);
- return new NegationSelector(negArg, _makeSpan(start));
+ return NegationSelector(negArg, _makeSpan(start));
} else if (!pseudoElement && (name == 'host' || name == 'host-context')) {
_eat(TokenKind.LPAREN);
var selector = processCompoundSelector();
@@ -1612,7 +1607,7 @@
}
_eat(TokenKind.RPAREN);
var span = _makeSpan(start);
- return new PseudoClassFunctionSelector(pseudoName, selector, span);
+ return PseudoClassFunctionSelector(pseudoName, selector, span);
} else {
// Special parsing for expressions in pseudo functions. Minus is used
// as operator not identifier.
@@ -1633,8 +1628,8 @@
if (expr is SelectorExpression) {
_eat(TokenKind.RPAREN);
return (pseudoElement)
- ? new PseudoElementFunctionSelector(pseudoName, expr, span)
- : new PseudoClassFunctionSelector(pseudoName, expr, span);
+ ? PseudoElementFunctionSelector(pseudoName, expr, span)
+ : PseudoClassFunctionSelector(pseudoName, expr, span);
} else {
_errorExpected("CSS expression");
return null;
@@ -1645,9 +1640,9 @@
// Treat CSS2.1 pseudo-elements defined with pseudo class syntax as pseudo-
// elements for backwards compatibility.
return pseudoElement || _legacyPseudoElements.contains(name)
- ? new PseudoElementSelector(pseudoName, _makeSpan(start),
+ ? PseudoElementSelector(pseudoName, _makeSpan(start),
isLegacy: !pseudoElement)
- : new PseudoClassSelector(pseudoName, _makeSpan(start));
+ : PseudoClassSelector(pseudoName, _makeSpan(start));
}
/// In CSS3, the expressions are identifiers, strings, or of the form "an+b".
@@ -1672,12 +1667,12 @@
case TokenKind.PLUS:
start = _peekToken.span;
termToken = _next();
- expressions.add(new OperatorPlus(_makeSpan(start)));
+ expressions.add(OperatorPlus(_makeSpan(start)));
break;
case TokenKind.MINUS:
start = _peekToken.span;
termToken = _next();
- expressions.add(new OperatorMinus(_makeSpan(start)));
+ expressions.add(OperatorMinus(_makeSpan(start)));
break;
case TokenKind.INTEGER:
termToken = _next();
@@ -1690,11 +1685,11 @@
case TokenKind.SINGLE_QUOTE:
value = processQuotedString(false);
value = "'${_escapeString(value, single: true)}'";
- return new LiteralTerm(value, value, _makeSpan(start));
+ return LiteralTerm(value, value, _makeSpan(start));
case TokenKind.DOUBLE_QUOTE:
value = processQuotedString(false);
value = '"${_escapeString(value)}"';
- return new LiteralTerm(value, value, _makeSpan(start));
+ return LiteralTerm(value, value, _makeSpan(start));
case TokenKind.IDENTIFIER:
value = identifier(); // Snarf up the ident we'll remap, maybe.
break;
@@ -1709,7 +1704,7 @@
unitTerm = processDimension(termToken, value, _makeSpan(start));
}
if (unitTerm == null) {
- unitTerm = new LiteralTerm(value, value.name, _makeSpan(start));
+ unitTerm = LiteralTerm(value, value.name, _makeSpan(start));
}
expressions.add(unitTerm);
@@ -1717,7 +1712,7 @@
}
}
- return new SelectorExpression(expressions, _makeSpan(start));
+ return SelectorExpression(expressions, _makeSpan(start));
}
// Attribute grammar:
@@ -1774,7 +1769,7 @@
_eat(TokenKind.RBRACK);
- return new AttributeSelector(attrName, op, value, _makeSpan(start));
+ return AttributeSelector(attrName, op, value, _makeSpan(start));
}
return null;
}
@@ -1817,8 +1812,7 @@
// Handle !important (prio)
var importantPriority = _maybeEat(TokenKind.IMPORTANT);
- decl = new Declaration(
- propertyIdent, exprs, dartComposite, _makeSpan(start),
+ decl = Declaration(propertyIdent, exprs, dartComposite, _makeSpan(start),
important: importantPriority, ie7: ie7);
} else if (_peekToken.kind == TokenKind.VAR_DEFINITION) {
_next();
@@ -1829,12 +1823,12 @@
Expressions exprs = processExpr();
- decl = new VarDefinition(definedName, exprs, _makeSpan(start));
+ decl = VarDefinition(definedName, exprs, _makeSpan(start));
} else if (_peekToken.kind == TokenKind.DIRECTIVE_INCLUDE) {
// @include mixinName in the declaration area.
var span = _makeSpan(start);
var include = processInclude(span, eatSemiColon: false);
- decl = new IncludeMixinAtDeclaration(include, span);
+ decl = IncludeMixinAtDeclaration(include, span);
} else if (_peekToken.kind == TokenKind.DIRECTIVE_EXTEND) {
var simpleSequences = <TreeNode>[];
@@ -1855,7 +1849,7 @@
_warning("not a valid selector", span);
}
}
- decl = new ExtendDeclaration(simpleSequences, span);
+ decl = ExtendDeclaration(simpleSequences, span);
}
return decl;
@@ -1892,7 +1886,7 @@
static const int _paddingPartRight = 27;
static const int _paddingPartBottom = 28;
- static const Map<String, int> _stylesToDart = const {
+ static const Map<String, int> _stylesToDart = {
'font': _fontPartFont,
'font-family': _fontPartFamily,
'font-size': _fontPartSize,
@@ -1924,7 +1918,7 @@
'padding-bottom': _paddingPartBottom
};
- static const Map<String, int> _nameToFontWeight = const {
+ static const Map<String, int> _nameToFontWeight = {
'bold': FontWeight.bold,
'normal': FontWeight.normal
};
@@ -1945,7 +1939,7 @@
// Merge all font styles for this class selector.
for (var dartStyle in dartStyles) {
if (dartStyle.isFont) {
- fontExpr = new FontExpression.merge(dartStyle, fontExpr);
+ fontExpr = FontExpression.merge(dartStyle, fontExpr);
}
}
@@ -1962,10 +1956,10 @@
// 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);
+ var processor = ExpressionsProcessor(exprs);
return _mergeFontStyles(processor.processFont(), dartStyles);
case _fontPartFamily:
- var processor = new ExpressionsProcessor(exprs);
+ var processor = ExpressionsProcessor(exprs);
try {
return _mergeFontStyles(processor.processFontFamily(), dartStyles);
@@ -1974,7 +1968,7 @@
}
break;
case _fontPartSize:
- var processor = new ExpressionsProcessor(exprs);
+ var processor = ExpressionsProcessor(exprs);
return _mergeFontStyles(processor.processFontSize(), dartStyles);
case _fontPartStyle:
// Possible style values:
@@ -2007,12 +2001,12 @@
// 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 = FontExpression(expr.span, weight: expr.value);
return _mergeFontStyles(fontExpr, dartStyles);
} else if (expr is LiteralTerm) {
int weight = _nameToFontWeight[expr.value.toString()];
if (weight != null) {
- var fontExpr = new FontExpression(expr.span, weight: weight);
+ var fontExpr = FontExpression(expr.span, weight: weight);
return _mergeFontStyles(fontExpr, dartStyles);
}
}
@@ -2026,15 +2020,15 @@
// See https://github.com/dart-lang/csslib/issues/2.
if (unitTerm.unit == TokenKind.UNIT_LENGTH_PX ||
unitTerm.unit == TokenKind.UNIT_LENGTH_PT) {
- var fontExpr = new FontExpression(expr.span,
- lineHeight: new LineHeight(expr.value, inPixels: true));
+ var fontExpr = FontExpression(expr.span,
+ lineHeight: LineHeight(expr.value, inPixels: true));
return _mergeFontStyles(fontExpr, dartStyles);
} else if (isChecked) {
_warning("Unexpected unit for line-height", expr.span);
}
} else if (expr is NumberTerm) {
- var fontExpr = new FontExpression(expr.span,
- lineHeight: new LineHeight(expr.value, inPixels: false));
+ var fontExpr = FontExpression(expr.span,
+ lineHeight: LineHeight(expr.value, inPixels: false));
return _mergeFontStyles(fontExpr, dartStyles);
} else if (isChecked) {
_warning("Unexpected value for line-height", expr.span);
@@ -2042,26 +2036,25 @@
}
break;
case _marginPartMargin:
- return new MarginExpression.boxEdge(exprs.span, processFourNums(exprs));
+ return MarginExpression.boxEdge(exprs.span, processFourNums(exprs));
case _borderPartBorder:
for (var expr in exprs.expressions) {
var v = marginValue(expr);
if (v != null) {
- final box = new BoxEdge.uniform(v);
- return new BorderExpression.boxEdge(exprs.span, box);
+ final box = BoxEdge.uniform(v);
+ return BorderExpression.boxEdge(exprs.span, box);
}
}
break;
case _borderPartWidth:
var v = marginValue(exprs.expressions[0]);
if (v != null) {
- final box = new BoxEdge.uniform(v);
- return new BorderExpression.boxEdge(exprs.span, box);
+ final box = BoxEdge.uniform(v);
+ return BorderExpression.boxEdge(exprs.span, box);
}
break;
case _paddingPartPadding:
- return new PaddingExpression.boxEdge(
- exprs.span, processFourNums(exprs));
+ return PaddingExpression.boxEdge(exprs.span, processFourNums(exprs));
case _marginPartLeft:
case _marginPartTop:
case _marginPartRight:
@@ -2080,7 +2073,7 @@
case _paddingPartTop:
case _paddingPartRight:
case _paddingPartBottom:
- if (exprs.expressions.length > 0) {
+ if (exprs.expressions.isNotEmpty) {
return processOneNumber(exprs, styleType);
}
break;
@@ -2095,37 +2088,37 @@
if (value != null) {
switch (part) {
case _marginPartLeft:
- return new MarginExpression(exprs.span, left: value);
+ return MarginExpression(exprs.span, left: value);
case _marginPartTop:
- return new MarginExpression(exprs.span, top: value);
+ return MarginExpression(exprs.span, top: value);
case _marginPartRight:
- return new MarginExpression(exprs.span, right: value);
+ return MarginExpression(exprs.span, right: value);
case _marginPartBottom:
- return new MarginExpression(exprs.span, bottom: value);
+ return MarginExpression(exprs.span, bottom: value);
case _borderPartLeft:
case _borderPartLeftWidth:
- return new BorderExpression(exprs.span, left: value);
+ return BorderExpression(exprs.span, left: value);
case _borderPartTop:
case _borderPartTopWidth:
- return new BorderExpression(exprs.span, top: value);
+ return BorderExpression(exprs.span, top: value);
case _borderPartRight:
case _borderPartRightWidth:
- return new BorderExpression(exprs.span, right: value);
+ return BorderExpression(exprs.span, right: value);
case _borderPartBottom:
case _borderPartBottomWidth:
- return new BorderExpression(exprs.span, bottom: value);
+ return BorderExpression(exprs.span, bottom: value);
case _heightPart:
- return new HeightExpression(exprs.span, value);
+ return HeightExpression(exprs.span, value);
case _widthPart:
- return new WidthExpression(exprs.span, value);
+ return WidthExpression(exprs.span, value);
case _paddingPartLeft:
- return new PaddingExpression(exprs.span, left: value);
+ return PaddingExpression(exprs.span, left: value);
case _paddingPartTop:
- return new PaddingExpression(exprs.span, top: value);
+ return PaddingExpression(exprs.span, top: value);
case _paddingPartRight:
- return new PaddingExpression(exprs.span, right: value);
+ return PaddingExpression(exprs.span, right: value);
case _paddingPartBottom:
- return new PaddingExpression(exprs.span, bottom: value);
+ return PaddingExpression(exprs.span, bottom: value);
}
}
return null;
@@ -2175,7 +2168,7 @@
return null;
}
- return new BoxEdge.clockwiseFromTop(top, right, bottom, left);
+ return BoxEdge.clockwiseFromTop(top, right, bottom, left);
}
// TODO(terry): Need to handle auto.
@@ -2196,7 +2189,7 @@
// term: (see processTerm)
Expressions processExpr([bool ieFilter = false]) {
var start = _peekToken.span;
- var expressions = new Expressions(_makeSpan(start));
+ var expressions = Expressions(_makeSpan(start));
var keepGoing = true;
var expr;
@@ -2207,10 +2200,10 @@
switch (_peek()) {
case TokenKind.SLASH:
- op = new OperatorSlash(_makeSpan(opStart));
+ op = OperatorSlash(_makeSpan(opStart));
break;
case TokenKind.COMMA:
- op = new OperatorComma(_makeSpan(opStart));
+ op = OperatorComma(_makeSpan(opStart));
break;
case TokenKind.BACKSLASH:
// Backslash outside of string; detected IE8 or older signaled by \9
@@ -2222,7 +2215,7 @@
var numToken = _next();
var value = int.parse(numToken.text);
if (value == 9) {
- op = new IE8Term(_makeSpan(ie8Start));
+ op = IE8Term(_makeSpan(ie8Start));
} else if (isChecked) {
_warning(
"\$value is not valid in an expression", _makeSpan(start));
@@ -2324,15 +2317,15 @@
case TokenKind.SINGLE_QUOTE:
value = processQuotedString(false);
value = "'${_escapeString(value, single: true)}'";
- return new LiteralTerm(value, value, _makeSpan(start));
+ return LiteralTerm(value, value, _makeSpan(start));
case TokenKind.DOUBLE_QUOTE:
value = processQuotedString(false);
value = '"${_escapeString(value)}"';
- return new LiteralTerm(value, value, _makeSpan(start));
+ return LiteralTerm(value, value, _makeSpan(start));
case TokenKind.LPAREN:
_next();
- GroupTerm group = new GroupTerm(_makeSpan(start));
+ GroupTerm group = GroupTerm(_makeSpan(start));
dynamic /* Expression | List<Expression> | ... */ term;
do {
@@ -2355,7 +2348,7 @@
_eat(TokenKind.RBRACK);
- return new ItemTerm(term.value, term.text, _makeSpan(start));
+ return ItemTerm(term.value, term.text, _makeSpan(start));
case TokenKind.IDENTIFIER:
var nameValue = identifier(); // Snarf up the ident we'll remap, maybe.
@@ -2380,7 +2373,7 @@
// 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));
+ return LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
}
// What kind of identifier is it, named color?
@@ -2393,7 +2386,7 @@
: "Unknown property value ${propName}";
_warning(errMsg, _makeSpan(start));
}
- return new LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
+ return LiteralTerm(nameValue, nameValue.name, _makeSpan(start));
}
// Yes, process the color as an RGB value.
@@ -2430,7 +2423,7 @@
first = _previousToken.text;
}
- return new UnicodeRangeTerm(first, second, _makeSpan(start));
+ return UnicodeRangeTerm(first, second, _makeSpan(start));
case TokenKind.AT:
if (messages.options.lessSupport) {
_next();
@@ -2442,7 +2435,7 @@
var param = expr.expressions[0];
var varUsage =
- new VarUsage((param as LiteralTerm).text, [], _makeSpan(start));
+ VarUsage((param as LiteralTerm).text, [], _makeSpan(start));
expr.expressions[0] = varUsage;
return expr.expressions;
}
@@ -2459,11 +2452,11 @@
switch (unitType) {
case TokenKind.UNIT_EM:
- term = new EmTerm(value, t.text, span);
+ term = EmTerm(value, t.text, span);
_next(); // Skip the unit
break;
case TokenKind.UNIT_EX:
- term = new ExTerm(value, t.text, span);
+ term = ExTerm(value, t.text, span);
_next(); // Skip the unit
break;
case TokenKind.UNIT_LENGTH_PX:
@@ -2472,60 +2465,60 @@
case TokenKind.UNIT_LENGTH_IN:
case TokenKind.UNIT_LENGTH_PT:
case TokenKind.UNIT_LENGTH_PC:
- term = new LengthTerm(value, t.text, span, unitType);
+ term = 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);
+ term = 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);
+ term = 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);
+ term = FreqTerm(value, t.text, span, unitType);
_next(); // Skip the unit
break;
case TokenKind.PERCENT:
- term = new PercentageTerm(value, t.text, span);
+ term = PercentageTerm(value, t.text, span);
_next(); // Skip the %
break;
case TokenKind.UNIT_FRACTION:
- term = new FractionTerm(value, t.text, span);
+ term = 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);
+ term = ResolutionTerm(value, t.text, span, unitType);
_next(); // Skip the unit
break;
case TokenKind.UNIT_CH:
- term = new ChTerm(value, t.text, span, unitType);
+ term = ChTerm(value, t.text, span, unitType);
_next(); // Skip the unit
break;
case TokenKind.UNIT_REM:
- term = new RemTerm(value, t.text, span, unitType);
+ term = 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);
+ term = 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);
+ ? LiteralTerm(value, value.name, span)
+ : NumberTerm(value, t.text, span);
}
break;
}
@@ -2569,7 +2562,7 @@
}
// Gobble up everything until we hit our stop token.
- var stringValue = new StringBuffer();
+ var stringValue = StringBuffer();
while (_peek() != stopToken && _peek() != TokenKind.END_OF_FILE) {
stringValue.write(_next().text);
}
@@ -2598,7 +2591,7 @@
if (kind == TokenKind.SEMICOLON || kind == TokenKind.RBRACE) {
var tok = tokenizer.makeIEFilter(
startAfterProgidColon.start.offset, _peekToken.start);
- return new LiteralTerm(tok.text, tok.text, tok.span);
+ return LiteralTerm(tok.text, tok.text, tok.span);
}
var parens = 0;
@@ -2613,7 +2606,7 @@
if (--parens == 0) {
var tok = tokenizer.makeIEFilter(
startAfterProgidColon.start.offset, _peekToken.start);
- return new LiteralTerm(tok.text, tok.text, tok.span);
+ return LiteralTerm(tok.text, tok.text, tok.span);
}
break;
default:
@@ -2638,7 +2631,7 @@
tokenizer._inString = false;
// Gobble up everything until we hit our stop token.
- var stringValue = new StringBuffer();
+ var stringValue = StringBuffer();
var left = 1;
var matchingParens = false;
while (_peek() != TokenKind.END_OF_FILE && !matchingParens) {
@@ -2667,13 +2660,13 @@
if (name == 'calc' || name == '-webkit-calc' || name == '-moz-calc') {
// TODO(terry): Implement expression parsing properly.
String expression = processCalcExpression();
- var calcExpr = new LiteralTerm(expression, expression, _makeSpan(start));
+ var calcExpr = LiteralTerm(expression, expression, _makeSpan(start));
if (!_maybeEat(TokenKind.RPAREN)) {
_error("problem parsing function expected ), ", _peekToken.span);
}
- return new CalcTerm(name, name, calcExpr, _makeSpan(start));
+ return CalcTerm(name, name, calcExpr, _makeSpan(start));
}
return null;
@@ -2702,7 +2695,7 @@
_next();
}
- return new UriTerm(urlParam, _makeSpan(start));
+ return UriTerm(urlParam, _makeSpan(start));
case 'var':
// TODO(terry): Consider handling var in IE specific filter/progid.
// This will require parsing entire IE specific syntax
@@ -2727,14 +2720,14 @@
var defaultValues = expr.expressions.length >= 3
? expr.expressions.sublist(2)
: <Expression>[];
- return new VarUsage(paramName, defaultValues, _makeSpan(start));
+ return 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 FunctionTerm(name, name, expr, _makeSpan(start));
}
}
@@ -2746,10 +2739,10 @@
if (isChecked) {
_warning('expected identifier, but found $tok', tok.span);
}
- return new Identifier("", _makeSpan(tok.span));
+ return Identifier("", _makeSpan(tok.span));
}
- return new Identifier(tok.text, _makeSpan(tok.span));
+ return Identifier(tok.text, _makeSpan(tok.span));
}
// TODO(terry): Move this to base <= 36 and into shared code.
@@ -2772,7 +2765,7 @@
var digit = _hexDigit(hexText.codeUnitAt(i));
if (digit < 0) {
_warning('Bad hex number', span);
- return new HexColorTerm(new BAD_HEX_VALUE(), hexText, span);
+ return HexColorTerm(BAD_HEX_VALUE(), hexText, span);
}
hexValue = (hexValue << 4) + digit;
}
@@ -2792,7 +2785,7 @@
} else if (hexText.length == 2 && hexText[0] == hexText[1]) {
hexText = '${hexText[0]}';
}
- return new HexColorTerm(hexValue, hexText, span);
+ return HexColorTerm(hexValue, hexText, span);
}
}
@@ -2832,7 +2825,7 @@
nextIsLineHeight = true;
} else if (nextIsLineHeight && expr is LengthTerm) {
assert(expr.unit == TokenKind.UNIT_LENGTH_PX);
- lineHt = new LineHeight(expr.value, inPixels: true);
+ lineHt = LineHeight(expr.value, inPixels: true);
nextIsLineHeight = false;
_index++;
break;
@@ -2844,7 +2837,7 @@
}
}
- return new FontExpression(_exprs.span, size: size, lineHeight: lineHt);
+ return FontExpression(_exprs.span, size: size, lineHeight: lineHt);
}
FontExpression processFontFamily() {
@@ -2858,21 +2851,21 @@
for (; _index < _exprs.expressions.length; _index++) {
Expression expr = _exprs.expressions[_index];
if (expr is LiteralTerm) {
- if (family.length == 0 || moreFamilies) {
+ if (family.isEmpty || moreFamilies) {
// It's font-family now.
family.add(expr.toString());
moreFamilies = false;
} else if (isChecked) {
messages.warning('Only font-family can be a list', _exprs.span);
}
- } else if (expr is OperatorComma && family.length > 0) {
+ } else if (expr is OperatorComma && family.isNotEmpty) {
moreFamilies = true;
} else {
break;
}
}
- return new FontExpression(_exprs.span, family: family);
+ return FontExpression(_exprs.span, family: family);
}
FontExpression processFont() {
@@ -2893,7 +2886,7 @@
// https://github.com/dart-lang/csslib/issues/5
}
- return new FontExpression(_exprs.span,
+ return FontExpression(_exprs.span,
size: fontSize.font.size,
lineHeight: fontSize.font.lineHeight,
family: fontFamily.font.family);
@@ -2902,12 +2895,12 @@
/// Escapes [text] for use in a CSS string.
/// [single] specifies single quote `'` vs double quote `"`.
-String _escapeString(String text, {bool single: false}) {
- StringBuffer result = null;
+String _escapeString(String text, {bool single = false}) {
+ StringBuffer result;
for (int i = 0; i < text.length; i++) {
var code = text.codeUnitAt(i);
- String replace = null;
+ String replace;
switch (code) {
case 34 /*'"'*/ :
if (!single) replace = r'\"';
@@ -2918,7 +2911,7 @@
}
if (replace != null && result == null) {
- result = new StringBuffer(text.substring(0, i));
+ result = StringBuffer(text.substring(0, i));
}
if (result != null) result.write(replace != null ? replace : text[i]);
diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart
index e6bb0eb..6421c6e 100644
--- a/lib/src/analyzer.dart
+++ b/lib/src/analyzer.dart
@@ -43,14 +43,14 @@
// Expand any nested selectors using selector desendant combinator to
// signal CSS inheritance notation.
- _styleSheets.forEach((styleSheet) => new ExpandNestedSelectors()
+ _styleSheets.forEach((styleSheet) => ExpandNestedSelectors()
..visitStyleSheet(styleSheet)
..flatten(styleSheet));
// Expand any @extend.
_styleSheets.forEach((styleSheet) {
- var allExtends = new AllExtends()..visitStyleSheet(styleSheet);
- new InheritExtends(_messages, allExtends)..visitStyleSheet(styleSheet);
+ var allExtends = AllExtends()..visitStyleSheet(styleSheet);
+ InheritExtends(_messages, allExtends)..visitStyleSheet(styleSheet);
});
}
}
@@ -186,7 +186,7 @@
List<RuleSet> _expandedRuleSets = [];
/// Maping of a nested rule set to the fully expanded list of RuleSet(s).
- final Map<RuleSet, List<RuleSet>> _expansions = new Map();
+ final Map<RuleSet, List<RuleSet>> _expansions = Map();
void visitRuleSet(RuleSet node) {
final oldParent = _parentRuleSet;
@@ -196,7 +196,7 @@
if (_nestedSelectorGroup == null) {
// Create top-level selector (may have nested rules).
final newSelectors = node.selectorGroup.selectors.toList();
- _topLevelSelectorGroup = new SelectorGroup(newSelectors, node.span);
+ _topLevelSelectorGroup = SelectorGroup(newSelectors, node.span);
_nestedSelectorGroup = _topLevelSelectorGroup;
} else {
// Generate new selector groups from the nested rules.
@@ -242,11 +242,11 @@
for (Selector nestedSelector in nestedSelectors) {
var seq = _mergeNestedSelector(nestedSelector.simpleSelectorSequences,
selector.simpleSelectorSequences);
- newSelectors.add(new Selector(seq, node.span));
+ newSelectors.add(Selector(seq, node.span));
}
}
- return new SelectorGroup(newSelectors, node.span);
+ return SelectorGroup(newSelectors, node.span);
}
/// Merge the nested selector sequences [current] to the [parent] sequences or
@@ -293,7 +293,7 @@
var newSequences = <SimpleSelectorSequence>[];
var first = sequences.first;
- newSequences.add(new SimpleSelectorSequence(
+ newSequences.add(SimpleSelectorSequence(
first.simpleSelector, first.span, TokenKind.COMBINATOR_DESCENDANT));
newSequences.addAll(sequences.skip(1));
@@ -303,7 +303,7 @@
void visitDeclarationGroup(DeclarationGroup node) {
var span = node.span;
- var currentGroup = new DeclarationGroup([], span);
+ var currentGroup = DeclarationGroup([], span);
var oldGroup = _flatDeclarationGroup;
_flatDeclarationGroup = currentGroup;
@@ -325,7 +325,7 @@
var selectorGroup = _nestedSelectorGroup;
// Build new rule set from the nested selectors and declarations.
- var newRuleSet = new RuleSet(selectorGroup, currentGroup, span);
+ var newRuleSet = RuleSet(selectorGroup, currentGroup, span);
// Place in order so outer-most rule is first.
if (expandedLength == _expandedRuleSets.length) {
@@ -395,7 +395,7 @@
/// true.
static bool replace(
StyleSheet styleSheet, RuleSet ruleSet, List<RuleSet> newRules) {
- var visitor = new _MediaRulesReplacer(ruleSet, newRules);
+ var visitor = _MediaRulesReplacer(ruleSet, newRules);
visitor.visitStyleSheet(styleSheet);
return visitor._foundAndReplaced;
}
@@ -418,11 +418,11 @@
final Messages _messages;
/// Map of variable name key to it's definition.
- final Map<String, MixinDefinition> map = new Map<String, MixinDefinition>();
+ final Map<String, MixinDefinition> map = Map<String, MixinDefinition>();
MixinDefinition currDef;
static void expand(Messages messages, List<StyleSheet> styleSheets) {
- new TopLevelIncludes(messages, styleSheets);
+ TopLevelIncludes(messages, styleSheets);
}
bool _anyRulesets(MixinRulesetDirective def) =>
@@ -503,7 +503,7 @@
/// true.
static bool replace(Messages messages, StyleSheet styleSheet,
IncludeDirective include, List<TreeNode> newRules) {
- var visitor = new _TopLevelIncludeReplacer(messages, include, newRules);
+ var visitor = _TopLevelIncludeReplacer(messages, include, newRules);
visitor.visitStyleSheet(styleSheet);
return visitor._foundAndReplaced;
}
@@ -514,7 +514,7 @@
var index = node.topLevels.indexOf(_include);
if (index != -1) {
node.topLevels.insertAll(index + 1, _newRules);
- node.topLevels.replaceRange(index, index + 1, [new NoOp()]);
+ node.topLevels.replaceRange(index, index + 1, [NoOp()]);
_foundAndReplaced = true;
}
super.visitStyleSheet(node);
@@ -525,7 +525,7 @@
if (index != -1) {
node.rulesets.insertAll(index + 1, _newRules);
// Only the resolve the @include once.
- node.rulesets.replaceRange(index, index + 1, [new NoOp()]);
+ node.rulesets.replaceRange(index, index + 1, [NoOp()]);
_foundAndReplaced = true;
}
super.visitMixinRulesetDirective(node);
@@ -556,7 +556,7 @@
Expressions _currExpressions;
int _currIndex = -1;
- final varUsages = new Map<String, Map<Expressions, Set<int>>>();
+ final varUsages = Map<String, Map<Expressions, Set<int>>>();
/// Only var defs with more than one expression (comma separated).
final Map<String, VarDefinition> varDefs;
@@ -636,7 +636,7 @@
}
void _addExpression(Map<Expressions, Set<int>> expressions) {
- var indexSet = new Set<int>();
+ var indexSet = Set<int>();
indexSet.add(_currIndex);
expressions[_currExpressions] = indexSet;
}
@@ -653,7 +653,7 @@
allIndexes.add(_currIndex);
}
} else {
- var newExpressions = new Map<Expressions, Set<int>>();
+ var newExpressions = Map<Expressions, Set<int>>();
_addExpression(newExpressions);
varUsages[node.name] = newExpressions;
}
@@ -677,18 +677,18 @@
final Messages _messages;
/// Map of variable name key to it's definition.
- final Map<String, MixinDefinition> map = new Map<String, MixinDefinition>();
+ final Map<String, MixinDefinition> map = Map<String, MixinDefinition>();
/// Cache of mixin called with parameters.
- final Map<String, CallMixin> callMap = new Map<String, CallMixin>();
+ final Map<String, CallMixin> callMap = Map<String, CallMixin>();
MixinDefinition currDef;
DeclarationGroup currDeclGroup;
/// Var definitions with more than 1 expression.
- final Map<String, VarDefinition> varDefs = new Map<String, VarDefinition>();
+ final Map<String, VarDefinition> varDefs = Map<String, VarDefinition>();
static void expand(Messages messages, List<StyleSheet> styleSheets) {
- new DeclarationIncludes(messages, styleSheets);
+ DeclarationIncludes(messages, styleSheets);
}
DeclarationIncludes(this._messages, List<StyleSheet> styleSheets) {
@@ -702,7 +702,7 @@
CallMixin _createCallDeclMixin(MixinDefinition mixinDef) {
callMap.putIfAbsent(mixinDef.name,
- () => callMap[mixinDef.name] = new CallMixin(mixinDef, varDefs));
+ () => callMap[mixinDef.name] = CallMixin(mixinDef, varDefs));
return callMap[mixinDef.name];
}
@@ -727,8 +727,7 @@
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, [NoOp()]);
}
_messages.warning(
"Using top-level mixin ${node.include.name} as a declaration",
@@ -740,7 +739,7 @@
var rulesets = <Declaration>[];
if (origRulesets.every((ruleset) => ruleset is IncludeDirective)) {
origRulesets.forEach((ruleset) {
- rulesets.add(new IncludeMixinAtDeclaration(
+ rulesets.add(IncludeMixinAtDeclaration(
ruleset as IncludeDirective, ruleset.span));
});
_IncludeReplacer.replace(_styleSheet, node, rulesets);
@@ -748,7 +747,7 @@
}
}
- if (mixinDef.definedArgs.length > 0 && node.include.args.length > 0) {
+ if (mixinDef.definedArgs.isNotEmpty && node.include.args.isNotEmpty) {
var callMixin = _createCallDeclMixin(mixinDef);
mixinDef = callMixin.transform(node.include.args);
}
@@ -776,7 +775,7 @@
(currDef as MixinDeclarationDirective).declarations.declarations;
var index = _findInclude(decls, node);
if (index != -1) {
- decls.replaceRange(index, index + 1, [new NoOp()]);
+ decls.replaceRange(index, index + 1, [NoOp()]);
}
}
}
@@ -829,7 +828,7 @@
/// with the [newRules].
static void replace(
StyleSheet ss, var include, List<TreeNode> newDeclarations) {
- var visitor = new _IncludeReplacer(include, newDeclarations);
+ var visitor = _IncludeReplacer(include, newDeclarations);
visitor.visitStyleSheet(ss);
}
@@ -840,7 +839,7 @@
if (index != -1) {
node.declarations.insertAll(index + 1, _newDeclarations);
// Change @include to NoOp so it's processed only once.
- node.declarations.replaceRange(index, index + 1, [new NoOp()]);
+ node.declarations.replaceRange(index, index + 1, [NoOp()]);
_foundAndReplaced = true;
}
super.visitDeclarationGroup(node);
@@ -851,7 +850,7 @@
/// @include.
class MixinsAndIncludes extends Visitor {
static void remove(StyleSheet styleSheet) {
- new MixinsAndIncludes()..visitStyleSheet(styleSheet);
+ MixinsAndIncludes()..visitStyleSheet(styleSheet);
}
bool _nodesToRemove(node) =>
@@ -881,7 +880,7 @@
/// Find all @extend to create inheritance.
class AllExtends extends Visitor {
final Map<String, List<SelectorGroup>> inherits =
- new Map<String, List<SelectorGroup>>();
+ Map<String, List<SelectorGroup>>();
SelectorGroup _currSelectorGroup;
int _currDeclIndex;
diff --git a/lib/src/css_printer.dart b/lib/src/css_printer.dart
index a8d5b4a..552f25e 100644
--- a/lib/src/css_printer.dart
+++ b/lib/src/css_printer.dart
@@ -6,14 +6,14 @@
/// Visitor that produces a formatted string representation of the CSS tree.
class CssPrinter extends Visitor {
- StringBuffer _buff = new StringBuffer();
+ StringBuffer _buff = StringBuffer();
bool prettyPrint = true;
/// Walk the [tree] Stylesheet. [pretty] if true emits line breaks, extra
/// spaces, friendly property values, etc., if false emits compacted output.
- void visitTree(StyleSheet tree, {bool pretty: false}) {
+ void visitTree(StyleSheet tree, {bool pretty = false}) {
prettyPrint = pretty;
- _buff = new StringBuffer();
+ _buff = StringBuffer();
visitStyleSheet(tree);
}
@@ -177,7 +177,7 @@
}
void visitImportDirective(ImportDirective node) {
- bool isStartingQuote(String ch) => ('\'"'.indexOf(ch[0]) >= 0);
+ bool isStartingQuote(String ch) => ('\'"'.contains(ch[0]));
if (_isTesting) {
// Emit assuming url() was parsed; most suite tests use url function.
@@ -223,7 +223,7 @@
}
void visitNamespaceDirective(NamespaceDirective node) {
- bool isStartingQuote(String ch) => ('\'"'.indexOf(ch) >= 0);
+ bool isStartingQuote(String ch) => ('\'"'.contains(ch));
if (isStartingQuote(node._uri)) {
emit(' @namespace ${node.prefix}"${node._uri}"');
diff --git a/lib/src/messages.dart b/lib/src/messages.dart
index 3fe079b..17d1acf 100644
--- a/lib/src/messages.dart
+++ b/lib/src/messages.dart
@@ -23,7 +23,7 @@
/// Map between error levels and their display color.
final Map<Level, String> _ERROR_COLORS = (() {
- var colorsMap = new Map<Level, String>();
+ var colorsMap = Map<Level, String>();
colorsMap[Level.SEVERE] = RED_COLOR;
colorsMap[Level.WARNING] = MAGENTA_COLOR;
colorsMap[Level.INFO] = GREEN_COLOR;
@@ -32,7 +32,7 @@
/// Map between error levels and their friendly name.
final Map<Level, String> _ERROR_LABEL = (() {
- var labels = new Map<Level, String>();
+ var labels = Map<Level, String>();
labels[Level.SEVERE] = 'error';
labels[Level.WARNING] = 'warning';
labels[Level.INFO] = 'info';
@@ -46,12 +46,12 @@
final SourceSpan span;
final bool useColors;
- Message(this.level, this.message, {SourceSpan span, bool useColors: false})
+ Message(this.level, this.message, {SourceSpan span, bool useColors = false})
: this.span = span,
this.useColors = useColors;
String toString() {
- var output = new StringBuffer();
+ var output = StringBuffer();
bool colors = useColors && _ERROR_COLORS.containsKey(level);
var levelColor = colors ? _ERROR_COLORS[level] : null;
if (colors) output.write(levelColor);
@@ -69,7 +69,7 @@
}
}
-typedef void PrintHandler(Message obj);
+typedef PrintHandler = void Function(Message obj);
/// This class tracks and prints information, warnings, and errors emitted by
/// the compiler.
@@ -81,12 +81,12 @@
final List<Message> messages = <Message>[];
- Messages({PreprocessorOptions options, this.printHandler: print})
- : options = options != null ? options : new PreprocessorOptions();
+ Messages({PreprocessorOptions options, this.printHandler = print})
+ : options = options != null ? options : PreprocessorOptions();
/// Report a compile-time CSS error.
void error(String message, SourceSpan span) {
- var msg = new Message(Level.SEVERE, message,
+ var msg = Message(Level.SEVERE, message,
span: span, useColors: options.useColors);
messages.add(msg);
@@ -99,7 +99,7 @@
if (options.warningsAsErrors) {
error(message, span);
} else {
- var msg = new Message(Level.WARNING, message,
+ var msg = Message(Level.WARNING, message,
span: span, useColors: options.useColors);
messages.add(msg);
@@ -108,8 +108,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 =
+ Message(Level.INFO, message, span: span, useColors: options.useColors);
messages.add(msg);
diff --git a/lib/src/options.dart b/lib/src/options.dart
index 19130fe..3300cf6 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -37,13 +37,13 @@
final String inputFile;
const PreprocessorOptions(
- {this.verbose: false,
- this.checked: false,
- this.lessSupport: true,
- this.warningsAsErrors: false,
- this.throwOnErrors: false,
- this.throwOnWarnings: false,
- this.useColors: true,
- this.polyfill: false,
+ {this.verbose = false,
+ this.checked = false,
+ this.lessSupport = true,
+ this.warningsAsErrors = false,
+ this.throwOnErrors = false,
+ this.throwOnWarnings = false,
+ this.useColors = true,
+ this.polyfill = false,
this.inputFile});
}
diff --git a/lib/src/polyfill.dart b/lib/src/polyfill.dart
index fc6cc5f..c8a01f1 100644
--- a/lib/src/polyfill.dart
+++ b/lib/src/polyfill.dart
@@ -8,10 +8,9 @@
/// understand (var, calc, etc.).
class PolyFill {
final Messages _messages;
- Map<String, VarDefinition> _allVarDefinitions =
- new Map<String, VarDefinition>();
+ Map<String, VarDefinition> _allVarDefinitions = Map<String, VarDefinition>();
- Set<StyleSheet> allStyleSheets = new Set<StyleSheet>();
+ Set<StyleSheet> allStyleSheets = Set<StyleSheet>();
/// [_pseudoElements] list of known pseudo attributes found in HTML, any
/// CSS pseudo-elements 'name::custom-element' is mapped to the manged name
@@ -20,20 +19,20 @@
/// Run the analyzer on every file that is a style sheet or any component that
/// has a style tag.
- void process(StyleSheet styleSheet, {List<StyleSheet> includes: null}) {
+ void process(StyleSheet styleSheet, {List<StyleSheet> includes}) {
if (includes != null) {
processVarDefinitions(includes);
}
processVars(styleSheet);
// Remove all var definitions for this style sheet.
- new _RemoveVarDefinitions().visitTree(styleSheet);
+ _RemoveVarDefinitions().visitTree(styleSheet);
}
/// Process all includes looking for var definitions.
void processVarDefinitions(List<StyleSheet> includes) {
for (var include in includes) {
- _allVarDefinitions = (new _VarDefinitionsIncludes(_allVarDefinitions)
+ _allVarDefinitions = (_VarDefinitionsIncludes(_allVarDefinitions)
..visitTree(include))
.varDefs;
}
@@ -42,7 +41,7 @@
void processVars(StyleSheet styleSheet) {
// Build list of all var definitions.
var mainStyleSheetVarDefs =
- (new _VarDefAndUsage(this._messages, _allVarDefinitions)
+ (_VarDefAndUsage(this._messages, _allVarDefinitions)
..visitTree(styleSheet))
.varDefs;
@@ -82,7 +81,7 @@
class _VarDefAndUsage extends Visitor {
final Messages _messages;
final Map<String, VarDefinition> _knownVarDefs;
- final Map<String, VarDefinition> varDefs = new Map<String, VarDefinition>();
+ final Map<String, VarDefinition> varDefs = Map<String, VarDefinition>();
VarDefinition currVarDefinition;
List<Expression> currentExpressions;
diff --git a/lib/src/property.dart b/lib/src/property.dart
index cf614fe..de74760 100644
--- a/lib/src/property.dart
+++ b/lib/src/property.dart
@@ -87,7 +87,7 @@
/// foreground).
Color.createHsla(num hueDegree, num saturationPercent, num lightnessPercent,
[num alpha])
- : this._argb = new Hsla(
+ : this._argb = Hsla(
Color._clamp(hueDegree, 0, 360) / 360,
Color._clamp(saturationPercent, 0, 100) / 100,
Color._clamp(lightnessPercent, 0, 100) / 100,
@@ -108,7 +108,7 @@
/// completely transparent foreground and 1 is a completely
/// opaque foreground.
Color.hslaRaw(num hue, num saturation, num lightness, [num alpha])
- : this._argb = new Hsla(
+ : this._argb = Hsla(
Color._clamp(hue, 0, 1),
Color._clamp(saturation, 0, 1),
Color._clamp(lightness, 0, 1),
@@ -154,10 +154,10 @@
int g = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2));
nextIndex += 2;
int b = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2));
- return new Rgba(r, g, b, a);
+ return Rgba(r, g, b, a);
}
- Hsla get hsla => new Hsla.fromRgba(rgba);
+ Hsla get hsla => Hsla.fromRgba(rgba);
int get argbValue => Color.hexToInt(_argb);
@@ -167,12 +167,12 @@
Color darker(num amount) {
Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, -amount);
- return new Color.hex("${newRgba.toHexArgbString()}");
+ return Color.hex("${newRgba.toHexArgbString()}");
}
Color lighter(num amount) {
Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, amount);
- return new Color.hex("${newRgba.toHexArgbString()}");
+ return Color.hex("${newRgba.toHexArgbString()}");
}
static bool equal(ColorBase curr, other) {
@@ -224,7 +224,7 @@
String v = color.substring(1);
Color.hexToInt(v); // Valid hexadecimal, throws if not.
return v;
- } else if (color.length > 0 && color[color.length - 1] == ')') {
+ } else if (color.isNotEmpty && color[color.length - 1] == ')') {
int type;
if (color.indexOf("rgb(") == 0 || color.indexOf("RGB(") == 0) {
color = color.substring(4);
@@ -239,7 +239,7 @@
type = _hslaCss;
color = color.substring(5);
} else {
- throw new UnsupportedError('CSS property not implemented');
+ throw UnsupportedError('CSS property not implemented');
}
color = color.substring(0, color.length - 1); // Strip close paren.
@@ -255,9 +255,9 @@
case _rgbaCss:
return Color.convertToHexString(args[0], args[1], args[2], args[3]);
case _hslCss:
- return new Hsla(args[0], args[1], args[2]).toHexArgbString();
+ return Hsla(args[0], args[1], args[2]).toHexArgbString();
case _hslaCss:
- return new Hsla(args[0], args[1], args[2], args[3]).toHexArgbString();
+ return Hsla(args[0], args[1], args[2], args[3]).toHexArgbString();
default:
// Type not defined UnsupportedOperationException should have thrown.
assert(false);
@@ -321,7 +321,7 @@
g = Color._changeTintShadeColor(rgba.g, tintShade).round().toInt();
b = Color._changeTintShadeColor(rgba.b, tintShade).round().toInt();
}
- return new Rgba(r, g, b, rgba.a);
+ return Rgba(r, g, b, rgba.a);
}
// TODO(terry): This does an okay lighter/darker; better would be convert to
@@ -500,12 +500,12 @@
this.a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
factory Rgba.fromString(String hexValue) =>
- new Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
+ Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
factory Rgba.fromColor(Color color) => color.rgba;
factory Rgba.fromArgbValue(num value) {
- return new Rgba(
+ return Rgba(
((value.toInt() & 0xff000000) >> 0x18), // a
((value.toInt() & 0xff0000) >> 0x10), // r
((value.toInt() & 0xff00) >> 8), // g
@@ -545,7 +545,7 @@
b = (255 * Rgba._hueToRGB(var1, var2, h - (1 / 3))).round().toInt();
}
- return new Rgba(r, g, b, a);
+ return Rgba(r, g, b, a);
}
static num _hueToRGB(num v1, num v2, num vH) {
@@ -595,8 +595,8 @@
return value;
}
- Color get color => new Color.createRgba(r, g, b, a);
- Hsla get hsla => new Hsla.fromRgba(this);
+ Color get color => Color.createRgba(r, g, b, a);
+ Hsla get hsla => Hsla.fromRgba(this);
Rgba darker(num amount) => Color._createNewTintShadeFromRgba(this, -amount);
Rgba lighter(num amount) => Color._createNewTintShadeFromRgba(this, amount);
@@ -625,7 +625,7 @@
this._a = (alpha != null) ? Color._clamp(alpha, 0, 1) : alpha;
factory Hsla.fromString(String hexValue) {
- Rgba rgba = new Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
+ Rgba rgba = Color.css("#${Color._convertCssToArgb(hexValue)}").rgba;
return _createFromRgba(rgba.r, rgba.g, rgba.b, rgba.a);
}
@@ -668,7 +668,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 Hsla(0, 0, l); // Black;
}
num vm = maxRgb - minRgb;
@@ -676,7 +676,7 @@
if (s > 0) {
s /= (l < 0.5) ? (maxRgb + minRgb) : (2 - maxRgb - minRgb);
} else {
- return new Hsla(0, 0, l); // White
+ return Hsla(0, 0, l); // White
}
num r2, g2, b2;
@@ -692,7 +692,7 @@
}
h /= 6;
- return new Hsla(h, s, l, a);
+ return Hsla(h, s, l, a);
}
/// Returns 0..1 fraction (ratio of 360°, e.g. 1° == 1/360).
@@ -722,18 +722,17 @@
? "hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)"
: "hsla($hueDegrees,$saturationPercentage,$lightnessPercentage,$_a)";
- String toHexArgbString() => new Rgba.fromHsla(this).toHexArgbString();
+ String toHexArgbString() => Rgba.fromHsla(this).toHexArgbString();
int get argbValue => Color.hexToInt(this.toHexArgbString());
- Color get color => new Color.createHsla(_h, _s, _l, _a);
- Rgba get rgba => new Rgba.fromHsla(this);
+ Color get color => Color.createHsla(_h, _s, _l, _a);
+ Rgba get rgba => Rgba.fromHsla(this);
- Hsla darker(num amount) =>
- new Hsla.fromRgba(new Rgba.fromHsla(this).darker(amount));
+ Hsla darker(num amount) => Hsla.fromRgba(Rgba.fromHsla(this).darker(amount));
Hsla lighter(num amount) =>
- new Hsla.fromRgba(new Rgba.fromHsla(this).lighter(amount));
+ Hsla.fromRgba(Rgba.fromHsla(this).lighter(amount));
int get hashCode => toHexArgbString().hashCode;
}
@@ -773,9 +772,9 @@
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";
+ "${right != null ? '$right' : '0'}px "
+ "${bottom != null ? '$bottom' : '0'}px "
+ "${left != null ? '$left' : '0'}px";
}
}
@@ -901,14 +900,14 @@
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.
/// Font style support for size, family, weight, style, variant, and lineheight.
class Font implements _StyleProperty {
/// Collection of most common sans-serif fonts in order.
- static const List<String> sansSerif = const [
+ static const List<String> sansSerif = [
FontFamily.arial,
FontFamily.verdana,
FontFamily.geneva,
@@ -917,7 +916,7 @@
];
/// Collection of most common serif fonts in order.
- static const List<String> serif = const [
+ static const List<String> serif = [
FontFamily.georgia,
FontFamily.timesNewRoman,
FontFamily.times,
@@ -925,14 +924,14 @@
];
/// Collection of most common monospace fonts in order.
- static const List<String> monospace = const [
+ static const List<String> monospace = [
FontFamily.courierNew,
FontFamily.courier,
FontGeneric.monospace
];
/// Collection of most common cursive fonts in order.
- static const List<String> cursive = const [
+ static const List<String> cursive = [
FontFamily.textile,
FontFamily.appleChancery,
FontFamily.zaphChancery,
@@ -940,7 +939,7 @@
];
/// Collection of most common fantasy fonts in order.
- static const List<String> fantasy = const [
+ static const List<String> fantasy = [
FontFamily.comicSansMs,
FontFamily.impact,
FontFamily.webdings,
@@ -1001,7 +1000,7 @@
factory Font.merge(Font a, Font b) {
if (a == null) return b;
if (b == null) return a;
- return new Font._merge(a, b);
+ return Font._merge(a, b);
}
Font._merge(Font a, Font b)
@@ -1031,7 +1030,7 @@
return '${size}px $_fontsAsString';
}
- Font scale(num ratio) => new Font(
+ Font scale(num ratio) => Font(
size: size * ratio,
family: family,
weight: weight,
@@ -1148,7 +1147,7 @@
make = true;
bottom = 0;
}
- return make ? new BoxEdge(left, top, right, bottom) : other;
+ return make ? BoxEdge(left, top, right, bottom) : other;
}
/// Merge the two box edge sizes and return the result. See [Style.merge] for
@@ -1156,7 +1155,7 @@
factory BoxEdge.merge(BoxEdge x, BoxEdge y) {
if (x == null) return y;
if (y == null) return x;
- return new BoxEdge._merge(x, y);
+ return BoxEdge._merge(x, y);
}
BoxEdge._merge(BoxEdge x, BoxEdge y)
diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart
index a4ca215..a09e306 100644
--- a/lib/src/tokenizer.dart
+++ b/lib/src/tokenizer.dart
@@ -18,7 +18,7 @@
Tokenizer(SourceFile file, String text, bool skipWhitespace, [int index = 0])
: super(file, text, skipWhitespace, index);
- Token next({bool unicodeRange: false}) {
+ Token next({bool unicodeRange = false}) {
// keep track of our starting position
_startIndex = _index;
@@ -241,7 +241,7 @@
(_peekChar() == '-'.codeUnitAt(0));
}
- Token _errorToken([String message = null]) {
+ Token _errorToken([String message]) {
return _finishToken(TokenKind.ERROR);
}
@@ -314,9 +314,9 @@
}
var span = _file.span(_startIndex, _index);
- var text = new String.fromCharCodes(chars);
+ var text = String.fromCharCodes(chars);
- return new IdentifierToken(text, getIdentifierKind(), span);
+ return IdentifierToken(text, getIdentifierKind(), span);
}
Token finishNumber() {
diff --git a/lib/src/tokenizer_base.dart b/lib/src/tokenizer_base.dart
index 07aee79..a856727 100644
--- a/lib/src/tokenizer_base.dart
+++ b/lib/src/tokenizer_base.dart
@@ -55,7 +55,7 @@
int getIdentifierKind();
/// Snapshot of Tokenizer scanning state.
- TokenizerState get mark => new TokenizerState(this);
+ TokenizerState get mark => TokenizerState(this);
/// Restore Tokenizer scanning state.
void restore(TokenizerState markedData) {
@@ -106,11 +106,11 @@
}
Token _finishToken(int kind) {
- return new Token(kind, _file.span(_startIndex, _index));
+ return Token(kind, _file.span(_startIndex, _index));
}
- Token _errorToken([String message = null]) {
- return new ErrorToken(
+ Token _errorToken([String message]) {
+ return ErrorToken(
TokenKind.ERROR, _file.span(_startIndex, _index), message);
}
@@ -248,14 +248,14 @@
}
Token _makeStringToken(List<int> buf, bool isPart) {
- final s = new String.fromCharCodes(buf);
+ final s = String.fromCharCodes(buf);
final kind = isPart ? TokenKind.STRING_PART : TokenKind.STRING;
- return new LiteralToken(kind, _file.span(_startIndex, _index), s);
+ return LiteralToken(kind, _file.span(_startIndex, _index), s);
}
Token makeIEFilter(int start, int end) {
var filter = _text.substring(start, end);
- return new LiteralToken(TokenKind.STRING, _file.span(start, end), filter);
+ return LiteralToken(TokenKind.STRING, _file.span(start, end), filter);
}
Token _makeRawStringToken(bool isMultiline) {
@@ -268,8 +268,7 @@
} else {
s = _text.substring(_startIndex + 2, _index - 1);
}
- return new LiteralToken(
- TokenKind.STRING, _file.span(_startIndex, _index), s);
+ return LiteralToken(TokenKind.STRING, _file.span(_startIndex, _index), s);
}
Token finishMultilineString(int quote) {
@@ -306,7 +305,7 @@
_maybeEatChar(TokenChar.NEWLINE);
return finishMultilineString(quote);
} else {
- return _makeStringToken(new List<int>(), false);
+ return _makeStringToken(List<int>(), false);
}
}
return finishStringBody(quote);
@@ -342,7 +341,7 @@
}
Token finishStringBody(int quote) {
- var buf = new List<int>();
+ var buf = List<int>();
while (true) {
int ch = _nextChar();
if (ch == quote) {
diff --git a/lib/src/tokenkind.dart b/lib/src/tokenkind.dart
index 1afbe4e..af6233e 100644
--- a/lib/src/tokenkind.dart
+++ b/lib/src/tokenkind.dart
@@ -198,121 +198,97 @@
static const int PSEUDO_CLASS_NAME = 705; // :pseudoClass
static const int NEGATION = 706; // NOT
- static const List<Map<String, dynamic>> _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 {
+ static const List<Map<String, dynamic>> _DIRECTIVES = [
+ {'type': TokenKind.DIRECTIVE_IMPORT, 'value': 'import'},
+ {'type': TokenKind.DIRECTIVE_MEDIA, 'value': 'media'},
+ {'type': TokenKind.DIRECTIVE_PAGE, 'value': 'page'},
+ {'type': TokenKind.DIRECTIVE_CHARSET, 'value': 'charset'},
+ {'type': TokenKind.DIRECTIVE_STYLET, 'value': 'stylet'},
+ {'type': TokenKind.DIRECTIVE_KEYFRAMES, 'value': 'keyframes'},
+ {
'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_MOZ_DOCUMENT, 'value': '-moz-document'},
- const {'type': TokenKind.DIRECTIVE_SUPPORTS, 'value': 'supports'},
- const {'type': TokenKind.DIRECTIVE_VIEWPORT, 'value': 'viewport'},
- const {'type': TokenKind.DIRECTIVE_MS_VIEWPORT, 'value': '-ms-viewport'},
+ {'type': TokenKind.DIRECTIVE_MOZ_KEYFRAMES, 'value': '-moz-keyframes'},
+ {'type': TokenKind.DIRECTIVE_MS_KEYFRAMES, 'value': '-ms-keyframes'},
+ {'type': TokenKind.DIRECTIVE_O_KEYFRAMES, 'value': '-o-keyframes'},
+ {'type': TokenKind.DIRECTIVE_FONTFACE, 'value': 'font-face'},
+ {'type': TokenKind.DIRECTIVE_NAMESPACE, 'value': 'namespace'},
+ {'type': TokenKind.DIRECTIVE_HOST, 'value': 'host'},
+ {'type': TokenKind.DIRECTIVE_MIXIN, 'value': 'mixin'},
+ {'type': TokenKind.DIRECTIVE_INCLUDE, 'value': 'include'},
+ {'type': TokenKind.DIRECTIVE_CONTENT, 'value': 'content'},
+ {'type': TokenKind.DIRECTIVE_EXTEND, 'value': 'extend'},
+ {'type': TokenKind.DIRECTIVE_MOZ_DOCUMENT, 'value': '-moz-document'},
+ {'type': TokenKind.DIRECTIVE_SUPPORTS, 'value': 'supports'},
+ {'type': TokenKind.DIRECTIVE_VIEWPORT, 'value': 'viewport'},
+ {'type': TokenKind.DIRECTIVE_MS_VIEWPORT, 'value': '-ms-viewport'},
];
- static const List<Map<String, dynamic>> 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'},
+ static const List<Map<String, dynamic>> MEDIA_OPERATORS = [
+ {'type': TokenKind.MEDIA_OP_ONLY, 'value': 'only'},
+ {'type': TokenKind.MEDIA_OP_NOT, 'value': 'not'},
+ {'type': TokenKind.MEDIA_OP_AND, 'value': 'and'},
];
- static const List<Map<String, dynamic>> MARGIN_DIRECTIVES = const [
- const {
+ static const List<Map<String, dynamic>> MARGIN_DIRECTIVES = [
+ {
'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_TOPLEFT, 'value': 'top-left'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_TOPCENTER, 'value': 'top-center'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHT, 'value': 'top-right'},
+ {
'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_BOTTOMLEFT, 'value': 'bottom-left'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMCENTER, 'value': 'bottom-center'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHT, 'value': 'bottom-right'},
+ {
'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'
- },
+ {'type': TokenKind.MARGIN_DIRECTIVE_LEFTTOP, 'value': 'left-top'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_LEFTMIDDLE, 'value': 'left-middle'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_LEFTBOTTOM, 'value': 'right-bottom'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTTOP, 'value': 'right-top'},
+ {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTMIDDLE, 'value': 'right-middle'},
+ {'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'},
+ static const List<Map> _UNITS = [
+ {'unit': TokenKind.UNIT_EM, 'value': 'em'},
+ {'unit': TokenKind.UNIT_EX, 'value': 'ex'},
+ {'unit': TokenKind.UNIT_LENGTH_PX, 'value': 'px'},
+ {'unit': TokenKind.UNIT_LENGTH_CM, 'value': 'cm'},
+ {'unit': TokenKind.UNIT_LENGTH_MM, 'value': 'mm'},
+ {'unit': TokenKind.UNIT_LENGTH_IN, 'value': 'in'},
+ {'unit': TokenKind.UNIT_LENGTH_PT, 'value': 'pt'},
+ {'unit': TokenKind.UNIT_LENGTH_PC, 'value': 'pc'},
+ {'unit': TokenKind.UNIT_ANGLE_DEG, 'value': 'deg'},
+ {'unit': TokenKind.UNIT_ANGLE_RAD, 'value': 'rad'},
+ {'unit': TokenKind.UNIT_ANGLE_GRAD, 'value': 'grad'},
+ {'unit': TokenKind.UNIT_ANGLE_TURN, 'value': 'turn'},
+ {'unit': TokenKind.UNIT_TIME_MS, 'value': 'ms'},
+ {'unit': TokenKind.UNIT_TIME_S, 'value': 's'},
+ {'unit': TokenKind.UNIT_FREQ_HZ, 'value': 'hz'},
+ {'unit': TokenKind.UNIT_FREQ_KHZ, 'value': 'khz'},
+ {'unit': TokenKind.UNIT_FRACTION, 'value': 'fr'},
+ {'unit': TokenKind.UNIT_RESOLUTION_DPI, 'value': 'dpi'},
+ {'unit': TokenKind.UNIT_RESOLUTION_DPCM, 'value': 'dpcm'},
+ {'unit': TokenKind.UNIT_RESOLUTION_DPPX, 'value': 'dppx'},
+ {'unit': TokenKind.UNIT_CH, 'value': 'ch'},
+ {'unit': TokenKind.UNIT_REM, 'value': 'rem'},
+ {'unit': TokenKind.UNIT_VIEWPORT_VW, 'value': 'vw'},
+ {'unit': TokenKind.UNIT_VIEWPORT_VH, 'value': 'vh'},
+ {'unit': TokenKind.UNIT_VIEWPORT_VMIN, 'value': 'vmin'},
+ {'unit': TokenKind.UNIT_VIEWPORT_VMAX, 'value': 'vmax'},
];
// Some more constants:
@@ -320,154 +296,154 @@
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},
+ static const List<Map> _EXTENDED_COLOR_NAMES = [
+ {'name': 'aliceblue', 'value': 0xF08FF},
+ {'name': 'antiquewhite', 'value': 0xFAEBD7},
+ {'name': 'aqua', 'value': 0x00FFFF},
+ {'name': 'aquamarine', 'value': 0x7FFFD4},
+ {'name': 'azure', 'value': 0xF0FFFF},
+ {'name': 'beige', 'value': 0xF5F5DC},
+ {'name': 'bisque', 'value': 0xFFE4C4},
+ {'name': 'black', 'value': 0x000000},
+ {'name': 'blanchedalmond', 'value': 0xFFEBCD},
+ {'name': 'blue', 'value': 0x0000FF},
+ {'name': 'blueviolet', 'value': 0x8A2BE2},
+ {'name': 'brown', 'value': 0xA52A2A},
+ {'name': 'burlywood', 'value': 0xDEB887},
+ {'name': 'cadetblue', 'value': 0x5F9EA0},
+ {'name': 'chartreuse', 'value': 0x7FFF00},
+ {'name': 'chocolate', 'value': 0xD2691E},
+ {'name': 'coral', 'value': 0xFF7F50},
+ {'name': 'cornflowerblue', 'value': 0x6495ED},
+ {'name': 'cornsilk', 'value': 0xFFF8DC},
+ {'name': 'crimson', 'value': 0xDC143C},
+ {'name': 'cyan', 'value': 0x00FFFF},
+ {'name': 'darkblue', 'value': 0x00008B},
+ {'name': 'darkcyan', 'value': 0x008B8B},
+ {'name': 'darkgoldenrod', 'value': 0xB8860B},
+ {'name': 'darkgray', 'value': 0xA9A9A9},
+ {'name': 'darkgreen', 'value': 0x006400},
+ {'name': 'darkgrey', 'value': 0xA9A9A9},
+ {'name': 'darkkhaki', 'value': 0xBDB76B},
+ {'name': 'darkmagenta', 'value': 0x8B008B},
+ {'name': 'darkolivegreen', 'value': 0x556B2F},
+ {'name': 'darkorange', 'value': 0xFF8C00},
+ {'name': 'darkorchid', 'value': 0x9932CC},
+ {'name': 'darkred', 'value': 0x8B0000},
+ {'name': 'darksalmon', 'value': 0xE9967A},
+ {'name': 'darkseagreen', 'value': 0x8FBC8F},
+ {'name': 'darkslateblue', 'value': 0x483D8B},
+ {'name': 'darkslategray', 'value': 0x2F4F4F},
+ {'name': 'darkslategrey', 'value': 0x2F4F4F},
+ {'name': 'darkturquoise', 'value': 0x00CED1},
+ {'name': 'darkviolet', 'value': 0x9400D3},
+ {'name': 'deeppink', 'value': 0xFF1493},
+ {'name': 'deepskyblue', 'value': 0x00BFFF},
+ {'name': 'dimgray', 'value': 0x696969},
+ {'name': 'dimgrey', 'value': 0x696969},
+ {'name': 'dodgerblue', 'value': 0x1E90FF},
+ {'name': 'firebrick', 'value': 0xB22222},
+ {'name': 'floralwhite', 'value': 0xFFFAF0},
+ {'name': 'forestgreen', 'value': 0x228B22},
+ {'name': 'fuchsia', 'value': 0xFF00FF},
+ {'name': 'gainsboro', 'value': 0xDCDCDC},
+ {'name': 'ghostwhite', 'value': 0xF8F8FF},
+ {'name': 'gold', 'value': 0xFFD700},
+ {'name': 'goldenrod', 'value': 0xDAA520},
+ {'name': 'gray', 'value': 0x808080},
+ {'name': 'green', 'value': 0x008000},
+ {'name': 'greenyellow', 'value': 0xADFF2F},
+ {'name': 'grey', 'value': 0x808080},
+ {'name': 'honeydew', 'value': 0xF0FFF0},
+ {'name': 'hotpink', 'value': 0xFF69B4},
+ {'name': 'indianred', 'value': 0xCD5C5C},
+ {'name': 'indigo', 'value': 0x4B0082},
+ {'name': 'ivory', 'value': 0xFFFFF0},
+ {'name': 'khaki', 'value': 0xF0E68C},
+ {'name': 'lavender', 'value': 0xE6E6FA},
+ {'name': 'lavenderblush', 'value': 0xFFF0F5},
+ {'name': 'lawngreen', 'value': 0x7CFC00},
+ {'name': 'lemonchiffon', 'value': 0xFFFACD},
+ {'name': 'lightblue', 'value': 0xADD8E6},
+ {'name': 'lightcoral', 'value': 0xF08080},
+ {'name': 'lightcyan', 'value': 0xE0FFFF},
+ {'name': 'lightgoldenrodyellow', 'value': 0xFAFAD2},
+ {'name': 'lightgray', 'value': 0xD3D3D3},
+ {'name': 'lightgreen', 'value': 0x90EE90},
+ {'name': 'lightgrey', 'value': 0xD3D3D3},
+ {'name': 'lightpink', 'value': 0xFFB6C1},
+ {'name': 'lightsalmon', 'value': 0xFFA07A},
+ {'name': 'lightseagreen', 'value': 0x20B2AA},
+ {'name': 'lightskyblue', 'value': 0x87CEFA},
+ {'name': 'lightslategray', 'value': 0x778899},
+ {'name': 'lightslategrey', 'value': 0x778899},
+ {'name': 'lightsteelblue', 'value': 0xB0C4DE},
+ {'name': 'lightyellow', 'value': 0xFFFFE0},
+ {'name': 'lime', 'value': 0x00FF00},
+ {'name': 'limegreen', 'value': 0x32CD32},
+ {'name': 'linen', 'value': 0xFAF0E6},
+ {'name': 'magenta', 'value': 0xFF00FF},
+ {'name': 'maroon', 'value': 0x800000},
+ {'name': 'mediumaquamarine', 'value': 0x66CDAA},
+ {'name': 'mediumblue', 'value': 0x0000CD},
+ {'name': 'mediumorchid', 'value': 0xBA55D3},
+ {'name': 'mediumpurple', 'value': 0x9370DB},
+ {'name': 'mediumseagreen', 'value': 0x3CB371},
+ {'name': 'mediumslateblue', 'value': 0x7B68EE},
+ {'name': 'mediumspringgreen', 'value': 0x00FA9A},
+ {'name': 'mediumturquoise', 'value': 0x48D1CC},
+ {'name': 'mediumvioletred', 'value': 0xC71585},
+ {'name': 'midnightblue', 'value': 0x191970},
+ {'name': 'mintcream', 'value': 0xF5FFFA},
+ {'name': 'mistyrose', 'value': 0xFFE4E1},
+ {'name': 'moccasin', 'value': 0xFFE4B5},
+ {'name': 'navajowhite', 'value': 0xFFDEAD},
+ {'name': 'navy', 'value': 0x000080},
+ {'name': 'oldlace', 'value': 0xFDF5E6},
+ {'name': 'olive', 'value': 0x808000},
+ {'name': 'olivedrab', 'value': 0x6B8E23},
+ {'name': 'orange', 'value': 0xFFA500},
+ {'name': 'orangered', 'value': 0xFF4500},
+ {'name': 'orchid', 'value': 0xDA70D6},
+ {'name': 'palegoldenrod', 'value': 0xEEE8AA},
+ {'name': 'palegreen', 'value': 0x98FB98},
+ {'name': 'paleturquoise', 'value': 0xAFEEEE},
+ {'name': 'palevioletred', 'value': 0xDB7093},
+ {'name': 'papayawhip', 'value': 0xFFEFD5},
+ {'name': 'peachpuff', 'value': 0xFFDAB9},
+ {'name': 'peru', 'value': 0xCD853F},
+ {'name': 'pink', 'value': 0xFFC0CB},
+ {'name': 'plum', 'value': 0xDDA0DD},
+ {'name': 'powderblue', 'value': 0xB0E0E6},
+ {'name': 'purple', 'value': 0x800080},
+ {'name': 'red', 'value': 0xFF0000},
+ {'name': 'rosybrown', 'value': 0xBC8F8F},
+ {'name': 'royalblue', 'value': 0x4169E1},
+ {'name': 'saddlebrown', 'value': 0x8B4513},
+ {'name': 'salmon', 'value': 0xFA8072},
+ {'name': 'sandybrown', 'value': 0xF4A460},
+ {'name': 'seagreen', 'value': 0x2E8B57},
+ {'name': 'seashell', 'value': 0xFFF5EE},
+ {'name': 'sienna', 'value': 0xA0522D},
+ {'name': 'silver', 'value': 0xC0C0C0},
+ {'name': 'skyblue', 'value': 0x87CEEB},
+ {'name': 'slateblue', 'value': 0x6A5ACD},
+ {'name': 'slategray', 'value': 0x708090},
+ {'name': 'slategrey', 'value': 0x708090},
+ {'name': 'snow', 'value': 0xFFFAFA},
+ {'name': 'springgreen', 'value': 0x00FF7F},
+ {'name': 'steelblue', 'value': 0x4682B4},
+ {'name': 'tan', 'value': 0xD2B48C},
+ {'name': 'teal', 'value': 0x008080},
+ {'name': 'thistle', 'value': 0xD8BFD8},
+ {'name': 'tomato', 'value': 0xFF6347},
+ {'name': 'turquoise', 'value': 0x40E0D0},
+ {'name': 'violet', 'value': 0xEE82EE},
+ {'name': 'wheat', 'value': 0xF5DEB3},
+ {'name': 'white', 'value': 0xFFFFFF},
+ {'name': 'whitesmoke', 'value': 0xF5F5F5},
+ {'name': 'yellow', 'value': 0xFFFF00},
+ {'name': 'yellowgreen', 'value': 0x9ACD32},
];
// TODO(terry): Should used Dart mirroring for parameter values and types
@@ -597,7 +573,7 @@
static String decimalToHex(int number, [int minDigits = 1]) {
final String _HEX_DIGITS = '0123456789abcdef';
- List<String> result = new List<String>();
+ List<String> result = List<String>();
int dividend = number >> 4;
int remain = number % 16;
@@ -608,7 +584,7 @@
result.add(_HEX_DIGITS[remain]);
}
- StringBuffer invertResult = new StringBuffer();
+ StringBuffer invertResult = StringBuffer();
int paddings = minDigits - result.length;
while (paddings-- > 0) {
invertResult.write('0');
diff --git a/lib/src/tree.dart b/lib/src/tree.dart
index f68c879..fa66422 100644
--- a/lib/src/tree.dart
+++ b/lib/src/tree.dart
@@ -13,7 +13,7 @@
Identifier(this.name, SourceSpan span) : super(span);
- Identifier clone() => new Identifier(name, span);
+ Identifier clone() => Identifier(name, span);
visit(VisitorBase visitor) => visitor.visitIdentifier(this);
@@ -22,7 +22,7 @@
class Wildcard extends TreeNode {
Wildcard(SourceSpan span) : super(span);
- Wildcard clone() => new Wildcard(span);
+ Wildcard clone() => Wildcard(span);
visit(VisitorBase visitor) => visitor.visitWildcard(this);
String get name => '*';
@@ -30,7 +30,7 @@
class ThisOperator extends TreeNode {
ThisOperator(SourceSpan span) : super(span);
- ThisOperator clone() => new ThisOperator(span);
+ ThisOperator clone() => ThisOperator(span);
visit(VisitorBase visitor) => visitor.visitThisOperator(this);
String get name => '&';
@@ -38,7 +38,7 @@
class Negation extends TreeNode {
Negation(SourceSpan span) : super(span);
- Negation clone() => new Negation(span);
+ Negation clone() => Negation(span);
visit(VisitorBase visitor) => visitor.visitNegation(this);
String get name => 'not';
@@ -53,7 +53,7 @@
CalcTerm(var value, String t, this.expr, SourceSpan span)
: super(value, t, span);
- CalcTerm clone() => new CalcTerm(value, text, expr.clone(), span);
+ CalcTerm clone() => CalcTerm(value, text, expr.clone(), span);
visit(VisitorBase visitor) => visitor.visitCalcTerm(this);
String toString() => "$text($expr)";
@@ -64,14 +64,14 @@
final String comment;
CssComment(this.comment, SourceSpan span) : super(span);
- CssComment clone() => new CssComment(comment, span);
+ CssComment clone() => 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 clone() => new CommentDefinition(comment, span);
+ CommentDefinition clone() => CommentDefinition(comment, span);
visit(VisitorBase visitor) => visitor.visitCommentDefinition(this);
}
@@ -80,7 +80,7 @@
SelectorGroup(this.selectors, SourceSpan span) : super(span);
- SelectorGroup clone() => new SelectorGroup(selectors, span);
+ SelectorGroup clone() => SelectorGroup(selectors, span);
visit(VisitorBase visitor) => visitor.visitSelectorGroup(this);
}
@@ -98,7 +98,7 @@
var simpleSequences =
simpleSelectorSequences.map((ss) => ss.clone()).toList();
- return new Selector(simpleSequences, span);
+ return Selector(simpleSequences, span);
}
visit(VisitorBase visitor) => visitor.visitSelector(this);
@@ -144,7 +144,7 @@
}
SimpleSelectorSequence clone() =>
- new SimpleSelectorSequence(simpleSelector, span, combinator);
+ SimpleSelectorSequence(simpleSelector, span, combinator);
visit(VisitorBase visitor) => visitor.visitSimpleSelectorSequence(this);
@@ -172,7 +172,7 @@
ElementSelector(name, SourceSpan span) : super(name, span);
visit(VisitorBase visitor) => visitor.visitElementSelector(this);
- ElementSelector clone() => new ElementSelector(_name, span);
+ ElementSelector clone() => ElementSelector(_name, span);
String toString() => name;
}
@@ -191,7 +191,7 @@
SimpleSelector get nameAsSimpleSelector => _name;
- NamespaceSelector clone() => new NamespaceSelector(_namespace, "", span);
+ NamespaceSelector clone() => NamespaceSelector(_namespace, "", span);
visit(VisitorBase visitor) => visitor.visitNamespaceSelector(this);
@@ -261,7 +261,7 @@
}
}
- AttributeSelector clone() => new AttributeSelector(_name, _op, _value, span);
+ AttributeSelector clone() => AttributeSelector(_name, _op, _value, span);
visit(VisitorBase visitor) => visitor.visitAttributeSelector(this);
@@ -271,7 +271,7 @@
// #id
class IdSelector extends SimpleSelector {
IdSelector(Identifier name, SourceSpan span) : super(name, span);
- IdSelector clone() => new IdSelector(_name, span);
+ IdSelector clone() => IdSelector(_name, span);
visit(VisitorBase visitor) => visitor.visitIdSelector(this);
String toString() => "#$_name";
@@ -280,7 +280,7 @@
// .class
class ClassSelector extends SimpleSelector {
ClassSelector(Identifier name, SourceSpan span) : super(name, span);
- ClassSelector clone() => new ClassSelector(_name, span);
+ ClassSelector clone() => ClassSelector(_name, span);
visit(VisitorBase visitor) => visitor.visitClassSelector(this);
String toString() => ".$_name";
@@ -291,7 +291,7 @@
PseudoClassSelector(Identifier name, SourceSpan span) : super(name, span);
visit(VisitorBase visitor) => visitor.visitPseudoClassSelector(this);
- PseudoClassSelector clone() => new PseudoClassSelector(_name, span);
+ PseudoClassSelector clone() => PseudoClassSelector(_name, span);
String toString() => ":$name";
}
@@ -302,11 +302,11 @@
final bool isLegacy;
PseudoElementSelector(Identifier name, SourceSpan span,
- {this.isLegacy: false})
+ {this.isLegacy = false})
: super(name, span);
visit(VisitorBase visitor) => visitor.visitPseudoElementSelector(this);
- PseudoElementSelector clone() => new PseudoElementSelector(_name, span);
+ PseudoElementSelector clone() => PseudoElementSelector(_name, span);
String toString() => "${isLegacy ? ':' : '::'}$name";
}
@@ -319,7 +319,7 @@
: super(name, span);
PseudoClassFunctionSelector clone() =>
- new PseudoClassFunctionSelector(_name, _argument, span);
+ PseudoClassFunctionSelector(_name, _argument, span);
TreeNode get argument => _argument;
Selector get selector => _argument as Selector;
@@ -337,7 +337,7 @@
: super(name, span);
PseudoElementFunctionSelector clone() =>
- new PseudoElementFunctionSelector(_name, expression, span);
+ PseudoElementFunctionSelector(_name, expression, span);
visit(VisitorBase visitor) =>
visitor.visitPseudoElementFunctionSelector(this);
@@ -349,8 +349,7 @@
SelectorExpression(this.expressions, SourceSpan span) : super(span);
SelectorExpression clone() {
- return new SelectorExpression(
- expressions.map((e) => e.clone()).toList(), span);
+ return SelectorExpression(expressions.map((e) => e.clone()).toList(), span);
}
visit(VisitorBase visitor) => visitor.visitSelectorExpression(this);
@@ -361,9 +360,9 @@
final SimpleSelector negationArg;
NegationSelector(this.negationArg, SourceSpan span)
- : super(new Negation(span), span);
+ : super(Negation(span), span);
- NegationSelector clone() => new NegationSelector(negationArg, span);
+ NegationSelector clone() => NegationSelector(negationArg, span);
visit(VisitorBase visitor) => visitor.visitNegationSelector(this);
}
@@ -371,7 +370,7 @@
class NoOp extends TreeNode {
NoOp() : super(null);
- NoOp clone() => new NoOp();
+ NoOp clone() => NoOp();
visit(VisitorBase visitor) => visitor.visitNoOp(this);
}
@@ -391,7 +390,7 @@
StyleSheet clone() {
var clonedTopLevels = topLevels.map((e) => e.clone()).toList();
- return new StyleSheet(clonedTopLevels, span);
+ return StyleSheet(clonedTopLevels, span);
}
visit(VisitorBase visitor) => visitor.visitStyleSheet(this);
@@ -399,7 +398,7 @@
class TopLevelProduction extends TreeNode {
TopLevelProduction(SourceSpan span) : super(span);
- TopLevelProduction clone() => new TopLevelProduction(span);
+ TopLevelProduction clone() => TopLevelProduction(span);
visit(VisitorBase visitor) => visitor.visitTopLevelProduction(this);
}
@@ -416,7 +415,7 @@
RuleSet clone() {
var cloneSelectorGroup = _selectorGroup.clone();
var cloneDeclarationGroup = _declarationGroup.clone();
- return new RuleSet(cloneSelectorGroup, cloneDeclarationGroup, span);
+ return RuleSet(cloneSelectorGroup, cloneDeclarationGroup, span);
}
visit(VisitorBase visitor) => visitor.visitRuleSet(this);
@@ -428,7 +427,7 @@
bool get isBuiltIn => true; // Known CSS directive?
bool get isExtension => false; // SCSS extension?
- Directive clone() => new Directive(span);
+ Directive clone() => Directive(span);
visit(VisitorBase visitor) => visitor.visitDirective(this);
}
@@ -448,7 +447,7 @@
for (var rule in groupRuleBody) {
clonedGroupRuleBody.add(rule.clone());
}
- return new DocumentDirective(clonedFunctions, clonedGroupRuleBody, span);
+ return DocumentDirective(clonedFunctions, clonedGroupRuleBody, span);
}
visit(VisitorBase visitor) => visitor.visitDocumentDirective(this);
@@ -467,7 +466,7 @@
for (var rule in groupRuleBody) {
clonedGroupRuleBody.add(rule.clone());
}
- return new SupportsDirective(clonedCondition, clonedGroupRuleBody, span);
+ return SupportsDirective(clonedCondition, clonedGroupRuleBody, span);
}
visit(VisitorBase visitor) => visitor.visitSupportsDirective(this);
@@ -490,7 +489,7 @@
super(span);
SupportsConditionInParens clone() =>
- new SupportsConditionInParens(condition.clone(), span);
+ SupportsConditionInParens(condition.clone(), span);
visit(VisitorBase visitor) => visitor.visitSupportsConditionInParens(this);
}
@@ -500,7 +499,7 @@
SupportsNegation(this.condition, SourceSpan span) : super(span);
- SupportsNegation clone() => new SupportsNegation(condition.clone(), span);
+ SupportsNegation clone() => SupportsNegation(condition.clone(), span);
visit(VisitorBase visitor) => visitor.visitSupportsNegation(this);
}
@@ -515,7 +514,7 @@
for (var condition in conditions) {
clonedConditions.add(condition.clone());
}
- return new SupportsConjunction(clonedConditions, span);
+ return SupportsConjunction(clonedConditions, span);
}
visit(VisitorBase visitor) => visitor.visitSupportsConjunction(this);
@@ -531,7 +530,7 @@
for (var condition in conditions) {
clonedConditions.add(condition.clone());
}
- return new SupportsDisjunction(clonedConditions, span);
+ return SupportsDisjunction(clonedConditions, span);
}
visit(VisitorBase visitor) => visitor.visitSupportsDisjunction(this);
@@ -545,7 +544,7 @@
: super(span);
ViewportDirective clone() =>
- new ViewportDirective(name, declarations.clone(), span);
+ ViewportDirective(name, declarations.clone(), span);
visit(VisitorBase visitor) => visitor.visitViewportDirective(this);
}
@@ -565,7 +564,7 @@
for (var mediaQuery in mediaQueries) {
cloneMediaQueries.add(mediaQuery.clone());
}
- return new ImportDirective(import, cloneMediaQueries, span);
+ return ImportDirective(import, cloneMediaQueries, span);
}
visit(VisitorBase visitor) => visitor.visitImportDirective(this);
@@ -587,7 +586,7 @@
MediaExpression clone() {
var clonedExprs = exprs.clone();
- return new MediaExpression(andOperator, _mediaFeature, clonedExprs, span);
+ return MediaExpression(andOperator, _mediaFeature, clonedExprs, span);
}
visit(VisitorBase visitor) => visitor.visitMediaExpression(this);
@@ -625,7 +624,7 @@
for (var expr in expressions) {
cloneExpressions.add(expr.clone());
}
- return new MediaQuery(_mediaUnary, _mediaType, cloneExpressions, span);
+ return MediaQuery(_mediaUnary, _mediaType, cloneExpressions, span);
}
visit(VisitorBase visitor) => visitor.visitMediaQuery(this);
@@ -646,7 +645,7 @@
for (var rule in rules) {
cloneRules.add(rule.clone());
}
- return new MediaDirective(cloneQueries, cloneRules, span);
+ return MediaDirective(cloneQueries, cloneRules, span);
}
visit(VisitorBase visitor) => visitor.visitMediaDirective(this);
@@ -662,7 +661,7 @@
for (var rule in rules) {
cloneRules.add(rule.clone());
}
- return new HostDirective(cloneRules, span);
+ return HostDirective(cloneRules, span);
}
visit(VisitorBase visitor) => visitor.visitHostDirective(this);
@@ -682,20 +681,20 @@
for (var declMargin in _declsMargin) {
cloneDeclsMargin.add(declMargin.clone());
}
- return new PageDirective(_ident, _pseudoPage, cloneDeclsMargin, span);
+ return PageDirective(_ident, _pseudoPage, cloneDeclsMargin, span);
}
visit(VisitorBase visitor) => visitor.visitPageDirective(this);
- bool get hasIdent => _ident != null && _ident.length > 0;
- bool get hasPseudoPage => _pseudoPage != null && _pseudoPage.length > 0;
+ bool get hasIdent => _ident != null && _ident.isNotEmpty;
+ bool get hasPseudoPage => _pseudoPage != null && _pseudoPage.isNotEmpty;
}
class CharsetDirective extends Directive {
final String charEncoding;
CharsetDirective(this.charEncoding, SourceSpan span) : super(span);
- CharsetDirective clone() => new CharsetDirective(charEncoding, span);
+ CharsetDirective clone() => CharsetDirective(charEncoding, span);
visit(VisitorBase visitor) => visitor.visitCharsetDirective(this);
}
@@ -747,7 +746,7 @@
: super(span);
KeyFrameBlock clone() =>
- new KeyFrameBlock(_blockSelectors.clone(), _declarations.clone(), span);
+ KeyFrameBlock(_blockSelectors.clone(), _declarations.clone(), span);
visit(VisitorBase visitor) => visitor.visitKeyFrameBlock(this);
}
@@ -756,8 +755,7 @@
FontFaceDirective(this._declarations, SourceSpan span) : super(span);
- FontFaceDirective clone() =>
- new FontFaceDirective(_declarations.clone(), span);
+ FontFaceDirective clone() => FontFaceDirective(_declarations.clone(), span);
visit(VisitorBase visitor) => visitor.visitFontFaceDirective(this);
}
@@ -776,7 +774,7 @@
for (var rule in rules) {
cloneRules.add(rule.clone());
}
- return new StyletDirective(dartClassName, cloneRules, span);
+ return StyletDirective(dartClassName, cloneRules, span);
}
visit(VisitorBase visitor) => visitor.visitStyletDirective(this);
@@ -791,11 +789,11 @@
NamespaceDirective(this._prefix, this._uri, SourceSpan span) : super(span);
- NamespaceDirective clone() => new NamespaceDirective(_prefix, _uri, span);
+ NamespaceDirective clone() => NamespaceDirective(_prefix, _uri, span);
visit(VisitorBase visitor) => visitor.visitNamespaceDirective(this);
- String get prefix => _prefix.length > 0 ? '$_prefix ' : '';
+ String get prefix => _prefix.isNotEmpty ? '$_prefix ' : '';
}
/// To support Less syntax @name: expression
@@ -804,8 +802,7 @@
VarDefinitionDirective(this.def, SourceSpan span) : super(span);
- VarDefinitionDirective clone() =>
- new VarDefinitionDirective(def.clone(), span);
+ VarDefinitionDirective clone() => VarDefinitionDirective(def.clone(), span);
visit(VisitorBase visitor) => visitor.visitVarDefinitionDirective(this);
}
@@ -823,7 +820,7 @@
for (var definedArg in definedArgs) {
cloneDefinedArgs.add(definedArg.clone());
}
- return new MixinDefinition(name, cloneDefinedArgs, varArgs, span);
+ return MixinDefinition(name, cloneDefinedArgs, varArgs, span);
}
visit(VisitorBase visitor) => visitor.visitMixinDefinition(this);
@@ -846,7 +843,7 @@
for (var ruleset in rulesets) {
clonedRulesets.add(ruleset.clone());
}
- return new MixinRulesetDirective(
+ return MixinRulesetDirective(
name, clonedArgs, varArgs, clonedRulesets, span);
}
@@ -865,7 +862,7 @@
for (var arg in definedArgs) {
clonedArgs.add(arg.clone());
}
- return new MixinDeclarationDirective(
+ return MixinDeclarationDirective(
name, clonedArgs, varArgs, declarations.clone(), span);
}
@@ -884,7 +881,7 @@
for (var arg in args) {
cloneArgs.add(arg.map((term) => term.clone()).toList());
}
- return new IncludeDirective(name, cloneArgs, span);
+ return IncludeDirective(name, cloneArgs, span);
}
visit(VisitorBase visitor) => visitor.visitIncludeDirective(this);
@@ -915,7 +912,7 @@
final bool isIE7;
Declaration(this._property, this._expression, this.dartStyle, SourceSpan span,
- {bool important: false, bool ie7: false})
+ {bool important = false, bool ie7 = false})
: this.important = important,
this.isIE7 = ie7,
super(span);
@@ -926,7 +923,7 @@
bool get hasDartStyle => dartStyle != null;
Declaration clone() =>
- new Declaration(_property.clone(), _expression.clone(), dartStyle, span,
+ Declaration(_property.clone(), _expression.clone(), dartStyle, span,
important: important);
visit(VisitorBase visitor) => visitor.visitDeclaration(this);
@@ -946,7 +943,7 @@
String get definedName => _property.name;
- VarDefinition clone() => new VarDefinition(
+ VarDefinition clone() => VarDefinition(
_property.clone(), expression != null ? expression.clone() : null, span);
visit(VisitorBase visitor) => visitor.visitVarDefinition(this);
@@ -965,7 +962,7 @@
: super(null, null, null, span);
IncludeMixinAtDeclaration clone() =>
- new IncludeMixinAtDeclaration(include.clone(), span);
+ IncludeMixinAtDeclaration(include.clone(), span);
visit(VisitorBase visitor) => visitor.visitIncludeMixinAtDeclaration(this);
}
@@ -978,7 +975,7 @@
ExtendDeclaration clone() {
var newSelector = selectors.map((s) => s.clone()).toList();
- return new ExtendDeclaration(newSelector, span);
+ return ExtendDeclaration(newSelector, span);
}
visit(VisitorBase visitor) => visitor.visitExtendDeclaration(this);
@@ -992,7 +989,7 @@
DeclarationGroup clone() {
var clonedDecls = declarations.map((d) => d.clone()).toList();
- return new DeclarationGroup(clonedDecls, span);
+ return DeclarationGroup(clonedDecls, span);
}
visit(VisitorBase visitor) => visitor.visitDeclarationGroup(this);
@@ -1004,7 +1001,7 @@
MarginGroup(this.margin_sym, List<TreeNode> decls, SourceSpan span)
: super(decls, span);
MarginGroup clone() =>
- new MarginGroup(margin_sym, super.clone().declarations, span);
+ MarginGroup(margin_sym, super.clone().declarations, span);
visit(VisitorBase visitor) => visitor.visitMarginGroup(this);
}
@@ -1019,7 +1016,7 @@
for (var expr in defaultValues) {
clonedValues.add(expr.clone());
}
- return new VarUsage(name, clonedValues, span);
+ return VarUsage(name, clonedValues, span);
}
visit(VisitorBase visitor) => visitor.visitVarUsage(this);
@@ -1027,25 +1024,25 @@
class OperatorSlash extends Expression {
OperatorSlash(SourceSpan span) : super(span);
- OperatorSlash clone() => new OperatorSlash(span);
+ OperatorSlash clone() => OperatorSlash(span);
visit(VisitorBase visitor) => visitor.visitOperatorSlash(this);
}
class OperatorComma extends Expression {
OperatorComma(SourceSpan span) : super(span);
- OperatorComma clone() => new OperatorComma(span);
+ OperatorComma clone() => OperatorComma(span);
visit(VisitorBase visitor) => visitor.visitOperatorComma(this);
}
class OperatorPlus extends Expression {
OperatorPlus(SourceSpan span) : super(span);
- OperatorPlus clone() => new OperatorPlus(span);
+ OperatorPlus clone() => OperatorPlus(span);
visit(VisitorBase visitor) => visitor.visitOperatorPlus(this);
}
class OperatorMinus extends Expression {
OperatorMinus(SourceSpan span) : super(span);
- OperatorMinus clone() => new OperatorMinus(span);
+ OperatorMinus clone() => OperatorMinus(span);
visit(VisitorBase visitor) => visitor.visitOperatorMinus(this);
}
@@ -1057,7 +1054,7 @@
bool get hasSecond => second != null;
- UnicodeRangeTerm clone() => new UnicodeRangeTerm(first, second, span);
+ UnicodeRangeTerm clone() => UnicodeRangeTerm(first, second, span);
visit(VisitorBase visitor) => visitor.visitUnicodeRangeTerm(this);
}
@@ -1071,14 +1068,14 @@
LiteralTerm(this.value, this.text, SourceSpan span) : super(span);
- LiteralTerm clone() => new LiteralTerm(value, text, span);
+ LiteralTerm clone() => LiteralTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitLiteralTerm(this);
}
class NumberTerm extends LiteralTerm {
NumberTerm(value, String t, SourceSpan span) : super(value, t, span);
- NumberTerm clone() => new NumberTerm(value, text, span);
+ NumberTerm clone() => NumberTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitNumberTerm(this);
}
@@ -1087,7 +1084,7 @@
UnitTerm(value, String t, SourceSpan span, this.unit) : super(value, t, span);
- UnitTerm clone() => new UnitTerm(value, text, span, unit);
+ UnitTerm clone() => UnitTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitUnitTerm(this);
@@ -1107,25 +1104,25 @@
this.unit == TokenKind.UNIT_LENGTH_PT ||
this.unit == TokenKind.UNIT_LENGTH_PC);
}
- LengthTerm clone() => new LengthTerm(value, text, span, unit);
+ LengthTerm clone() => LengthTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitLengthTerm(this);
}
class PercentageTerm extends LiteralTerm {
PercentageTerm(value, String t, SourceSpan span) : super(value, t, span);
- PercentageTerm clone() => new PercentageTerm(value, text, span);
+ PercentageTerm clone() => PercentageTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitPercentageTerm(this);
}
class EmTerm extends LiteralTerm {
EmTerm(value, String t, SourceSpan span) : super(value, t, span);
- EmTerm clone() => new EmTerm(value, text, span);
+ EmTerm clone() => EmTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitEmTerm(this);
}
class ExTerm extends LiteralTerm {
ExTerm(value, String t, SourceSpan span) : super(value, t, span);
- ExTerm clone() => new ExTerm(value, text, span);
+ ExTerm clone() => ExTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitExTerm(this);
}
@@ -1139,7 +1136,7 @@
this.unit == TokenKind.UNIT_ANGLE_TURN);
}
- AngleTerm clone() => new AngleTerm(value, text, span, unit);
+ AngleTerm clone() => AngleTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitAngleTerm(this);
}
@@ -1152,7 +1149,7 @@
this.unit == TokenKind.UNIT_TIME_S);
}
- TimeTerm clone() => new TimeTerm(value, text, span, unit);
+ TimeTerm clone() => TimeTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitTimeTerm(this);
}
@@ -1163,21 +1160,21 @@
assert(unit == TokenKind.UNIT_FREQ_HZ || unit == TokenKind.UNIT_FREQ_KHZ);
}
- FreqTerm clone() => new FreqTerm(value, text, span, unit);
+ FreqTerm clone() => FreqTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitFreqTerm(this);
}
class FractionTerm extends LiteralTerm {
FractionTerm(var value, String t, SourceSpan span) : super(value, t, span);
- FractionTerm clone() => new FractionTerm(value, text, span);
+ FractionTerm clone() => FractionTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitFractionTerm(this);
}
class UriTerm extends LiteralTerm {
UriTerm(String value, SourceSpan span) : super(value, value, span);
- UriTerm clone() => new UriTerm(value, span);
+ UriTerm clone() => UriTerm(value, span);
visit(VisitorBase visitor) => visitor.visitUriTerm(this);
}
@@ -1190,7 +1187,7 @@
unit == TokenKind.UNIT_RESOLUTION_DPPX);
}
- ResolutionTerm clone() => new ResolutionTerm(value, text, span, unit);
+ ResolutionTerm clone() => ResolutionTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitResolutionTerm(this);
}
@@ -1201,7 +1198,7 @@
assert(unit == TokenKind.UNIT_CH);
}
- ChTerm clone() => new ChTerm(value, text, span, unit);
+ ChTerm clone() => ChTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitChTerm(this);
}
@@ -1212,7 +1209,7 @@
assert(unit == TokenKind.UNIT_REM);
}
- RemTerm clone() => new RemTerm(value, text, span, unit);
+ RemTerm clone() => RemTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitRemTerm(this);
}
@@ -1226,7 +1223,7 @@
unit == TokenKind.UNIT_VIEWPORT_VMAX);
}
- ViewportTerm clone() => new ViewportTerm(value, text, span, unit);
+ ViewportTerm clone() => ViewportTerm(value, text, span, unit);
visit(VisitorBase visitor) => visitor.visitViewportTerm(this);
}
@@ -1236,7 +1233,7 @@
class HexColorTerm extends LiteralTerm {
HexColorTerm(var value, String t, SourceSpan span) : super(value, t, span);
- HexColorTerm clone() => new HexColorTerm(value, text, span);
+ HexColorTerm clone() => HexColorTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitHexColorTerm(this);
}
@@ -1246,7 +1243,7 @@
FunctionTerm(var value, String t, this._params, SourceSpan span)
: super(value, t, span);
- FunctionTerm clone() => new FunctionTerm(value, text, _params.clone(), span);
+ FunctionTerm clone() => FunctionTerm(value, text, _params.clone(), span);
visit(VisitorBase visitor) => visitor.visitFunctionTerm(this);
}
@@ -1255,7 +1252,7 @@
/// browsers.
class IE8Term extends LiteralTerm {
IE8Term(SourceSpan span) : super('\\9', '\\9', span);
- IE8Term clone() => new IE8Term(span);
+ IE8Term clone() => IE8Term(span);
visit(VisitorBase visitor) => visitor.visitIE8Term(this);
}
@@ -1270,14 +1267,14 @@
_terms.add(term);
}
- GroupTerm clone() => new GroupTerm(span);
+ GroupTerm clone() => GroupTerm(span);
visit(VisitorBase visitor) => visitor.visitGroupTerm(this);
}
class ItemTerm extends NumberTerm {
ItemTerm(dynamic value, String t, SourceSpan span) : super(value, t, span);
- ItemTerm clone() => new ItemTerm(value, text, span);
+ ItemTerm clone() => ItemTerm(value, text, span);
visit(VisitorBase visitor) => visitor.visitItemTerm(this);
}
@@ -1291,7 +1288,7 @@
}
Expressions clone() {
- var clonedExprs = new Expressions(span);
+ var clonedExprs = Expressions(span);
for (var expr in expressions) {
clonedExprs.add(expr.clone());
}
@@ -1308,8 +1305,7 @@
BinaryExpression(this.op, this.x, this.y, SourceSpan span) : super(span);
- BinaryExpression clone() =>
- new BinaryExpression(op, x.clone(), y.clone(), span);
+ BinaryExpression clone() => BinaryExpression(op, x.clone(), y.clone(), span);
visit(VisitorBase visitor) => visitor.visitBinaryExpression(this);
}
@@ -1319,7 +1315,7 @@
UnaryExpression(this.op, this.self, SourceSpan span) : super(span);
- UnaryExpression clone() => new UnaryExpression(op, self.clone(), span);
+ UnaryExpression clone() => UnaryExpression(op, self.clone(), span);
visit(VisitorBase visitor) => visitor.visitUnaryExpression(this);
}
@@ -1369,7 +1365,7 @@
String style,
String variant,
LineHeight lineHeight})
- : font = new Font(
+ : font = Font(
size: size is LengthTerm ? size.value : size as num,
family: family,
weight: weight,
@@ -1380,21 +1376,21 @@
FontExpression merged(DartStyleExpression newFontExpr) {
if (newFontExpr is FontExpression && this.isFont && newFontExpr.isFont) {
- return new FontExpression.merge(this, newFontExpr);
+ return FontExpression.merge(this, newFontExpr);
}
return null;
}
/// Merge the two FontExpression and return the result.
factory FontExpression.merge(FontExpression x, FontExpression y) {
- return new FontExpression._merge(x, y, y.span);
+ return FontExpression._merge(x, y, y.span);
}
FontExpression._merge(FontExpression x, FontExpression y, SourceSpan span)
- : font = new Font.merge(x.font, y.font),
+ : font = Font.merge(x.font, y.font),
super(DartStyleExpression.fontStyle, span);
- FontExpression clone() => new FontExpression(span,
+ FontExpression clone() => FontExpression(span,
size: font.size,
family: font.family,
weight: font.weight,
@@ -1431,7 +1427,7 @@
/// Margin expression ripped apart.
MarginExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.marginStyle, span,
- new BoxEdge(left, top, right, bottom));
+ BoxEdge(left, top, right, bottom));
MarginExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.marginStyle, span, box);
@@ -1440,7 +1436,7 @@
if (newMarginExpr is MarginExpression &&
this.isMargin &&
newMarginExpr.isMargin) {
- return new MarginExpression.merge(this, newMarginExpr);
+ return MarginExpression.merge(this, newMarginExpr);
}
return null;
@@ -1448,14 +1444,14 @@
/// Merge the two MarginExpressions and return the result.
factory MarginExpression.merge(MarginExpression x, MarginExpression y) {
- return new MarginExpression._merge(x, y, y.span);
+ return MarginExpression._merge(x, y, y.span);
}
MarginExpression._merge(
MarginExpression x, MarginExpression y, SourceSpan span)
- : super(x._styleType, span, new BoxEdge.merge(x.box, y.box));
+ : super(x._styleType, span, BoxEdge.merge(x.box, y.box));
- MarginExpression clone() => new MarginExpression(span,
+ MarginExpression clone() => MarginExpression(span,
top: box.top, right: box.right, bottom: box.bottom, left: box.left);
visit(VisitorBase visitor) => visitor.visitMarginExpression(this);
@@ -1465,7 +1461,7 @@
/// Border expression ripped apart.
BorderExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.borderStyle, span,
- new BoxEdge(left, top, right, bottom));
+ BoxEdge(left, top, right, bottom));
BorderExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.borderStyle, span, box);
@@ -1474,7 +1470,7 @@
if (newBorderExpr is BorderExpression &&
this.isBorder &&
newBorderExpr.isBorder) {
- return new BorderExpression.merge(this, newBorderExpr);
+ return BorderExpression.merge(this, newBorderExpr);
}
return null;
@@ -1482,15 +1478,15 @@
/// Merge the two BorderExpression and return the result.
factory BorderExpression.merge(BorderExpression x, BorderExpression y) {
- return new BorderExpression._merge(x, y, y.span);
+ return BorderExpression._merge(x, y, y.span);
}
BorderExpression._merge(
BorderExpression x, BorderExpression y, SourceSpan span)
- : super(DartStyleExpression.borderStyle, span,
- new BoxEdge.merge(x.box, y.box));
+ : super(
+ DartStyleExpression.borderStyle, span, BoxEdge.merge(x.box, y.box));
- BorderExpression clone() => new BorderExpression(span,
+ BorderExpression clone() => BorderExpression(span,
top: box.top, right: box.right, bottom: box.bottom, left: box.left);
visit(VisitorBase visitor) => visitor.visitBorderExpression(this);
@@ -1512,7 +1508,7 @@
return null;
}
- HeightExpression clone() => new HeightExpression(span, height);
+ HeightExpression clone() => HeightExpression(span, height);
visit(VisitorBase visitor) => visitor.visitHeightExpression(this);
}
@@ -1532,7 +1528,7 @@
return null;
}
- WidthExpression clone() => new WidthExpression(span, width);
+ WidthExpression clone() => WidthExpression(span, width);
visit(VisitorBase visitor) => visitor.visitWidthExpression(this);
}
@@ -1540,7 +1536,7 @@
/// Padding expression ripped apart.
PaddingExpression(SourceSpan span, {num top, num right, num bottom, num left})
: super(DartStyleExpression.paddingStyle, span,
- new BoxEdge(left, top, right, bottom));
+ BoxEdge(left, top, right, bottom));
PaddingExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.paddingStyle, span, box);
@@ -1549,7 +1545,7 @@
if (newPaddingExpr is PaddingExpression &&
this.isPadding &&
newPaddingExpr.isPadding) {
- return new PaddingExpression.merge(this, newPaddingExpr);
+ return PaddingExpression.merge(this, newPaddingExpr);
}
return null;
@@ -1557,15 +1553,15 @@
/// Merge the two PaddingExpression and return the result.
factory PaddingExpression.merge(PaddingExpression x, PaddingExpression y) {
- return new PaddingExpression._merge(x, y, y.span);
+ return PaddingExpression._merge(x, y, y.span);
}
PaddingExpression._merge(
PaddingExpression x, PaddingExpression y, SourceSpan span)
: super(DartStyleExpression.paddingStyle, span,
- new BoxEdge.merge(x.box, y.box));
+ BoxEdge.merge(x.box, y.box));
- PaddingExpression clone() => new PaddingExpression(span,
+ PaddingExpression clone() => 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 f662a7c..8338ad3 100644
--- a/lib/src/tree_base.dart
+++ b/lib/src/tree_base.dart
@@ -18,8 +18,8 @@
/// A multiline string showing the node and its children.
String toDebugString() {
- var to = new TreeOutput();
- var tp = new _TreePrinter(to, true);
+ var to = TreeOutput();
+ var tp = _TreePrinter(to, true);
this.visit(tp);
return to.buf.toString();
}
@@ -33,7 +33,7 @@
/// Simple class to provide a textual dump of trees for debugging.
class TreeOutput {
int depth = 0;
- final StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = StringBuffer();
VisitorBase printer;
void write(String s) {
diff --git a/lib/src/tree_printer.dart b/lib/src/tree_printer.dart
index 6aad40c..2371015 100644
--- a/lib/src/tree_printer.dart
+++ b/lib/src/tree_printer.dart
@@ -8,8 +8,8 @@
/// Helper function to dump the CSS AST.
String treeToDebugString(StyleSheet styleSheet, [bool useSpan = false]) {
- var to = new TreeOutput();
- new _TreePrinter(to, useSpan)..visitTree(styleSheet);
+ var to = TreeOutput();
+ _TreePrinter(to, useSpan)..visitTree(styleSheet);
return to.toString();
}
diff --git a/lib/src/validate.dart b/lib/src/validate.dart
index 72f14e0..6e903b6 100644
--- a/lib/src/validate.dart
+++ b/lib/src/validate.dart
@@ -22,7 +22,7 @@
(selector.isCombinatorNone && matches == 0)) {
if (matches < 0) {
String tooMany = selector.simpleSelector.toString();
- throw new CssSelectorException(
+ throw CssSelectorException(
'Can not mix Id selector with class selector(s). Id '
'selector must be singleton too many starting at $tooMany');
}
@@ -30,7 +30,7 @@
return matches + 1;
} else {
String error = selector.toString();
- throw new CssSelectorException(
+ throw CssSelectorException(
'Selectors can not have combinators (>, +, or ~) before $error');
}
}
@@ -41,11 +41,11 @@
return -1;
} else if (selector.isCombinatorDescendant) {
String tooMany = selector.simpleSelector.toString();
- throw new CssSelectorException(
+ throw CssSelectorException(
'Use of Id selector must be singleton starting at $tooMany');
} else {
String error = selector.simpleSelector.toString();
- throw new CssSelectorException(
+ throw CssSelectorException(
'Selectors can not have combinators (>, +, or ~) before $error');
}
}
@@ -105,13 +105,12 @@
}
} else {
String badSelector = simpleSelector.toString();
- throw new CssSelectorException(
- 'Invalid template selector $badSelector');
+ throw CssSelectorException('Invalid template selector $badSelector');
}
if (!found) {
String unknownName = simpleSelector.toString();
- throw new CssSelectorException('Unknown selector name $unknownName');
+ throw CssSelectorException('Unknown selector name $unknownName');
}
}
}
diff --git a/lib/visitor.dart b/lib/visitor.dart
index e2f1f04..7b411cd 100644
--- a/lib/visitor.dart
+++ b/lib/visitor.dart
@@ -436,12 +436,12 @@
visitBinaryExpression(BinaryExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitUnaryExpression(UnaryExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitIdentifier(Identifier node) {}
@@ -456,36 +456,36 @@
visitFontExpression(FontExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitBoxExpression(BoxExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitMarginExpression(MarginExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitBorderExpression(BorderExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitHeightExpression(HeightExpression node) {
// TODO(terry): TB
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitPaddingExpression(PaddingExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
visitWidthExpression(WidthExpression node) {
// TODO(terry): TBD
- throw new UnimplementedError();
+ throw UnimplementedError();
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 4f6a9e2..c928dbd 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -6,7 +6,7 @@
homepage: https://github.com/dart-lang/csslib
environment:
- sdk: '>=2.0.0-dev.17.0 <3.0.0'
+ sdk: '>=2.0.0 <3.0.0'
dependencies:
args: ^1.4.3
@@ -15,4 +15,5 @@
source_span: ^1.4.0
dev_dependencies:
+ pedantic: ^1.0.0
test: ^1.2.0
diff --git a/test/extend_test.dart b/test/extend_test.dart
index 7df68c5..78c2994 100644
--- a/test/extend_test.dart
+++ b/test/extend_test.dart
@@ -199,13 +199,13 @@
}
''',
'.btn > .btn, '
- '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'
- '}');
+ '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'
+ '}');
// TODO(terry): Optimize merge selectors would be:
//
@@ -226,13 +226,13 @@
}
''',
'.btn + .btn, '
- '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}');
+ '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}');
}
main() {
diff --git a/test/samples_test.dart b/test/samples_test.dart
index 4607a05..4059543 100644
--- a/test/samples_test.dart
+++ b/test/samples_test.dart
@@ -7,7 +7,7 @@
import 'package:test/test.dart';
import 'package:csslib/parser.dart';
-const testOptions = const PreprocessorOptions(
+const testOptions = PreprocessorOptions(
useColors: false,
checked: false,
warningsAsErrors: true,
@@ -24,7 +24,7 @@
main() {
final libraryUri = currentMirrorSystem().findLibrary(#samples_test).uri;
- final cssDir = new Directory.fromUri(libraryUri.resolve('examples'));
+ final cssDir = Directory.fromUri(libraryUri.resolve('examples'));
for (var element in cssDir.listSync())
if (element is File && element.uri.pathSegments.last.endsWith('.css')) {
test(element.uri.pathSegments.last, () => testCSSFile(element));
diff --git a/test/testing.dart b/test/testing.dart
index 33dbe7c..28b707d 100644
--- a/test/testing.dart
+++ b/test/testing.dart
@@ -12,16 +12,16 @@
export 'package:csslib/src/options.dart';
-const simpleOptionsWithCheckedAndWarningsAsErrors = const PreprocessorOptions(
+const simpleOptionsWithCheckedAndWarningsAsErrors = PreprocessorOptions(
useColors: false,
checked: true,
warningsAsErrors: true,
inputFile: 'memory');
const simpleOptions =
- const PreprocessorOptions(useColors: false, inputFile: 'memory');
+ PreprocessorOptions(useColors: false, inputFile: 'memory');
-const options = const PreprocessorOptions(
+const options = PreprocessorOptions(
useColors: false, warningsAsErrors: true, inputFile: 'memory');
/// Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
@@ -40,8 +40,8 @@
StyleSheet compileCss(String cssInput,
{List<Message> errors,
PreprocessorOptions opts,
- bool polyfill: false,
- List<StyleSheet> includes: null}) =>
+ bool polyfill = false,
+ List<StyleSheet> includes}) =>
compile(cssInput,
errors: errors,
options:
@@ -54,10 +54,10 @@
compileCss(input, errors: errors, polyfill: true, opts: opts);
/// CSS emitter walks the style sheet tree and emits readable CSS.
-final _emitCss = new CssPrinter();
+final _emitCss = CssPrinter();
/// Simple Visitor does nothing but walk tree.
-final _cssVisitor = new Visitor();
+final _cssVisitor = Visitor();
/// Pretty printer for CSS.
String prettyPrint(StyleSheet ss) {
diff --git a/test/visitor_test.dart b/test/visitor_test.dart
index 02784c4..b82ac6b 100644
--- a/test/visitor_test.dart
+++ b/test/visitor_test.dart
@@ -12,7 +12,7 @@
class ClassVisitor extends Visitor {
final List expectedClasses;
- final Set<String> foundClasses = new Set();
+ final Set<String> foundClasses = Set();
ClassVisitor(this.expectedClasses);
@@ -42,7 +42,7 @@
expect(s != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- var clsVisits = new ClassVisitor(['foobar'])..visitTree(s);
+ var clsVisits = ClassVisitor(['foobar'])..visitTree(s);
expect(clsVisits.matches, true);
in1 = '''
@@ -56,8 +56,7 @@
expect(s != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- clsVisits = new ClassVisitor(['foobar1', 'xyzzy', 'foo', 'hello'])
- ..visitTree(s);
+ clsVisits = ClassVisitor(['foobar1', 'xyzzy', 'foo', 'hello'])..visitTree(s);
expect(clsVisits.matches, true);
expect(prettyPrint(s), r'''
@@ -82,7 +81,7 @@
}
String polyfillPrint(String prefix, StyleSheet ss) =>
- (new PolyfillEmitter(prefix)..visitTree(ss, pretty: true)).toString();
+ (PolyfillEmitter(prefix)..visitTree(ss, pretty: true)).toString();
void testPolyFill() {
var errors = <Message>[];