Remove deprecated lints, enable/fix all dartfmt --fix lints (dart-lang/markdown#240)
diff --git a/pkgs/markdown/analysis_options.yaml b/pkgs/markdown/analysis_options.yaml index e2b8e87..f246f8c 100644 --- a/pkgs/markdown/analysis_options.yaml +++ b/pkgs/markdown/analysis_options.yaml
@@ -36,13 +36,15 @@ - overridden_fields - package_api_docs - prefer_final_fields + - prefer_generic_function_type_aliases - prefer_is_not_empty #- prefer_single_quotes - slash_for_doc_comments - - super_goes_last - test_types_in_equals - throw_in_finally - type_init_formals - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_new - unrelated_type_equality_checks - valid_regexps
diff --git a/pkgs/markdown/benchmark/benchmark.dart b/pkgs/markdown/benchmark/benchmark.dart index ea5fda2..b6d480c 100644 --- a/pkgs/markdown/benchmark/benchmark.dart +++ b/pkgs/markdown/benchmark/benchmark.dart
@@ -20,7 +20,7 @@ // Run the benchmark several times. This ensures the VM is warmed up and lets // us see how much variance there is. for (var i = 0; i <= numTrials; i++) { - var start = new DateTime.now(); + var start = DateTime.now(); // For a single benchmark, convert the source multiple times. var result; @@ -29,7 +29,7 @@ } var elapsed = - new DateTime.now().difference(start).inMilliseconds / runsPerTrial; + DateTime.now().difference(start).inMilliseconds / runsPerTrial; // Keep track of the best run so far. if (elapsed >= best) continue; @@ -53,7 +53,7 @@ String loadFile(String name) { var path = p.join(p.dirname(p.fromUri(Platform.script)), name); - return new File(path).readAsStringSync(); + return File(path).readAsStringSync(); } void printResult(String label, double time) {
diff --git a/pkgs/markdown/bin/markdown.dart b/pkgs/markdown/bin/markdown.dart index 943d28f..951b106 100644 --- a/pkgs/markdown/bin/markdown.dart +++ b/pkgs/markdown/bin/markdown.dart
@@ -12,7 +12,7 @@ }; Future main(List<String> args) async { - var parser = new ArgParser() + var parser = ArgParser() ..addFlag('help', negatable: false, help: 'Print help text and exit') ..addFlag('version', negatable: false, help: 'Print version and exit') ..addOption('extension-set', @@ -47,13 +47,13 @@ if (results.rest.length == 1) { // Read argument as a file path. - var input = new File(results.rest.first).readAsStringSync(); + var input = File(results.rest.first).readAsStringSync(); print(markdownToHtml(input, extensionSet: extensionSet)); return; } // Read from stdin. - var buffer = new StringBuffer(); + var buffer = StringBuffer(); String line; while ((line = stdin.readLineSync()) != null) { buffer.writeln(line);
diff --git a/pkgs/markdown/example/app.dart b/pkgs/markdown/example/app.dart index 9f7c164..7e7cf91 100644 --- a/pkgs/markdown/example/app.dart +++ b/pkgs/markdown/example/app.dart
@@ -8,8 +8,8 @@ final htmlDiv = querySelector('#html') as DivElement; final versionSpan = querySelector('.version') as SpanElement; -final nullSanitizer = new NullTreeSanitizer(); -const typing = const Duration(milliseconds: 150); +final nullSanitizer = NullTreeSanitizer(); +const typing = Duration(milliseconds: 150); final introText = r'''Markdown is the **best**! * It has lists. @@ -89,10 +89,10 @@ markdownInput.focus(); _renderMarkdown(); pos++; - timer = new Timer(typing, addCharacter); + timer = Timer(typing, addCharacter); } - timer = new Timer(typing, addCharacter); + timer = Timer(typing, addCharacter); } void _switchFlavor(Event e) {
diff --git a/pkgs/markdown/lib/src/ast.dart b/pkgs/markdown/lib/src/ast.dart index 4d7af15..5dcb848 100644 --- a/pkgs/markdown/lib/src/ast.dart +++ b/pkgs/markdown/lib/src/ast.dart
@@ -2,7 +2,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. -typedef Node Resolver(String name, [String title]); +typedef Resolver = Node Function(String name, [String title]); /// Base class for any AST item. /// @@ -35,7 +35,7 @@ /// Instantiates a [tag] Element with a single Text child. Element.text(this.tag, String text) - : children = [new Text(text)], + : children = [Text(text)], attributes = {}; /// Whether this element is self-closing.
diff --git a/pkgs/markdown/lib/src/block_parser.dart b/pkgs/markdown/lib/src/block_parser.dart index a121927..bbabd8c 100644 --- a/pkgs/markdown/lib/src/block_parser.dart +++ b/pkgs/markdown/lib/src/block_parser.dart
@@ -7,33 +7,33 @@ import 'util.dart'; /// The line contains only whitespace or is empty. -final _emptyPattern = new RegExp(r'^(?:[ \t]*)$'); +final _emptyPattern = RegExp(r'^(?:[ \t]*)$'); /// A series of `=` or `-` (on the next line) define setext-style headers. -final _setextPattern = new RegExp(r'^[ ]{0,3}(=+|-+)\s*$'); +final _setextPattern = RegExp(r'^[ ]{0,3}(=+|-+)\s*$'); /// Leading (and trailing) `#` define atx-style headers. /// /// Starts with 1-6 unescaped `#` characters which must not be followed by a /// non-space character. Line may end with any number of `#` characters,. -final _headerPattern = new RegExp(r'^ {0,3}(#{1,6})[ \x09\x0b\x0c](.*?)#*$'); +final _headerPattern = RegExp(r'^ {0,3}(#{1,6})[ \x09\x0b\x0c](.*?)#*$'); /// The line starts with `>` with one optional space after. -final _blockquotePattern = new RegExp(r'^[ ]{0,3}>[ ]?(.*)$'); +final _blockquotePattern = RegExp(r'^[ ]{0,3}>[ ]?(.*)$'); /// A line indented four spaces. Used for code blocks and lists. -final _indentPattern = new RegExp(r'^(?: | {0,3}\t)(.*)$'); +final _indentPattern = RegExp(r'^(?: | {0,3}\t)(.*)$'); /// Fenced code block. -final _codePattern = new RegExp(r'^[ ]{0,3}(`{3,}|~{3,})(.*)$'); +final _codePattern = RegExp(r'^[ ]{0,3}(`{3,}|~{3,})(.*)$'); /// Three or more hyphens, asterisks or underscores by themselves. Note that /// a line like `----` is valid as both HR and SETEXT. In case of a tie, /// SETEXT should win. -final _hrPattern = new RegExp(r'^ {0,3}([-*_])[ \t]*\1[ \t]*\1(?:\1|[ \t])*$'); +final _hrPattern = RegExp(r'^ {0,3}([-*_])[ \t]*\1[ \t]*\1(?:\1|[ \t])*$'); /// One or more whitespace, for compressing. -final _oneOrMoreWhitespacePattern = new RegExp('[ \n\r\t]+'); +final _oneOrMoreWhitespacePattern = RegExp('[ \n\r\t]+'); /// A line starting with one of these markers: `-`, `*`, `+`. May have up to /// three leading spaces before the marker and any number of spaces or tabs @@ -42,16 +42,15 @@ /// Contains a dummy group at [2], so that the groups in [_ulPattern] and /// [_olPattern] match up; in both, [2] is the length of the number that begins /// the list marker. -final _ulPattern = new RegExp(r'^([ ]{0,3})()([*+-])(([ \t])([ \t]*)(.*))?$'); +final _ulPattern = RegExp(r'^([ ]{0,3})()([*+-])(([ \t])([ \t]*)(.*))?$'); /// A line starting with a number like `123.`. May have up to three leading /// spaces before the marker and any number of spaces or tabs after. final _olPattern = - new RegExp(r'^([ ]{0,3})(\d{1,9})([\.)])(([ \t])([ \t]*)(.*))?$'); + RegExp(r'^([ ]{0,3})(\d{1,9})([\.)])(([ \t])([ \t]*)(.*))?$'); /// A line of hyphens separated by at least one pipe. -final _tablePattern = - new RegExp(r'^[ ]{0,3}\|?( *:?\-+:? *\|)+( *:?\-+:? *)?$'); +final _tablePattern = RegExp(r'^[ ]{0,3}\|?( *:?\-+:? *\|)+( *:?\-+:? *)?$'); /// Maintains the internal state needed to parse a series of lines into blocks /// of Markdown suitable for further inline parsing. @@ -78,13 +77,13 @@ final List<BlockSyntax> standardBlockSyntaxes = [ const EmptyBlockSyntax(), const BlockTagBlockHtmlSyntax(), - new LongBlockHtmlSyntax(r'^ {0,3}<pre(?:\s|>|$)', '</pre>'), - new LongBlockHtmlSyntax(r'^ {0,3}<script(?:\s|>|$)', '</script>'), - new LongBlockHtmlSyntax(r'^ {0,3}<style(?:\s|>|$)', '</style>'), - new LongBlockHtmlSyntax('^ {0,3}<!--', '-->'), - new LongBlockHtmlSyntax('^ {0,3}<\\?', '\\?>'), - new LongBlockHtmlSyntax('^ {0,3}<![A-Z]', '>'), - new LongBlockHtmlSyntax('^ {0,3}<!\\[CDATA\\[', '\\]\\]>'), + LongBlockHtmlSyntax(r'^ {0,3}<pre(?:\s|>|$)', '</pre>'), + LongBlockHtmlSyntax(r'^ {0,3}<script(?:\s|>|$)', '</script>'), + LongBlockHtmlSyntax(r'^ {0,3}<style(?:\s|>|$)', '</style>'), + LongBlockHtmlSyntax('^ {0,3}<!--', '-->'), + LongBlockHtmlSyntax('^ {0,3}<\\?', '\\?>'), + LongBlockHtmlSyntax('^ {0,3}<![A-Z]', '>'), + LongBlockHtmlSyntax('^ {0,3}<!\\[CDATA\\[', '\\]\\]>'), const OtherTagBlockHtmlSyntax(), const SetextHeaderSyntax(), const HeaderSyntax(), @@ -119,7 +118,7 @@ /// `peek(1)` is equivalent to [next]. String peek(int linesAhead) { if (linesAhead < 0) { - throw new ArgumentError('Invalid linesAhead: $linesAhead; must be >= 0.'); + throw ArgumentError('Invalid linesAhead: $linesAhead; must be >= 0.'); } // Don't read past the end. if (_pos >= lines.length - linesAhead) return null; @@ -199,8 +198,8 @@ element.children.first.textContent .toLowerCase() .trim() - .replaceAll(new RegExp(r'[^a-z0-9 _-]'), '') - .replaceAll(new RegExp(r'\s'), '-'); + .replaceAll(RegExp(r'[^a-z0-9 _-]'), '') + .replaceAll(RegExp(r'\s'), '-'); } class EmptyBlockSyntax extends BlockSyntax { @@ -259,9 +258,9 @@ } } - var contents = new UnparsedContent(lines.join('\n')); + var contents = UnparsedContent(lines.join('\n')); - return new Element(tag, [contents]); + return Element(tag, [contents]); } bool _interperableAsParagraph(String line) => @@ -297,8 +296,8 @@ var match = pattern.firstMatch(parser.current); parser.advance(); var level = match[1].length; - var contents = new UnparsedContent(match[2].trim()); - return new Element('h$level', [contents]); + var contents = UnparsedContent(match[2].trim()); + return Element('h$level', [contents]); } } @@ -350,9 +349,9 @@ var childLines = parseChildLines(parser); // Recursively parse the contents of the blockquote. - var children = new BlockParser(childLines, parser.document).parseLines(); + var children = BlockParser(childLines, parser.document).parseLines(); - return new Element('blockquote', children); + return Element('blockquote', children); } } @@ -399,7 +398,7 @@ // Escape the code. var escaped = escapeHtml(childLines.join('\n')); - return new Element('pre', [new Element.text('code', escaped)]); + return Element('pre', [Element.text('code', escaped)]); } } @@ -445,7 +444,7 @@ // Escape the code. var escaped = escapeHtml(childLines.join('\n')); - var code = new Element.text('code', escaped); + var code = Element.text('code', escaped); // the info-string should be trimmed // http://spec.commonmark.org/0.22/#example-100 @@ -457,7 +456,7 @@ code.attributes['class'] = "language-$infoString"; } - var element = new Element('pre', [code]); + var element = Element('pre', [code]); return element; } @@ -471,7 +470,7 @@ Node parse(BlockParser parser) { parser.advance(); - return new Element.empty('hr'); + return Element.empty('hr'); } } @@ -488,7 +487,7 @@ } class BlockTagBlockHtmlSyntax extends BlockHtmlSyntax { - static final _pattern = new RegExp( + static final _pattern = RegExp( r'^ {0,3}</?(?:address|article|aside|base|basefont|blockquote|body|' r'caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|' r'figcaption|figure|footer|form|frame|frameset|h1|head|header|hr|html|' @@ -510,7 +509,7 @@ parser.advance(); } - return new Text(childLines.join('\n')); + return Text(childLines.join('\n')); } } @@ -526,7 +525,7 @@ // * a close bracket, or // * whitespace followed by not-brackets followed by a close bracket // * possible whitespace and the end of the line. - RegExp get pattern => new RegExp(r'^ {0,3}</?\w+(?:>|\s+[^>]*>)\s*$'); + RegExp get pattern => RegExp(r'^ {0,3}</?\w+(?:>|\s+[^>]*>)\s*$'); const OtherTagBlockHtmlSyntax(); } @@ -540,8 +539,8 @@ final RegExp _endPattern; LongBlockHtmlSyntax(String pattern, String endPattern) - : pattern = new RegExp(pattern), - _endPattern = new RegExp(endPattern); + : pattern = RegExp(pattern), + _endPattern = RegExp(endPattern); Node parse(BlockParser parser) { var childLines = <String>[]; @@ -553,7 +552,7 @@ } parser.advance(); - return new Text(childLines.join('\n')); + return Text(childLines.join('\n')); } } @@ -582,7 +581,7 @@ _olPattern ]; - static final _whitespaceRe = new RegExp('[ \t]*'); + static final _whitespaceRe = RegExp('[ \t]*'); Node parse(BlockParser parser) { var items = <ListItem>[]; @@ -590,7 +589,7 @@ void endItem() { if (childLines.isNotEmpty) { - items.add(new ListItem(childLines)); + items.add(ListItem(childLines)); childLines = <String>[]; } } @@ -691,9 +690,9 @@ var anyEmptyLinesBetweenBlocks = false; for (var item in items) { - var itemParser = new BlockParser(item.lines, parser.document); + var itemParser = BlockParser(item.lines, parser.document); var children = itemParser.parseLines(); - itemNodes.add(new Element('li', children)); + itemNodes.add(Element('li', children)); anyEmptyLinesBetweenBlocks = anyEmptyLinesBetweenBlocks || itemParser.encounteredBlankLine; } @@ -717,10 +716,9 @@ } if (listTag == 'ol' && startNumber != 1) { - return new Element(listTag, itemNodes) - ..attributes['start'] = '$startNumber'; + return Element(listTag, itemNodes)..attributes['start'] = '$startNumber'; } else { - return new Element(listTag, itemNodes); + return Element(listTag, itemNodes); } } @@ -774,9 +772,9 @@ /// Parses tables. class TableSyntax extends BlockSyntax { - static final _pipePattern = new RegExp(r'\s*\|\s*'); - static final _openingPipe = new RegExp(r'^\|\s*'); - static final _closingPipe = new RegExp(r'\s*\|$'); + static final _pipePattern = RegExp(r'\s*\|\s*'); + static final _openingPipe = RegExp(r'^\|\s*'); + static final _closingPipe = RegExp(r'\s*\|$'); bool get canEndBlock => false; @@ -800,7 +798,7 @@ if (headRow.children.length != columnCount) { return null; } - var head = new Element('thead', [headRow]); + var head = Element('thead', [headRow]); // Advance past the divider of hyphens. parser.advance(); @@ -810,7 +808,7 @@ var row = parseRow(parser, alignments, 'td'); while (row.children.length < columnCount) { // Insert synthetic empty cells. - row.children.add(new Element.empty('td')); + row.children.add(Element.empty('td')); } while (row.children.length > columnCount) { row.children.removeLast(); @@ -818,11 +816,11 @@ rows.add(row); } if (rows.isEmpty) { - return new Element('table', [head]); + return Element('table', [head]); } else { - var body = new Element('tbody', rows); + var body = Element('tbody', rows); - return new Element('table', [head, body]); + return Element('table', [head, body]); } } @@ -857,8 +855,8 @@ continue; } - var contents = new UnparsedContent(cell); - row.add(new Element(cellType, [contents])); + var contents = UnparsedContent(cell); + row.add(Element(cellType, [contents])); } for (var i = 0; i < row.length && i < alignments.length; i++) { @@ -866,15 +864,15 @@ row[i].attributes['style'] = 'text-align: ${alignments[i]};'; } - return new Element('tr', row); + return Element('tr', row); } } /// Parses paragraphs of regular text. class ParagraphSyntax extends BlockSyntax { - static final _reflinkDefinitionStart = new RegExp(r'[ ]{0,3}\['); + static final _reflinkDefinitionStart = RegExp(r'[ ]{0,3}\['); - static final _whitespacePattern = new RegExp(r'^\s*$'); + static final _whitespacePattern = RegExp(r'^\s*$'); bool get canEndBlock => false; @@ -894,10 +892,10 @@ var paragraphLines = _extractReflinkDefinitions(parser, childLines); if (paragraphLines == null) { // Paragraph consisted solely of reference link definitions. - return new Text(''); + return Text(''); } else { - var contents = new UnparsedContent(paragraphLines.join('\n')); - return new Element('p', [contents]); + var contents = UnparsedContent(paragraphLines.join('\n')); + return Element('p', [contents]); } } @@ -988,7 +986,7 @@ // // Returns whether [contents] could be parsed as a reference link definition. bool _parseReflinkDefinition(BlockParser parser, String contents) { - var pattern = new RegExp( + var pattern = RegExp( // Leading indentation. r'''^[ ]{0,3}''' // Reference id in brackets, and URL. @@ -1028,7 +1026,7 @@ label.toLowerCase().trim().replaceAll(_oneOrMoreWhitespacePattern, ' '); parser.document.linkReferences - .putIfAbsent(label, () => new LinkReference(label, destination, title)); + .putIfAbsent(label, () => LinkReference(label, destination, title)); return true; } }
diff --git a/pkgs/markdown/lib/src/document.dart b/pkgs/markdown/lib/src/document.dart index f9c47be..f42086b 100644 --- a/pkgs/markdown/lib/src/document.dart +++ b/pkgs/markdown/lib/src/document.dart
@@ -14,8 +14,8 @@ final Resolver linkResolver; final Resolver imageLinkResolver; final bool encodeHtml; - final _blockSyntaxes = new Set<BlockSyntax>(); - final _inlineSyntaxes = new Set<InlineSyntax>(); + final _blockSyntaxes = Set<BlockSyntax>(); + final _inlineSyntaxes = Set<InlineSyntax>(); Iterable<BlockSyntax> get blockSyntaxes => _blockSyntaxes; Iterable<InlineSyntax> get inlineSyntaxes => _inlineSyntaxes; @@ -38,13 +38,13 @@ /// Parses the given [lines] of Markdown to a series of AST nodes. List<Node> parseLines(List<String> lines) { - var nodes = new BlockParser(lines, this).parseLines(); + var nodes = BlockParser(lines, this).parseLines(); _parseInlineContent(nodes); return nodes; } /// Parses the given inline Markdown [text] to a series of AST nodes. - List<Node> parseInline(String text) => new InlineParser(text, this).parse(); + List<Node> parseInline(String text) => InlineParser(text, this).parse(); void _parseInlineContent(List<Node> nodes) { for (var i = 0; i < nodes.length; i++) {
diff --git a/pkgs/markdown/lib/src/emojis.dart b/pkgs/markdown/lib/src/emojis.dart index c7e9bce..cdb3b69 100644 --- a/pkgs/markdown/lib/src/emojis.dart +++ b/pkgs/markdown/lib/src/emojis.dart
@@ -4,7 +4,7 @@ // https://github.com/muan/emojilib/raw/master/emojis.json // at 2018-07-02 15:07:49.422933 by the script, tool/update_emojis.dart. -const emojis = const <String, String>{ +const emojis = <String, String>{ 'grinning': '😀', 'grimacing': '😬', 'grin': '😁',
diff --git a/pkgs/markdown/lib/src/extension_set.dart b/pkgs/markdown/lib/src/extension_set.dart index cd92e96..c9a4ea9 100644 --- a/pkgs/markdown/lib/src/extension_set.dart +++ b/pkgs/markdown/lib/src/extension_set.dart
@@ -15,13 +15,13 @@ /// fenced code blocks, or inline HTML. /// /// [Markdown.pl]: http://daringfireball.net/projects/markdown/syntax - static final ExtensionSet none = new ExtensionSet([], []); + static final ExtensionSet none = ExtensionSet([], []); /// The [commonMark] extension set is close to compliance with [CommonMark]. /// /// [CommonMark]: http://commonmark.org/ - static final ExtensionSet commonMark = new ExtensionSet( - [const FencedCodeBlockSyntax()], [new InlineHtmlSyntax()]); + static final ExtensionSet commonMark = + ExtensionSet([const FencedCodeBlockSyntax()], [InlineHtmlSyntax()]); /// The [gitHubWeb] extension set renders Markdown similarly to GitHub. /// @@ -32,29 +32,29 @@ /// linkable IDs.) /// /// [GitHub flavored Markdown]: https://github.github.com/gfm/ - static final ExtensionSet gitHubWeb = new ExtensionSet([ + static final ExtensionSet gitHubWeb = ExtensionSet([ const FencedCodeBlockSyntax(), const HeaderWithIdSyntax(), const SetextHeaderWithIdSyntax(), const TableSyntax() ], [ - new InlineHtmlSyntax(), - new StrikethroughSyntax(), - new EmojiSyntax(), - new AutolinkExtensionSyntax(), + InlineHtmlSyntax(), + StrikethroughSyntax(), + EmojiSyntax(), + AutolinkExtensionSyntax(), ]); /// The [gitHubFlavored] extension set is close to compliance with the [GitHub /// flavored Markdown spec]. /// /// [GitHub flavored Markdown]: https://github.github.com/gfm/ - static final ExtensionSet gitHubFlavored = new ExtensionSet([ + static final ExtensionSet gitHubFlavored = ExtensionSet([ const FencedCodeBlockSyntax(), const TableSyntax() ], [ - new InlineHtmlSyntax(), - new StrikethroughSyntax(), - new AutolinkExtensionSyntax(), + InlineHtmlSyntax(), + StrikethroughSyntax(), + AutolinkExtensionSyntax(), ]); final List<BlockSyntax> blockSyntaxes;
diff --git a/pkgs/markdown/lib/src/html_renderer.dart b/pkgs/markdown/lib/src/html_renderer.dart index 8c65a43..95e0cda 100644 --- a/pkgs/markdown/lib/src/html_renderer.dart +++ b/pkgs/markdown/lib/src/html_renderer.dart
@@ -18,7 +18,7 @@ Resolver linkResolver, Resolver imageLinkResolver, bool inlineOnly = false}) { - var document = new Document( + var document = Document( blockSyntaxes: blockSyntaxes, inlineSyntaxes: inlineSyntaxes, extensionSet: extensionSet, @@ -34,11 +34,11 @@ } /// Renders [nodes] to HTML. -String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes); +String renderToHtml(List<Node> nodes) => HtmlRenderer().render(nodes); /// Translates a parsed AST to HTML. class HtmlRenderer implements NodeVisitor { - static final _blockTags = new RegExp('blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre'); + static final _blockTags = RegExp('blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre'); StringBuffer buffer; Set<String> uniqueIds; @@ -46,8 +46,8 @@ HtmlRenderer(); String render(List<Node> nodes) { - buffer = new StringBuffer(); - uniqueIds = new LinkedHashSet<String>(); + buffer = StringBuffer(); + uniqueIds = LinkedHashSet<String>(); for (final node in nodes) node.accept(this);
diff --git a/pkgs/markdown/lib/src/inline_parser.dart b/pkgs/markdown/lib/src/inline_parser.dart index a52f42b..d7e711d 100644 --- a/pkgs/markdown/lib/src/inline_parser.dart +++ b/pkgs/markdown/lib/src/inline_parser.dart
@@ -13,35 +13,35 @@ /// Markdown. class InlineParser { static final List<InlineSyntax> _defaultSyntaxes = - new List<InlineSyntax>.unmodifiable(<InlineSyntax>[ - new EmailAutolinkSyntax(), - new AutolinkSyntax(), - new LineBreakSyntax(), - new LinkSyntax(), - new ImageSyntax(), + List<InlineSyntax>.unmodifiable(<InlineSyntax>[ + EmailAutolinkSyntax(), + AutolinkSyntax(), + LineBreakSyntax(), + LinkSyntax(), + ImageSyntax(), // Allow any punctuation to be escaped. - new EscapeSyntax(), + EscapeSyntax(), // "*" surrounded by spaces is left alone. - new TextSyntax(r' \* '), + TextSyntax(r' \* '), // "_" surrounded by spaces is left alone. - new TextSyntax(r' _ '), + TextSyntax(r' _ '), // Parse "**strong**" and "*emphasis*" tags. - new TagSyntax(r'\*+', requiresDelimiterRun: true), + TagSyntax(r'\*+', requiresDelimiterRun: true), // Parse "__strong__" and "_emphasis_" tags. - new TagSyntax(r'_+', requiresDelimiterRun: true), - new CodeSyntax(), + TagSyntax(r'_+', requiresDelimiterRun: true), + CodeSyntax(), // We will add the LinkSyntax once we know about the specific link resolver. ]); static final List<InlineSyntax> _htmlSyntaxes = - new List<InlineSyntax>.unmodifiable(<InlineSyntax>[ + List<InlineSyntax>.unmodifiable(<InlineSyntax>[ // Leave already-encoded HTML entities alone. Ensures we don't turn // "&" into "&amp;" - new TextSyntax(r'&[#a-zA-Z0-9]*;'), + TextSyntax(r'&[#a-zA-Z0-9]*;'), // Encode "&". - new TextSyntax(r'&', sub: '&'), + TextSyntax(r'&', sub: '&'), // Encode "<". (Why not encode ">" too? Gruber is toying with us.) - new TextSyntax(r'<', sub: '<'), + TextSyntax(r'<', sub: '<'), // We will add the LinkSyntax once we know about the specific link resolver. ]); @@ -75,9 +75,9 @@ // character position. if (documentHasCustomInlineSyntaxes) { // We should be less aggressive in blowing past "words". - syntaxes.add(new TextSyntax(r'[A-Za-z0-9]+(?=\s)')); + syntaxes.add(TextSyntax(r'[A-Za-z0-9]+(?=\s)')); } else { - syntaxes.add(new TextSyntax(r'[ \tA-Za-z0-9]*[A-Za-z0-9](?=\s)')); + syntaxes.add(TextSyntax(r'[ \tA-Za-z0-9]*[A-Za-z0-9](?=\s)')); } syntaxes.addAll(_defaultSyntaxes); @@ -88,14 +88,14 @@ // Custom link resolvers go after the generic text syntax. syntaxes.insertAll(1, [ - new LinkSyntax(linkResolver: document.linkResolver), - new ImageSyntax(linkResolver: document.imageLinkResolver) + LinkSyntax(linkResolver: document.linkResolver), + ImageSyntax(linkResolver: document.imageLinkResolver) ]); } List<Node> parse() { // Make a fake top tag to hold the results. - _stack.add(new TagState(0, 0, null, null)); + _stack.add(TagState(0, 0, null, null)); while (!isDone) { // See if any of the current tags on the stack match. This takes @@ -131,9 +131,9 @@ // If the previous node is text too, just append. if (nodes.isNotEmpty && nodes.last is Text) { var textNode = nodes.last as Text; - nodes[nodes.length - 1] = new Text('${textNode.text}$text'); + nodes[nodes.length - 1] = Text('${textNode.text}$text'); } else { - nodes.add(new Text(text)); + nodes.add(Text(text)); } } @@ -161,7 +161,7 @@ abstract class InlineSyntax { final RegExp pattern; - InlineSyntax(String pattern) : pattern = new RegExp(pattern, multiLine: true); + InlineSyntax(String pattern) : pattern = RegExp(pattern, multiLine: true); /// Tries to match at the parser's current position. /// @@ -193,7 +193,7 @@ /// Create a void <br> element. bool onMatch(InlineParser parser, Match match) { - parser.addNode(new Element.empty('br')); + parser.addNode(Element.empty('br')); return true; } } @@ -214,7 +214,7 @@ } // Insert the substitution. - parser.addNode(new Text(substitute)); + parser.addNode(Text(substitute)); return true; } } @@ -225,7 +225,7 @@ bool onMatch(InlineParser parser, Match match) { // Insert the substitution. - parser.addNode(new Text(match[0][1])); + parser.addNode(Text(match[0][1])); return true; } } @@ -255,7 +255,7 @@ bool onMatch(InlineParser parser, Match match) { var url = match[1]; - var anchor = new Element.text('a', escapeHtml(url)); + var anchor = Element.text('a', escapeHtml(url)); anchor.attributes['href'] = Uri.encodeFull('mailto:$url'); parser.addNode(anchor); @@ -269,7 +269,7 @@ bool onMatch(InlineParser parser, Match match) { var url = match[1]; - var anchor = new Element.text('a', escapeHtml(url)); + var anchor = Element.text('a', escapeHtml(url)); anchor.attributes['href'] = Uri.encodeFull(url); parser.addNode(anchor); @@ -300,9 +300,9 @@ static const truncatingPunctuationPositive = r'[?!.,:*_~]'; static final regExpTrailingPunc = - new RegExp('$truncatingPunctuationPositive*' + r'$'); - static final regExpEndsWithColon = new RegExp(r'\&[a-zA-Z0-9]+;$'); - static final regExpWhiteSpace = new RegExp(r'\s'); + RegExp('$truncatingPunctuationPositive*' + r'$'); + static final regExpEndsWithColon = RegExp(r'\&[a-zA-Z0-9]+;$'); + static final regExpWhiteSpace = RegExp(r'\s'); AutolinkExtensionSyntax() : super('$start(($scheme)($domain)($path))'); @@ -380,7 +380,7 @@ href = 'http://$href'; } - final anchor = new Element.text('a', escapeHtml(url)); + final anchor = Element.text('a', escapeHtml(url)); anchor.attributes['href'] = Uri.encodeFull(href); parser.addNode(anchor); @@ -464,7 +464,7 @@ return null; } - return new _DelimiterRun._( + return _DelimiterRun._( char: parser.charAt(runStart), length: runEnd - runStart + 1, isLeftFlanking: leftFlanking, @@ -500,7 +500,7 @@ final bool requiresDelimiterRun; TagSyntax(String pattern, {String end, this.requiresDelimiterRun = false}) - : endPattern = new RegExp((end != null) ? end : pattern, multiLine: true), + : endPattern = RegExp((end != null) ? end : pattern, multiLine: true), super(pattern); bool onMatch(InlineParser parser, Match match) { @@ -508,14 +508,13 @@ var matchStart = parser.pos; var matchEnd = parser.pos + runLength - 1; if (!requiresDelimiterRun) { - parser.openTag(new TagState(parser.pos, matchEnd + 1, this, null)); + parser.openTag(TagState(parser.pos, matchEnd + 1, this, null)); return true; } var delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd); if (delimiterRun != null && delimiterRun.canOpen) { - parser - .openTag(new TagState(parser.pos, matchEnd + 1, this, delimiterRun)); + parser.openTag(TagState(parser.pos, matchEnd + 1, this, delimiterRun)); return true; } else { parser.advanceBy(runLength); @@ -531,29 +530,29 @@ var delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd); if (openingRunLength == 1 && runLength == 1) { - parser.addNode(new Element('em', state.children)); + parser.addNode(Element('em', state.children)); } else if (openingRunLength == 1 && runLength > 1) { - parser.addNode(new Element('em', state.children)); + parser.addNode(Element('em', state.children)); parser.pos = parser.pos - (runLength - 1); parser.start = parser.pos; } else if (openingRunLength > 1 && runLength == 1) { parser.openTag( - new TagState(state.startPos, state.endPos - 1, this, delimiterRun)); - parser.addNode(new Element('em', state.children)); + TagState(state.startPos, state.endPos - 1, this, delimiterRun)); + parser.addNode(Element('em', state.children)); } else if (openingRunLength == 2 && runLength == 2) { - parser.addNode(new Element('strong', state.children)); + parser.addNode(Element('strong', state.children)); } else if (openingRunLength == 2 && runLength > 2) { - parser.addNode(new Element('strong', state.children)); + parser.addNode(Element('strong', state.children)); parser.pos = parser.pos - (runLength - 2); parser.start = parser.pos; } else if (openingRunLength > 2 && runLength == 2) { parser.openTag( - new TagState(state.startPos, state.endPos - 2, this, delimiterRun)); - parser.addNode(new Element('strong', state.children)); + TagState(state.startPos, state.endPos - 2, this, delimiterRun)); + parser.addNode(Element('strong', state.children)); } else if (openingRunLength > 2 && runLength > 2) { parser.openTag( - new TagState(state.startPos, state.endPos - 2, this, delimiterRun)); - parser.addNode(new Element('strong', state.children)); + TagState(state.startPos, state.endPos - 2, this, delimiterRun)); + parser.addNode(Element('strong', state.children)); parser.pos = parser.pos - (runLength - 2); parser.start = parser.pos; } @@ -576,14 +575,14 @@ return false; } - parser.addNode(new Element('del', state.children)); + parser.addNode(Element('del', state.children)); return true; } } /// Matches links like `[blah][label]` and `[blah](url)`. class LinkSyntax extends TagSyntax { - static final _entirelyWhitespacePattern = new RegExp(r'^\s*$'); + static final _entirelyWhitespacePattern = RegExp(r'^\s*$'); final Resolver linkResolver; @@ -705,7 +704,7 @@ /// Create the node represented by a Markdown link. Node _createNode(TagState state, String destination, String title) { - var element = new Element('a', state.children); + var element = Element('a', state.children); element.attributes['href'] = escapeAttribute(destination); if (title != null && title.isNotEmpty) { element.attributes['title'] = escapeAttribute(title); @@ -751,7 +750,7 @@ parser.advanceBy(1); if (parser.isDone) return null; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); while (true) { var char = parser.charAt(parser.pos); if (char == $backslash) { @@ -810,7 +809,7 @@ InlineLink _parseInlineBracketedLink(InlineParser parser) { parser.advanceBy(1); - var buffer = new StringBuffer(); + var buffer = StringBuffer(); while (true) { var char = parser.charAt(parser.pos); if (char == $backslash) { @@ -848,9 +847,9 @@ // followed by mystery characters; no longer a link. return null; } - return new InlineLink(destination, title: title); + return InlineLink(destination, title: title); } else if (char == $rparen) { - return new InlineLink(destination); + return InlineLink(destination); } else { // We parsed something like `[foo](<url>X`. Not a link. return null; @@ -872,7 +871,7 @@ // We need to count the open parens. We start with 1 for the paren that // opened the destination. var parenCount = 1; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); while (true) { var char = parser.charAt(parser.pos); @@ -906,7 +905,7 @@ // parentheses). parenCount--; if (parenCount == 0) { - return new InlineLink(destination, title: title); + return InlineLink(destination, title: title); } break; @@ -919,7 +918,7 @@ parenCount--; if (parenCount == 0) { var destination = buffer.toString(); - return new InlineLink(destination); + return InlineLink(destination); } buffer.writeCharCode(char); break; @@ -968,7 +967,7 @@ parser.advanceBy(1); // Now we look for an un-escaped closing delimiter. - var buffer = new StringBuffer(); + var buffer = StringBuffer(); while (true) { var char = parser.charAt(parser.pos); if (char == $backslash) { @@ -1005,7 +1004,7 @@ : super(linkResolver: linkResolver, pattern: r'!\['); Node _createNode(TagState state, String destination, String title) { - var element = new Element.empty('img'); + var element = Element.empty('img'); element.attributes['src'] = escapeHtml(destination); element.attributes['alt'] = state?.textContent ?? ''; if (title != null && title.isNotEmpty) { @@ -1068,7 +1067,7 @@ } bool onMatch(InlineParser parser, Match match) { - parser.addNode(new Element.text('code', escapeHtml(match[2].trim()))); + parser.addNode(Element.text('code', escapeHtml(match[2].trim()))); return true; } } @@ -1090,7 +1089,7 @@ parser.advanceBy(1); return false; } - parser.addNode(new Text(emoji)); + parser.addNode(Text(emoji)); return true; }
diff --git a/pkgs/markdown/lib/src/util.dart b/pkgs/markdown/lib/src/util.dart index c35bc74..5b0db05 100644 --- a/pkgs/markdown/lib/src/util.dart +++ b/pkgs/markdown/lib/src/util.dart
@@ -9,7 +9,7 @@ // Based on http://spec.commonmark.org/0.28/#backslash-escapes. String escapeAttribute(String value) { - var result = new StringBuffer(); + var result = StringBuffer(); int ch; for (var i = 0; i < value.codeUnits.length; i++) { ch = value.codeUnitAt(i);
diff --git a/pkgs/markdown/test/blns.dart b/pkgs/markdown/test/blns.dart index f515658..8285124 100644 --- a/pkgs/markdown/test/blns.dart +++ b/pkgs/markdown/test/blns.dart
@@ -4,7 +4,7 @@ // https://github.com/minimaxir/big-list-of-naughty-strings/raw/master/blns.json // at 2018-07-02 12:53:34.521084 by the script, tool/update_blns.dart. -const blns = const <String>[ +const blns = <String>[ '', 'undefined', 'undef',
diff --git a/pkgs/markdown/test/document_test.dart b/pkgs/markdown/test/document_test.dart index 78290f7..e5a9377 100644 --- a/pkgs/markdown/test/document_test.dart +++ b/pkgs/markdown/test/document_test.dart
@@ -8,7 +8,7 @@ void main() { group('Document', () { test('encodeHtml prevents less than and ampersand escaping', () { - var document = new Document(encodeHtml: false); + var document = Document(encodeHtml: false); var result = document.parseInline('< &'); expect(result, hasLength(1)); expect(
diff --git a/pkgs/markdown/test/markdown_test.dart b/pkgs/markdown/test/markdown_test.dart index e7b70f9..87b5093 100644 --- a/pkgs/markdown/test/markdown_test.dart +++ b/pkgs/markdown/test/markdown_test.dart
@@ -20,13 +20,12 @@ testFile('extensions/tables.unit', blockSyntaxes: [const TableSyntax()]); // Inline syntax extensions - testFile('extensions/emojis.unit', inlineSyntaxes: [new EmojiSyntax()]); - testFile('extensions/inline_html.unit', - inlineSyntaxes: [new InlineHtmlSyntax()]); + testFile('extensions/emojis.unit', inlineSyntaxes: [EmojiSyntax()]); + testFile('extensions/inline_html.unit', inlineSyntaxes: [InlineHtmlSyntax()]); group('Resolver', () { Node nyanResolver(String text, [_]) => - text.isEmpty ? null : new Text('~=[,,_${text}_,,]:3'); + text.isEmpty ? null : Text('~=[,,_${text}_,,]:3'); validateCore( 'simple link resolver', ''' @@ -89,7 +88,7 @@ }); group('Custom inline syntax', () { - var nyanSyntax = <InlineSyntax>[new TextSyntax('nyan', sub: '~=[,,_,,]:3')]; + var nyanSyntax = <InlineSyntax>[TextSyntax('nyan', sub: '~=[,,_,,]:3')]; validateCore( 'simple inline syntax', ''' @@ -101,7 +100,7 @@ validateCore('dart custom links', 'links [are<foo>] awesome', '<p>links <a>are<foo></a> awesome</p>\n', linkResolver: (String text, [_]) => - new Element.text('a', text.replaceAll('<', '<'))); + Element.text('a', text.replaceAll('<', '<'))); // TODO(amouravski): need more tests here for custom syntaxes, as some // things are not quite working properly. The regexps are sometime a little
diff --git a/pkgs/markdown/test/version_test.dart b/pkgs/markdown/test/version_test.dart index cb2f621..f9cb207 100644 --- a/pkgs/markdown/test/version_test.dart +++ b/pkgs/markdown/test/version_test.dart
@@ -21,7 +21,7 @@ var pubspecFile = p.normalize(p.join(_currentDir, '..', 'pubspec.yaml')); var pubspecContent = - loadYaml(new File(pubspecFile).readAsStringSync()) as YamlMap; + loadYaml(File(pubspecFile).readAsStringSync()) as YamlMap; expect(binVersion, pubspecContent['version'], reason: 'The version reported by bin/markdown.dart should match the '
diff --git a/pkgs/markdown/tool/dartdoc-compare.dart b/pkgs/markdown/tool/dartdoc-compare.dart index 4864034..9a06b45 100644 --- a/pkgs/markdown/tool/dartdoc-compare.dart +++ b/pkgs/markdown/tool/dartdoc-compare.dart
@@ -12,7 +12,7 @@ const _help = 'help'; void main(List<String> arguments) { - final parser = new ArgParser() + final parser = ArgParser() ..addSeparator("Usage: dartdoc-compare.dart [OPTIONS] <dart-package>") ..addOption(_dartdocDir, help: "Directory of the dartdoc package") ..addOption(_markdownBefore, help: "Markdown package 'before' ref") @@ -35,7 +35,7 @@ exitCode = 1; return; } - var comparer = new DartdocCompare( + var comparer = DartdocCompare( options[_dartdocDir] as String, options[_markdownBefore] as String, options[_markdownAfter] as String, @@ -66,7 +66,7 @@ final String dartdocBin; final String dartdocPubspecPath; final bool sdk; - final String markdownPath = new File(Platform.script.path).parent.parent.path; + final String markdownPath = File(Platform.script.path).parent.parent.path; DartdocCompare(this.dartdocDir, this.markdownBefore, this.markdownAfter, this.dartdocBin, this.dartdocPubspecPath, this.sdk); @@ -94,7 +94,7 @@ _doInPath(dartdocDir, () { var returnCode = _updateDartdocPubspec(markdownRef); if (returnCode != 0) { - throw new Exception("Could not update dartdoc's pubspec!"); + throw Exception("Could not update dartdoc's pubspec!"); } }); return _doInPath(path, () { @@ -111,9 +111,9 @@ } print('Command: $cmd ${args.join(' ')}'); - var startTime = new DateTime.now(); + var startTime = DateTime.now(); _system(cmd, args); - var endTime = new DateTime.now(); + var endTime = DateTime.now(); var duration = endTime.difference(startTime).inSeconds; print('dartdoc generation for $markdownRef took $duration seconds.'); print(''); @@ -124,7 +124,7 @@ int _updateDartdocPubspec(String markdownRef) { var dartdocPubspec = - loadYaml(new File(dartdocPubspecPath).readAsStringSync()) as Map; + loadYaml(File(dartdocPubspecPath).readAsStringSync()) as Map; // make modifiable copy dartdocPubspec = jsonDecode(jsonEncode(dartdocPubspec)) as Map; @@ -141,7 +141,7 @@ }; } - new File(dartdocPubspecPath).writeAsStringSync(jsonEncode(dartdocPubspec)); + File(dartdocPubspecPath).writeAsStringSync(jsonEncode(dartdocPubspec)); return _system('pub', ['upgrade']); } }
diff --git a/pkgs/markdown/tool/stats.dart b/pkgs/markdown/tool/stats.dart index 8572c8d..476c74c 100644 --- a/pkgs/markdown/tool/stats.dart +++ b/pkgs/markdown/tool/stats.dart
@@ -10,7 +10,7 @@ import 'stats_lib.dart'; Future main(List<String> args) async { - final parser = new ArgParser() + final parser = ArgParser() ..addOption('section', help: 'Restrict tests to one section, provided after the option.') ..addFlag('raw', @@ -72,12 +72,12 @@ config = Config.commonMarkConfig; break; default: - throw new ArgumentError('Does not support `$testPrefix`.'); + throw ArgumentError('Does not support `$testPrefix`.'); } var sections = loadCommonMarkSections(testPrefix); - var scores = new SplayTreeMap<String, SplayTreeMap<int, CompareLevel>>( + var scores = SplayTreeMap<String, SplayTreeMap<int, CompareLevel>>( compareAsciiLowerCaseNatural); sections.forEach((section, examples) { @@ -85,8 +85,8 @@ return; } for (var e in examples) { - var nestedMap = scores.putIfAbsent( - section, () => new SplayTreeMap<int, CompareLevel>()); + var nestedMap = + scores.putIfAbsent(section, () => SplayTreeMap<int, CompareLevel>()); nestedMap[e.example] = compareResult(config, e, verboseFail: verbose, verboseLooseMatch: verboseLooseMatch); @@ -114,7 +114,7 @@ case CompareLevel.loose: return 'loose'; default: - throw new ArgumentError("`$obj` is unknown."); + throw ArgumentError("`$obj` is unknown."); } } if (obj is Map) { @@ -164,7 +164,7 @@ if (updateFiles) { var path = p.join(toolDir, '${testPrefix}_stats.txt'); print('Updating $path'); - var file = new File(path); + var file = File(path); sink = file.openWrite(); } else { sink = stdout;
diff --git a/pkgs/markdown/tool/stats_lib.dart b/pkgs/markdown/tool/stats_lib.dart index 5622bed..7e55671 100644 --- a/pkgs/markdown/tool/stats_lib.dart +++ b/pkgs/markdown/tool/stats_lib.dart
@@ -18,20 +18,20 @@ .path); File getStatsFile(String prefix) => - new File(p.join(toolDir, '${prefix}_stats.json')); + File(p.join(toolDir, '${prefix}_stats.json')); Map<String, List<CommonMarkTestCase>> loadCommonMarkSections( String testPrefix) { - var testFile = new File(p.join(toolDir, '${testPrefix}_tests.json')); + var testFile = File(p.join(toolDir, '${testPrefix}_tests.json')); var testsJson = testFile.readAsStringSync(); var testArray = jsonDecode(testsJson) as List; - var sections = new Map<String, List<CommonMarkTestCase>>(); + var sections = Map<String, List<CommonMarkTestCase>>(); for (var exampleMap in testArray) { var exampleTest = - new CommonMarkTestCase.fromJson(exampleMap as Map<String, dynamic>); + CommonMarkTestCase.fromJson(exampleMap as Map<String, dynamic>); var sectionList = sections.putIfAbsent(exampleTest.section, () => <CommonMarkTestCase>[]); @@ -44,8 +44,8 @@ class Config { static final Config commonMarkConfig = - new Config._('common_mark', 'http://spec.commonmark.org/0.28/', null); - static final Config gfmConfig = new Config._( + Config._('common_mark', 'http://spec.commonmark.org/0.28/', null); + static final Config gfmConfig = Config._( 'gfm', 'https://github.github.com/gfm/', ExtensionSet.gitHubFlavored); final String prefix; @@ -67,7 +67,7 @@ this.markdown, this.html); factory CommonMarkTestCase.fromJson(Map<String, dynamic> json) { - return new CommonMarkTestCase( + return CommonMarkTestCase( json['example'] as int, json['section'] as String, json['start_line'] as int,
diff --git a/pkgs/markdown/tool/update_blns.dart b/pkgs/markdown/tool/update_blns.dart index 744d87f..37d10ee 100644 --- a/pkgs/markdown/tool/update_blns.dart +++ b/pkgs/markdown/tool/update_blns.dart
@@ -7,7 +7,7 @@ final _blnsFilePath = 'test/blns.dart'; Future<Null> main() async { - var client = new HttpClient(); + var client = HttpClient(); List<String> json; try { var request = await client.getUrl(Uri.parse(_blnsJsonRawUrl)); @@ -17,12 +17,12 @@ } finally { client.close(); } - var blnsContent = new StringBuffer(''' + var blnsContent = StringBuffer(''' // GENERATED FILE. DO NOT EDIT. // // This file was generated from big-list-of-naughty-strings's JSON file: // $_blnsJsonRawUrl -// at ${new DateTime.now()} by the script, tool/update_blns.dart. +// at ${DateTime.now()} by the script, tool/update_blns.dart. '''); blnsContent.writeln('const blns = const <String>['); @@ -34,5 +34,5 @@ blnsContent.writeln(" '$escaped',"); } blnsContent.writeln('];'); - new File(_blnsFilePath)..writeAsStringSync(blnsContent.toString()); + File(_blnsFilePath)..writeAsStringSync(blnsContent.toString()); }
diff --git a/pkgs/markdown/tool/update_emojis.dart b/pkgs/markdown/tool/update_emojis.dart index fa07c0a..03d17b0 100644 --- a/pkgs/markdown/tool/update_emojis.dart +++ b/pkgs/markdown/tool/update_emojis.dart
@@ -7,18 +7,18 @@ final _emojisFilePath = 'lib/src/emojis.dart'; Future<Null> main() async { - var client = new HttpClient(); + var client = HttpClient(); var request = await client.getUrl(Uri.parse(_emojisJsonRawUrl)); var response = await request.close(); var json = jsonDecode(await response.transform(utf8.decoder).join('')) - .map((alias, info) => new MapEntry(alias, info.cast<String, dynamic>())) + .map((alias, info) => MapEntry(alias, info.cast<String, dynamic>())) .cast<String, Map<String, dynamic>>(); - var emojisContent = new StringBuffer(''' + var emojisContent = StringBuffer(''' // GENERATED FILE. DO NOT EDIT. // // This file was generated from emojilib's emoji data file: // $_emojisJsonRawUrl -// at ${new DateTime.now()} by the script, tool/update_emojis.dart. +// at ${DateTime.now()} by the script, tool/update_emojis.dart. '''); emojisContent.writeln('const emojis = const <String, String>{'); @@ -33,7 +33,7 @@ } }); emojisContent.writeln('};'); - new File(_emojisFilePath)..writeAsStringSync(emojisContent.toString()); + File(_emojisFilePath)..writeAsStringSync(emojisContent.toString()); print('Wrote data to $_emojisFilePath for $emojiCount emojis, ' 'ignoring ${ignored.length}: ${ignored.join(', ')}.'); exit(0);