From fa5c3a7f960112eb9ae2d71766f888344e456e01 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Wed, 20 Mar 2013 23:41:50 +0000 Subject: [PATCH 001/133] Move source maps package to the dart repo, so it can be used by other internal tools. Review URL: https://codereview.chromium.org//12207008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@20300 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/README.md | 27 ++ pkgs/source_maps/lib/builder.dart | 146 +++++++++ pkgs/source_maps/lib/parser.dart | 391 ++++++++++++++++++++++++ pkgs/source_maps/lib/printer.dart | 89 ++++++ pkgs/source_maps/lib/source_maps.dart | 25 ++ pkgs/source_maps/lib/span.dart | 330 ++++++++++++++++++++ pkgs/source_maps/lib/src/utils.dart | 29 ++ pkgs/source_maps/lib/src/vlq.dart | 103 +++++++ pkgs/source_maps/pubspec.yaml | 6 + pkgs/source_maps/test/builder_test.dart | 32 ++ pkgs/source_maps/test/common.dart | 97 ++++++ pkgs/source_maps/test/end2end_test.dart | 106 +++++++ pkgs/source_maps/test/parser_test.dart | 36 +++ pkgs/source_maps/test/printer_test.dart | 82 +++++ pkgs/source_maps/test/run.dart | 38 +++ pkgs/source_maps/test/span_test.dart | 215 +++++++++++++ pkgs/source_maps/test/utils_test.dart | 54 ++++ pkgs/source_maps/test/vlq_test.dart | 59 ++++ 18 files changed, 1865 insertions(+) create mode 100644 pkgs/source_maps/README.md create mode 100644 pkgs/source_maps/lib/builder.dart create mode 100644 pkgs/source_maps/lib/parser.dart create mode 100644 pkgs/source_maps/lib/printer.dart create mode 100644 pkgs/source_maps/lib/source_maps.dart create mode 100644 pkgs/source_maps/lib/span.dart create mode 100644 pkgs/source_maps/lib/src/utils.dart create mode 100644 pkgs/source_maps/lib/src/vlq.dart create mode 100644 pkgs/source_maps/pubspec.yaml create mode 100644 pkgs/source_maps/test/builder_test.dart create mode 100644 pkgs/source_maps/test/common.dart create mode 100644 pkgs/source_maps/test/end2end_test.dart create mode 100644 pkgs/source_maps/test/parser_test.dart create mode 100644 pkgs/source_maps/test/printer_test.dart create mode 100755 pkgs/source_maps/test/run.dart create mode 100644 pkgs/source_maps/test/span_test.dart create mode 100644 pkgs/source_maps/test/utils_test.dart create mode 100644 pkgs/source_maps/test/vlq_test.dart diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md new file mode 100644 index 000000000..df182d9ba --- /dev/null +++ b/pkgs/source_maps/README.md @@ -0,0 +1,27 @@ +Source Maps +=========== + +This project implements a Dart pub package to work with source maps. The +implementation is based on the [source map version 3 spec][spec] which was +originated from the [Closure Compiler][closure] and has been implemented in +Chrome and Firefox. + +In this package we provide: + * Data types defining file locations and spans: these are not part of the + original source map specification. These data types are great for tracking + source locations on source maps, but they can also be used by tools to + reporting useful error messages that include on source locations. + * A builder that creates a source map programatically and produces the encoded + source map format. + * A parser that reads the source map format and provides APIs to read the + mapping information. + +Some upcoming features we are planning to add to this package are: + * A printer that lets you generate code, but record source map information in + the process. + * A tool that can compose source maps together. This would be useful for + instance, if you have 2 tools that produce source maps and you call one with + the result of the other. + +[closure]: http://code.google.com/p/closure-compiler/wiki/SourceMaps +[spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart new file mode 100644 index 000000000..ad80fa000 --- /dev/null +++ b/pkgs/source_maps/lib/builder.dart @@ -0,0 +1,146 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Contains a builder object useful for creating source maps programatically. +library source_maps.builder; + +// TODO(sigmund): add a builder for multi-section mappings. + +import 'dart:json' as json; +import 'dart:collection'; + +import 'span.dart'; +import 'src/vlq.dart'; + +/// Builds a source map given a set of mappings. +class SourceMapBuilder { + + final List _entries = []; + + /// Indices associated with file urls that will be part of the source map. We + /// use a linked hash-map so that `_urls.keys[_urls[u]] == u` + final Map _urls = new LinkedHashMap(); + + /// Indices associated with identifiers that will be part of the source map. + /// We use a linked hash-map so that `_names.keys[_names[n]] == n` + final Map _names = new LinkedHashMap(); + + /// Adds an entry mapping the [targetOffset] to [source]. + void addFromOffset(Location source, + SourceFile targetFile, int targetOffset, String identifier) { + if (targetFile == null) { + throw new ArgumentError('targetFile cannot be null'); + } + _entries.add(new Entry(source, + new FileLocation(targetFile, targetOffset), identifier)); + } + + /// Adds an entry mapping [target] to [source]. + void addSpan(Span source, Span target) { + var name = source.isIdentifier ? source.text : null; + _entries.add(new Entry(source.start, target.start, name)); + } + + void addLocation(Location source, Location target, String identifier) { + _entries.add(new Entry(source, target, identifier)); + } + + /// Encodes all mappings added to this builder as a json map. + Map build(String fileUrl) { + var buff = new StringBuffer(); + var line = 0; + var column = 0; + var srcLine = 0; + var srcColumn = 0; + var srcUrlId = 0; + var srcNameId = 0; + var first = true; + + // The encoding needs to be sorted by the target offsets. + _entries.sort(); + for (var entry in _entries) { + int nextLine = entry.target.line; + if (nextLine > line) { + for (int i = line; i < nextLine; ++i) { + buff.write(';'); + } + line = nextLine; + column = 0; + first = true; + } + + if (!first) buff.write(','); + first = false; + column = _append(buff, column, entry.target.column); + + if (entry.source == null) continue; + + srcUrlId = _append(buff, srcUrlId, + _indexOf(_urls, entry.source.sourceUrl)); + srcLine = _append(buff, srcLine, entry.source.line); + srcColumn = _append(buff, srcColumn, entry.source.column); + + if (entry.identifierName == null) continue; + srcNameId = _append(buff, srcNameId, + _indexOf(_names, entry.identifierName)); + } + + var result = { + 'version': 3, + 'sourceRoot': '', + 'sources': _urls.keys.toList(), + 'names' : _names.keys.toList(), + 'mappings' : buff.toString() + }; + if (fileUrl != null) { + result['file'] = fileUrl; + } + return result; + } + + /// Encodes all mappings added to this builder as a json string. + String toJson(String fileUrl) => json.stringify(build(fileUrl)); + + /// Get the index of [value] in [map], or create one if it doesn't exist. + int _indexOf(Map map, String value) { + return map.putIfAbsent(value, () { + int index = map.length; + map[value] = index; + return index; + }); + } + + /// Appends to [buff] a VLQ encoding of [newValue] using the difference + /// between [oldValue] and [newValue] + static int _append(StringBuffer buff, int oldValue, int newValue) { + buff.writeAll(encodeVlq(newValue - oldValue)); + return newValue; + } +} + +/// An entry in the source map builder. +class Entry implements Comparable { + /// Span denoting the original location in the input source file + final Location source; + + /// Span indicating the corresponding location in the target file. + final Location target; + + /// An identifier name, when this location is the start of an identifier. + final String identifierName; + + Entry(this.source, this.target, this.identifierName); + + /// Implements [Comparable] to ensure that entries are ordered by their + /// location in the target file. We sort primarily by the target offset + /// because source map files are encoded by printing each mapping in order as + /// they appear in the target file. + int compareTo(Entry other) { + int res = target.compareTo(other.target); + if (res != 0) return res; + res = source.sourceUrl.compareTo(other.source.sourceUrl); + if (res != 0) return res; + return source.compareTo(other.source); + } +} diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart new file mode 100644 index 000000000..3849913a3 --- /dev/null +++ b/pkgs/source_maps/lib/parser.dart @@ -0,0 +1,391 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Contains the top-level function to parse source maps version 3. +library source_maps.parser; + +import 'dart:json' as json; + +import 'span.dart'; +import 'src/utils.dart'; +import 'src/vlq.dart'; + +/// Parses a source map directly from a json string. +// TODO(sigmund): evaluate whether other maps should have the json parsed, or +// the string represenation. +Mapping parse(String jsonMap, {Map otherMaps}) => + parseJson(json.parse(jsonMap), otherMaps: otherMaps); + +/// Parses a source map directly from a json map object. +Mapping parseJson(Map map, {Map otherMaps}) { + if (map['version'] != 3) { + throw new ArgumentError( + 'unexpected source map version: ${map["version"]}. ' + 'Only version 3 is supported.'); + } + + // TODO(sigmund): relax this? dart2js doesn't generate the file entry. + if (!map.containsKey('file')) { + throw new ArgumentError('missing "file" in source map'); + } + + if (map.containsKey('sections')) { + if (map.containsKey('mappings') || map.containsKey('sources') || + map.containsKey('names')) { + throw new FormatException('map containing "sections" ' + 'cannot contain "mappings", "sources", or "names".'); + } + return new MultiSectionMapping.fromJson(map['sections'], otherMaps); + } + return new SingleMapping.fromJson(map); +} + + +/// A mapping parsed our of a source map. +abstract class Mapping { + Span spanFor(int line, int column, {Map files}); + + Span spanForLocation(Location loc, {Map files}) { + return spanFor(loc.line, loc.column, files: files); + } +} + +/// A meta-level map containing sections. +class MultiSectionMapping extends Mapping { + /// For each section, the start line offset. + final List _lineStart = []; + + /// For each section, the start column offset. + final List _columnStart = []; + + /// For each section, the actual source map information, which is not adjusted + /// for offsets. + final List _maps = []; + + /// Creates a section mapping from json. + MultiSectionMapping.fromJson(List sections, Map otherMaps) { + for (var section in sections) { + var offset = section['offset']; + if (offset == null) throw new FormatException('section missing offset'); + + var line = section['offset']['line']; + if (line == null) throw new FormatException('offset missing line'); + + var column = section['offset']['column']; + if (column == null) throw new FormatException('offset missing column'); + + _lineStart.add(line); + _columnStart.add(column); + + var url = section['url']; + var map = section['map']; + + if (url != null && map != null) { + throw new FormatException("section can't use both url and map entries"); + } else if (url != null) { + if (otherMaps == null || otherMaps[url] == null) { + throw new FormatException( + 'section contains refers to $url, but no map was ' + 'given for it. Make sure a map is passed in "otherMaps"'); + } + _maps.add(parseJson(otherMaps[url], otherMaps: otherMaps)); + } else if (map != null) { + _maps.add(parseJson(map, otherMaps: otherMaps)); + } else { + throw new FormatException('section missing url or map'); + } + } + if (_lineStart.length == 0) { + throw new FormatException('expected at least one section'); + } + } + + int _indexFor(line, column) { + for(int i = 0; i < _lineStart.length; i++) { + if (line < _lineStart[i]) return i - 1; + if (line == _lineStart[i] && column < _columnStart[i]) return i - 1; + } + return _lineStart.length - 1; + } + + Span spanFor(int line, int column, {Map files}) { + int index = _indexFor(line, column); + return _maps[index].spanFor( + line - _lineStart[index], column - _columnStart[index], files: files); + } + + String toString() { + var buff = new StringBuffer("$runtimeType : ["); + for (int i = 0; i < _lineStart.length; i++) { + buff..write('(') + ..write(_lineStart[i]) + ..write(',') + ..write(_columnStart[i]) + ..write(':') + ..write(_maps[i]) + ..write(')'); + } + buff.write(']'); + return buff.toString(); + } +} + +/// A map containing direct source mappings. +// TODO(sigmund): integrate mapping and sourcemap builder? +class SingleMapping extends Mapping { + /// Url of the target file. + final String targetUrl; + + /// Source urls used in the mapping, indexed by id. + final List urls; + + /// Source names used in the mapping, indexed by id. + final List names; + + /// Entries indicating the beginning of each span. + final List lines = []; + + SingleMapping.fromJson(Map map) + : targetUrl = map['file'], + // TODO(sigmund): add support for 'sourceRoot' + urls = map['sources'], + names = map['names'] { + int line = 0; + int column = 0; + int srcUrlId = 0; + int srcLine = 0; + int srcColumn = 0; + int srcNameId = 0; + var tokenizer = new _MappingTokenizer(map['mappings']); + var entries = []; + + while (tokenizer.hasTokens) { + if (tokenizer.nextKind.isNewLine) { + if (!entries.isEmpty) { + lines.add(new TargetLineEntry(line, entries)); + entries = []; + } + line++; + column = 0; + tokenizer._consumeNewLine(); + continue; + } + + // Decode the next entry, using the previous encountered values to + // decode the relative values. + // + // We expect 1, 4, or 5 values. If present, values are expected in the + // following order: + // 0: the starting column in the current line of the generated file + // 1: the id of the original source file + // 2: the starting line in the original source + // 3: the starting column in the original source + // 4: the id of the original symbol name + // The values are relative to the previous encountered values. + if (tokenizer.nextKind.isNewSegment) throw _segmentError(0, line); + column += tokenizer._consumeValue(); + if (!tokenizer.nextKind.isValue) { + entries.add(new TargetEntry(column)); + } else { + srcUrlId += tokenizer._consumeValue(); + if (srcUrlId >= urls.length) { + throw new StateError( + 'Invalid source url id. $targetUrl, $line, $srcUrlId'); + } + if (!tokenizer.nextKind.isValue) throw _segmentError(2, line); + srcLine += tokenizer._consumeValue(); + if (!tokenizer.nextKind.isValue) throw _segmentError(3, line); + srcColumn += tokenizer._consumeValue(); + if (!tokenizer.nextKind.isValue) { + entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn)); + } else { + srcNameId += tokenizer._consumeValue(); + if (srcNameId >= names.length) { + throw new StateError( + 'Invalid name id: $targetUrl, $line, $srcNameId'); + } + entries.add( + new TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId)); + } + } + if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment(); + } + if (!entries.isEmpty) { + lines.add(new TargetLineEntry(line, entries)); + } + } + + _segmentError(int seen, int line) => new StateError( + 'Invalid entry in sourcemap, expected 1, 4, or 5' + ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); + + /// Returns [TargetLineEntry] which includes the location in the target [line] + /// number. In particular, the resulting entry is the last entry whose line + /// number is lower or equal to [line]. + TargetLineEntry _findLine(int line) { + int index = binarySearch(lines, (e) => e.line > line); + return (index <= 0) ? null : lines[index - 1]; + } + + /// Returns [TargetEntry] which includes the location denoted by + /// [line], [column]. If [lineEntry] corresponds to [line], then this will be + /// the last entry whose column is lower or equal than [column]. If + /// [lineEntry] corresponds to a line prior to [line], then the result will be + /// the very last entry on that line. + TargetEntry _findColumn(int line, int column, TargetLineEntry lineEntry) { + if (lineEntry == null || lineEntry.entries.length == 0) return null; + if (lineEntry.line != line) return lineEntry.entries.last; + var entries = lineEntry.entries; + int index = binarySearch(entries, (e) => e.column > column); + return (index <= 0) ? null : entries[index - 1]; + } + + Span spanFor(int line, int column, {Map files}) { + var lineEntry = _findLine(line); + var entry = _findColumn(line, column, _findLine(line)); + if (entry == null) return null; + var url = urls[entry.sourceUrlId]; + if (files != null && files[url] != null) { + var file = files[url]; + var start = file.getOffset(entry.sourceLine, entry.sourceColumn); + if (entry.sourceNameId != null) { + var text = names[entry.sourceNameId]; + return new FileSpan(files[url], start, start + text.length, true); + } else { + return new FileSpan(files[url], start); + } + } else { + // Offset and other context is not available. + if (entry.sourceNameId != null) { + return new FixedSpan(url, 0, entry.sourceLine, entry.sourceColumn, + text: names[entry.sourceNameId], isIdentifier: true); + } else { + return new FixedSpan(url, 0, entry.sourceLine, entry.sourceColumn); + } + } + } + + String toString() { + return (new StringBuffer("$runtimeType : [") + ..write('targetUrl: ') + ..write(targetUrl) + ..write(', urls: ') + ..write(urls) + ..write(', names: ') + ..write(names) + ..write(', lines: ') + ..write(lines) + ..write(']')).toString(); + } + + String get debugString { + var buff = new StringBuffer(); + for (var lineEntry in lines) { + var line = lineEntry.line; + for (var entry in lineEntry.entries) { + buff..write(targetUrl) + ..write(': ') + ..write(line) + ..write(':') + ..write(entry.column) + ..write(' --> ') + ..write(urls[entry.sourceUrlId]) + ..write(': ') + ..write(entry.sourceLine) + ..write(':') + ..write(entry.sourceColumn); + if (entry.sourceNameId != null) { + buff..write(' (') + ..write(names[entry.sourceNameId]) + ..write(')'); + } + buff.write('\n'); + } + } + return buff.toString(); + } +} + +/// A line entry read from a source map. +class TargetLineEntry { + final int line; + List entries = []; + TargetLineEntry(this.line, this.entries); + + String toString() => '$runtimeType: $line $entries'; +} + +/// A target segment entry read from a source map +class TargetEntry { + final int column; + final int sourceUrlId; + final int sourceLine; + final int sourceColumn; + final int sourceNameId; + TargetEntry(this.column, [this.sourceUrlId, this.sourceLine, + this.sourceColumn, this.sourceNameId]); + + String toString() => '$runtimeType: ' + '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; +} + +/** A character iterator over a string that can peek one character ahead. */ +class _MappingTokenizer implements Iterator { + final String _internal; + final int _length; + int index = -1; + _MappingTokenizer(String internal) + : _internal = internal, + _length = internal.length; + + // Iterator API is used by decodeVlq to consume VLQ entries. + bool moveNext() => ++index < _length; + String get current => + (index >= 0 && index < _length) ? _internal[index] : null; + + bool get hasTokens => index < _length - 1 && _length > 0; + + _TokenKind get nextKind { + if (!hasTokens) return _TokenKind.EOF; + var next = _internal[index + 1]; + if (next == ';') return _TokenKind.LINE; + if (next == ',') return _TokenKind.SEGMENT; + return _TokenKind.VALUE; + } + + int _consumeValue() => decodeVlq(this); + void _consumeNewLine() { ++index; } + void _consumeNewSegment() { ++index; } + + // Print the state of the iterator, with colors indicating the current + // position. + String toString() { + var buff = new StringBuffer(); + for (int i = 0; i < index; i++) { + buff.write(_internal[i]); + } + buff.write(''); + buff.write(current == null ? '' : current); + buff.write(''); + for (int i = index + 1; i < _internal.length; i++) { + buff.write(_internal[i]); + } + buff.write(' ($index)'); + return buff.toString(); + } +} + +class _TokenKind { + static const _TokenKind LINE = const _TokenKind(isNewLine: true); + static const _TokenKind SEGMENT = const _TokenKind(isNewSegment: true); + static const _TokenKind EOF = const _TokenKind(isEof: true); + static const _TokenKind VALUE = const _TokenKind(); + final bool isNewLine; + final bool isNewSegment; + final bool isEof; + bool get isValue => !isNewLine && !isNewSegment && !isEof; + + const _TokenKind( + {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); +} diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart new file mode 100644 index 000000000..333aadcd4 --- /dev/null +++ b/pkgs/source_maps/lib/printer.dart @@ -0,0 +1,89 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Contains a code printer that generates code by recording the source maps. +library source_maps.printer; + +import 'dart:utf' show stringToCodepoints; +import 'builder.dart'; +import 'span.dart'; + +const int _LF = 10; +const int _CR = 13; + +/// A printer that keeps track of offset locations and records source maps +/// locations. +class Printer { + final String filename; + final StringBuffer _buff = new StringBuffer(); + final SourceMapBuilder _maps = new SourceMapBuilder(); + String get text => _buff.toString(); + String get map => _maps.toJson(filename); + + /// Current source location mapping. + Location _loc; + + /// Current line in the buffer; + int _line = 0; + + /// Current column in the buffer. + int _column = 0; + + Printer(this.filename); + + /// Add [str] contents to the output, tracking new lines to track correct + /// positions for span locations. When [projectMarks] is true, this method + /// adds a source map location on each new line, projecting that every new + /// line in the target file (printed here) corresponds to a new line in the + /// source file. + void add(String str, {projectMarks: false}) { + var chars = stringToCodepoints(str); + var length = chars.length; + for (int i = 0; i < length; i++) { + var c = chars[i]; + if (c == _LF || (c == _CR && (i + 1 == length || chars[i + 1] != _LF))) { + // Return not followed by line-feed is treated as a new line. + _line++; + _column = 0; + if (projectMarks && _loc != null) { + if (_loc is FixedLocation) { + mark(new FixedLocation(0, _loc.sourceUrl, _loc.line + 1, 0)); + } else if (_loc is FileLocation) { + var file = (_loc as FileLocation).file; + mark(new FileLocation(file, file.getOffset(_loc.line + 1, 0))); + } + } + } else { + _column++; + } + } + _buff.write(str); + } + + + /// Append a [total] number of spaces in the target file. Typically used for + /// formatting indentation. + void addSpaces(int total) { + for (int i = 0; i < total; i++) _buff.write(' '); + _column += total; + } + + /// Marks that the current point in the target file corresponds to the [mark] + /// in the source file, which can be either a [Location] or a [Span]. When the + /// mark is an identifier's Span, this also records the name of the identifier + /// in the source map information. + void mark(mark) { + var loc; + var identifier = null; + if (mark is Location) { + loc = mark; + } else if (mark is Span) { + loc = mark.start; + if (mark.isIdentifier) identifier = mark.text; + } + _maps.addLocation(loc, + new FixedLocation(_buff.length, null, _line, _column), identifier); + _loc = loc; + } +} diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart new file mode 100644 index 000000000..4e24deab5 --- /dev/null +++ b/pkgs/source_maps/lib/source_maps.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Source maps library. +/// +/// Create a source map using [SourceMapBuilder]. For example: +/// var json = (new SourceMapBuilder() +/// ..add(inputSpan1, outputSpan1) +/// ..add(inputSpan2, outputSpan2) +/// ..add(inputSpan3, outputSpan3) +/// .toJson(outputFile); +/// +/// Use the [Span] and [SourceFile] classes to specify span locations. +/// +/// Parse a source map using [parse], and call `spanFor` on the returned mapping +/// object. For example: +/// var mapping = parse(json); +/// mapping.spanFor(outputSpan1.line, outputSpan1.column) +library source_maps; + +export "builder.dart"; +export "parser.dart"; +export "printer.dart"; +export "span.dart"; diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart new file mode 100644 index 000000000..19829941f --- /dev/null +++ b/pkgs/source_maps/lib/span.dart @@ -0,0 +1,330 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Dart classes representing the souce spans and source files. +library source_maps.span; + +import 'dart:utf' show stringToCodepoints, codepointsToString; +import 'dart:math' show min; + +import 'src/utils.dart'; + +/// A simple class that describe a segment of source text. +abstract class Span implements Comparable { + /// The start location of this span. + final Location start; + + /// The end location of this span, exclusive. + final Location end; + + /// Url of the source (typically a file) containing this span. + String get sourceUrl => start.sourceUrl; + + /// The length of this span, in characters. + int get length => end.offset - start.offset; + + /// The source text for this span, if available. + String get text; + + /// Whether [text] corresponds to an identifier symbol. + final bool isIdentifier; + + Span(this.start, this.end, bool isIdentifier) + : isIdentifier = isIdentifier != null ? isIdentifier : false { + _checkRange(); + } + + /// Creates a new span that is the union of two existing spans [start] and + /// [end]. Note that the resulting span might contain some positions that were + /// not in either of the original spans if [start] and [end] are disjoint. + Span.union(Span start, Span end) + : start = start.start, end = end.end, isIdentifier = false { + _checkRange(); + } + + void _checkRange() { + if (start.offset < 0) throw new ArgumentError('start $start must be >= 0'); + if (end.offset < start.offset) { + throw new ArgumentError('end $end must be >= start $start'); + } + } + + /// Compares two spans. If the spans are not in the same source, this method + /// generates an error. + int compareTo(Span other) { + int d = start.compareTo(other.start); + return d == 0 ? end.compareTo(other.end) : d; + } + + /// Gets the location in standard printed form `filename:line:column`, where + /// line and column are adjusted by 1 to match the convention in editors. + String get formatLocation => start.formatString; + + String getLocationMessage(String message, + {bool useColors: false, String color}) { + return '$formatLocation: $message'; + } + + bool operator ==(Span other) => + sourceUrl == other.sourceUrl && start == other.start && end == other.end; + + String toString() => '<$runtimeType: $start $end $formatLocation $text>'; +} + +/// A location in the source text +abstract class Location implements Comparable { + /// Url of the source containing this span. + String get sourceUrl; + + /// The offset of this location, 0-based. + final int offset; + + /// The 0-based line in the source of this location. + int get line; + + /// The 0-based column in the source of this location. + int get column; + + Location(this.offset); + + /// Compares two locations. If the locations are not in the same source, this + /// method generates an error. + int compareTo(Location other) { + if (sourceUrl != other.sourceUrl) { + throw new ArgumentError('can only compare locations of the same source'); + } + return offset - other.offset; + } + + String toString() => '(Location $offset)'; + String get formatString => '$sourceUrl:${line + 1}:${column + 1}'; +} + +/// Implementation of [Location] with fixed values given at allocation time. +class FixedLocation extends Location { + final String sourceUrl; + final int line; + final int column; + + FixedLocation(int offset, this.sourceUrl, this.line, this.column) + : super(offset); +} + +/// Implementation of [Span] where all the values are given at allocation time. +class FixedSpan extends Span { + /// The source text for this span, if available. + final String text; + + /// Creates a span which starts and end in the same line. + FixedSpan(String sourceUrl, int start, int line, int column, + {String text: '', bool isIdentifier: false}) + : text = text, super(new FixedLocation(start, sourceUrl, line, column), + new FixedLocation(start + text.length, sourceUrl, line, + column + text.length), + isIdentifier); +} + +/// [Location] with values computed from an underling [SourceFile]. +class FileLocation extends Location { + /// The source file containing this location. + final SourceFile file; + + String get sourceUrl => file.url; + int get line => file.getLine(offset); + int get column => file.getColumn(line, offset); + + FileLocation(this.file, int offset): super(offset); +} + +/// [Span] where values are computed from an underling [SourceFile]. +class FileSpan extends Span { + /// The source file containing this span. + final SourceFile file; + + /// The source text for this span, if available. + String get text => file.getText(start.offset, end.offset); + + factory FileSpan(SourceFile file, int start, + [int end, bool isIdentifier = false]) { + var startLoc = new FileLocation(file, start); + var endLoc = end == null ? startLoc : new FileLocation(file, end); + return new FileSpan.locations(startLoc, endLoc, isIdentifier); + } + + FileSpan.locations(FileLocation start, FileLocation end, + bool isIdentifier) + : file = start.file, super(start, end, isIdentifier); + + /// Creates a new span that is the union of two existing spans [start] and + /// [end]. Note that the resulting span might contain some positions that were + /// not in either of the original spans if [start] and [end] are disjoint. + FileSpan.union(FileSpan start, FileSpan end) + : file = start.file, super.union(start, end) { + if (start.file != end.file) { + throw new ArgumentError('start and end must be from the same file'); + } + } + + String getLocationMessage(String message, + {bool useColors: false, String color}) { + return file.getLocationMessage(message, start.offset, end.offset, + useColors: useColors, color: color); + } +} + +// Constants to determine end-of-lines. +const int _LF = 10; +const int _CR = 13; + +// Color constants used for generating messages. +const String _RED_COLOR = '\u001b[31m'; +const String _NO_COLOR = '\u001b[0m'; + +/// Stores information about a source file, to permit computation of the line +/// and column. Also contains a nice default error message highlighting the code +/// location. +class SourceFile { + /// Url where the source file is located. + final String url; + final List _lineStarts; + final List _decodedChars; + + SourceFile(this.url, this._lineStarts, this._decodedChars); + + SourceFile.text(this.url, String text) + : _lineStarts = [0], + _decodedChars = stringToCodepoints(text) { + for (int i = 0; i < _decodedChars.length; i++) { + var c = _decodedChars[i]; + if (c == _CR) { + // Return not followed by newline is treated as a newline + int j = i + 1; + if (j >= _decodedChars.length || _decodedChars[j] != _LF) { + c = _LF; + } + } + if (c == _LF) _lineStarts.add(i + 1); + } + } + + /// Returns a span in this [SourceFile] with the given offsets. + Span span(int start, [int end, bool isIdentifier = false]) => + new FileSpan(this, start, end, isIdentifier); + + /// Returns a location in this [SourceFile] with the given offset. + Location location(int offset) => new FileLocation(this, offset); + + /// Gets the 0-based line corresponding to an offset. + int getLine(int offset) { + return binarySearch(_lineStarts, (o) => o > offset) - 1; + } + + /// Gets the 0-based column corresponding to an offset. + int getColumn(int line, int offset) { + return offset - _lineStarts[line]; + } + + /// Get the offset for a given line and column + int getOffset(int line, int column) { + return _lineStarts[min(line, _lineStarts.length - 1)] + column; + } + + /// Gets the text at the given offsets. + String getText(int start, [int end]) { + return codepointsToString(_decodedChars.sublist(start, end)); + } + + /// Create a pretty string representation from a span. + String getLocationMessage(String message, int start, int end, + {bool useColors: false, String color}) { + // TODO(jmesserly): it would be more useful to pass in an object that + // controls how the errors are printed. This method is a bit too smart. + var line = getLine(start); + var column = getColumn(line, start); + + var src = url == null ? '' : url; + var msg = '$src:${line + 1}:${column + 1}: $message'; + + if (_decodedChars == null) { + // We don't have any text to include, so exit. + return msg; + } + + var buf = new StringBuffer(msg); + buf.write('\n'); + var textLine; + + // +1 for 0-indexing, +1 again to avoid the last line + if ((line + 2) < _lineStarts.length) { + textLine = getText(_lineStarts[line], _lineStarts[line + 1]); + } else { + textLine = getText(_lineStarts[line]); + textLine = '$textLine\n'; + } + + int toColumn = min(column + end - start, textLine.length); + if (useColors) { + if (color == null) { + color = _RED_COLOR; + } + buf.write(textLine.substring(0, column)); + buf.write(color); + buf.write(textLine.substring(column, toColumn)); + buf.write(_NO_COLOR); + buf.write(textLine.substring(toColumn)); + } else { + buf.write(textLine); + } + + int i = 0; + for (; i < column; i++) { + buf.write(' '); + } + + if (useColors) buf.write(color); + for (; i < toColumn; i++) { + buf.write('^'); + } + if (useColors) buf.write(_NO_COLOR); + return buf.toString(); + } +} + +/// A convenience type to treat a code segment as if it were a separate +/// [SourceFile]. A [SourceFileSegment] shifts all locations by an offset, which +/// allows you to set source-map locations based on the locations relative to +/// the start of the segment, but that get translated to absolute locations in +/// the original source file. +class SourceFileSegment extends SourceFile { + final int _baseOffset; + final int _baseLine; + final int _baseColumn; + + SourceFileSegment(String url, String textSegment, Location startOffset) + : _baseOffset = startOffset.offset, + _baseLine = startOffset.line, + _baseColumn = startOffset.column, + super.text(url, textSegment); + + Span span(int start, [int end, bool isIdentifier = false]) => + super.span(start + _baseOffset, + end == null ? null : end + _baseOffset, isIdentifier); + + Location location(int offset) => super.location(offset + _baseOffset); + + int getLine(int offset) => + super.getLine(offset - _baseOffset) + _baseLine; + + int getColumn(int line, int offset) { + var col = super.getColumn(line - _baseLine, offset - _baseOffset); + return line == _baseLine ? col + _baseColumn : col; + } + + int getOffset(int line, int column) => + super.getOffset(line - _baseLine, + line == _baseLine ? column - _baseColumn : column) + _baseOffset; + + String getText(int start, [int end]) => + super.getText(start - _baseOffset, end - _baseOffset); +} diff --git a/pkgs/source_maps/lib/src/utils.dart b/pkgs/source_maps/lib/src/utils.dart new file mode 100644 index 000000000..78f098e70 --- /dev/null +++ b/pkgs/source_maps/lib/src/utils.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Utilities that shouldn't be in this package. +library source_maps.utils; + +/// Find the first entry in a sorted [list] that matches a monotonic predicate. +/// Given a result `n`, that all items before `n` will not match, `n` matches, +/// and all items after `n` match too. The result is -1 when there are no +/// items, 0 when all items match, and list.length when none does. +// TODO(sigmund): remove this function after dartbug.com/5624 is fixed. +int binarySearch(List list, bool matches(item)) { + if (list.length == 0) return -1; + if (matches(list.first)) return 0; + if (!matches(list.last)) return list.length; + + int min = 0; + int max = list.length - 1; + while (min < max) { + var half = min + ((max - min) ~/ 2); + if (matches(list[half])) { + max = half; + } else { + min = half + 1; + } + } + return max; +} diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart new file mode 100644 index 000000000..e4ab4eb69 --- /dev/null +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -0,0 +1,103 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + + +/// Utilities to encode and decode VLQ values used in source maps. +/// +/// Sourcemaps are encoded with variable length numbers as base64 encoded +/// strings with the least significant digit coming first. Each base64 digit +/// encodes a 5-bit value (0-31) and a continuation bit. Signed values can be +/// represented by using the least significant bit of the value as the sign bit. +/// +/// For more details see the source map [version 3 documentation][spec]. +/// [spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit +library source_maps.src.vlq; + +import 'dart:math'; + +const int VLQ_BASE_SHIFT = 5; + +const int VLQ_BASE_MASK = (1 << 5) - 1; + +const int VLQ_CONTINUATION_BIT = 1 << 5; + +const int VLQ_CONTINUATION_MASK = 1 << 5; + +const String BASE64_DIGITS = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + +final Map _digits = () { + var map = {}; + for (int i = 0; i < 64; i++) { + map[BASE64_DIGITS[i]] = i; + } + return map; +}(); + +final int MAX_INT32 = pow(2, 31) - 1; +final int MIN_INT32 = -pow(2, 31); + +/// Creates the VLQ encoding of [value] as a sequence of characters +Iterable encodeVlq(int value) { + if (value < MIN_INT32 || value > MAX_INT32) { + throw new ArgumentError('expected 32 bit int, got: $value'); + } + var res = []; + int signBit = 0; + if (value < 0) { + signBit = 1; + value = -value; + } + value = (value << 1) | signBit; + do { + int digit = value & VLQ_BASE_MASK; + value >>= VLQ_BASE_SHIFT; + if (value > 0) { + digit |= VLQ_CONTINUATION_BIT; + } + res.add(BASE64_DIGITS[digit]); + } while (value > 0); + return res; +} + +/// Decodes a value written as a sequence of VLQ characters. The first input +/// character will be `chars.current` after calling `chars.moveNext` once. The +/// iterator is advanced until a stop character is found (a character without +/// the [VLQ_CONTINUATION_BIT]). +int decodeVlq(Iterator chars) { + int result = 0; + bool stop = false; + int shift = 0; + while (!stop) { + if (!chars.moveNext()) throw new StateError('incomplete VLQ value'); + var char = chars.current; + if (!_digits.containsKey(char)) { + throw new FormatException('invalid character in VLQ encoding: $char'); + } + var digit = _digits[char]; + stop = (digit & VLQ_CONTINUATION_BIT) == 0; + digit &= VLQ_BASE_MASK; + result += (digit << shift); + shift += VLQ_BASE_SHIFT; + } + + // Result uses the least significant bit as a sign bit. We convert it into a + // two-complement value. For example, + // 2 (10 binary) becomes 1 + // 3 (11 binary) becomes -1 + // 4 (100 binary) becomes 2 + // 5 (101 binary) becomes -2 + // 6 (110 binary) becomes 3 + // 7 (111 binary) becomes -3 + bool negate = (result & 1) == 1; + result = result >> 1; + result = negate ? -result : result; + + // TODO(sigmund): can we detect this earlier? + if (result < MIN_INT32 || result > MAX_INT32) { + throw new FormatException( + 'expected an encoded 32 bit int, but we got: $result'); + } + return result; +} diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml new file mode 100644 index 000000000..a559b5850 --- /dev/null +++ b/pkgs/source_maps/pubspec.yaml @@ -0,0 +1,6 @@ +name: source_maps +author: "Dart Team " +homepage: https://github.com/dart-lang/source-maps +description: Library to programmatically manipulate source map files. +dev_dependencies: + unittest: any diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart new file mode 100644 index 000000000..7bf2ee424 --- /dev/null +++ b/pkgs/source_maps/test/builder_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.source_maps_test; + +import 'dart:json' as json; +import 'package:unittest/unittest.dart'; +import 'package:source_maps/source_maps.dart'; +import 'common.dart'; + +main() { + test('builder - with span', () { + var map = (new SourceMapBuilder() + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) + .build(output.url); + expect(map, equals(EXPECTED_MAP)); + }); + + test('builder - with location', () { + var str = (new SourceMapBuilder() + ..addLocation(inputVar1.start, outputVar1.start, 'longVar1') + ..addLocation(inputFunction.start, outputFunction.start, 'longName') + ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') + ..addLocation(inputExpr.start, outputExpr.start, null)) + .toJson(output.url); + expect(str, json.stringify(EXPECTED_MAP)); + }); +} diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart new file mode 100644 index 000000000..661979b85 --- /dev/null +++ b/pkgs/source_maps/test/common.dart @@ -0,0 +1,97 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Common input/output used by builder, parser and end2end tests +library test.common; + +import 'package:source_maps/source_maps.dart'; +import 'package:unittest/unittest.dart'; + +/// Content of the source file +const String INPUT = ''' +/** this is a comment. */ +int longVar1 = 3; + +// this is a comment too +int longName(int longVar2) { + return longVar1 + longVar2; +} +'''; +var input = new SourceFile.text('input.dart', INPUT); + +/// A span in the input file +Span ispan(int start, int end, [bool isIdentifier = false]) => + new FileSpan(input, start, end, isIdentifier); + +Span inputVar1 = ispan(30, 38, true); +Span inputFunction = ispan(74, 82, true); +Span inputVar2 = ispan(87, 95, true); +Span inputExpr = ispan(108, 127); + +/// Content of the target file +const String OUTPUT = ''' +var x = 3; +f(y) => x + y; +'''; +var output = new SourceFile.text('output.dart', OUTPUT); + +/// A span in the output file +Span ospan(int start, int end, [bool isIdentifier = false]) => + new FileSpan(output, start, end, isIdentifier); + +Span outputVar1 = ospan(4, 5, true); +Span outputFunction = ospan(11, 12, true); +Span outputVar2 = ospan(13, 14, true); +Span outputExpr = ospan(19, 24); + +/// Expected output mapping when recording the following four mappings: +/// inputVar1 <= outputVar1 +/// inputFunction <= outputFunction +/// inputVar2 <= outputVar2 +/// inputExpr <= outputExpr +/// +/// This mapping is stored in the tests so we can independently test the builder +/// and parser algorithms without relying entirely on end2end tests. +const Map EXPECTED_MAP = const { + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const ['longVar1','longName','longVar2'], + 'mappings': 'IACIA;AAGAC,EAAaC,MACR', + 'file': 'output.dart' +}; + +check(Span outputSpan, Mapping mapping, Span inputSpan, bool realOffsets) { + var line = outputSpan.start.line; + var column = outputSpan.start.column; + var files = realOffsets ? {'input.dart': input} : null; + var span = mapping.spanFor(line, column, files: files); + var span2 = mapping.spanForLocation(outputSpan.start, files: files); + + // Both mapping APIs are equivalent. + expect(span.start.offset, span2.start.offset); + expect(span.start.line, span2.start.line); + expect(span.start.column, span2.start.column); + expect(span.end.offset, span2.end.offset); + expect(span.end.line, span2.end.line); + expect(span.end.column, span2.end.column); + + // Mapping matches our input location (modulo using real offsets) + expect(span.start.line, inputSpan.start.line); + expect(span.start.column, inputSpan.start.column); + expect(span.sourceUrl, inputSpan.sourceUrl); + expect(span.start.offset, realOffsets ? inputSpan.start.offset : 0); + + // Mapping includes the identifier, if any + if (inputSpan.isIdentifier) { + expect(span.end.line, inputSpan.end.line); + expect(span.end.column, inputSpan.end.column); + expect(span.end.offset, span.start.offset + inputSpan.text.length); + if (realOffsets) expect(span.end.offset, inputSpan.end.offset); + } else { + expect(span.end.offset, span.start.offset); + expect(span.end.line, span.start.line); + expect(span.end.column, span.start.column); + } +} diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart new file mode 100644 index 000000000..5ea958a98 --- /dev/null +++ b/pkgs/source_maps/test/end2end_test.dart @@ -0,0 +1,106 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.end2end_test; + +import 'package:unittest/unittest.dart'; +import 'package:source_maps/source_maps.dart'; +import 'common.dart'; + +main() { + test('end-to-end setup', () { + expect(inputVar1.text, 'longVar1'); + expect(inputFunction.text, 'longName'); + expect(inputVar2.text, 'longVar2'); + expect(inputExpr.text, 'longVar1 + longVar2'); + + expect(outputVar1.text, 'x'); + expect(outputFunction.text, 'f'); + expect(outputVar2.text, 'y'); + expect(outputExpr.text, 'x + y'); + }); + + test('build + parse', () { + var map = (new SourceMapBuilder() + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) + .build(output.url); + var mapping = parseJson(map); + check(outputVar1, mapping, inputVar1, false); + check(outputVar2, mapping, inputVar2, false); + check(outputFunction, mapping, inputFunction, false); + check(outputExpr, mapping, inputExpr, false); + }); + + test('build + parse with file', () { + var json = (new SourceMapBuilder() + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) + .toJson(output.url); + var mapping = parse(json); + check(outputVar1, mapping, inputVar1, true); + check(outputVar2, mapping, inputVar2, true); + check(outputFunction, mapping, inputFunction, true); + check(outputExpr, mapping, inputExpr, true); + }); + + test('printer projecting marks + parse', () { + var out = INPUT.replaceAll('long', '_s'); + var file = new SourceFile.text('output2.dart', out); + var printer = new Printer('output2.dart'); + printer.mark(ispan(0, 0)); + + bool first = true; + var segments = INPUT.split('long'); + expect(segments.length, 6); + printer.add(segments[0], projectMarks: true); + printer.mark(inputVar1); + printer.add('_s'); + printer.add(segments[1], projectMarks: true); + printer.mark(inputFunction); + printer.add('_s'); + printer.add(segments[2], projectMarks: true); + printer.mark(inputVar2); + printer.add('_s'); + printer.add(segments[3], projectMarks: true); + printer.mark(inputExpr); + printer.add('_s'); + printer.add(segments[4], projectMarks: true); + printer.add('_s'); + printer.add(segments[5], projectMarks: true); + + expect(printer.text, out); + + var mapping = parse(printer.map); + checkHelper(Span inputSpan, int adjustment) { + var start = inputSpan.start.offset - adjustment; + var end = (inputSpan.end.offset - adjustment) - 2; + var span = new FileSpan(file, start, end, inputSpan.isIdentifier); + check(span, mapping, inputSpan, true); + } + + checkHelper(inputVar1, 0); + checkHelper(inputFunction, 2); + checkHelper(inputVar2, 4); + checkHelper(inputExpr, 6); + + // We projected correctly lines that have no mappings + check(new FileSpan(file, 66, 66, false), mapping, ispan(45, 45), true); + check(new FileSpan(file, 63, 64, false), mapping, ispan(45, 45), true); + check(new FileSpan(file, 68, 68, false), mapping, ispan(70, 70), true); + check(new FileSpan(file, 71, 71, false), mapping, ispan(70, 70), true); + + // Start of the last line + var oOffset = out.length - 2; + var iOffset = INPUT.length - 2; + check(new FileSpan(file, oOffset, oOffset, false), mapping, + ispan(iOffset, iOffset), true); + check(new FileSpan(file, oOffset + 1, oOffset + 1, false), mapping, + ispan(iOffset, iOffset), true); + }); +} diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart new file mode 100644 index 000000000..1c32cbd34 --- /dev/null +++ b/pkgs/source_maps/test/parser_test.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.parser_test; + +import 'dart:json' as json; +import 'package:unittest/unittest.dart'; +import 'package:source_maps/source_maps.dart'; +import 'common.dart'; + +main() { + test('parse', () { + var mapping = parseJson(EXPECTED_MAP); + check(outputVar1, mapping, inputVar1, false); + check(outputVar2, mapping, inputVar2, false); + check(outputFunction, mapping, inputFunction, false); + check(outputExpr, mapping, inputExpr, false); + }); + + test('parse + json', () { + var mapping = parse(json.stringify(EXPECTED_MAP)); + check(outputVar1, mapping, inputVar1, false); + check(outputVar2, mapping, inputVar2, false); + check(outputFunction, mapping, inputFunction, false); + check(outputExpr, mapping, inputExpr, false); + }); + + test('parse with file', () { + var mapping = parseJson(EXPECTED_MAP); + check(outputVar1, mapping, inputVar1, true); + check(outputVar2, mapping, inputVar2, true); + check(outputFunction, mapping, inputFunction, true); + check(outputExpr, mapping, inputExpr, true); + }); +} diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart new file mode 100644 index 000000000..d038ad51b --- /dev/null +++ b/pkgs/source_maps/test/printer_test.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.printer_test; + +import 'dart:json' as json; +import 'package:unittest/unittest.dart'; +import 'package:source_maps/printer.dart'; +import 'package:source_maps/span.dart'; +import 'common.dart'; + +main() { + test('printer', () { + var printer = new Printer('output.dart'); + printer..add('var ') + ..mark(inputVar1) + ..add('x = 3;\n') + ..mark(inputFunction) + ..add('f(') + ..mark(inputVar2) + ..add('y) => ') + ..mark(inputExpr) + ..add('x + y;\n'); + expect(printer.text, OUTPUT); + expect(printer.map, json.stringify(EXPECTED_MAP)); + }); + + test('printer projecting marks', () { + var out = INPUT.replaceAll('long', '_s'); + var printer = new Printer('output2.dart'); + + var segments = INPUT.split('long'); + expect(segments.length, 6); + printer..mark(ispan(0, 0)) + ..add(segments[0], projectMarks: true) + ..mark(inputVar1) + ..add('_s') + ..add(segments[1], projectMarks: true) + ..mark(inputFunction) + ..add('_s') + ..add(segments[2], projectMarks: true) + ..mark(inputVar2) + ..add('_s') + ..add(segments[3], projectMarks: true) + ..mark(inputExpr) + ..add('_s') + ..add(segments[4], projectMarks: true) + ..add('_s') + ..add(segments[5], projectMarks: true); + + expect(printer.text, out); + // 8 new lines in the source map: + expect(printer.map.split(';').length, 8); + + asFixed(Span s) => new FixedSpan(s.sourceUrl, + s.start.offset, s.start.line, s.start.column, + text: s.text, isIdentifier: s.isIdentifier); + + // The result is the same if we use fixed positions + var printer2 = new Printer('output2.dart'); + printer2..mark(new FixedSpan('input.dart', 0, 0, 0)) + ..add(segments[0], projectMarks: true) + ..mark(asFixed(inputVar1)) + ..add('_s') + ..add(segments[1], projectMarks: true) + ..mark(asFixed(inputFunction)) + ..add('_s') + ..add(segments[2], projectMarks: true) + ..mark(asFixed(inputVar2)) + ..add('_s') + ..add(segments[3], projectMarks: true) + ..mark(asFixed(inputExpr)) + ..add('_s') + ..add(segments[4], projectMarks: true) + ..add('_s') + ..add(segments[5], projectMarks: true); + + expect(printer2.text, out); + expect(printer2.map, printer.map); + }); +} diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart new file mode 100755 index 000000000..9a197855f --- /dev/null +++ b/pkgs/source_maps/test/run.dart @@ -0,0 +1,38 @@ +#!/usr/bin/env dart +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.run; + +import 'package:unittest/compact_vm_config.dart'; +import 'package:unittest/unittest.dart'; +import 'dart:io' show Options; + +import 'builder_test.dart' as builder_test; +import 'end2end_test.dart' as end2end_test; +import 'parser_test.dart' as parser_test; +import 'printer_test.dart' as printer_test; +import 'span_test.dart' as span_test; +import 'utils_test.dart' as utils_test; +import 'vlq_test.dart' as vlq_test; + +main() { + var args = new Options().arguments; + var pattern = new RegExp(args.length > 0 ? args[0] : '.'); + useCompactVMConfiguration(); + + void addGroup(testFile, testMain) { + if (pattern.hasMatch(testFile)) { + group(testFile.replaceAll('_test.dart', ':'), testMain); + } + } + + addGroup('builder_test.dart', builder_test.main); + addGroup('end2end_test.dart', end2end_test.main); + addGroup('parser_test.dart', parser_test.main); + addGroup('printer_test.dart', printer_test.main); + addGroup('span_test.dart', span_test.main); + addGroup('utils_test.dart', utils_test.main); + addGroup('vlq_test.dart', vlq_test.main); +} diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart new file mode 100644 index 000000000..8f61b5871 --- /dev/null +++ b/pkgs/source_maps/test/span_test.dart @@ -0,0 +1,215 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.span_test; + +import 'package:unittest/unittest.dart'; +import 'package:source_maps/span.dart'; + +const String TEST_FILE = ''' ++23456789_ + + _123456789_123456789_123456789_123456789_123456789_123456789_123456789_ + + _123456789_1 +123+56789_123456789_1234567 +1234+6789_1234 +12345+789_123456789_12345 +123456+89_123456789_123456789_123456789_123456789_123456789_123456789_123456789 +1234567+9_123456789_123456789_123456789_123456789_123456789_123456789_123 +12345678+_123456789_123456789_123456789_123456789_1 +123456789+123456789_123456789_12345678 +123456789_+23456789_123456789_123456789_123 +123456789_1+3456789_123456789 +'''; + +List newLines = TEST_FILE.split('\n').map((s) => s.length).toList(); + +main() { + var file = new SourceFile.text('file', TEST_FILE); + span(int start, int end) => file.span(start, end); + loc(int offset) => file.location(offset); + + test('validate test input', () { + expect(newLines, + const [10, 80, 31, 27, 14, 25, 79, 73, 51, 38, 43, 29, 0]); + }); + + test('get line and column', () { + line(int n) => file.getLine(n); + col(int n) => file.getColumn(file.getLine(n), n); + + expect(line(8), 0); + expect(line(10), 0); + expect(line(11), 1); + expect(line(12), 1); + expect(line(91), 1); + expect(line(92), 2); + expect(line(93), 2); + expect(col(11), 0); + expect(col(12), 1); + expect(col(91), 80); + expect(col(92), 0); + expect(col(93), 1); + + int j = 0; + int lineOffset = 0; + for (int i = 0; i < TEST_FILE.length; i++) { + if (i > lineOffset + newLines[j]) { + lineOffset += newLines[j] + 1; + j++; + } + expect(line(i), j, reason: 'position: $i'); + expect(col(i), i - lineOffset, reason: 'position: $i'); + } + }); + + test('get text', () { + // fifth line (including 4 new lines), columns 2 .. 11 + var line = 10 + 80 + 31 + 27 + 4; + expect(file.getText(line + 2, line + 11), '34+6789_1'); + }); + + test('get location message', () { + // fifth line (including 4 new lines), columns 2 .. 11 + var line = 10 + 80 + 31 + 27 + 4; + expect(file.getLocationMessage('the message', line + 2, line + 11), + 'file:5:3: the message\n' + '1234+6789_1234\n' + ' ^^^^^^^^^'); + }); + + test('get location message - no file url', () { + var line = 10 + 80 + 31 + 27 + 4; + expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( + 'the message', line + 2, line + 11), + ':5:3: the message\n' + '1234+6789_1234\n' + ' ^^^^^^^^^'); + }); + + test('location getters', () { + expect(loc(8).line, 0); + expect(loc(8).column, 8); + expect(loc(9).line, 0); + expect(loc(9).column, 9); + expect(loc(8).formatString, 'file:1:9'); + expect(loc(12).line, 1); + expect(loc(12).column, 1); + expect(loc(95).line, 2); + expect(loc(95).column, 3); + }); + + test('location compare', () { + var list = [9, 8, 11, 14, 6, 6, 1, 1].map((n) => loc(n)).toList(); + list.sort(); + var lastOffset = 0; + for (var location in list) { + expect(location.offset, greaterThanOrEqualTo(lastOffset)); + lastOffset = location.offset; + } + }); + + test('span getters', () { + expect(span(8, 9).start.line, 0); + expect(span(8, 9).start.column, 8); + expect(span(8, 9).end.line, 0); + expect(span(8, 9).end.column, 9); + expect(span(8, 9).text, '9'); + expect(span(8, 9).isIdentifier, false); + expect(span(8, 9).formatLocation, 'file:1:9'); + + var line = 10 + 80 + 31 + 27 + 4; + expect(span(line + 2, line + 11).getLocationMessage('the message'), + 'file:5:3: the message\n' + '1234+6789_1234\n' + ' ^^^^^^^^^'); + + expect(span(12, 95).start.line, 1); + expect(span(12, 95).start.column, 1); + expect(span(12, 95).end.line, 2); + expect(span(12, 95).end.column, 3); + expect(span(12, 95).text, + '+ _123456789_123456789_123456789_123456789_123456789_1234567' + '89_123456789_\n +'); + expect(span(12, 95).formatLocation, 'file:2:2'); + }); + + test('span union', () { + var union = new FileSpan.union(span(8, 9), span(12, 95)); + expect(union.start.offset, 8); + expect(union.start.line, 0); + expect(union.start.column, 8); + expect(union.end.offset, 95); + expect(union.end.line, 2); + expect(union.end.column, 3); + expect(union.text, + '9_\n' + ' + _123456789_123456789_123456789_123456789_123456789_' + '123456789_123456789_\n +'); + expect(union.formatLocation, 'file:1:9'); + }); + + test('span compare', () { + var list = [span(9, 10), span(8, 9), span(11, 12), span(14, 19), + span(6, 12), span(6, 8), span(1, 9), span(1, 2)]; + list.sort(); + var lastStart = 0; + var lastEnd = 0; + for (var span in list) { + expect(span.start.offset, greaterThanOrEqualTo(lastStart)); + if (span.start.offset == lastStart) { + expect(span.end.offset, greaterThanOrEqualTo(lastEnd)); + } + lastStart = span.start.offset; + lastEnd = span.end.offset; + } + }); + + test('file segment', () { + var segment = new SourceFileSegment('file', + TEST_FILE.substring(12), loc(12)); + sline(int n) => segment.getLine(n); + scol(int n) => segment.getColumn(segment.getLine(n), n); + + line(int n) => file.getLine(n); + col(int n) => file.getColumn(file.getLine(n), n); + + int j = 0; + int lineOffset = 0; + for (int i = 12; i < TEST_FILE.length; i++) { + if (i > lineOffset + newLines[j]) { + lineOffset += newLines[j] + 1; + j++; + } + expect(segment.location(i - 12).offset, i); + expect(segment.location(i - 12).line, line(i)); + expect(segment.location(i - 12).column, col(i)); + expect(segment.span(i - 12).start.offset, i); + expect(segment.span(i - 12).start.line, line(i)); + expect(segment.span(i - 12).start.column, col(i)); + + expect(sline(i), line(i)); + expect(scol(i), col(i)); + } + }); + + test('span isIdentifier defaults to false', () { + var start = new TestLocation(0); + var end = new TestLocation(1); + expect(new TestSpan(start, end).isIdentifier, false); + expect(file.span(8, 9, null).isIdentifier, false); + expect(new FixedSpan('', 8, 1, 8, isIdentifier: null).isIdentifier, false); + }); +} + +class TestSpan extends Span { + TestSpan(Location start, Location end) : super(start, end, null); + get text => null; +} + +class TestLocation extends Location { + String get sourceUrl => ''; + TestLocation(int offset) : super(offset); + get line => 0; + get column => 0; +} diff --git a/pkgs/source_maps/test/utils_test.dart b/pkgs/source_maps/test/utils_test.dart new file mode 100644 index 000000000..79a7de769 --- /dev/null +++ b/pkgs/source_maps/test/utils_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Tests for the binary search utility algorithm. +library test.utils_test; + +import 'package:unittest/unittest.dart'; +import 'package:source_maps/src/utils.dart'; + +main() { + group('binary search', () { + test('empty', () { + expect(binarySearch([], (x) => true), -1); + }); + + test('single element', () { + expect(binarySearch([1], (x) => true), 0); + expect(binarySearch([1], (x) => false), 1); + }); + + test('no matches', () { + var list = [1, 2, 3, 4, 5, 6, 7]; + expect(binarySearch(list, (x) => false), list.length); + }); + + test('all match', () { + var list = [1, 2, 3, 4, 5, 6, 7]; + expect(binarySearch(list, (x) => true), 0); + }); + + test('compare with linear search', () { + for (int size = 0; size < 100; size++) { + var list = []; + for (int i = 0; i < size; i++) { + list.add(i); + } + for (int pos = 0; pos <= size; pos++) { + expect(binarySearch(list, (x) => x >= pos), + _linearSearch(list, (x) => x >= pos)); + } + } + }); + }); +} + +_linearSearch(list, predicate) { + if (list.length == 0) return -1; + for (int i = 0; i < list.length; i++) { + if (predicate(list[i])) return i; + } + return list.length; +} + diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart new file mode 100644 index 000000000..0abdc4795 --- /dev/null +++ b/pkgs/source_maps/test/vlq_test.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library test.vlq_test; + +import 'dart:math'; +import 'package:unittest/unittest.dart'; +import 'package:source_maps/src/vlq.dart'; + +main() { + test('encode and decode - simple values', () { + expect(encodeVlq(1).join(''), 'C'); + expect(encodeVlq(2).join(''), 'E'); + expect(encodeVlq(3).join(''), 'G'); + expect(encodeVlq(100).join(''), 'oG'); + expect(decodeVlq('C'.split('').iterator), 1); + expect(decodeVlq('E'.split('').iterator), 2); + expect(decodeVlq('G'.split('').iterator), 3); + expect(decodeVlq('oG'.split('').iterator), 100); + }); + + test('encode and decode', () { + for (int i = -10000; i < 10000; i++) { + _checkEncodeDecode(i); + } + }); + + test('only 32-bit ints allowed', () { + var max_int = pow(2, 31) - 1; + var min_int = -pow(2, 31); + _checkEncodeDecode(max_int - 1); + _checkEncodeDecode(min_int + 1); + _checkEncodeDecode(max_int); + _checkEncodeDecode(min_int); + + expect(encodeVlq(min_int).join(''), 'hgggggE'); + expect(decodeVlq('hgggggE'.split('').iterator), min_int); + + expect(() => encodeVlq(max_int + 1), throws); + expect(() => encodeVlq(max_int + 2), throws); + expect(() => encodeVlq(min_int - 1), throws); + expect(() => encodeVlq(min_int - 2), throws); + + + // if we allowed more than 32 bits, these would be the expected encodings + // for the large numbers above. + expect(() => decodeVlq('ggggggE'.split('').iterator), throws); + expect(() => decodeVlq('igggggE'.split('').iterator), throws); + expect(() => decodeVlq('jgggggE'.split('').iterator), throws); + expect(() => decodeVlq('lgggggE'.split('').iterator), throws); + }); +} + +_checkEncodeDecode(int value) { + var encoded = encodeVlq(value); + expect(decodeVlq(encoded.iterator), value); + expect(decodeVlq(encoded.join('').split('').iterator), value); +} From 909880414b99eda0198faf70567ddb6ec4db90c6 Mon Sep 17 00:00:00 2001 From: "kevmoo@j832.com" Date: Tue, 9 Apr 2013 13:51:05 +0000 Subject: [PATCH 002/133] lib/utf: remove codepointsToString point folks to use String.fromCharCodes Review URL: https://codereview.chromium.org//13493020 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@21151 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 19829941f..fd302bcb6 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -5,7 +5,7 @@ /// Dart classes representing the souce spans and source files. library source_maps.span; -import 'dart:utf' show stringToCodepoints, codepointsToString; +import 'dart:utf' show stringToCodepoints; import 'dart:math' show min; import 'src/utils.dart'; @@ -232,7 +232,7 @@ class SourceFile { /// Gets the text at the given offsets. String getText(int start, [int end]) { - return codepointsToString(_decodedChars.sublist(start, end)); + return new String.fromCharCodes(_decodedChars.sublist(start, end)); } /// Create a pretty string representation from a span. From 5fd76a732b3f5c43480c0e97ce4426f8b3a21c22 Mon Sep 17 00:00:00 2001 From: "sethladd@google.com" Date: Fri, 19 Apr 2013 20:51:10 +0000 Subject: [PATCH 003/133] add installation instructions to pkg packages BUG= Review URL: https://codereview.chromium.org//14188048 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@21770 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/source_maps.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 4e24deab5..15948276f 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -4,6 +4,21 @@ /// Source maps library. /// +/// ## Installing ## +/// +/// Use [pub][] to install this package. Add the following to your +/// `pubspec.yaml` file. +/// +/// dependencies: +/// source_maps: any +/// +/// Then run `pub install`. +/// +/// For more information, see the +/// [source_maps package on pub.dartlang.org][pkg]. +/// +/// ## Using ## +/// /// Create a source map using [SourceMapBuilder]. For example: /// var json = (new SourceMapBuilder() /// ..add(inputSpan1, outputSpan1) @@ -17,6 +32,9 @@ /// object. For example: /// var mapping = parse(json); /// mapping.spanFor(outputSpan1.line, outputSpan1.column) +/// +/// [pub]: http://pub.dartlang.org +/// [pkg]: http://pub.dartlang.org/packages/source_maps library source_maps; export "builder.dart"; From 2dc1edc3352223c21a082066cadc9c3b6ab9d370 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Wed, 3 Jul 2013 22:26:55 +0000 Subject: [PATCH 004/133] Fixes source map bug: getLocationMessage was incorrect on file segments R=jmesserly@google.com Review URL: https://codereview.chromium.org//18083030 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@24759 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 58 +++++++++------ pkgs/source_maps/test/span_test.dart | 104 +++++++++++++++++++++------ 2 files changed, 119 insertions(+), 43 deletions(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index fd302bcb6..e7bf5bfa4 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -6,7 +6,7 @@ library source_maps.span; import 'dart:utf' show stringToCodepoints; -import 'dart:math' show min; +import 'dart:math' show min, max; import 'src/utils.dart'; @@ -216,24 +216,18 @@ class SourceFile { Location location(int offset) => new FileLocation(this, offset); /// Gets the 0-based line corresponding to an offset. - int getLine(int offset) { - return binarySearch(_lineStarts, (o) => o > offset) - 1; - } + int getLine(int offset) => binarySearch(_lineStarts, (o) => o > offset) - 1; /// Gets the 0-based column corresponding to an offset. - int getColumn(int line, int offset) { - return offset - _lineStarts[line]; - } + int getColumn(int line, int offset) => offset - _lineStarts[line]; /// Get the offset for a given line and column - int getOffset(int line, int column) { - return _lineStarts[min(line, _lineStarts.length - 1)] + column; - } + int getOffset(int line, int column) => + _lineStarts[max(min(line, _lineStarts.length - 1), 0)] + column; /// Gets the text at the given offsets. - String getText(int start, [int end]) { - return new String.fromCharCodes(_decodedChars.sublist(start, end)); - } + String getText(int start, [int end]) => + new String.fromCharCodes(_decodedChars.sublist(max(start, 0), end)); /// Create a pretty string representation from a span. String getLocationMessage(String message, int start, int end, @@ -253,16 +247,12 @@ class SourceFile { var buf = new StringBuffer(msg); buf.write('\n'); - var textLine; // +1 for 0-indexing, +1 again to avoid the last line - if ((line + 2) < _lineStarts.length) { - textLine = getText(_lineStarts[line], _lineStarts[line + 1]); - } else { - textLine = getText(_lineStarts[line]); - textLine = '$textLine\n'; - } + var textLine = getText(getOffset(line, 0), getOffset(line + 1, 0)); + + column = min(column, textLine.length - 1); int toColumn = min(column + end - start, textLine.length); if (useColors) { if (color == null) { @@ -301,30 +291,52 @@ class SourceFileSegment extends SourceFile { final int _baseLine; final int _baseColumn; + // TODO(sigmund): consider providing an end-offset to correctly truncate + // values passed the end of the segment. SourceFileSegment(String url, String textSegment, Location startOffset) : _baseOffset = startOffset.offset, _baseLine = startOffset.line, _baseColumn = startOffset.column, super.text(url, textSegment); + /// Craete a span, where [start] is relative to this segment's base offset. + /// The returned span stores the real offset on the file, so that error + /// messages are reported at the real location. Span span(int start, [int end, bool isIdentifier = false]) => super.span(start + _baseOffset, end == null ? null : end + _baseOffset, isIdentifier); + /// Create a location, where [offset] relative to this segment's base offset. + /// The returned span stores the real offset on the file, so that error + /// messages are reported at the real location. Location location(int offset) => super.location(offset + _baseOffset); + /// Return the line on the underlying file associated with the [offset] of the + /// underlying file. This method operates on the real offsets from the + /// original file, so that error messages can be reported accurately. int getLine(int offset) => - super.getLine(offset - _baseOffset) + _baseLine; + super.getLine(max(offset - _baseOffset, 0)) + _baseLine; + /// Return the column on the underlying file associated with [line] and + /// [offset], where [line] is absolute from the beginning of the underlying + /// file. This method operates on the real offsets from the original file, so + /// that error messages can be reported accurately. int getColumn(int line, int offset) { - var col = super.getColumn(line - _baseLine, offset - _baseOffset); + var col = super.getColumn(line - _baseLine, max(offset - _baseOffset, 0)); return line == _baseLine ? col + _baseColumn : col; } + /// Return the offset associated with a line and column. This method operates + /// on the real offsets from the original file, so that error messages can be + /// reported accurately. int getOffset(int line, int column) => super.getOffset(line - _baseLine, line == _baseLine ? column - _baseColumn : column) + _baseOffset; + /// Retrieve the text associated with the specified range. This method + /// operates on the real offsets from the original file, so that error + /// messages can be reported accurately. String getText(int start, [int end]) => - super.getText(start - _baseOffset, end - _baseOffset); + super.getText(start - _baseOffset, + end == null ? null : end - _baseOffset); } diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index 8f61b5871..66bd8a8cb 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -165,32 +165,96 @@ main() { } }); - test('file segment', () { - var segment = new SourceFileSegment('file', - TEST_FILE.substring(12), loc(12)); + test('range check for large offsets', () { + var start = TEST_FILE.length; + expect(file.getLocationMessage('the message', start, start + 9), + 'file:13:1: the message\n'); + }); + + group('file segment', () { + var baseOffset = 123; + var segmentText = TEST_FILE.substring(baseOffset, TEST_FILE.length - 100); + var segment = new SourceFileSegment('file', segmentText, loc(baseOffset)); sline(int n) => segment.getLine(n); scol(int n) => segment.getColumn(segment.getLine(n), n); - line(int n) => file.getLine(n); col(int n) => file.getColumn(file.getLine(n), n); - int j = 0; - int lineOffset = 0; - for (int i = 12; i < TEST_FILE.length; i++) { - if (i > lineOffset + newLines[j]) { - lineOffset += newLines[j] + 1; - j++; + test('get line and column', () { + int j = 0; + int lineOffset = 0; + for (int i = baseOffset; i < segmentText.length; i++) { + if (i > lineOffset + newLines[j]) { + lineOffset += newLines[j] + 1; + j++; + } + expect(segment.location(i - baseOffset).offset, i); + expect(segment.location(i - baseOffset).line, line(i)); + expect(segment.location(i - baseOffset).column, col(i)); + expect(segment.span(i - baseOffset).start.offset, i); + expect(segment.span(i - baseOffset).start.line, line(i)); + expect(segment.span(i - baseOffset).start.column, col(i)); + + expect(sline(i), line(i)); + expect(scol(i), col(i)); } - expect(segment.location(i - 12).offset, i); - expect(segment.location(i - 12).line, line(i)); - expect(segment.location(i - 12).column, col(i)); - expect(segment.span(i - 12).start.offset, i); - expect(segment.span(i - 12).start.line, line(i)); - expect(segment.span(i - 12).start.column, col(i)); - - expect(sline(i), line(i)); - expect(scol(i), col(i)); - } + }); + + test('get text', () { + var start = 10 + 80 + 31 + 27 + 4 + 2; + expect(segment.getText(start, start + 9), file.getText(start, start + 9)); + }); + + group('location message', () { + test('first line', () { + var start = baseOffset + 7; + expect(segment.getLocationMessage('the message', start, start + 2), + file.getLocationMessage('the message', start, start + 2)); + }); + + test('in a middle line', () { + // Example from another test above: + var start = 10 + 80 + 31 + 27 + 4 + 2; + expect(segment.getLocationMessage('the message', start, start + 9), + file.getLocationMessage('the message', start, start + 9)); + }); + + test('last segment line', () { + var start = segmentText.length - 4; + expect(segment.getLocationMessage('the message', start, start + 2), + file.getLocationMessage('the message', start, start + 2)); + }); + + test('past segment, same as last segment line', () { + var start = segmentText.length; + expect(segment.getLocationMessage('the message', start, start + 2), + file.getLocationMessage('the message', start, start + 2)); + + start = segmentText.length + 20; + expect(segment.getLocationMessage('the message', start, start + 2), + file.getLocationMessage('the message', start, start + 2)); + }); + + test('past segment, past its line', () { + var start = TEST_FILE.length - 2; + expect(file.getLocationMessage('the message', start, start + 1), + 'file:12:29: the message\n' + '123456789_1+3456789_123456789\n' + ' ^'); + + // TODO(sigmund): consider also fixing this and report file:10:4 + // The answer below is different because the segment parsing only knows + // about the 10 lines it has (and nothing about the possible extra lines + // afterwards) + expect(segment.getLocationMessage('the message', start, start + 1), + 'file:10:112: the message\n'); + + // The number 112 includes the count of extra characters past the + // segment, which we verify here: + var lastSegmentLineStart = segmentText.lastIndexOf('\n'); + expect(start - baseOffset - lastSegmentLineStart, 112); + }); + }); }); test('span isIdentifier defaults to false', () { From d98bf46e00969efa5fe10d99d479bf2d006bca9e Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Wed, 10 Jul 2013 16:56:00 +0000 Subject: [PATCH 005/133] Fixes in sourcemaps discovered in csslib R=dgrove@google.com Review URL: https://codereview.chromium.org//18749005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@24881 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 38 +++++++---- pkgs/source_maps/test/span_test.dart | 96 +++++++++++++++++++++------- 2 files changed, 99 insertions(+), 35 deletions(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index e7bf5bfa4..7ca0ca97c 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -219,11 +219,20 @@ class SourceFile { int getLine(int offset) => binarySearch(_lineStarts, (o) => o > offset) - 1; /// Gets the 0-based column corresponding to an offset. - int getColumn(int line, int offset) => offset - _lineStarts[line]; + int getColumn(int line, int offset) { + if (line < 0 || line >= _lineStarts.length) return 0; + return offset - _lineStarts[line]; + } /// Get the offset for a given line and column - int getOffset(int line, int column) => - _lineStarts[max(min(line, _lineStarts.length - 1), 0)] + column; + int getOffset(int line, int column) { + if (line < 0) return getOffset(0, 0); + if (line < _lineStarts.length) { + return _lineStarts[line] + column; + } else { + return _decodedChars.length; + } + } /// Gets the text at the given offsets. String getText(int start, [int end]) => @@ -251,7 +260,6 @@ class SourceFile { // +1 for 0-indexing, +1 again to avoid the last line var textLine = getText(getOffset(line, 0), getOffset(line + 1, 0)); - column = min(column, textLine.length - 1); int toColumn = min(column + end - start, textLine.length); if (useColors) { @@ -265,6 +273,7 @@ class SourceFile { buf.write(textLine.substring(toColumn)); } else { buf.write(textLine); + if (textLine != '' && !textLine.endsWith('\n')) buf.write('\n'); } int i = 0; @@ -290,13 +299,13 @@ class SourceFileSegment extends SourceFile { final int _baseOffset; final int _baseLine; final int _baseColumn; + final int _maxOffset; - // TODO(sigmund): consider providing an end-offset to correctly truncate - // values passed the end of the segment. SourceFileSegment(String url, String textSegment, Location startOffset) : _baseOffset = startOffset.offset, _baseLine = startOffset.line, _baseColumn = startOffset.column, + _maxOffset = startOffset.offset + textSegment.length, super.text(url, textSegment); /// Craete a span, where [start] is relative to this segment's base offset. @@ -313,9 +322,13 @@ class SourceFileSegment extends SourceFile { /// Return the line on the underlying file associated with the [offset] of the /// underlying file. This method operates on the real offsets from the - /// original file, so that error messages can be reported accurately. - int getLine(int offset) => - super.getLine(max(offset - _baseOffset, 0)) + _baseLine; + /// original file, so that error messages can be reported accurately. When the + /// requested offset is past the length of the segment, this returns the line + /// number after the end of the segment (total lines + 1). + int getLine(int offset) { + var res = super.getLine(max(offset - _baseOffset, 0)) + _baseLine; + return (offset > _maxOffset) ? res + 1 : res; + } /// Return the column on the underlying file associated with [line] and /// [offset], where [line] is absolute from the beginning of the underlying @@ -330,13 +343,12 @@ class SourceFileSegment extends SourceFile { /// on the real offsets from the original file, so that error messages can be /// reported accurately. int getOffset(int line, int column) => - super.getOffset(line - _baseLine, - line == _baseLine ? column - _baseColumn : column) + _baseOffset; + super.getOffset(line - _baseLine, + line == _baseLine ? column - _baseColumn : column) + _baseOffset; /// Retrieve the text associated with the specified range. This method /// operates on the real offsets from the original file, so that error /// messages can be reported accurately. String getText(int start, [int end]) => - super.getText(start - _baseOffset, - end == null ? null : end - _baseOffset); + super.getText(start - _baseOffset, end == null ? null : end - _baseOffset); } diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index 66bd8a8cb..c7b9cde16 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -69,22 +69,80 @@ main() { expect(file.getText(line + 2, line + 11), '34+6789_1'); }); - test('get location message', () { - // fifth line (including 4 new lines), columns 2 .. 11 - var line = 10 + 80 + 31 + 27 + 4; - expect(file.getLocationMessage('the message', line + 2, line + 11), - 'file:5:3: the message\n' - '1234+6789_1234\n' - ' ^^^^^^^^^'); - }); + group('location message', () { + test('first line', () { + expect(file.getLocationMessage('the message', 1, 3), + 'file:1:2: the message\n' + '+23456789_\n' + ' ^^'); + }); - test('get location message - no file url', () { - var line = 10 + 80 + 31 + 27 + 4; - expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( - 'the message', line + 2, line + 11), - ':5:3: the message\n' - '1234+6789_1234\n' - ' ^^^^^^^^^'); + test('in the middle of the file', () { + // fifth line (including 4 new lines), columns 2 .. 11 + var line = 10 + 80 + 31 + 27 + 4; + expect(file.getLocationMessage('the message', line + 2, line + 11), + 'file:5:3: the message\n' + '1234+6789_1234\n' + ' ^^^^^^^^^'); + }); + + test('no file url', () { + var line = 10 + 80 + 31 + 27 + 4; + expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( + 'the message', line + 2, line + 11), + ':5:3: the message\n' + '1234+6789_1234\n' + ' ^^^^^^^^^'); + }); + + test('penultimate line', () { + // We search '\n' backwards twice because last line is \n terminated: + int index = TEST_FILE.lastIndexOf('\n'); + var start = TEST_FILE.lastIndexOf('\n', index - 1) - 3; + expect(file.getLocationMessage('the message', start, start + 2), + 'file:11:41: the message\n' + '123456789_+23456789_123456789_123456789_123\n' + ' ^^'); + }); + + test('last line', () { + var start = TEST_FILE.lastIndexOf('\n') - 2; + expect(file.getLocationMessage('the message', start, start + 1), + 'file:12:28: the message\n' + '123456789_1+3456789_123456789\n' + ' ^'); + }); + + group('no trailing empty-line at the end -', () { + var text = TEST_FILE.substring(0, TEST_FILE.length - 1); + var file2 = new SourceFile.text('file', text); + + test('penultimate line', () { + var start = text.lastIndexOf('\n') - 3; + expect(file2.getLocationMessage('the message', start, start + 2), + 'file:11:41: the message\n' + '123456789_+23456789_123456789_123456789_123\n' + ' ^^'); + }); + + test('last line', () { + var start = text.length - 2; + expect(file2.getLocationMessage('the message', start, start + 1), + 'file:12:28: the message\n' + '123456789_1+3456789_123456789\n' + ' ^'); + }); + }); + + test('single line', () { + var text = "this is a single line"; + int start = text.indexOf(' ') + 1; + var file2 = new SourceFile.text('file', text); + expect(file2.getLocationMessage('the message', start, start + 2), + 'file:1:${start + 1}: the message\n' + 'this is a single line\n' + ' ^^'); + }); }); test('location getters', () { @@ -242,17 +300,11 @@ main() { '123456789_1+3456789_123456789\n' ' ^'); - // TODO(sigmund): consider also fixing this and report file:10:4 // The answer below is different because the segment parsing only knows // about the 10 lines it has (and nothing about the possible extra lines // afterwards) expect(segment.getLocationMessage('the message', start, start + 1), - 'file:10:112: the message\n'); - - // The number 112 includes the count of extra characters past the - // segment, which we verify here: - var lastSegmentLineStart = segmentText.lastIndexOf('\n'); - expect(start - baseOffset - lastSegmentLineStart, 112); + 'file:11:1: the message\n'); }); }); }); From 920ff12d6c4a697a78929afad50744723202dbd4 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 12 Jul 2013 23:14:38 +0000 Subject: [PATCH 006/133] Fix bug in source-maps parsing: parser failed when most information could be inferred. This fixes bug http://dartbug.com/11782 R=dgrove@google.com Review URL: https://codereview.chromium.org//19019006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@24981 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/builder.dart | 18 +++++--- pkgs/source_maps/lib/parser.dart | 11 +++-- pkgs/source_maps/lib/source_maps.dart | 31 +++++++------- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/common.dart | 8 ++++ pkgs/source_maps/test/end2end_test.dart | 55 +++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 28 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index ad80fa000..be00c9e81 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -74,12 +74,20 @@ class SourceMapBuilder { first = false; column = _append(buff, column, entry.target.column); - if (entry.source == null) continue; + // Encoding can be just the column offset if there is no source + // information, or if two consecutive mappings share exactly the same + // source information. + var source = entry.source; + if (source == null) continue; + var newUrlId = _indexOf(_urls, source.sourceUrl); + if (newUrlId == srcUrlId && source.line == srcLine + && source.column == srcColumn && entry.identifierName == null) { + continue; + } - srcUrlId = _append(buff, srcUrlId, - _indexOf(_urls, entry.source.sourceUrl)); - srcLine = _append(buff, srcLine, entry.source.line); - srcColumn = _append(buff, srcColumn, entry.source.column); + srcUrlId = _append(buff, srcUrlId, newUrlId); + srcLine = _append(buff, srcLine, source.line); + srcColumn = _append(buff, srcColumn, source.column); if (entry.identifierName == null) continue; srcNameId = _append(buff, srcNameId, diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 3849913a3..e2932634f 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -25,9 +25,8 @@ Mapping parseJson(Map map, {Map otherMaps}) { 'Only version 3 is supported.'); } - // TODO(sigmund): relax this? dart2js doesn't generate the file entry. if (!map.containsKey('file')) { - throw new ArgumentError('missing "file" in source map'); + print('warning: missing "file" entry in source map'); } if (map.containsKey('sections')) { @@ -186,7 +185,7 @@ class SingleMapping extends Mapping { if (tokenizer.nextKind.isNewSegment) throw _segmentError(0, line); column += tokenizer._consumeValue(); if (!tokenizer.nextKind.isValue) { - entries.add(new TargetEntry(column)); + entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn)); } else { srcUrlId += tokenizer._consumeValue(); if (srcUrlId >= urls.length) { @@ -242,7 +241,6 @@ class SingleMapping extends Mapping { } Span spanFor(int line, int column, {Map files}) { - var lineEntry = _findLine(line); var entry = _findColumn(line, column, _findLine(line)); if (entry == null) return null; var url = urls[entry.sourceUrlId]; @@ -323,8 +321,9 @@ class TargetEntry { final int sourceLine; final int sourceColumn; final int sourceNameId; - TargetEntry(this.column, [this.sourceUrlId, this.sourceLine, - this.sourceColumn, this.sourceNameId]); + + TargetEntry(this.column, this.sourceUrlId, this.sourceLine, + this.sourceColumn, [this.sourceNameId]); String toString() => '$runtimeType: ' '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 15948276f..8fc48c996 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -2,22 +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. -/// Source maps library. -/// -/// ## Installing ## -/// -/// Use [pub][] to install this package. Add the following to your -/// `pubspec.yaml` file. -/// -/// dependencies: -/// source_maps: any -/// -/// Then run `pub install`. -/// -/// For more information, see the -/// [source_maps package on pub.dartlang.org][pkg]. -/// -/// ## Using ## +/// Library to create and parse source maps. /// /// Create a source map using [SourceMapBuilder]. For example: /// var json = (new SourceMapBuilder() @@ -33,6 +18,20 @@ /// var mapping = parse(json); /// mapping.spanFor(outputSpan1.line, outputSpan1.column) /// +/// ## Getting the code ## +/// +/// This library is distributed as a [pub][] package. To install this package, +/// add the following to your `pubspec.yaml` file: +/// +/// dependencies: +/// source_maps: any +/// +/// After you run `pub install`, you should be able to access this library by +/// importing `package:source_maps/source_maps.dart`. +/// +/// For more information, see the +/// [source_maps package on pub.dartlang.org][pkg]. +/// /// [pub]: http://pub.dartlang.org /// [pkg]: http://pub.dartlang.org/packages/source_maps library source_maps; diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index a559b5850..4ae180291 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,6 +1,6 @@ name: source_maps author: "Dart Team " -homepage: https://github.com/dart-lang/source-maps +homepage: http://www.dartlang.org description: Library to programmatically manipulate source map files. dev_dependencies: unittest: any diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 661979b85..0c1f28a74 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -27,6 +27,11 @@ Span ispan(int start, int end, [bool isIdentifier = false]) => Span inputVar1 = ispan(30, 38, true); Span inputFunction = ispan(74, 82, true); Span inputVar2 = ispan(87, 95, true); + +Span inputVar1NoSymbol = ispan(30, 38); +Span inputFunctionNoSymbol = ispan(74, 82); +Span inputVar2NoSymbol = ispan(87, 95); + Span inputExpr = ispan(108, 127); /// Content of the target file @@ -43,6 +48,9 @@ Span ospan(int start, int end, [bool isIdentifier = false]) => Span outputVar1 = ospan(4, 5, true); Span outputFunction = ospan(11, 12, true); Span outputVar2 = ospan(13, 14, true); +Span outputVar1NoSymbol = ospan(4, 5); +Span outputFunctionNoSymbol = ospan(11, 12); +Span outputVar2NoSymbol = ospan(13, 14); Span outputExpr = ospan(19, 24); /// Expected output mapping when recording the following four mappings: diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 5ea958a98..99fe40d40 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -13,11 +13,17 @@ main() { expect(inputVar1.text, 'longVar1'); expect(inputFunction.text, 'longName'); expect(inputVar2.text, 'longVar2'); + expect(inputVar1NoSymbol.text, 'longVar1'); + expect(inputFunctionNoSymbol.text, 'longName'); + expect(inputVar2NoSymbol.text, 'longVar2'); expect(inputExpr.text, 'longVar1 + longVar2'); expect(outputVar1.text, 'x'); expect(outputFunction.text, 'f'); expect(outputVar2.text, 'y'); + expect(outputVar1NoSymbol.text, 'x'); + expect(outputFunctionNoSymbol.text, 'f'); + expect(outputVar2NoSymbol.text, 'y'); expect(outputExpr.text, 'x + y'); }); @@ -35,6 +41,55 @@ main() { check(outputExpr, mapping, inputExpr, false); }); + test('build + parse - no symbols', () { + var map = (new SourceMapBuilder() + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputExpr, outputExpr)) + .build(output.url); + var mapping = parseJson(map); + check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); + check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); + check(outputFunctionNoSymbol, mapping, inputFunctionNoSymbol, false); + check(outputExpr, mapping, inputExpr, false); + }); + + test('build + parse, repeated entries', () { + var map = (new SourceMapBuilder() + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr) + ..addSpan(inputExpr, outputExpr)) + .build(output.url); + var mapping = parseJson(map); + check(outputVar1, mapping, inputVar1, false); + check(outputVar2, mapping, inputVar2, false); + check(outputFunction, mapping, inputFunction, false); + check(outputExpr, mapping, inputExpr, false); + }); + + test('build + parse - no symbols, repeated entries', () { + var map = (new SourceMapBuilder() + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputExpr, outputExpr)) + .build(output.url); + var mapping = parseJson(map); + check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); + check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); + check(outputFunctionNoSymbol, mapping, inputFunctionNoSymbol, false); + check(outputExpr, mapping, inputExpr, false); + }); + test('build + parse with file', () { var json = (new SourceMapBuilder() ..addSpan(inputVar1, outputVar1) From f6c5549cb063f3d01ce165b10996e08f8fbf6a2c Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Tue, 16 Jul 2013 16:01:36 +0000 Subject: [PATCH 007/133] Address hint discovered by dart2js: add hashCode to source_maps.Span R=dgrove@google.com Review URL: https://codereview.chromium.org//19315003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@25050 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 7ca0ca97c..1d2152da7 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -69,6 +69,8 @@ abstract class Span implements Comparable { bool operator ==(Span other) => sourceUrl == other.sourceUrl && start == other.start && end == other.end; + int get hashCode => sourceUrl.hashCode + start + (31 * (end - start)); + String toString() => '<$runtimeType: $start $end $formatLocation $text>'; } From df5c29e07cb327774f9312aab07da86b9f37a097 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 26 Jul 2013 00:50:29 +0000 Subject: [PATCH 008/133] Fix source spans hashcode implementation R=justinfagnani@google.com Review URL: https://codereview.chromium.org//20600002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@25514 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 7 ++++++- pkgs/source_maps/test/span_test.dart | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 1d2152da7..e5057fceb 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -69,7 +69,7 @@ abstract class Span implements Comparable { bool operator ==(Span other) => sourceUrl == other.sourceUrl && start == other.start && end == other.end; - int get hashCode => sourceUrl.hashCode + start + (31 * (end - start)); + int get hashCode => sourceUrl.hashCode + start.offset + (31 * length); String toString() => '<$runtimeType: $start $end $formatLocation $text>'; } @@ -99,6 +99,11 @@ abstract class Location implements Comparable { return offset - other.offset; } + bool operator ==(Location other) => + sourceUrl == other.sourceUrl && offset == other.offset; + + int get hashCode => sourceUrl.hashCode + offset; + String toString() => '(Location $offset)'; String get formatString => '$sourceUrl:${line + 1}:${column + 1}'; } diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index c7b9cde16..da3e063ef 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -316,6 +316,16 @@ main() { expect(file.span(8, 9, null).isIdentifier, false); expect(new FixedSpan('', 8, 1, 8, isIdentifier: null).isIdentifier, false); }); + + test('span/location implement == and hashCode', () { + expect(identical(span(10, 14), span(10, 14)), isFalse); + expect(span(10, 14), equals(span(10, 14))); + expect(span(10, 14).hashCode, span(10, 14).hashCode); + + expect(identical(loc(13), loc(13)), isFalse); + expect(loc(13), equals(loc(13))); + expect(loc(13).hashCode, loc(13).hashCode); + }); } class TestSpan extends Span { From 889b8ab4291d2a3ac434b79dcd071d8fe798c01d Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 9 Aug 2013 22:29:38 +0000 Subject: [PATCH 009/133] Make observable transform a barback transform. R=jmesserly@google.com, nweiz@google.com, rnystrom@google.com Review URL: https://codereview.chromium.org//22396004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@25985 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/printer.dart | 160 ++++++++++++++++++++++- pkgs/source_maps/lib/refactor.dart | 131 +++++++++++++++++++ pkgs/source_maps/lib/source_maps.dart | 1 + pkgs/source_maps/test/printer_test.dart | 40 ++++++ pkgs/source_maps/test/refactor_test.dart | 96 ++++++++++++++ pkgs/source_maps/test/run.dart | 2 + 6 files changed, 428 insertions(+), 2 deletions(-) create mode 100644 pkgs/source_maps/lib/refactor.dart create mode 100644 pkgs/source_maps/test/refactor_test.dart diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 333aadcd4..95539d2b7 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -12,8 +12,8 @@ import 'span.dart'; const int _LF = 10; const int _CR = 13; -/// A printer that keeps track of offset locations and records source maps -/// locations. +/// A simple printer that keeps track of offset locations and records source +/// maps locations. class Printer { final String filename; final StringBuffer _buff = new StringBuffer(); @@ -87,3 +87,159 @@ class Printer { _loc = loc; } } + +/// A more advanced printer that keeps track of offset locations to record +/// source maps, but additionally allows nesting of different kind of items, +/// including [NestedPrinter]s, and it let's you automatically indent text. +/// +/// This class is especially useful when doing code generation, where different +/// peices of the code are generated independently on separate printers, and are +/// finally put together in the end. +class NestedPrinter implements NestedItem { + + /// Items recoded by this printer, which can be [String] literals, + /// [NestedItem]s, and source map information like [Location] and [Span]. + List _items = []; + + /// Internal buffer to merge consecutive strings added to this printer. + StringBuffer _buff; + + /// Current indentation, which can be updated from outside this class. + int indent; + + /// Item used to indicate that the following item is copied from the original + /// source code, and hence we should preserve source-maps on every new line. + static final _ORIGINAL = new Object(); + + NestedPrinter([this.indent = 0]); + + /// Adds [object] to this printer. [object] can be a [String], + /// [NestedPrinter], or anything implementing [NestedItem]. If [object] is a + /// [String], the value is appended directly, without doing any formatting + /// changes. If you wish to add a line of code with automatic indentation, use + /// [addLine] instead. [NestedPrinter]s and [NestedItem]s are not processed + /// until [build] gets called later on. We ensure that [build] emits every + /// object in the order that they were added to this printer. + /// + /// The [location] and [span] parameters indicate the corresponding source map + /// location of [object] in the original input. Only one, [location] or + /// [span], should be provided at a time. + /// + /// Indicate [isOriginal] when [object] is copied directly from the user code. + /// Setting [isOriginal] will make this printer propagate source map locations + /// on every line-break. + void add(object, {Location location, Span span, bool isOriginal: false}) { + if (object is! String || location != null || span != null || isOriginal) { + _flush(); + assert(location == null || span == null); + if (location != null) _items.add(location); + if (span != null) _items.add(span); + if (isOriginal) _items.add(_ORIGINAL); + } + + if (object is String) { + _appendString(object); + } else { + _items.add(object); + } + } + + /// Append `2 * indent` spaces to this printer. + void insertIndent() => _indent(indent); + + /// Add a [line], autoindenting to the current value of [indent]. Note, + /// indentation is not inferred from the contents added to this printer. If a + /// line starts or ends an indentation block, you need to also update [indent] + /// accordingly. Also, indentation is not adapted for nested printers. If + /// you add a [NestedPrinter] to this printer, its indentation is set + /// separately and will not include any the indentation set here. + /// + /// The [location] and [span] parameters indicate the corresponding source map + /// location of [object] in the original input. Only one, [location] or + /// [span], should be provided at a time. + void addLine(String line, {Location location, Span span}) { + if (location != null || span != null) { + _flush(); + assert(location == null || span == null); + if (location != null) _items.add(location); + if (span != null) _items.add(span); + } + if (line == null) return; + if (line != '') { + // We don't indent empty lines. + _indent(indent); + _appendString(line); + } + _appendString('\n'); + } + + /// Appends a string merging it with any previous strings, if possible. + void _appendString(String s) { + if (_buff == null) _buff = new StringBuffer(); + _buff.write(s); + } + + /// Adds all of the current [_buff] contents as a string item. + void _flush() { + if (_buff != null) { + _items.add(_buff.toString()); + _buff = null; + } + } + + void _indent(int indent) { + for (int i = 0; i < indent; i++) _appendString(' '); + } + + /// Returns a string representation of all the contents appended to this + /// printer, including source map location tokens. + String toString() { + _flush(); + return (new StringBuffer()..writeAll(_items)).toString(); + } + + /// [Printer] used during the last call to [build], if any. + Printer printer; + + /// Returns the text produced after calling [build]. + String get text => printer.text; + + /// Returns the source-map information produced after calling [build]. + String get map => printer.map; + + /// Builds the output of this printer and source map information. After + /// calling this function, you can use [text] and [map] to retrieve the + /// geenrated code and source map information, respectively. + void build(String filename) { + writeTo(printer = new Printer(filename)); + } + + /// Implements the [NestedItem] interface. + void writeTo(Printer printer) { + _flush(); + bool propagate = false; + for (var item in _items) { + if (item is NestedItem) { + item.writeTo(printer); + } else if (item is String) { + printer.add(item, projectMarks: propagate); + propagate = false; + } else if (item is Location || item is Span) { + printer.mark(item); + } else if (item == _ORIGINAL) { + // we insert booleans when we are about to quote text that was copied + // from the original source. In such case, we will propagate marks on + // every new-line. + propagate = true; + } else { + throw new UnsupportedError('Unknown item type: $item'); + } + } + } +} + +/// An item added to a [NestedPrinter]. +abstract class NestedItem { + /// Write the contents of this item into [printer]. + void writeTo(Printer printer); +} diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart new file mode 100644 index 000000000..45fb06949 --- /dev/null +++ b/pkgs/source_maps/lib/refactor.dart @@ -0,0 +1,131 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Tools to help implement refactoring like transformations to Dart code. +/// +/// [TextEditTransaction] supports making a series of changes to a text buffer. +/// [guessIndent] helps to guess the appropriate indentiation for the new code. +library source_maps.refactor; + +import 'span.dart'; +import 'printer.dart'; + +/// Editable text transaction. +/// +/// Applies a series of edits using original location +/// information, and composes them into the edited string. +class TextEditTransaction { + final SourceFile file; + final String original; + final _edits = <_TextEdit>[]; + + TextEditTransaction(this.original, this.file); + + bool get hasEdits => _edits.length > 0; + + /// Edit the original text, replacing text on the range [begin] and [end] + /// with the [replacement]. [replacement] can be either a string or a + /// [NestedPrinter]. + void edit(int begin, int end, replacement) { + _edits.add(new _TextEdit(begin, end, replacement)); + } + + /// Create a source map [Location] for [offset]. + Location _loc(int offset) => + file != null ? file.location(offset) : null; + + /// Applies all pending [edit]s and returns a [NestedPrinter] containing the + /// rewritten string and source map information. [filename] is given to the + /// underlying printer to indicate the name of the generated file that will + /// contains the source map information. + /// + /// Throws [UnsupportedError] if the edits were overlapping. If no edits were + /// made, the printer simply contains the original string. + NestedPrinter commit() { + var printer = new NestedPrinter(); + if (_edits.length == 0) { + return printer..add(original, location: _loc(0), isOriginal: true); + } + + // Sort edits by start location. + _edits.sort(); + + int consumed = 0; + for (var edit in _edits) { + if (consumed > edit.begin) { + var sb = new StringBuffer(); + sb..write(file.location(edit.begin).formatString) + ..write(': overlapping edits. Insert at offset ') + ..write(edit.begin) + ..write(' but have consumed ') + ..write(consumed) + ..write(' input characters. List of edits:'); + for (var e in _edits) sb..write('\n ')..write(e); + throw new UnsupportedError(sb.toString()); + } + + // Add characters from the original string between this edit and the last + // one, if any. + var betweenEdits = original.substring(consumed, edit.begin); + printer..add(betweenEdits, location: _loc(consumed), isOriginal: true) + ..add(edit.replace, location: _loc(edit.begin)); + consumed = edit.end; + } + + // Add any text from the end of the original string that was not replaced. + printer.add(original.substring(consumed), + location: _loc(consumed), isOriginal: true); + return printer; + } +} + +class _TextEdit implements Comparable<_TextEdit> { + final int begin; + final int end; + + /// The replacement used by the edit, can be a string or a [NestedPrinter]. + final replace; + + _TextEdit(this.begin, this.end, this.replace); + + int get length => end - begin; + + String toString() => '(Edit @ $begin,$end: "$replace")'; + + int compareTo(_TextEdit other) { + int diff = begin - other.begin; + if (diff != 0) return diff; + return end - other.end; + } +} + +/// Returns all whitespace characters at the start of [charOffset]'s line. +String guessIndent(String code, int charOffset) { + // Find the beginning of the line + int lineStart = 0; + for (int i = charOffset - 1; i >= 0; i--) { + var c = code.codeUnitAt(i); + if (c == _LF || c == _CR) { + lineStart = i + 1; + break; + } + } + + // Grab all the whitespace + int whitespaceEnd = code.length; + for (int i = lineStart; i < code.length; i++) { + var c = code.codeUnitAt(i); + if (c != _SPACE && c != _TAB) { + whitespaceEnd = i; + break; + } + } + + return code.substring(lineStart, whitespaceEnd); +} + +const int _CR = 13; +const int _LF = 10; +const int _TAB = 9; +const int _SPACE = 32; diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 8fc48c996..2d4a4ccc4 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -39,4 +39,5 @@ library source_maps; export "builder.dart"; export "parser.dart"; export "printer.dart"; +export "refactor.dart"; export "span.dart"; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index d038ad51b..06bed5768 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -79,4 +79,44 @@ main() { expect(printer2.text, out); expect(printer2.map, printer.map); }); + + group('nested printer', () { + test('simple use', () { + var printer = new NestedPrinter(); + printer..add('var ') + ..add('x = 3;\n', location: inputVar1) + ..add('f(', location: inputFunction) + ..add('y) => ', location: inputVar2) + ..add('x + y;\n', location: inputExpr) + ..build('output.dart'); + expect(printer.text, OUTPUT); + expect(printer.map, json.stringify(EXPECTED_MAP)); + }); + + test('nested use', () { + var printer = new NestedPrinter(); + printer..add('var ') + ..add(new NestedPrinter()..add('x = 3;\n', location: inputVar1)) + ..add('f(', location: inputFunction) + ..add(new NestedPrinter()..add('y) => ', location: inputVar2)) + ..add('x + y;\n', location: inputExpr) + ..build('output.dart'); + expect(printer.text, OUTPUT); + expect(printer.map, json.stringify(EXPECTED_MAP)); + }); + + test('add indentation', () { + var out = INPUT.replaceAll('long', '_s'); + var lines = INPUT.trim().split('\n'); + expect(lines.length, 7); + var printer = new NestedPrinter(); + for (int i = 0; i < lines.length; i++) { + if (i == 5) printer.indent++; + printer.addLine(lines[i].replaceAll('long', '_s').trim()); + if (i == 5) printer.indent--; + } + printer.build('output.dart'); + expect(printer.text, out); + }); + }); } diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart new file mode 100644 index 000000000..c153d9043 --- /dev/null +++ b/pkgs/source_maps/test/refactor_test.dart @@ -0,0 +1,96 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// 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. + +library polymer.test.refactor_test; + +import 'package:unittest/unittest.dart'; +import 'package:source_maps/refactor.dart'; +import 'package:source_maps/span.dart'; +import 'package:source_maps/parser.dart' show parse, Mapping; + +main() { + group('conflict detection', () { + var original = "0123456789abcdefghij"; + var file = new SourceFile.text('', original); + + test('no conflict, in order', () { + var txn = new TextEditTransaction(original, file); + txn.edit(2, 4, '.'); + txn.edit(5, 5, '|'); + txn.edit(6, 6, '-'); + txn.edit(6, 7, '_'); + expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); + }); + + test('no conflict, out of order', () { + var txn = new TextEditTransaction(original, file); + txn.edit(2, 4, '.'); + txn.edit(5, 5, '|'); + + // Regresion test for issue #404: there is no conflict/overlap for edits + // that don't remove any of the original code. + txn.edit(6, 7, '_'); + txn.edit(6, 6, '-'); + expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); + + }); + + test('conflict', () { + var txn = new TextEditTransaction(original, file); + txn.edit(2, 4, '.'); + txn.edit(3, 3, '-'); + expect(() => txn.commit(), throwsA(predicate( + (e) => e.toString().contains('overlapping edits')))); + }); + }); + + test('generated source maps', () { + var original = + "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; + var file = new SourceFile.text('', original); + var txn = new TextEditTransaction(original, file); + txn.edit(27, 29, '__\n '); + txn.edit(34, 35, '___'); + var printer = (txn.commit()..build('')); + var output = printer.text; + var map = parse(printer.map); + expect(output, + "0123456789\n0*23456789\n01*34__\n 789\na___cdefghij\nabcd*fghij\n"); + + // Line 1 and 2 are unmodified: mapping any column returns the beginning + // of the corresponding line: + expect(_span(1, 1, map, file), ":1:1: \n0123456789"); + expect(_span(1, 5, map, file), ":1:1: \n0123456789"); + expect(_span(2, 1, map, file), ":2:1: \n0*23456789"); + expect(_span(2, 8, map, file), ":2:1: \n0*23456789"); + + // Line 3 is modified part way: mappings before the edits have the right + // mapping, after the edits the mapping is null. + expect(_span(3, 1, map, file), ":3:1: \n01*3456789"); + expect(_span(3, 5, map, file), ":3:1: \n01*3456789"); + + // Start of edits map to beginning of the edit secion: + expect(_span(3, 6, map, file), ":3:6: \n01*3456789"); + expect(_span(3, 7, map, file), ":3:6: \n01*3456789"); + + // Lines added have no mapping (they should inherit the last mapping), + // but the end of the edit region continues were we left off: + expect(_span(4, 1, map, file), isNull); + expect(_span(4, 5, map, file), ":3:8: \n01*3456789"); + + // Subsequent lines are still mapped correctly: + expect(_span(5, 1, map, file), ":4:1: \nabcdefghij"); // a (in a___cd...) + expect(_span(5, 2, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) + expect(_span(5, 3, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) + expect(_span(5, 4, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) + expect(_span(5, 5, map, file), ":4:3: \nabcdefghij"); // c (in a___cd...) + expect(_span(6, 1, map, file), ":5:1: \nabcd*fghij"); + expect(_span(6, 8, map, file), ":5:1: \nabcd*fghij"); + }); +} + +String _span(int line, int column, Mapping map, SourceFile file) { + var span = map.spanFor(line - 1, column - 1, files: {'': file}); + return span == null ? null : span.getLocationMessage('').trim(); +} diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart index 9a197855f..876cff774 100755 --- a/pkgs/source_maps/test/run.dart +++ b/pkgs/source_maps/test/run.dart @@ -13,6 +13,7 @@ import 'builder_test.dart' as builder_test; import 'end2end_test.dart' as end2end_test; import 'parser_test.dart' as parser_test; import 'printer_test.dart' as printer_test; +import 'refactor_test.dart' as refactor_test; import 'span_test.dart' as span_test; import 'utils_test.dart' as utils_test; import 'vlq_test.dart' as vlq_test; @@ -32,6 +33,7 @@ main() { addGroup('end2end_test.dart', end2end_test.main); addGroup('parser_test.dart', parser_test.main); addGroup('printer_test.dart', printer_test.main); + addGroup('refactor_test.dart', refactor_test.main); addGroup('span_test.dart', span_test.main); addGroup('utils_test.dart', utils_test.main); addGroup('vlq_test.dart', vlq_test.main); From c9315076acda696daa795c4a9afcb90b48de92c6 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 9 Aug 2013 22:44:51 +0000 Subject: [PATCH 010/133] Fix source maps test (failed in checked mode). R=jmesserly@google.com Review URL: https://codereview.chromium.org//22762003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@25987 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/test/printer_test.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index 06bed5768..eaeae2a12 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -84,10 +84,10 @@ main() { test('simple use', () { var printer = new NestedPrinter(); printer..add('var ') - ..add('x = 3;\n', location: inputVar1) - ..add('f(', location: inputFunction) - ..add('y) => ', location: inputVar2) - ..add('x + y;\n', location: inputExpr) + ..add('x = 3;\n', span: inputVar1) + ..add('f(', span: inputFunction) + ..add('y) => ', span: inputVar2) + ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); expect(printer.map, json.stringify(EXPECTED_MAP)); @@ -96,10 +96,10 @@ main() { test('nested use', () { var printer = new NestedPrinter(); printer..add('var ') - ..add(new NestedPrinter()..add('x = 3;\n', location: inputVar1)) - ..add('f(', location: inputFunction) - ..add(new NestedPrinter()..add('y) => ', location: inputVar2)) - ..add('x + y;\n', location: inputExpr) + ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1)) + ..add('f(', span: inputFunction) + ..add(new NestedPrinter()..add('y) => ', span: inputVar2)) + ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); expect(printer.map, json.stringify(EXPECTED_MAP)); From af8c728dadb4c3d6de8f58dc38fb1eeae48b7f30 Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Tue, 27 Aug 2013 13:18:34 +0000 Subject: [PATCH 011/133] Some more removals of dart:utf. R=jmesserly@google.com, lrn@google.com, nweiz@google.com Review URL: https://codereview.chromium.org//22909059 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@26712 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/printer.dart | 3 +-- pkgs/source_maps/lib/span.dart | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 95539d2b7..0898017c4 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -5,7 +5,6 @@ /// Contains a code printer that generates code by recording the source maps. library source_maps.printer; -import 'dart:utf' show stringToCodepoints; import 'builder.dart'; import 'span.dart'; @@ -38,7 +37,7 @@ class Printer { /// line in the target file (printed here) corresponds to a new line in the /// source file. void add(String str, {projectMarks: false}) { - var chars = stringToCodepoints(str); + var chars = str.runes.toList(); var length = chars.length; for (int i = 0; i < length; i++) { var c = chars[i]; diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index e5057fceb..17ccd272d 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -5,7 +5,6 @@ /// Dart classes representing the souce spans and source files. library source_maps.span; -import 'dart:utf' show stringToCodepoints; import 'dart:math' show min, max; import 'src/utils.dart'; @@ -201,7 +200,7 @@ class SourceFile { SourceFile.text(this.url, String text) : _lineStarts = [0], - _decodedChars = stringToCodepoints(text) { + _decodedChars = text.runes.toList() { for (int i = 0; i < _decodedChars.length; i++) { var c = _decodedChars[i]; if (c == _CR) { From 35a756b9766e27423cc416239c61c6873db2d369 Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Wed, 28 Aug 2013 14:05:11 +0000 Subject: [PATCH 012/133] Remove usage of dart:json. R=jmesserly@google.com, lrn@google.com, nweiz@google.com, rnystrom@google.com Review URL: https://codereview.chromium.org//23596007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@26789 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/builder.dart | 4 ++-- pkgs/source_maps/lib/parser.dart | 4 ++-- pkgs/source_maps/test/builder_test.dart | 4 ++-- pkgs/source_maps/test/parser_test.dart | 4 ++-- pkgs/source_maps/test/printer_test.dart | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index be00c9e81..12587cd84 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -7,8 +7,8 @@ library source_maps.builder; // TODO(sigmund): add a builder for multi-section mappings. -import 'dart:json' as json; import 'dart:collection'; +import 'dart:convert'; import 'span.dart'; import 'src/vlq.dart'; @@ -108,7 +108,7 @@ class SourceMapBuilder { } /// Encodes all mappings added to this builder as a json string. - String toJson(String fileUrl) => json.stringify(build(fileUrl)); + String toJson(String fileUrl) => JSON.encode(build(fileUrl)); /// Get the index of [value] in [map], or create one if it doesn't exist. int _indexOf(Map map, String value) { diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index e2932634f..6b8bf3780 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -5,7 +5,7 @@ /// Contains the top-level function to parse source maps version 3. library source_maps.parser; -import 'dart:json' as json; +import 'dart:convert'; import 'span.dart'; import 'src/utils.dart'; @@ -15,7 +15,7 @@ import 'src/vlq.dart'; // TODO(sigmund): evaluate whether other maps should have the json parsed, or // the string represenation. Mapping parse(String jsonMap, {Map otherMaps}) => - parseJson(json.parse(jsonMap), otherMaps: otherMaps); + parseJson(JSON.decode(jsonMap), otherMaps: otherMaps); /// Parses a source map directly from a json map object. Mapping parseJson(Map map, {Map otherMaps}) { diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index 7bf2ee424..8842c62cb 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -4,7 +4,7 @@ library test.source_maps_test; -import 'dart:json' as json; +import 'dart:convert'; import 'package:unittest/unittest.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; @@ -27,6 +27,6 @@ main() { ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') ..addLocation(inputExpr.start, outputExpr.start, null)) .toJson(output.url); - expect(str, json.stringify(EXPECTED_MAP)); + expect(str, JSON.encode(EXPECTED_MAP)); }); } diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 1c32cbd34..c99acb2f1 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -4,7 +4,7 @@ library test.parser_test; -import 'dart:json' as json; +import 'dart:convert'; import 'package:unittest/unittest.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; @@ -19,7 +19,7 @@ main() { }); test('parse + json', () { - var mapping = parse(json.stringify(EXPECTED_MAP)); + var mapping = parse(JSON.encode(EXPECTED_MAP)); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); check(outputFunction, mapping, inputFunction, false); diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index eaeae2a12..fe27f76c0 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -4,7 +4,7 @@ library test.printer_test; -import 'dart:json' as json; +import 'dart:convert'; import 'package:unittest/unittest.dart'; import 'package:source_maps/printer.dart'; import 'package:source_maps/span.dart'; @@ -23,7 +23,7 @@ main() { ..mark(inputExpr) ..add('x + y;\n'); expect(printer.text, OUTPUT); - expect(printer.map, json.stringify(EXPECTED_MAP)); + expect(printer.map, JSON.encode(EXPECTED_MAP)); }); test('printer projecting marks', () { @@ -90,7 +90,7 @@ main() { ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); - expect(printer.map, json.stringify(EXPECTED_MAP)); + expect(printer.map, JSON.encode(EXPECTED_MAP)); }); test('nested use', () { @@ -102,7 +102,7 @@ main() { ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); - expect(printer.map, json.stringify(EXPECTED_MAP)); + expect(printer.map, JSON.encode(EXPECTED_MAP)); }); test('add indentation', () { From d3344948ebe1f7a03f19d172288309e2108505f5 Mon Sep 17 00:00:00 2001 From: "whesse@google.com" Date: Wed, 30 Oct 2013 15:17:01 +0000 Subject: [PATCH 013/133] Remove uses of Options from pkg, samples, tests, and third_party directories. BUG= R=sgjesse@google.com Review URL: https://codereview.chromium.org//52573002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@29552 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/test/run.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart index 876cff774..21d20377e 100755 --- a/pkgs/source_maps/test/run.dart +++ b/pkgs/source_maps/test/run.dart @@ -18,9 +18,8 @@ import 'span_test.dart' as span_test; import 'utils_test.dart' as utils_test; import 'vlq_test.dart' as vlq_test; -main() { - var args = new Options().arguments; - var pattern = new RegExp(args.length > 0 ? args[0] : '.'); +main(List arguments) { + var pattern = new RegExp(arguments.length > 0 ? arguments[0] : '.'); useCompactVMConfiguration(); void addGroup(testFile, testMain) { From 5edd73de8ad5f4be4d55c432cd4fd6ccdc145501 Mon Sep 17 00:00:00 2001 From: "jmesserly@google.com" Date: Wed, 6 Nov 2013 03:27:58 +0000 Subject: [PATCH 014/133] add versions and constraints for packages and samples - all packages at 0.9.0, except "analyzer" which had a version already - dependencies at ">=0.9.0 <0.10.0" except analyzer is ">=0.10.0 <0.11.0" - sdk constraint ">=1.0.0 <2.0.0" R=sigmund@google.com Review URL: https://codereview.chromium.org//59763006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@29957 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/pubspec.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 4ae180291..a0b0dc498 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,6 +1,9 @@ name: source_maps +version: 0.9.0 author: "Dart Team " homepage: http://www.dartlang.org description: Library to programmatically manipulate source map files. dev_dependencies: - unittest: any + unittest: ">=0.9.0 <0.10.0" +environment: + sdk: ">=1.0.0 <2.0.0" From 20c0ed16de8ca5dd554c71cf2c628357b8674c74 Mon Sep 17 00:00:00 2001 From: "ajohnsen@google.com" Date: Wed, 6 Nov 2013 09:09:18 +0000 Subject: [PATCH 015/133] Revert "add versions and constraints for packages and samples" This is currently blocking us from testing samples. BUG= R=kasperl@google.com Review URL: https://codereview.chromium.org//59513007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@29960 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/pubspec.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index a0b0dc498..4ae180291 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,9 +1,6 @@ name: source_maps -version: 0.9.0 author: "Dart Team " homepage: http://www.dartlang.org description: Library to programmatically manipulate source map files. dev_dependencies: - unittest: ">=0.9.0 <0.10.0" -environment: - sdk: ">=1.0.0 <2.0.0" + unittest: any From 7c4320ea7995e5b2fd48665b5ef2406fda089def Mon Sep 17 00:00:00 2001 From: "dgrove@google.com" Date: Wed, 6 Nov 2013 18:28:22 +0000 Subject: [PATCH 016/133] Re-land r29957 (add versions and constraints for packages and samples), with SDK constraints bumped from 1.0.0 to 0.8.10+6 . R=ricow@google.com, sigmund@google.com Review URL: https://codereview.chromium.org//62473002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@29986 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/pubspec.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 4ae180291..83c59a336 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,6 +1,9 @@ name: source_maps +version: 0.9.0 author: "Dart Team " homepage: http://www.dartlang.org description: Library to programmatically manipulate source map files. dev_dependencies: - unittest: any + unittest: ">=0.9.0 <0.10.0" +environment: + sdk: ">=0.8.10+6 <2.0.0" From 274cc23e5deea734dfc7878db24fcb470b93d829 Mon Sep 17 00:00:00 2001 From: "kevmoo@google.com" Date: Mon, 13 Jan 2014 18:07:45 +0000 Subject: [PATCH 017/133] pkg/unittest: added LICENSE R=rnystrom@google.com Review URL: https://codereview.chromium.org//135343002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@31750 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/LICENSE | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkgs/source_maps/LICENSE diff --git a/pkgs/source_maps/LICENSE b/pkgs/source_maps/LICENSE new file mode 100644 index 000000000..5c60afea3 --- /dev/null +++ b/pkgs/source_maps/LICENSE @@ -0,0 +1,26 @@ +Copyright 2014, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 2f2fc2051e866351cf8858ca91ac1afac595de2b Mon Sep 17 00:00:00 2001 From: "zarah@google.com" Date: Wed, 23 Apr 2014 07:57:14 +0000 Subject: [PATCH 018/133] Support unmapped areas in source maps. R=johnniwinther@google.com Review URL: https://codereview.chromium.org//237123003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@35307 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/builder.dart | 7 +-- pkgs/source_maps/lib/parser.dart | 12 ++--- pkgs/source_maps/pubspec.yaml | 12 ++--- pkgs/source_maps/test/parser_test.dart | 66 ++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 18 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 12587cd84..ef22e3123 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -75,15 +75,10 @@ class SourceMapBuilder { column = _append(buff, column, entry.target.column); // Encoding can be just the column offset if there is no source - // information, or if two consecutive mappings share exactly the same - // source information. + // information. var source = entry.source; if (source == null) continue; var newUrlId = _indexOf(_urls, source.sourceUrl); - if (newUrlId == srcUrlId && source.line == srcLine - && source.column == srcColumn && entry.identifierName == null) { - continue; - } srcUrlId = _append(buff, srcUrlId, newUrlId); srcLine = _append(buff, srcLine, source.line); diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 6b8bf3780..c92a8bba0 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -185,7 +185,7 @@ class SingleMapping extends Mapping { if (tokenizer.nextKind.isNewSegment) throw _segmentError(0, line); column += tokenizer._consumeValue(); if (!tokenizer.nextKind.isValue) { - entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn)); + entries.add(new TargetEntry(column)); } else { srcUrlId += tokenizer._consumeValue(); if (srcUrlId >= urls.length) { @@ -204,8 +204,8 @@ class SingleMapping extends Mapping { throw new StateError( 'Invalid name id: $targetUrl, $line, $srcNameId'); } - entries.add( - new TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId)); + entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn, + srcNameId)); } } if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment(); @@ -242,7 +242,7 @@ class SingleMapping extends Mapping { Span spanFor(int line, int column, {Map files}) { var entry = _findColumn(line, column, _findLine(line)); - if (entry == null) return null; + if (entry == null || entry.sourceUrlId == null) return null; var url = urls[entry.sourceUrlId]; if (files != null && files[url] != null) { var file = files[url]; @@ -322,8 +322,8 @@ class TargetEntry { final int sourceColumn; final int sourceNameId; - TargetEntry(this.column, this.sourceUrlId, this.sourceLine, - this.sourceColumn, [this.sourceNameId]); + TargetEntry(this.column, [this.sourceUrlId, this.sourceLine, + this.sourceColumn, this.sourceNameId]); String toString() => '$runtimeType: ' '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 83c59a336..71cbfb54f 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,9 +1,9 @@ name: source_maps -version: 0.9.0 -author: "Dart Team " -homepage: http://www.dartlang.org +version: 0.9.1-dev +author: Dart Team description: Library to programmatically manipulate source map files. -dev_dependencies: - unittest: ">=0.9.0 <0.10.0" +homepage: http://www.dartlang.org environment: - sdk: ">=0.8.10+6 <2.0.0" + sdk: '>=0.8.10+6 <2.0.0' +dev_dependencies: + unittest: '>=0.9.0 <0.10.0' diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index c99acb2f1..afdd7fb2c 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -9,6 +9,33 @@ import 'package:unittest/unittest.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; +const Map MAP_WITH_NO_SOURCE_LOCATION = const { + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const [], + 'mappings': 'A', + 'file': 'output.dart' +}; + +const Map MAP_WITH_SOURCE_LOCATION = const { + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const [], + 'mappings': 'AAAA', + 'file': 'output.dart' +}; + +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = const { + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const ['var'], + 'mappings': 'AAAAA', + 'file': 'output.dart' +}; + main() { test('parse', () { var mapping = parseJson(EXPECTED_MAP); @@ -33,4 +60,43 @@ main() { check(outputFunction, mapping, inputFunction, true); check(outputExpr, mapping, inputExpr, true); }); + + test('parse with no source location', () { + SingleMapping map = parse(JSON.encode(MAP_WITH_NO_SOURCE_LOCATION)); + expect(map.lines.length, 1); + expect(map.lines.first.entries.length, 1); + TargetEntry entry = map.lines.first.entries.first; + + expect(entry.column, 0); + expect(entry.sourceUrlId, null); + expect(entry.sourceColumn, null); + expect(entry.sourceLine, null); + expect(entry.sourceNameId, null); + }); + + test('parse with source location and no name', () { + SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION)); + expect(map.lines.length, 1); + expect(map.lines.first.entries.length, 1); + TargetEntry entry = map.lines.first.entries.first; + + expect(entry.column, 0); + expect(entry.sourceUrlId, 0); + expect(entry.sourceColumn, 0); + expect(entry.sourceLine, 0); + expect(entry.sourceNameId, null); + }); + + test('parse with source location and name', () { + SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); + expect(map.lines.length, 1); + expect(map.lines.first.entries.length, 1); + TargetEntry entry = map.lines.first.entries.first; + + expect(entry.sourceUrlId, 0); + expect(entry.sourceUrlId, 0); + expect(entry.sourceColumn, 0); + expect(entry.sourceLine, 0); + expect(entry.sourceNameId, 0); + }); } From 4a16d390427369bf9bf531d4d06b6f9277137026 Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Sat, 24 May 2014 00:52:08 +0000 Subject: [PATCH 019/133] Make source map location information more readable. This changes "file:1:2" to "line 1, column 2 of file" and ":1:2" to "line 1, column 2" in [SourceFile.getLocationMessage]. The more machine-readable colon-separated format doesn't make sense for a message intended for humans. Since [Location.formatString] seems more likely to be consumed by machines, its format was left as-is. This also prepares version 0.9.1 for release. R=sigmund@google.com Review URL: https://codereview.chromium.org//300583002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@36603 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/lib/span.dart | 6 ++++-- pkgs/source_maps/pubspec.yaml | 4 +++- pkgs/source_maps/test/span_test.dart | 24 ++++++++++++------------ 4 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 pkgs/source_maps/CHANGELOG.md diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md new file mode 100644 index 000000000..e2784587e --- /dev/null +++ b/pkgs/source_maps/CHANGELOG.md @@ -0,0 +1,5 @@ +## 0.9.1 + +* Support unmapped areas in source maps. + +* Increase the readability of location messages. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 17ccd272d..f47e08eb6 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -7,6 +7,8 @@ library source_maps.span; import 'dart:math' show min, max; +import 'package:path/path.dart' as p; + import 'src/utils.dart'; /// A simple class that describe a segment of source text. @@ -252,8 +254,8 @@ class SourceFile { var line = getLine(start); var column = getColumn(line, start); - var src = url == null ? '' : url; - var msg = '$src:${line + 1}:${column + 1}: $message'; + var source = url == null ? '' : ' of ${p.prettyUri(url)}'; + var msg = 'line ${line + 1}, column ${column + 1}$source: $message'; if (_decodedChars == null) { // We don't have any text to include, so exit. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 71cbfb54f..3c946e006 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,8 +1,10 @@ name: source_maps -version: 0.9.1-dev +version: 0.9.1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org +dependencies: + path: '>=1.2.0 <2.0.0' environment: sdk: '>=0.8.10+6 <2.0.0' dev_dependencies: diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index da3e063ef..190b7a66b 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -72,7 +72,7 @@ main() { group('location message', () { test('first line', () { expect(file.getLocationMessage('the message', 1, 3), - 'file:1:2: the message\n' + 'line 1, column 2 of file: the message\n' '+23456789_\n' ' ^^'); }); @@ -81,7 +81,7 @@ main() { // fifth line (including 4 new lines), columns 2 .. 11 var line = 10 + 80 + 31 + 27 + 4; expect(file.getLocationMessage('the message', line + 2, line + 11), - 'file:5:3: the message\n' + 'line 5, column 3 of file: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -90,7 +90,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( 'the message', line + 2, line + 11), - ':5:3: the message\n' + 'line 5, column 3: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -100,7 +100,7 @@ main() { int index = TEST_FILE.lastIndexOf('\n'); var start = TEST_FILE.lastIndexOf('\n', index - 1) - 3; expect(file.getLocationMessage('the message', start, start + 2), - 'file:11:41: the message\n' + 'line 11, column 41 of file: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -108,7 +108,7 @@ main() { test('last line', () { var start = TEST_FILE.lastIndexOf('\n') - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'file:12:28: the message\n' + 'line 12, column 28 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -120,7 +120,7 @@ main() { test('penultimate line', () { var start = text.lastIndexOf('\n') - 3; expect(file2.getLocationMessage('the message', start, start + 2), - 'file:11:41: the message\n' + 'line 11, column 41 of file: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -128,7 +128,7 @@ main() { test('last line', () { var start = text.length - 2; expect(file2.getLocationMessage('the message', start, start + 1), - 'file:12:28: the message\n' + 'line 12, column 28 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -139,7 +139,7 @@ main() { int start = text.indexOf(' ') + 1; var file2 = new SourceFile.text('file', text); expect(file2.getLocationMessage('the message', start, start + 2), - 'file:1:${start + 1}: the message\n' + 'line 1, column ${start + 1} of file: the message\n' 'this is a single line\n' ' ^^'); }); @@ -178,7 +178,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(span(line + 2, line + 11).getLocationMessage('the message'), - 'file:5:3: the message\n' + 'line 5, column 3 of file: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); @@ -226,7 +226,7 @@ main() { test('range check for large offsets', () { var start = TEST_FILE.length; expect(file.getLocationMessage('the message', start, start + 9), - 'file:13:1: the message\n'); + 'line 13, column 1 of file: the message\n'); }); group('file segment', () { @@ -296,7 +296,7 @@ main() { test('past segment, past its line', () { var start = TEST_FILE.length - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'file:12:29: the message\n' + 'line 12, column 29 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); @@ -304,7 +304,7 @@ main() { // about the 10 lines it has (and nothing about the possible extra lines // afterwards) expect(segment.getLocationMessage('the message', start, start + 1), - 'file:11:1: the message\n'); + 'line 11, column 1 of file: the message\n'); }); }); }); From 5c2376945aea24d3cbe36c0bdec2e7012ba02037 Mon Sep 17 00:00:00 2001 From: "ricow@google.com" Date: Mon, 26 May 2014 05:52:05 +0000 Subject: [PATCH 020/133] Revert revision 36603 This is making 60% of the bots red Review URL: https://codereview.chromium.org//303493002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@36615 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 5 ----- pkgs/source_maps/lib/span.dart | 6 ++---- pkgs/source_maps/pubspec.yaml | 4 +--- pkgs/source_maps/test/span_test.dart | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 pkgs/source_maps/CHANGELOG.md diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md deleted file mode 100644 index e2784587e..000000000 --- a/pkgs/source_maps/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -## 0.9.1 - -* Support unmapped areas in source maps. - -* Increase the readability of location messages. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index f47e08eb6..17ccd272d 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -7,8 +7,6 @@ library source_maps.span; import 'dart:math' show min, max; -import 'package:path/path.dart' as p; - import 'src/utils.dart'; /// A simple class that describe a segment of source text. @@ -254,8 +252,8 @@ class SourceFile { var line = getLine(start); var column = getColumn(line, start); - var source = url == null ? '' : ' of ${p.prettyUri(url)}'; - var msg = 'line ${line + 1}, column ${column + 1}$source: $message'; + var src = url == null ? '' : url; + var msg = '$src:${line + 1}:${column + 1}: $message'; if (_decodedChars == null) { // We don't have any text to include, so exit. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 3c946e006..71cbfb54f 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,10 +1,8 @@ name: source_maps -version: 0.9.1 +version: 0.9.1-dev author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org -dependencies: - path: '>=1.2.0 <2.0.0' environment: sdk: '>=0.8.10+6 <2.0.0' dev_dependencies: diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index 190b7a66b..da3e063ef 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -72,7 +72,7 @@ main() { group('location message', () { test('first line', () { expect(file.getLocationMessage('the message', 1, 3), - 'line 1, column 2 of file: the message\n' + 'file:1:2: the message\n' '+23456789_\n' ' ^^'); }); @@ -81,7 +81,7 @@ main() { // fifth line (including 4 new lines), columns 2 .. 11 var line = 10 + 80 + 31 + 27 + 4; expect(file.getLocationMessage('the message', line + 2, line + 11), - 'line 5, column 3 of file: the message\n' + 'file:5:3: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -90,7 +90,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( 'the message', line + 2, line + 11), - 'line 5, column 3: the message\n' + ':5:3: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -100,7 +100,7 @@ main() { int index = TEST_FILE.lastIndexOf('\n'); var start = TEST_FILE.lastIndexOf('\n', index - 1) - 3; expect(file.getLocationMessage('the message', start, start + 2), - 'line 11, column 41 of file: the message\n' + 'file:11:41: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -108,7 +108,7 @@ main() { test('last line', () { var start = TEST_FILE.lastIndexOf('\n') - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'line 12, column 28 of file: the message\n' + 'file:12:28: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -120,7 +120,7 @@ main() { test('penultimate line', () { var start = text.lastIndexOf('\n') - 3; expect(file2.getLocationMessage('the message', start, start + 2), - 'line 11, column 41 of file: the message\n' + 'file:11:41: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -128,7 +128,7 @@ main() { test('last line', () { var start = text.length - 2; expect(file2.getLocationMessage('the message', start, start + 1), - 'line 12, column 28 of file: the message\n' + 'file:12:28: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -139,7 +139,7 @@ main() { int start = text.indexOf(' ') + 1; var file2 = new SourceFile.text('file', text); expect(file2.getLocationMessage('the message', start, start + 2), - 'line 1, column ${start + 1} of file: the message\n' + 'file:1:${start + 1}: the message\n' 'this is a single line\n' ' ^^'); }); @@ -178,7 +178,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(span(line + 2, line + 11).getLocationMessage('the message'), - 'line 5, column 3 of file: the message\n' + 'file:5:3: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); @@ -226,7 +226,7 @@ main() { test('range check for large offsets', () { var start = TEST_FILE.length; expect(file.getLocationMessage('the message', start, start + 9), - 'line 13, column 1 of file: the message\n'); + 'file:13:1: the message\n'); }); group('file segment', () { @@ -296,7 +296,7 @@ main() { test('past segment, past its line', () { var start = TEST_FILE.length - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'line 12, column 29 of file: the message\n' + 'file:12:29: the message\n' '123456789_1+3456789_123456789\n' ' ^'); @@ -304,7 +304,7 @@ main() { // about the 10 lines it has (and nothing about the possible extra lines // afterwards) expect(segment.getLocationMessage('the message', start, start + 1), - 'line 11, column 1 of file: the message\n'); + 'file:11:1: the message\n'); }); }); }); From 653f02456ffefc530c4ebea7a17dd6ab5e0cb1de Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Tue, 27 May 2014 23:01:24 +0000 Subject: [PATCH 021/133] Make source map location information more readable. This changes "file:1:2" to "line 1, column 2 of file" and ":1:2" to "line 1, column 2" in [SourceFile.getLocationMessage]. The more machine-readable colon-separated format doesn't make sense for a message intended for humans. Since [Location.formatString] seems more likely to be consumed by machines, its format was left as-is. This also prepares version 0.9.1 for release. This was previously submitted as r36603. That caused buildbot errors and was rolled back by r36615. This CL fixes the test errors in r36603. R=sigmund@google.com Review URL: https://codereview.chromium.org//304603003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@36717 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/lib/span.dart | 6 ++++-- pkgs/source_maps/pubspec.yaml | 4 +++- pkgs/source_maps/test/span_test.dart | 24 ++++++++++++------------ 4 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 pkgs/source_maps/CHANGELOG.md diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md new file mode 100644 index 000000000..e2784587e --- /dev/null +++ b/pkgs/source_maps/CHANGELOG.md @@ -0,0 +1,5 @@ +## 0.9.1 + +* Support unmapped areas in source maps. + +* Increase the readability of location messages. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 17ccd272d..f47e08eb6 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -7,6 +7,8 @@ library source_maps.span; import 'dart:math' show min, max; +import 'package:path/path.dart' as p; + import 'src/utils.dart'; /// A simple class that describe a segment of source text. @@ -252,8 +254,8 @@ class SourceFile { var line = getLine(start); var column = getColumn(line, start); - var src = url == null ? '' : url; - var msg = '$src:${line + 1}:${column + 1}: $message'; + var source = url == null ? '' : ' of ${p.prettyUri(url)}'; + var msg = 'line ${line + 1}, column ${column + 1}$source: $message'; if (_decodedChars == null) { // We don't have any text to include, so exit. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 71cbfb54f..3c946e006 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,8 +1,10 @@ name: source_maps -version: 0.9.1-dev +version: 0.9.1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org +dependencies: + path: '>=1.2.0 <2.0.0' environment: sdk: '>=0.8.10+6 <2.0.0' dev_dependencies: diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart index da3e063ef..190b7a66b 100644 --- a/pkgs/source_maps/test/span_test.dart +++ b/pkgs/source_maps/test/span_test.dart @@ -72,7 +72,7 @@ main() { group('location message', () { test('first line', () { expect(file.getLocationMessage('the message', 1, 3), - 'file:1:2: the message\n' + 'line 1, column 2 of file: the message\n' '+23456789_\n' ' ^^'); }); @@ -81,7 +81,7 @@ main() { // fifth line (including 4 new lines), columns 2 .. 11 var line = 10 + 80 + 31 + 27 + 4; expect(file.getLocationMessage('the message', line + 2, line + 11), - 'file:5:3: the message\n' + 'line 5, column 3 of file: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -90,7 +90,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( 'the message', line + 2, line + 11), - ':5:3: the message\n' + 'line 5, column 3: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); }); @@ -100,7 +100,7 @@ main() { int index = TEST_FILE.lastIndexOf('\n'); var start = TEST_FILE.lastIndexOf('\n', index - 1) - 3; expect(file.getLocationMessage('the message', start, start + 2), - 'file:11:41: the message\n' + 'line 11, column 41 of file: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -108,7 +108,7 @@ main() { test('last line', () { var start = TEST_FILE.lastIndexOf('\n') - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'file:12:28: the message\n' + 'line 12, column 28 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -120,7 +120,7 @@ main() { test('penultimate line', () { var start = text.lastIndexOf('\n') - 3; expect(file2.getLocationMessage('the message', start, start + 2), - 'file:11:41: the message\n' + 'line 11, column 41 of file: the message\n' '123456789_+23456789_123456789_123456789_123\n' ' ^^'); }); @@ -128,7 +128,7 @@ main() { test('last line', () { var start = text.length - 2; expect(file2.getLocationMessage('the message', start, start + 1), - 'file:12:28: the message\n' + 'line 12, column 28 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); }); @@ -139,7 +139,7 @@ main() { int start = text.indexOf(' ') + 1; var file2 = new SourceFile.text('file', text); expect(file2.getLocationMessage('the message', start, start + 2), - 'file:1:${start + 1}: the message\n' + 'line 1, column ${start + 1} of file: the message\n' 'this is a single line\n' ' ^^'); }); @@ -178,7 +178,7 @@ main() { var line = 10 + 80 + 31 + 27 + 4; expect(span(line + 2, line + 11).getLocationMessage('the message'), - 'file:5:3: the message\n' + 'line 5, column 3 of file: the message\n' '1234+6789_1234\n' ' ^^^^^^^^^'); @@ -226,7 +226,7 @@ main() { test('range check for large offsets', () { var start = TEST_FILE.length; expect(file.getLocationMessage('the message', start, start + 9), - 'file:13:1: the message\n'); + 'line 13, column 1 of file: the message\n'); }); group('file segment', () { @@ -296,7 +296,7 @@ main() { test('past segment, past its line', () { var start = TEST_FILE.length - 2; expect(file.getLocationMessage('the message', start, start + 1), - 'file:12:29: the message\n' + 'line 12, column 29 of file: the message\n' '123456789_1+3456789_123456789\n' ' ^'); @@ -304,7 +304,7 @@ main() { // about the 10 lines it has (and nothing about the possible extra lines // afterwards) expect(segment.getLocationMessage('the message', start, start + 1), - 'file:11:1: the message\n'); + 'line 11, column 1 of file: the message\n'); }); }); }); From eaf8323227ff98fca687de5bf3073b1593b86e2c Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Wed, 28 May 2014 00:32:00 +0000 Subject: [PATCH 022/133] Fix a couple more tests that were relying on sourcemap message format. Review URL: https://codereview.chromium.org//297203009 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@36722 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/test/refactor_test.dart | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index c153d9043..5d0abf1e2 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -60,33 +60,38 @@ main() { // Line 1 and 2 are unmodified: mapping any column returns the beginning // of the corresponding line: - expect(_span(1, 1, map, file), ":1:1: \n0123456789"); - expect(_span(1, 5, map, file), ":1:1: \n0123456789"); - expect(_span(2, 1, map, file), ":2:1: \n0*23456789"); - expect(_span(2, 8, map, file), ":2:1: \n0*23456789"); + expect(_span(1, 1, map, file), "line 1, column 1 of .: \n0123456789"); + expect(_span(1, 5, map, file), "line 1, column 1 of .: \n0123456789"); + expect(_span(2, 1, map, file), "line 2, column 1 of .: \n0*23456789"); + expect(_span(2, 8, map, file), "line 2, column 1 of .: \n0*23456789"); // Line 3 is modified part way: mappings before the edits have the right // mapping, after the edits the mapping is null. - expect(_span(3, 1, map, file), ":3:1: \n01*3456789"); - expect(_span(3, 5, map, file), ":3:1: \n01*3456789"); + expect(_span(3, 1, map, file), "line 3, column 1 of .: \n01*3456789"); + expect(_span(3, 5, map, file), "line 3, column 1 of .: \n01*3456789"); // Start of edits map to beginning of the edit secion: - expect(_span(3, 6, map, file), ":3:6: \n01*3456789"); - expect(_span(3, 7, map, file), ":3:6: \n01*3456789"); + expect(_span(3, 6, map, file), "line 3, column 6 of .: \n01*3456789"); + expect(_span(3, 7, map, file), "line 3, column 6 of .: \n01*3456789"); // Lines added have no mapping (they should inherit the last mapping), // but the end of the edit region continues were we left off: expect(_span(4, 1, map, file), isNull); - expect(_span(4, 5, map, file), ":3:8: \n01*3456789"); + expect(_span(4, 5, map, file), "line 3, column 8 of .: \n01*3456789"); // Subsequent lines are still mapped correctly: - expect(_span(5, 1, map, file), ":4:1: \nabcdefghij"); // a (in a___cd...) - expect(_span(5, 2, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) - expect(_span(5, 3, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) - expect(_span(5, 4, map, file), ":4:2: \nabcdefghij"); // _ (in a___cd...) - expect(_span(5, 5, map, file), ":4:3: \nabcdefghij"); // c (in a___cd...) - expect(_span(6, 1, map, file), ":5:1: \nabcd*fghij"); - expect(_span(6, 8, map, file), ":5:1: \nabcd*fghij"); + // a (in a___cd...) + expect(_span(5, 1, map, file), "line 4, column 1 of .: \nabcdefghij"); + // _ (in a___cd...) + expect(_span(5, 2, map, file), "line 4, column 2 of .: \nabcdefghij"); + // _ (in a___cd...) + expect(_span(5, 3, map, file), "line 4, column 2 of .: \nabcdefghij"); + // _ (in a___cd...) + expect(_span(5, 4, map, file), "line 4, column 2 of .: \nabcdefghij"); + // c (in a___cd...) + expect(_span(5, 5, map, file), "line 4, column 3 of .: \nabcdefghij"); + expect(_span(6, 1, map, file), "line 5, column 1 of .: \nabcd*fghij"); + expect(_span(6, 8, map, file), "line 5, column 1 of .: \nabcd*fghij"); }); } From b1c2cb2dd20be9579ab21038e839ec9e5e2375dd Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Thu, 19 Jun 2014 19:28:45 +0000 Subject: [PATCH 023/133] Add SpanException and SpanFormatException classes to source_maps. It's often useful to associate source range information with an exception in a way that will get printed along with that exception but can be pulled out and manipulated directly. It's especially useful if there's a common superclass/interface for doing so that can be shared across packages. This adds that superclass. R=sigmund@google.com Review URL: https://codereview.chromium.org//348493004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@37509 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/span.dart | 24 ++++++++++++++++++++++++ pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index e2784587e..3730a10f5 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.2 + +* Add `SpanException` and `SpanFormatException` classes. + ## 0.9.1 * Support unmapped areas in source maps. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index f47e08eb6..cc48f190d 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -360,3 +360,27 @@ class SourceFileSegment extends SourceFile { String getText(int start, [int end]) => super.getText(start - _baseOffset, end == null ? null : end - _baseOffset); } + +/// A class for exceptions that have source span information attached. +class SpanException implements Exception { + /// A message describing the exception. + final String message; + + /// The span associated with this exception. + /// + /// This may be `null` if the source location can't be determined. + final Span span; + + SpanException(this.message, this.span); + + String toString({bool useColors: false, String color}) { + if (span == null) return message; + return span.getLocationMessage(message, useColors: useColors, color: color); + } +} + +/// A [SpanException] that's also a [FormatException]. +class SpanFormatException extends SpanException implements FormatException { + SpanFormatException(String message, Span span) + : super(message, span); +} diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 3c946e006..213587c43 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.9.1 +version: 0.9.2 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 36b7da221d34001c33f8ba4f7f1ba2f39bf859fb Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Fri, 20 Jun 2014 01:55:41 +0000 Subject: [PATCH 024/133] Improve the readability of some human-consumed strings in source_maps. R=jmesserly@google.com Review URL: https://codereview.chromium.org//346983002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@37530 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/lib/span.dart | 7 +++++-- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 3730a10f5..55d789633 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.9.2+1 + +* Minor readability improvements to `FixedSpan.getLocationMessage` and + `SpanException.toString`. + ## 0.9.2 * Add `SpanException` and `SpanFormatException` classes. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index cc48f190d..91cfcd39c 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -64,7 +64,9 @@ abstract class Span implements Comparable { String getLocationMessage(String message, {bool useColors: false, String color}) { - return '$formatLocation: $message'; + var source = url == null ? '' : ' of ${p.prettyUri(url)}'; + return 'line ${start.line + 1}, column ${start.column + 1}$source: ' + + message; } bool operator ==(Span other) => @@ -375,7 +377,8 @@ class SpanException implements Exception { String toString({bool useColors: false, String color}) { if (span == null) return message; - return span.getLocationMessage(message, useColors: useColors, color: color); + return "Error on " + span.getLocationMessage(message, + useColors: useColors, color: color); } } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 213587c43..7fae470cb 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.9.2 +version: 0.9.2+1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 23fa7bfaa6b9789f3cb2dbe2174966e8e572e1ee Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Fri, 20 Jun 2014 02:12:33 +0000 Subject: [PATCH 025/133] Fix a bug in FixedSpan.getLocationMessage. R=jmesserly@google.com Review URL: https://codereview.chromium.org//346993002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@37531 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/span.dart | 3 ++- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 55d789633..f40a16d80 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.2+2 + +* Fix a bug in `FixedSpan.getLocationMessage`. + ## 0.9.2+1 * Minor readability improvements to `FixedSpan.getLocationMessage` and diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 91cfcd39c..600506ee1 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -64,7 +64,8 @@ abstract class Span implements Comparable { String getLocationMessage(String message, {bool useColors: false, String color}) { - var source = url == null ? '' : ' of ${p.prettyUri(url)}'; + var source = start.sourceUrl == null ? '' : + ' of ${p.prettyUri(start.sourceUrl)}'; return 'line ${start.line + 1}, column ${start.column + 1}$source: ' + message; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 7fae470cb..80c7e7f25 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.9.2+1 +version: 0.9.2+2 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 7ea40395d0728b760f96b9c8116a1a7a142da0d8 Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Thu, 26 Jun 2014 20:04:05 +0000 Subject: [PATCH 026/133] Add implicit constraints from pub onto stack_trace and source_maps. These packages are used in pub's plugin isolate, so pub needs to have a dependency on them to ensure their APIs don't change out from under it. R=rnystrom@google.com BUG=19574 Review URL: https://codereview.chromium.org//356523003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@37751 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/pubspec.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 80c7e7f25..97d6c6bdc 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,4 +1,12 @@ name: source_maps + +# Note! This version number is referenced directly in the pub source code in +# lib/src/barback.dart. Pub implicitly places a version constraint on +# source_maps to ensure users only select a version of source_maps that works +# with their current version of pub. +# +# When the minor version is upgraded, you *must* update that version constraint +# in pub to stay in sync with this. version: 0.9.2+2 author: Dart Team description: Library to programmatically manipulate source map files. From 2cf49c580b37375ba5a746e0842a47a17cf5edfc Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 27 Jun 2014 19:07:20 +0000 Subject: [PATCH 027/133] Fix markdown in source_maps README.md so it renders correctly in pub site. R=nweiz@google.com Review URL: https://codereview.chromium.org//357013002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@37796 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/README.md | 2 ++ pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index df182d9ba..5c7f638f4 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -7,6 +7,7 @@ originated from the [Closure Compiler][closure] and has been implemented in Chrome and Firefox. In this package we provide: + * Data types defining file locations and spans: these are not part of the original source map specification. These data types are great for tracking source locations on source maps, but they can also be used by tools to @@ -17,6 +18,7 @@ In this package we provide: mapping information. Some upcoming features we are planning to add to this package are: + * A printer that lets you generate code, but record source map information in the process. * A tool that can compose source maps together. This would be useful for diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 97d6c6bdc..9dee45f81 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.2+2 +version: 0.9.2+3 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 3fdc73687f5602b708e830cf516f0d9ab533a29d Mon Sep 17 00:00:00 2001 From: "tjblasi@google.com" Date: Tue, 8 Jul 2014 22:13:43 +0000 Subject: [PATCH 028/133] Moving logic for writing source maps from SourceMapBuilder into the Mapping class. R=sigmund@google.com Review URL: https://codereview.chromium.org//372153002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38073 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/builder.dart | 80 +---------------- pkgs/source_maps/lib/parser.dart | 116 +++++++++++++++++++++++-- pkgs/source_maps/test/parser_test.dart | 11 +++ 3 files changed, 124 insertions(+), 83 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index ef22e3123..cd30ccb94 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -7,25 +7,16 @@ library source_maps.builder; // TODO(sigmund): add a builder for multi-section mappings. -import 'dart:collection'; import 'dart:convert'; +import 'parser.dart'; import 'span.dart'; -import 'src/vlq.dart'; /// Builds a source map given a set of mappings. class SourceMapBuilder { final List _entries = []; - /// Indices associated with file urls that will be part of the source map. We - /// use a linked hash-map so that `_urls.keys[_urls[u]] == u` - final Map _urls = new LinkedHashMap(); - - /// Indices associated with identifiers that will be part of the source map. - /// We use a linked hash-map so that `_names.keys[_names[n]] == n` - final Map _names = new LinkedHashMap(); - /// Adds an entry mapping the [targetOffset] to [source]. void addFromOffset(Location source, SourceFile targetFile, int targetOffset, String identifier) { @@ -48,78 +39,11 @@ class SourceMapBuilder { /// Encodes all mappings added to this builder as a json map. Map build(String fileUrl) { - var buff = new StringBuffer(); - var line = 0; - var column = 0; - var srcLine = 0; - var srcColumn = 0; - var srcUrlId = 0; - var srcNameId = 0; - var first = true; - - // The encoding needs to be sorted by the target offsets. - _entries.sort(); - for (var entry in _entries) { - int nextLine = entry.target.line; - if (nextLine > line) { - for (int i = line; i < nextLine; ++i) { - buff.write(';'); - } - line = nextLine; - column = 0; - first = true; - } - - if (!first) buff.write(','); - first = false; - column = _append(buff, column, entry.target.column); - - // Encoding can be just the column offset if there is no source - // information. - var source = entry.source; - if (source == null) continue; - var newUrlId = _indexOf(_urls, source.sourceUrl); - - srcUrlId = _append(buff, srcUrlId, newUrlId); - srcLine = _append(buff, srcLine, source.line); - srcColumn = _append(buff, srcColumn, source.column); - - if (entry.identifierName == null) continue; - srcNameId = _append(buff, srcNameId, - _indexOf(_names, entry.identifierName)); - } - - var result = { - 'version': 3, - 'sourceRoot': '', - 'sources': _urls.keys.toList(), - 'names' : _names.keys.toList(), - 'mappings' : buff.toString() - }; - if (fileUrl != null) { - result['file'] = fileUrl; - } - return result; + return new SingleMapping.fromEntries(this._entries, fileUrl).toJson(); } /// Encodes all mappings added to this builder as a json string. String toJson(String fileUrl) => JSON.encode(build(fileUrl)); - - /// Get the index of [value] in [map], or create one if it doesn't exist. - int _indexOf(Map map, String value) { - return map.putIfAbsent(value, () { - int index = map.length; - map[value] = index; - return index; - }); - } - - /// Appends to [buff] a VLQ encoding of [newValue] using the difference - /// between [oldValue] and [newValue] - static int _append(StringBuffer buff, int oldValue, int newValue) { - buff.writeAll(encodeVlq(newValue - oldValue)); - return newValue; - } } /// An entry in the source map builder. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index c92a8bba0..23835a60f 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -5,8 +5,10 @@ /// Contains the top-level function to parse source maps version 3. library source_maps.parser; +import 'dart:collection'; import 'dart:convert'; +import 'builder.dart' as builder; import 'span.dart'; import 'src/utils.dart'; import 'src/vlq.dart'; @@ -41,7 +43,7 @@ Mapping parseJson(Map map, {Map otherMaps}) { } -/// A mapping parsed our of a source map. +/// A mapping parsed out of a source map. abstract class Mapping { Span spanFor(int line, int column, {Map files}); @@ -131,7 +133,6 @@ class MultiSectionMapping extends Mapping { } /// A map containing direct source mappings. -// TODO(sigmund): integrate mapping and sourcemap builder? class SingleMapping extends Mapping { /// Url of the target file. final String targetUrl; @@ -143,13 +144,58 @@ class SingleMapping extends Mapping { final List names; /// Entries indicating the beginning of each span. - final List lines = []; + final List lines; + + SingleMapping._internal(this.targetUrl, this.urls, this.names, this.lines); + + factory SingleMapping.fromEntries( + Iterable entries, [String fileUrl]) { + // The entries needs to be sorted by the target offsets. + var sourceEntries = new List.from(entries)..sort(); + var lines = []; + + // Indices associated with file urls that will be part of the source map. We + // use a linked hash-map so that `_urls.keys[_urls[u]] == u` + var urls = new LinkedHashMap(); + + // Indices associated with identifiers that will be part of the source map. + // We use a linked hash-map so that `_names.keys[_names[n]] == n` + var names = new LinkedHashMap(); + + var lineNum; + var targetEntries; + for (var sourceEntry in sourceEntries) { + if (lineNum == null || sourceEntry.target.line > lineNum) { + lineNum = sourceEntry.target.line; + targetEntries = []; + lines.add(new TargetLineEntry(lineNum, targetEntries)); + } + + if (sourceEntry.source == null) { + targetEntries.add(new TargetEntry(sourceEntry.target.column)); + } else { + var urlId = urls.putIfAbsent( + sourceEntry.source.sourceUrl, () => urls.length); + var srcNameId = sourceEntry.identifierName == null ? null : + names.putIfAbsent(sourceEntry.identifierName, () => names.length); + targetEntries.add(new TargetEntry( + sourceEntry.target.column, + urlId, + sourceEntry.source.line, + sourceEntry.source.column, + srcNameId)); + } + } + return new SingleMapping._internal( + fileUrl, urls.keys.toList(), names.keys.toList(), lines); + } SingleMapping.fromJson(Map map) : targetUrl = map['file'], // TODO(sigmund): add support for 'sourceRoot' urls = map['sources'], - names = map['names'] { + names = map['names'], + lines = [] { int line = 0; int column = 0; int srcUrlId = 0; @@ -215,6 +261,66 @@ class SingleMapping extends Mapping { } } + /// Encodes the Mapping mappings as a json map. + Map toJson() { + var buff = new StringBuffer(); + var line = 0; + var column = 0; + var srcLine = 0; + var srcColumn = 0; + var srcUrlId = 0; + var srcNameId = 0; + var first = true; + + for (var entry in lines) { + int nextLine = entry.line; + if (nextLine > line) { + for (int i = line; i < nextLine; ++i) { + buff.write(';'); + } + line = nextLine; + column = 0; + first = true; + } + + for (var segment in entry.entries) { + if (!first) buff.write(','); + first = false; + column = _append(buff, column, segment.column); + + // Encoding can be just the column offset if there is no source + // information. + var newUrlId = segment.sourceUrlId; + if (newUrlId == null) continue; + srcUrlId = _append(buff, srcUrlId, newUrlId); + srcLine = _append(buff, srcLine, segment.sourceLine); + srcColumn = _append(buff, srcColumn, segment.sourceColumn); + + if (segment.sourceNameId == null) continue; + srcNameId = _append(buff, srcNameId, segment.sourceNameId); + } + } + + var result = { + 'version': 3, + 'sourceRoot': '', + 'sources': urls, + 'names' : names, + 'mappings' : buff.toString() + }; + if (targetUrl != null) { + result['file'] = targetUrl; + } + return result; + } + + /// Appends to [buff] a VLQ encoding of [newValue] using the difference + /// between [oldValue] and [newValue] + static int _append(StringBuffer buff, int oldValue, int newValue) { + buff.writeAll(encodeVlq(newValue - oldValue)); + return newValue; + } + _segmentError(int seen, int line) => new StateError( 'Invalid entry in sourcemap, expected 1, 4, or 5' ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); @@ -308,7 +414,7 @@ class SingleMapping extends Mapping { /// A line entry read from a source map. class TargetLineEntry { final int line; - List entries = []; + List entries; TargetLineEntry(this.line, this.entries); String toString() => '$runtimeType: $line $entries'; diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index afdd7fb2c..8f1be3dc5 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -99,4 +99,15 @@ main() { expect(entry.sourceLine, 0); expect(entry.sourceNameId, 0); }); + + test('parse and re-emit', () { + for (var expected in [ + EXPECTED_MAP, + MAP_WITH_NO_SOURCE_LOCATION, + MAP_WITH_SOURCE_LOCATION, + MAP_WITH_SOURCE_LOCATION_AND_NAME]) { + var mapping = parseJson(expected); + expect(mapping.toJson(), equals(expected)); + } + }); } From eb79592cedbff4734c3b218461b6a115d0a30fe8 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Mon, 14 Jul 2014 09:24:11 +0000 Subject: [PATCH 029/133] Fix class implementing FormatException getting warnings. Update mirrors-used-test count. R=kustermann@google.com Review URL: https://codereview.chromium.org//392563003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38182 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 3 +++ pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 600506ee1..771e9e0ef 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -387,4 +387,7 @@ class SpanException implements Exception { class SpanFormatException extends SpanException implements FormatException { SpanFormatException(String message, Span span) : super(message, span); + + get source => null; + int get position => null; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 9dee45f81..e6e749c8a 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.2+3 +version: 0.9.2+4-dev author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 74e08e7027d6d3e3dd9731f5a4a1bb88ff423aba Mon Sep 17 00:00:00 2001 From: "tjblasi@google.com" Date: Tue, 15 Jul 2014 16:47:12 +0000 Subject: [PATCH 030/133] Adding support for `sourceRoot` to the SingleMapping class. BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//383823002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38241 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/parser.dart | 31 ++++++++++++++++++-------- pkgs/source_maps/test/parser_test.dart | 14 ++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 23835a60f..f53f7edcc 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -16,6 +16,8 @@ import 'src/vlq.dart'; /// Parses a source map directly from a json string. // TODO(sigmund): evaluate whether other maps should have the json parsed, or // the string represenation. +// TODO(tjblasi): Ignore the first line of [jsonMap] if the JSON safety string +// `)]}'` begins the string representation of the map. Mapping parse(String jsonMap, {Map otherMaps}) => parseJson(JSON.decode(jsonMap), otherMaps: otherMaps); @@ -146,6 +148,9 @@ class SingleMapping extends Mapping { /// Entries indicating the beginning of each span. final List lines; + /// Source root appended to the start of all entries in [urls]. + String sourceRoot = null; + SingleMapping._internal(this.targetUrl, this.urls, this.names, this.lines); factory SingleMapping.fromEntries( @@ -192,9 +197,9 @@ class SingleMapping extends Mapping { SingleMapping.fromJson(Map map) : targetUrl = map['file'], - // TODO(sigmund): add support for 'sourceRoot' urls = map['sources'], names = map['names'], + sourceRoot = map['sourceRoot'], lines = [] { int line = 0; int column = 0; @@ -303,7 +308,7 @@ class SingleMapping extends Mapping { var result = { 'version': 3, - 'sourceRoot': '', + 'sourceRoot': sourceRoot == null ? '' : sourceRoot, 'sources': urls, 'names' : names, 'mappings' : buff.toString() @@ -350,6 +355,9 @@ class SingleMapping extends Mapping { var entry = _findColumn(line, column, _findLine(line)); if (entry == null || entry.sourceUrlId == null) return null; var url = urls[entry.sourceUrlId]; + if (sourceRoot != null) { + url = '${sourceRoot}${url}'; + } if (files != null && files[url] != null) { var file = files[url]; var start = file.getOffset(entry.sourceLine, entry.sourceColumn); @@ -374,6 +382,8 @@ class SingleMapping extends Mapping { return (new StringBuffer("$runtimeType : [") ..write('targetUrl: ') ..write(targetUrl) + ..write(', sourceRoot: ') + ..write(sourceRoot) ..write(', urls: ') ..write(urls) ..write(', names: ') @@ -392,13 +402,16 @@ class SingleMapping extends Mapping { ..write(': ') ..write(line) ..write(':') - ..write(entry.column) - ..write(' --> ') - ..write(urls[entry.sourceUrlId]) - ..write(': ') - ..write(entry.sourceLine) - ..write(':') - ..write(entry.sourceColumn); + ..write(entry.column); + if (entry.sourceUrlId != null) { + buff..write(' --> ') + ..write(sourceRoot) + ..write(urls[entry.sourceUrlId]) + ..write(': ') + ..write(entry.sourceLine) + ..write(':') + ..write(entry.sourceColumn); + } if (entry.sourceNameId != null) { buff..write(' (') ..write(names[entry.sourceNameId]) diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 8f1be3dc5..62cd08f1f 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -100,6 +100,20 @@ main() { expect(entry.sourceNameId, 0); }); + test('parse with source root', () { + var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); + inputMap['sourceRoot'] = '/pkg/'; + var mapping = parseJson(inputMap); + expect(mapping.spanFor(0, 0).sourceUrl, "/pkg/input.dart"); + + var newSourceRoot = '/new/'; + + mapping.sourceRoot = newSourceRoot; + inputMap["sourceRoot"] = newSourceRoot; + + expect(mapping.toJson(), equals(inputMap)); + }); + test('parse and re-emit', () { for (var expected in [ EXPECTED_MAP, From 91ea87a9e6bebf643df99ee02063f1efe800e460 Mon Sep 17 00:00:00 2001 From: "tjblasi@google.com" Date: Tue, 15 Jul 2014 18:07:06 +0000 Subject: [PATCH 031/133] Allow updating the `targetUrl` property of SingleMapping. R=sigmund@google.com Review URL: https://codereview.chromium.org//397693002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38245 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/parser.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index f53f7edcc..3fd0d1445 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -136,9 +136,6 @@ class MultiSectionMapping extends Mapping { /// A map containing direct source mappings. class SingleMapping extends Mapping { - /// Url of the target file. - final String targetUrl; - /// Source urls used in the mapping, indexed by id. final List urls; @@ -148,10 +145,13 @@ class SingleMapping extends Mapping { /// Entries indicating the beginning of each span. final List lines; + /// Url of the target file. + String targetUrl; + /// Source root appended to the start of all entries in [urls]. - String sourceRoot = null; + String sourceRoot; - SingleMapping._internal(this.targetUrl, this.urls, this.names, this.lines); + SingleMapping._(this.targetUrl, this.urls, this.names, this.lines); factory SingleMapping.fromEntries( Iterable entries, [String fileUrl]) { @@ -191,7 +191,7 @@ class SingleMapping extends Mapping { srcNameId)); } } - return new SingleMapping._internal( + return new SingleMapping._( fileUrl, urls.keys.toList(), names.keys.toList(), lines); } From c106380a92e912d29d8705a826c73c4ac9c3490d Mon Sep 17 00:00:00 2001 From: "tjblasi@google.com" Date: Wed, 16 Jul 2014 17:49:58 +0000 Subject: [PATCH 032/133] Rev source_maps patch number, package is now 0.9.3. R=sigmund@google.com Review URL: https://codereview.chromium.org//396833003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38295 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 6 ++++++ pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index f40a16d80..7767fc145 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.9.3 + +* Support writing SingleMapping objects to source map version 3 format. +* Support the `sourceRoot` field in the SingleMapping class. +* Support updating the `targetUrl` field in the SingleMapping class. + ## 0.9.2+2 * Fix a bug in `FixedSpan.getLocationMessage`. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index e6e749c8a..ae0323d0c 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.2+4-dev +version: 0.9.3 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From be186a1d45c9112ab448785bb40bb909b55b9bfa Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Fri, 18 Jul 2014 08:22:32 +0000 Subject: [PATCH 033/133] Change "FormatException.position" to be named "offset". Address comments on SpanFormatException changes. R=nweiz@google.com Review URL: https://codereview.chromium.org//396603003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38373 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/span.dart | 7 ++++--- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 7767fc145..c52d585d4 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.4 + +* Update `SpanFormatException` with `source` and `offset`. + ## 0.9.3 * Support writing SingleMapping objects to source map version 3 format. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 771e9e0ef..7b513e6be 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -385,9 +385,10 @@ class SpanException implements Exception { /// A [SpanException] that's also a [FormatException]. class SpanFormatException extends SpanException implements FormatException { - SpanFormatException(String message, Span span) + final source; + + SpanFormatException(String message, Span span, [this.source]) : super(message, span); - get source => null; - int get position => null; + int get position => span == null ? null : span.start.offset; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index ae0323d0c..c5029e2d9 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.3 +version: 0.9.4 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From af4e166a34eb68e0f7ead74803b662281ddb3b0e Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Fri, 18 Jul 2014 08:57:34 +0000 Subject: [PATCH 034/133] Use the new "offset" name in span.dart too. Review URL: https://codereview.chromium.org//397343005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38376 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/span.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 7b513e6be..b546a97aa 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -390,5 +390,5 @@ class SpanFormatException extends SpanException implements FormatException { SpanFormatException(String message, Span span, [this.source]) : super(message, span); - int get position => span == null ? null : span.start.offset; + int get offset => span == null ? null : span.start.offset; } From b3e5fcea34ecb57d46fd0e2467612e9d1df7550f Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Fri, 18 Jul 2014 09:22:58 +0000 Subject: [PATCH 035/133] Change "FormatException.position" to be named "offset". Address comments on SpanFormatException changes. R=nweiz@google.com Committed: https://code.google.com/p/dart/source/detail?r=38373 Review URL: https://codereview.chromium.org//396603003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38378 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 ---- pkgs/source_maps/lib/span.dart | 7 +++---- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index c52d585d4..7767fc145 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,7 +1,3 @@ -## 0.9.4 - -* Update `SpanFormatException` with `source` and `offset`. - ## 0.9.3 * Support writing SingleMapping objects to source map version 3 format. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index b546a97aa..771e9e0ef 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -385,10 +385,9 @@ class SpanException implements Exception { /// A [SpanException] that's also a [FormatException]. class SpanFormatException extends SpanException implements FormatException { - final source; - - SpanFormatException(String message, Span span, [this.source]) + SpanFormatException(String message, Span span) : super(message, span); - int get offset => span == null ? null : span.start.offset; + get source => null; + int get position => null; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index c5029e2d9..ae0323d0c 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.4 +version: 0.9.3 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 3928ed938e6a4c4c937cb5885d39aa5d3b1078b9 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Fri, 18 Jul 2014 09:25:48 +0000 Subject: [PATCH 036/133] Change "FormatException.position" to be named "offset". Address comments on SpanFormatException changes. R=nweiz@google.com Committed: https://code.google.com/p/dart/source/detail?r=38373 Committed: https://code.google.com/p/dart/source/detail?r=38378 Review URL: https://codereview.chromium.org//396603003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38379 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/span.dart | 7 ++++--- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 7767fc145..c52d585d4 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.4 + +* Update `SpanFormatException` with `source` and `offset`. + ## 0.9.3 * Support writing SingleMapping objects to source map version 3 format. diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index 771e9e0ef..b546a97aa 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -385,9 +385,10 @@ class SpanException implements Exception { /// A [SpanException] that's also a [FormatException]. class SpanFormatException extends SpanException implements FormatException { - SpanFormatException(String message, Span span) + final source; + + SpanFormatException(String message, Span span, [this.source]) : super(message, span); - get source => null; - int get position => null; + int get offset => span == null ? null : span.start.offset; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index ae0323d0c..c5029e2d9 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,7 +7,7 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.3 +version: 0.9.4 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 333a0e54f9c449864fed175ecece66e075385632 Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Wed, 23 Jul 2014 23:17:23 +0000 Subject: [PATCH 037/133] Deprecate the source_maps span classes. This also updates source_maps to take the new classes where possible. BUG=19930 R=sigmund@google.com Review URL: https://codereview.chromium.org//402843003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38524 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 4 + pkgs/source_maps/lib/builder.dart | 37 ++++++++-- pkgs/source_maps/lib/parser.dart | 26 +++++-- pkgs/source_maps/lib/printer.dart | 30 +++++--- pkgs/source_maps/lib/refactor.dart | 9 ++- pkgs/source_maps/lib/span.dart | 10 +++ pkgs/source_maps/lib/src/span_wrapper.dart | 85 ++++++++++++++++++++++ pkgs/source_maps/pubspec.yaml | 3 +- 8 files changed, 180 insertions(+), 24 deletions(-) create mode 100644 pkgs/source_maps/lib/src/span_wrapper.dart diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index c52d585d4..6d371c9bf 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -2,6 +2,10 @@ * Update `SpanFormatException` with `source` and `offset`. +* All methods that take `Span`s, `Location`s, and `SourceFile`s as inputs now + also accept the corresponding `source_span` classes as well. Using the old + classes is now deprecated and will be unsupported in version 0.10.0. + ## 0.9.3 * Support writing SingleMapping objects to source map version 3 format. diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index cd30ccb94..494a6b6e9 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -11,6 +11,7 @@ import 'dart:convert'; import 'parser.dart'; import 'span.dart'; +import 'src/span_wrapper.dart'; /// Builds a source map given a set of mappings. class SourceMapBuilder { @@ -18,8 +19,10 @@ class SourceMapBuilder { final List _entries = []; /// Adds an entry mapping the [targetOffset] to [source]. - void addFromOffset(Location source, - SourceFile targetFile, int targetOffset, String identifier) { + /// + /// [source] can be either a [Location] or a [SourceLocation]. Using a + /// [Location] is deprecated and will be unsupported in version 0.10.0. + void addFromOffset(source, targetFile, int targetOffset, String identifier) { if (targetFile == null) { throw new ArgumentError('targetFile cannot be null'); } @@ -28,12 +31,27 @@ class SourceMapBuilder { } /// Adds an entry mapping [target] to [source]. - void addSpan(Span source, Span target) { - var name = source.isIdentifier ? source.text : null; + /// + /// [source] and [target] can be either a [Span] or a [SourceSpan]. Using a + /// [Span] is deprecated and will be unsupported in version 0.10.0. + /// + /// If [isIdentifier] is true, this entry is considered to represent an + /// identifier whose value will be stored in the source map. + void addSpan(source, target, {bool isIdentifier}) { + source = SpanWrapper.wrap(source); + target = SpanWrapper.wrap(target); + if (isIdentifier == null) isIdentifier = source.isIdentifier; + + var name = isIdentifier ? source.text : null; _entries.add(new Entry(source.start, target.start, name)); } - void addLocation(Location source, Location target, String identifier) { + /// Adds an entry mapping [target] to [source]. + /// + /// [source] and [target] can be either a [Location] or a [SourceLocation]. + /// Using a [Location] is deprecated and will be unsupported in version + /// 0.10.0. + void addLocation(source, target, String identifier) { _entries.add(new Entry(source, target, identifier)); } @@ -57,7 +75,14 @@ class Entry implements Comparable { /// An identifier name, when this location is the start of an identifier. final String identifierName; - Entry(this.source, this.target, this.identifierName); + /// Creates a new [Entry] mapping [target] to [source]. + /// + /// [source] and [target] can be either a [Location] or a [SourceLocation]. + /// Using a [Location] is deprecated and will be unsupported in version + /// 0.10.0. + Entry(source, target, this.identifierName) + : source = LocationWrapper.wrap(source), + target = LocationWrapper.wrap(target); /// Implements [Comparable] to ensure that entries are ordered by their /// location in the target file. We sort primarily by the target offset diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 3fd0d1445..c18a1d69b 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -10,6 +10,7 @@ import 'dart:convert'; import 'builder.dart' as builder; import 'span.dart'; +import 'src/span_wrapper.dart'; import 'src/utils.dart'; import 'src/vlq.dart'; @@ -47,10 +48,21 @@ Mapping parseJson(Map map, {Map otherMaps}) { /// A mapping parsed out of a source map. abstract class Mapping { - Span spanFor(int line, int column, {Map files}); - - Span spanForLocation(Location loc, {Map files}) { - return spanFor(loc.line, loc.column, files: files); + /// Returns the span associated with [line] and [column]. + /// + /// The values of [files] can be either `source_map` [SourceFile]s or + /// `source_span` `SourceFile`s. Using `source_map` [SourceFile]s is + /// deprecated and will be unsupported in version 0.10.0. + Span spanFor(int line, int column, {Map files}); + + /// Returns the span associated with [location]. + /// + /// The values of [files] may be either `source_map` [SourceFile]s or + /// `source_span` `SourceFile`s. Using `source_map` [SourceFile]s is + /// deprecated and will be unsupported in version 0.10.0. + Span spanForLocation(location, {Map files}) { + location = LocationWrapper.wrap(location); + return spanFor(location.line, location.column, files: files); } } @@ -112,7 +124,7 @@ class MultiSectionMapping extends Mapping { return _lineStart.length - 1; } - Span spanFor(int line, int column, {Map files}) { + Span spanFor(int line, int column, {Map files}) { int index = _indexFor(line, column); return _maps[index].spanFor( line - _lineStart[index], column - _columnStart[index], files: files); @@ -351,7 +363,7 @@ class SingleMapping extends Mapping { return (index <= 0) ? null : entries[index - 1]; } - Span spanFor(int line, int column, {Map files}) { + Span spanFor(int line, int column, {Map files}) { var entry = _findColumn(line, column, _findLine(line)); if (entry == null || entry.sourceUrlId == null) return null; var url = urls[entry.sourceUrlId]; @@ -359,7 +371,7 @@ class SingleMapping extends Mapping { url = '${sourceRoot}${url}'; } if (files != null && files[url] != null) { - var file = files[url]; + var file = SourceFileWrapper.wrap(files[url]); var start = file.getOffset(entry.sourceLine, entry.sourceColumn); if (entry.sourceNameId != null) { var text = names[entry.sourceNameId]; diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 0898017c4..aa18bd764 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -5,8 +5,11 @@ /// Contains a code printer that generates code by recording the source maps. library source_maps.printer; +import 'package:source_span/source_span.dart' as source_span; + import 'builder.dart'; import 'span.dart'; +import 'src/span_wrapper.dart'; const int _LF = 10; const int _CR = 13; @@ -75,9 +78,10 @@ class Printer { void mark(mark) { var loc; var identifier = null; - if (mark is Location) { - loc = mark; - } else if (mark is Span) { + if (mark is Location || mark is source_span.SourceLocation) { + loc = LocationWrapper.wrap(mark); + } else if (mark is Span || mark is source_span.SourceSpan) { + mark = SpanWrapper.wrap(mark); loc = mark.start; if (mark.isIdentifier) identifier = mark.text; } @@ -124,15 +128,19 @@ class NestedPrinter implements NestedItem { /// location of [object] in the original input. Only one, [location] or /// [span], should be provided at a time. /// + /// [location] can be either a [Location] or a [SourceLocation]. [span] can be + /// either a [Span] or a [SourceSpan]. Using a [Location] or a [Span] is + /// deprecated and will be unsupported in version 0.10.0. + /// /// Indicate [isOriginal] when [object] is copied directly from the user code. /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. - void add(object, {Location location, Span span, bool isOriginal: false}) { + void add(object, {location, span, bool isOriginal: false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); assert(location == null || span == null); - if (location != null) _items.add(location); - if (span != null) _items.add(span); + if (location != null) _items.add(LocationWrapper.wrap(location)); + if (span != null) _items.add(SpanWrapper.wrap(span)); if (isOriginal) _items.add(_ORIGINAL); } @@ -156,12 +164,16 @@ class NestedPrinter implements NestedItem { /// The [location] and [span] parameters indicate the corresponding source map /// location of [object] in the original input. Only one, [location] or /// [span], should be provided at a time. - void addLine(String line, {Location location, Span span}) { + /// + /// [location] can be either a [Location] or a [SourceLocation]. [span] can be + /// either a [Span] or a [SourceSpan]. Using a [Location] or a [Span] is + /// deprecated and will be unsupported in version 0.10.0. + void addLine(String line, {location, span}) { if (location != null || span != null) { _flush(); assert(location == null || span == null); - if (location != null) _items.add(location); - if (span != null) _items.add(span); + if (location != null) _items.add(LocationWrapper.wrap(location)); + if (span != null) _items.add(SpanWrapper.wrap(span)); } if (line == null) return; if (line != '') { diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 45fb06949..47ce2ed90 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -10,6 +10,7 @@ library source_maps.refactor; import 'span.dart'; import 'printer.dart'; +import 'src/span_wrapper.dart'; /// Editable text transaction. /// @@ -20,7 +21,13 @@ class TextEditTransaction { final String original; final _edits = <_TextEdit>[]; - TextEditTransaction(this.original, this.file); + /// Creates a new transaction. + /// + /// [file] can be either a `source_map` [SourceFile] or a `source_span` + /// `SourceFile`. Using a `source_map` [SourceFile] is deprecated and will be + /// unsupported in version 0.10.0. + TextEditTransaction(this.original, file) + : file = SourceFileWrapper.wrap(file); bool get hasEdits => _edits.length > 0; diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart index b546a97aa..a21e893b7 100644 --- a/pkgs/source_maps/lib/span.dart +++ b/pkgs/source_maps/lib/span.dart @@ -12,6 +12,7 @@ import 'package:path/path.dart' as p; import 'src/utils.dart'; /// A simple class that describe a segment of source text. +@Deprecated("Use the source_span package instead.") abstract class Span implements Comparable { /// The start location of this span. final Location start; @@ -79,6 +80,7 @@ abstract class Span implements Comparable { } /// A location in the source text +@Deprecated("Use the source_span package instead.") abstract class Location implements Comparable { /// Url of the source containing this span. String get sourceUrl; @@ -113,6 +115,7 @@ abstract class Location implements Comparable { } /// Implementation of [Location] with fixed values given at allocation time. +@Deprecated("Use the source_span package instead.") class FixedLocation extends Location { final String sourceUrl; final int line; @@ -123,6 +126,7 @@ class FixedLocation extends Location { } /// Implementation of [Span] where all the values are given at allocation time. +@Deprecated("Use the source_span package instead.") class FixedSpan extends Span { /// The source text for this span, if available. final String text; @@ -137,6 +141,7 @@ class FixedSpan extends Span { } /// [Location] with values computed from an underling [SourceFile]. +@Deprecated("Use the source_span package instead.") class FileLocation extends Location { /// The source file containing this location. final SourceFile file; @@ -149,6 +154,7 @@ class FileLocation extends Location { } /// [Span] where values are computed from an underling [SourceFile]. +@Deprecated("Use the source_span package instead.") class FileSpan extends Span { /// The source file containing this span. final SourceFile file; @@ -195,6 +201,7 @@ const String _NO_COLOR = '\u001b[0m'; /// Stores information about a source file, to permit computation of the line /// and column. Also contains a nice default error message highlighting the code /// location. +@Deprecated("Use the source_span package instead.") class SourceFile { /// Url where the source file is located. final String url; @@ -306,6 +313,7 @@ class SourceFile { /// allows you to set source-map locations based on the locations relative to /// the start of the segment, but that get translated to absolute locations in /// the original source file. +@Deprecated("Use the source_span package instead.") class SourceFileSegment extends SourceFile { final int _baseOffset; final int _baseLine; @@ -365,6 +373,7 @@ class SourceFileSegment extends SourceFile { } /// A class for exceptions that have source span information attached. +@Deprecated("Use the source_span package instead.") class SpanException implements Exception { /// A message describing the exception. final String message; @@ -384,6 +393,7 @@ class SpanException implements Exception { } /// A [SpanException] that's also a [FormatException]. +@Deprecated("Use the source_span package instead.") class SpanFormatException extends SpanException implements FormatException { final source; diff --git a/pkgs/source_maps/lib/src/span_wrapper.dart b/pkgs/source_maps/lib/src/span_wrapper.dart new file mode 100644 index 000000000..e0c107bf7 --- /dev/null +++ b/pkgs/source_maps/lib/src/span_wrapper.dart @@ -0,0 +1,85 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// 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. + +library source_maps.span_wrapper; + +import 'package:source_span/source_span.dart' as source_span; + +import '../span.dart'; + +/// A wrapper that exposes a [source_span.SourceSpan] as a [Span]. +class SpanWrapper extends Span { + final source_span.SourceSpan _inner; + + String get text => _inner.text; + + SpanWrapper(source_span.SourceSpan inner, bool isIdentifier) + : _inner = inner, + super( + new LocationWrapper(inner.start), + new LocationWrapper(inner.end), + isIdentifier); + + static Span wrap(span, [bool isIdentifier = false]) { + if (span is Span) return span; + return new SpanWrapper(span, isIdentifier); + } +} + +/// A wrapper that exposes a [source_span.SourceLocation] as a [Location]. +class LocationWrapper extends Location { + final source_span.SourceLocation _inner; + + String get sourceUrl => _inner.sourceUrl.toString(); + int get line => _inner.line; + int get column => _inner.column; + + LocationWrapper(source_span.SourceLocation inner) + : _inner = inner, + super(inner.offset); + + static Location wrap(location) { + if (location is Location) return location; + return new LocationWrapper(location); + } +} + +/// A wrapper that exposes a [source_span.SourceFile] as a [SourceFile]. +class SourceFileWrapper implements SourceFile { + final source_span.SourceFile _inner; + + // These are necessary to avoid analyzer warnings; + final _lineStarts = null; + final _decodedChars = null; + + String get url => _inner.url.toString(); + + SourceFileWrapper(this._inner); + + static SourceFile wrap(sourceFile) { + if (sourceFile is SourceFile) return sourceFile; + return new SourceFileWrapper(sourceFile); + } + + Span span(int start, [int end, bool isIdentifier = false]) { + if (end == null) end = start; + return new SpanWrapper(_inner.span(start, end), isIdentifier); + } + + Location location(int offset) => new LocationWrapper(_inner.location(offset)); + + int getLine(int offset) => _inner.getLine(offset); + + int getColumn(int line, int offset) => _inner.getColumn(offset, line: line); + + int getOffset(int line, int column) => _inner.getOffset(line, column); + + String getText(int start, [int end]) => _inner.getText(start, end); + + String getLocationMessage(String message, int start, int end, + {bool useColors: false, String color}) { + return span(start, end).getLocationMessage(message, + useColors: useColors, color: color); + } +} diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index c5029e2d9..0548215b1 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -7,12 +7,13 @@ name: source_maps # # When the minor version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 0.9.4 +version: 0.9.4-dev author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org dependencies: path: '>=1.2.0 <2.0.0' + source_span: '>=1.0.0 <2.0.0' environment: sdk: '>=0.8.10+6 <2.0.0' dev_dependencies: From 96b1161c2a8803c6d8eeae1797c110e2e2accb93 Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Thu, 31 Jul 2014 22:04:31 +0000 Subject: [PATCH 038/133] Remove support for the old Span classes from source_maps. This releases source_maps 0.10.0, code_transformers 0.2.0+2, observe 0.11.0+3, and polymer 0.12.0+4. BUG=19930 R=sigmund@google.com Review URL: https://codereview.chromium.org//421723004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38803 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/lib/builder.dart | 54 +-- pkgs/source_maps/lib/parser.dart | 41 +- pkgs/source_maps/lib/printer.dart | 64 ++- pkgs/source_maps/lib/refactor.dart | 17 +- pkgs/source_maps/lib/source_maps.dart | 5 +- pkgs/source_maps/lib/span.dart | 404 ------------------ pkgs/source_maps/lib/src/source_map_span.dart | 59 +++ pkgs/source_maps/lib/src/span_wrapper.dart | 85 ---- pkgs/source_maps/test/builder_test.dart | 4 +- pkgs/source_maps/test/common.dart | 44 +- pkgs/source_maps/test/end2end_test.dart | 31 +- pkgs/source_maps/test/parser_test.dart | 2 +- pkgs/source_maps/test/printer_test.dart | 11 +- pkgs/source_maps/test/refactor_test.dart | 88 +++- pkgs/source_maps/test/run.dart | 2 - pkgs/source_maps/test/span_test.dart | 341 --------------- 16 files changed, 254 insertions(+), 998 deletions(-) delete mode 100644 pkgs/source_maps/lib/span.dart create mode 100644 pkgs/source_maps/lib/src/source_map_span.dart delete mode 100644 pkgs/source_maps/lib/src/span_wrapper.dart delete mode 100644 pkgs/source_maps/test/span_test.dart diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 494a6b6e9..091e220c5 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -9,9 +9,10 @@ library source_maps.builder; import 'dart:convert'; +import 'package:source_span/source_span.dart'; + import 'parser.dart'; -import 'span.dart'; -import 'src/span_wrapper.dart'; +import 'src/source_map_span.dart'; /// Builds a source map given a set of mappings. class SourceMapBuilder { @@ -19,39 +20,33 @@ class SourceMapBuilder { final List _entries = []; /// Adds an entry mapping the [targetOffset] to [source]. - /// - /// [source] can be either a [Location] or a [SourceLocation]. Using a - /// [Location] is deprecated and will be unsupported in version 0.10.0. - void addFromOffset(source, targetFile, int targetOffset, String identifier) { + void addFromOffset(SourceLocation source, SourceFile targetFile, + int targetOffset, String identifier) { if (targetFile == null) { throw new ArgumentError('targetFile cannot be null'); } - _entries.add(new Entry(source, - new FileLocation(targetFile, targetOffset), identifier)); + _entries.add( + new Entry(source, targetFile.location(targetOffset), identifier)); } /// Adds an entry mapping [target] to [source]. /// - /// [source] and [target] can be either a [Span] or a [SourceSpan]. Using a - /// [Span] is deprecated and will be unsupported in version 0.10.0. - /// - /// If [isIdentifier] is true, this entry is considered to represent an - /// identifier whose value will be stored in the source map. - void addSpan(source, target, {bool isIdentifier}) { - source = SpanWrapper.wrap(source); - target = SpanWrapper.wrap(target); - if (isIdentifier == null) isIdentifier = source.isIdentifier; + /// If [isIdentifier] is true or if [target] is a [SourceMapSpan] with + /// `isIdentifier` set to true, this entry is considered to represent an + /// identifier whose value will be stored in the source map. [isIdenfier] + /// takes precedence over [target]'s `isIdentifier` value. + void addSpan(SourceSpan source, SourceSpan target, {bool isIdentifier}) { + if (isIdentifier == null) { + isIdentifier = source is SourceMapSpan ? source.isIdentifier : false; + } var name = isIdentifier ? source.text : null; _entries.add(new Entry(source.start, target.start, name)); } /// Adds an entry mapping [target] to [source]. - /// - /// [source] and [target] can be either a [Location] or a [SourceLocation]. - /// Using a [Location] is deprecated and will be unsupported in version - /// 0.10.0. - void addLocation(source, target, String identifier) { + void addLocation(SourceLocation source, SourceLocation target, + String identifier) { _entries.add(new Entry(source, target, identifier)); } @@ -67,22 +62,16 @@ class SourceMapBuilder { /// An entry in the source map builder. class Entry implements Comparable { /// Span denoting the original location in the input source file - final Location source; + final SourceLocation source; /// Span indicating the corresponding location in the target file. - final Location target; + final SourceLocation target; /// An identifier name, when this location is the start of an identifier. final String identifierName; /// Creates a new [Entry] mapping [target] to [source]. - /// - /// [source] and [target] can be either a [Location] or a [SourceLocation]. - /// Using a [Location] is deprecated and will be unsupported in version - /// 0.10.0. - Entry(source, target, this.identifierName) - : source = LocationWrapper.wrap(source), - target = LocationWrapper.wrap(target); + Entry(this.source, this.target, this.identifierName); /// Implements [Comparable] to ensure that entries are ordered by their /// location in the target file. We sort primarily by the target offset @@ -91,7 +80,8 @@ class Entry implements Comparable { int compareTo(Entry other) { int res = target.compareTo(other.target); if (res != 0) return res; - res = source.sourceUrl.compareTo(other.source.sourceUrl); + res = source.sourceUrl.toString().compareTo( + other.source.sourceUrl.toString()); if (res != 0) return res; return source.compareTo(other.source); } diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index c18a1d69b..d67a65e58 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -8,9 +8,10 @@ library source_maps.parser; import 'dart:collection'; import 'dart:convert'; +import 'package:source_span/source_span.dart'; + import 'builder.dart' as builder; -import 'span.dart'; -import 'src/span_wrapper.dart'; +import 'src/source_map_span.dart'; import 'src/utils.dart'; import 'src/vlq.dart'; @@ -49,19 +50,11 @@ Mapping parseJson(Map map, {Map otherMaps}) { /// A mapping parsed out of a source map. abstract class Mapping { /// Returns the span associated with [line] and [column]. - /// - /// The values of [files] can be either `source_map` [SourceFile]s or - /// `source_span` `SourceFile`s. Using `source_map` [SourceFile]s is - /// deprecated and will be unsupported in version 0.10.0. - Span spanFor(int line, int column, {Map files}); + SourceMapSpan spanFor(int line, int column, {Map files}); /// Returns the span associated with [location]. - /// - /// The values of [files] may be either `source_map` [SourceFile]s or - /// `source_span` `SourceFile`s. Using `source_map` [SourceFile]s is - /// deprecated and will be unsupported in version 0.10.0. - Span spanForLocation(location, {Map files}) { - location = LocationWrapper.wrap(location); + SourceMapSpan spanForLocation(SourceLocation location, + {Map files}) { return spanFor(location.line, location.column, files: files); } } @@ -124,7 +117,7 @@ class MultiSectionMapping extends Mapping { return _lineStart.length - 1; } - Span spanFor(int line, int column, {Map files}) { + SourceMapSpan spanFor(int line, int column, {Map files}) { int index = _indexFor(line, column); return _maps[index].spanFor( line - _lineStart[index], column - _columnStart[index], files: files); @@ -191,8 +184,9 @@ class SingleMapping extends Mapping { if (sourceEntry.source == null) { targetEntries.add(new TargetEntry(sourceEntry.target.column)); } else { + var sourceUrl = sourceEntry.source.sourceUrl; var urlId = urls.putIfAbsent( - sourceEntry.source.sourceUrl, () => urls.length); + sourceUrl == null ? '' : sourceUrl.toString(), () => urls.length); var srcNameId = sourceEntry.identifierName == null ? null : names.putIfAbsent(sourceEntry.identifierName, () => names.length); targetEntries.add(new TargetEntry( @@ -363,7 +357,7 @@ class SingleMapping extends Mapping { return (index <= 0) ? null : entries[index - 1]; } - Span spanFor(int line, int column, {Map files}) { + SourceMapSpan spanFor(int line, int column, {Map files}) { var entry = _findColumn(line, column, _findLine(line)); if (entry == null || entry.sourceUrlId == null) return null; var url = urls[entry.sourceUrlId]; @@ -371,21 +365,24 @@ class SingleMapping extends Mapping { url = '${sourceRoot}${url}'; } if (files != null && files[url] != null) { - var file = SourceFileWrapper.wrap(files[url]); + var file = files[url]; var start = file.getOffset(entry.sourceLine, entry.sourceColumn); if (entry.sourceNameId != null) { var text = names[entry.sourceNameId]; - return new FileSpan(files[url], start, start + text.length, true); + return new SourceMapFileSpan( + files[url].span(start, start + text.length), + isIdentifier: true); } else { - return new FileSpan(files[url], start); + return new SourceMapFileSpan(files[url].location(start).pointSpan()); } } else { + var start = new SourceLocation(0, + sourceUrl: url, line: entry.sourceLine, column: entry.sourceColumn); // Offset and other context is not available. if (entry.sourceNameId != null) { - return new FixedSpan(url, 0, entry.sourceLine, entry.sourceColumn, - text: names[entry.sourceNameId], isIdentifier: true); + return new SourceMapSpan.identifier(start, names[entry.sourceNameId]); } else { - return new FixedSpan(url, 0, entry.sourceLine, entry.sourceColumn); + return new SourceMapSpan(start, start, ''); } } } diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index aa18bd764..906e260f8 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -5,11 +5,10 @@ /// Contains a code printer that generates code by recording the source maps. library source_maps.printer; -import 'package:source_span/source_span.dart' as source_span; +import 'package:source_span/source_span.dart'; import 'builder.dart'; -import 'span.dart'; -import 'src/span_wrapper.dart'; +import 'src/source_map_span.dart'; const int _LF = 10; const int _CR = 13; @@ -24,7 +23,7 @@ class Printer { String get map => _maps.toJson(filename); /// Current source location mapping. - Location _loc; + SourceLocation _loc; /// Current line in the buffer; int _line = 0; @@ -49,11 +48,12 @@ class Printer { _line++; _column = 0; if (projectMarks && _loc != null) { - if (_loc is FixedLocation) { - mark(new FixedLocation(0, _loc.sourceUrl, _loc.line + 1, 0)); - } else if (_loc is FileLocation) { + if (_loc is FileLocation) { var file = (_loc as FileLocation).file; - mark(new FileLocation(file, file.getOffset(_loc.line + 1, 0))); + mark(file.location(file.getOffset(_loc.line + 1))); + } else { + mark(new SourceLocation(0, + sourceUrl: _loc.sourceUrl, line: _loc.line + 1, column: 0)); } } } else { @@ -72,21 +72,23 @@ class Printer { } /// Marks that the current point in the target file corresponds to the [mark] - /// in the source file, which can be either a [Location] or a [Span]. When the - /// mark is an identifier's Span, this also records the name of the identifier - /// in the source map information. + /// in the source file, which can be either a [SourceLocation] or a + /// [SourceSpan]. When the mark is a [SourceMapSpan] with `isIdentifier` set, + /// this also records the name of the identifier in the source map + /// information. void mark(mark) { var loc; var identifier = null; - if (mark is Location || mark is source_span.SourceLocation) { - loc = LocationWrapper.wrap(mark); - } else if (mark is Span || mark is source_span.SourceSpan) { - mark = SpanWrapper.wrap(mark); + if (mark is SourceLocation) { + loc = mark; + } else if (mark is SourceSpan) { loc = mark.start; - if (mark.isIdentifier) identifier = mark.text; + if (mark is SourceMapSpan && mark.isIdentifier) identifier = mark.text; } - _maps.addLocation(loc, - new FixedLocation(_buff.length, null, _line, _column), identifier); + _maps.addLocation( + loc, + new SourceLocation(_buff.length, line: _line, column: _column), + identifier); _loc = loc; } } @@ -101,7 +103,8 @@ class Printer { class NestedPrinter implements NestedItem { /// Items recoded by this printer, which can be [String] literals, - /// [NestedItem]s, and source map information like [Location] and [Span]. + /// [NestedItem]s, and source map information like [SourceLocation] and + /// [SourceSpan]. List _items = []; /// Internal buffer to merge consecutive strings added to this printer. @@ -128,19 +131,16 @@ class NestedPrinter implements NestedItem { /// location of [object] in the original input. Only one, [location] or /// [span], should be provided at a time. /// - /// [location] can be either a [Location] or a [SourceLocation]. [span] can be - /// either a [Span] or a [SourceSpan]. Using a [Location] or a [Span] is - /// deprecated and will be unsupported in version 0.10.0. - /// /// Indicate [isOriginal] when [object] is copied directly from the user code. /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. - void add(object, {location, span, bool isOriginal: false}) { + void add(object, {SourceLocation location, SourceSpan span, + bool isOriginal: false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); assert(location == null || span == null); - if (location != null) _items.add(LocationWrapper.wrap(location)); - if (span != null) _items.add(SpanWrapper.wrap(span)); + if (location != null) _items.add(location); + if (span != null) _items.add(span); if (isOriginal) _items.add(_ORIGINAL); } @@ -164,16 +164,12 @@ class NestedPrinter implements NestedItem { /// The [location] and [span] parameters indicate the corresponding source map /// location of [object] in the original input. Only one, [location] or /// [span], should be provided at a time. - /// - /// [location] can be either a [Location] or a [SourceLocation]. [span] can be - /// either a [Span] or a [SourceSpan]. Using a [Location] or a [Span] is - /// deprecated and will be unsupported in version 0.10.0. - void addLine(String line, {location, span}) { + void addLine(String line, {SourceLocation location, SourceSpan span}) { if (location != null || span != null) { _flush(); assert(location == null || span == null); - if (location != null) _items.add(LocationWrapper.wrap(location)); - if (span != null) _items.add(SpanWrapper.wrap(span)); + if (location != null) _items.add(location); + if (span != null) _items.add(span); } if (line == null) return; if (line != '') { @@ -235,7 +231,7 @@ class NestedPrinter implements NestedItem { } else if (item is String) { printer.add(item, projectMarks: propagate); propagate = false; - } else if (item is Location || item is Span) { + } else if (item is SourceLocation || item is SourceSpan) { printer.mark(item); } else if (item == _ORIGINAL) { // we insert booleans when we are about to quote text that was copied diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 47ce2ed90..a33b86bec 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -8,9 +8,9 @@ /// [guessIndent] helps to guess the appropriate indentiation for the new code. library source_maps.refactor; -import 'span.dart'; +import 'package:source_span/source_span.dart'; + import 'printer.dart'; -import 'src/span_wrapper.dart'; /// Editable text transaction. /// @@ -22,12 +22,7 @@ class TextEditTransaction { final _edits = <_TextEdit>[]; /// Creates a new transaction. - /// - /// [file] can be either a `source_map` [SourceFile] or a `source_span` - /// `SourceFile`. Using a `source_map` [SourceFile] is deprecated and will be - /// unsupported in version 0.10.0. - TextEditTransaction(this.original, file) - : file = SourceFileWrapper.wrap(file); + TextEditTransaction(this.original, this.file); bool get hasEdits => _edits.length > 0; @@ -38,8 +33,8 @@ class TextEditTransaction { _edits.add(new _TextEdit(begin, end, replacement)); } - /// Create a source map [Location] for [offset]. - Location _loc(int offset) => + /// Create a source map [SourceLocation] for [offset]. + SourceLocation _loc(int offset) => file != null ? file.location(offset) : null; /// Applies all pending [edit]s and returns a [NestedPrinter] containing the @@ -62,7 +57,7 @@ class TextEditTransaction { for (var edit in _edits) { if (consumed > edit.begin) { var sb = new StringBuffer(); - sb..write(file.location(edit.begin).formatString) + sb..write(file.location(edit.begin).toolString) ..write(': overlapping edits. Insert at offset ') ..write(edit.begin) ..write(' but have consumed ') diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 2d4a4ccc4..953190341 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -11,7 +11,8 @@ /// ..add(inputSpan3, outputSpan3) /// .toJson(outputFile); /// -/// Use the [Span] and [SourceFile] classes to specify span locations. +/// Use the source_span package's [SourceSpan] and [SourceFile] classes to +/// specify span locations. /// /// Parse a source map using [parse], and call `spanFor` on the returned mapping /// object. For example: @@ -40,4 +41,4 @@ export "builder.dart"; export "parser.dart"; export "printer.dart"; export "refactor.dart"; -export "span.dart"; +export 'src/source_map_span.dart'; diff --git a/pkgs/source_maps/lib/span.dart b/pkgs/source_maps/lib/span.dart deleted file mode 100644 index a21e893b7..000000000 --- a/pkgs/source_maps/lib/span.dart +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// 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. - -/// Dart classes representing the souce spans and source files. -library source_maps.span; - -import 'dart:math' show min, max; - -import 'package:path/path.dart' as p; - -import 'src/utils.dart'; - -/// A simple class that describe a segment of source text. -@Deprecated("Use the source_span package instead.") -abstract class Span implements Comparable { - /// The start location of this span. - final Location start; - - /// The end location of this span, exclusive. - final Location end; - - /// Url of the source (typically a file) containing this span. - String get sourceUrl => start.sourceUrl; - - /// The length of this span, in characters. - int get length => end.offset - start.offset; - - /// The source text for this span, if available. - String get text; - - /// Whether [text] corresponds to an identifier symbol. - final bool isIdentifier; - - Span(this.start, this.end, bool isIdentifier) - : isIdentifier = isIdentifier != null ? isIdentifier : false { - _checkRange(); - } - - /// Creates a new span that is the union of two existing spans [start] and - /// [end]. Note that the resulting span might contain some positions that were - /// not in either of the original spans if [start] and [end] are disjoint. - Span.union(Span start, Span end) - : start = start.start, end = end.end, isIdentifier = false { - _checkRange(); - } - - void _checkRange() { - if (start.offset < 0) throw new ArgumentError('start $start must be >= 0'); - if (end.offset < start.offset) { - throw new ArgumentError('end $end must be >= start $start'); - } - } - - /// Compares two spans. If the spans are not in the same source, this method - /// generates an error. - int compareTo(Span other) { - int d = start.compareTo(other.start); - return d == 0 ? end.compareTo(other.end) : d; - } - - /// Gets the location in standard printed form `filename:line:column`, where - /// line and column are adjusted by 1 to match the convention in editors. - String get formatLocation => start.formatString; - - String getLocationMessage(String message, - {bool useColors: false, String color}) { - var source = start.sourceUrl == null ? '' : - ' of ${p.prettyUri(start.sourceUrl)}'; - return 'line ${start.line + 1}, column ${start.column + 1}$source: ' + - message; - } - - bool operator ==(Span other) => - sourceUrl == other.sourceUrl && start == other.start && end == other.end; - - int get hashCode => sourceUrl.hashCode + start.offset + (31 * length); - - String toString() => '<$runtimeType: $start $end $formatLocation $text>'; -} - -/// A location in the source text -@Deprecated("Use the source_span package instead.") -abstract class Location implements Comparable { - /// Url of the source containing this span. - String get sourceUrl; - - /// The offset of this location, 0-based. - final int offset; - - /// The 0-based line in the source of this location. - int get line; - - /// The 0-based column in the source of this location. - int get column; - - Location(this.offset); - - /// Compares two locations. If the locations are not in the same source, this - /// method generates an error. - int compareTo(Location other) { - if (sourceUrl != other.sourceUrl) { - throw new ArgumentError('can only compare locations of the same source'); - } - return offset - other.offset; - } - - bool operator ==(Location other) => - sourceUrl == other.sourceUrl && offset == other.offset; - - int get hashCode => sourceUrl.hashCode + offset; - - String toString() => '(Location $offset)'; - String get formatString => '$sourceUrl:${line + 1}:${column + 1}'; -} - -/// Implementation of [Location] with fixed values given at allocation time. -@Deprecated("Use the source_span package instead.") -class FixedLocation extends Location { - final String sourceUrl; - final int line; - final int column; - - FixedLocation(int offset, this.sourceUrl, this.line, this.column) - : super(offset); -} - -/// Implementation of [Span] where all the values are given at allocation time. -@Deprecated("Use the source_span package instead.") -class FixedSpan extends Span { - /// The source text for this span, if available. - final String text; - - /// Creates a span which starts and end in the same line. - FixedSpan(String sourceUrl, int start, int line, int column, - {String text: '', bool isIdentifier: false}) - : text = text, super(new FixedLocation(start, sourceUrl, line, column), - new FixedLocation(start + text.length, sourceUrl, line, - column + text.length), - isIdentifier); -} - -/// [Location] with values computed from an underling [SourceFile]. -@Deprecated("Use the source_span package instead.") -class FileLocation extends Location { - /// The source file containing this location. - final SourceFile file; - - String get sourceUrl => file.url; - int get line => file.getLine(offset); - int get column => file.getColumn(line, offset); - - FileLocation(this.file, int offset): super(offset); -} - -/// [Span] where values are computed from an underling [SourceFile]. -@Deprecated("Use the source_span package instead.") -class FileSpan extends Span { - /// The source file containing this span. - final SourceFile file; - - /// The source text for this span, if available. - String get text => file.getText(start.offset, end.offset); - - factory FileSpan(SourceFile file, int start, - [int end, bool isIdentifier = false]) { - var startLoc = new FileLocation(file, start); - var endLoc = end == null ? startLoc : new FileLocation(file, end); - return new FileSpan.locations(startLoc, endLoc, isIdentifier); - } - - FileSpan.locations(FileLocation start, FileLocation end, - bool isIdentifier) - : file = start.file, super(start, end, isIdentifier); - - /// Creates a new span that is the union of two existing spans [start] and - /// [end]. Note that the resulting span might contain some positions that were - /// not in either of the original spans if [start] and [end] are disjoint. - FileSpan.union(FileSpan start, FileSpan end) - : file = start.file, super.union(start, end) { - if (start.file != end.file) { - throw new ArgumentError('start and end must be from the same file'); - } - } - - String getLocationMessage(String message, - {bool useColors: false, String color}) { - return file.getLocationMessage(message, start.offset, end.offset, - useColors: useColors, color: color); - } -} - -// Constants to determine end-of-lines. -const int _LF = 10; -const int _CR = 13; - -// Color constants used for generating messages. -const String _RED_COLOR = '\u001b[31m'; -const String _NO_COLOR = '\u001b[0m'; - -/// Stores information about a source file, to permit computation of the line -/// and column. Also contains a nice default error message highlighting the code -/// location. -@Deprecated("Use the source_span package instead.") -class SourceFile { - /// Url where the source file is located. - final String url; - final List _lineStarts; - final List _decodedChars; - - SourceFile(this.url, this._lineStarts, this._decodedChars); - - SourceFile.text(this.url, String text) - : _lineStarts = [0], - _decodedChars = text.runes.toList() { - for (int i = 0; i < _decodedChars.length; i++) { - var c = _decodedChars[i]; - if (c == _CR) { - // Return not followed by newline is treated as a newline - int j = i + 1; - if (j >= _decodedChars.length || _decodedChars[j] != _LF) { - c = _LF; - } - } - if (c == _LF) _lineStarts.add(i + 1); - } - } - - /// Returns a span in this [SourceFile] with the given offsets. - Span span(int start, [int end, bool isIdentifier = false]) => - new FileSpan(this, start, end, isIdentifier); - - /// Returns a location in this [SourceFile] with the given offset. - Location location(int offset) => new FileLocation(this, offset); - - /// Gets the 0-based line corresponding to an offset. - int getLine(int offset) => binarySearch(_lineStarts, (o) => o > offset) - 1; - - /// Gets the 0-based column corresponding to an offset. - int getColumn(int line, int offset) { - if (line < 0 || line >= _lineStarts.length) return 0; - return offset - _lineStarts[line]; - } - - /// Get the offset for a given line and column - int getOffset(int line, int column) { - if (line < 0) return getOffset(0, 0); - if (line < _lineStarts.length) { - return _lineStarts[line] + column; - } else { - return _decodedChars.length; - } - } - - /// Gets the text at the given offsets. - String getText(int start, [int end]) => - new String.fromCharCodes(_decodedChars.sublist(max(start, 0), end)); - - /// Create a pretty string representation from a span. - String getLocationMessage(String message, int start, int end, - {bool useColors: false, String color}) { - // TODO(jmesserly): it would be more useful to pass in an object that - // controls how the errors are printed. This method is a bit too smart. - var line = getLine(start); - var column = getColumn(line, start); - - var source = url == null ? '' : ' of ${p.prettyUri(url)}'; - var msg = 'line ${line + 1}, column ${column + 1}$source: $message'; - - if (_decodedChars == null) { - // We don't have any text to include, so exit. - return msg; - } - - var buf = new StringBuffer(msg); - buf.write('\n'); - - // +1 for 0-indexing, +1 again to avoid the last line - var textLine = getText(getOffset(line, 0), getOffset(line + 1, 0)); - - column = min(column, textLine.length - 1); - int toColumn = min(column + end - start, textLine.length); - if (useColors) { - if (color == null) { - color = _RED_COLOR; - } - buf.write(textLine.substring(0, column)); - buf.write(color); - buf.write(textLine.substring(column, toColumn)); - buf.write(_NO_COLOR); - buf.write(textLine.substring(toColumn)); - } else { - buf.write(textLine); - if (textLine != '' && !textLine.endsWith('\n')) buf.write('\n'); - } - - int i = 0; - for (; i < column; i++) { - buf.write(' '); - } - - if (useColors) buf.write(color); - for (; i < toColumn; i++) { - buf.write('^'); - } - if (useColors) buf.write(_NO_COLOR); - return buf.toString(); - } -} - -/// A convenience type to treat a code segment as if it were a separate -/// [SourceFile]. A [SourceFileSegment] shifts all locations by an offset, which -/// allows you to set source-map locations based on the locations relative to -/// the start of the segment, but that get translated to absolute locations in -/// the original source file. -@Deprecated("Use the source_span package instead.") -class SourceFileSegment extends SourceFile { - final int _baseOffset; - final int _baseLine; - final int _baseColumn; - final int _maxOffset; - - SourceFileSegment(String url, String textSegment, Location startOffset) - : _baseOffset = startOffset.offset, - _baseLine = startOffset.line, - _baseColumn = startOffset.column, - _maxOffset = startOffset.offset + textSegment.length, - super.text(url, textSegment); - - /// Craete a span, where [start] is relative to this segment's base offset. - /// The returned span stores the real offset on the file, so that error - /// messages are reported at the real location. - Span span(int start, [int end, bool isIdentifier = false]) => - super.span(start + _baseOffset, - end == null ? null : end + _baseOffset, isIdentifier); - - /// Create a location, where [offset] relative to this segment's base offset. - /// The returned span stores the real offset on the file, so that error - /// messages are reported at the real location. - Location location(int offset) => super.location(offset + _baseOffset); - - /// Return the line on the underlying file associated with the [offset] of the - /// underlying file. This method operates on the real offsets from the - /// original file, so that error messages can be reported accurately. When the - /// requested offset is past the length of the segment, this returns the line - /// number after the end of the segment (total lines + 1). - int getLine(int offset) { - var res = super.getLine(max(offset - _baseOffset, 0)) + _baseLine; - return (offset > _maxOffset) ? res + 1 : res; - } - - /// Return the column on the underlying file associated with [line] and - /// [offset], where [line] is absolute from the beginning of the underlying - /// file. This method operates on the real offsets from the original file, so - /// that error messages can be reported accurately. - int getColumn(int line, int offset) { - var col = super.getColumn(line - _baseLine, max(offset - _baseOffset, 0)); - return line == _baseLine ? col + _baseColumn : col; - } - - /// Return the offset associated with a line and column. This method operates - /// on the real offsets from the original file, so that error messages can be - /// reported accurately. - int getOffset(int line, int column) => - super.getOffset(line - _baseLine, - line == _baseLine ? column - _baseColumn : column) + _baseOffset; - - /// Retrieve the text associated with the specified range. This method - /// operates on the real offsets from the original file, so that error - /// messages can be reported accurately. - String getText(int start, [int end]) => - super.getText(start - _baseOffset, end == null ? null : end - _baseOffset); -} - -/// A class for exceptions that have source span information attached. -@Deprecated("Use the source_span package instead.") -class SpanException implements Exception { - /// A message describing the exception. - final String message; - - /// The span associated with this exception. - /// - /// This may be `null` if the source location can't be determined. - final Span span; - - SpanException(this.message, this.span); - - String toString({bool useColors: false, String color}) { - if (span == null) return message; - return "Error on " + span.getLocationMessage(message, - useColors: useColors, color: color); - } -} - -/// A [SpanException] that's also a [FormatException]. -@Deprecated("Use the source_span package instead.") -class SpanFormatException extends SpanException implements FormatException { - final source; - - SpanFormatException(String message, Span span, [this.source]) - : super(message, span); - - int get offset => span == null ? null : span.start.offset; -} diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart new file mode 100644 index 000000000..20eb17ad0 --- /dev/null +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// 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. + +library source_maps.source_map_span; + +import 'package:source_span/source_span.dart'; + +/// A [SourceSpan] for spans coming from or being written to source maps. +/// +/// These spans have an extra piece of metadata: whether or not they represent +/// an identifier (see [isIdentifier]). +class SourceMapSpan extends SourceSpanBase { + /// Whether this span represents an identifier. + /// + /// If this is `true`, [text] is the value of the identifier. + final bool isIdentifier; + + SourceMapSpan(SourceLocation start, SourceLocation end, String text, + {this.isIdentifier: false}) + : super(start, end, text); + + /// Creates a [SourceMapSpan] for an identifier with value [text] starting at + /// [start]. + /// + /// The [end] location is determined by adding [text] to [start]. + SourceMapSpan.identifier(SourceLocation start, String text) + : this( + start, + new SourceLocation(start.offset + text.length, + sourceUrl: start.sourceUrl, + line: start.line, + column: start.column + text.length), + text, + isIdentifier: true); +} + +/// A wrapper aruond a [FileSpan] that implements [SourceMapSpan]. +class SourceMapFileSpan implements SourceMapSpan, FileSpan { + final FileSpan _inner; + final bool isIdentifier; + + SourceFile get file => _inner.file; + FileLocation get start => _inner.start; + FileLocation get end => _inner.end; + String get text => _inner.text; + Uri get sourceUrl => _inner.sourceUrl; + int get length => _inner.length; + + SourceMapFileSpan(this._inner, {this.isIdentifier: false}); + + int compareTo(SourceSpan other) => _inner.compareTo(other); + SourceSpan union(SourceSpan other) => _inner.union(other); + FileSpan expand(FileSpan other) => _inner.expand(other); + String message(String message, {color}) => + _inner.message(message, color: color); + String toString() => _inner.toString() + .replaceAll("FileSpan", "SourceMapFileSpan"); +} diff --git a/pkgs/source_maps/lib/src/span_wrapper.dart b/pkgs/source_maps/lib/src/span_wrapper.dart deleted file mode 100644 index e0c107bf7..000000000 --- a/pkgs/source_maps/lib/src/span_wrapper.dart +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// 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. - -library source_maps.span_wrapper; - -import 'package:source_span/source_span.dart' as source_span; - -import '../span.dart'; - -/// A wrapper that exposes a [source_span.SourceSpan] as a [Span]. -class SpanWrapper extends Span { - final source_span.SourceSpan _inner; - - String get text => _inner.text; - - SpanWrapper(source_span.SourceSpan inner, bool isIdentifier) - : _inner = inner, - super( - new LocationWrapper(inner.start), - new LocationWrapper(inner.end), - isIdentifier); - - static Span wrap(span, [bool isIdentifier = false]) { - if (span is Span) return span; - return new SpanWrapper(span, isIdentifier); - } -} - -/// A wrapper that exposes a [source_span.SourceLocation] as a [Location]. -class LocationWrapper extends Location { - final source_span.SourceLocation _inner; - - String get sourceUrl => _inner.sourceUrl.toString(); - int get line => _inner.line; - int get column => _inner.column; - - LocationWrapper(source_span.SourceLocation inner) - : _inner = inner, - super(inner.offset); - - static Location wrap(location) { - if (location is Location) return location; - return new LocationWrapper(location); - } -} - -/// A wrapper that exposes a [source_span.SourceFile] as a [SourceFile]. -class SourceFileWrapper implements SourceFile { - final source_span.SourceFile _inner; - - // These are necessary to avoid analyzer warnings; - final _lineStarts = null; - final _decodedChars = null; - - String get url => _inner.url.toString(); - - SourceFileWrapper(this._inner); - - static SourceFile wrap(sourceFile) { - if (sourceFile is SourceFile) return sourceFile; - return new SourceFileWrapper(sourceFile); - } - - Span span(int start, [int end, bool isIdentifier = false]) { - if (end == null) end = start; - return new SpanWrapper(_inner.span(start, end), isIdentifier); - } - - Location location(int offset) => new LocationWrapper(_inner.location(offset)); - - int getLine(int offset) => _inner.getLine(offset); - - int getColumn(int line, int offset) => _inner.getColumn(offset, line: line); - - int getOffset(int line, int column) => _inner.getOffset(line, column); - - String getText(int start, [int end]) => _inner.getText(start, end); - - String getLocationMessage(String message, int start, int end, - {bool useColors: false, String color}) { - return span(start, end).getLocationMessage(message, - useColors: useColors, color: color); - } -} diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index 8842c62cb..ca0ca8d2d 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -16,7 +16,7 @@ main() { ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) ..addSpan(inputExpr, outputExpr)) - .build(output.url); + .build(output.url.toString()); expect(map, equals(EXPECTED_MAP)); }); @@ -26,7 +26,7 @@ main() { ..addLocation(inputFunction.start, outputFunction.start, 'longName') ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') ..addLocation(inputExpr.start, outputExpr.start, null)) - .toJson(output.url); + .toJson(output.url.toString()); expect(str, JSON.encode(EXPECTED_MAP)); }); } diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 0c1f28a74..73a8d406b 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -6,6 +6,7 @@ library test.common; import 'package:source_maps/source_maps.dart'; +import 'package:source_span/source_span.dart'; import 'package:unittest/unittest.dart'; /// Content of the source file @@ -18,40 +19,40 @@ int longName(int longVar2) { return longVar1 + longVar2; } '''; -var input = new SourceFile.text('input.dart', INPUT); +var input = new SourceFile(INPUT, url: 'input.dart'); /// A span in the input file -Span ispan(int start, int end, [bool isIdentifier = false]) => - new FileSpan(input, start, end, isIdentifier); +SourceMapSpan ispan(int start, int end, [bool isIdentifier = false]) => + new SourceMapFileSpan(input.span(start, end), isIdentifier: isIdentifier); -Span inputVar1 = ispan(30, 38, true); -Span inputFunction = ispan(74, 82, true); -Span inputVar2 = ispan(87, 95, true); +SourceMapSpan inputVar1 = ispan(30, 38, true); +SourceMapSpan inputFunction = ispan(74, 82, true); +SourceMapSpan inputVar2 = ispan(87, 95, true); -Span inputVar1NoSymbol = ispan(30, 38); -Span inputFunctionNoSymbol = ispan(74, 82); -Span inputVar2NoSymbol = ispan(87, 95); +SourceMapSpan inputVar1NoSymbol = ispan(30, 38); +SourceMapSpan inputFunctionNoSymbol = ispan(74, 82); +SourceMapSpan inputVar2NoSymbol = ispan(87, 95); -Span inputExpr = ispan(108, 127); +SourceMapSpan inputExpr = ispan(108, 127); /// Content of the target file const String OUTPUT = ''' var x = 3; f(y) => x + y; '''; -var output = new SourceFile.text('output.dart', OUTPUT); +var output = new SourceFile(OUTPUT, url: 'output.dart'); /// A span in the output file -Span ospan(int start, int end, [bool isIdentifier = false]) => - new FileSpan(output, start, end, isIdentifier); +SourceMapSpan ospan(int start, int end, [bool isIdentifier = false]) => + new SourceMapFileSpan(output.span(start, end), isIdentifier: isIdentifier); -Span outputVar1 = ospan(4, 5, true); -Span outputFunction = ospan(11, 12, true); -Span outputVar2 = ospan(13, 14, true); -Span outputVar1NoSymbol = ospan(4, 5); -Span outputFunctionNoSymbol = ospan(11, 12); -Span outputVar2NoSymbol = ospan(13, 14); -Span outputExpr = ospan(19, 24); +SourceMapSpan outputVar1 = ospan(4, 5, true); +SourceMapSpan outputFunction = ospan(11, 12, true); +SourceMapSpan outputVar2 = ospan(13, 14, true); +SourceMapSpan outputVar1NoSymbol = ospan(4, 5); +SourceMapSpan outputFunctionNoSymbol = ospan(11, 12); +SourceMapSpan outputVar2NoSymbol = ospan(13, 14); +SourceMapSpan outputExpr = ospan(19, 24); /// Expected output mapping when recording the following four mappings: /// inputVar1 <= outputVar1 @@ -70,7 +71,8 @@ const Map EXPECTED_MAP = const { 'file': 'output.dart' }; -check(Span outputSpan, Mapping mapping, Span inputSpan, bool realOffsets) { +check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan, + bool realOffsets) { var line = outputSpan.start.line; var column = outputSpan.start.column; var files = realOffsets ? {'input.dart': input} : null; diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 99fe40d40..7dbc6bd9b 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -6,6 +6,7 @@ library test.end2end_test; import 'package:unittest/unittest.dart'; import 'package:source_maps/source_maps.dart'; +import 'package:source_span/source_span.dart'; import 'common.dart'; main() { @@ -33,7 +34,7 @@ main() { ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) ..addSpan(inputExpr, outputExpr)) - .build(output.url); + .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); @@ -47,7 +48,7 @@ main() { ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) ..addSpan(inputExpr, outputExpr)) - .build(output.url); + .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); @@ -65,7 +66,7 @@ main() { ..addSpan(inputVar2, outputVar2) ..addSpan(inputExpr, outputExpr) ..addSpan(inputExpr, outputExpr)) - .build(output.url); + .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); @@ -82,7 +83,7 @@ main() { ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) ..addSpan(inputExpr, outputExpr)) - .build(output.url); + .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); @@ -96,7 +97,7 @@ main() { ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) ..addSpan(inputExpr, outputExpr)) - .toJson(output.url); + .toJson(output.url.toString()); var mapping = parse(json); check(outputVar1, mapping, inputVar1, true); check(outputVar2, mapping, inputVar2, true); @@ -106,7 +107,7 @@ main() { test('printer projecting marks + parse', () { var out = INPUT.replaceAll('long', '_s'); - var file = new SourceFile.text('output2.dart', out); + var file = new SourceFile(out, url: 'output2.dart'); var printer = new Printer('output2.dart'); printer.mark(ispan(0, 0)); @@ -132,10 +133,11 @@ main() { expect(printer.text, out); var mapping = parse(printer.map); - checkHelper(Span inputSpan, int adjustment) { + checkHelper(SourceMapSpan inputSpan, int adjustment) { var start = inputSpan.start.offset - adjustment; var end = (inputSpan.end.offset - adjustment) - 2; - var span = new FileSpan(file, start, end, inputSpan.isIdentifier); + var span = new SourceMapFileSpan(file.span(start, end), + isIdentifier: inputSpan.isIdentifier); check(span, mapping, inputSpan, true); } @@ -145,17 +147,16 @@ main() { checkHelper(inputExpr, 6); // We projected correctly lines that have no mappings - check(new FileSpan(file, 66, 66, false), mapping, ispan(45, 45), true); - check(new FileSpan(file, 63, 64, false), mapping, ispan(45, 45), true); - check(new FileSpan(file, 68, 68, false), mapping, ispan(70, 70), true); - check(new FileSpan(file, 71, 71, false), mapping, ispan(70, 70), true); + check(file.span(66, 66), mapping, ispan(45, 45), true); + check(file.span(63, 64), mapping, ispan(45, 45), true); + check(file.span(68, 68), mapping, ispan(70, 70), true); + check(file.span(71, 71), mapping, ispan(70, 70), true); // Start of the last line var oOffset = out.length - 2; var iOffset = INPUT.length - 2; - check(new FileSpan(file, oOffset, oOffset, false), mapping, - ispan(iOffset, iOffset), true); - check(new FileSpan(file, oOffset + 1, oOffset + 1, false), mapping, + check(file.span(oOffset, oOffset), mapping, ispan(iOffset, iOffset), true); + check(file.span(oOffset + 1, oOffset + 1), mapping, ispan(iOffset, iOffset), true); }); } diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 62cd08f1f..8528683f3 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -104,7 +104,7 @@ main() { var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap); - expect(mapping.spanFor(0, 0).sourceUrl, "/pkg/input.dart"); + expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart")); var newSourceRoot = '/new/'; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index fe27f76c0..e55ca9f6e 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -6,8 +6,8 @@ library test.printer_test; import 'dart:convert'; import 'package:unittest/unittest.dart'; -import 'package:source_maps/printer.dart'; -import 'package:source_maps/span.dart'; +import 'package:source_maps/source_maps.dart'; +import 'package:source_span/source_span.dart'; import 'common.dart'; main() { @@ -53,13 +53,12 @@ main() { // 8 new lines in the source map: expect(printer.map.split(';').length, 8); - asFixed(Span s) => new FixedSpan(s.sourceUrl, - s.start.offset, s.start.line, s.start.column, - text: s.text, isIdentifier: s.isIdentifier); + asFixed(SourceMapSpan s) => new SourceMapSpan(s.start, s.end, s.text, + isIdentifier: s.isIdentifier); // The result is the same if we use fixed positions var printer2 = new Printer('output2.dart'); - printer2..mark(new FixedSpan('input.dart', 0, 0, 0)) + printer2..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan()) ..add(segments[0], projectMarks: true) ..mark(asFixed(inputVar1)) ..add('_s') diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 5d0abf1e2..08b896510 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -6,13 +6,13 @@ library polymer.test.refactor_test; import 'package:unittest/unittest.dart'; import 'package:source_maps/refactor.dart'; -import 'package:source_maps/span.dart'; import 'package:source_maps/parser.dart' show parse, Mapping; +import 'package:source_span/source_span.dart'; main() { group('conflict detection', () { var original = "0123456789abcdefghij"; - var file = new SourceFile.text('', original); + var file = new SourceFile(original); test('no conflict, in order', () { var txn = new TextEditTransaction(original, file); @@ -48,7 +48,7 @@ main() { test('generated source maps', () { var original = "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; - var file = new SourceFile.text('', original); + var file = new SourceFile(original); var txn = new TextEditTransaction(original, file); txn.edit(27, 29, '__\n '); txn.edit(34, 35, '___'); @@ -60,42 +60,90 @@ main() { // Line 1 and 2 are unmodified: mapping any column returns the beginning // of the corresponding line: - expect(_span(1, 1, map, file), "line 1, column 1 of .: \n0123456789"); - expect(_span(1, 5, map, file), "line 1, column 1 of .: \n0123456789"); - expect(_span(2, 1, map, file), "line 2, column 1 of .: \n0*23456789"); - expect(_span(2, 8, map, file), "line 2, column 1 of .: \n0*23456789"); + expect(_span(1, 1, map, file), + "line 1, column 1: \n" + "0123456789\n" + "^"); + expect(_span(1, 5, map, file), + "line 1, column 1: \n" + "0123456789\n" + "^"); + expect(_span(2, 1, map, file), + "line 2, column 1: \n" + "0*23456789\n" + "^"); + expect(_span(2, 8, map, file), + "line 2, column 1: \n" + "0*23456789\n" + "^"); // Line 3 is modified part way: mappings before the edits have the right // mapping, after the edits the mapping is null. - expect(_span(3, 1, map, file), "line 3, column 1 of .: \n01*3456789"); - expect(_span(3, 5, map, file), "line 3, column 1 of .: \n01*3456789"); + expect(_span(3, 1, map, file), + "line 3, column 1: \n" + "01*3456789\n" + "^"); + expect(_span(3, 5, map, file), + "line 3, column 1: \n" + "01*3456789\n" + "^"); // Start of edits map to beginning of the edit secion: - expect(_span(3, 6, map, file), "line 3, column 6 of .: \n01*3456789"); - expect(_span(3, 7, map, file), "line 3, column 6 of .: \n01*3456789"); + expect(_span(3, 6, map, file), + "line 3, column 6: \n" + "01*3456789\n" + " ^"); + expect(_span(3, 7, map, file), + "line 3, column 6: \n" + "01*3456789\n" + " ^"); // Lines added have no mapping (they should inherit the last mapping), // but the end of the edit region continues were we left off: expect(_span(4, 1, map, file), isNull); - expect(_span(4, 5, map, file), "line 3, column 8 of .: \n01*3456789"); + expect(_span(4, 5, map, file), + "line 3, column 8: \n" + "01*3456789\n" + " ^"); // Subsequent lines are still mapped correctly: // a (in a___cd...) - expect(_span(5, 1, map, file), "line 4, column 1 of .: \nabcdefghij"); + expect(_span(5, 1, map, file), + "line 4, column 1: \n" + "abcdefghij\n" + "^"); // _ (in a___cd...) - expect(_span(5, 2, map, file), "line 4, column 2 of .: \nabcdefghij"); + expect(_span(5, 2, map, file), + "line 4, column 2: \n" + "abcdefghij\n" + " ^"); // _ (in a___cd...) - expect(_span(5, 3, map, file), "line 4, column 2 of .: \nabcdefghij"); + expect(_span(5, 3, map, file), + "line 4, column 2: \n" + "abcdefghij\n" + " ^"); // _ (in a___cd...) - expect(_span(5, 4, map, file), "line 4, column 2 of .: \nabcdefghij"); + expect(_span(5, 4, map, file), + "line 4, column 2: \n" + "abcdefghij\n" + " ^"); // c (in a___cd...) - expect(_span(5, 5, map, file), "line 4, column 3 of .: \nabcdefghij"); - expect(_span(6, 1, map, file), "line 5, column 1 of .: \nabcd*fghij"); - expect(_span(6, 8, map, file), "line 5, column 1 of .: \nabcd*fghij"); + expect(_span(5, 5, map, file), + "line 4, column 3: \n" + "abcdefghij\n" + " ^"); + expect(_span(6, 1, map, file), + "line 5, column 1: \n" + "abcd*fghij\n" + "^"); + expect(_span(6, 8, map, file), + "line 5, column 1: \n" + "abcd*fghij\n" + "^"); }); } String _span(int line, int column, Mapping map, SourceFile file) { var span = map.spanFor(line - 1, column - 1, files: {'': file}); - return span == null ? null : span.getLocationMessage('').trim(); + return span == null ? null : span.message('').trim(); } diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart index 21d20377e..ec3c3ab7f 100755 --- a/pkgs/source_maps/test/run.dart +++ b/pkgs/source_maps/test/run.dart @@ -14,7 +14,6 @@ import 'end2end_test.dart' as end2end_test; import 'parser_test.dart' as parser_test; import 'printer_test.dart' as printer_test; import 'refactor_test.dart' as refactor_test; -import 'span_test.dart' as span_test; import 'utils_test.dart' as utils_test; import 'vlq_test.dart' as vlq_test; @@ -33,7 +32,6 @@ main(List arguments) { addGroup('parser_test.dart', parser_test.main); addGroup('printer_test.dart', printer_test.main); addGroup('refactor_test.dart', refactor_test.main); - addGroup('span_test.dart', span_test.main); addGroup('utils_test.dart', utils_test.main); addGroup('vlq_test.dart', vlq_test.main); } diff --git a/pkgs/source_maps/test/span_test.dart b/pkgs/source_maps/test/span_test.dart deleted file mode 100644 index 190b7a66b..000000000 --- a/pkgs/source_maps/test/span_test.dart +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// 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. - -library test.span_test; - -import 'package:unittest/unittest.dart'; -import 'package:source_maps/span.dart'; - -const String TEST_FILE = ''' -+23456789_ - + _123456789_123456789_123456789_123456789_123456789_123456789_123456789_ - + _123456789_1 -123+56789_123456789_1234567 -1234+6789_1234 -12345+789_123456789_12345 -123456+89_123456789_123456789_123456789_123456789_123456789_123456789_123456789 -1234567+9_123456789_123456789_123456789_123456789_123456789_123456789_123 -12345678+_123456789_123456789_123456789_123456789_1 -123456789+123456789_123456789_12345678 -123456789_+23456789_123456789_123456789_123 -123456789_1+3456789_123456789 -'''; - -List newLines = TEST_FILE.split('\n').map((s) => s.length).toList(); - -main() { - var file = new SourceFile.text('file', TEST_FILE); - span(int start, int end) => file.span(start, end); - loc(int offset) => file.location(offset); - - test('validate test input', () { - expect(newLines, - const [10, 80, 31, 27, 14, 25, 79, 73, 51, 38, 43, 29, 0]); - }); - - test('get line and column', () { - line(int n) => file.getLine(n); - col(int n) => file.getColumn(file.getLine(n), n); - - expect(line(8), 0); - expect(line(10), 0); - expect(line(11), 1); - expect(line(12), 1); - expect(line(91), 1); - expect(line(92), 2); - expect(line(93), 2); - expect(col(11), 0); - expect(col(12), 1); - expect(col(91), 80); - expect(col(92), 0); - expect(col(93), 1); - - int j = 0; - int lineOffset = 0; - for (int i = 0; i < TEST_FILE.length; i++) { - if (i > lineOffset + newLines[j]) { - lineOffset += newLines[j] + 1; - j++; - } - expect(line(i), j, reason: 'position: $i'); - expect(col(i), i - lineOffset, reason: 'position: $i'); - } - }); - - test('get text', () { - // fifth line (including 4 new lines), columns 2 .. 11 - var line = 10 + 80 + 31 + 27 + 4; - expect(file.getText(line + 2, line + 11), '34+6789_1'); - }); - - group('location message', () { - test('first line', () { - expect(file.getLocationMessage('the message', 1, 3), - 'line 1, column 2 of file: the message\n' - '+23456789_\n' - ' ^^'); - }); - - test('in the middle of the file', () { - // fifth line (including 4 new lines), columns 2 .. 11 - var line = 10 + 80 + 31 + 27 + 4; - expect(file.getLocationMessage('the message', line + 2, line + 11), - 'line 5, column 3 of file: the message\n' - '1234+6789_1234\n' - ' ^^^^^^^^^'); - }); - - test('no file url', () { - var line = 10 + 80 + 31 + 27 + 4; - expect(new SourceFile.text(null, TEST_FILE).getLocationMessage( - 'the message', line + 2, line + 11), - 'line 5, column 3: the message\n' - '1234+6789_1234\n' - ' ^^^^^^^^^'); - }); - - test('penultimate line', () { - // We search '\n' backwards twice because last line is \n terminated: - int index = TEST_FILE.lastIndexOf('\n'); - var start = TEST_FILE.lastIndexOf('\n', index - 1) - 3; - expect(file.getLocationMessage('the message', start, start + 2), - 'line 11, column 41 of file: the message\n' - '123456789_+23456789_123456789_123456789_123\n' - ' ^^'); - }); - - test('last line', () { - var start = TEST_FILE.lastIndexOf('\n') - 2; - expect(file.getLocationMessage('the message', start, start + 1), - 'line 12, column 28 of file: the message\n' - '123456789_1+3456789_123456789\n' - ' ^'); - }); - - group('no trailing empty-line at the end -', () { - var text = TEST_FILE.substring(0, TEST_FILE.length - 1); - var file2 = new SourceFile.text('file', text); - - test('penultimate line', () { - var start = text.lastIndexOf('\n') - 3; - expect(file2.getLocationMessage('the message', start, start + 2), - 'line 11, column 41 of file: the message\n' - '123456789_+23456789_123456789_123456789_123\n' - ' ^^'); - }); - - test('last line', () { - var start = text.length - 2; - expect(file2.getLocationMessage('the message', start, start + 1), - 'line 12, column 28 of file: the message\n' - '123456789_1+3456789_123456789\n' - ' ^'); - }); - }); - - test('single line', () { - var text = "this is a single line"; - int start = text.indexOf(' ') + 1; - var file2 = new SourceFile.text('file', text); - expect(file2.getLocationMessage('the message', start, start + 2), - 'line 1, column ${start + 1} of file: the message\n' - 'this is a single line\n' - ' ^^'); - }); - }); - - test('location getters', () { - expect(loc(8).line, 0); - expect(loc(8).column, 8); - expect(loc(9).line, 0); - expect(loc(9).column, 9); - expect(loc(8).formatString, 'file:1:9'); - expect(loc(12).line, 1); - expect(loc(12).column, 1); - expect(loc(95).line, 2); - expect(loc(95).column, 3); - }); - - test('location compare', () { - var list = [9, 8, 11, 14, 6, 6, 1, 1].map((n) => loc(n)).toList(); - list.sort(); - var lastOffset = 0; - for (var location in list) { - expect(location.offset, greaterThanOrEqualTo(lastOffset)); - lastOffset = location.offset; - } - }); - - test('span getters', () { - expect(span(8, 9).start.line, 0); - expect(span(8, 9).start.column, 8); - expect(span(8, 9).end.line, 0); - expect(span(8, 9).end.column, 9); - expect(span(8, 9).text, '9'); - expect(span(8, 9).isIdentifier, false); - expect(span(8, 9).formatLocation, 'file:1:9'); - - var line = 10 + 80 + 31 + 27 + 4; - expect(span(line + 2, line + 11).getLocationMessage('the message'), - 'line 5, column 3 of file: the message\n' - '1234+6789_1234\n' - ' ^^^^^^^^^'); - - expect(span(12, 95).start.line, 1); - expect(span(12, 95).start.column, 1); - expect(span(12, 95).end.line, 2); - expect(span(12, 95).end.column, 3); - expect(span(12, 95).text, - '+ _123456789_123456789_123456789_123456789_123456789_1234567' - '89_123456789_\n +'); - expect(span(12, 95).formatLocation, 'file:2:2'); - }); - - test('span union', () { - var union = new FileSpan.union(span(8, 9), span(12, 95)); - expect(union.start.offset, 8); - expect(union.start.line, 0); - expect(union.start.column, 8); - expect(union.end.offset, 95); - expect(union.end.line, 2); - expect(union.end.column, 3); - expect(union.text, - '9_\n' - ' + _123456789_123456789_123456789_123456789_123456789_' - '123456789_123456789_\n +'); - expect(union.formatLocation, 'file:1:9'); - }); - - test('span compare', () { - var list = [span(9, 10), span(8, 9), span(11, 12), span(14, 19), - span(6, 12), span(6, 8), span(1, 9), span(1, 2)]; - list.sort(); - var lastStart = 0; - var lastEnd = 0; - for (var span in list) { - expect(span.start.offset, greaterThanOrEqualTo(lastStart)); - if (span.start.offset == lastStart) { - expect(span.end.offset, greaterThanOrEqualTo(lastEnd)); - } - lastStart = span.start.offset; - lastEnd = span.end.offset; - } - }); - - test('range check for large offsets', () { - var start = TEST_FILE.length; - expect(file.getLocationMessage('the message', start, start + 9), - 'line 13, column 1 of file: the message\n'); - }); - - group('file segment', () { - var baseOffset = 123; - var segmentText = TEST_FILE.substring(baseOffset, TEST_FILE.length - 100); - var segment = new SourceFileSegment('file', segmentText, loc(baseOffset)); - sline(int n) => segment.getLine(n); - scol(int n) => segment.getColumn(segment.getLine(n), n); - line(int n) => file.getLine(n); - col(int n) => file.getColumn(file.getLine(n), n); - - test('get line and column', () { - int j = 0; - int lineOffset = 0; - for (int i = baseOffset; i < segmentText.length; i++) { - if (i > lineOffset + newLines[j]) { - lineOffset += newLines[j] + 1; - j++; - } - expect(segment.location(i - baseOffset).offset, i); - expect(segment.location(i - baseOffset).line, line(i)); - expect(segment.location(i - baseOffset).column, col(i)); - expect(segment.span(i - baseOffset).start.offset, i); - expect(segment.span(i - baseOffset).start.line, line(i)); - expect(segment.span(i - baseOffset).start.column, col(i)); - - expect(sline(i), line(i)); - expect(scol(i), col(i)); - } - }); - - test('get text', () { - var start = 10 + 80 + 31 + 27 + 4 + 2; - expect(segment.getText(start, start + 9), file.getText(start, start + 9)); - }); - - group('location message', () { - test('first line', () { - var start = baseOffset + 7; - expect(segment.getLocationMessage('the message', start, start + 2), - file.getLocationMessage('the message', start, start + 2)); - }); - - test('in a middle line', () { - // Example from another test above: - var start = 10 + 80 + 31 + 27 + 4 + 2; - expect(segment.getLocationMessage('the message', start, start + 9), - file.getLocationMessage('the message', start, start + 9)); - }); - - test('last segment line', () { - var start = segmentText.length - 4; - expect(segment.getLocationMessage('the message', start, start + 2), - file.getLocationMessage('the message', start, start + 2)); - }); - - test('past segment, same as last segment line', () { - var start = segmentText.length; - expect(segment.getLocationMessage('the message', start, start + 2), - file.getLocationMessage('the message', start, start + 2)); - - start = segmentText.length + 20; - expect(segment.getLocationMessage('the message', start, start + 2), - file.getLocationMessage('the message', start, start + 2)); - }); - - test('past segment, past its line', () { - var start = TEST_FILE.length - 2; - expect(file.getLocationMessage('the message', start, start + 1), - 'line 12, column 29 of file: the message\n' - '123456789_1+3456789_123456789\n' - ' ^'); - - // The answer below is different because the segment parsing only knows - // about the 10 lines it has (and nothing about the possible extra lines - // afterwards) - expect(segment.getLocationMessage('the message', start, start + 1), - 'line 11, column 1 of file: the message\n'); - }); - }); - }); - - test('span isIdentifier defaults to false', () { - var start = new TestLocation(0); - var end = new TestLocation(1); - expect(new TestSpan(start, end).isIdentifier, false); - expect(file.span(8, 9, null).isIdentifier, false); - expect(new FixedSpan('', 8, 1, 8, isIdentifier: null).isIdentifier, false); - }); - - test('span/location implement == and hashCode', () { - expect(identical(span(10, 14), span(10, 14)), isFalse); - expect(span(10, 14), equals(span(10, 14))); - expect(span(10, 14).hashCode, span(10, 14).hashCode); - - expect(identical(loc(13), loc(13)), isFalse); - expect(loc(13), equals(loc(13))); - expect(loc(13).hashCode, loc(13).hashCode); - }); -} - -class TestSpan extends Span { - TestSpan(Location start, Location end) : super(start, end, null); - get text => null; -} - -class TestLocation extends Location { - String get sourceUrl => ''; - TestLocation(int offset) : super(offset); - get line => 0; - get column => 0; -} From 4cb3edebe57134b861f633a4d9c79746fd0770d5 Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Fri, 1 Aug 2014 00:39:29 +0000 Subject: [PATCH 039/133] Actually release source_maps 0.10.0. BUG=19930 R=sigmund@google.com Review URL: https://codereview.chromium.org//430343002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@38813 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/pubspec.yaml | 10 +--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 6d371c9bf..a70bc4480 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.0 + +* Remove the `Span`, `Location` and `SourceFile` classes. Use the + corresponding `source_span` classes instead. + ## 0.9.4 * Update `SpanFormatException` with `source` and `offset`. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 0548215b1..4af996e56 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,13 +1,5 @@ name: source_maps - -# Note! This version number is referenced directly in the pub source code in -# lib/src/barback.dart. Pub implicitly places a version constraint on -# source_maps to ensure users only select a version of source_maps that works -# with their current version of pub. -# -# When the minor version is upgraded, you *must* update that version constraint -# in pub to stay in sync with this. -version: 0.9.4-dev +version: 0.10.0 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 266d348e935604f43cf42f76153d27221d47336c Mon Sep 17 00:00:00 2001 From: "tjblasi@google.com" Date: Thu, 4 Dec 2014 01:16:27 +0000 Subject: [PATCH 040/133] Removing unnecessary warning when parsing Json. BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//781643002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@42098 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/source_maps/CHANGELOG.md | 6 ++++++ pkgs/source_maps/lib/parser.dart | 4 ---- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index a70bc4480..531a6d053 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.10.0+1 + +* Remove an unnecessary warning printed when the "file" field is missing from a + Json formatted source map. This field is optional and its absence is not + unusual. + ## 0.10.0 * Remove the `Span`, `Location` and `SourceFile` classes. Use the diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index d67a65e58..369c27d0a 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -31,10 +31,6 @@ Mapping parseJson(Map map, {Map otherMaps}) { 'Only version 3 is supported.'); } - if (!map.containsKey('file')) { - print('warning: missing "file" entry in source map'); - } - if (map.containsKey('sections')) { if (map.containsKey('mappings') || map.containsKey('sources') || map.containsKey('names')) { diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 4af996e56..275103415 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.0 +version: 0.10.0+1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://www.dartlang.org From 769affb575b92c5a64f2563b5e3e62606724abc1 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 19 Dec 2014 13:58:41 -0800 Subject: [PATCH 041/133] Add gitignore, status, and codereview files. --- pkgs/source_maps/.gitignore | 14 ++++++++++++++ pkgs/source_maps/.status | 20 ++++++++++++++++++++ pkgs/source_maps/codereview.settings | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 pkgs/source_maps/.gitignore create mode 100644 pkgs/source_maps/.status create mode 100644 pkgs/source_maps/codereview.settings diff --git a/pkgs/source_maps/.gitignore b/pkgs/source_maps/.gitignore new file mode 100644 index 000000000..388eff0ba --- /dev/null +++ b/pkgs/source_maps/.gitignore @@ -0,0 +1,14 @@ +# Don’t commit the following directories created by pub. +.buildlog +.pub/ +build/ +packages + +# Or the files created by dart2js. +*.dart.js +*.js_ +*.js.deps +*.js.map + +# Include when developing application packages. +pubspec.lock \ No newline at end of file diff --git a/pkgs/source_maps/.status b/pkgs/source_maps/.status new file mode 100644 index 000000000..befa7ddc7 --- /dev/null +++ b/pkgs/source_maps/.status @@ -0,0 +1,20 @@ +# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +# 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. + +# Skip non-test files ending with "_test". +packages/*: Skip +*/packages/*: Skip +*/*/packages/*: Skip +*/*/*/packages/*: Skip +*/*/*/*packages/*: Skip +*/*/*/*/*packages/*: Skip + +# Only run tests from the build directory, since we don't care about the +# difference between transformed an untransformed code. +test/*: Skip + +[ $compiler == dart2js || $compiler == dart2dart ] +build/test/vlq_test: RuntimeError # A VLQ test checks for large numbers that + # overflow in JS (numbers slightly larger than + # 32 bits where we do bitwise operations). diff --git a/pkgs/source_maps/codereview.settings b/pkgs/source_maps/codereview.settings new file mode 100644 index 000000000..313ad0a67 --- /dev/null +++ b/pkgs/source_maps/codereview.settings @@ -0,0 +1,3 @@ +CODE_REVIEW_SERVER: http://codereview.chromium.org/ +VIEW_VC: https://github.com/dart-lang/source_maps/commit/ +CC_LIST: reviews@dartlang.org \ No newline at end of file From fceb4f5fada64d1a63ca791fd3197a9962261abf Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 19 Dec 2014 13:58:59 -0800 Subject: [PATCH 042/133] Update the pubspec's homepage link. --- pkgs/source_maps/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 275103415..1d94c3280 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -2,7 +2,7 @@ name: source_maps version: 0.10.0+1 author: Dart Team description: Library to programmatically manipulate source map files. -homepage: http://www.dartlang.org +homepage: http://github.com/dart-lang/source_maps dependencies: path: '>=1.2.0 <2.0.0' source_span: '>=1.0.0 <2.0.0' From 14112478108ebb8f60818319d22e94100f0133a2 Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Fri, 27 Mar 2015 17:39:28 -0700 Subject: [PATCH 043/133] Fix sourcemap after changes in source_span BUG= R=nweiz@google.com Review URL: https://codereview.chromium.org//1035343002 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/src/source_map_span.dart | 1 + pkgs/source_maps/pubspec.yaml | 10 +++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 531a6d053..747765511 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.0+2 + +* Fix analyzer error (FileSpan has a new field since `source_span` 1.1.1) + ## 0.10.0+1 * Remove an unnecessary warning printed when the "file" field is missing from a diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index 20eb17ad0..b70bdfe98 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -44,6 +44,7 @@ class SourceMapFileSpan implements SourceMapSpan, FileSpan { FileLocation get start => _inner.start; FileLocation get end => _inner.end; String get text => _inner.text; + String get context => _inner.context; Uri get sourceUrl => _inner.sourceUrl; int get length => _inner.length; diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 1d94c3280..200f8f85b 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,12 +1,12 @@ name: source_maps -version: 0.10.0+1 +version: 0.10.0+2 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps dependencies: - path: '>=1.2.0 <2.0.0' - source_span: '>=1.0.0 <2.0.0' + path: ^1.2.0 + source_span: ^1.1.1 environment: - sdk: '>=0.8.10+6 <2.0.0' + sdk: '>=1.8.0 <2.0.0' dev_dependencies: - unittest: '>=0.9.0 <0.10.0' + unittest: '>=0.9.0 <0.12.0' From 96485a882b8df24ec7ea0a3cb34ae0ea68d45e14 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 29 Apr 2015 11:24:39 -0700 Subject: [PATCH 044/133] Add a mapUrl parameter to parse() and parseJson(). Closes dart-lang/source_maps#2 R=sigmund@google.com Review URL: https://codereview.chromium.org//1112743002 --- pkgs/source_maps/CHANGELOG.md | 5 +++ pkgs/source_maps/lib/parser.dart | 43 ++++++++++++++++++-------- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 8 +++++ 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 747765511..3066293dd 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.1 + +* Add a `mapUrl` named argument to `parse` and `parseJson`. This argument is + used to resolve source URLs for source spans. + ## 0.10.0+2 * Fix analyzer error (FileSpan has a new field since `source_span` 1.1.1) diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 369c27d0a..a9fcff578 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -16,15 +16,23 @@ import 'src/utils.dart'; import 'src/vlq.dart'; /// Parses a source map directly from a json string. +/// +/// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of +/// the source map file itself. If it's passed, any URLs in the source +/// map will be interpreted as relative to this URL when generating spans. // TODO(sigmund): evaluate whether other maps should have the json parsed, or // the string represenation. // TODO(tjblasi): Ignore the first line of [jsonMap] if the JSON safety string // `)]}'` begins the string representation of the map. -Mapping parse(String jsonMap, {Map otherMaps}) => - parseJson(JSON.decode(jsonMap), otherMaps: otherMaps); +Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => + parseJson(JSON.decode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); /// Parses a source map directly from a json map object. -Mapping parseJson(Map map, {Map otherMaps}) { +/// +/// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of +/// the source map file itself. If it's passed, any URLs in the source +/// map will be interpreted as relative to this URL when generating spans. +Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { if (map['version'] != 3) { throw new ArgumentError( 'unexpected source map version: ${map["version"]}. ' @@ -37,9 +45,10 @@ Mapping parseJson(Map map, {Map otherMaps}) { throw new FormatException('map containing "sections" ' 'cannot contain "mappings", "sources", or "names".'); } - return new MultiSectionMapping.fromJson(map['sections'], otherMaps); + return new MultiSectionMapping.fromJson(map['sections'], otherMaps, + mapUrl: mapUrl); } - return new SingleMapping.fromJson(map); + return new SingleMapping.fromJson(map, mapUrl: mapUrl); } @@ -68,7 +77,8 @@ class MultiSectionMapping extends Mapping { final List _maps = []; /// Creates a section mapping from json. - MultiSectionMapping.fromJson(List sections, Map otherMaps) { + MultiSectionMapping.fromJson(List sections, Map otherMaps, + {mapUrl}) { for (var section in sections) { var offset = section['offset']; if (offset == null) throw new FormatException('section missing offset'); @@ -93,9 +103,9 @@ class MultiSectionMapping extends Mapping { 'section contains refers to $url, but no map was ' 'given for it. Make sure a map is passed in "otherMaps"'); } - _maps.add(parseJson(otherMaps[url], otherMaps: otherMaps)); + _maps.add(parseJson(otherMaps[url], otherMaps: otherMaps, mapUrl: url)); } else if (map != null) { - _maps.add(parseJson(map, otherMaps: otherMaps)); + _maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl)); } else { throw new FormatException('section missing url or map'); } @@ -149,10 +159,13 @@ class SingleMapping extends Mapping { /// Url of the target file. String targetUrl; - /// Source root appended to the start of all entries in [urls]. + /// Source root prepended to all entries in [urls]. String sourceRoot; - SingleMapping._(this.targetUrl, this.urls, this.names, this.lines); + final Uri _mapUrl; + + SingleMapping._(this.targetUrl, this.urls, this.names, this.lines) + : _mapUrl = null; factory SingleMapping.fromEntries( Iterable entries, [String fileUrl]) { @@ -197,12 +210,13 @@ class SingleMapping extends Mapping { fileUrl, urls.keys.toList(), names.keys.toList(), lines); } - SingleMapping.fromJson(Map map) + SingleMapping.fromJson(Map map, {mapUrl}) : targetUrl = map['file'], urls = map['sources'], names = map['names'], sourceRoot = map['sourceRoot'], - lines = [] { + lines = [], + _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl { int line = 0; int column = 0; int srcUrlId = 0; @@ -373,7 +387,10 @@ class SingleMapping extends Mapping { } } else { var start = new SourceLocation(0, - sourceUrl: url, line: entry.sourceLine, column: entry.sourceColumn); + sourceUrl: _mapUrl == null ? url : _mapUrl.resolve(url), + line: entry.sourceLine, + column: entry.sourceColumn); + // Offset and other context is not available. if (entry.sourceNameId != null) { return new SourceMapSpan.identifier(start, names[entry.sourceNameId]); diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 200f8f85b..fc0fe9bcc 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.0+2 +version: 0.10.1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 8528683f3..b14fdf425 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -114,6 +114,14 @@ main() { expect(mapping.toJson(), equals(inputMap)); }); + test('parse with map URL', () { + var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); + inputMap['sourceRoot'] = 'pkg/'; + var mapping = parseJson(inputMap, mapUrl: "file:///path/to/map"); + expect(mapping.spanFor(0, 0).sourceUrl, + Uri.parse("file:///path/to/pkg/input.dart")); + }); + test('parse and re-emit', () { for (var expected in [ EXPECTED_MAP, From 91d98d80e0cc485672dfa5c3a66fdb15e91dc1f7 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 16 Jul 2015 13:41:26 -0700 Subject: [PATCH 045/133] Upgrade to the new test runner. R=sigmund@google.com Review URL: https://codereview.chromium.org//1240863004 . --- pkgs/source_maps/.gitignore | 1 + pkgs/source_maps/.status | 20 -------------------- pkgs/source_maps/.test_config | 3 +++ pkgs/source_maps/pubspec.yaml | 4 ++-- pkgs/source_maps/test/builder_test.dart | 2 +- pkgs/source_maps/test/common.dart | 2 +- pkgs/source_maps/test/end2end_test.dart | 2 +- pkgs/source_maps/test/parser_test.dart | 2 +- pkgs/source_maps/test/printer_test.dart | 2 +- pkgs/source_maps/test/refactor_test.dart | 2 +- pkgs/source_maps/test/run.dart | 4 ++-- pkgs/source_maps/test/utils_test.dart | 2 +- pkgs/source_maps/test/vlq_test.dart | 6 ++++-- 13 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 pkgs/source_maps/.status create mode 100644 pkgs/source_maps/.test_config diff --git a/pkgs/source_maps/.gitignore b/pkgs/source_maps/.gitignore index 388eff0ba..7dbf0350d 100644 --- a/pkgs/source_maps/.gitignore +++ b/pkgs/source_maps/.gitignore @@ -3,6 +3,7 @@ .pub/ build/ packages +.packages # Or the files created by dart2js. *.dart.js diff --git a/pkgs/source_maps/.status b/pkgs/source_maps/.status deleted file mode 100644 index befa7ddc7..000000000 --- a/pkgs/source_maps/.status +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -# 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. - -# Skip non-test files ending with "_test". -packages/*: Skip -*/packages/*: Skip -*/*/packages/*: Skip -*/*/*/packages/*: Skip -*/*/*/*packages/*: Skip -*/*/*/*/*packages/*: Skip - -# Only run tests from the build directory, since we don't care about the -# difference between transformed an untransformed code. -test/*: Skip - -[ $compiler == dart2js || $compiler == dart2dart ] -build/test/vlq_test: RuntimeError # A VLQ test checks for large numbers that - # overflow in JS (numbers slightly larger than - # 32 bits where we do bitwise operations). diff --git a/pkgs/source_maps/.test_config b/pkgs/source_maps/.test_config new file mode 100644 index 000000000..412fc5c5c --- /dev/null +++ b/pkgs/source_maps/.test_config @@ -0,0 +1,3 @@ +{ + "test_package": true +} \ No newline at end of file diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index fc0fe9bcc..86015d540 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1 +version: 0.10.2-dev author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps @@ -9,4 +9,4 @@ dependencies: environment: sdk: '>=1.8.0 <2.0.0' dev_dependencies: - unittest: '>=0.9.0 <0.12.0' + test: '>=0.12.0 <0.13.0' diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index ca0ca8d2d..dcc583cfd 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -5,7 +5,7 @@ library test.source_maps_test; import 'dart:convert'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 73a8d406b..3bc512cdf 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -7,7 +7,7 @@ library test.common; import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; /// Content of the source file const String INPUT = ''' diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 7dbc6bd9b..8caf2e9ea 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -4,7 +4,7 @@ library test.end2end_test; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'common.dart'; diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index b14fdf425..88da8c547 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -5,7 +5,7 @@ library test.parser_test; import 'dart:convert'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index e55ca9f6e..25036eee9 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -5,7 +5,7 @@ library test.printer_test; import 'dart:convert'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'common.dart'; diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 08b896510..03292d1db 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -4,7 +4,7 @@ library polymer.test.refactor_test; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/refactor.dart'; import 'package:source_maps/parser.dart' show parse, Mapping; import 'package:source_span/source_span.dart'; diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart index ec3c3ab7f..b37fdcd6f 100755 --- a/pkgs/source_maps/test/run.dart +++ b/pkgs/source_maps/test/run.dart @@ -5,8 +5,8 @@ library test.run; -import 'package:unittest/compact_vm_config.dart'; -import 'package:unittest/unittest.dart'; +import 'package:test/compact_vm_config.dart'; +import 'package:test/test.dart'; import 'dart:io' show Options; import 'builder_test.dart' as builder_test; diff --git a/pkgs/source_maps/test/utils_test.dart b/pkgs/source_maps/test/utils_test.dart index 79a7de769..cbbb40ab3 100644 --- a/pkgs/source_maps/test/utils_test.dart +++ b/pkgs/source_maps/test/utils_test.dart @@ -5,7 +5,7 @@ /// Tests for the binary search utility algorithm. library test.utils_test; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/src/utils.dart'; main() { diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 0abdc4795..d1b543da0 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -5,7 +5,7 @@ library test.vlq_test; import 'dart:math'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; import 'package:source_maps/src/vlq.dart'; main() { @@ -49,7 +49,9 @@ main() { expect(() => decodeVlq('igggggE'.split('').iterator), throws); expect(() => decodeVlq('jgggggE'.split('').iterator), throws); expect(() => decodeVlq('lgggggE'.split('').iterator), throws); - }); + }, + // This test uses integers so large they overflow in JS. + testOn: "dart-vm"); } _checkEncodeDecode(int value) { From 8ba5f7c7fca2f169df82f4533bc7494c56381f6b Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 8 Mar 2016 17:22:47 -0800 Subject: [PATCH 046/133] Fix unused import --- pkgs/source_maps/test/run.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart index b37fdcd6f..477da8a37 100755 --- a/pkgs/source_maps/test/run.dart +++ b/pkgs/source_maps/test/run.dart @@ -7,7 +7,6 @@ library test.run; import 'package:test/compact_vm_config.dart'; import 'package:test/test.dart'; -import 'dart:io' show Options; import 'builder_test.dart' as builder_test; import 'end2end_test.dart' as end2end_test; From 51e3022771f3e69af4327b544b8dfbbff17c3493 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 24 Mar 2016 13:21:49 -0700 Subject: [PATCH 047/133] Fix strong-mode warnings. R=sigmund@google.com Review URL: https://codereview.chromium.org//1826093002 . --- pkgs/source_maps/.analysis_options | 2 ++ pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/lib/parser.dart | 6 +++--- pkgs/source_maps/pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 pkgs/source_maps/.analysis_options diff --git a/pkgs/source_maps/.analysis_options b/pkgs/source_maps/.analysis_options new file mode 100644 index 000000000..a10d4c5a0 --- /dev/null +++ b/pkgs/source_maps/.analysis_options @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 3066293dd..4872d79a9 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.1+1 + +* Fix all strong mode warnings. + ## 0.10.1 * Add a `mapUrl` named argument to `parse` and `parseJson`. This argument is diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index a9fcff578..b659654f0 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -182,7 +182,7 @@ class SingleMapping extends Mapping { var names = new LinkedHashMap(); var lineNum; - var targetEntries; + List targetEntries; for (var sourceEntry in sourceEntries) { if (lineNum == null || sourceEntry.target.line > lineNum) { lineNum = sourceEntry.target.line; @@ -212,8 +212,8 @@ class SingleMapping extends Mapping { SingleMapping.fromJson(Map map, {mapUrl}) : targetUrl = map['file'], - urls = map['sources'], - names = map['names'], + urls = new List.from(map['sources']), + names = new List.from(map['names']), sourceRoot = map['sourceRoot'], lines = [], _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl { diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 86015d540..e8dd7940a 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.2-dev +version: 0.10.1+1 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps From c5a436d21659b3134bce9c86549997eeca392ae5 Mon Sep 17 00:00:00 2001 From: Vittorio Ballestra Date: Sun, 7 Aug 2016 12:13:16 +0200 Subject: [PATCH 048/133] fixes dart-lang/source_maps#16 --- pkgs/source_maps/lib/builder.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 091e220c5..1f36b999b 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -77,7 +77,8 @@ class Entry implements Comparable { /// location in the target file. We sort primarily by the target offset /// because source map files are encoded by printing each mapping in order as /// they appear in the target file. - int compareTo(Entry other) { + int compareTo(_other) { + Entry other = _other as Entry; int res = target.compareTo(other.target); if (res != 0) return res; res = source.sourceUrl.toString().compareTo( From 4e30af0b5e5bf55fad647d450d4588ebc5792003 Mon Sep 17 00:00:00 2001 From: Vittorio Ballestra Date: Tue, 9 Aug 2016 10:41:26 +0200 Subject: [PATCH 049/133] much better indeed --- pkgs/source_maps/lib/builder.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 1f36b999b..c8596fe63 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -60,7 +60,7 @@ class SourceMapBuilder { } /// An entry in the source map builder. -class Entry implements Comparable { +class Entry implements Comparable { /// Span denoting the original location in the input source file final SourceLocation source; @@ -77,8 +77,7 @@ class Entry implements Comparable { /// location in the target file. We sort primarily by the target offset /// because source map files are encoded by printing each mapping in order as /// they appear in the target file. - int compareTo(_other) { - Entry other = _other as Entry; + int compareTo(Entry other) { int res = target.compareTo(other.target); if (res != 0) return res; res = source.sourceUrl.toString().compareTo( From d9853149e09a3ea73a42b9f63c6460479adcf9f4 Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Mon, 31 Oct 2016 09:32:35 -0700 Subject: [PATCH 050/133] Publish new version of source_maps with extra strong mode fixes --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 4872d79a9..fe88e6db4 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.1+2 + +* Fix more strong mode warnings. + ## 0.10.1+1 * Fix all strong mode warnings. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index e8dd7940a..0aea12baa 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1+1 +version: 0.10.1+2 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps From 5e3d46ed16bd97d99b27b2e81e53d1c97d3ef4e3 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Thu, 8 Dec 2016 08:20:42 -0800 Subject: [PATCH 051/133] Support a new source map bundle format useful for the Dart Dev Compiler. A source map bundle is a JSON array where each entry is a source map. BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//2560623003 . --- pkgs/source_maps/CHANGELOG.md | 7 + pkgs/source_maps/lib/parser.dart | 211 +++++++++++++++++-------- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 159 ++++++++++++++++--- 4 files changed, 290 insertions(+), 89 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index fe88e6db4..4e3286662 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.10.1+3 + +* Add `MappingBundle` class that handles extended source map format that + supports source maps for multiple output files in a single mapper. + Extend `Mapping.spanFor` API to accept a uri parameter that is optional + for normal source maps but required for MappingBundle source maps. + ## 0.10.1+2 * Fix more strong mode warnings. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index b659654f0..c651f89ff 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -8,6 +8,7 @@ library source_maps.parser; import 'dart:collection'; import 'dart:convert'; +import 'package:path/path.dart' as path; import 'package:source_span/source_span.dart'; import 'builder.dart' as builder; @@ -25,22 +26,44 @@ import 'src/vlq.dart'; // TODO(tjblasi): Ignore the first line of [jsonMap] if the JSON safety string // `)]}'` begins the string representation of the map. Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => - parseJson(JSON.decode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); + parseJson(JSON.decode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); -/// Parses a source map directly from a json map object. +/// Parses a source map or source map bundle directly from a json string. +/// +/// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of +/// the source map file itself. If it's passed, any URLs in the source +/// map will be interpreted as relative to this URL when generating spans. +Mapping parseExtended(String jsonMap, {Map otherMaps, mapUrl}) => + parseJsonExtended(JSON.decode(jsonMap), + otherMaps: otherMaps, mapUrl: mapUrl); + +/// Parses a source map or source map bundle. +/// +/// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of +/// the source map file itself. If it's passed, any URLs in the source +/// map will be interpreted as relative to this URL when generating spans. +Mapping parseJsonExtended(/*List|Map*/ json, + {Map otherMaps, mapUrl}) { + if (json is List) { + return new MappingBundle.fromJson(json, mapUrl: mapUrl); + } + return parseJson(json as Map); +} + +/// Parses a source map /// /// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of /// the source map file itself. If it's passed, any URLs in the source /// map will be interpreted as relative to this URL when generating spans. Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { if (map['version'] != 3) { - throw new ArgumentError( - 'unexpected source map version: ${map["version"]}. ' + throw new ArgumentError('unexpected source map version: ${map["version"]}. ' 'Only version 3 is supported.'); } if (map.containsKey('sections')) { - if (map.containsKey('mappings') || map.containsKey('sources') || + if (map.containsKey('mappings') || + map.containsKey('sources') || map.containsKey('names')) { throw new FormatException('map containing "sections" ' 'cannot contain "mappings", "sources", or "names".'); @@ -51,16 +74,21 @@ Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { return new SingleMapping.fromJson(map, mapUrl: mapUrl); } - /// A mapping parsed out of a source map. abstract class Mapping { /// Returns the span associated with [line] and [column]. - SourceMapSpan spanFor(int line, int column, {Map files}); + /// + /// [uri] is the optional location of the output file to find the span for + /// to disambiguate cases where a mapping may have different mappings for + /// different output files. + SourceMapSpan spanFor(int line, int column, + {Map files, String uri}); /// Returns the span associated with [location]. SourceMapSpan spanForLocation(SourceLocation location, {Map files}) { - return spanFor(location.line, location.column, files: files); + return spanFor(location.line, location.column, + uri: location.sourceUrl?.toString(), files: files); } } @@ -116,35 +144,79 @@ class MultiSectionMapping extends Mapping { } int _indexFor(line, column) { - for(int i = 0; i < _lineStart.length; i++) { + for (int i = 0; i < _lineStart.length; i++) { if (line < _lineStart[i]) return i - 1; if (line == _lineStart[i] && column < _columnStart[i]) return i - 1; } return _lineStart.length - 1; } - SourceMapSpan spanFor(int line, int column, {Map files}) { + SourceMapSpan spanFor(int line, int column, + {Map files, String uri}) { + // TODO(jacobr): perhaps verify that targetUrl matches the actual uri + // or at least ends in the same file name. int index = _indexFor(line, column); return _maps[index].spanFor( - line - _lineStart[index], column - _columnStart[index], files: files); + line - _lineStart[index], column - _columnStart[index], + files: files); } String toString() { var buff = new StringBuffer("$runtimeType : ["); for (int i = 0; i < _lineStart.length; i++) { - buff..write('(') - ..write(_lineStart[i]) - ..write(',') - ..write(_columnStart[i]) - ..write(':') - ..write(_maps[i]) - ..write(')'); + buff + ..write('(') + ..write(_lineStart[i]) + ..write(',') + ..write(_columnStart[i]) + ..write(':') + ..write(_maps[i]) + ..write(')'); } buff.write(']'); return buff.toString(); } } +class MappingBundle extends Mapping { + Map _mappings = {}; + + MappingBundle.fromJson(List json, {String mapUrl}) { + for (var map in json) { + var mapping = parseJson(map, mapUrl: mapUrl) as SingleMapping; + var targetUrl = mapping.targetUrl; + _mappings[targetUrl] = mapping; + } + } + + /// Encodes the Mapping mappings as a json map. + List toJson() => _mappings.values.map((v) => v.toJson()).toList(); + + String toString() { + var buff = new StringBuffer(); + for (var map in _mappings.values) { + buff.write(map.toString()); + } + return buff.toString(); + } + + SourceMapSpan spanFor(int line, int column, + {Map files, String uri}) { + if (uri == null) { + throw new ArgumentError.notNull('uri'); + } + if (_mappings.containsKey(uri)) { + return _mappings[uri].spanFor(line, column, files: files, uri: uri); + } + // Fall back to looking up the source map on just the basename. + var name = path.basename(uri.toString()); + if (_mappings.containsKey(name)) { + return _mappings[name].spanFor(line, column, files: files, uri: name); + } + return null; + } +} + /// A map containing direct source mappings. class SingleMapping extends Mapping { /// Source urls used in the mapping, indexed by id. @@ -167,8 +239,8 @@ class SingleMapping extends Mapping { SingleMapping._(this.targetUrl, this.urls, this.names, this.lines) : _mapUrl = null; - factory SingleMapping.fromEntries( - Iterable entries, [String fileUrl]) { + factory SingleMapping.fromEntries(Iterable entries, + [String fileUrl]) { // The entries needs to be sorted by the target offsets. var sourceEntries = new List.from(entries)..sort(); var lines = []; @@ -196,14 +268,11 @@ class SingleMapping extends Mapping { var sourceUrl = sourceEntry.source.sourceUrl; var urlId = urls.putIfAbsent( sourceUrl == null ? '' : sourceUrl.toString(), () => urls.length); - var srcNameId = sourceEntry.identifierName == null ? null : - names.putIfAbsent(sourceEntry.identifierName, () => names.length); - targetEntries.add(new TargetEntry( - sourceEntry.target.column, - urlId, - sourceEntry.source.line, - sourceEntry.source.column, - srcNameId)); + var srcNameId = sourceEntry.identifierName == null + ? null + : names.putIfAbsent(sourceEntry.identifierName, () => names.length); + targetEntries.add(new TargetEntry(sourceEntry.target.column, urlId, + sourceEntry.source.line, sourceEntry.source.column, srcNameId)); } } return new SingleMapping._( @@ -271,8 +340,8 @@ class SingleMapping extends Mapping { throw new StateError( 'Invalid name id: $targetUrl, $line, $srcNameId'); } - entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn, - srcNameId)); + entries.add( + new TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId)); } } if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment(); @@ -326,8 +395,8 @@ class SingleMapping extends Mapping { 'version': 3, 'sourceRoot': sourceRoot == null ? '' : sourceRoot, 'sources': urls, - 'names' : names, - 'mappings' : buff.toString() + 'names': names, + 'mappings': buff.toString() }; if (targetUrl != null) { result['file'] = targetUrl; @@ -342,9 +411,9 @@ class SingleMapping extends Mapping { return newValue; } - _segmentError(int seen, int line) => new StateError( - 'Invalid entry in sourcemap, expected 1, 4, or 5' - ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); + _segmentError(int seen, int line) => + new StateError('Invalid entry in sourcemap, expected 1, 4, or 5' + ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); /// Returns [TargetLineEntry] which includes the location in the target [line] /// number. In particular, the resulting entry is the last entry whose line @@ -367,7 +436,8 @@ class SingleMapping extends Mapping { return (index <= 0) ? null : entries[index - 1]; } - SourceMapSpan spanFor(int line, int column, {Map files}) { + SourceMapSpan spanFor(int line, int column, + {Map files, String uri}) { var entry = _findColumn(line, column, _findLine(line)); if (entry == null || entry.sourceUrlId == null) return null; var url = urls[entry.sourceUrlId]; @@ -402,17 +472,18 @@ class SingleMapping extends Mapping { String toString() { return (new StringBuffer("$runtimeType : [") - ..write('targetUrl: ') - ..write(targetUrl) - ..write(', sourceRoot: ') - ..write(sourceRoot) - ..write(', urls: ') - ..write(urls) - ..write(', names: ') - ..write(names) - ..write(', lines: ') - ..write(lines) - ..write(']')).toString(); + ..write('targetUrl: ') + ..write(targetUrl) + ..write(', sourceRoot: ') + ..write(sourceRoot) + ..write(', urls: ') + ..write(urls) + ..write(', names: ') + ..write(names) + ..write(', lines: ') + ..write(lines) + ..write(']')) + .toString(); } String get debugString { @@ -420,24 +491,24 @@ class SingleMapping extends Mapping { for (var lineEntry in lines) { var line = lineEntry.line; for (var entry in lineEntry.entries) { - buff..write(targetUrl) + buff + ..write(targetUrl) + ..write(': ') + ..write(line) + ..write(':') + ..write(entry.column); + if (entry.sourceUrlId != null) { + buff + ..write(' --> ') + ..write(sourceRoot) + ..write(urls[entry.sourceUrlId]) ..write(': ') - ..write(line) + ..write(entry.sourceLine) ..write(':') - ..write(entry.column); - if (entry.sourceUrlId != null) { - buff..write(' --> ') - ..write(sourceRoot) - ..write(urls[entry.sourceUrlId]) - ..write(': ') - ..write(entry.sourceLine) - ..write(':') - ..write(entry.sourceColumn); + ..write(entry.sourceColumn); } if (entry.sourceNameId != null) { - buff..write(' (') - ..write(names[entry.sourceNameId]) - ..write(')'); + buff..write(' (')..write(names[entry.sourceNameId])..write(')'); } buff.write('\n'); } @@ -463,8 +534,11 @@ class TargetEntry { final int sourceColumn; final int sourceNameId; - TargetEntry(this.column, [this.sourceUrlId, this.sourceLine, - this.sourceColumn, this.sourceNameId]); + TargetEntry(this.column, + [this.sourceUrlId, + this.sourceLine, + this.sourceColumn, + this.sourceNameId]); String toString() => '$runtimeType: ' '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; @@ -482,7 +556,7 @@ class _MappingTokenizer implements Iterator { // Iterator API is used by decodeVlq to consume VLQ entries. bool moveNext() => ++index < _length; String get current => - (index >= 0 && index < _length) ? _internal[index] : null; + (index >= 0 && index < _length) ? _internal[index] : null; bool get hasTokens => index < _length - 1 && _length > 0; @@ -495,8 +569,13 @@ class _MappingTokenizer implements Iterator { } int _consumeValue() => decodeVlq(this); - void _consumeNewLine() { ++index; } - void _consumeNewSegment() { ++index; } + void _consumeNewLine() { + ++index; + } + + void _consumeNewSegment() { + ++index; + } // Print the state of the iterator, with colors indicating the current // position. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 0aea12baa..33626c550 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1+2 +version: 0.10.1+3 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 88da8c547..9448ea08f 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -7,35 +7,59 @@ library test.parser_test; import 'dart:convert'; import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; +import 'package:source_span/source_span.dart'; import 'common.dart'; const Map MAP_WITH_NO_SOURCE_LOCATION = const { - 'version': 3, - 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const [], - 'mappings': 'A', - 'file': 'output.dart' + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const [], + 'mappings': 'A', + 'file': 'output.dart' }; const Map MAP_WITH_SOURCE_LOCATION = const { - 'version': 3, - 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const [], - 'mappings': 'AAAA', - 'file': 'output.dart' + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const [], + 'mappings': 'AAAA', + 'file': 'output.dart' }; const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = const { - 'version': 3, - 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const ['var'], - 'mappings': 'AAAAA', - 'file': 'output.dart' + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const ['var'], + 'mappings': 'AAAAA', + 'file': 'output.dart' }; +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = const { + 'version': 3, + 'sourceRoot': 'pkg/', + 'sources': const ['input1.dart'], + 'names': const ['var1'], + 'mappings': 'AAAAA', + 'file': 'output1.dart' +}; + +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = const { + 'version': 3, + 'sourceRoot': 'pkg/', + 'sources': const ['input2.dart'], + 'names': const ['var2'], + 'mappings': 'AAAAA', + 'file': 'output2.dart' +}; + +const List SOURCE_MAP_BUNDLE = const [ + MAP_WITH_SOURCE_LOCATION_AND_NAME_1, + MAP_WITH_SOURCE_LOCATION_AND_NAME_2 +]; + main() { test('parse', () { var mapping = parseJson(EXPECTED_MAP); @@ -105,6 +129,12 @@ main() { inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap); expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart")); + expect( + mapping + .spanForLocation( + new SourceLocation(0, sourceUrl: Uri.parse("ignored.dart"))) + .sourceUrl, + Uri.parse("/pkg/input.dart")); var newSourceRoot = '/new/'; @@ -122,14 +152,99 @@ main() { Uri.parse("file:///path/to/pkg/input.dart")); }); + group('parse with bundle', () { + var mapping = + parseJsonExtended(SOURCE_MAP_BUNDLE, mapUrl: "file:///path/to/map"); + test('simple', () { + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: new Uri.file('/path/to/output1.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: new Uri.file('/path/to/output2.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + + expect( + mapping.spanFor(0, 0, uri: "file:///path/to/output1.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect( + mapping.spanFor(0, 0, uri: "file:///path/to/output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + }); + + test('unmapped path', () { + expect(mapping.spanFor(0, 0, uri: "unmapped_output.dart"), isNull); + }); + + test('missing path', () { + expect(() => mapping.spanFor(0, 0), throws); + }); + + test('incomplete paths', () { + expect(mapping.spanFor(0, 0, uri: "output1.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + }); + + test('parseExtended', () { + var mapping = parseExtended(JSON.encode(SOURCE_MAP_BUNDLE), + mapUrl: "file:///path/to/map"); + + expect(mapping.spanFor(0, 0, uri: "output1.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + }); + + // Test that the source map can handle cases where the uri passed in is + // not from the expected host but it is still unambiguous which source + // map should be used. + test('different paths', () { + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('http://localhost/output1.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('http://localhost/output2.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + + expect( + mapping.spanFor(0, 0, uri: "http://localhost/output1.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect( + mapping.spanFor(0, 0, uri: "http://localhost/output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + }); + }); + test('parse and re-emit', () { for (var expected in [ - EXPECTED_MAP, - MAP_WITH_NO_SOURCE_LOCATION, - MAP_WITH_SOURCE_LOCATION, - MAP_WITH_SOURCE_LOCATION_AND_NAME]) { + EXPECTED_MAP, + MAP_WITH_NO_SOURCE_LOCATION, + MAP_WITH_SOURCE_LOCATION, + MAP_WITH_SOURCE_LOCATION_AND_NAME + ]) { var mapping = parseJson(expected); expect(mapping.toJson(), equals(expected)); + + mapping = parseJsonExtended(expected); + expect(mapping.toJson(), equals(expected)); } + // Invalid for this case + expect(() => parseJson(SOURCE_MAP_BUNDLE), throws); + + var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE); + expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); }); } From c05a686f4dd048b0d269464f428da760d063dac2 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Fri, 9 Dec 2016 09:56:09 -0800 Subject: [PATCH 052/133] Improve handling of locations not from the uris the source map is for. Make `MappingBundle` distinguish between locations from a file with source maps that do not have a source map entry and locations that are from a file that does not have a source map. This enables more graceful generation of stack traces with mixed Dart and JS stack frames. Support a new source map bundle format useful for the Dart Dev Compiler. A source map bundle is a JSON array where each entry is a source map. BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//2564683003 . --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/lib/parser.dart | 12 +++++++++++- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 10 +++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 4e3286662..e5f3ae2e6 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.1+4 + +* Extend `MappingBundle.spanFor` to accept requests for output files that + don't have source maps. + ## 0.10.1+3 * Add `MappingBundle` class that handles extended source map format that diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index c651f89ff..492e6cf65 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -213,7 +213,17 @@ class MappingBundle extends Mapping { if (_mappings.containsKey(name)) { return _mappings[name].spanFor(line, column, files: files, uri: name); } - return null; + + // Note: when there is no source map for an uri, this behaves like an + // identity function, returning the requested location as the result. + + // Create a mock offset for the output location. We compute it in terms + // of the input line and column to minimize the chances that two different + // line and column locations are mapped to the same offset. + var offset = line * 1000000 + column; + var location = new SourceLocation(offset, + line: line, column: column, sourceUrl: Uri.parse(uri)); + return new SourceMapSpan(location, location, ""); } } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 33626c550..d0d455fff 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1+3 +version: 0.10.1+4 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 9448ea08f..a317f7e63 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -178,7 +178,15 @@ main() { }); test('unmapped path', () { - expect(mapping.spanFor(0, 0, uri: "unmapped_output.dart"), isNull); + var span = mapping.spanFor(0, 0, uri: "unmapped_output.dart"); + expect(span.sourceUrl, Uri.parse("unmapped_output.dart")); + expect(span.start.line, equals(0)); + expect(span.start.column, equals(0)); + + span = mapping.spanFor(10, 5, uri: "unmapped_output.dart"); + expect(span.sourceUrl, Uri.parse("unmapped_output.dart")); + expect(span.start.line, equals(10)); + expect(span.start.column, equals(5)); }); test('missing path', () { From fb162a9c6db95499e372c49d3f17fc7b4c7a57e1 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Mon, 12 Dec 2016 08:57:43 -0800 Subject: [PATCH 053/133] Fix strong mode error in test. Closes https://github.com/dart-lang/source_maps/issues/21 BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//2565053002 . --- pkgs/source_maps/CHANGELOG.md | 3 +++ pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index e5f3ae2e6..425e7aec5 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.10.1+5 + * Fix strong mode warning in test. + ## 0.10.1+4 * Extend `MappingBundle.spanFor` to accept requests for output files that diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index d0d455fff..3beb3eae0 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1+4 +version: 0.10.1+5 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index a317f7e63..4b2d94713 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -250,7 +250,7 @@ main() { expect(mapping.toJson(), equals(expected)); } // Invalid for this case - expect(() => parseJson(SOURCE_MAP_BUNDLE), throws); + expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws); var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE); expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); From 6f9505f8b60d4b184d3fb782afe83aadb9d23619 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Wed, 14 Dec 2016 11:35:40 -0800 Subject: [PATCH 054/133] Rev package version as the extended source map format is a new feature. Polish `MappingBundle.spanFor` handling of uris that have a suffix that exactly match a source map in the MappingBundle. R=nweiz@google.com, sigmund@google.com Review URL: https://codereview.chromium.org//2574593004 . --- pkgs/source_maps/CHANGELOG.md | 5 ++ pkgs/source_maps/lib/parser.dart | 33 ++++++++--- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 79 +++++++++++++++++++++++--- 4 files changed, 102 insertions(+), 17 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 425e7aec5..d2bed8aca 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.2 + * Support for extended source map format. + * Polish `MappingBundle.spanFor` handling of URIs that have a suffix that + exactly match a source map in the MappingBundle. + ## 0.10.1+5 * Fix strong mode warning in test. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 492e6cf65..1c2318774 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -8,7 +8,6 @@ library source_maps.parser; import 'dart:collection'; import 'dart:convert'; -import 'package:path/path.dart' as path; import 'package:source_span/source_span.dart'; import 'builder.dart' as builder; @@ -185,6 +184,8 @@ class MappingBundle extends Mapping { for (var map in json) { var mapping = parseJson(map, mapUrl: mapUrl) as SingleMapping; var targetUrl = mapping.targetUrl; + // TODO(jacobr): verify that targetUrl is valid uri instead of a windows + // path. _mappings[targetUrl] = mapping; } } @@ -205,13 +206,29 @@ class MappingBundle extends Mapping { if (uri == null) { throw new ArgumentError.notNull('uri'); } - if (_mappings.containsKey(uri)) { - return _mappings[uri].spanFor(line, column, files: files, uri: uri); - } - // Fall back to looking up the source map on just the basename. - var name = path.basename(uri.toString()); - if (_mappings.containsKey(name)) { - return _mappings[name].spanFor(line, column, files: files, uri: name); + + // Find the longest suffix of the uri that matches the sourcemap + // where the suffix starts after a path segment boundary. + // We consider ":" and "/" as path segment boundaries so that + // "package:" uris can be handled with minimal special casing. Having a + // few false positive path segment boundaries is not a significant issue + // as we prefer the longest matching prefix. + // Using package:path `path.split` to find path segment boundaries would + // not generate all of the path segment boundaries we want for "package:" + // urls as "package:package_name" would be one path segment when we want + // "package" and "package_name" to be sepearate path segments. + + bool onBoundary = true; + var separatorCodeUnits = ['/'.codeUnitAt(0), ':'.codeUnitAt(0)]; + for (var i = 0; i < uri.length; ++i) { + if (onBoundary) { + var candidate = uri.substring(i); + if (_mappings.containsKey(candidate)) { + return _mappings[candidate] + .spanFor(line, column, files: files, uri: candidate); + } + } + onBoundary = separatorCodeUnits.contains(uri.codeUnitAt(i)); } // Note: when there is no source map for an uri, this behaves like an diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 3beb3eae0..64c0e9c7b 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1+5 +version: 0.10.2 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 4b2d94713..3cccf4413 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -43,7 +43,7 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = const { 'sources': const ['input1.dart'], 'names': const ['var1'], 'mappings': 'AAAAA', - 'file': 'output1.dart' + 'file': 'output.dart' }; const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = const { @@ -55,9 +55,19 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = const { 'file': 'output2.dart' }; +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = const { + 'version': 3, + 'sourceRoot': 'pkg/', + 'sources': const ['input3.dart'], + 'names': const ['var3'], + 'mappings': 'AAAAA', + 'file': '3/output.dart' +}; + const List SOURCE_MAP_BUNDLE = const [ MAP_WITH_SOURCE_LOCATION_AND_NAME_1, - MAP_WITH_SOURCE_LOCATION_AND_NAME_2 + MAP_WITH_SOURCE_LOCATION_AND_NAME_2, + MAP_WITH_SOURCE_LOCATION_AND_NAME_3, ]; main() { @@ -155,11 +165,12 @@ main() { group('parse with bundle', () { var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE, mapUrl: "file:///path/to/map"); + test('simple', () { expect( mapping .spanForLocation(new SourceLocation(0, - sourceUrl: new Uri.file('/path/to/output1.dart'))) + sourceUrl: new Uri.file('/path/to/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( @@ -168,13 +179,50 @@ main() { sourceUrl: new Uri.file('/path/to/output2.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: new Uri.file('/path/to/3/output.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); expect( - mapping.spanFor(0, 0, uri: "file:///path/to/output1.dart").sourceUrl, + mapping.spanFor(0, 0, uri: "file:///path/to/output.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( mapping.spanFor(0, 0, uri: "file:///path/to/output2.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect( + mapping.spanFor(0, 0, uri: "file:///path/to/3/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); + }); + + test('package uris', () { + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('package:1/output.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('package:2/output2.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('package:3/output.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); + + expect(mapping.spanFor(0, 0, uri: "package:1/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + expect(mapping.spanFor(0, 0, uri: "package:2/output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + expect(mapping.spanFor(0, 0, uri: "package:3/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); }); test('unmapped path', () { @@ -194,20 +242,24 @@ main() { }); test('incomplete paths', () { - expect(mapping.spanFor(0, 0, uri: "output1.dart").sourceUrl, + expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); }); test('parseExtended', () { var mapping = parseExtended(JSON.encode(SOURCE_MAP_BUNDLE), mapUrl: "file:///path/to/map"); - expect(mapping.spanFor(0, 0, uri: "output1.dart").sourceUrl, + expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); }); // Test that the source map can handle cases where the uri passed in is @@ -217,7 +269,7 @@ main() { expect( mapping .spanForLocation(new SourceLocation(0, - sourceUrl: Uri.parse('http://localhost/output1.dart'))) + sourceUrl: Uri.parse('http://localhost/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( @@ -226,13 +278,24 @@ main() { sourceUrl: Uri.parse('http://localhost/output2.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect( + mapping + .spanForLocation(new SourceLocation(0, + sourceUrl: Uri.parse('http://localhost/3/output.dart'))) + .sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); expect( - mapping.spanFor(0, 0, uri: "http://localhost/output1.dart").sourceUrl, + mapping.spanFor(0, 0, uri: "http://localhost/output.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( mapping.spanFor(0, 0, uri: "http://localhost/output2.dart").sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); + expect( + mapping + .spanFor(0, 0, uri: "http://localhost/3/output.dart") + .sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); }); }); From 78b28e9bbee08b51b856ef3adab8fa6f79e04c91 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Tue, 7 Mar 2017 11:29:40 -0800 Subject: [PATCH 055/133] Enabling adding and querying for source maps in a MappingBundle. BUG= R=sigmund@google.com Review-Url: https://codereview.chromium.org//2736983002 . --- pkgs/source_maps/CHANGELOG.md | 3 +++ pkgs/source_maps/lib/parser.dart | 16 +++++++++++----- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 23 +++++++++++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index d2bed8aca..95b161daf 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.10.3 + * Add `addMapping` and `containsMapping` members to `MappingBundle`. + ## 0.10.2 * Support for extended source map format. * Polish `MappingBundle.spanFor` handling of URIs that have a suffix that diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 1c2318774..3b65e8910 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -180,16 +180,20 @@ class MultiSectionMapping extends Mapping { class MappingBundle extends Mapping { Map _mappings = {}; + MappingBundle() {} + MappingBundle.fromJson(List json, {String mapUrl}) { for (var map in json) { - var mapping = parseJson(map, mapUrl: mapUrl) as SingleMapping; - var targetUrl = mapping.targetUrl; - // TODO(jacobr): verify that targetUrl is valid uri instead of a windows - // path. - _mappings[targetUrl] = mapping; + addMapping(parseJson(map, mapUrl: mapUrl) as SingleMapping); } } + addMapping(SingleMapping mapping) { + // TODO(jacobr): verify that targetUrl is valid uri instead of a windows + // path. + _mappings[mapping.targetUrl] = mapping; + } + /// Encodes the Mapping mappings as a json map. List toJson() => _mappings.values.map((v) => v.toJson()).toList(); @@ -201,6 +205,8 @@ class MappingBundle extends Mapping { return buff.toString(); } + bool containsMapping(String url) => _mappings.containsKey(url); + SourceMapSpan spanFor(int line, int column, {Map files, String uri}) { if (uri == null) { diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 64c0e9c7b..618551236 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.2 +version: 0.10.3 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 3cccf4413..2c24d1b6f 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -262,6 +262,29 @@ main() { Uri.parse("file:///path/to/pkg/input3.dart")); }); + test('build bundle incrementally', () { + var mapping = new MappingBundle(); + + mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1, + mapUrl: "file:///path/to/map")); + expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input1.dart")); + + expect(mapping.containsMapping("output2.dart"), isFalse); + mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_2, + mapUrl: "file:///path/to/map")); + expect(mapping.containsMapping("output2.dart"), isTrue); + expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input2.dart")); + + expect(mapping.containsMapping("3/output.dart"), isFalse); + mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_3, + mapUrl: "file:///path/to/map")); + expect(mapping.containsMapping("3/output.dart"), isTrue); + expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, + Uri.parse("file:///path/to/pkg/input3.dart")); + }); + // Test that the source map can handle cases where the uri passed in is // not from the expected host but it is still unambiguous which source // map should be used. From 8e233ce3ffb54ea6c9afd1ef363d852dc1277f11 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Tue, 7 Mar 2017 14:39:54 -0800 Subject: [PATCH 056/133] Remove unused dependency on the path package. BUG= R=sigmund@google.com Review-Url: https://codereview.chromium.org//2732253003 . --- pkgs/source_maps/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 618551236..c10127166 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -4,7 +4,6 @@ author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps dependencies: - path: ^1.2.0 source_span: ^1.1.1 environment: sdk: '>=1.8.0 <2.0.0' From 27f0d293f012ca440d9713ac27d49cb8ca72f17a Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 23 Mar 2017 09:33:24 -0700 Subject: [PATCH 057/133] implement highlight for SourceMapFileSpan --- pkgs/source_maps/lib/src/source_map_span.dart | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index b70bdfe98..37107e1c7 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -17,7 +17,7 @@ class SourceMapSpan extends SourceSpanBase { final bool isIdentifier; SourceMapSpan(SourceLocation start, SourceLocation end, String text, - {this.isIdentifier: false}) + {this.isIdentifier: false}) : super(start, end, text); /// Creates a [SourceMapSpan] for an identifier with value [text] starting at @@ -26,13 +26,13 @@ class SourceMapSpan extends SourceSpanBase { /// The [end] location is determined by adding [text] to [start]. SourceMapSpan.identifier(SourceLocation start, String text) : this( - start, - new SourceLocation(start.offset + text.length, - sourceUrl: start.sourceUrl, - line: start.line, - column: start.column + text.length), - text, - isIdentifier: true); + start, + new SourceLocation(start.offset + text.length, + sourceUrl: start.sourceUrl, + line: start.line, + column: start.column + text.length), + text, + isIdentifier: true); } /// A wrapper aruond a [FileSpan] that implements [SourceMapSpan]. @@ -51,10 +51,11 @@ class SourceMapFileSpan implements SourceMapSpan, FileSpan { SourceMapFileSpan(this._inner, {this.isIdentifier: false}); int compareTo(SourceSpan other) => _inner.compareTo(other); + String highlight({color}) => _inner.highlight(color: color); SourceSpan union(SourceSpan other) => _inner.union(other); FileSpan expand(FileSpan other) => _inner.expand(other); String message(String message, {color}) => _inner.message(message, color: color); - String toString() => _inner.toString() - .replaceAll("FileSpan", "SourceMapFileSpan"); + String toString() => + _inner.toString().replaceAll("FileSpan", "SourceMapFileSpan"); } From 06dea5e04daf524761d2a9c8df903e5c2d338add Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 23 Mar 2017 09:36:05 -0700 Subject: [PATCH 058/133] update pubspec/changelog for 0.10.4 --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 95b161daf..a7c1b0670 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.4 +* Implement `highlight` in `SourceMapFileSpan`. +* Require version `^1.3.0` of `source_span`. + ## 0.10.3 * Add `addMapping` and `containsMapping` members to `MappingBundle`. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index c10127166..1db777bdc 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,10 +1,10 @@ name: source_maps -version: 0.10.3 +version: 0.10.4 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps dependencies: - source_span: ^1.1.1 + source_span: ^1.3.0 environment: sdk: '>=1.8.0 <2.0.0' dev_dependencies: From 162b1a9b58eac382180240f123759884cdc3afe5 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Tue, 12 Dec 2017 13:27:55 +0100 Subject: [PATCH 059/133] Fix analyzer warnings in parser_test.dart --- pkgs/source_maps/test/parser_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 2c24d1b6f..87141522d 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -137,7 +137,7 @@ main() { test('parse with source root', () { var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = '/pkg/'; - var mapping = parseJson(inputMap); + var mapping = parseJson(inputMap) as SingleMapping; expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart")); expect( mapping @@ -329,14 +329,14 @@ main() { MAP_WITH_SOURCE_LOCATION, MAP_WITH_SOURCE_LOCATION_AND_NAME ]) { - var mapping = parseJson(expected); + var mapping = parseJson(expected) as SingleMapping; expect(mapping.toJson(), equals(expected)); - mapping = parseJsonExtended(expected); + mapping = parseJsonExtended(expected) as SingleMapping; expect(mapping.toJson(), equals(expected)); } // Invalid for this case - expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws); + expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws) as MappingBundle; var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE); expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); From dffd5c30d8355097f30edef138fd53a2bb5bc5e2 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Tue, 12 Dec 2017 17:37:36 +0100 Subject: [PATCH 060/133] Update following review comments --- pkgs/source_maps/test/parser_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 87141522d..8c98c8178 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -329,16 +329,16 @@ main() { MAP_WITH_SOURCE_LOCATION, MAP_WITH_SOURCE_LOCATION_AND_NAME ]) { - var mapping = parseJson(expected) as SingleMapping; + SingleMapping mapping = parseJson(expected); expect(mapping.toJson(), equals(expected)); - mapping = parseJsonExtended(expected) as SingleMapping; + mapping = parseJsonExtended(expected); expect(mapping.toJson(), equals(expected)); } // Invalid for this case - expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws) as MappingBundle; + expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws); - var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE); + var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE) as MappingBundle; expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); }); } From 14631cd03338d3c828438e98c1c7e89985e192a3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 10 Mar 2018 16:50:41 -0800 Subject: [PATCH 061/133] Enable Travis, rename analysis_options, update .gitignore --- pkgs/source_maps/.gitignore | 17 ++------- pkgs/source_maps/.travis.yml | 23 ++++++++++++ ...analysis_options => analysis_options.yaml} | 0 pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/run.dart | 36 ------------------- 5 files changed, 27 insertions(+), 51 deletions(-) create mode 100644 pkgs/source_maps/.travis.yml rename pkgs/source_maps/{.analysis_options => analysis_options.yaml} (100%) delete mode 100755 pkgs/source_maps/test/run.dart diff --git a/pkgs/source_maps/.gitignore b/pkgs/source_maps/.gitignore index 7dbf0350d..f73b2f917 100644 --- a/pkgs/source_maps/.gitignore +++ b/pkgs/source_maps/.gitignore @@ -1,15 +1,4 @@ -# Don’t commit the following directories created by pub. -.buildlog -.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 \ No newline at end of file +.pub/ +pubspec.lock diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml new file mode 100644 index 000000000..25aeabec0 --- /dev/null +++ b/pkgs/source_maps/.travis.yml @@ -0,0 +1,23 @@ +language: dart + +dart: + - dev + - stable + +dart_task: + - test: -p vm,chrome + - dartanalyzer + +matrix: + include: + # Only validate formatting using the dev release + - dart: dev + dart_task: dartfmt + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache diff --git a/pkgs/source_maps/.analysis_options b/pkgs/source_maps/analysis_options.yaml similarity index 100% rename from pkgs/source_maps/.analysis_options rename to pkgs/source_maps/analysis_options.yaml diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 1db777bdc..ecf277ba8 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.4 +version: 0.10.5-dev author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/run.dart b/pkgs/source_maps/test/run.dart deleted file mode 100755 index 477da8a37..000000000 --- a/pkgs/source_maps/test/run.dart +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env dart -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// 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. - -library test.run; - -import 'package:test/compact_vm_config.dart'; -import 'package:test/test.dart'; - -import 'builder_test.dart' as builder_test; -import 'end2end_test.dart' as end2end_test; -import 'parser_test.dart' as parser_test; -import 'printer_test.dart' as printer_test; -import 'refactor_test.dart' as refactor_test; -import 'utils_test.dart' as utils_test; -import 'vlq_test.dart' as vlq_test; - -main(List arguments) { - var pattern = new RegExp(arguments.length > 0 ? arguments[0] : '.'); - useCompactVMConfiguration(); - - void addGroup(testFile, testMain) { - if (pattern.hasMatch(testFile)) { - group(testFile.replaceAll('_test.dart', ':'), testMain); - } - } - - addGroup('builder_test.dart', builder_test.main); - addGroup('end2end_test.dart', end2end_test.main); - addGroup('parser_test.dart', parser_test.main); - addGroup('printer_test.dart', printer_test.main); - addGroup('refactor_test.dart', refactor_test.main); - addGroup('utils_test.dart', utils_test.main); - addGroup('vlq_test.dart', vlq_test.main); -} From 83a68264f32d45f3947af8fe00c05d87db435c87 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 10 Mar 2018 16:54:32 -0800 Subject: [PATCH 062/133] dartfmt --- pkgs/source_maps/lib/builder.dart | 14 +-- pkgs/source_maps/lib/printer.dart | 6 +- pkgs/source_maps/lib/refactor.dart | 20 ++-- pkgs/source_maps/lib/src/vlq.dart | 1 - pkgs/source_maps/test/builder_test.dart | 16 ++-- pkgs/source_maps/test/common.dart | 14 +-- pkgs/source_maps/test/end2end_test.dart | 58 ++++++------ pkgs/source_maps/test/printer_test.dart | 115 ++++++++++++----------- pkgs/source_maps/test/refactor_test.dart | 55 +++++++---- pkgs/source_maps/test/utils_test.dart | 1 - pkgs/source_maps/test/vlq_test.dart | 1 - 11 files changed, 160 insertions(+), 141 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index c8596fe63..cdba2d2dc 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -16,7 +16,6 @@ import 'src/source_map_span.dart'; /// Builds a source map given a set of mappings. class SourceMapBuilder { - final List _entries = []; /// Adds an entry mapping the [targetOffset] to [source]. @@ -25,8 +24,8 @@ class SourceMapBuilder { if (targetFile == null) { throw new ArgumentError('targetFile cannot be null'); } - _entries.add( - new Entry(source, targetFile.location(targetOffset), identifier)); + _entries + .add(new Entry(source, targetFile.location(targetOffset), identifier)); } /// Adds an entry mapping [target] to [source]. @@ -45,8 +44,8 @@ class SourceMapBuilder { } /// Adds an entry mapping [target] to [source]. - void addLocation(SourceLocation source, SourceLocation target, - String identifier) { + void addLocation( + SourceLocation source, SourceLocation target, String identifier) { _entries.add(new Entry(source, target, identifier)); } @@ -80,8 +79,9 @@ class Entry implements Comparable { int compareTo(Entry other) { int res = target.compareTo(other.target); if (res != 0) return res; - res = source.sourceUrl.toString().compareTo( - other.source.sourceUrl.toString()); + res = source.sourceUrl + .toString() + .compareTo(other.source.sourceUrl.toString()); if (res != 0) return res; return source.compareTo(other.source); } diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 906e260f8..6187dba81 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -63,7 +63,6 @@ class Printer { _buff.write(str); } - /// Append a [total] number of spaces in the target file. Typically used for /// formatting indentation. void addSpaces(int total) { @@ -101,7 +100,6 @@ class Printer { /// peices of the code are generated independently on separate printers, and are /// finally put together in the end. class NestedPrinter implements NestedItem { - /// Items recoded by this printer, which can be [String] literals, /// [NestedItem]s, and source map information like [SourceLocation] and /// [SourceSpan]. @@ -134,8 +132,8 @@ class NestedPrinter implements NestedItem { /// Indicate [isOriginal] when [object] is copied directly from the user code. /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. - void add(object, {SourceLocation location, SourceSpan span, - bool isOriginal: false}) { + void add(object, + {SourceLocation location, SourceSpan span, bool isOriginal: false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); assert(location == null || span == null); diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index a33b86bec..d6b129a29 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -41,7 +41,7 @@ class TextEditTransaction { /// rewritten string and source map information. [filename] is given to the /// underlying printer to indicate the name of the generated file that will /// contains the source map information. - /// + /// /// Throws [UnsupportedError] if the edits were overlapping. If no edits were /// made, the printer simply contains the original string. NestedPrinter commit() { @@ -57,12 +57,13 @@ class TextEditTransaction { for (var edit in _edits) { if (consumed > edit.begin) { var sb = new StringBuffer(); - sb..write(file.location(edit.begin).toolString) - ..write(': overlapping edits. Insert at offset ') - ..write(edit.begin) - ..write(' but have consumed ') - ..write(consumed) - ..write(' input characters. List of edits:'); + sb + ..write(file.location(edit.begin).toolString) + ..write(': overlapping edits. Insert at offset ') + ..write(edit.begin) + ..write(' but have consumed ') + ..write(consumed) + ..write(' input characters. List of edits:'); for (var e in _edits) sb..write('\n ')..write(e); throw new UnsupportedError(sb.toString()); } @@ -70,8 +71,9 @@ class TextEditTransaction { // Add characters from the original string between this edit and the last // one, if any. var betweenEdits = original.substring(consumed, edit.begin); - printer..add(betweenEdits, location: _loc(consumed), isOriginal: true) - ..add(edit.replace, location: _loc(edit.begin)); + printer + ..add(betweenEdits, location: _loc(consumed), isOriginal: true) + ..add(edit.replace, location: _loc(edit.begin)); consumed = edit.end; } diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index e4ab4eb69..0c54dbf66 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -2,7 +2,6 @@ // 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. - /// Utilities to encode and decode VLQ values used in source maps. /// /// Sourcemaps are encoded with variable length numbers as base64 encoded diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index dcc583cfd..7c27e4e17 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -12,20 +12,20 @@ import 'common.dart'; main() { test('builder - with span', () { var map = (new SourceMapBuilder() - ..addSpan(inputVar1, outputVar1) - ..addSpan(inputFunction, outputFunction) - ..addSpan(inputVar2, outputVar2) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); expect(map, equals(EXPECTED_MAP)); }); test('builder - with location', () { var str = (new SourceMapBuilder() - ..addLocation(inputVar1.start, outputVar1.start, 'longVar1') - ..addLocation(inputFunction.start, outputFunction.start, 'longName') - ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') - ..addLocation(inputExpr.start, outputExpr.start, null)) + ..addLocation(inputVar1.start, outputVar1.start, 'longVar1') + ..addLocation(inputFunction.start, outputFunction.start, 'longName') + ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') + ..addLocation(inputExpr.start, outputExpr.start, null)) .toJson(output.url.toString()); expect(str, JSON.encode(EXPECTED_MAP)); }); diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 3bc512cdf..01ffdada6 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -63,19 +63,19 @@ SourceMapSpan outputExpr = ospan(19, 24); /// This mapping is stored in the tests so we can independently test the builder /// and parser algorithms without relying entirely on end2end tests. const Map EXPECTED_MAP = const { - 'version': 3, - 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const ['longVar1','longName','longVar2'], - 'mappings': 'IACIA;AAGAC,EAAaC,MACR', - 'file': 'output.dart' + 'version': 3, + 'sourceRoot': '', + 'sources': const ['input.dart'], + 'names': const ['longVar1', 'longName', 'longVar2'], + 'mappings': 'IACIA;AAGAC,EAAaC,MACR', + 'file': 'output.dart' }; check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan, bool realOffsets) { var line = outputSpan.start.line; var column = outputSpan.start.column; - var files = realOffsets ? {'input.dart': input} : null; + var files = realOffsets ? {'input.dart': input} : null; var span = mapping.spanFor(line, column, files: files); var span2 = mapping.spanForLocation(outputSpan.start, files: files); diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 8caf2e9ea..dd5bced00 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -30,10 +30,10 @@ main() { test('build + parse', () { var map = (new SourceMapBuilder() - ..addSpan(inputVar1, outputVar1) - ..addSpan(inputFunction, outputFunction) - ..addSpan(inputVar2, outputVar2) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1, mapping, inputVar1, false); @@ -44,10 +44,10 @@ main() { test('build + parse - no symbols', () { var map = (new SourceMapBuilder() - ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) - ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) - ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); @@ -58,14 +58,14 @@ main() { test('build + parse, repeated entries', () { var map = (new SourceMapBuilder() - ..addSpan(inputVar1, outputVar1) - ..addSpan(inputVar1, outputVar1) - ..addSpan(inputFunction, outputFunction) - ..addSpan(inputFunction, outputFunction) - ..addSpan(inputVar2, outputVar2) - ..addSpan(inputVar2, outputVar2) - ..addSpan(inputExpr, outputExpr) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr) + ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1, mapping, inputVar1, false); @@ -76,13 +76,13 @@ main() { test('build + parse - no symbols, repeated entries', () { var map = (new SourceMapBuilder() - ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) - ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) - ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) - ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) - ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) - ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) + ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); var mapping = parseJson(map); check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); @@ -93,10 +93,10 @@ main() { test('build + parse with file', () { var json = (new SourceMapBuilder() - ..addSpan(inputVar1, outputVar1) - ..addSpan(inputFunction, outputFunction) - ..addSpan(inputVar2, outputVar2) - ..addSpan(inputExpr, outputExpr)) + ..addSpan(inputVar1, outputVar1) + ..addSpan(inputFunction, outputFunction) + ..addSpan(inputVar2, outputVar2) + ..addSpan(inputExpr, outputExpr)) .toJson(output.url.toString()); var mapping = parse(json); check(outputVar1, mapping, inputVar1, true); @@ -156,7 +156,7 @@ main() { var oOffset = out.length - 2; var iOffset = INPUT.length - 2; check(file.span(oOffset, oOffset), mapping, ispan(iOffset, iOffset), true); - check(file.span(oOffset + 1, oOffset + 1), mapping, - ispan(iOffset, iOffset), true); + check(file.span(oOffset + 1, oOffset + 1), mapping, ispan(iOffset, iOffset), + true); }); } diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index 25036eee9..3fd768d8c 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -13,15 +13,16 @@ import 'common.dart'; main() { test('printer', () { var printer = new Printer('output.dart'); - printer..add('var ') - ..mark(inputVar1) - ..add('x = 3;\n') - ..mark(inputFunction) - ..add('f(') - ..mark(inputVar2) - ..add('y) => ') - ..mark(inputExpr) - ..add('x + y;\n'); + printer + ..add('var ') + ..mark(inputVar1) + ..add('x = 3;\n') + ..mark(inputFunction) + ..add('f(') + ..mark(inputVar2) + ..add('y) => ') + ..mark(inputExpr) + ..add('x + y;\n'); expect(printer.text, OUTPUT); expect(printer.map, JSON.encode(EXPECTED_MAP)); }); @@ -32,48 +33,50 @@ main() { var segments = INPUT.split('long'); expect(segments.length, 6); - printer..mark(ispan(0, 0)) - ..add(segments[0], projectMarks: true) - ..mark(inputVar1) - ..add('_s') - ..add(segments[1], projectMarks: true) - ..mark(inputFunction) - ..add('_s') - ..add(segments[2], projectMarks: true) - ..mark(inputVar2) - ..add('_s') - ..add(segments[3], projectMarks: true) - ..mark(inputExpr) - ..add('_s') - ..add(segments[4], projectMarks: true) - ..add('_s') - ..add(segments[5], projectMarks: true); + printer + ..mark(ispan(0, 0)) + ..add(segments[0], projectMarks: true) + ..mark(inputVar1) + ..add('_s') + ..add(segments[1], projectMarks: true) + ..mark(inputFunction) + ..add('_s') + ..add(segments[2], projectMarks: true) + ..mark(inputVar2) + ..add('_s') + ..add(segments[3], projectMarks: true) + ..mark(inputExpr) + ..add('_s') + ..add(segments[4], projectMarks: true) + ..add('_s') + ..add(segments[5], projectMarks: true); expect(printer.text, out); // 8 new lines in the source map: expect(printer.map.split(';').length, 8); - asFixed(SourceMapSpan s) => new SourceMapSpan(s.start, s.end, s.text, - isIdentifier: s.isIdentifier); + asFixed(SourceMapSpan s) => + new SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier); // The result is the same if we use fixed positions var printer2 = new Printer('output2.dart'); - printer2..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan()) - ..add(segments[0], projectMarks: true) - ..mark(asFixed(inputVar1)) - ..add('_s') - ..add(segments[1], projectMarks: true) - ..mark(asFixed(inputFunction)) - ..add('_s') - ..add(segments[2], projectMarks: true) - ..mark(asFixed(inputVar2)) - ..add('_s') - ..add(segments[3], projectMarks: true) - ..mark(asFixed(inputExpr)) - ..add('_s') - ..add(segments[4], projectMarks: true) - ..add('_s') - ..add(segments[5], projectMarks: true); + printer2 + ..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan()) + ..add(segments[0], projectMarks: true) + ..mark(asFixed(inputVar1)) + ..add('_s') + ..add(segments[1], projectMarks: true) + ..mark(asFixed(inputFunction)) + ..add('_s') + ..add(segments[2], projectMarks: true) + ..mark(asFixed(inputVar2)) + ..add('_s') + ..add(segments[3], projectMarks: true) + ..mark(asFixed(inputExpr)) + ..add('_s') + ..add(segments[4], projectMarks: true) + ..add('_s') + ..add(segments[5], projectMarks: true); expect(printer2.text, out); expect(printer2.map, printer.map); @@ -82,24 +85,26 @@ main() { group('nested printer', () { test('simple use', () { var printer = new NestedPrinter(); - printer..add('var ') - ..add('x = 3;\n', span: inputVar1) - ..add('f(', span: inputFunction) - ..add('y) => ', span: inputVar2) - ..add('x + y;\n', span: inputExpr) - ..build('output.dart'); + printer + ..add('var ') + ..add('x = 3;\n', span: inputVar1) + ..add('f(', span: inputFunction) + ..add('y) => ', span: inputVar2) + ..add('x + y;\n', span: inputExpr) + ..build('output.dart'); expect(printer.text, OUTPUT); expect(printer.map, JSON.encode(EXPECTED_MAP)); }); test('nested use', () { var printer = new NestedPrinter(); - printer..add('var ') - ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1)) - ..add('f(', span: inputFunction) - ..add(new NestedPrinter()..add('y) => ', span: inputVar2)) - ..add('x + y;\n', span: inputExpr) - ..build('output.dart'); + printer + ..add('var ') + ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1)) + ..add('f(', span: inputFunction) + ..add(new NestedPrinter()..add('y) => ', span: inputVar2)) + ..add('x + y;\n', span: inputExpr) + ..build('output.dart'); expect(printer.text, OUTPUT); expect(printer.map, JSON.encode(EXPECTED_MAP)); }); diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 03292d1db..afaeec26e 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -33,15 +33,16 @@ main() { txn.edit(6, 7, '_'); txn.edit(6, 6, '-'); expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); - }); test('conflict', () { var txn = new TextEditTransaction(original, file); txn.edit(2, 4, '.'); txn.edit(3, 3, '-'); - expect(() => txn.commit(), throwsA(predicate( - (e) => e.toString().contains('overlapping edits')))); + expect( + () => txn.commit(), + throwsA( + predicate((e) => e.toString().contains('overlapping edits')))); }); }); @@ -60,40 +61,48 @@ main() { // Line 1 and 2 are unmodified: mapping any column returns the beginning // of the corresponding line: - expect(_span(1, 1, map, file), + expect( + _span(1, 1, map, file), "line 1, column 1: \n" "0123456789\n" "^"); - expect(_span(1, 5, map, file), + expect( + _span(1, 5, map, file), "line 1, column 1: \n" "0123456789\n" "^"); - expect(_span(2, 1, map, file), + expect( + _span(2, 1, map, file), "line 2, column 1: \n" "0*23456789\n" "^"); - expect(_span(2, 8, map, file), + expect( + _span(2, 8, map, file), "line 2, column 1: \n" "0*23456789\n" "^"); // Line 3 is modified part way: mappings before the edits have the right // mapping, after the edits the mapping is null. - expect(_span(3, 1, map, file), + expect( + _span(3, 1, map, file), "line 3, column 1: \n" "01*3456789\n" "^"); - expect(_span(3, 5, map, file), + expect( + _span(3, 5, map, file), "line 3, column 1: \n" "01*3456789\n" "^"); // Start of edits map to beginning of the edit secion: - expect(_span(3, 6, map, file), + expect( + _span(3, 6, map, file), "line 3, column 6: \n" "01*3456789\n" " ^"); - expect(_span(3, 7, map, file), + expect( + _span(3, 7, map, file), "line 3, column 6: \n" "01*3456789\n" " ^"); @@ -101,42 +110,50 @@ main() { // Lines added have no mapping (they should inherit the last mapping), // but the end of the edit region continues were we left off: expect(_span(4, 1, map, file), isNull); - expect(_span(4, 5, map, file), + expect( + _span(4, 5, map, file), "line 3, column 8: \n" "01*3456789\n" " ^"); // Subsequent lines are still mapped correctly: // a (in a___cd...) - expect(_span(5, 1, map, file), + expect( + _span(5, 1, map, file), "line 4, column 1: \n" "abcdefghij\n" "^"); // _ (in a___cd...) - expect(_span(5, 2, map, file), + expect( + _span(5, 2, map, file), "line 4, column 2: \n" "abcdefghij\n" " ^"); // _ (in a___cd...) - expect(_span(5, 3, map, file), + expect( + _span(5, 3, map, file), "line 4, column 2: \n" "abcdefghij\n" " ^"); // _ (in a___cd...) - expect(_span(5, 4, map, file), + expect( + _span(5, 4, map, file), "line 4, column 2: \n" "abcdefghij\n" " ^"); // c (in a___cd...) - expect(_span(5, 5, map, file), + expect( + _span(5, 5, map, file), "line 4, column 3: \n" "abcdefghij\n" " ^"); - expect(_span(6, 1, map, file), + expect( + _span(6, 1, map, file), "line 5, column 1: \n" "abcd*fghij\n" "^"); - expect(_span(6, 8, map, file), + expect( + _span(6, 8, map, file), "line 5, column 1: \n" "abcd*fghij\n" "^"); diff --git a/pkgs/source_maps/test/utils_test.dart b/pkgs/source_maps/test/utils_test.dart index cbbb40ab3..6790082aa 100644 --- a/pkgs/source_maps/test/utils_test.dart +++ b/pkgs/source_maps/test/utils_test.dart @@ -51,4 +51,3 @@ _linearSearch(list, predicate) { } return list.length; } - diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index d1b543da0..30b6d4529 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -42,7 +42,6 @@ main() { expect(() => encodeVlq(min_int - 1), throws); expect(() => encodeVlq(min_int - 2), throws); - // if we allowed more than 32 bits, these would be the expected encodings // for the large numbers above. expect(() => decodeVlq('ggggggE'.split('').iterator), throws); From 70c30cd2bd3aa08f87a11f338679ce1fa24f65c8 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 25 Apr 2018 15:32:00 -0700 Subject: [PATCH 063/133] Add support for the sourcesContent field (dart-lang/source_maps#28) --- pkgs/source_maps/CHANGELOG.md | 8 ++++ pkgs/source_maps/lib/parser.dart | 58 +++++++++++++++++++++----- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 51 ++++++++++++++++++++++ 4 files changed, 108 insertions(+), 11 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index a7c1b0670..8ef25be0e 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.10.5 + +* Add a `SingleMapping.files` field which provides access to `SourceFile`s + representing the `"sourcesContent"` fields in the source map. + +* Add an `includeSourceContents` flag to `SingleMapping.toJson()` which + indicates whether to include source file contents in the source map. + ## 0.10.4 * Implement `highlight` in `SourceMapFileSpan`. * Require version `^1.3.0` of `source_span`. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 3b65e8910..e46b78341 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -5,7 +5,6 @@ /// Contains the top-level function to parse source maps version 3. library source_maps.parser; -import 'dart:collection'; import 'dart:convert'; import 'package:source_span/source_span.dart'; @@ -258,6 +257,16 @@ class SingleMapping extends Mapping { /// Source names used in the mapping, indexed by id. final List names; + /// The [SourceFile]s to which the entries in [lines] refer. + /// + /// This is in the same order as [urls]. If this was constructed using + /// [fromEntries], this contains files from any [FileLocation]s used to build + /// the mapping. If it was parsed from JSON, it contains files for any sources + /// whose contents were provided via the `"sourcesContent"` field. + /// + /// Files whose contents aren't available are `null`. + final List files; + /// Entries indicating the beginning of each span. final List lines; @@ -269,7 +278,7 @@ class SingleMapping extends Mapping { final Uri _mapUrl; - SingleMapping._(this.targetUrl, this.urls, this.names, this.lines) + SingleMapping._(this.targetUrl, this.files, this.urls, this.names, this.lines) : _mapUrl = null; factory SingleMapping.fromEntries(Iterable entries, @@ -279,12 +288,15 @@ class SingleMapping extends Mapping { var lines = []; // Indices associated with file urls that will be part of the source map. We - // use a linked hash-map so that `_urls.keys[_urls[u]] == u` - var urls = new LinkedHashMap(); + // rely on map order so that `urls.keys[urls[u]] == u` + var urls = {}; // Indices associated with identifiers that will be part of the source map. - // We use a linked hash-map so that `_names.keys[_names[n]] == n` - var names = new LinkedHashMap(); + // We rely on map order so that `names.keys[names[n]] == n` + var names = {}; + + /// The file for each URL, indexed by [urls]' values. + var files = {}; var lineNum; List targetEntries; @@ -301,6 +313,12 @@ class SingleMapping extends Mapping { var sourceUrl = sourceEntry.source.sourceUrl; var urlId = urls.putIfAbsent( sourceUrl == null ? '' : sourceUrl.toString(), () => urls.length); + + if (sourceEntry.source is FileLocation) { + files.putIfAbsent( + urlId, () => (sourceEntry.source as FileLocation).file); + } + var srcNameId = sourceEntry.identifierName == null ? null : names.putIfAbsent(sourceEntry.identifierName, () => names.length); @@ -309,16 +327,30 @@ class SingleMapping extends Mapping { } } return new SingleMapping._( - fileUrl, urls.keys.toList(), names.keys.toList(), lines); + fileUrl, + urls.values.map((i) => files[i]).toList(), + urls.keys.toList(), + names.keys.toList(), + lines); } SingleMapping.fromJson(Map map, {mapUrl}) : targetUrl = map['file'], urls = new List.from(map['sources']), names = new List.from(map['names']), + files = new List(map['sources'].length), sourceRoot = map['sourceRoot'], lines = [], _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl { + var sourcesContent = map['sourcesContent'] == null + ? const [] + : new List.from(map['sourcesContent']); + for (var i = 0; i < urls.length && i < sourcesContent.length; i++) { + var source = sourcesContent[i]; + if (source == null) continue; + files[i] = new SourceFile.fromString(source, url: urls[i]); + } + int line = 0; int column = 0; int srcUrlId = 0; @@ -385,7 +417,10 @@ class SingleMapping extends Mapping { } /// Encodes the Mapping mappings as a json map. - Map toJson() { + /// + /// If [sourcesContent] is `true`, this includes the source file contents from + /// [files] in the map if possible. + Map toJson({bool includeSourceContents: false}) { var buff = new StringBuffer(); var line = 0; var column = 0; @@ -431,9 +466,12 @@ class SingleMapping extends Mapping { 'names': names, 'mappings': buff.toString() }; - if (targetUrl != null) { - result['file'] = targetUrl; + if (targetUrl != null) result['file'] = targetUrl; + + if (includeSourceContents) { + result['sourcesContent'] = files.map((file) => file?.getText(0)).toList(); } + return result; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index ecf277ba8..7bf7bcd26 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.5-dev +version: 0.10.5 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 8c98c8178..78963418f 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -341,4 +341,55 @@ main() { var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE) as MappingBundle; expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); }); + + group("source files", () { + group("from fromEntries()", () { + test("are null for non-FileLocations", () { + var mapping = new SingleMapping.fromEntries([ + new Entry(new SourceLocation(10, line: 1, column: 8), + outputVar1.start, null) + ]); + expect(mapping.files, equals([null])); + }); + + test("use a file location's file", () { + var mapping = new SingleMapping.fromEntries( + [new Entry(inputVar1.start, outputVar1.start, null)]); + expect(mapping.files, equals([input])); + }); + }); + + group("from parse()", () { + group("are null", () { + test("with no sourcesContent field", () { + var mapping = parseJson(EXPECTED_MAP) as SingleMapping; + expect(mapping.files, equals([null])); + }); + + test("with null sourcesContent values", () { + var map = new Map.from(EXPECTED_MAP); + map["sourcesContent"] = [null]; + var mapping = parseJson(map) as SingleMapping; + expect(mapping.files, equals([null])); + }); + + test("with a too-short sourcesContent", () { + var map = new Map.from(EXPECTED_MAP); + map["sourcesContent"] = []; + var mapping = parseJson(map) as SingleMapping; + expect(mapping.files, equals([null])); + }); + }); + + test("are parsed from sourcesContent", () { + var map = new Map.from(EXPECTED_MAP); + map["sourcesContent"] = ["hello, world!"]; + var mapping = parseJson(map) as SingleMapping; + + var file = mapping.files[0]; + expect(file.url, equals(Uri.parse("input.dart"))); + expect(file.getText(0), equals("hello, world!")); + }); + }); + }); } From fbf2d23870bf1e2c417e0e41bcabce7a2c4bcf57 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Fri, 25 May 2018 14:03:44 +0200 Subject: [PATCH 064/133] Remove upper case constants (dart-lang/source_maps#27) * Remove usage of upper-case constants. * update SDK version * remove stable from Travis config --- pkgs/source_maps/.travis.yml | 2 -- pkgs/source_maps/CHANGELOG.md | 1 + pkgs/source_maps/lib/builder.dart | 2 +- pkgs/source_maps/lib/parser.dart | 4 ++-- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/builder_test.dart | 2 +- pkgs/source_maps/test/parser_test.dart | 10 +++++----- pkgs/source_maps/test/printer_test.dart | 6 +++--- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml index 25aeabec0..a49fc6ff0 100644 --- a/pkgs/source_maps/.travis.yml +++ b/pkgs/source_maps/.travis.yml @@ -2,8 +2,6 @@ language: dart dart: - dev - - stable - dart_task: - test: -p vm,chrome - dartanalyzer diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 8ef25be0e..9a0879cb5 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -9,6 +9,7 @@ ## 0.10.4 * Implement `highlight` in `SourceMapFileSpan`. * Require version `^1.3.0` of `source_span`. +* Require version 2.0.0 of the Dart SDK. ## 0.10.3 * Add `addMapping` and `containsMapping` members to `MappingBundle`. diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index cdba2d2dc..0769d5052 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -55,7 +55,7 @@ class SourceMapBuilder { } /// Encodes all mappings added to this builder as a json string. - String toJson(String fileUrl) => JSON.encode(build(fileUrl)); + String toJson(String fileUrl) => jsonEncode(build(fileUrl)); } /// An entry in the source map builder. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index e46b78341..a500b13ec 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -24,7 +24,7 @@ import 'src/vlq.dart'; // TODO(tjblasi): Ignore the first line of [jsonMap] if the JSON safety string // `)]}'` begins the string representation of the map. Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => - parseJson(JSON.decode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); + parseJson(jsonDecode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); /// Parses a source map or source map bundle directly from a json string. /// @@ -32,7 +32,7 @@ Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => /// the source map file itself. If it's passed, any URLs in the source /// map will be interpreted as relative to this URL when generating spans. Mapping parseExtended(String jsonMap, {Map otherMaps, mapUrl}) => - parseJsonExtended(JSON.decode(jsonMap), + parseJsonExtended(jsonDecode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); /// Parses a source map or source map bundle. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 7bf7bcd26..8598aefea 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -6,6 +6,6 @@ homepage: http://github.com/dart-lang/source_maps dependencies: source_span: ^1.3.0 environment: - sdk: '>=1.8.0 <2.0.0' + sdk: '>=2.0.0-dev.17.0 <2.0.0' dev_dependencies: test: '>=0.12.0 <0.13.0' diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index 7c27e4e17..1e2efdd5c 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -27,6 +27,6 @@ main() { ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') ..addLocation(inputExpr.start, outputExpr.start, null)) .toJson(output.url.toString()); - expect(str, JSON.encode(EXPECTED_MAP)); + expect(str, jsonEncode(EXPECTED_MAP)); }); } diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 78963418f..398a40eb3 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -80,7 +80,7 @@ main() { }); test('parse + json', () { - var mapping = parse(JSON.encode(EXPECTED_MAP)); + var mapping = parse(jsonEncode(EXPECTED_MAP)); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); check(outputFunction, mapping, inputFunction, false); @@ -96,7 +96,7 @@ main() { }); test('parse with no source location', () { - SingleMapping map = parse(JSON.encode(MAP_WITH_NO_SOURCE_LOCATION)); + SingleMapping map = parse(jsonEncode(MAP_WITH_NO_SOURCE_LOCATION)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); TargetEntry entry = map.lines.first.entries.first; @@ -109,7 +109,7 @@ main() { }); test('parse with source location and no name', () { - SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION)); + SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); TargetEntry entry = map.lines.first.entries.first; @@ -122,7 +122,7 @@ main() { }); test('parse with source location and name', () { - SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); + SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); TargetEntry entry = map.lines.first.entries.first; @@ -251,7 +251,7 @@ main() { }); test('parseExtended', () { - var mapping = parseExtended(JSON.encode(SOURCE_MAP_BUNDLE), + var mapping = parseExtended(jsonEncode(SOURCE_MAP_BUNDLE), mapUrl: "file:///path/to/map"); expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index 3fd768d8c..32db69565 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -24,7 +24,7 @@ main() { ..mark(inputExpr) ..add('x + y;\n'); expect(printer.text, OUTPUT); - expect(printer.map, JSON.encode(EXPECTED_MAP)); + expect(printer.map, jsonEncode(EXPECTED_MAP)); }); test('printer projecting marks', () { @@ -93,7 +93,7 @@ main() { ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); - expect(printer.map, JSON.encode(EXPECTED_MAP)); + expect(printer.map, jsonEncode(EXPECTED_MAP)); }); test('nested use', () { @@ -106,7 +106,7 @@ main() { ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); - expect(printer.map, JSON.encode(EXPECTED_MAP)); + expect(printer.map, jsonEncode(EXPECTED_MAP)); }); test('add indentation', () { From 6245184d74c916adebe2cc602579ef5bac76adcc Mon Sep 17 00:00:00 2001 From: sigmundch Date: Tue, 26 Jun 2018 16:30:07 -0700 Subject: [PATCH 065/133] Prepare to publish 0.10.6 (dart-lang/source_maps#29) --- pkgs/source_maps/CHANGELOG.md | 5 ++++- pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 9a0879cb5..d8ee77a61 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.6 + +* Require version 2.0.0 of the Dart SDK. + ## 0.10.5 * Add a `SingleMapping.files` field which provides access to `SourceFile`s @@ -9,7 +13,6 @@ ## 0.10.4 * Implement `highlight` in `SourceMapFileSpan`. * Require version `^1.3.0` of `source_span`. -* Require version 2.0.0 of the Dart SDK. ## 0.10.3 * Add `addMapping` and `containsMapping` members to `MappingBundle`. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 8598aefea..2c70f6b59 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.5 +version: 0.10.6 author: Dart Team description: Library to programmatically manipulate source map files. homepage: http://github.com/dart-lang/source_maps From e3efcb3400597b0bb9aa6dbea132680d5b4554e5 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Tue, 17 Jul 2018 13:11:37 -0400 Subject: [PATCH 066/133] chore: set max SDK version to <3.0.0 (dart-lang/source_maps#30) --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/analysis_options.yaml | 1 - pkgs/source_maps/pubspec.yaml | 14 +++++++++----- pkgs/source_maps/test/end2end_test.dart | 1 - 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index d8ee77a61..8411c74b5 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.7 + +* Set max SDK version to `<3.0.0`, and adjust other dependencies. + ## 0.10.6 * Require version 2.0.0 of the Dart SDK. diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index a10d4c5a0..2e6cdca29 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1,2 +1 @@ analyzer: - strong-mode: true diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 2c70f6b59..0f4980eac 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,11 +1,15 @@ name: source_maps -version: 0.10.6 -author: Dart Team +version: 0.10.7 + description: Library to programmatically manipulate source map files. +author: Dart Team homepage: http://github.com/dart-lang/source_maps + +environment: + sdk: '>=2.0.0-dev.17.0 <3.0.0' + dependencies: source_span: ^1.3.0 -environment: - sdk: '>=2.0.0-dev.17.0 <2.0.0' + dev_dependencies: - test: '>=0.12.0 <0.13.0' + test: ^1.2.0 diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index dd5bced00..1082c979b 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -111,7 +111,6 @@ main() { var printer = new Printer('output2.dart'); printer.mark(ispan(0, 0)); - bool first = true; var segments = INPUT.split('long'); expect(segments.length, 6); printer.add(segments[0], projectMarks: true); From 1c0a9842c8ad9c4632273053d056729d1cf8ed87 Mon Sep 17 00:00:00 2001 From: sigmundch Date: Thu, 27 Sep 2018 16:30:13 -0700 Subject: [PATCH 067/133] Preserve source-map extensions in SingleMapping (dart-lang/source_maps#31) * Preserve source-map extensions in SingleMapping * include test that extensions are preserved --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/lib/parser.dart | 13 +++++++++++-- pkgs/source_maps/pubspec.yaml | 2 +- pkgs/source_maps/test/parser_test.dart | 10 ++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 8411c74b5..af62d9460 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.8 + +* Preserve source-map extensions in `SingleMapping`. Extensions are keys in the + json map that start with `"x_"`. + ## 0.10.7 * Set max SDK version to `<3.0.0`, and adjust other dependencies. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index a500b13ec..7fe45654f 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -278,8 +278,11 @@ class SingleMapping extends Mapping { final Uri _mapUrl; + final Map extensions; + SingleMapping._(this.targetUrl, this.files, this.urls, this.names, this.lines) - : _mapUrl = null; + : _mapUrl = null, + extensions = {}; factory SingleMapping.fromEntries(Iterable entries, [String fileUrl]) { @@ -341,7 +344,8 @@ class SingleMapping extends Mapping { files = new List(map['sources'].length), sourceRoot = map['sourceRoot'], lines = [], - _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl { + _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl, + extensions = {} { var sourcesContent = map['sourcesContent'] == null ? const [] : new List.from(map['sourcesContent']); @@ -414,6 +418,10 @@ class SingleMapping extends Mapping { if (!entries.isEmpty) { lines.add(new TargetLineEntry(line, entries)); } + + map.forEach((name, value) { + if (name.startsWith("x_")) extensions[name] = value; + }); } /// Encodes the Mapping mappings as a json map. @@ -471,6 +479,7 @@ class SingleMapping extends Mapping { if (includeSourceContents) { result['sourcesContent'] = files.map((file) => file?.getText(0)).toList(); } + extensions.forEach((name, value) => result[name] = value); return result; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 0f4980eac..49ab53da1 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.7 +version: 0.10.8 description: Library to programmatically manipulate source map files. author: Dart Team diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 398a40eb3..390184292 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -342,6 +342,16 @@ main() { expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); }); + test('parse extensions', () { + var map = new Map.from(EXPECTED_MAP); + map["x_foo"] = "a"; + map["x_bar"] = [3]; + SingleMapping mapping = parseJson(map); + expect(mapping.toJson(), equals(map)); + expect(mapping.extensions["x_foo"], equals("a")); + expect(mapping.extensions["x_bar"].first, equals(3)); + }); + group("source files", () { group("from fromEntries()", () { test("are null for non-FileLocations", () { From 45587fef3f4e664d36fb849eb59a6d4be4df28ac Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 17 Jan 2019 18:07:45 -0500 Subject: [PATCH 068/133] Support dart-lang/source_spandart-lang/source_maps#25 (dart-lang/source_maps#33) Close dart-lang/source_maps#32 --- pkgs/source_maps/pubspec.yaml | 1 + pkgs/source_maps/test/refactor_test.dart | 101 ++++++++++++++++------- 2 files changed, 70 insertions(+), 32 deletions(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 49ab53da1..3e41803ba 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -13,3 +13,4 @@ dependencies: dev_dependencies: test: ^1.2.0 + term_glyph: ^1.0.0 diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index afaeec26e..857d30dce 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -8,8 +8,13 @@ import 'package:test/test.dart'; import 'package:source_maps/refactor.dart'; import 'package:source_maps/parser.dart' show parse, Mapping; import 'package:source_span/source_span.dart'; +import 'package:term_glyph/term_glyph.dart' as term_glyph; main() { + setUpAll(() { + term_glyph.ascii = true; + }); + group('conflict detection', () { var original = "0123456789abcdefghij"; var file = new SourceFile(original); @@ -64,48 +69,64 @@ main() { expect( _span(1, 1, map, file), "line 1, column 1: \n" - "0123456789\n" - "^"); + " ,\n" + "1 | 0123456789\n" + " | ^\n" + " '"); expect( _span(1, 5, map, file), "line 1, column 1: \n" - "0123456789\n" - "^"); + " ,\n" + "1 | 0123456789\n" + " | ^\n" + " '"); expect( _span(2, 1, map, file), "line 2, column 1: \n" - "0*23456789\n" - "^"); + " ,\n" + "2 | 0*23456789\n" + " | ^\n" + " '"); expect( _span(2, 8, map, file), "line 2, column 1: \n" - "0*23456789\n" - "^"); + " ,\n" + "2 | 0*23456789\n" + " | ^\n" + " '"); // Line 3 is modified part way: mappings before the edits have the right // mapping, after the edits the mapping is null. expect( _span(3, 1, map, file), "line 3, column 1: \n" - "01*3456789\n" - "^"); + " ,\n" + "3 | 01*3456789\n" + " | ^\n" + " '"); expect( _span(3, 5, map, file), "line 3, column 1: \n" - "01*3456789\n" - "^"); + " ,\n" + "3 | 01*3456789\n" + " | ^\n" + " '"); // Start of edits map to beginning of the edit secion: expect( _span(3, 6, map, file), "line 3, column 6: \n" - "01*3456789\n" - " ^"); + " ,\n" + "3 | 01*3456789\n" + " | ^\n" + " '"); expect( _span(3, 7, map, file), "line 3, column 6: \n" - "01*3456789\n" - " ^"); + " ,\n" + "3 | 01*3456789\n" + " | ^\n" + " '"); // Lines added have no mapping (they should inherit the last mapping), // but the end of the edit region continues were we left off: @@ -113,50 +134,66 @@ main() { expect( _span(4, 5, map, file), "line 3, column 8: \n" - "01*3456789\n" - " ^"); + " ,\n" + "3 | 01*3456789\n" + " | ^\n" + " '"); // Subsequent lines are still mapped correctly: // a (in a___cd...) expect( _span(5, 1, map, file), "line 4, column 1: \n" - "abcdefghij\n" - "^"); + " ,\n" + "4 | abcdefghij\n" + " | ^\n" + " '"); // _ (in a___cd...) expect( _span(5, 2, map, file), "line 4, column 2: \n" - "abcdefghij\n" - " ^"); + " ,\n" + "4 | abcdefghij\n" + " | ^\n" + " '"); // _ (in a___cd...) expect( _span(5, 3, map, file), "line 4, column 2: \n" - "abcdefghij\n" - " ^"); + " ,\n" + "4 | abcdefghij\n" + " | ^\n" + " '"); // _ (in a___cd...) expect( _span(5, 4, map, file), "line 4, column 2: \n" - "abcdefghij\n" - " ^"); + " ,\n" + "4 | abcdefghij\n" + " | ^\n" + " '"); // c (in a___cd...) expect( _span(5, 5, map, file), "line 4, column 3: \n" - "abcdefghij\n" - " ^"); + " ,\n" + "4 | abcdefghij\n" + " | ^\n" + " '"); expect( _span(6, 1, map, file), "line 5, column 1: \n" - "abcd*fghij\n" - "^"); + " ,\n" + "5 | abcd*fghij\n" + " | ^\n" + " '"); expect( _span(6, 8, map, file), "line 5, column 1: \n" - "abcd*fghij\n" - "^"); + " ,\n" + "5 | abcd*fghij\n" + " | ^\n" + " '"); }); } From fc558d27f3eb0f3b74e58063ae2719f426c4c19b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 15 Feb 2019 17:52:50 -0800 Subject: [PATCH 069/133] Support the latest source_span (dart-lang/source_maps#34) --- pkgs/source_maps/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 3e41803ba..0a35df6e0 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -12,5 +12,6 @@ dependencies: source_span: ^1.3.0 dev_dependencies: + source_span: ^1.5.4 test: ^1.2.0 term_glyph: ^1.0.0 From ce9aa9d6d43538e4f2bc66f0a68afe55faddcc1c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 12 Apr 2019 11:25:16 -0700 Subject: [PATCH 070/133] Delete analysis_options.yaml --- pkgs/source_maps/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkgs/source_maps/analysis_options.yaml diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml deleted file mode 100644 index 2e6cdca29..000000000 --- a/pkgs/source_maps/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -analyzer: From 86871c2bfbcef2b0257fa9d08a20521e90293da4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 12 Apr 2019 11:25:33 -0700 Subject: [PATCH 071/133] Delete codereview.settings --- pkgs/source_maps/codereview.settings | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 pkgs/source_maps/codereview.settings diff --git a/pkgs/source_maps/codereview.settings b/pkgs/source_maps/codereview.settings deleted file mode 100644 index 313ad0a67..000000000 --- a/pkgs/source_maps/codereview.settings +++ /dev/null @@ -1,3 +0,0 @@ -CODE_REVIEW_SERVER: http://codereview.chromium.org/ -VIEW_VC: https://github.com/dart-lang/source_maps/commit/ -CC_LIST: reviews@dartlang.org \ No newline at end of file From cb144c756d65e04783e365c912e0653319975ca4 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 9 Dec 2019 17:41:12 -0800 Subject: [PATCH 072/133] Run dartfmt --fix (dart-lang/source_maps#35) - Drop optional new. - Use `=` over `:` for named parameter default values. --- pkgs/source_maps/lib/builder.dart | 11 +- pkgs/source_maps/lib/parser.dart | 112 +++++++++--------- pkgs/source_maps/lib/printer.dart | 26 ++-- pkgs/source_maps/lib/refactor.dart | 8 +- pkgs/source_maps/lib/src/source_map_span.dart | 6 +- pkgs/source_maps/lib/src/vlq.dart | 8 +- pkgs/source_maps/pubspec.yaml | 4 +- pkgs/source_maps/test/builder_test.dart | 4 +- pkgs/source_maps/test/common.dart | 14 +-- pkgs/source_maps/test/end2end_test.dart | 16 +-- pkgs/source_maps/test/parser_test.dart | 87 +++++++------- pkgs/source_maps/test/printer_test.dart | 20 ++-- pkgs/source_maps/test/refactor_test.dart | 12 +- 13 files changed, 159 insertions(+), 169 deletions(-) diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 0769d5052..67b48501d 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -22,10 +22,9 @@ class SourceMapBuilder { void addFromOffset(SourceLocation source, SourceFile targetFile, int targetOffset, String identifier) { if (targetFile == null) { - throw new ArgumentError('targetFile cannot be null'); + throw ArgumentError('targetFile cannot be null'); } - _entries - .add(new Entry(source, targetFile.location(targetOffset), identifier)); + _entries.add(Entry(source, targetFile.location(targetOffset), identifier)); } /// Adds an entry mapping [target] to [source]. @@ -40,18 +39,18 @@ class SourceMapBuilder { } var name = isIdentifier ? source.text : null; - _entries.add(new Entry(source.start, target.start, name)); + _entries.add(Entry(source.start, target.start, name)); } /// Adds an entry mapping [target] to [source]. void addLocation( SourceLocation source, SourceLocation target, String identifier) { - _entries.add(new Entry(source, target, identifier)); + _entries.add(Entry(source, target, identifier)); } /// Encodes all mappings added to this builder as a json map. Map build(String fileUrl) { - return new SingleMapping.fromEntries(this._entries, fileUrl).toJson(); + return SingleMapping.fromEntries(this._entries, fileUrl).toJson(); } /// Encodes all mappings added to this builder as a json string. diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 7fe45654f..755674e83 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -43,7 +43,7 @@ Mapping parseExtended(String jsonMap, {Map otherMaps, mapUrl}) => Mapping parseJsonExtended(/*List|Map*/ json, {Map otherMaps, mapUrl}) { if (json is List) { - return new MappingBundle.fromJson(json, mapUrl: mapUrl); + return MappingBundle.fromJson(json, mapUrl: mapUrl); } return parseJson(json as Map); } @@ -55,7 +55,7 @@ Mapping parseJsonExtended(/*List|Map*/ json, /// map will be interpreted as relative to this URL when generating spans. Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { if (map['version'] != 3) { - throw new ArgumentError('unexpected source map version: ${map["version"]}. ' + throw ArgumentError('unexpected source map version: ${map["version"]}. ' 'Only version 3 is supported.'); } @@ -63,13 +63,13 @@ Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { if (map.containsKey('mappings') || map.containsKey('sources') || map.containsKey('names')) { - throw new FormatException('map containing "sections" ' + throw FormatException('map containing "sections" ' 'cannot contain "mappings", "sources", or "names".'); } - return new MultiSectionMapping.fromJson(map['sections'], otherMaps, + return MultiSectionMapping.fromJson(map['sections'], otherMaps, mapUrl: mapUrl); } - return new SingleMapping.fromJson(map, mapUrl: mapUrl); + return SingleMapping.fromJson(map, mapUrl: mapUrl); } /// A mapping parsed out of a source map. @@ -107,13 +107,13 @@ class MultiSectionMapping extends Mapping { {mapUrl}) { for (var section in sections) { var offset = section['offset']; - if (offset == null) throw new FormatException('section missing offset'); + if (offset == null) throw FormatException('section missing offset'); var line = section['offset']['line']; - if (line == null) throw new FormatException('offset missing line'); + if (line == null) throw FormatException('offset missing line'); var column = section['offset']['column']; - if (column == null) throw new FormatException('offset missing column'); + if (column == null) throw FormatException('offset missing column'); _lineStart.add(line); _columnStart.add(column); @@ -122,10 +122,10 @@ class MultiSectionMapping extends Mapping { var map = section['map']; if (url != null && map != null) { - throw new FormatException("section can't use both url and map entries"); + throw FormatException("section can't use both url and map entries"); } else if (url != null) { if (otherMaps == null || otherMaps[url] == null) { - throw new FormatException( + throw FormatException( 'section contains refers to $url, but no map was ' 'given for it. Make sure a map is passed in "otherMaps"'); } @@ -133,11 +133,11 @@ class MultiSectionMapping extends Mapping { } else if (map != null) { _maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl)); } else { - throw new FormatException('section missing url or map'); + throw FormatException('section missing url or map'); } } if (_lineStart.length == 0) { - throw new FormatException('expected at least one section'); + throw FormatException('expected at least one section'); } } @@ -160,7 +160,7 @@ class MultiSectionMapping extends Mapping { } String toString() { - var buff = new StringBuffer("$runtimeType : ["); + var buff = StringBuffer("$runtimeType : ["); for (int i = 0; i < _lineStart.length; i++) { buff ..write('(') @@ -197,7 +197,7 @@ class MappingBundle extends Mapping { List toJson() => _mappings.values.map((v) => v.toJson()).toList(); String toString() { - var buff = new StringBuffer(); + var buff = StringBuffer(); for (var map in _mappings.values) { buff.write(map.toString()); } @@ -209,7 +209,7 @@ class MappingBundle extends Mapping { SourceMapSpan spanFor(int line, int column, {Map files, String uri}) { if (uri == null) { - throw new ArgumentError.notNull('uri'); + throw ArgumentError.notNull('uri'); } // Find the longest suffix of the uri that matches the sourcemap @@ -243,9 +243,9 @@ class MappingBundle extends Mapping { // of the input line and column to minimize the chances that two different // line and column locations are mapped to the same offset. var offset = line * 1000000 + column; - var location = new SourceLocation(offset, + var location = SourceLocation(offset, line: line, column: column, sourceUrl: Uri.parse(uri)); - return new SourceMapSpan(location, location, ""); + return SourceMapSpan(location, location, ""); } } @@ -287,7 +287,7 @@ class SingleMapping extends Mapping { factory SingleMapping.fromEntries(Iterable entries, [String fileUrl]) { // The entries needs to be sorted by the target offsets. - var sourceEntries = new List.from(entries)..sort(); + var sourceEntries = List.from(entries)..sort(); var lines = []; // Indices associated with file urls that will be part of the source map. We @@ -307,11 +307,11 @@ class SingleMapping extends Mapping { if (lineNum == null || sourceEntry.target.line > lineNum) { lineNum = sourceEntry.target.line; targetEntries = []; - lines.add(new TargetLineEntry(lineNum, targetEntries)); + lines.add(TargetLineEntry(lineNum, targetEntries)); } if (sourceEntry.source == null) { - targetEntries.add(new TargetEntry(sourceEntry.target.column)); + targetEntries.add(TargetEntry(sourceEntry.target.column)); } else { var sourceUrl = sourceEntry.source.sourceUrl; var urlId = urls.putIfAbsent( @@ -325,34 +325,30 @@ class SingleMapping extends Mapping { var srcNameId = sourceEntry.identifierName == null ? null : names.putIfAbsent(sourceEntry.identifierName, () => names.length); - targetEntries.add(new TargetEntry(sourceEntry.target.column, urlId, + targetEntries.add(TargetEntry(sourceEntry.target.column, urlId, sourceEntry.source.line, sourceEntry.source.column, srcNameId)); } } - return new SingleMapping._( - fileUrl, - urls.values.map((i) => files[i]).toList(), - urls.keys.toList(), - names.keys.toList(), - lines); + return SingleMapping._(fileUrl, urls.values.map((i) => files[i]).toList(), + urls.keys.toList(), names.keys.toList(), lines); } SingleMapping.fromJson(Map map, {mapUrl}) : targetUrl = map['file'], - urls = new List.from(map['sources']), - names = new List.from(map['names']), - files = new List(map['sources'].length), + urls = List.from(map['sources']), + names = List.from(map['names']), + files = List(map['sources'].length), sourceRoot = map['sourceRoot'], lines = [], _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl, extensions = {} { var sourcesContent = map['sourcesContent'] == null ? const [] - : new List.from(map['sourcesContent']); + : List.from(map['sourcesContent']); for (var i = 0; i < urls.length && i < sourcesContent.length; i++) { var source = sourcesContent[i]; if (source == null) continue; - files[i] = new SourceFile.fromString(source, url: urls[i]); + files[i] = SourceFile.fromString(source, url: urls[i]); } int line = 0; @@ -361,13 +357,13 @@ class SingleMapping extends Mapping { int srcLine = 0; int srcColumn = 0; int srcNameId = 0; - var tokenizer = new _MappingTokenizer(map['mappings']); + var tokenizer = _MappingTokenizer(map['mappings']); var entries = []; while (tokenizer.hasTokens) { if (tokenizer.nextKind.isNewLine) { if (!entries.isEmpty) { - lines.add(new TargetLineEntry(line, entries)); + lines.add(TargetLineEntry(line, entries)); entries = []; } line++; @@ -390,11 +386,11 @@ class SingleMapping extends Mapping { if (tokenizer.nextKind.isNewSegment) throw _segmentError(0, line); column += tokenizer._consumeValue(); if (!tokenizer.nextKind.isValue) { - entries.add(new TargetEntry(column)); + entries.add(TargetEntry(column)); } else { srcUrlId += tokenizer._consumeValue(); if (srcUrlId >= urls.length) { - throw new StateError( + throw StateError( 'Invalid source url id. $targetUrl, $line, $srcUrlId'); } if (!tokenizer.nextKind.isValue) throw _segmentError(2, line); @@ -402,21 +398,20 @@ class SingleMapping extends Mapping { if (!tokenizer.nextKind.isValue) throw _segmentError(3, line); srcColumn += tokenizer._consumeValue(); if (!tokenizer.nextKind.isValue) { - entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn)); + entries.add(TargetEntry(column, srcUrlId, srcLine, srcColumn)); } else { srcNameId += tokenizer._consumeValue(); if (srcNameId >= names.length) { - throw new StateError( - 'Invalid name id: $targetUrl, $line, $srcNameId'); + throw StateError('Invalid name id: $targetUrl, $line, $srcNameId'); } entries.add( - new TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId)); + TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId)); } } if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment(); } if (!entries.isEmpty) { - lines.add(new TargetLineEntry(line, entries)); + lines.add(TargetLineEntry(line, entries)); } map.forEach((name, value) { @@ -428,8 +423,8 @@ class SingleMapping extends Mapping { /// /// If [sourcesContent] is `true`, this includes the source file contents from /// [files] in the map if possible. - Map toJson({bool includeSourceContents: false}) { - var buff = new StringBuffer(); + Map toJson({bool includeSourceContents = false}) { + var buff = StringBuffer(); var line = 0; var column = 0; var srcLine = 0; @@ -492,7 +487,7 @@ class SingleMapping extends Mapping { } _segmentError(int seen, int line) => - new StateError('Invalid entry in sourcemap, expected 1, 4, or 5' + StateError('Invalid entry in sourcemap, expected 1, 4, or 5' ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); /// Returns [TargetLineEntry] which includes the location in the target [line] @@ -529,29 +524,28 @@ class SingleMapping extends Mapping { var start = file.getOffset(entry.sourceLine, entry.sourceColumn); if (entry.sourceNameId != null) { var text = names[entry.sourceNameId]; - return new SourceMapFileSpan( - files[url].span(start, start + text.length), + return SourceMapFileSpan(files[url].span(start, start + text.length), isIdentifier: true); } else { - return new SourceMapFileSpan(files[url].location(start).pointSpan()); + return SourceMapFileSpan(files[url].location(start).pointSpan()); } } else { - var start = new SourceLocation(0, + var start = SourceLocation(0, sourceUrl: _mapUrl == null ? url : _mapUrl.resolve(url), line: entry.sourceLine, column: entry.sourceColumn); // Offset and other context is not available. if (entry.sourceNameId != null) { - return new SourceMapSpan.identifier(start, names[entry.sourceNameId]); + return SourceMapSpan.identifier(start, names[entry.sourceNameId]); } else { - return new SourceMapSpan(start, start, ''); + return SourceMapSpan(start, start, ''); } } } String toString() { - return (new StringBuffer("$runtimeType : [") + return (StringBuffer("$runtimeType : [") ..write('targetUrl: ') ..write(targetUrl) ..write(', sourceRoot: ') @@ -567,7 +561,7 @@ class SingleMapping extends Mapping { } String get debugString { - var buff = new StringBuffer(); + var buff = StringBuffer(); for (var lineEntry in lines) { var line = lineEntry.line; for (var entry in lineEntry.entries) { @@ -624,7 +618,7 @@ class TargetEntry { '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; } -/** A character iterator over a string that can peek one character ahead. */ +/// A character iterator over a string that can peek one character ahead. class _MappingTokenizer implements Iterator { final String _internal; final int _length; @@ -660,7 +654,7 @@ class _MappingTokenizer implements Iterator { // Print the state of the iterator, with colors indicating the current // position. String toString() { - var buff = new StringBuffer(); + var buff = StringBuffer(); for (int i = 0; i < index; i++) { buff.write(_internal[i]); } @@ -676,15 +670,15 @@ class _MappingTokenizer implements Iterator { } class _TokenKind { - static const _TokenKind LINE = const _TokenKind(isNewLine: true); - static const _TokenKind SEGMENT = const _TokenKind(isNewSegment: true); - static const _TokenKind EOF = const _TokenKind(isEof: true); - static const _TokenKind VALUE = const _TokenKind(); + static const _TokenKind LINE = _TokenKind(isNewLine: true); + static const _TokenKind SEGMENT = _TokenKind(isNewSegment: true); + static const _TokenKind EOF = _TokenKind(isEof: true); + static const _TokenKind VALUE = _TokenKind(); final bool isNewLine; final bool isNewSegment; final bool isEof; bool get isValue => !isNewLine && !isNewSegment && !isEof; const _TokenKind( - {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); + {this.isNewLine = false, this.isNewSegment = false, this.isEof = false}); } diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 6187dba81..beadbdd4e 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -17,8 +17,8 @@ const int _CR = 13; /// maps locations. class Printer { final String filename; - final StringBuffer _buff = new StringBuffer(); - final SourceMapBuilder _maps = new SourceMapBuilder(); + final StringBuffer _buff = StringBuffer(); + final SourceMapBuilder _maps = SourceMapBuilder(); String get text => _buff.toString(); String get map => _maps.toJson(filename); @@ -38,7 +38,7 @@ class Printer { /// adds a source map location on each new line, projecting that every new /// line in the target file (printed here) corresponds to a new line in the /// source file. - void add(String str, {projectMarks: false}) { + void add(String str, {projectMarks = false}) { var chars = str.runes.toList(); var length = chars.length; for (int i = 0; i < length; i++) { @@ -52,7 +52,7 @@ class Printer { var file = (_loc as FileLocation).file; mark(file.location(file.getOffset(_loc.line + 1))); } else { - mark(new SourceLocation(0, + mark(SourceLocation(0, sourceUrl: _loc.sourceUrl, line: _loc.line + 1, column: 0)); } } @@ -84,10 +84,8 @@ class Printer { loc = mark.start; if (mark is SourceMapSpan && mark.isIdentifier) identifier = mark.text; } - _maps.addLocation( - loc, - new SourceLocation(_buff.length, line: _line, column: _column), - identifier); + _maps.addLocation(loc, + SourceLocation(_buff.length, line: _line, column: _column), identifier); _loc = loc; } } @@ -113,7 +111,7 @@ class NestedPrinter implements NestedItem { /// Item used to indicate that the following item is copied from the original /// source code, and hence we should preserve source-maps on every new line. - static final _ORIGINAL = new Object(); + static final _ORIGINAL = Object(); NestedPrinter([this.indent = 0]); @@ -133,7 +131,7 @@ class NestedPrinter implements NestedItem { /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. void add(object, - {SourceLocation location, SourceSpan span, bool isOriginal: false}) { + {SourceLocation location, SourceSpan span, bool isOriginal = false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); assert(location == null || span == null); @@ -180,7 +178,7 @@ class NestedPrinter implements NestedItem { /// Appends a string merging it with any previous strings, if possible. void _appendString(String s) { - if (_buff == null) _buff = new StringBuffer(); + if (_buff == null) _buff = StringBuffer(); _buff.write(s); } @@ -200,7 +198,7 @@ class NestedPrinter implements NestedItem { /// printer, including source map location tokens. String toString() { _flush(); - return (new StringBuffer()..writeAll(_items)).toString(); + return (StringBuffer()..writeAll(_items)).toString(); } /// [Printer] used during the last call to [build], if any. @@ -216,7 +214,7 @@ class NestedPrinter implements NestedItem { /// calling this function, you can use [text] and [map] to retrieve the /// geenrated code and source map information, respectively. void build(String filename) { - writeTo(printer = new Printer(filename)); + writeTo(printer = Printer(filename)); } /// Implements the [NestedItem] interface. @@ -237,7 +235,7 @@ class NestedPrinter implements NestedItem { // every new-line. propagate = true; } else { - throw new UnsupportedError('Unknown item type: $item'); + throw UnsupportedError('Unknown item type: $item'); } } } diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index d6b129a29..34eabf816 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -30,7 +30,7 @@ class TextEditTransaction { /// with the [replacement]. [replacement] can be either a string or a /// [NestedPrinter]. void edit(int begin, int end, replacement) { - _edits.add(new _TextEdit(begin, end, replacement)); + _edits.add(_TextEdit(begin, end, replacement)); } /// Create a source map [SourceLocation] for [offset]. @@ -45,7 +45,7 @@ class TextEditTransaction { /// Throws [UnsupportedError] if the edits were overlapping. If no edits were /// made, the printer simply contains the original string. NestedPrinter commit() { - var printer = new NestedPrinter(); + var printer = NestedPrinter(); if (_edits.length == 0) { return printer..add(original, location: _loc(0), isOriginal: true); } @@ -56,7 +56,7 @@ class TextEditTransaction { int consumed = 0; for (var edit in _edits) { if (consumed > edit.begin) { - var sb = new StringBuffer(); + var sb = StringBuffer(); sb ..write(file.location(edit.begin).toolString) ..write(': overlapping edits. Insert at offset ') @@ -65,7 +65,7 @@ class TextEditTransaction { ..write(consumed) ..write(' input characters. List of edits:'); for (var e in _edits) sb..write('\n ')..write(e); - throw new UnsupportedError(sb.toString()); + throw UnsupportedError(sb.toString()); } // Add characters from the original string between this edit and the last diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index 37107e1c7..ba67027d5 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -17,7 +17,7 @@ class SourceMapSpan extends SourceSpanBase { final bool isIdentifier; SourceMapSpan(SourceLocation start, SourceLocation end, String text, - {this.isIdentifier: false}) + {this.isIdentifier = false}) : super(start, end, text); /// Creates a [SourceMapSpan] for an identifier with value [text] starting at @@ -27,7 +27,7 @@ class SourceMapSpan extends SourceSpanBase { SourceMapSpan.identifier(SourceLocation start, String text) : this( start, - new SourceLocation(start.offset + text.length, + SourceLocation(start.offset + text.length, sourceUrl: start.sourceUrl, line: start.line, column: start.column + text.length), @@ -48,7 +48,7 @@ class SourceMapFileSpan implements SourceMapSpan, FileSpan { Uri get sourceUrl => _inner.sourceUrl; int get length => _inner.length; - SourceMapFileSpan(this._inner, {this.isIdentifier: false}); + SourceMapFileSpan(this._inner, {this.isIdentifier = false}); int compareTo(SourceSpan other) => _inner.compareTo(other); String highlight({color}) => _inner.highlight(color: color); diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index 0c54dbf66..ebae139fd 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -40,7 +40,7 @@ final int MIN_INT32 = -pow(2, 31); /// Creates the VLQ encoding of [value] as a sequence of characters Iterable encodeVlq(int value) { if (value < MIN_INT32 || value > MAX_INT32) { - throw new ArgumentError('expected 32 bit int, got: $value'); + throw ArgumentError('expected 32 bit int, got: $value'); } var res = []; int signBit = 0; @@ -69,10 +69,10 @@ int decodeVlq(Iterator chars) { bool stop = false; int shift = 0; while (!stop) { - if (!chars.moveNext()) throw new StateError('incomplete VLQ value'); + if (!chars.moveNext()) throw StateError('incomplete VLQ value'); var char = chars.current; if (!_digits.containsKey(char)) { - throw new FormatException('invalid character in VLQ encoding: $char'); + throw FormatException('invalid character in VLQ encoding: $char'); } var digit = _digits[char]; stop = (digit & VLQ_CONTINUATION_BIT) == 0; @@ -95,7 +95,7 @@ int decodeVlq(Iterator chars) { // TODO(sigmund): can we detect this earlier? if (result < MIN_INT32 || result > MAX_INT32) { - throw new FormatException( + throw FormatException( 'expected an encoded 32 bit int, but we got: $result'); } return result; diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 0a35df6e0..cf7976605 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,12 +1,12 @@ name: source_maps -version: 0.10.8 +version: 0.10.9-dev description: Library to programmatically manipulate source map files. author: Dart Team homepage: http://github.com/dart-lang/source_maps environment: - sdk: '>=2.0.0-dev.17.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dependencies: source_span: ^1.3.0 diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index 1e2efdd5c..0b2a96512 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -11,7 +11,7 @@ import 'common.dart'; main() { test('builder - with span', () { - var map = (new SourceMapBuilder() + var map = (SourceMapBuilder() ..addSpan(inputVar1, outputVar1) ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) @@ -21,7 +21,7 @@ main() { }); test('builder - with location', () { - var str = (new SourceMapBuilder() + var str = (SourceMapBuilder() ..addLocation(inputVar1.start, outputVar1.start, 'longVar1') ..addLocation(inputFunction.start, outputFunction.start, 'longName') ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 01ffdada6..8217c0e22 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -19,11 +19,11 @@ int longName(int longVar2) { return longVar1 + longVar2; } '''; -var input = new SourceFile(INPUT, url: 'input.dart'); +var input = SourceFile(INPUT, url: 'input.dart'); /// A span in the input file SourceMapSpan ispan(int start, int end, [bool isIdentifier = false]) => - new SourceMapFileSpan(input.span(start, end), isIdentifier: isIdentifier); + SourceMapFileSpan(input.span(start, end), isIdentifier: isIdentifier); SourceMapSpan inputVar1 = ispan(30, 38, true); SourceMapSpan inputFunction = ispan(74, 82, true); @@ -40,11 +40,11 @@ const String OUTPUT = ''' var x = 3; f(y) => x + y; '''; -var output = new SourceFile(OUTPUT, url: 'output.dart'); +var output = SourceFile(OUTPUT, url: 'output.dart'); /// A span in the output file SourceMapSpan ospan(int start, int end, [bool isIdentifier = false]) => - new SourceMapFileSpan(output.span(start, end), isIdentifier: isIdentifier); + SourceMapFileSpan(output.span(start, end), isIdentifier: isIdentifier); SourceMapSpan outputVar1 = ospan(4, 5, true); SourceMapSpan outputFunction = ospan(11, 12, true); @@ -62,11 +62,11 @@ SourceMapSpan outputExpr = ospan(19, 24); /// /// This mapping is stored in the tests so we can independently test the builder /// and parser algorithms without relying entirely on end2end tests. -const Map EXPECTED_MAP = const { +const Map EXPECTED_MAP = { 'version': 3, 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const ['longVar1', 'longName', 'longVar2'], + 'sources': ['input.dart'], + 'names': ['longVar1', 'longName', 'longVar2'], 'mappings': 'IACIA;AAGAC,EAAaC,MACR', 'file': 'output.dart' }; diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 1082c979b..5d6016538 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -29,7 +29,7 @@ main() { }); test('build + parse', () { - var map = (new SourceMapBuilder() + var map = (SourceMapBuilder() ..addSpan(inputVar1, outputVar1) ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) @@ -43,7 +43,7 @@ main() { }); test('build + parse - no symbols', () { - var map = (new SourceMapBuilder() + var map = (SourceMapBuilder() ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) @@ -57,7 +57,7 @@ main() { }); test('build + parse, repeated entries', () { - var map = (new SourceMapBuilder() + var map = (SourceMapBuilder() ..addSpan(inputVar1, outputVar1) ..addSpan(inputVar1, outputVar1) ..addSpan(inputFunction, outputFunction) @@ -75,7 +75,7 @@ main() { }); test('build + parse - no symbols, repeated entries', () { - var map = (new SourceMapBuilder() + var map = (SourceMapBuilder() ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) @@ -92,7 +92,7 @@ main() { }); test('build + parse with file', () { - var json = (new SourceMapBuilder() + var json = (SourceMapBuilder() ..addSpan(inputVar1, outputVar1) ..addSpan(inputFunction, outputFunction) ..addSpan(inputVar2, outputVar2) @@ -107,8 +107,8 @@ main() { test('printer projecting marks + parse', () { var out = INPUT.replaceAll('long', '_s'); - var file = new SourceFile(out, url: 'output2.dart'); - var printer = new Printer('output2.dart'); + var file = SourceFile(out, url: 'output2.dart'); + var printer = Printer('output2.dart'); printer.mark(ispan(0, 0)); var segments = INPUT.split('long'); @@ -135,7 +135,7 @@ main() { checkHelper(SourceMapSpan inputSpan, int adjustment) { var start = inputSpan.start.offset - adjustment; var end = (inputSpan.end.offset - adjustment) - 2; - var span = new SourceMapFileSpan(file.span(start, end), + var span = SourceMapFileSpan(file.span(start, end), isIdentifier: inputSpan.isIdentifier); check(span, mapping, inputSpan, true); } diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 390184292..d6a8ac12d 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -10,61 +10,61 @@ import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'common.dart'; -const Map MAP_WITH_NO_SOURCE_LOCATION = const { +const Map MAP_WITH_NO_SOURCE_LOCATION = { 'version': 3, 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const [], + 'sources': ['input.dart'], + 'names': [], 'mappings': 'A', 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION = const { +const Map MAP_WITH_SOURCE_LOCATION = { 'version': 3, 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const [], + 'sources': ['input.dart'], + 'names': [], 'mappings': 'AAAA', 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = const { +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = { 'version': 3, 'sourceRoot': '', - 'sources': const ['input.dart'], - 'names': const ['var'], + 'sources': ['input.dart'], + 'names': ['var'], 'mappings': 'AAAAA', 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = const { +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = { 'version': 3, 'sourceRoot': 'pkg/', - 'sources': const ['input1.dart'], - 'names': const ['var1'], + 'sources': ['input1.dart'], + 'names': ['var1'], 'mappings': 'AAAAA', 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = const { +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = { 'version': 3, 'sourceRoot': 'pkg/', - 'sources': const ['input2.dart'], - 'names': const ['var2'], + 'sources': ['input2.dart'], + 'names': ['var2'], 'mappings': 'AAAAA', 'file': 'output2.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = const { +const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = { 'version': 3, 'sourceRoot': 'pkg/', - 'sources': const ['input3.dart'], - 'names': const ['var3'], + 'sources': ['input3.dart'], + 'names': ['var3'], 'mappings': 'AAAAA', 'file': '3/output.dart' }; -const List SOURCE_MAP_BUNDLE = const [ +const List SOURCE_MAP_BUNDLE = [ MAP_WITH_SOURCE_LOCATION_AND_NAME_1, MAP_WITH_SOURCE_LOCATION_AND_NAME_2, MAP_WITH_SOURCE_LOCATION_AND_NAME_3, @@ -135,14 +135,14 @@ main() { }); test('parse with source root', () { - var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); + var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap) as SingleMapping; expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart")); expect( mapping .spanForLocation( - new SourceLocation(0, sourceUrl: Uri.parse("ignored.dart"))) + SourceLocation(0, sourceUrl: Uri.parse("ignored.dart"))) .sourceUrl, Uri.parse("/pkg/input.dart")); @@ -155,7 +155,7 @@ main() { }); test('parse with map URL', () { - var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION); + var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = 'pkg/'; var mapping = parseJson(inputMap, mapUrl: "file:///path/to/map"); expect(mapping.spanFor(0, 0).sourceUrl, @@ -169,20 +169,20 @@ main() { test('simple', () { expect( mapping - .spanForLocation(new SourceLocation(0, - sourceUrl: new Uri.file('/path/to/output.dart'))) + .spanForLocation(SourceLocation(0, + sourceUrl: Uri.file('/path/to/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, - sourceUrl: new Uri.file('/path/to/output2.dart'))) + .spanForLocation(SourceLocation(0, + sourceUrl: Uri.file('/path/to/output2.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, - sourceUrl: new Uri.file('/path/to/3/output.dart'))) + .spanForLocation(SourceLocation(0, + sourceUrl: Uri.file('/path/to/3/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input3.dart")); @@ -200,19 +200,19 @@ main() { test('package uris', () { expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:1/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:2/output2.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:3/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input3.dart")); @@ -263,7 +263,7 @@ main() { }); test('build bundle incrementally', () { - var mapping = new MappingBundle(); + var mapping = MappingBundle(); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1, mapUrl: "file:///path/to/map")); @@ -291,19 +291,19 @@ main() { test('different paths', () { expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input1.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output2.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input2.dart")); expect( mapping - .spanForLocation(new SourceLocation(0, + .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/3/output.dart'))) .sourceUrl, Uri.parse("file:///path/to/pkg/input3.dart")); @@ -343,7 +343,7 @@ main() { }); test('parse extensions', () { - var map = new Map.from(EXPECTED_MAP); + var map = Map.from(EXPECTED_MAP); map["x_foo"] = "a"; map["x_bar"] = [3]; SingleMapping mapping = parseJson(map); @@ -355,16 +355,15 @@ main() { group("source files", () { group("from fromEntries()", () { test("are null for non-FileLocations", () { - var mapping = new SingleMapping.fromEntries([ - new Entry(new SourceLocation(10, line: 1, column: 8), - outputVar1.start, null) + var mapping = SingleMapping.fromEntries([ + Entry(SourceLocation(10, line: 1, column: 8), outputVar1.start, null) ]); expect(mapping.files, equals([null])); }); test("use a file location's file", () { - var mapping = new SingleMapping.fromEntries( - [new Entry(inputVar1.start, outputVar1.start, null)]); + var mapping = SingleMapping.fromEntries( + [Entry(inputVar1.start, outputVar1.start, null)]); expect(mapping.files, equals([input])); }); }); @@ -377,14 +376,14 @@ main() { }); test("with null sourcesContent values", () { - var map = new Map.from(EXPECTED_MAP); + var map = Map.from(EXPECTED_MAP); map["sourcesContent"] = [null]; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); }); test("with a too-short sourcesContent", () { - var map = new Map.from(EXPECTED_MAP); + var map = Map.from(EXPECTED_MAP); map["sourcesContent"] = []; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); @@ -392,7 +391,7 @@ main() { }); test("are parsed from sourcesContent", () { - var map = new Map.from(EXPECTED_MAP); + var map = Map.from(EXPECTED_MAP); map["sourcesContent"] = ["hello, world!"]; var mapping = parseJson(map) as SingleMapping; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index 32db69565..a2479073a 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -12,7 +12,7 @@ import 'common.dart'; main() { test('printer', () { - var printer = new Printer('output.dart'); + var printer = Printer('output.dart'); printer ..add('var ') ..mark(inputVar1) @@ -29,7 +29,7 @@ main() { test('printer projecting marks', () { var out = INPUT.replaceAll('long', '_s'); - var printer = new Printer('output2.dart'); + var printer = Printer('output2.dart'); var segments = INPUT.split('long'); expect(segments.length, 6); @@ -56,12 +56,12 @@ main() { expect(printer.map.split(';').length, 8); asFixed(SourceMapSpan s) => - new SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier); + SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier); // The result is the same if we use fixed positions - var printer2 = new Printer('output2.dart'); + var printer2 = Printer('output2.dart'); printer2 - ..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan()) + ..mark(SourceLocation(0, sourceUrl: 'input.dart').pointSpan()) ..add(segments[0], projectMarks: true) ..mark(asFixed(inputVar1)) ..add('_s') @@ -84,7 +84,7 @@ main() { group('nested printer', () { test('simple use', () { - var printer = new NestedPrinter(); + var printer = NestedPrinter(); printer ..add('var ') ..add('x = 3;\n', span: inputVar1) @@ -97,12 +97,12 @@ main() { }); test('nested use', () { - var printer = new NestedPrinter(); + var printer = NestedPrinter(); printer ..add('var ') - ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1)) + ..add(NestedPrinter()..add('x = 3;\n', span: inputVar1)) ..add('f(', span: inputFunction) - ..add(new NestedPrinter()..add('y) => ', span: inputVar2)) + ..add(NestedPrinter()..add('y) => ', span: inputVar2)) ..add('x + y;\n', span: inputExpr) ..build('output.dart'); expect(printer.text, OUTPUT); @@ -113,7 +113,7 @@ main() { var out = INPUT.replaceAll('long', '_s'); var lines = INPUT.trim().split('\n'); expect(lines.length, 7); - var printer = new NestedPrinter(); + var printer = NestedPrinter(); for (int i = 0; i < lines.length; i++) { if (i == 5) printer.indent++; printer.addLine(lines[i].replaceAll('long', '_s').trim()); diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 857d30dce..ba2ddc955 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -17,10 +17,10 @@ main() { group('conflict detection', () { var original = "0123456789abcdefghij"; - var file = new SourceFile(original); + var file = SourceFile(original); test('no conflict, in order', () { - var txn = new TextEditTransaction(original, file); + var txn = TextEditTransaction(original, file); txn.edit(2, 4, '.'); txn.edit(5, 5, '|'); txn.edit(6, 6, '-'); @@ -29,7 +29,7 @@ main() { }); test('no conflict, out of order', () { - var txn = new TextEditTransaction(original, file); + var txn = TextEditTransaction(original, file); txn.edit(2, 4, '.'); txn.edit(5, 5, '|'); @@ -41,7 +41,7 @@ main() { }); test('conflict', () { - var txn = new TextEditTransaction(original, file); + var txn = TextEditTransaction(original, file); txn.edit(2, 4, '.'); txn.edit(3, 3, '-'); expect( @@ -54,8 +54,8 @@ main() { test('generated source maps', () { var original = "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; - var file = new SourceFile(original); - var txn = new TextEditTransaction(original, file); + var file = SourceFile(original); + var txn = TextEditTransaction(original, file); txn.edit(27, 29, '__\n '); txn.edit(34, 35, '___'); var printer = (txn.commit()..build('')); From d92d0de2861d4dfc1bd016c5e489ecf8cf9b0f45 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 9 Dec 2019 17:59:46 -0800 Subject: [PATCH 073/133] Migrate for deprecations from other packages (dart-lang/source_maps#36) --- pkgs/source_maps/test/common.dart | 4 ++-- pkgs/source_maps/test/end2end_test.dart | 2 +- pkgs/source_maps/test/parser_test.dart | 4 ++-- pkgs/source_maps/test/refactor_test.dart | 4 ++-- pkgs/source_maps/test/vlq_test.dart | 16 ++++++++-------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 8217c0e22..ef119ec22 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -19,7 +19,7 @@ int longName(int longVar2) { return longVar1 + longVar2; } '''; -var input = SourceFile(INPUT, url: 'input.dart'); +var input = SourceFile.fromString(INPUT, url: 'input.dart'); /// A span in the input file SourceMapSpan ispan(int start, int end, [bool isIdentifier = false]) => @@ -40,7 +40,7 @@ const String OUTPUT = ''' var x = 3; f(y) => x + y; '''; -var output = SourceFile(OUTPUT, url: 'output.dart'); +var output = SourceFile.fromString(OUTPUT, url: 'output.dart'); /// A span in the output file SourceMapSpan ospan(int start, int end, [bool isIdentifier = false]) => diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 5d6016538..28c662556 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -107,7 +107,7 @@ main() { test('printer projecting marks + parse', () { var out = INPUT.replaceAll('long', '_s'); - var file = SourceFile(out, url: 'output2.dart'); + var file = SourceFile.fromString(out, url: 'output2.dart'); var printer = Printer('output2.dart'); printer.mark(ispan(0, 0)); diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index d6a8ac12d..6b2f5573f 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -238,7 +238,7 @@ main() { }); test('missing path', () { - expect(() => mapping.spanFor(0, 0), throws); + expect(() => mapping.spanFor(0, 0), throwsA(anything)); }); test('incomplete paths', () { @@ -336,7 +336,7 @@ main() { expect(mapping.toJson(), equals(expected)); } // Invalid for this case - expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws); + expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throwsA(anything)); var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE) as MappingBundle; expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index ba2ddc955..552081ae9 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -17,7 +17,7 @@ main() { group('conflict detection', () { var original = "0123456789abcdefghij"; - var file = SourceFile(original); + var file = SourceFile.fromString(original); test('no conflict, in order', () { var txn = TextEditTransaction(original, file); @@ -54,7 +54,7 @@ main() { test('generated source maps', () { var original = "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; - var file = SourceFile(original); + var file = SourceFile.fromString(original); var txn = TextEditTransaction(original, file); txn.edit(27, 29, '__\n '); txn.edit(34, 35, '___'); diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 30b6d4529..f97989f2b 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -37,17 +37,17 @@ main() { expect(encodeVlq(min_int).join(''), 'hgggggE'); expect(decodeVlq('hgggggE'.split('').iterator), min_int); - expect(() => encodeVlq(max_int + 1), throws); - expect(() => encodeVlq(max_int + 2), throws); - expect(() => encodeVlq(min_int - 1), throws); - expect(() => encodeVlq(min_int - 2), throws); + expect(() => encodeVlq(max_int + 1), throwsA(anything)); + expect(() => encodeVlq(max_int + 2), throwsA(anything)); + expect(() => encodeVlq(min_int - 1), throwsA(anything)); + expect(() => encodeVlq(min_int - 2), throwsA(anything)); // if we allowed more than 32 bits, these would be the expected encodings // for the large numbers above. - expect(() => decodeVlq('ggggggE'.split('').iterator), throws); - expect(() => decodeVlq('igggggE'.split('').iterator), throws); - expect(() => decodeVlq('jgggggE'.split('').iterator), throws); - expect(() => decodeVlq('lgggggE'.split('').iterator), throws); + expect(() => decodeVlq('ggggggE'.split('').iterator), throwsA(anything)); + expect(() => decodeVlq('igggggE'.split('').iterator), throwsA(anything)); + expect(() => decodeVlq('jgggggE'.split('').iterator), throwsA(anything)); + expect(() => decodeVlq('lgggggE'.split('').iterator), throwsA(anything)); }, // This test uses integers so large they overflow in JS. testOn: "dart-vm"); From 949aaedc7c5bac357548eb60ca4a3ad60ed094a6 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 11 Dec 2019 17:15:14 -0800 Subject: [PATCH 074/133] Enforce and fix package:pedantic lints (dart-lang/source_maps#37) Add an `analysis_options.yaml` which includes `package:pedantic` config. Fix existing lints: - always_declare_return_types - annotate_overrides - avoid_init_to_null - curly_braces_in_flow_control_structures - empty_constructor_bodies - omit_local_variable_types - prefer_conditional_assignment - prefer_final_fields - prefer_if_null_operators - prefer_is_empty - prefer_is_not_empty - prefer_single_quotes - unnecessary_this - use_function_type_syntax_for_parameters --- pkgs/source_maps/analysis_options.yaml | 1 + pkgs/source_maps/lib/builder.dart | 9 +- pkgs/source_maps/lib/parser.dart | 71 ++++--- pkgs/source_maps/lib/printer.dart | 22 ++- pkgs/source_maps/lib/refactor.dart | 22 ++- pkgs/source_maps/lib/source_maps.dart | 8 +- pkgs/source_maps/lib/src/source_map_span.dart | 16 +- pkgs/source_maps/lib/src/utils.dart | 8 +- pkgs/source_maps/lib/src/vlq.dart | 14 +- pkgs/source_maps/test/builder_test.dart | 2 +- pkgs/source_maps/test/common.dart | 2 +- pkgs/source_maps/test/end2end_test.dart | 4 +- pkgs/source_maps/test/parser_test.dart | 176 +++++++++--------- pkgs/source_maps/test/printer_test.dart | 6 +- pkgs/source_maps/test/refactor_test.dart | 140 +++++++------- pkgs/source_maps/test/utils_test.dart | 12 +- pkgs/source_maps/test/vlq_test.dart | 8 +- 17 files changed, 278 insertions(+), 243 deletions(-) create mode 100644 pkgs/source_maps/analysis_options.yaml diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml new file mode 100644 index 000000000..108d1058a --- /dev/null +++ b/pkgs/source_maps/analysis_options.yaml @@ -0,0 +1 @@ +include: package:pedantic/analysis_options.yaml diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 67b48501d..5574f0df0 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -34,9 +34,7 @@ class SourceMapBuilder { /// identifier whose value will be stored in the source map. [isIdenfier] /// takes precedence over [target]'s `isIdentifier` value. void addSpan(SourceSpan source, SourceSpan target, {bool isIdentifier}) { - if (isIdentifier == null) { - isIdentifier = source is SourceMapSpan ? source.isIdentifier : false; - } + isIdentifier ??= source is SourceMapSpan ? source.isIdentifier : false; var name = isIdentifier ? source.text : null; _entries.add(Entry(source.start, target.start, name)); @@ -50,7 +48,7 @@ class SourceMapBuilder { /// Encodes all mappings added to this builder as a json map. Map build(String fileUrl) { - return SingleMapping.fromEntries(this._entries, fileUrl).toJson(); + return SingleMapping.fromEntries(_entries, fileUrl).toJson(); } /// Encodes all mappings added to this builder as a json string. @@ -75,8 +73,9 @@ class Entry implements Comparable { /// location in the target file. We sort primarily by the target offset /// because source map files are encoded by printing each mapping in order as /// they appear in the target file. + @override int compareTo(Entry other) { - int res = target.compareTo(other.target); + var res = target.compareTo(other.target); if (res != 0) return res; res = source.sourceUrl .toString() diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 755674e83..c15ff2a11 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -136,32 +136,34 @@ class MultiSectionMapping extends Mapping { throw FormatException('section missing url or map'); } } - if (_lineStart.length == 0) { + if (_lineStart.isEmpty) { throw FormatException('expected at least one section'); } } int _indexFor(line, column) { - for (int i = 0; i < _lineStart.length; i++) { + for (var i = 0; i < _lineStart.length; i++) { if (line < _lineStart[i]) return i - 1; if (line == _lineStart[i] && column < _columnStart[i]) return i - 1; } return _lineStart.length - 1; } + @override SourceMapSpan spanFor(int line, int column, {Map files, String uri}) { // TODO(jacobr): perhaps verify that targetUrl matches the actual uri // or at least ends in the same file name. - int index = _indexFor(line, column); + var index = _indexFor(line, column); return _maps[index].spanFor( line - _lineStart[index], column - _columnStart[index], files: files); } + @override String toString() { - var buff = StringBuffer("$runtimeType : ["); - for (int i = 0; i < _lineStart.length; i++) { + var buff = StringBuffer('$runtimeType : ['); + for (var i = 0; i < _lineStart.length; i++) { buff ..write('(') ..write(_lineStart[i]) @@ -177,9 +179,9 @@ class MultiSectionMapping extends Mapping { } class MappingBundle extends Mapping { - Map _mappings = {}; + final Map _mappings = {}; - MappingBundle() {} + MappingBundle(); MappingBundle.fromJson(List json, {String mapUrl}) { for (var map in json) { @@ -187,7 +189,7 @@ class MappingBundle extends Mapping { } } - addMapping(SingleMapping mapping) { + void addMapping(SingleMapping mapping) { // TODO(jacobr): verify that targetUrl is valid uri instead of a windows // path. _mappings[mapping.targetUrl] = mapping; @@ -196,6 +198,7 @@ class MappingBundle extends Mapping { /// Encodes the Mapping mappings as a json map. List toJson() => _mappings.values.map((v) => v.toJson()).toList(); + @override String toString() { var buff = StringBuffer(); for (var map in _mappings.values) { @@ -206,6 +209,7 @@ class MappingBundle extends Mapping { bool containsMapping(String url) => _mappings.containsKey(url); + @override SourceMapSpan spanFor(int line, int column, {Map files, String uri}) { if (uri == null) { @@ -223,7 +227,7 @@ class MappingBundle extends Mapping { // urls as "package:package_name" would be one path segment when we want // "package" and "package_name" to be sepearate path segments. - bool onBoundary = true; + var onBoundary = true; var separatorCodeUnits = ['/'.codeUnitAt(0), ':'.codeUnitAt(0)]; for (var i = 0; i < uri.length; ++i) { if (onBoundary) { @@ -245,7 +249,7 @@ class MappingBundle extends Mapping { var offset = line * 1000000 + column; var location = SourceLocation(offset, line: line, column: column, sourceUrl: Uri.parse(uri)); - return SourceMapSpan(location, location, ""); + return SourceMapSpan(location, location, ''); } } @@ -351,18 +355,18 @@ class SingleMapping extends Mapping { files[i] = SourceFile.fromString(source, url: urls[i]); } - int line = 0; - int column = 0; - int srcUrlId = 0; - int srcLine = 0; - int srcColumn = 0; - int srcNameId = 0; + var line = 0; + var column = 0; + var srcUrlId = 0; + var srcLine = 0; + var srcColumn = 0; + var srcNameId = 0; var tokenizer = _MappingTokenizer(map['mappings']); var entries = []; while (tokenizer.hasTokens) { if (tokenizer.nextKind.isNewLine) { - if (!entries.isEmpty) { + if (entries.isNotEmpty) { lines.add(TargetLineEntry(line, entries)); entries = []; } @@ -410,12 +414,12 @@ class SingleMapping extends Mapping { } if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment(); } - if (!entries.isEmpty) { + if (entries.isNotEmpty) { lines.add(TargetLineEntry(line, entries)); } map.forEach((name, value) { - if (name.startsWith("x_")) extensions[name] = value; + if (name.startsWith('x_')) extensions[name] = value; }); } @@ -434,9 +438,9 @@ class SingleMapping extends Mapping { var first = true; for (var entry in lines) { - int nextLine = entry.line; + var nextLine = entry.line; if (nextLine > line) { - for (int i = line; i < nextLine; ++i) { + for (var i = line; i < nextLine; ++i) { buff.write(';'); } line = nextLine; @@ -464,7 +468,7 @@ class SingleMapping extends Mapping { var result = { 'version': 3, - 'sourceRoot': sourceRoot == null ? '' : sourceRoot, + 'sourceRoot': sourceRoot ?? '', 'sources': urls, 'names': names, 'mappings': buff.toString() @@ -486,7 +490,7 @@ class SingleMapping extends Mapping { return newValue; } - _segmentError(int seen, int line) => + StateError _segmentError(int seen, int line) => StateError('Invalid entry in sourcemap, expected 1, 4, or 5' ' values, but got $seen.\ntargeturl: $targetUrl, line: $line'); @@ -494,7 +498,7 @@ class SingleMapping extends Mapping { /// number. In particular, the resulting entry is the last entry whose line /// number is lower or equal to [line]. TargetLineEntry _findLine(int line) { - int index = binarySearch(lines, (e) => e.line > line); + var index = binarySearch(lines, (e) => e.line > line); return (index <= 0) ? null : lines[index - 1]; } @@ -504,13 +508,14 @@ class SingleMapping extends Mapping { /// [lineEntry] corresponds to a line prior to [line], then the result will be /// the very last entry on that line. TargetEntry _findColumn(int line, int column, TargetLineEntry lineEntry) { - if (lineEntry == null || lineEntry.entries.length == 0) return null; + if (lineEntry == null || lineEntry.entries.isEmpty) return null; if (lineEntry.line != line) return lineEntry.entries.last; var entries = lineEntry.entries; - int index = binarySearch(entries, (e) => e.column > column); + var index = binarySearch(entries, (e) => e.column > column); return (index <= 0) ? null : entries[index - 1]; } + @override SourceMapSpan spanFor(int line, int column, {Map files, String uri}) { var entry = _findColumn(line, column, _findLine(line)); @@ -544,8 +549,9 @@ class SingleMapping extends Mapping { } } + @override String toString() { - return (StringBuffer("$runtimeType : [") + return (StringBuffer('$runtimeType : [') ..write('targetUrl: ') ..write(targetUrl) ..write(', sourceRoot: ') @@ -597,6 +603,7 @@ class TargetLineEntry { List entries; TargetLineEntry(this.line, this.entries); + @override String toString() => '$runtimeType: $line $entries'; } @@ -614,6 +621,7 @@ class TargetEntry { this.sourceColumn, this.sourceNameId]); + @override String toString() => '$runtimeType: ' '($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)'; } @@ -628,7 +636,9 @@ class _MappingTokenizer implements Iterator { _length = internal.length; // Iterator API is used by decodeVlq to consume VLQ entries. + @override bool moveNext() => ++index < _length; + @override String get current => (index >= 0 && index < _length) ? _internal[index] : null; @@ -653,15 +663,16 @@ class _MappingTokenizer implements Iterator { // Print the state of the iterator, with colors indicating the current // position. + @override String toString() { var buff = StringBuffer(); - for (int i = 0; i < index; i++) { + for (var i = 0; i < index; i++) { buff.write(_internal[i]); } buff.write(''); - buff.write(current == null ? '' : current); + buff.write(current ?? ''); buff.write(''); - for (int i = index + 1; i < _internal.length; i++) { + for (var i = index + 1; i < _internal.length; i++) { buff.write(_internal[i]); } buff.write(' ($index)'); diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index beadbdd4e..24eec6429 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -41,7 +41,7 @@ class Printer { void add(String str, {projectMarks = false}) { var chars = str.runes.toList(); var length = chars.length; - for (int i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { var c = chars[i]; if (c == _LF || (c == _CR && (i + 1 == length || chars[i + 1] != _LF))) { // Return not followed by line-feed is treated as a new line. @@ -66,7 +66,9 @@ class Printer { /// Append a [total] number of spaces in the target file. Typically used for /// formatting indentation. void addSpaces(int total) { - for (int i = 0; i < total; i++) _buff.write(' '); + for (var i = 0; i < total; i++) { + _buff.write(' '); + } _column += total; } @@ -76,8 +78,8 @@ class Printer { /// this also records the name of the identifier in the source map /// information. void mark(mark) { - var loc; - var identifier = null; + SourceLocation loc; + String identifier; if (mark is SourceLocation) { loc = mark; } else if (mark is SourceSpan) { @@ -101,7 +103,7 @@ class NestedPrinter implements NestedItem { /// Items recoded by this printer, which can be [String] literals, /// [NestedItem]s, and source map information like [SourceLocation] and /// [SourceSpan]. - List _items = []; + final _items = []; /// Internal buffer to merge consecutive strings added to this printer. StringBuffer _buff; @@ -178,7 +180,7 @@ class NestedPrinter implements NestedItem { /// Appends a string merging it with any previous strings, if possible. void _appendString(String s) { - if (_buff == null) _buff = StringBuffer(); + _buff ??= StringBuffer(); _buff.write(s); } @@ -191,11 +193,14 @@ class NestedPrinter implements NestedItem { } void _indent(int indent) { - for (int i = 0; i < indent; i++) _appendString(' '); + for (var i = 0; i < indent; i++) { + _appendString(' '); + } } /// Returns a string representation of all the contents appended to this /// printer, including source map location tokens. + @override String toString() { _flush(); return (StringBuffer()..writeAll(_items)).toString(); @@ -218,9 +223,10 @@ class NestedPrinter implements NestedItem { } /// Implements the [NestedItem] interface. + @override void writeTo(Printer printer) { _flush(); - bool propagate = false; + var propagate = false; for (var item in _items) { if (item is NestedItem) { item.writeTo(printer); diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 34eabf816..32daf326c 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -24,7 +24,7 @@ class TextEditTransaction { /// Creates a new transaction. TextEditTransaction(this.original, this.file); - bool get hasEdits => _edits.length > 0; + bool get hasEdits => _edits.isNotEmpty; /// Edit the original text, replacing text on the range [begin] and [end] /// with the [replacement]. [replacement] can be either a string or a @@ -46,14 +46,14 @@ class TextEditTransaction { /// made, the printer simply contains the original string. NestedPrinter commit() { var printer = NestedPrinter(); - if (_edits.length == 0) { + if (_edits.isEmpty) { return printer..add(original, location: _loc(0), isOriginal: true); } // Sort edits by start location. _edits.sort(); - int consumed = 0; + var consumed = 0; for (var edit in _edits) { if (consumed > edit.begin) { var sb = StringBuffer(); @@ -64,7 +64,9 @@ class TextEditTransaction { ..write(' but have consumed ') ..write(consumed) ..write(' input characters. List of edits:'); - for (var e in _edits) sb..write('\n ')..write(e); + for (var e in _edits) { + sb..write('\n ')..write(e); + } throw UnsupportedError(sb.toString()); } @@ -95,10 +97,12 @@ class _TextEdit implements Comparable<_TextEdit> { int get length => end - begin; + @override String toString() => '(Edit @ $begin,$end: "$replace")'; + @override int compareTo(_TextEdit other) { - int diff = begin - other.begin; + var diff = begin - other.begin; if (diff != 0) return diff; return end - other.end; } @@ -107,8 +111,8 @@ class _TextEdit implements Comparable<_TextEdit> { /// Returns all whitespace characters at the start of [charOffset]'s line. String guessIndent(String code, int charOffset) { // Find the beginning of the line - int lineStart = 0; - for (int i = charOffset - 1; i >= 0; i--) { + var lineStart = 0; + for (var i = charOffset - 1; i >= 0; i--) { var c = code.codeUnitAt(i); if (c == _LF || c == _CR) { lineStart = i + 1; @@ -117,8 +121,8 @@ String guessIndent(String code, int charOffset) { } // Grab all the whitespace - int whitespaceEnd = code.length; - for (int i = lineStart; i < code.length; i++) { + var whitespaceEnd = code.length; + for (var i = lineStart; i < code.length; i++) { var c = code.codeUnitAt(i); if (c != _SPACE && c != _TAB) { whitespaceEnd = i; diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 953190341..e77ac5967 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -37,8 +37,8 @@ /// [pkg]: http://pub.dartlang.org/packages/source_maps library source_maps; -export "builder.dart"; -export "parser.dart"; -export "printer.dart"; -export "refactor.dart"; +export 'builder.dart'; +export 'parser.dart'; +export 'printer.dart'; +export 'refactor.dart'; export 'src/source_map_span.dart'; diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index ba67027d5..b8f1152f7 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -38,24 +38,38 @@ class SourceMapSpan extends SourceSpanBase { /// A wrapper aruond a [FileSpan] that implements [SourceMapSpan]. class SourceMapFileSpan implements SourceMapSpan, FileSpan { final FileSpan _inner; + @override final bool isIdentifier; + @override SourceFile get file => _inner.file; + @override FileLocation get start => _inner.start; + @override FileLocation get end => _inner.end; + @override String get text => _inner.text; + @override String get context => _inner.context; + @override Uri get sourceUrl => _inner.sourceUrl; + @override int get length => _inner.length; SourceMapFileSpan(this._inner, {this.isIdentifier = false}); + @override int compareTo(SourceSpan other) => _inner.compareTo(other); + @override String highlight({color}) => _inner.highlight(color: color); + @override SourceSpan union(SourceSpan other) => _inner.union(other); + @override FileSpan expand(FileSpan other) => _inner.expand(other); + @override String message(String message, {color}) => _inner.message(message, color: color); + @override String toString() => - _inner.toString().replaceAll("FileSpan", "SourceMapFileSpan"); + _inner.toString().replaceAll('FileSpan', 'SourceMapFileSpan'); } diff --git a/pkgs/source_maps/lib/src/utils.dart b/pkgs/source_maps/lib/src/utils.dart index 78f098e70..f9870d2f3 100644 --- a/pkgs/source_maps/lib/src/utils.dart +++ b/pkgs/source_maps/lib/src/utils.dart @@ -10,13 +10,13 @@ library source_maps.utils; /// and all items after `n` match too. The result is -1 when there are no /// items, 0 when all items match, and list.length when none does. // TODO(sigmund): remove this function after dartbug.com/5624 is fixed. -int binarySearch(List list, bool matches(item)) { - if (list.length == 0) return -1; +int binarySearch(List list, bool Function(dynamic) matches) { + if (list.isEmpty) return -1; if (matches(list.first)) return 0; if (!matches(list.last)) return list.length; - int min = 0; - int max = list.length - 1; + var min = 0; + var max = list.length - 1; while (min < max) { var half = min + ((max - min) ~/ 2); if (matches(list[half])) { diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index ebae139fd..de3ab27e9 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -28,7 +28,7 @@ const String BASE64_DIGITS = final Map _digits = () { var map = {}; - for (int i = 0; i < 64; i++) { + for (var i = 0; i < 64; i++) { map[BASE64_DIGITS[i]] = i; } return map; @@ -43,14 +43,14 @@ Iterable encodeVlq(int value) { throw ArgumentError('expected 32 bit int, got: $value'); } var res = []; - int signBit = 0; + var signBit = 0; if (value < 0) { signBit = 1; value = -value; } value = (value << 1) | signBit; do { - int digit = value & VLQ_BASE_MASK; + var digit = value & VLQ_BASE_MASK; value >>= VLQ_BASE_SHIFT; if (value > 0) { digit |= VLQ_CONTINUATION_BIT; @@ -65,9 +65,9 @@ Iterable encodeVlq(int value) { /// iterator is advanced until a stop character is found (a character without /// the [VLQ_CONTINUATION_BIT]). int decodeVlq(Iterator chars) { - int result = 0; - bool stop = false; - int shift = 0; + var result = 0; + var stop = false; + var shift = 0; while (!stop) { if (!chars.moveNext()) throw StateError('incomplete VLQ value'); var char = chars.current; @@ -89,7 +89,7 @@ int decodeVlq(Iterator chars) { // 5 (101 binary) becomes -2 // 6 (110 binary) becomes 3 // 7 (111 binary) becomes -3 - bool negate = (result & 1) == 1; + var negate = (result & 1) == 1; result = result >> 1; result = negate ? -result : result; diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index 0b2a96512..fddf46c88 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'common.dart'; -main() { +void main() { test('builder - with span', () { var map = (SourceMapBuilder() ..addSpan(inputVar1, outputVar1) diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index ef119ec22..c0bed6810 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -71,7 +71,7 @@ const Map EXPECTED_MAP = { 'file': 'output.dart' }; -check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan, +void check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan, bool realOffsets) { var line = outputSpan.start.line; var column = outputSpan.start.column; diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 28c662556..954339fbd 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -9,7 +9,7 @@ import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'common.dart'; -main() { +void main() { test('end-to-end setup', () { expect(inputVar1.text, 'longVar1'); expect(inputFunction.text, 'longName'); @@ -132,7 +132,7 @@ main() { expect(printer.text, out); var mapping = parse(printer.map); - checkHelper(SourceMapSpan inputSpan, int adjustment) { + void checkHelper(SourceMapSpan inputSpan, int adjustment) { var start = inputSpan.start.offset - adjustment; var end = (inputSpan.end.offset - adjustment) - 2; var span = SourceMapFileSpan(file.span(start, end), diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 6b2f5573f..275efd30a 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -70,7 +70,7 @@ const List SOURCE_MAP_BUNDLE = [ MAP_WITH_SOURCE_LOCATION_AND_NAME_3, ]; -main() { +void main() { test('parse', () { var mapping = parseJson(EXPECTED_MAP); check(outputVar1, mapping, inputVar1, false); @@ -99,7 +99,7 @@ main() { SingleMapping map = parse(jsonEncode(MAP_WITH_NO_SOURCE_LOCATION)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); - TargetEntry entry = map.lines.first.entries.first; + var entry = map.lines.first.entries.first; expect(entry.column, 0); expect(entry.sourceUrlId, null); @@ -112,7 +112,7 @@ main() { SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); - TargetEntry entry = map.lines.first.entries.first; + var entry = map.lines.first.entries.first; expect(entry.column, 0); expect(entry.sourceUrlId, 0); @@ -125,7 +125,7 @@ main() { SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); - TargetEntry entry = map.lines.first.entries.first; + var entry = map.lines.first.entries.first; expect(entry.sourceUrlId, 0); expect(entry.sourceUrlId, 0); @@ -138,18 +138,18 @@ main() { var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap) as SingleMapping; - expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart")); + expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse('/pkg/input.dart')); expect( mapping .spanForLocation( - SourceLocation(0, sourceUrl: Uri.parse("ignored.dart"))) + SourceLocation(0, sourceUrl: Uri.parse('ignored.dart'))) .sourceUrl, - Uri.parse("/pkg/input.dart")); + Uri.parse('/pkg/input.dart')); var newSourceRoot = '/new/'; mapping.sourceRoot = newSourceRoot; - inputMap["sourceRoot"] = newSourceRoot; + inputMap['sourceRoot'] = newSourceRoot; expect(mapping.toJson(), equals(inputMap)); }); @@ -157,14 +157,14 @@ main() { test('parse with map URL', () { var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = 'pkg/'; - var mapping = parseJson(inputMap, mapUrl: "file:///path/to/map"); + var mapping = parseJson(inputMap, mapUrl: 'file:///path/to/map'); expect(mapping.spanFor(0, 0).sourceUrl, - Uri.parse("file:///path/to/pkg/input.dart")); + Uri.parse('file:///path/to/pkg/input.dart')); }); group('parse with bundle', () { var mapping = - parseJsonExtended(SOURCE_MAP_BUNDLE, mapUrl: "file:///path/to/map"); + parseJsonExtended(SOURCE_MAP_BUNDLE, mapUrl: 'file:///path/to/map'); test('simple', () { expect( @@ -172,29 +172,29 @@ main() { .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/output2.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/3/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + Uri.parse('file:///path/to/pkg/input3.dart')); expect( - mapping.spanFor(0, 0, uri: "file:///path/to/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + mapping.spanFor(0, 0, uri: 'file:///path/to/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); expect( - mapping.spanFor(0, 0, uri: "file:///path/to/output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + mapping.spanFor(0, 0, uri: 'file:///path/to/output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); expect( - mapping.spanFor(0, 0, uri: "file:///path/to/3/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + mapping.spanFor(0, 0, uri: 'file:///path/to/3/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input3.dart')); }); test('package uris', () { @@ -203,36 +203,36 @@ main() { .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:1/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:2/output2.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:3/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); - - expect(mapping.spanFor(0, 0, uri: "package:1/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); - expect(mapping.spanFor(0, 0, uri: "package:2/output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); - expect(mapping.spanFor(0, 0, uri: "package:3/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + Uri.parse('file:///path/to/pkg/input3.dart')); + + expect(mapping.spanFor(0, 0, uri: 'package:1/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); + expect(mapping.spanFor(0, 0, uri: 'package:2/output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); + expect(mapping.spanFor(0, 0, uri: 'package:3/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input3.dart')); }); test('unmapped path', () { - var span = mapping.spanFor(0, 0, uri: "unmapped_output.dart"); - expect(span.sourceUrl, Uri.parse("unmapped_output.dart")); + var span = mapping.spanFor(0, 0, uri: 'unmapped_output.dart'); + expect(span.sourceUrl, Uri.parse('unmapped_output.dart')); expect(span.start.line, equals(0)); expect(span.start.column, equals(0)); - span = mapping.spanFor(10, 5, uri: "unmapped_output.dart"); - expect(span.sourceUrl, Uri.parse("unmapped_output.dart")); + span = mapping.spanFor(10, 5, uri: 'unmapped_output.dart'); + expect(span.sourceUrl, Uri.parse('unmapped_output.dart')); expect(span.start.line, equals(10)); expect(span.start.column, equals(5)); }); @@ -242,47 +242,47 @@ main() { }); test('incomplete paths', () { - expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); - expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); - expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); + expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); + expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input3.dart')); }); test('parseExtended', () { var mapping = parseExtended(jsonEncode(SOURCE_MAP_BUNDLE), - mapUrl: "file:///path/to/map"); - - expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); - expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); - expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + mapUrl: 'file:///path/to/map'); + + expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); + expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); + expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input3.dart')); }); test('build bundle incrementally', () { var mapping = MappingBundle(); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1, - mapUrl: "file:///path/to/map")); - expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + mapUrl: 'file:///path/to/map')); + expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); - expect(mapping.containsMapping("output2.dart"), isFalse); + expect(mapping.containsMapping('output2.dart'), isFalse); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_2, - mapUrl: "file:///path/to/map")); - expect(mapping.containsMapping("output2.dart"), isTrue); - expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + mapUrl: 'file:///path/to/map')); + expect(mapping.containsMapping('output2.dart'), isTrue); + expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); - expect(mapping.containsMapping("3/output.dart"), isFalse); + expect(mapping.containsMapping('3/output.dart'), isFalse); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_3, - mapUrl: "file:///path/to/map")); - expect(mapping.containsMapping("3/output.dart"), isTrue); - expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + mapUrl: 'file:///path/to/map')); + expect(mapping.containsMapping('3/output.dart'), isTrue); + expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input3.dart')); }); // Test that the source map can handle cases where the uri passed in is @@ -294,31 +294,31 @@ main() { .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output2.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/3/output.dart'))) .sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + Uri.parse('file:///path/to/pkg/input3.dart')); expect( - mapping.spanFor(0, 0, uri: "http://localhost/output.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input1.dart")); + mapping.spanFor(0, 0, uri: 'http://localhost/output.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input1.dart')); expect( - mapping.spanFor(0, 0, uri: "http://localhost/output2.dart").sourceUrl, - Uri.parse("file:///path/to/pkg/input2.dart")); + mapping.spanFor(0, 0, uri: 'http://localhost/output2.dart').sourceUrl, + Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping - .spanFor(0, 0, uri: "http://localhost/3/output.dart") + .spanFor(0, 0, uri: 'http://localhost/3/output.dart') .sourceUrl, - Uri.parse("file:///path/to/pkg/input3.dart")); + Uri.parse('file:///path/to/pkg/input3.dart')); }); }); @@ -344,17 +344,17 @@ main() { test('parse extensions', () { var map = Map.from(EXPECTED_MAP); - map["x_foo"] = "a"; - map["x_bar"] = [3]; + map['x_foo'] = 'a'; + map['x_bar'] = [3]; SingleMapping mapping = parseJson(map); expect(mapping.toJson(), equals(map)); - expect(mapping.extensions["x_foo"], equals("a")); - expect(mapping.extensions["x_bar"].first, equals(3)); + expect(mapping.extensions['x_foo'], equals('a')); + expect(mapping.extensions['x_bar'].first, equals(3)); }); - group("source files", () { - group("from fromEntries()", () { - test("are null for non-FileLocations", () { + group('source files', () { + group('from fromEntries()', () { + test('are null for non-FileLocations', () { var mapping = SingleMapping.fromEntries([ Entry(SourceLocation(10, line: 1, column: 8), outputVar1.start, null) ]); @@ -368,36 +368,36 @@ main() { }); }); - group("from parse()", () { - group("are null", () { - test("with no sourcesContent field", () { + group('from parse()', () { + group('are null', () { + test('with no sourcesContent field', () { var mapping = parseJson(EXPECTED_MAP) as SingleMapping; expect(mapping.files, equals([null])); }); - test("with null sourcesContent values", () { + test('with null sourcesContent values', () { var map = Map.from(EXPECTED_MAP); - map["sourcesContent"] = [null]; + map['sourcesContent'] = [null]; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); }); - test("with a too-short sourcesContent", () { + test('with a too-short sourcesContent', () { var map = Map.from(EXPECTED_MAP); - map["sourcesContent"] = []; + map['sourcesContent'] = []; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); }); }); - test("are parsed from sourcesContent", () { + test('are parsed from sourcesContent', () { var map = Map.from(EXPECTED_MAP); - map["sourcesContent"] = ["hello, world!"]; + map['sourcesContent'] = ['hello, world!']; var mapping = parseJson(map) as SingleMapping; var file = mapping.files[0]; - expect(file.url, equals(Uri.parse("input.dart"))); - expect(file.getText(0), equals("hello, world!")); + expect(file.url, equals(Uri.parse('input.dart'))); + expect(file.getText(0), equals('hello, world!')); }); }); }); diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index a2479073a..fc7991359 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -10,7 +10,7 @@ import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'common.dart'; -main() { +void main() { test('printer', () { var printer = Printer('output.dart'); printer @@ -55,7 +55,7 @@ main() { // 8 new lines in the source map: expect(printer.map.split(';').length, 8); - asFixed(SourceMapSpan s) => + SourceMapSpan asFixed(SourceMapSpan s) => SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier); // The result is the same if we use fixed positions @@ -114,7 +114,7 @@ main() { var lines = INPUT.trim().split('\n'); expect(lines.length, 7); var printer = NestedPrinter(); - for (int i = 0; i < lines.length; i++) { + for (var i = 0; i < lines.length; i++) { if (i == 5) printer.indent++; printer.addLine(lines[i].replaceAll('long', '_s').trim()); if (i == 5) printer.indent--; diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 552081ae9..36b934a8d 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -10,13 +10,13 @@ import 'package:source_maps/parser.dart' show parse, Mapping; import 'package:source_span/source_span.dart'; import 'package:term_glyph/term_glyph.dart' as term_glyph; -main() { +void main() { setUpAll(() { term_glyph.ascii = true; }); group('conflict detection', () { - var original = "0123456789abcdefghij"; + var original = '0123456789abcdefghij'; var file = SourceFile.fromString(original); test('no conflict, in order', () { @@ -25,7 +25,7 @@ main() { txn.edit(5, 5, '|'); txn.edit(6, 6, '-'); txn.edit(6, 7, '_'); - expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); + expect((txn.commit()..build('')).text, '01.4|5-_789abcdefghij'); }); test('no conflict, out of order', () { @@ -37,7 +37,7 @@ main() { // that don't remove any of the original code. txn.edit(6, 7, '_'); txn.edit(6, 6, '-'); - expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); + expect((txn.commit()..build('')).text, '01.4|5-_789abcdefghij'); }); test('conflict', () { @@ -53,7 +53,7 @@ main() { test('generated source maps', () { var original = - "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; + '0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n'; var file = SourceFile.fromString(original); var txn = TextEditTransaction(original, file); txn.edit(27, 29, '__\n '); @@ -62,70 +62,70 @@ main() { var output = printer.text; var map = parse(printer.map); expect(output, - "0123456789\n0*23456789\n01*34__\n 789\na___cdefghij\nabcd*fghij\n"); + '0123456789\n0*23456789\n01*34__\n 789\na___cdefghij\nabcd*fghij\n'); // Line 1 and 2 are unmodified: mapping any column returns the beginning // of the corresponding line: expect( _span(1, 1, map, file), - "line 1, column 1: \n" - " ,\n" - "1 | 0123456789\n" - " | ^\n" + 'line 1, column 1: \n' + ' ,\n' + '1 | 0123456789\n' + ' | ^\n' " '"); expect( _span(1, 5, map, file), - "line 1, column 1: \n" - " ,\n" - "1 | 0123456789\n" - " | ^\n" + 'line 1, column 1: \n' + ' ,\n' + '1 | 0123456789\n' + ' | ^\n' " '"); expect( _span(2, 1, map, file), - "line 2, column 1: \n" - " ,\n" - "2 | 0*23456789\n" - " | ^\n" + 'line 2, column 1: \n' + ' ,\n' + '2 | 0*23456789\n' + ' | ^\n' " '"); expect( _span(2, 8, map, file), - "line 2, column 1: \n" - " ,\n" - "2 | 0*23456789\n" - " | ^\n" + 'line 2, column 1: \n' + ' ,\n' + '2 | 0*23456789\n' + ' | ^\n' " '"); // Line 3 is modified part way: mappings before the edits have the right // mapping, after the edits the mapping is null. expect( _span(3, 1, map, file), - "line 3, column 1: \n" - " ,\n" - "3 | 01*3456789\n" - " | ^\n" + 'line 3, column 1: \n' + ' ,\n' + '3 | 01*3456789\n' + ' | ^\n' " '"); expect( _span(3, 5, map, file), - "line 3, column 1: \n" - " ,\n" - "3 | 01*3456789\n" - " | ^\n" + 'line 3, column 1: \n' + ' ,\n' + '3 | 01*3456789\n' + ' | ^\n' " '"); // Start of edits map to beginning of the edit secion: expect( _span(3, 6, map, file), - "line 3, column 6: \n" - " ,\n" - "3 | 01*3456789\n" - " | ^\n" + 'line 3, column 6: \n' + ' ,\n' + '3 | 01*3456789\n' + ' | ^\n' " '"); expect( _span(3, 7, map, file), - "line 3, column 6: \n" - " ,\n" - "3 | 01*3456789\n" - " | ^\n" + 'line 3, column 6: \n' + ' ,\n' + '3 | 01*3456789\n' + ' | ^\n' " '"); // Lines added have no mapping (they should inherit the last mapping), @@ -133,66 +133,66 @@ main() { expect(_span(4, 1, map, file), isNull); expect( _span(4, 5, map, file), - "line 3, column 8: \n" - " ,\n" - "3 | 01*3456789\n" - " | ^\n" + 'line 3, column 8: \n' + ' ,\n' + '3 | 01*3456789\n' + ' | ^\n' " '"); // Subsequent lines are still mapped correctly: // a (in a___cd...) expect( _span(5, 1, map, file), - "line 4, column 1: \n" - " ,\n" - "4 | abcdefghij\n" - " | ^\n" + 'line 4, column 1: \n' + ' ,\n' + '4 | abcdefghij\n' + ' | ^\n' " '"); // _ (in a___cd...) expect( _span(5, 2, map, file), - "line 4, column 2: \n" - " ,\n" - "4 | abcdefghij\n" - " | ^\n" + 'line 4, column 2: \n' + ' ,\n' + '4 | abcdefghij\n' + ' | ^\n' " '"); // _ (in a___cd...) expect( _span(5, 3, map, file), - "line 4, column 2: \n" - " ,\n" - "4 | abcdefghij\n" - " | ^\n" + 'line 4, column 2: \n' + ' ,\n' + '4 | abcdefghij\n' + ' | ^\n' " '"); // _ (in a___cd...) expect( _span(5, 4, map, file), - "line 4, column 2: \n" - " ,\n" - "4 | abcdefghij\n" - " | ^\n" + 'line 4, column 2: \n' + ' ,\n' + '4 | abcdefghij\n' + ' | ^\n' " '"); // c (in a___cd...) expect( _span(5, 5, map, file), - "line 4, column 3: \n" - " ,\n" - "4 | abcdefghij\n" - " | ^\n" + 'line 4, column 3: \n' + ' ,\n' + '4 | abcdefghij\n' + ' | ^\n' " '"); expect( _span(6, 1, map, file), - "line 5, column 1: \n" - " ,\n" - "5 | abcd*fghij\n" - " | ^\n" + 'line 5, column 1: \n' + ' ,\n' + '5 | abcd*fghij\n' + ' | ^\n' " '"); expect( _span(6, 8, map, file), - "line 5, column 1: \n" - " ,\n" - "5 | abcd*fghij\n" - " | ^\n" + 'line 5, column 1: \n' + ' ,\n' + '5 | abcd*fghij\n' + ' | ^\n' " '"); }); } diff --git a/pkgs/source_maps/test/utils_test.dart b/pkgs/source_maps/test/utils_test.dart index 6790082aa..3064d6b22 100644 --- a/pkgs/source_maps/test/utils_test.dart +++ b/pkgs/source_maps/test/utils_test.dart @@ -8,7 +8,7 @@ library test.utils_test; import 'package:test/test.dart'; import 'package:source_maps/src/utils.dart'; -main() { +void main() { group('binary search', () { test('empty', () { expect(binarySearch([], (x) => true), -1); @@ -30,12 +30,12 @@ main() { }); test('compare with linear search', () { - for (int size = 0; size < 100; size++) { + for (var size = 0; size < 100; size++) { var list = []; - for (int i = 0; i < size; i++) { + for (var i = 0; i < size; i++) { list.add(i); } - for (int pos = 0; pos <= size; pos++) { + for (var pos = 0; pos <= size; pos++) { expect(binarySearch(list, (x) => x >= pos), _linearSearch(list, (x) => x >= pos)); } @@ -44,9 +44,9 @@ main() { }); } -_linearSearch(list, predicate) { +int _linearSearch(list, predicate) { if (list.length == 0) return -1; - for (int i = 0; i < list.length; i++) { + for (var i = 0; i < list.length; i++) { if (predicate(list[i])) return i; } return list.length; diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index f97989f2b..6021519dd 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -8,7 +8,7 @@ import 'dart:math'; import 'package:test/test.dart'; import 'package:source_maps/src/vlq.dart'; -main() { +void main() { test('encode and decode - simple values', () { expect(encodeVlq(1).join(''), 'C'); expect(encodeVlq(2).join(''), 'E'); @@ -21,7 +21,7 @@ main() { }); test('encode and decode', () { - for (int i = -10000; i < 10000; i++) { + for (var i = -10000; i < 10000; i++) { _checkEncodeDecode(i); } }); @@ -50,10 +50,10 @@ main() { expect(() => decodeVlq('lgggggE'.split('').iterator), throwsA(anything)); }, // This test uses integers so large they overflow in JS. - testOn: "dart-vm"); + testOn: 'dart-vm'); } -_checkEncodeDecode(int value) { +void _checkEncodeDecode(int value) { var encoded = encodeVlq(value); expect(decodeVlq(encoded.iterator), value); expect(decodeVlq(encoded.join('').split('').iterator), value); From 303dd9fa615a762b7f5145c817d6508a3f66ae55 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 22 Jan 2020 10:58:08 -0800 Subject: [PATCH 075/133] Fix a number of doc comments Enable corresponding lint --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/analysis_options.yaml | 4 ++++ pkgs/source_maps/lib/builder.dart | 2 +- pkgs/source_maps/lib/parser.dart | 11 ++++++----- pkgs/source_maps/lib/printer.dart | 2 +- pkgs/source_maps/lib/refactor.dart | 6 +++--- pkgs/source_maps/lib/source_maps.dart | 22 +++++----------------- pkgs/source_maps/lib/src/vlq.dart | 3 +-- 8 files changed, 25 insertions(+), 29 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index af62d9460..73bbed05e 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.9-dev + +* Fix a number of document comment issues. + ## 0.10.8 * Preserve source-map extensions in `SingleMapping`. Extensions are keys in the diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index 108d1058a..4f9dfb038 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1 +1,5 @@ include: package:pedantic/analysis_options.yaml + +linter: + rules: + - comment_references diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 5574f0df0..e6b8d82ee 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -31,7 +31,7 @@ class SourceMapBuilder { /// /// If [isIdentifier] is true or if [target] is a [SourceMapSpan] with /// `isIdentifier` set to true, this entry is considered to represent an - /// identifier whose value will be stored in the source map. [isIdenfier] + /// identifier whose value will be stored in the source map. [isIdentifier] /// takes precedence over [target]'s `isIdentifier` value. void addSpan(SourceSpan source, SourceSpan target, {bool isIdentifier}) { isIdentifier ??= source is SourceMapSpan ? source.isIdentifier : false; diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index c15ff2a11..124ef6dc4 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -264,9 +264,10 @@ class SingleMapping extends Mapping { /// The [SourceFile]s to which the entries in [lines] refer. /// /// This is in the same order as [urls]. If this was constructed using - /// [fromEntries], this contains files from any [FileLocation]s used to build - /// the mapping. If it was parsed from JSON, it contains files for any sources - /// whose contents were provided via the `"sourcesContent"` field. + /// [SingleMapping.fromEntries], this contains files from any [FileLocation]s + /// used to build the mapping. If it was parsed from JSON, it contains files + /// for any sources whose contents were provided via the `"sourcesContent"` + /// field. /// /// Files whose contents aren't available are `null`. final List files; @@ -425,8 +426,8 @@ class SingleMapping extends Mapping { /// Encodes the Mapping mappings as a json map. /// - /// If [sourcesContent] is `true`, this includes the source file contents from - /// [files] in the map if possible. + /// If [includeSourceContents] is `true`, this includes the source file + /// contents from [files] in the map if possible. Map toJson({bool includeSourceContents = false}) { var buff = StringBuffer(); var line = 0; diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 24eec6429..d79d2cb03 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -160,7 +160,7 @@ class NestedPrinter implements NestedItem { /// separately and will not include any the indentation set here. /// /// The [location] and [span] parameters indicate the corresponding source map - /// location of [object] in the original input. Only one, [location] or + /// location of [line] in the original input. Only one, [location] or /// [span], should be provided at a time. void addLine(String line, {SourceLocation location, SourceSpan span}) { if (location != null || span != null) { diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 32daf326c..5e117e8ac 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -38,9 +38,9 @@ class TextEditTransaction { file != null ? file.location(offset) : null; /// Applies all pending [edit]s and returns a [NestedPrinter] containing the - /// rewritten string and source map information. [filename] is given to the - /// underlying printer to indicate the name of the generated file that will - /// contains the source map information. + /// rewritten string and source map information. [file]`.location` is given to + /// the underlying printer to indicate the name of the generated file that + /// will contains the source map information. /// /// Throws [UnsupportedError] if the edits were overlapping. If no edits were /// made, the printer simply contains the original string. diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index e77ac5967..0d171788b 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -18,25 +18,13 @@ /// object. For example: /// var mapping = parse(json); /// mapping.spanFor(outputSpan1.line, outputSpan1.column) -/// -/// ## Getting the code ## -/// -/// This library is distributed as a [pub][] package. To install this package, -/// add the following to your `pubspec.yaml` file: -/// -/// dependencies: -/// source_maps: any -/// -/// After you run `pub install`, you should be able to access this library by -/// importing `package:source_maps/source_maps.dart`. -/// -/// For more information, see the -/// [source_maps package on pub.dartlang.org][pkg]. -/// -/// [pub]: http://pub.dartlang.org -/// [pkg]: http://pub.dartlang.org/packages/source_maps library source_maps; +import 'package:source_span/source_span.dart'; + +import 'parser.dart'; +import 'builder.dart'; + export 'builder.dart'; export 'parser.dart'; export 'printer.dart'; diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index de3ab27e9..d4e29a1c3 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -9,8 +9,7 @@ /// encodes a 5-bit value (0-31) and a continuation bit. Signed values can be /// represented by using the least significant bit of the value as the sign bit. /// -/// For more details see the source map [version 3 documentation][spec]. -/// [spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit +/// For more details see the source map [version 3 documentation](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?usp=sharing). library source_maps.src.vlq; import 'dart:math'; From 27129d3a37067071492a3d0bb08f026645d38a30 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 22 Jan 2020 12:10:17 -0800 Subject: [PATCH 076/133] Drop author from pubspec (dart-lang/source_maps#39) --- pkgs/source_maps/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index cf7976605..3c42700b8 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -2,7 +2,6 @@ name: source_maps version: 0.10.9-dev description: Library to programmatically manipulate source map files. -author: Dart Team homepage: http://github.com/dart-lang/source_maps environment: From 173173868aa030ef6431cdc82ffe823ce77649f8 Mon Sep 17 00:00:00 2001 From: Tod Bachman Date: Mon, 10 Feb 2020 17:04:07 -0700 Subject: [PATCH 077/133] Handle null names field when parsing source map files (dart-lang/source_maps#40) The field is required by the spec, but we can be more lenient. --- pkgs/source_maps/lib/parser.dart | 2 +- pkgs/source_maps/test/parser_test.dart | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 124ef6dc4..e3044aa31 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -341,7 +341,7 @@ class SingleMapping extends Mapping { SingleMapping.fromJson(Map map, {mapUrl}) : targetUrl = map['file'], urls = List.from(map['sources']), - names = List.from(map['names']), + names = List.from(map['names'] ?? []), files = List(map['sources'].length), sourceRoot = map['sourceRoot'], lines = [], diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 275efd30a..45ac52db2 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -28,6 +28,14 @@ const Map MAP_WITH_SOURCE_LOCATION = { 'file': 'output.dart' }; +const Map MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES = { + 'version': 3, + 'sourceRoot': '', + 'sources': ['input.dart'], + 'mappings': 'AAAA', + 'file': 'output.dart' +}; + const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = { 'version': 3, 'sourceRoot': '', @@ -121,6 +129,20 @@ void main() { expect(entry.sourceNameId, null); }); + test('parse with source location and missing names entry', () { + SingleMapping map = + parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES)); + expect(map.lines.length, 1); + expect(map.lines.first.entries.length, 1); + var entry = map.lines.first.entries.first; + + expect(entry.column, 0); + expect(entry.sourceUrlId, 0); + expect(entry.sourceColumn, 0); + expect(entry.sourceLine, 0); + expect(entry.sourceNameId, null); + }); + test('parse with source location and name', () { SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); expect(map.lines.length, 1); From 87e2ef4a3bc7e2b158944c5c986445be7d97da20 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 11 Feb 2020 11:26:46 -0800 Subject: [PATCH 078/133] Fix homepage URL (dart-lang/source_maps#43) --- pkgs/source_maps/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 3c42700b8..f2db1eb32 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -2,7 +2,7 @@ name: source_maps version: 0.10.9-dev description: Library to programmatically manipulate source map files. -homepage: http://github.com/dart-lang/source_maps +homepage: https://github.com/dart-lang/source_maps environment: sdk: '>=2.0.0 <3.0.0' From e03b48d57938d47f28f22953c06b3b0902af5776 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 11 Feb 2020 11:26:55 -0800 Subject: [PATCH 079/133] Remove an unnecessary test expectation (dart-lang/source_maps#42) This expect is testing language implementation which is not necessary to do in this package. --- pkgs/source_maps/test/parser_test.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 45ac52db2..1b73f13cb 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -357,8 +357,6 @@ void main() { mapping = parseJsonExtended(expected); expect(mapping.toJson(), equals(expected)); } - // Invalid for this case - expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throwsA(anything)); var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE) as MappingBundle; expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); From 9bf652983ef2fd4888c5879bfa49c1479df791dd Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 11 Feb 2020 11:27:07 -0800 Subject: [PATCH 080/133] Prepare to publish (dart-lang/source_maps#41) Add a changelog entry for the `names` field change, drop `-dev`. --- pkgs/source_maps/CHANGELOG.md | 3 ++- pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 73bbed05e..321c37140 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,6 +1,7 @@ -## 0.10.9-dev +## 0.10.9 * Fix a number of document comment issues. +* Allow parsing source map files with a missing `names` field. ## 0.10.8 diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index f2db1eb32..871c40acc 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.9-dev +version: 0.10.9 description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps From 6dc79a7796b18a1e9467e103ed6b43e57a5dab29 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Sat, 30 May 2020 14:57:29 -0700 Subject: [PATCH 081/133] Correct markdown in library dartdoc This dartdoc has "code" examples that are not rendered as code. This change fixes that. --- pkgs/source_maps/lib/source_maps.dart | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 0d171788b..0c6cc084c 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -5,19 +5,25 @@ /// Library to create and parse source maps. /// /// Create a source map using [SourceMapBuilder]. For example: -/// var json = (new SourceMapBuilder() -/// ..add(inputSpan1, outputSpan1) -/// ..add(inputSpan2, outputSpan2) -/// ..add(inputSpan3, outputSpan3) -/// .toJson(outputFile); +/// +/// ```dart +/// var json = (new SourceMapBuilder() +/// ..add(inputSpan1, outputSpan1) +/// ..add(inputSpan2, outputSpan2) +/// ..add(inputSpan3, outputSpan3) +/// .toJson(outputFile); +/// ``` /// /// Use the source_span package's [SourceSpan] and [SourceFile] classes to /// specify span locations. /// /// Parse a source map using [parse], and call `spanFor` on the returned mapping /// object. For example: -/// var mapping = parse(json); -/// mapping.spanFor(outputSpan1.line, outputSpan1.column) +/// +/// ```dart +/// var mapping = parse(json); +/// mapping.spanFor(outputSpan1.line, outputSpan1.column) +/// ``` library source_maps; import 'package:source_span/source_span.dart'; From 8334a9f0621e86064cd0026e81c425d81ba15927 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 14 Jul 2020 15:47:34 -0700 Subject: [PATCH 082/133] Merge the null_safety branch into master (dart-lang/source_maps#49) --- pkgs/source_maps/.travis.yml | 35 ++-- pkgs/source_maps/CHANGELOG.md | 4 + pkgs/source_maps/analysis_options.yaml | 4 + pkgs/source_maps/lib/builder.dart | 10 +- pkgs/source_maps/lib/parser.dart | 182 ++++++++++-------- pkgs/source_maps/lib/printer.dart | 56 +++--- pkgs/source_maps/lib/refactor.dart | 10 +- pkgs/source_maps/lib/src/source_map_span.dart | 2 +- pkgs/source_maps/lib/src/vlq.dart | 8 +- pkgs/source_maps/pubspec.yaml | 85 +++++++- pkgs/source_maps/test/common.dart | 4 +- pkgs/source_maps/test/parser_test.dart | 93 ++++----- pkgs/source_maps/test/refactor_test.dart | 8 +- pkgs/source_maps/test/vlq_test.dart | 4 +- 14 files changed, 314 insertions(+), 191 deletions(-) diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml index a49fc6ff0..785c7c2e4 100644 --- a/pkgs/source_maps/.travis.yml +++ b/pkgs/source_maps/.travis.yml @@ -1,21 +1,34 @@ language: dart dart: - - dev -dart_task: - - test: -p vm,chrome - - dartanalyzer + - be/raw/latest -matrix: +jobs: include: - # Only validate formatting using the dev release - - dart: dev - dart_task: dartfmt + - stage: analyze_and_format + name: "Analyze" + dart: be/raw/latest + os: linux + script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . + - stage: analyze_and_format + name: "Format" + dart: be/raw/latest + os: linux + script: dartfmt -n --set-exit-if-changed . + - stage: test + name: "Vm Tests" + dart: be/raw/latest + os: linux + script: pub run --enable-experiment=non-nullable test -p vm + +stages: + - analyze_and_format + - test # Only building master means that we don't run two builds for each pull request. branches: - only: [master] + only: [master, null_safety] cache: - directories: - - $HOME/.pub-cache + directories: + - $HOME/.pub-cache diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 321c37140..bc7c9ef84 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.0-nullsafety + +* Migrate to null safety + ## 0.10.9 * Fix a number of document comment issues. diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index 4f9dfb038..86c836783 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1,5 +1,9 @@ include: package:pedantic/analysis_options.yaml +analyzer: + enable-experiment: + - non-nullable + linter: rules: - comment_references diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index e6b8d82ee..5c56ca462 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -21,9 +21,7 @@ class SourceMapBuilder { /// Adds an entry mapping the [targetOffset] to [source]. void addFromOffset(SourceLocation source, SourceFile targetFile, int targetOffset, String identifier) { - if (targetFile == null) { - throw ArgumentError('targetFile cannot be null'); - } + ArgumentError.checkNotNull(targetFile, 'targetFile'); _entries.add(Entry(source, targetFile.location(targetOffset), identifier)); } @@ -33,7 +31,7 @@ class SourceMapBuilder { /// `isIdentifier` set to true, this entry is considered to represent an /// identifier whose value will be stored in the source map. [isIdentifier] /// takes precedence over [target]'s `isIdentifier` value. - void addSpan(SourceSpan source, SourceSpan target, {bool isIdentifier}) { + void addSpan(SourceSpan source, SourceSpan target, {bool? isIdentifier}) { isIdentifier ??= source is SourceMapSpan ? source.isIdentifier : false; var name = isIdentifier ? source.text : null; @@ -42,7 +40,7 @@ class SourceMapBuilder { /// Adds an entry mapping [target] to [source]. void addLocation( - SourceLocation source, SourceLocation target, String identifier) { + SourceLocation source, SourceLocation target, String? identifier) { _entries.add(Entry(source, target, identifier)); } @@ -64,7 +62,7 @@ class Entry implements Comparable { final SourceLocation target; /// An identifier name, when this location is the start of an identifier. - final String identifierName; + final String? identifierName; /// Creates a new [Entry] mapping [target] to [source]. Entry(this.source, this.target, this.identifierName); diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index e3044aa31..1f8b8175f 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -23,7 +23,8 @@ import 'src/vlq.dart'; // the string represenation. // TODO(tjblasi): Ignore the first line of [jsonMap] if the JSON safety string // `)]}'` begins the string representation of the map. -Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => +Mapping parse(String jsonMap, + {Map? otherMaps, /*String|Uri*/ Object? mapUrl}) => parseJson(jsonDecode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); /// Parses a source map or source map bundle directly from a json string. @@ -31,7 +32,8 @@ Mapping parse(String jsonMap, {Map otherMaps, mapUrl}) => /// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of /// the source map file itself. If it's passed, any URLs in the source /// map will be interpreted as relative to this URL when generating spans. -Mapping parseExtended(String jsonMap, {Map otherMaps, mapUrl}) => +Mapping parseExtended(String jsonMap, + {Map? otherMaps, /*String|Uri*/ Object? mapUrl}) => parseJsonExtended(jsonDecode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); @@ -40,8 +42,8 @@ Mapping parseExtended(String jsonMap, {Map otherMaps, mapUrl}) => /// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of /// the source map file itself. If it's passed, any URLs in the source /// map will be interpreted as relative to this URL when generating spans. -Mapping parseJsonExtended(/*List|Map*/ json, - {Map otherMaps, mapUrl}) { +Mapping parseJsonExtended(/*List|Map*/ Object? json, + {Map? otherMaps, /*String|Uri*/ Object? mapUrl}) { if (json is List) { return MappingBundle.fromJson(json, mapUrl: mapUrl); } @@ -53,7 +55,8 @@ Mapping parseJsonExtended(/*List|Map*/ json, /// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of /// the source map file itself. If it's passed, any URLs in the source /// map will be interpreted as relative to this URL when generating spans. -Mapping parseJson(Map map, {Map otherMaps, mapUrl}) { +Mapping parseJson(Map map, + {Map? otherMaps, /*String|Uri*/ Object? mapUrl}) { if (map['version'] != 3) { throw ArgumentError('unexpected source map version: ${map["version"]}. ' 'Only version 3 is supported.'); @@ -79,12 +82,12 @@ abstract class Mapping { /// [uri] is the optional location of the output file to find the span for /// to disambiguate cases where a mapping may have different mappings for /// different output files. - SourceMapSpan spanFor(int line, int column, - {Map files, String uri}); + SourceMapSpan? spanFor(int line, int column, + {Map? files, String? uri}); /// Returns the span associated with [location]. - SourceMapSpan spanForLocation(SourceLocation location, - {Map files}) { + SourceMapSpan? spanForLocation(SourceLocation location, + {Map? files}) { return spanFor(location.line, location.column, uri: location.sourceUrl?.toString(), files: files); } @@ -103,8 +106,8 @@ class MultiSectionMapping extends Mapping { final List _maps = []; /// Creates a section mapping from json. - MultiSectionMapping.fromJson(List sections, Map otherMaps, - {mapUrl}) { + MultiSectionMapping.fromJson(List sections, Map? otherMaps, + {/*String|Uri*/ Object? mapUrl}) { for (var section in sections) { var offset = section['offset']; if (offset == null) throw FormatException('section missing offset'); @@ -124,12 +127,13 @@ class MultiSectionMapping extends Mapping { if (url != null && map != null) { throw FormatException("section can't use both url and map entries"); } else if (url != null) { - if (otherMaps == null || otherMaps[url] == null) { + var other = otherMaps?[url]; + if (otherMaps == null || other == null) { throw FormatException( 'section contains refers to $url, but no map was ' 'given for it. Make sure a map is passed in "otherMaps"'); } - _maps.add(parseJson(otherMaps[url], otherMaps: otherMaps, mapUrl: url)); + _maps.add(parseJson(other, otherMaps: otherMaps, mapUrl: url)); } else if (map != null) { _maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl)); } else { @@ -141,7 +145,7 @@ class MultiSectionMapping extends Mapping { } } - int _indexFor(line, column) { + int _indexFor(int line, int column) { for (var i = 0; i < _lineStart.length; i++) { if (line < _lineStart[i]) return i - 1; if (line == _lineStart[i] && column < _columnStart[i]) return i - 1; @@ -150,8 +154,8 @@ class MultiSectionMapping extends Mapping { } @override - SourceMapSpan spanFor(int line, int column, - {Map files, String uri}) { + SourceMapSpan? spanFor(int line, int column, + {Map? files, String? uri}) { // TODO(jacobr): perhaps verify that targetUrl matches the actual uri // or at least ends in the same file name. var index = _indexFor(line, column); @@ -183,7 +187,7 @@ class MappingBundle extends Mapping { MappingBundle(); - MappingBundle.fromJson(List json, {String mapUrl}) { + MappingBundle.fromJson(List json, {/*String|Uri*/ Object? mapUrl}) { for (var map in json) { addMapping(parseJson(map, mapUrl: mapUrl) as SingleMapping); } @@ -192,7 +196,10 @@ class MappingBundle extends Mapping { void addMapping(SingleMapping mapping) { // TODO(jacobr): verify that targetUrl is valid uri instead of a windows // path. - _mappings[mapping.targetUrl] = mapping; + // TODO: Remove type arg https://github.com/dart-lang/sdk/issues/42227 + var targetUrl = ArgumentError.checkNotNull( + mapping.targetUrl, 'mapping.targetUrl'); + _mappings[targetUrl] = mapping; } /// Encodes the Mapping mappings as a json map. @@ -210,11 +217,10 @@ class MappingBundle extends Mapping { bool containsMapping(String url) => _mappings.containsKey(url); @override - SourceMapSpan spanFor(int line, int column, - {Map files, String uri}) { - if (uri == null) { - throw ArgumentError.notNull('uri'); - } + SourceMapSpan? spanFor(int line, int column, + {Map? files, String? uri}) { + // TODO: Remove type arg https://github.com/dart-lang/sdk/issues/42227 + uri = ArgumentError.checkNotNull(uri, 'uri'); // Find the longest suffix of the uri that matches the sourcemap // where the suffix starts after a path segment boundary. @@ -232,9 +238,10 @@ class MappingBundle extends Mapping { for (var i = 0; i < uri.length; ++i) { if (onBoundary) { var candidate = uri.substring(i); - if (_mappings.containsKey(candidate)) { - return _mappings[candidate] - .spanFor(line, column, files: files, uri: candidate); + var candidateMapping = _mappings[candidate]; + if (candidateMapping != null) { + return candidateMapping.spanFor(line, column, + files: files, uri: candidate); } } onBoundary = separatorCodeUnits.contains(uri.codeUnitAt(i)); @@ -270,18 +277,18 @@ class SingleMapping extends Mapping { /// field. /// /// Files whose contents aren't available are `null`. - final List files; + final List files; /// Entries indicating the beginning of each span. final List lines; /// Url of the target file. - String targetUrl; + String? targetUrl; /// Source root prepended to all entries in [urls]. - String sourceRoot; + String? sourceRoot; - final Uri _mapUrl; + final Uri? _mapUrl; final Map extensions; @@ -290,9 +297,9 @@ class SingleMapping extends Mapping { extensions = {}; factory SingleMapping.fromEntries(Iterable entries, - [String fileUrl]) { + [String? fileUrl]) { // The entries needs to be sorted by the target offsets. - var sourceEntries = List.from(entries)..sort(); + var sourceEntries = entries.toList()..sort(); var lines = []; // Indices associated with file urls that will be part of the source map. We @@ -307,7 +314,7 @@ class SingleMapping extends Mapping { var files = {}; var lineNum; - List targetEntries; + late List targetEntries; for (var sourceEntry in sourceEntries) { if (lineNum == null || sourceEntry.target.line > lineNum) { lineNum = sourceEntry.target.line; @@ -315,24 +322,21 @@ class SingleMapping extends Mapping { lines.add(TargetLineEntry(lineNum, targetEntries)); } - if (sourceEntry.source == null) { - targetEntries.add(TargetEntry(sourceEntry.target.column)); - } else { - var sourceUrl = sourceEntry.source.sourceUrl; - var urlId = urls.putIfAbsent( - sourceUrl == null ? '' : sourceUrl.toString(), () => urls.length); + var sourceUrl = sourceEntry.source.sourceUrl; + var urlId = urls.putIfAbsent( + sourceUrl == null ? '' : sourceUrl.toString(), () => urls.length); - if (sourceEntry.source is FileLocation) { - files.putIfAbsent( - urlId, () => (sourceEntry.source as FileLocation).file); - } - - var srcNameId = sourceEntry.identifierName == null - ? null - : names.putIfAbsent(sourceEntry.identifierName, () => names.length); - targetEntries.add(TargetEntry(sourceEntry.target.column, urlId, - sourceEntry.source.line, sourceEntry.source.column, srcNameId)); + if (sourceEntry.source is FileLocation) { + files.putIfAbsent( + urlId, () => (sourceEntry.source as FileLocation).file); } + + var sourceEntryIdentifierName = sourceEntry.identifierName; + var srcNameId = sourceEntryIdentifierName == null + ? null + : names.putIfAbsent(sourceEntryIdentifierName, () => names.length); + targetEntries.add(TargetEntry(sourceEntry.target.column, urlId, + sourceEntry.source.line, sourceEntry.source.column, srcNameId)); } return SingleMapping._(fileUrl, urls.values.map((i) => files[i]).toList(), urls.keys.toList(), names.keys.toList(), lines); @@ -342,14 +346,14 @@ class SingleMapping extends Mapping { : targetUrl = map['file'], urls = List.from(map['sources']), names = List.from(map['names'] ?? []), - files = List(map['sources'].length), + files = List.filled(map['sources'].length, null), sourceRoot = map['sourceRoot'], lines = [], _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl, extensions = {} { var sourcesContent = map['sourcesContent'] == null - ? const [] - : List.from(map['sourcesContent']); + ? const [] + : List.from(map['sourcesContent']); for (var i = 0; i < urls.length && i < sourcesContent.length; i++) { var source = sourcesContent[i]; if (source == null) continue; @@ -459,11 +463,11 @@ class SingleMapping extends Mapping { var newUrlId = segment.sourceUrlId; if (newUrlId == null) continue; srcUrlId = _append(buff, srcUrlId, newUrlId); - srcLine = _append(buff, srcLine, segment.sourceLine); - srcColumn = _append(buff, srcColumn, segment.sourceColumn); + srcLine = _append(buff, srcLine, segment.sourceLine!); + srcColumn = _append(buff, srcColumn, segment.sourceColumn!); if (segment.sourceNameId == null) continue; - srcNameId = _append(buff, srcNameId, segment.sourceNameId); + srcNameId = _append(buff, srcNameId, segment.sourceNameId!); } } @@ -474,7 +478,7 @@ class SingleMapping extends Mapping { 'names': names, 'mappings': buff.toString() }; - if (targetUrl != null) result['file'] = targetUrl; + if (targetUrl != null) result['file'] = targetUrl!; if (includeSourceContents) { result['sourcesContent'] = files.map((file) => file?.getText(0)).toList(); @@ -498,7 +502,7 @@ class SingleMapping extends Mapping { /// Returns [TargetLineEntry] which includes the location in the target [line] /// number. In particular, the resulting entry is the last entry whose line /// number is lower or equal to [line]. - TargetLineEntry _findLine(int line) { + TargetLineEntry? _findLine(int line) { var index = binarySearch(lines, (e) => e.line > line); return (index <= 0) ? null : lines[index - 1]; } @@ -508,7 +512,7 @@ class SingleMapping extends Mapping { /// the last entry whose column is lower or equal than [column]. If /// [lineEntry] corresponds to a line prior to [line], then the result will be /// the very last entry on that line. - TargetEntry _findColumn(int line, int column, TargetLineEntry lineEntry) { + TargetEntry? _findColumn(int line, int column, TargetLineEntry? lineEntry) { if (lineEntry == null || lineEntry.entries.isEmpty) return null; if (lineEntry.line != line) return lineEntry.entries.last; var entries = lineEntry.entries; @@ -517,33 +521,39 @@ class SingleMapping extends Mapping { } @override - SourceMapSpan spanFor(int line, int column, - {Map files, String uri}) { + SourceMapSpan? spanFor(int line, int column, + {Map? files, String? uri}) { var entry = _findColumn(line, column, _findLine(line)); - if (entry == null || entry.sourceUrlId == null) return null; - var url = urls[entry.sourceUrlId]; + if (entry == null) return null; + + var sourceUrlId = entry.sourceUrlId; + if (sourceUrlId == null) return null; + + var url = urls[sourceUrlId]; if (sourceRoot != null) { url = '${sourceRoot}${url}'; } - if (files != null && files[url] != null) { - var file = files[url]; - var start = file.getOffset(entry.sourceLine, entry.sourceColumn); - if (entry.sourceNameId != null) { - var text = names[entry.sourceNameId]; - return SourceMapFileSpan(files[url].span(start, start + text.length), + + var sourceNameId = entry.sourceNameId; + var file = files?[url]; + if (file != null) { + var start = file.getOffset(entry.sourceLine!, entry.sourceColumn); + if (sourceNameId != null) { + var text = names[sourceNameId]; + return SourceMapFileSpan(file.span(start, start + text.length), isIdentifier: true); } else { - return SourceMapFileSpan(files[url].location(start).pointSpan()); + return SourceMapFileSpan(file.location(start).pointSpan()); } } else { var start = SourceLocation(0, - sourceUrl: _mapUrl == null ? url : _mapUrl.resolve(url), + sourceUrl: _mapUrl?.resolve(url) ?? url, line: entry.sourceLine, column: entry.sourceColumn); // Offset and other context is not available. - if (entry.sourceNameId != null) { - return SourceMapSpan.identifier(start, names[entry.sourceNameId]); + if (sourceNameId != null) { + return SourceMapSpan.identifier(start, names[sourceNameId]); } else { return SourceMapSpan(start, start, ''); } @@ -578,18 +588,20 @@ class SingleMapping extends Mapping { ..write(line) ..write(':') ..write(entry.column); - if (entry.sourceUrlId != null) { + var sourceUrlId = entry.sourceUrlId; + if (sourceUrlId != null) { buff ..write(' --> ') ..write(sourceRoot) - ..write(urls[entry.sourceUrlId]) + ..write(urls[sourceUrlId]) ..write(': ') ..write(entry.sourceLine) ..write(':') ..write(entry.sourceColumn); } - if (entry.sourceNameId != null) { - buff..write(' (')..write(names[entry.sourceNameId])..write(')'); + var sourceNameId = entry.sourceNameId; + if (sourceNameId != null) { + buff..write(' (')..write(names[sourceNameId])..write(')'); } buff.write('\n'); } @@ -611,10 +623,10 @@ class TargetLineEntry { /// A target segment entry read from a source map class TargetEntry { final int column; - final int sourceUrlId; - final int sourceLine; - final int sourceColumn; - final int sourceNameId; + final int? sourceUrlId; + final int? sourceLine; + final int? sourceColumn; + final int? sourceNameId; TargetEntry(this.column, [this.sourceUrlId, @@ -639,9 +651,11 @@ class _MappingTokenizer implements Iterator { // Iterator API is used by decodeVlq to consume VLQ entries. @override bool moveNext() => ++index < _length; + @override - String get current => - (index >= 0 && index < _length) ? _internal[index] : null; + String get current => (index >= 0 && index < _length) + ? _internal[index] + : throw RangeError.index(index, _internal); bool get hasTokens => index < _length - 1 && _length > 0; @@ -671,7 +685,9 @@ class _MappingTokenizer implements Iterator { buff.write(_internal[i]); } buff.write(''); - buff.write(current ?? ''); + try { + buff.write(current); + } on RangeError catch (_) {} buff.write(''); for (var i = index + 1; i < _internal.length; i++) { buff.write(_internal[i]); diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index d79d2cb03..922c7fea0 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -23,7 +23,7 @@ class Printer { String get map => _maps.toJson(filename); /// Current source location mapping. - SourceLocation _loc; + SourceLocation? _loc; /// Current line in the buffer; int _line = 0; @@ -47,13 +47,21 @@ class Printer { // Return not followed by line-feed is treated as a new line. _line++; _column = 0; - if (projectMarks && _loc != null) { - if (_loc is FileLocation) { - var file = (_loc as FileLocation).file; - mark(file.location(file.getOffset(_loc.line + 1))); - } else { - mark(SourceLocation(0, - sourceUrl: _loc.sourceUrl, line: _loc.line + 1, column: 0)); + { + // **Warning**: Any calls to `mark` will change the value of `_loc`, + // so this local variable is no longer up to date after that point. + // + // This is why it has been put inside its own block to limit the + // scope in which it is available. + var loc = _loc; + if (projectMarks && loc != null) { + if (loc is FileLocation) { + var file = loc.file; + mark(file.location(file.getOffset(loc.line + 1))); + } else { + mark(SourceLocation(0, + sourceUrl: loc.sourceUrl, line: loc.line + 1, column: 0)); + } } } } else { @@ -78,8 +86,8 @@ class Printer { /// this also records the name of the identifier in the source map /// information. void mark(mark) { - SourceLocation loc; - String identifier; + late final SourceLocation loc; + String? identifier; if (mark is SourceLocation) { loc = mark; } else if (mark is SourceSpan) { @@ -106,11 +114,20 @@ class NestedPrinter implements NestedItem { final _items = []; /// Internal buffer to merge consecutive strings added to this printer. - StringBuffer _buff; + StringBuffer? _buff; /// Current indentation, which can be updated from outside this class. int indent; + /// [Printer] used during the last call to [build], if any. + Printer? printer; + + /// Returns the text produced after calling [build]. + String? get text => printer?.text; + + /// Returns the source-map information produced after calling [build]. + String? get map => printer?.map; + /// Item used to indicate that the following item is copied from the original /// source code, and hence we should preserve source-maps on every new line. static final _ORIGINAL = Object(); @@ -133,7 +150,7 @@ class NestedPrinter implements NestedItem { /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. void add(object, - {SourceLocation location, SourceSpan span, bool isOriginal = false}) { + {SourceLocation? location, SourceSpan? span, bool isOriginal = false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); assert(location == null || span == null); @@ -162,7 +179,7 @@ class NestedPrinter implements NestedItem { /// The [location] and [span] parameters indicate the corresponding source map /// location of [line] in the original input. Only one, [location] or /// [span], should be provided at a time. - void addLine(String line, {SourceLocation location, SourceSpan span}) { + void addLine(String? line, {SourceLocation? location, SourceSpan? span}) { if (location != null || span != null) { _flush(); assert(location == null || span == null); @@ -180,8 +197,8 @@ class NestedPrinter implements NestedItem { /// Appends a string merging it with any previous strings, if possible. void _appendString(String s) { - _buff ??= StringBuffer(); - _buff.write(s); + var buf = _buff ??= StringBuffer(); + buf.write(s); } /// Adds all of the current [_buff] contents as a string item. @@ -206,15 +223,6 @@ class NestedPrinter implements NestedItem { return (StringBuffer()..writeAll(_items)).toString(); } - /// [Printer] used during the last call to [build], if any. - Printer printer; - - /// Returns the text produced after calling [build]. - String get text => printer.text; - - /// Returns the source-map information produced after calling [build]. - String get map => printer.map; - /// Builds the output of this printer and source map information. After /// calling this function, you can use [text] and [map] to retrieve the /// geenrated code and source map information, respectively. diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 5e117e8ac..64fd61050 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -17,7 +17,7 @@ import 'printer.dart'; /// Applies a series of edits using original location /// information, and composes them into the edited string. class TextEditTransaction { - final SourceFile file; + final SourceFile? file; final String original; final _edits = <_TextEdit>[]; @@ -33,9 +33,9 @@ class TextEditTransaction { _edits.add(_TextEdit(begin, end, replacement)); } - /// Create a source map [SourceLocation] for [offset]. - SourceLocation _loc(int offset) => - file != null ? file.location(offset) : null; + /// Create a source map [SourceLocation] for [offset], if [file] is not + /// `null`. + SourceLocation? _loc(int offset) => file?.location(offset); /// Applies all pending [edit]s and returns a [NestedPrinter] containing the /// rewritten string and source map information. [file]`.location` is given to @@ -58,7 +58,7 @@ class TextEditTransaction { if (consumed > edit.begin) { var sb = StringBuffer(); sb - ..write(file.location(edit.begin).toolString) + ..write(file?.location(edit.begin).toolString) ..write(': overlapping edits. Insert at offset ') ..write(edit.begin) ..write(' but have consumed ') diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index b8f1152f7..65574ca5e 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -52,7 +52,7 @@ class SourceMapFileSpan implements SourceMapSpan, FileSpan { @override String get context => _inner.context; @override - Uri get sourceUrl => _inner.sourceUrl; + Uri? get sourceUrl => _inner.sourceUrl; @override int get length => _inner.length; diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index d4e29a1c3..951ea8b96 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -33,8 +33,8 @@ final Map _digits = () { return map; }(); -final int MAX_INT32 = pow(2, 31) - 1; -final int MIN_INT32 = -pow(2, 31); +final int MAX_INT32 = (pow(2, 31) as int) - 1; +final int MIN_INT32 = -(pow(2, 31) as int); /// Creates the VLQ encoding of [value] as a sequence of characters Iterable encodeVlq(int value) { @@ -70,10 +70,10 @@ int decodeVlq(Iterator chars) { while (!stop) { if (!chars.moveNext()) throw StateError('incomplete VLQ value'); var char = chars.current; - if (!_digits.containsKey(char)) { + var digit = _digits[char]; + if (digit == null) { throw FormatException('invalid character in VLQ encoding: $char'); } - var digit = _digits[char]; stop = (digit & VLQ_CONTINUATION_BIT) == 0; digit &= VLQ_BASE_MASK; result += (digit << shift); diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 871c40acc..a59c77d54 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,16 +1,93 @@ name: source_maps -version: 0.10.9 +version: 0.11.0-nullsafety description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.9.0-18.0 <2.9.0' dependencies: - source_span: ^1.3.0 + source_span: '>=1.8.0-nullsafety <1.8.0' dev_dependencies: - source_span: ^1.5.4 test: ^1.2.0 term_glyph: ^1.0.0 + +dependency_overrides: + # Overrides required for a version solve + coverage: 0.14.0 + # NNBD Branches + async: + git: + url: git://github.com/dart-lang/async.git + ref: null_safety + boolean_selector: + git: + url: git://github.com/dart-lang/boolean_selector.git + ref: null_safety + charcode: + git: + url: git://github.com/dart-lang/charcode.git + ref: null_safety + collection: 1.15.0-nullsafety + js: + git: + url: git://github.com/dart-lang/sdk.git + path: pkg/js + matcher: + git: + url: git://github.com/dart-lang/matcher.git + ref: null_safety + meta: 1.3.0-nullsafety + path: + git: + url: git://github.com/dart-lang/path.git + ref: null_safety + pedantic: + git: + url: git://github.com/dart-lang/pedantic.git + ref: null_safety + pool: + git: + url: git://github.com/dart-lang/pool.git + ref: null_safety + source_map_stack_trace: + git: + url: git://github.com/dart-lang/source_map_stack_trace.git + ref: null_safety + source_span: + git: + url: git://github.com/dart-lang/source_span.git + ref: null_safety + stack_trace: + git: + url: git://github.com/dart-lang/stack_trace.git + ref: null_safety + stream_channel: + git: + url: git://github.com/dart-lang/stream_channel.git + ref: null_safety + string_scanner: + git: + url: git://github.com/dart-lang/string_scanner.git + ref: null_safety + term_glyph: + git: + url: git://github.com/dart-lang/term_glyph.git + ref: null_safety + test: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test + test_api: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test_api + test_core: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test_core diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index c0bed6810..6ba1c6796 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -76,8 +76,8 @@ void check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan, var line = outputSpan.start.line; var column = outputSpan.start.column; var files = realOffsets ? {'input.dart': input} : null; - var span = mapping.spanFor(line, column, files: files); - var span2 = mapping.spanForLocation(outputSpan.start, files: files); + var span = mapping.spanFor(line, column, files: files)!; + var span2 = mapping.spanForLocation(outputSpan.start, files: files)!; // Both mapping APIs are equivalent. expect(span.start.offset, span2.start.offset); diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 1b73f13cb..1b3ae6f92 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -104,7 +104,7 @@ void main() { }); test('parse with no source location', () { - SingleMapping map = parse(jsonEncode(MAP_WITH_NO_SOURCE_LOCATION)); + var map = parse(jsonEncode(MAP_WITH_NO_SOURCE_LOCATION)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -117,7 +117,7 @@ void main() { }); test('parse with source location and no name', () { - SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION)); + var map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -130,8 +130,8 @@ void main() { }); test('parse with source location and missing names entry', () { - SingleMapping map = - parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES)); + var map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES)) + as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -144,7 +144,8 @@ void main() { }); test('parse with source location and name', () { - SingleMapping map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)); + var map = + parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -160,12 +161,12 @@ void main() { var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap) as SingleMapping; - expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse('/pkg/input.dart')); + expect(mapping.spanFor(0, 0)?.sourceUrl, Uri.parse('/pkg/input.dart')); expect( mapping .spanForLocation( SourceLocation(0, sourceUrl: Uri.parse('ignored.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('/pkg/input.dart')); var newSourceRoot = '/new/'; @@ -180,7 +181,7 @@ void main() { var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); inputMap['sourceRoot'] = 'pkg/'; var mapping = parseJson(inputMap, mapUrl: 'file:///path/to/map'); - expect(mapping.spanFor(0, 0).sourceUrl, + expect(mapping.spanFor(0, 0)?.sourceUrl, Uri.parse('file:///path/to/pkg/input.dart')); }); @@ -193,29 +194,31 @@ void main() { mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/output2.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.file('/path/to/3/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); expect( - mapping.spanFor(0, 0, uri: 'file:///path/to/output.dart').sourceUrl, + mapping.spanFor(0, 0, uri: 'file:///path/to/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect( - mapping.spanFor(0, 0, uri: 'file:///path/to/output2.dart').sourceUrl, + mapping.spanFor(0, 0, uri: 'file:///path/to/output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect( - mapping.spanFor(0, 0, uri: 'file:///path/to/3/output.dart').sourceUrl, + mapping + .spanFor(0, 0, uri: 'file:///path/to/3/output.dart') + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); @@ -224,36 +227,36 @@ void main() { mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:1/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:2/output2.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('package:3/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); - expect(mapping.spanFor(0, 0, uri: 'package:1/output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'package:1/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); - expect(mapping.spanFor(0, 0, uri: 'package:2/output2.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'package:2/output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); - expect(mapping.spanFor(0, 0, uri: 'package:3/output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'package:3/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); test('unmapped path', () { - var span = mapping.spanFor(0, 0, uri: 'unmapped_output.dart'); + var span = mapping.spanFor(0, 0, uri: 'unmapped_output.dart')!; expect(span.sourceUrl, Uri.parse('unmapped_output.dart')); expect(span.start.line, equals(0)); expect(span.start.column, equals(0)); - span = mapping.spanFor(10, 5, uri: 'unmapped_output.dart'); + span = mapping.spanFor(10, 5, uri: 'unmapped_output.dart')!; expect(span.sourceUrl, Uri.parse('unmapped_output.dart')); expect(span.start.line, equals(10)); expect(span.start.column, equals(5)); @@ -264,11 +267,11 @@ void main() { }); test('incomplete paths', () { - expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); - expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); - expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: '3/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); @@ -276,11 +279,11 @@ void main() { var mapping = parseExtended(jsonEncode(SOURCE_MAP_BUNDLE), mapUrl: 'file:///path/to/map'); - expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); - expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); - expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: '3/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); @@ -288,22 +291,22 @@ void main() { var mapping = MappingBundle(); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1, - mapUrl: 'file:///path/to/map')); - expect(mapping.spanFor(0, 0, uri: 'output.dart').sourceUrl, + mapUrl: 'file:///path/to/map') as SingleMapping); + expect(mapping.spanFor(0, 0, uri: 'output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect(mapping.containsMapping('output2.dart'), isFalse); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_2, - mapUrl: 'file:///path/to/map')); + mapUrl: 'file:///path/to/map') as SingleMapping); expect(mapping.containsMapping('output2.dart'), isTrue); - expect(mapping.spanFor(0, 0, uri: 'output2.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: 'output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect(mapping.containsMapping('3/output.dart'), isFalse); mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_3, - mapUrl: 'file:///path/to/map')); + mapUrl: 'file:///path/to/map') as SingleMapping); expect(mapping.containsMapping('3/output.dart'), isTrue); - expect(mapping.spanFor(0, 0, uri: '3/output.dart').sourceUrl, + expect(mapping.spanFor(0, 0, uri: '3/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); @@ -315,31 +318,33 @@ void main() { mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/output2.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanForLocation(SourceLocation(0, sourceUrl: Uri.parse('http://localhost/3/output.dart'))) - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); expect( - mapping.spanFor(0, 0, uri: 'http://localhost/output.dart').sourceUrl, + mapping.spanFor(0, 0, uri: 'http://localhost/output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect( - mapping.spanFor(0, 0, uri: 'http://localhost/output2.dart').sourceUrl, + mapping + .spanFor(0, 0, uri: 'http://localhost/output2.dart') + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect( mapping .spanFor(0, 0, uri: 'http://localhost/3/output.dart') - .sourceUrl, + ?.sourceUrl, Uri.parse('file:///path/to/pkg/input3.dart')); }); }); @@ -351,10 +356,10 @@ void main() { MAP_WITH_SOURCE_LOCATION, MAP_WITH_SOURCE_LOCATION_AND_NAME ]) { - SingleMapping mapping = parseJson(expected); + var mapping = parseJson(expected) as SingleMapping; expect(mapping.toJson(), equals(expected)); - mapping = parseJsonExtended(expected); + mapping = parseJsonExtended(expected) as SingleMapping; expect(mapping.toJson(), equals(expected)); } @@ -366,7 +371,7 @@ void main() { var map = Map.from(EXPECTED_MAP); map['x_foo'] = 'a'; map['x_bar'] = [3]; - SingleMapping mapping = parseJson(map); + var mapping = parseJson(map) as SingleMapping; expect(mapping.toJson(), equals(map)); expect(mapping.extensions['x_foo'], equals('a')); expect(mapping.extensions['x_bar'].first, equals(3)); @@ -415,7 +420,7 @@ void main() { map['sourcesContent'] = ['hello, world!']; var mapping = parseJson(map) as SingleMapping; - var file = mapping.files[0]; + var file = mapping.files[0]!; expect(file.url, equals(Uri.parse('input.dart'))); expect(file.getText(0), equals('hello, world!')); }); diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 36b934a8d..9a403a1b3 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -60,7 +60,7 @@ void main() { txn.edit(34, 35, '___'); var printer = (txn.commit()..build('')); var output = printer.text; - var map = parse(printer.map); + var map = parse(printer.map!); expect(output, '0123456789\n0*23456789\n01*34__\n 789\na___cdefghij\nabcd*fghij\n'); @@ -197,7 +197,5 @@ void main() { }); } -String _span(int line, int column, Mapping map, SourceFile file) { - var span = map.spanFor(line - 1, column - 1, files: {'': file}); - return span == null ? null : span.message('').trim(); -} +String? _span(int line, int column, Mapping map, SourceFile file) => + map.spanFor(line - 1, column - 1, files: {'': file})?.message('').trim(); diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 6021519dd..92a8f4add 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -27,8 +27,8 @@ void main() { }); test('only 32-bit ints allowed', () { - var max_int = pow(2, 31) - 1; - var min_int = -pow(2, 31); + var max_int = (pow(2, 31) as int) - 1; + var min_int = -(pow(2, 31) as int); _checkEncodeDecode(max_int - 1); _checkEncodeDecode(min_int + 1); _checkEncodeDecode(max_int); From ead4b8993bd3bf2f627d676e8bcd8121b14f454c Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 21 Jul 2020 19:41:09 -0700 Subject: [PATCH 083/133] update for the 2.10 dev sdk (dart-lang/source_maps#50) This is in preparation for the actual 2.10 dev sdk release. --- pkgs/source_maps/.travis.yml | 10 ++--- pkgs/source_maps/pubspec.yaml | 80 +++++++++++++---------------------- 2 files changed, 34 insertions(+), 56 deletions(-) diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml index 785c7c2e4..51a3d8a48 100644 --- a/pkgs/source_maps/.travis.yml +++ b/pkgs/source_maps/.travis.yml @@ -1,23 +1,23 @@ language: dart dart: - - be/raw/latest + - preview/raw/2.10.0-0.2-dev jobs: include: - stage: analyze_and_format name: "Analyze" - dart: be/raw/latest + dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . - stage: analyze_and_format name: "Format" - dart: be/raw/latest + dart: preview/raw/2.10.0-0.2-dev os: linux script: dartfmt -n --set-exit-if-changed . - stage: test name: "Vm Tests" - dart: be/raw/latest + dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p vm @@ -27,7 +27,7 @@ stages: # Only building master means that we don't run two builds for each pull request. branches: - only: [master, null_safety] + only: [master] cache: directories: diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index a59c77d54..4bdc225a0 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -5,7 +5,8 @@ description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: - sdk: '>=2.9.0-18.0 <2.9.0' + # This must remain a tight constraint until nnbd is stable + sdk: '>=2.10.0-0 <2.10.0' dependencies: source_span: '>=1.8.0-nullsafety <1.8.0' @@ -15,79 +16,56 @@ dev_dependencies: term_glyph: ^1.0.0 dependency_overrides: - # Overrides required for a version solve - coverage: 0.14.0 - # NNBD Branches async: - git: - url: git://github.com/dart-lang/async.git - ref: null_safety + git: git://github.com/dart-lang/async.git boolean_selector: - git: - url: git://github.com/dart-lang/boolean_selector.git - ref: null_safety + git: git://github.com/dart-lang/boolean_selector.git charcode: - git: - url: git://github.com/dart-lang/charcode.git - ref: null_safety - collection: 1.15.0-nullsafety + git: git://github.com/dart-lang/charcode.git + collection: + git: git://github.com/dart-lang/collection.git js: git: url: git://github.com/dart-lang/sdk.git path: pkg/js + ref: 2-10-pkgs matcher: + git: git://github.com/dart-lang/matcher.git + meta: git: - url: git://github.com/dart-lang/matcher.git - ref: null_safety - meta: 1.3.0-nullsafety + url: git://github.com/dart-lang/sdk.git + path: pkg/meta + ref: 2-10-pkgs path: - git: - url: git://github.com/dart-lang/path.git - ref: null_safety + git: git://github.com/dart-lang/path.git pedantic: - git: - url: git://github.com/dart-lang/pedantic.git - ref: null_safety + git: git://github.com/dart-lang/pedantic.git pool: - git: - url: git://github.com/dart-lang/pool.git - ref: null_safety + git: git://github.com/dart-lang/pool.git source_map_stack_trace: - git: - url: git://github.com/dart-lang/source_map_stack_trace.git - ref: null_safety + git: git://github.com/dart-lang/source_map_stack_trace.git source_span: - git: - url: git://github.com/dart-lang/source_span.git - ref: null_safety + git: git://github.com/dart-lang/source_span.git stack_trace: - git: - url: git://github.com/dart-lang/stack_trace.git - ref: null_safety + git: git://github.com/dart-lang/stack_trace.git stream_channel: - git: - url: git://github.com/dart-lang/stream_channel.git - ref: null_safety + git: git://github.com/dart-lang/stream_channel.git string_scanner: - git: - url: git://github.com/dart-lang/string_scanner.git - ref: null_safety + git: git://github.com/dart-lang/string_scanner.git term_glyph: - git: - url: git://github.com/dart-lang/term_glyph.git - ref: null_safety - test: - git: - url: git://github.com/dart-lang/test.git - ref: null_safety - path: pkgs/test + git: git://github.com/dart-lang/term_glyph.git test_api: git: url: git://github.com/dart-lang/test.git - ref: null_safety path: pkgs/test_api test_core: git: url: git://github.com/dart-lang/test.git - ref: null_safety path: pkgs/test_core + test: + git: + url: git://github.com/dart-lang/test.git + path: pkgs/test + typed_data: + git: git://github.com/dart-lang/typed_data.git + From 471c213e807a20ea3d08bf520953ac0850fd331a Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 22 Jul 2020 10:46:41 -0700 Subject: [PATCH 084/133] add back coverage override to fix travis (dart-lang/source_maps#51) --- pkgs/source_maps/pubspec.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 4bdc225a0..8fc3fb3f1 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -16,6 +16,9 @@ dev_dependencies: term_glyph: ^1.0.0 dependency_overrides: + # Overrides required for a version solve + coverage: 0.14.0 + # Null Safety Overrides async: git: git://github.com/dart-lang/async.git boolean_selector: From 82232f36f7a608fefe604b61e509bb494d8067ee Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 28 Jul 2020 13:44:53 -0700 Subject: [PATCH 085/133] Update travis-ci: test on dev (dart-lang/source_maps#52) --- pkgs/source_maps/.travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml index 51a3d8a48..ac74df9cc 100644 --- a/pkgs/source_maps/.travis.yml +++ b/pkgs/source_maps/.travis.yml @@ -1,23 +1,20 @@ language: dart dart: - - preview/raw/2.10.0-0.2-dev + - dev jobs: include: - stage: analyze_and_format name: "Analyze" - dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . - stage: analyze_and_format name: "Format" - dart: preview/raw/2.10.0-0.2-dev os: linux script: dartfmt -n --set-exit-if-changed . - stage: test name: "Vm Tests" - dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p vm From 1fb0604a9a80ccd775aa4713a459a22d7e08e99a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 28 Jul 2020 20:33:37 -0700 Subject: [PATCH 086/133] Delete .test_config No longer used --- pkgs/source_maps/.test_config | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 pkgs/source_maps/.test_config diff --git a/pkgs/source_maps/.test_config b/pkgs/source_maps/.test_config deleted file mode 100644 index 412fc5c5c..000000000 --- a/pkgs/source_maps/.test_config +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test_package": true -} \ No newline at end of file From 2ef6558ddc47da1513b4f46739d070a1c110f491 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 29 Jul 2020 12:12:24 -0700 Subject: [PATCH 087/133] change version to be non-breaking (dart-lang/source_maps#53) --- pkgs/source_maps/CHANGELOG.md | 2 +- pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index bc7c9ef84..155b6cd12 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.11.0-nullsafety +## 0.10.1-nullsafety * Migrate to null safety diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 8fc3fb3f1..d540efbb9 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.11.0-nullsafety +version: 0.10.1-nullsafety description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps From dce5cbe9bf14ebf2c5d5cb0ba58b1f418e311207 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 29 Jul 2020 13:31:39 -0700 Subject: [PATCH 088/133] version should be 0.10.10-nullsafety (dart-lang/source_maps#54) --- pkgs/source_maps/CHANGELOG.md | 2 +- pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 155b6cd12..5af57527d 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.10.1-nullsafety +## 0.10.10-nullsafety * Migrate to null safety diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index d540efbb9..1951d7232 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.1-nullsafety +version: 0.10.10-nullsafety description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps From 618612dc9092a9a178d37f842cf2b82d1c2fe7c8 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 22 Sep 2020 09:09:03 -0700 Subject: [PATCH 089/133] Prepare for the 2.11 dev SDKs (dart-lang/source_maps#55) Bump the upper bound to allow 2.10 stable and 2.11.0 dev SDK versions. --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 5af57527d..fe1976163 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.10-nullsafety.1 + +* Allow 2.10 stable and 2.11.0 dev SDK versions. + ## 0.10.10-nullsafety * Migrate to null safety diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 1951d7232..a61224ab8 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,12 +1,12 @@ name: source_maps -version: 0.10.10-nullsafety +version: 0.10.10-nullsafety.1 description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.10.0' + sdk: '>=2.10.0-0 <2.11.0' dependencies: source_span: '>=1.8.0-nullsafety <1.8.0' From 8ad7c52042ba31de2877ca698c1cba03d05830e4 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 23 Oct 2020 13:07:00 -0700 Subject: [PATCH 090/133] allow the 2.12 prerelease sdks (dart-lang/source_maps#56) --- pkgs/source_maps/CHANGELOG.md | 4 +++ pkgs/source_maps/pubspec.yaml | 66 +++-------------------------------- 2 files changed, 8 insertions(+), 62 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index fe1976163..6d3bb3541 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.10-nullsafety.2 + +* Allow prerelease versions of the 2.12 sdk. + ## 0.10.10-nullsafety.1 * Allow 2.10 stable and 2.11.0 dev SDK versions. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index a61224ab8..73fa7657d 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,74 +1,16 @@ name: source_maps -version: 0.10.10-nullsafety.1 +version: 0.10.10-nullsafety.2 description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.11.0' + sdk: '>=2.10.0-0 <2.12.0' dependencies: source_span: '>=1.8.0-nullsafety <1.8.0' dev_dependencies: - test: ^1.2.0 - term_glyph: ^1.0.0 - -dependency_overrides: - # Overrides required for a version solve - coverage: 0.14.0 - # Null Safety Overrides - async: - git: git://github.com/dart-lang/async.git - boolean_selector: - git: git://github.com/dart-lang/boolean_selector.git - charcode: - git: git://github.com/dart-lang/charcode.git - collection: - git: git://github.com/dart-lang/collection.git - js: - git: - url: git://github.com/dart-lang/sdk.git - path: pkg/js - ref: 2-10-pkgs - matcher: - git: git://github.com/dart-lang/matcher.git - meta: - git: - url: git://github.com/dart-lang/sdk.git - path: pkg/meta - ref: 2-10-pkgs - path: - git: git://github.com/dart-lang/path.git - pedantic: - git: git://github.com/dart-lang/pedantic.git - pool: - git: git://github.com/dart-lang/pool.git - source_map_stack_trace: - git: git://github.com/dart-lang/source_map_stack_trace.git - source_span: - git: git://github.com/dart-lang/source_span.git - stack_trace: - git: git://github.com/dart-lang/stack_trace.git - stream_channel: - git: git://github.com/dart-lang/stream_channel.git - string_scanner: - git: git://github.com/dart-lang/string_scanner.git - term_glyph: - git: git://github.com/dart-lang/term_glyph.git - test_api: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test_api - test_core: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test_core - test: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test - typed_data: - git: git://github.com/dart-lang/typed_data.git - + test: ^1.16.0-nullsafety + term_glyph: ^1.2.0-nullsafety From 7cf68751f3d03d3c27b4a45bfdc7598addfca6a3 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 3 Nov 2020 14:25:35 -0800 Subject: [PATCH 091/133] Bump SDK constraints for pub (dart-lang/source_maps#57) Use a 2.12.0 lower bound since pub does not understand allowed experiments for earlier versions. Use a 3.0.0 upper bound to avoid a warning in pub and to give some flexibility in publishing for stable. --- pkgs/source_maps/CHANGELOG.md | 5 +++++ pkgs/source_maps/pubspec.yaml | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 6d3bb3541..7bdead97f 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.10-nullsafety.3 + +* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release + guidelines. + ## 0.10.10-nullsafety.2 * Allow prerelease versions of the 2.12 sdk. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 73fa7657d..ab75dc5c6 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,12 +1,11 @@ name: source_maps -version: 0.10.10-nullsafety.2 +version: 0.10.10-nullsafety.3 description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: - # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.12.0' + sdk: ">=2.12.0-0 <3.0.0" dependencies: source_span: '>=1.8.0-nullsafety <1.8.0' From 21b831d74e81751717799629e310639a141a60f8 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Wed, 11 Nov 2020 09:54:20 -0800 Subject: [PATCH 092/133] remove redundant experiment --- pkgs/source_maps/analysis_options.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index 86c836783..4f9dfb038 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1,9 +1,5 @@ include: package:pedantic/analysis_options.yaml -analyzer: - enable-experiment: - - non-nullable - linter: rules: - comment_references From 4576b85ed4a30859a744dcca906326b963208871 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Wed, 20 Jan 2021 16:06:47 +0100 Subject: [PATCH 093/133] Migrate to GitHub Actions (dart-lang/source_maps#60) * Delete .travis.yml --- .../.github/workflows/test-package.yml | 61 +++++++++++++++++++ pkgs/source_maps/.travis.yml | 31 ---------- 2 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 pkgs/source_maps/.github/workflows/test-package.yml delete mode 100644 pkgs/source_maps/.travis.yml diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml new file mode 100644 index 000000000..21a3c50b6 --- /dev/null +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -0,0 +1,61 @@ +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart dev. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Analyze code + run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + + # Run tests on a matrix consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release channel: dev + test: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm + if: always() && steps.install.outcome == 'success' diff --git a/pkgs/source_maps/.travis.yml b/pkgs/source_maps/.travis.yml deleted file mode 100644 index ac74df9cc..000000000 --- a/pkgs/source_maps/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: dart - -dart: - - dev - -jobs: - include: - - stage: analyze_and_format - name: "Analyze" - os: linux - script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . - - stage: analyze_and_format - name: "Format" - os: linux - script: dartfmt -n --set-exit-if-changed . - - stage: test - name: "Vm Tests" - os: linux - script: pub run --enable-experiment=non-nullable test -p vm - -stages: - - analyze_and_format - - test - -# Only building master means that we don't run two builds for each pull request. -branches: - only: [master] - -cache: - directories: - - $HOME/.pub-cache From e13c6af6304a26cea128b96fd82ebb065792f827 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 2 Feb 2021 16:31:39 -0800 Subject: [PATCH 094/133] Prepare to publish for stable null safety (dart-lang/source_maps#61) --- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 7bdead97f..a59cf3006 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.10 + +* Stable release for null safety. + ## 0.10.10-nullsafety.3 * Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index ab75dc5c6..648010a3f 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.10-nullsafety.3 +version: 0.10.10 description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps @@ -8,7 +8,7 @@ environment: sdk: ">=2.12.0-0 <3.0.0" dependencies: - source_span: '>=1.8.0-nullsafety <1.8.0' + source_span: ^1.8.0 dev_dependencies: test: ^1.16.0-nullsafety From 1020d5abe3c6ab5e7dd772feeecfe9a8127f5f25 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 11 Mar 2021 09:56:42 -0800 Subject: [PATCH 095/133] fix latest lints (dart-lang/source_maps#62) --- pkgs/source_maps/lib/parser.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 1f8b8175f..99a3c81b1 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -531,7 +531,7 @@ class SingleMapping extends Mapping { var url = urls[sourceUrlId]; if (sourceRoot != null) { - url = '${sourceRoot}${url}'; + url = '$sourceRoot$url'; } var sourceNameId = entry.sourceNameId; From 8f45e2eb9fc350caa170000868c358edfc9f1334 Mon Sep 17 00:00:00 2001 From: Franklin Yow <58489007+franklinyow@users.noreply.github.com> Date: Tue, 30 Mar 2021 16:57:08 -0700 Subject: [PATCH 096/133] Update LICENSE Changes to comply with open source review --- pkgs/source_maps/LICENSE | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/LICENSE b/pkgs/source_maps/LICENSE index 5c60afea3..162572a44 100644 --- a/pkgs/source_maps/LICENSE +++ b/pkgs/source_maps/LICENSE @@ -1,4 +1,5 @@ -Copyright 2014, the Dart project authors. All rights reserved. +Copyright 2014, the Dart project authors. + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -9,7 +10,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. From a4e89f0f2e60d9ef4ea4b60ac56ba7184d74fc83 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 26 Apr 2021 10:48:40 -0700 Subject: [PATCH 097/133] update ci (dart-lang/source_maps#64) --- pkgs/source_maps/.github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 21a3c50b6..e47bf6600 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,10 +47,10 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [dev] + sdk: [2.12.0, dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install From 5bb1de7b237b3c8682ace686648f4048061d2158 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Oct 2021 14:54:42 -0700 Subject: [PATCH 098/133] Migrate to pkg:lints, fix related lints, cleanup in pubspec (dart-lang/source_maps#65) Removed pre-release versions from changelog --- pkgs/source_maps/CHANGELOG.md | 19 +----- pkgs/source_maps/analysis_options.yaml | 2 +- pkgs/source_maps/lib/parser.dart | 23 +++---- pkgs/source_maps/lib/printer.dart | 14 ++--- pkgs/source_maps/lib/refactor.dart | 17 +++--- pkgs/source_maps/lib/src/utils.dart | 3 + pkgs/source_maps/lib/src/vlq.dart | 36 +++++------ pkgs/source_maps/pubspec.yaml | 9 +-- pkgs/source_maps/test/builder_test.dart | 8 ++- pkgs/source_maps/test/common.dart | 10 ++-- pkgs/source_maps/test/end2end_test.dart | 9 +-- pkgs/source_maps/test/parser_test.dart | 79 ++++++++++++------------- pkgs/source_maps/test/printer_test.dart | 24 ++++---- pkgs/source_maps/test/vlq_test.dart | 28 ++++----- 14 files changed, 139 insertions(+), 142 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index a59cf3006..366dce2e5 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,24 +1,9 @@ +# 0.10.11-dev + ## 0.10.10 * Stable release for null safety. -## 0.10.10-nullsafety.3 - -* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release - guidelines. - -## 0.10.10-nullsafety.2 - -* Allow prerelease versions of the 2.12 sdk. - -## 0.10.10-nullsafety.1 - -* Allow 2.10 stable and 2.11.0 dev SDK versions. - -## 0.10.10-nullsafety - -* Migrate to null safety - ## 0.10.9 * Fix a number of document comment issues. diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index 4f9dfb038..c09985a51 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml linter: rules: diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 99a3c81b1..e3c7179f9 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -313,7 +313,7 @@ class SingleMapping extends Mapping { /// The file for each URL, indexed by [urls]' values. var files = {}; - var lineNum; + int? lineNum; late List targetEntries; for (var sourceEntry in sourceEntries) { if (lineNum == null || sourceEntry.target.line > lineNum) { @@ -601,7 +601,10 @@ class SingleMapping extends Mapping { } var sourceNameId = entry.sourceNameId; if (sourceNameId != null) { - buff..write(' (')..write(names[sourceNameId])..write(')'); + buff + ..write(' (') + ..write(names[sourceNameId]) + ..write(')'); } buff.write('\n'); } @@ -660,11 +663,11 @@ class _MappingTokenizer implements Iterator { bool get hasTokens => index < _length - 1 && _length > 0; _TokenKind get nextKind { - if (!hasTokens) return _TokenKind.EOF; + if (!hasTokens) return _TokenKind.eof; var next = _internal[index + 1]; - if (next == ';') return _TokenKind.LINE; - if (next == ',') return _TokenKind.SEGMENT; - return _TokenKind.VALUE; + if (next == ';') return _TokenKind.line; + if (next == ',') return _TokenKind.segment; + return _TokenKind.value; } int _consumeValue() => decodeVlq(this); @@ -698,10 +701,10 @@ class _MappingTokenizer implements Iterator { } class _TokenKind { - static const _TokenKind LINE = _TokenKind(isNewLine: true); - static const _TokenKind SEGMENT = _TokenKind(isNewSegment: true); - static const _TokenKind EOF = _TokenKind(isEof: true); - static const _TokenKind VALUE = _TokenKind(); + static const _TokenKind line = _TokenKind(isNewLine: true); + static const _TokenKind segment = _TokenKind(isNewSegment: true); + static const _TokenKind eof = _TokenKind(isEof: true); + static const _TokenKind value = _TokenKind(); final bool isNewLine; final bool isNewSegment; final bool isEof; diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 922c7fea0..7d128f7ec 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -9,9 +9,7 @@ import 'package:source_span/source_span.dart'; import 'builder.dart'; import 'src/source_map_span.dart'; - -const int _LF = 10; -const int _CR = 13; +import 'src/utils.dart'; /// A simple printer that keeps track of offset locations and records source /// maps locations. @@ -43,7 +41,9 @@ class Printer { var length = chars.length; for (var i = 0; i < length; i++) { var c = chars[i]; - if (c == _LF || (c == _CR && (i + 1 == length || chars[i + 1] != _LF))) { + if (c == lineFeed || + (c == carriageReturn && + (i + 1 == length || chars[i + 1] != lineFeed))) { // Return not followed by line-feed is treated as a new line. _line++; _column = 0; @@ -130,7 +130,7 @@ class NestedPrinter implements NestedItem { /// Item used to indicate that the following item is copied from the original /// source code, and hence we should preserve source-maps on every new line. - static final _ORIGINAL = Object(); + static final _original = Object(); NestedPrinter([this.indent = 0]); @@ -156,7 +156,7 @@ class NestedPrinter implements NestedItem { assert(location == null || span == null); if (location != null) _items.add(location); if (span != null) _items.add(span); - if (isOriginal) _items.add(_ORIGINAL); + if (isOriginal) _items.add(_original); } if (object is String) { @@ -243,7 +243,7 @@ class NestedPrinter implements NestedItem { propagate = false; } else if (item is SourceLocation || item is SourceSpan) { printer.mark(item); - } else if (item == _ORIGINAL) { + } else if (item == _original) { // we insert booleans when we are about to quote text that was copied // from the original source. In such case, we will propagate marks on // every new-line. diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 64fd61050..97bd2a708 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -11,6 +11,7 @@ library source_maps.refactor; import 'package:source_span/source_span.dart'; import 'printer.dart'; +import 'src/utils.dart'; /// Editable text transaction. /// @@ -65,7 +66,9 @@ class TextEditTransaction { ..write(consumed) ..write(' input characters. List of edits:'); for (var e in _edits) { - sb..write('\n ')..write(e); + sb + ..write('\n ') + ..write(e); } throw UnsupportedError(sb.toString()); } @@ -91,7 +94,7 @@ class _TextEdit implements Comparable<_TextEdit> { final int end; /// The replacement used by the edit, can be a string or a [NestedPrinter]. - final replace; + final Object replace; _TextEdit(this.begin, this.end, this.replace); @@ -114,7 +117,7 @@ String guessIndent(String code, int charOffset) { var lineStart = 0; for (var i = charOffset - 1; i >= 0; i--) { var c = code.codeUnitAt(i); - if (c == _LF || c == _CR) { + if (c == lineFeed || c == carriageReturn) { lineStart = i + 1; break; } @@ -124,7 +127,7 @@ String guessIndent(String code, int charOffset) { var whitespaceEnd = code.length; for (var i = lineStart; i < code.length; i++) { var c = code.codeUnitAt(i); - if (c != _SPACE && c != _TAB) { + if (c != _space && c != _tab) { whitespaceEnd = i; break; } @@ -133,7 +136,5 @@ String guessIndent(String code, int charOffset) { return code.substring(lineStart, whitespaceEnd); } -const int _CR = 13; -const int _LF = 10; -const int _TAB = 9; -const int _SPACE = 32; +const int _tab = 9; +const int _space = 32; diff --git a/pkgs/source_maps/lib/src/utils.dart b/pkgs/source_maps/lib/src/utils.dart index f9870d2f3..eb238342d 100644 --- a/pkgs/source_maps/lib/src/utils.dart +++ b/pkgs/source_maps/lib/src/utils.dart @@ -27,3 +27,6 @@ int binarySearch(List list, bool Function(dynamic) matches) { } return max; } + +const int lineFeed = 10; +const int carriageReturn = 13; diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index 951ea8b96..6c41b6e2c 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -14,31 +14,31 @@ library source_maps.src.vlq; import 'dart:math'; -const int VLQ_BASE_SHIFT = 5; +const int vlqBaseShift = 5; -const int VLQ_BASE_MASK = (1 << 5) - 1; +const int vlqBaseMask = (1 << 5) - 1; -const int VLQ_CONTINUATION_BIT = 1 << 5; +const int vlqContinuationBit = 1 << 5; -const int VLQ_CONTINUATION_MASK = 1 << 5; +const int vlqContinuationMask = 1 << 5; -const String BASE64_DIGITS = +const String base64Digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; final Map _digits = () { var map = {}; for (var i = 0; i < 64; i++) { - map[BASE64_DIGITS[i]] = i; + map[base64Digits[i]] = i; } return map; }(); -final int MAX_INT32 = (pow(2, 31) as int) - 1; -final int MIN_INT32 = -(pow(2, 31) as int); +final int maxInt32 = (pow(2, 31) as int) - 1; +final int minInt32 = -(pow(2, 31) as int); /// Creates the VLQ encoding of [value] as a sequence of characters Iterable encodeVlq(int value) { - if (value < MIN_INT32 || value > MAX_INT32) { + if (value < minInt32 || value > maxInt32) { throw ArgumentError('expected 32 bit int, got: $value'); } var res = []; @@ -49,12 +49,12 @@ Iterable encodeVlq(int value) { } value = (value << 1) | signBit; do { - var digit = value & VLQ_BASE_MASK; - value >>= VLQ_BASE_SHIFT; + var digit = value & vlqBaseMask; + value >>= vlqBaseShift; if (value > 0) { - digit |= VLQ_CONTINUATION_BIT; + digit |= vlqContinuationBit; } - res.add(BASE64_DIGITS[digit]); + res.add(base64Digits[digit]); } while (value > 0); return res; } @@ -62,7 +62,7 @@ Iterable encodeVlq(int value) { /// Decodes a value written as a sequence of VLQ characters. The first input /// character will be `chars.current` after calling `chars.moveNext` once. The /// iterator is advanced until a stop character is found (a character without -/// the [VLQ_CONTINUATION_BIT]). +/// the [vlqContinuationBit]). int decodeVlq(Iterator chars) { var result = 0; var stop = false; @@ -74,10 +74,10 @@ int decodeVlq(Iterator chars) { if (digit == null) { throw FormatException('invalid character in VLQ encoding: $char'); } - stop = (digit & VLQ_CONTINUATION_BIT) == 0; - digit &= VLQ_BASE_MASK; + stop = (digit & vlqContinuationBit) == 0; + digit &= vlqBaseMask; result += (digit << shift); - shift += VLQ_BASE_SHIFT; + shift += vlqBaseShift; } // Result uses the least significant bit as a sign bit. We convert it into a @@ -93,7 +93,7 @@ int decodeVlq(Iterator chars) { result = negate ? -result : result; // TODO(sigmund): can we detect this earlier? - if (result < MIN_INT32 || result > MAX_INT32) { + if (result < minInt32 || result > maxInt32) { throw FormatException( 'expected an encoded 32 bit int, but we got: $result'); } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 648010a3f..23e53a589 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,15 +1,16 @@ name: source_maps -version: 0.10.10 +version: 0.10.11-dev description: Library to programmatically manipulate source map files. homepage: https://github.com/dart-lang/source_maps environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: source_span: ^1.8.0 dev_dependencies: - test: ^1.16.0-nullsafety - term_glyph: ^1.2.0-nullsafety + lints: ^1.0.0 + test: ^1.16.0 + term_glyph: ^1.2.0 diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index fddf46c88..b9bb9c770 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -5,8 +5,10 @@ library test.source_maps_test; import 'dart:convert'; -import 'package:test/test.dart'; + import 'package:source_maps/source_maps.dart'; +import 'package:test/test.dart'; + import 'common.dart'; void main() { @@ -17,7 +19,7 @@ void main() { ..addSpan(inputVar2, outputVar2) ..addSpan(inputExpr, outputExpr)) .build(output.url.toString()); - expect(map, equals(EXPECTED_MAP)); + expect(map, equals(expectedMap)); }); test('builder - with location', () { @@ -27,6 +29,6 @@ void main() { ..addLocation(inputVar2.start, outputVar2.start, 'longVar2') ..addLocation(inputExpr.start, outputExpr.start, null)) .toJson(output.url.toString()); - expect(str, jsonEncode(EXPECTED_MAP)); + expect(str, jsonEncode(expectedMap)); }); } diff --git a/pkgs/source_maps/test/common.dart b/pkgs/source_maps/test/common.dart index 6ba1c6796..f6139de47 100644 --- a/pkgs/source_maps/test/common.dart +++ b/pkgs/source_maps/test/common.dart @@ -10,7 +10,7 @@ import 'package:source_span/source_span.dart'; import 'package:test/test.dart'; /// Content of the source file -const String INPUT = ''' +const String inputContent = ''' /** this is a comment. */ int longVar1 = 3; @@ -19,7 +19,7 @@ int longName(int longVar2) { return longVar1 + longVar2; } '''; -var input = SourceFile.fromString(INPUT, url: 'input.dart'); +final input = SourceFile.fromString(inputContent, url: 'input.dart'); /// A span in the input file SourceMapSpan ispan(int start, int end, [bool isIdentifier = false]) => @@ -36,11 +36,11 @@ SourceMapSpan inputVar2NoSymbol = ispan(87, 95); SourceMapSpan inputExpr = ispan(108, 127); /// Content of the target file -const String OUTPUT = ''' +const String outputContent = ''' var x = 3; f(y) => x + y; '''; -var output = SourceFile.fromString(OUTPUT, url: 'output.dart'); +final output = SourceFile.fromString(outputContent, url: 'output.dart'); /// A span in the output file SourceMapSpan ospan(int start, int end, [bool isIdentifier = false]) => @@ -62,7 +62,7 @@ SourceMapSpan outputExpr = ospan(19, 24); /// /// This mapping is stored in the tests so we can independently test the builder /// and parser algorithms without relying entirely on end2end tests. -const Map EXPECTED_MAP = { +const Map expectedMap = { 'version': 3, 'sourceRoot': '', 'sources': ['input.dart'], diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 954339fbd..153fcc286 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -4,9 +4,10 @@ library test.end2end_test; -import 'package:test/test.dart'; import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; +import 'package:test/test.dart'; + import 'common.dart'; void main() { @@ -106,12 +107,12 @@ void main() { }); test('printer projecting marks + parse', () { - var out = INPUT.replaceAll('long', '_s'); + var out = inputContent.replaceAll('long', '_s'); var file = SourceFile.fromString(out, url: 'output2.dart'); var printer = Printer('output2.dart'); printer.mark(ispan(0, 0)); - var segments = INPUT.split('long'); + var segments = inputContent.split('long'); expect(segments.length, 6); printer.add(segments[0], projectMarks: true); printer.mark(inputVar1); @@ -153,7 +154,7 @@ void main() { // Start of the last line var oOffset = out.length - 2; - var iOffset = INPUT.length - 2; + var iOffset = inputContent.length - 2; check(file.span(oOffset, oOffset), mapping, ispan(iOffset, iOffset), true); check(file.span(oOffset + 1, oOffset + 1), mapping, ispan(iOffset, iOffset), true); diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 1b3ae6f92..7c7b142bb 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -2,15 +2,15 @@ // 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. -library test.parser_test; - import 'dart:convert'; -import 'package:test/test.dart'; + import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; +import 'package:test/test.dart'; + import 'common.dart'; -const Map MAP_WITH_NO_SOURCE_LOCATION = { +const Map _mapWithNoSourceLocation = { 'version': 3, 'sourceRoot': '', 'sources': ['input.dart'], @@ -19,7 +19,7 @@ const Map MAP_WITH_NO_SOURCE_LOCATION = { 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION = { +const Map _mapWithSourceLocation = { 'version': 3, 'sourceRoot': '', 'sources': ['input.dart'], @@ -28,7 +28,7 @@ const Map MAP_WITH_SOURCE_LOCATION = { 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES = { +const Map _mapWithSourceLocationAndMissingNames = { 'version': 3, 'sourceRoot': '', 'sources': ['input.dart'], @@ -36,7 +36,7 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES = { 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = { +const Map _mapWithSourceLocationAndName = { 'version': 3, 'sourceRoot': '', 'sources': ['input.dart'], @@ -45,7 +45,7 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME = { 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = { +const Map _mapWithSourceLocationAndName1 = { 'version': 3, 'sourceRoot': 'pkg/', 'sources': ['input1.dart'], @@ -54,7 +54,7 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = { 'file': 'output.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = { +const Map _mapWithSourceLocationAndName2 = { 'version': 3, 'sourceRoot': 'pkg/', 'sources': ['input2.dart'], @@ -63,7 +63,7 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = { 'file': 'output2.dart' }; -const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = { +const Map _mapWithSourceLocationAndName3 = { 'version': 3, 'sourceRoot': 'pkg/', 'sources': ['input3.dart'], @@ -72,15 +72,15 @@ const Map MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = { 'file': '3/output.dart' }; -const List SOURCE_MAP_BUNDLE = [ - MAP_WITH_SOURCE_LOCATION_AND_NAME_1, - MAP_WITH_SOURCE_LOCATION_AND_NAME_2, - MAP_WITH_SOURCE_LOCATION_AND_NAME_3, +const _sourceMapBundle = [ + _mapWithSourceLocationAndName1, + _mapWithSourceLocationAndName2, + _mapWithSourceLocationAndName3, ]; void main() { test('parse', () { - var mapping = parseJson(EXPECTED_MAP); + var mapping = parseJson(expectedMap); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); check(outputFunction, mapping, inputFunction, false); @@ -88,7 +88,7 @@ void main() { }); test('parse + json', () { - var mapping = parse(jsonEncode(EXPECTED_MAP)); + var mapping = parse(jsonEncode(expectedMap)); check(outputVar1, mapping, inputVar1, false); check(outputVar2, mapping, inputVar2, false); check(outputFunction, mapping, inputFunction, false); @@ -96,7 +96,7 @@ void main() { }); test('parse with file', () { - var mapping = parseJson(EXPECTED_MAP); + var mapping = parseJson(expectedMap); check(outputVar1, mapping, inputVar1, true); check(outputVar2, mapping, inputVar2, true); check(outputFunction, mapping, inputFunction, true); @@ -104,7 +104,7 @@ void main() { }); test('parse with no source location', () { - var map = parse(jsonEncode(MAP_WITH_NO_SOURCE_LOCATION)) as SingleMapping; + var map = parse(jsonEncode(_mapWithNoSourceLocation)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -117,7 +117,7 @@ void main() { }); test('parse with source location and no name', () { - var map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION)) as SingleMapping; + var map = parse(jsonEncode(_mapWithSourceLocation)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -130,7 +130,7 @@ void main() { }); test('parse with source location and missing names entry', () { - var map = parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_MISSING_NAMES)) + var map = parse(jsonEncode(_mapWithSourceLocationAndMissingNames)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); @@ -144,8 +144,7 @@ void main() { }); test('parse with source location and name', () { - var map = - parse(jsonEncode(MAP_WITH_SOURCE_LOCATION_AND_NAME)) as SingleMapping; + var map = parse(jsonEncode(_mapWithSourceLocationAndName)) as SingleMapping; expect(map.lines.length, 1); expect(map.lines.first.entries.length, 1); var entry = map.lines.first.entries.first; @@ -158,7 +157,7 @@ void main() { }); test('parse with source root', () { - var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); + var inputMap = Map.from(_mapWithSourceLocation); inputMap['sourceRoot'] = '/pkg/'; var mapping = parseJson(inputMap) as SingleMapping; expect(mapping.spanFor(0, 0)?.sourceUrl, Uri.parse('/pkg/input.dart')); @@ -178,7 +177,7 @@ void main() { }); test('parse with map URL', () { - var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION); + var inputMap = Map.from(_mapWithSourceLocation); inputMap['sourceRoot'] = 'pkg/'; var mapping = parseJson(inputMap, mapUrl: 'file:///path/to/map'); expect(mapping.spanFor(0, 0)?.sourceUrl, @@ -187,7 +186,7 @@ void main() { group('parse with bundle', () { var mapping = - parseJsonExtended(SOURCE_MAP_BUNDLE, mapUrl: 'file:///path/to/map'); + parseJsonExtended(_sourceMapBundle, mapUrl: 'file:///path/to/map'); test('simple', () { expect( @@ -276,7 +275,7 @@ void main() { }); test('parseExtended', () { - var mapping = parseExtended(jsonEncode(SOURCE_MAP_BUNDLE), + var mapping = parseExtended(jsonEncode(_sourceMapBundle), mapUrl: 'file:///path/to/map'); expect(mapping.spanFor(0, 0, uri: 'output.dart')?.sourceUrl, @@ -290,20 +289,20 @@ void main() { test('build bundle incrementally', () { var mapping = MappingBundle(); - mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1, + mapping.addMapping(parseJson(_mapWithSourceLocationAndName1, mapUrl: 'file:///path/to/map') as SingleMapping); expect(mapping.spanFor(0, 0, uri: 'output.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input1.dart')); expect(mapping.containsMapping('output2.dart'), isFalse); - mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_2, + mapping.addMapping(parseJson(_mapWithSourceLocationAndName2, mapUrl: 'file:///path/to/map') as SingleMapping); expect(mapping.containsMapping('output2.dart'), isTrue); expect(mapping.spanFor(0, 0, uri: 'output2.dart')?.sourceUrl, Uri.parse('file:///path/to/pkg/input2.dart')); expect(mapping.containsMapping('3/output.dart'), isFalse); - mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_3, + mapping.addMapping(parseJson(_mapWithSourceLocationAndName3, mapUrl: 'file:///path/to/map') as SingleMapping); expect(mapping.containsMapping('3/output.dart'), isTrue); expect(mapping.spanFor(0, 0, uri: '3/output.dart')?.sourceUrl, @@ -351,10 +350,10 @@ void main() { test('parse and re-emit', () { for (var expected in [ - EXPECTED_MAP, - MAP_WITH_NO_SOURCE_LOCATION, - MAP_WITH_SOURCE_LOCATION, - MAP_WITH_SOURCE_LOCATION_AND_NAME + expectedMap, + _mapWithNoSourceLocation, + _mapWithSourceLocation, + _mapWithSourceLocationAndName ]) { var mapping = parseJson(expected) as SingleMapping; expect(mapping.toJson(), equals(expected)); @@ -363,12 +362,12 @@ void main() { expect(mapping.toJson(), equals(expected)); } - var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE) as MappingBundle; - expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); + var mapping = parseJsonExtended(_sourceMapBundle) as MappingBundle; + expect(mapping.toJson(), equals(_sourceMapBundle)); }); test('parse extensions', () { - var map = Map.from(EXPECTED_MAP); + var map = Map.from(expectedMap); map['x_foo'] = 'a'; map['x_bar'] = [3]; var mapping = parseJson(map) as SingleMapping; @@ -396,19 +395,19 @@ void main() { group('from parse()', () { group('are null', () { test('with no sourcesContent field', () { - var mapping = parseJson(EXPECTED_MAP) as SingleMapping; + var mapping = parseJson(expectedMap) as SingleMapping; expect(mapping.files, equals([null])); }); test('with null sourcesContent values', () { - var map = Map.from(EXPECTED_MAP); + var map = Map.from(expectedMap); map['sourcesContent'] = [null]; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); }); test('with a too-short sourcesContent', () { - var map = Map.from(EXPECTED_MAP); + var map = Map.from(expectedMap); map['sourcesContent'] = []; var mapping = parseJson(map) as SingleMapping; expect(mapping.files, equals([null])); @@ -416,7 +415,7 @@ void main() { }); test('are parsed from sourcesContent', () { - var map = Map.from(EXPECTED_MAP); + var map = Map.from(expectedMap); map['sourcesContent'] = ['hello, world!']; var mapping = parseJson(map) as SingleMapping; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index fc7991359..3db321dde 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -5,9 +5,11 @@ library test.printer_test; import 'dart:convert'; -import 'package:test/test.dart'; + import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; +import 'package:test/test.dart'; + import 'common.dart'; void main() { @@ -23,15 +25,15 @@ void main() { ..add('y) => ') ..mark(inputExpr) ..add('x + y;\n'); - expect(printer.text, OUTPUT); - expect(printer.map, jsonEncode(EXPECTED_MAP)); + expect(printer.text, outputContent); + expect(printer.map, jsonEncode(expectedMap)); }); test('printer projecting marks', () { - var out = INPUT.replaceAll('long', '_s'); + var out = inputContent.replaceAll('long', '_s'); var printer = Printer('output2.dart'); - var segments = INPUT.split('long'); + var segments = inputContent.split('long'); expect(segments.length, 6); printer ..mark(ispan(0, 0)) @@ -92,8 +94,8 @@ void main() { ..add('y) => ', span: inputVar2) ..add('x + y;\n', span: inputExpr) ..build('output.dart'); - expect(printer.text, OUTPUT); - expect(printer.map, jsonEncode(EXPECTED_MAP)); + expect(printer.text, outputContent); + expect(printer.map, jsonEncode(expectedMap)); }); test('nested use', () { @@ -105,13 +107,13 @@ void main() { ..add(NestedPrinter()..add('y) => ', span: inputVar2)) ..add('x + y;\n', span: inputExpr) ..build('output.dart'); - expect(printer.text, OUTPUT); - expect(printer.map, jsonEncode(EXPECTED_MAP)); + expect(printer.text, outputContent); + expect(printer.map, jsonEncode(expectedMap)); }); test('add indentation', () { - var out = INPUT.replaceAll('long', '_s'); - var lines = INPUT.trim().split('\n'); + var out = inputContent.replaceAll('long', '_s'); + var lines = inputContent.trim().split('\n'); expect(lines.length, 7); var printer = NestedPrinter(); for (var i = 0; i < lines.length; i++) { diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 92a8f4add..5a4f02a73 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -27,20 +27,20 @@ void main() { }); test('only 32-bit ints allowed', () { - var max_int = (pow(2, 31) as int) - 1; - var min_int = -(pow(2, 31) as int); - _checkEncodeDecode(max_int - 1); - _checkEncodeDecode(min_int + 1); - _checkEncodeDecode(max_int); - _checkEncodeDecode(min_int); - - expect(encodeVlq(min_int).join(''), 'hgggggE'); - expect(decodeVlq('hgggggE'.split('').iterator), min_int); - - expect(() => encodeVlq(max_int + 1), throwsA(anything)); - expect(() => encodeVlq(max_int + 2), throwsA(anything)); - expect(() => encodeVlq(min_int - 1), throwsA(anything)); - expect(() => encodeVlq(min_int - 2), throwsA(anything)); + var maxInt = (pow(2, 31) as int) - 1; + var minInt = -(pow(2, 31) as int); + _checkEncodeDecode(maxInt - 1); + _checkEncodeDecode(minInt + 1); + _checkEncodeDecode(maxInt); + _checkEncodeDecode(minInt); + + expect(encodeVlq(minInt).join(''), 'hgggggE'); + expect(decodeVlq('hgggggE'.split('').iterator), minInt); + + expect(() => encodeVlq(maxInt + 1), throwsA(anything)); + expect(() => encodeVlq(maxInt + 2), throwsA(anything)); + expect(() => encodeVlq(minInt - 1), throwsA(anything)); + expect(() => encodeVlq(minInt - 2), throwsA(anything)); // if we allowed more than 32 bits, these would be the expected encodings // for the large numbers above. From a0fdffcb3100ce46cd1533dbd52c9ffaede2e936 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 3 May 2022 22:00:09 +0000 Subject: [PATCH 099/133] populate the pubspec repository field --- pkgs/source_maps/CHANGELOG.md | 3 +++ pkgs/source_maps/README.md | 5 +++-- pkgs/source_maps/pubspec.yaml | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 366dce2e5..dcd04000b 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,5 +1,8 @@ # 0.10.11-dev +- Switch to `package:lints`. +- Populate the pubspec `repository` field. + ## 0.10.10 * Stable release for null safety. diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index 5c7f638f4..89e9eff82 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -1,5 +1,6 @@ -Source Maps -=========== +[![Dart CI](https://github.com/dart-lang/source_maps/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/source_maps/actions/workflows/test-package.yml) +[![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) +[![package publisher](https://img.shields.io/pub/publisher/source_maps.svg)](https://pub.dev/packages/source_maps/publisher) This project implements a Dart pub package to work with source maps. The implementation is based on the [source map version 3 spec][spec] which was diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 23e53a589..b1cb177b5 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,8 +1,7 @@ name: source_maps version: 0.10.11-dev - description: Library to programmatically manipulate source map files. -homepage: https://github.com/dart-lang/source_maps +repository: https://github.com/dart-lang/source_maps environment: sdk: ">=2.12.0 <3.0.0" From 35655f497c5597426790f0552102cf7e34bf0c7b Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 18 Oct 2022 18:30:04 +0000 Subject: [PATCH 100/133] update ci; prep for publishing (dart-lang/source_maps#67) * update ci; prep for publishing * review comments --- pkgs/source_maps/.github/dependabot.yaml | 8 ++++++++ pkgs/source_maps/.github/workflows/test-package.yml | 8 ++++---- pkgs/source_maps/CHANGELOG.md | 5 ++--- pkgs/source_maps/pubspec.yaml | 8 ++++---- 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 pkgs/source_maps/.github/dependabot.yaml diff --git a/pkgs/source_maps/.github/dependabot.yaml b/pkgs/source_maps/.github/dependabot.yaml new file mode 100644 index 000000000..214481934 --- /dev/null +++ b/pkgs/source_maps/.github/dependabot.yaml @@ -0,0 +1,8 @@ +# Dependabot configuration file. +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index e47bf6600..81ebfebcd 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -49,8 +49,8 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index dcd04000b..a282117f6 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,7 +1,6 @@ -# 0.10.11-dev +# 0.10.11 -- Switch to `package:lints`. -- Populate the pubspec `repository` field. +* Populate the pubspec `repository` field. ## 0.10.10 diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index b1cb177b5..e32c27857 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,15 +1,15 @@ name: source_maps -version: 0.10.11-dev +version: 0.10.11 description: Library to programmatically manipulate source map files. repository: https://github.com/dart-lang/source_maps environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.18.0 <3.0.0' dependencies: source_span: ^1.8.0 dev_dependencies: - lints: ^1.0.0 - test: ^1.16.0 + lints: ^2.0.0 term_glyph: ^1.2.0 + test: ^1.16.0 From 512570677b821da576d856bc1a26b5e4173585bc Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 18 Oct 2022 19:48:28 +0000 Subject: [PATCH 101/133] adjust the min sdk we test against (dart-lang/source_maps#68) --- pkgs/source_maps/.github/workflows/test-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 81ebfebcd..d257b9f9c 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.18.0, dev] steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d From 3488a00d49c5691b9d34adc1076efee0d08bf9a3 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 19 Oct 2022 16:41:42 +0000 Subject: [PATCH 102/133] Update README.md (dart-lang/source_maps#69) * Update README.md * update the changelog --- pkgs/source_maps/CHANGELOG.md | 1 + pkgs/source_maps/README.md | 2 +- pkgs/source_maps/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index a282117f6..366501968 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.10.11 * Populate the pubspec `repository` field. +* Update the source map documentation link in the readme. ## 0.10.10 diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index 89e9eff82..e81f2782c 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -26,5 +26,5 @@ Some upcoming features we are planning to add to this package are: instance, if you have 2 tools that produce source maps and you call one with the result of the other. -[closure]: http://code.google.com/p/closure-compiler/wiki/SourceMaps +[closure]: https://github.com/google/closure-compiler/wiki/Source-Maps [spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index e32c27857..eaaa46cd8 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,6 +1,6 @@ name: source_maps version: 0.10.11 -description: Library to programmatically manipulate source map files. +description: A library to programmatically manipulate source map files. repository: https://github.com/dart-lang/source_maps environment: From 03161571970cb7cead716f752c1f1cfa02dfb57a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:12:10 -0800 Subject: [PATCH 103/133] Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/source_maps#70) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index d257b9f9c..265a4f31b 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 9fa02d2ccd2698ceede5dd67ca1bf06eb223d7aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 09:04:54 -0800 Subject: [PATCH 104/133] Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/source_maps#71) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 265a4f31b..54fc2c89e 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From 8ed4c0f54d744366fa322c9ba4238cdc209e4093 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 09:14:18 -0800 Subject: [PATCH 105/133] Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/source_maps#72) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 54fc2c89e..729b3139a 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 82382c6ad371a529e9fe9a17f31754e29abbd220 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 7 Feb 2023 13:59:28 -0800 Subject: [PATCH 106/133] tighten up analysis; add types at the api boundaries (dart-lang/source_maps#73) --- pkgs/source_maps/CHANGELOG.md | 4 ++ pkgs/source_maps/README.md | 15 ++---- pkgs/source_maps/analysis_options.yaml | 6 +-- pkgs/source_maps/lib/builder.dart | 2 +- pkgs/source_maps/lib/parser.dart | 48 ++++++++++--------- pkgs/source_maps/lib/printer.dart | 10 ++-- pkgs/source_maps/lib/refactor.dart | 2 +- pkgs/source_maps/lib/source_maps.dart | 2 +- pkgs/source_maps/lib/src/source_map_span.dart | 4 +- pkgs/source_maps/lib/src/utils.dart | 2 +- pkgs/source_maps/lib/src/vlq.dart | 2 +- pkgs/source_maps/pubspec.yaml | 4 +- pkgs/source_maps/test/parser_test.dart | 2 +- pkgs/source_maps/test/refactor_test.dart | 4 +- pkgs/source_maps/test/utils_test.dart | 8 ++-- pkgs/source_maps/test/vlq_test.dart | 3 +- 16 files changed, 58 insertions(+), 60 deletions(-) diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 366501968..e29a375da 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.10.12 + +* Add additional types at API boundaries. + # 0.10.11 * Populate the pubspec `repository` field. diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index e81f2782c..ad8fd258a 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -2,8 +2,11 @@ [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) [![package publisher](https://img.shields.io/pub/publisher/source_maps.svg)](https://pub.dev/packages/source_maps/publisher) -This project implements a Dart pub package to work with source maps. The -implementation is based on the [source map version 3 spec][spec] which was +This project implements a Dart pub package to work with source maps. + +## Docs and usage + +The implementation is based on the [source map version 3 spec][spec] which was originated from the [Closure Compiler][closure] and has been implemented in Chrome and Firefox. @@ -18,13 +21,5 @@ In this package we provide: * A parser that reads the source map format and provides APIs to read the mapping information. -Some upcoming features we are planning to add to this package are: - - * A printer that lets you generate code, but record source map information in - the process. - * A tool that can compose source maps together. This would be useful for - instance, if you have 2 tools that produce source maps and you call one with - the result of the other. - [closure]: https://github.com/google/closure-compiler/wiki/Source-Maps [spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit diff --git a/pkgs/source_maps/analysis_options.yaml b/pkgs/source_maps/analysis_options.yaml index c09985a51..d978f811c 100644 --- a/pkgs/source_maps/analysis_options.yaml +++ b/pkgs/source_maps/analysis_options.yaml @@ -1,5 +1 @@ -include: package:lints/recommended.yaml - -linter: - rules: - - comment_references +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/source_maps/lib/builder.dart b/pkgs/source_maps/lib/builder.dart index 5c56ca462..54ba7433f 100644 --- a/pkgs/source_maps/lib/builder.dart +++ b/pkgs/source_maps/lib/builder.dart @@ -45,7 +45,7 @@ class SourceMapBuilder { } /// Encodes all mappings added to this builder as a json map. - Map build(String fileUrl) { + Map build(String fileUrl) { return SingleMapping.fromEntries(_entries, fileUrl).toJson(); } diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index e3c7179f9..701a63f1c 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -25,7 +25,7 @@ import 'src/vlq.dart'; // `)]}'` begins the string representation of the map. Mapping parse(String jsonMap, {Map? otherMaps, /*String|Uri*/ Object? mapUrl}) => - parseJson(jsonDecode(jsonMap), otherMaps: otherMaps, mapUrl: mapUrl); + parseJson(jsonDecode(jsonMap) as Map, otherMaps: otherMaps, mapUrl: mapUrl); /// Parses a source map or source map bundle directly from a json string. /// @@ -50,7 +50,7 @@ Mapping parseJsonExtended(/*List|Map*/ Object? json, return parseJson(json as Map); } -/// Parses a source map +/// Parses a source map. /// /// [mapUrl], which may be either a [String] or a [Uri], indicates the URL of /// the source map file itself. If it's passed, any URLs in the source @@ -69,10 +69,10 @@ Mapping parseJson(Map map, throw FormatException('map containing "sections" ' 'cannot contain "mappings", "sources", or "names".'); } - return MultiSectionMapping.fromJson(map['sections'], otherMaps, + return MultiSectionMapping.fromJson(map['sections'] as List, otherMaps, mapUrl: mapUrl); } - return SingleMapping.fromJson(map, mapUrl: mapUrl); + return SingleMapping.fromJson(map.cast(), mapUrl: mapUrl); } /// A mapping parsed out of a source map. @@ -108,21 +108,21 @@ class MultiSectionMapping extends Mapping { /// Creates a section mapping from json. MultiSectionMapping.fromJson(List sections, Map? otherMaps, {/*String|Uri*/ Object? mapUrl}) { - for (var section in sections) { - var offset = section['offset']; + for (var section in sections.cast()) { + var offset = section['offset'] as Map?; if (offset == null) throw FormatException('section missing offset'); - var line = section['offset']['line']; + var line = offset['line'] as int?; if (line == null) throw FormatException('offset missing line'); - var column = section['offset']['column']; + var column = offset['column'] as int?; if (column == null) throw FormatException('offset missing column'); _lineStart.add(line); _columnStart.add(column); - var url = section['url']; - var map = section['map']; + var url = section['url'] as String?; + var map = section['map'] as Map?; if (url != null && map != null) { throw FormatException("section can't use both url and map entries"); @@ -189,7 +189,7 @@ class MappingBundle extends Mapping { MappingBundle.fromJson(List json, {/*String|Uri*/ Object? mapUrl}) { for (var map in json) { - addMapping(parseJson(map, mapUrl: mapUrl) as SingleMapping); + addMapping(parseJson(map as Map, mapUrl: mapUrl) as SingleMapping); } } @@ -342,18 +342,18 @@ class SingleMapping extends Mapping { urls.keys.toList(), names.keys.toList(), lines); } - SingleMapping.fromJson(Map map, {mapUrl}) - : targetUrl = map['file'], - urls = List.from(map['sources']), - names = List.from(map['names'] ?? []), - files = List.filled(map['sources'].length, null), - sourceRoot = map['sourceRoot'], + SingleMapping.fromJson(Map map, {mapUrl}) + : targetUrl = map['file'] as String?, + urls = List.from(map['sources'] as List), + names = List.from((map['names'] as List?) ?? []), + files = List.filled((map['sources'] as List).length, null), + sourceRoot = map['sourceRoot'] as String?, lines = [], - _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl, + _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : (mapUrl as Uri?), extensions = {} { var sourcesContent = map['sourcesContent'] == null ? const [] - : List.from(map['sourcesContent']); + : List.from(map['sourcesContent'] as List); for (var i = 0; i < urls.length && i < sourcesContent.length; i++) { var source = sourcesContent[i]; if (source == null) continue; @@ -366,7 +366,7 @@ class SingleMapping extends Mapping { var srcLine = 0; var srcColumn = 0; var srcNameId = 0; - var tokenizer = _MappingTokenizer(map['mappings']); + var tokenizer = _MappingTokenizer(map['mappings'] as String); var entries = []; while (tokenizer.hasTokens) { @@ -432,7 +432,7 @@ class SingleMapping extends Mapping { /// /// If [includeSourceContents] is `true`, this includes the source file /// contents from [files] in the map if possible. - Map toJson({bool includeSourceContents = false}) { + Map toJson({bool includeSourceContents = false}) { var buff = StringBuffer(); var line = 0; var column = 0; @@ -471,12 +471,12 @@ class SingleMapping extends Mapping { } } - var result = { + var result = { 'version': 3, 'sourceRoot': sourceRoot ?? '', 'sources': urls, 'names': names, - 'mappings': buff.toString() + 'mappings': buff.toString(), }; if (targetUrl != null) result['file'] = targetUrl!; @@ -690,6 +690,8 @@ class _MappingTokenizer implements Iterator { buff.write(''); try { buff.write(current); + // TODO: Determine whether this try / catch can be removed. + // ignore: avoid_catching_errors } on RangeError catch (_) {} buff.write(''); for (var i = index + 1; i < _internal.length; i++) { diff --git a/pkgs/source_maps/lib/printer.dart b/pkgs/source_maps/lib/printer.dart index 7d128f7ec..17733cdd3 100644 --- a/pkgs/source_maps/lib/printer.dart +++ b/pkgs/source_maps/lib/printer.dart @@ -36,7 +36,7 @@ class Printer { /// adds a source map location on each new line, projecting that every new /// line in the target file (printed here) corresponds to a new line in the /// source file. - void add(String str, {projectMarks = false}) { + void add(String str, {bool projectMarks = false}) { var chars = str.runes.toList(); var length = chars.length; for (var i = 0; i < length; i++) { @@ -85,7 +85,7 @@ class Printer { /// [SourceSpan]. When the mark is a [SourceMapSpan] with `isIdentifier` set, /// this also records the name of the identifier in the source map /// information. - void mark(mark) { + void mark(Object mark) { late final SourceLocation loc; String? identifier; if (mark is SourceLocation) { @@ -105,13 +105,13 @@ class Printer { /// including [NestedPrinter]s, and it let's you automatically indent text. /// /// This class is especially useful when doing code generation, where different -/// peices of the code are generated independently on separate printers, and are +/// pieces of the code are generated independently on separate printers, and are /// finally put together in the end. class NestedPrinter implements NestedItem { /// Items recoded by this printer, which can be [String] literals, /// [NestedItem]s, and source map information like [SourceLocation] and /// [SourceSpan]. - final _items = []; + final List _items = []; /// Internal buffer to merge consecutive strings added to this printer. StringBuffer? _buff; @@ -149,7 +149,7 @@ class NestedPrinter implements NestedItem { /// Indicate [isOriginal] when [object] is copied directly from the user code. /// Setting [isOriginal] will make this printer propagate source map locations /// on every line-break. - void add(object, + void add(Object object, {SourceLocation? location, SourceSpan? span, bool isOriginal = false}) { if (object is! String || location != null || span != null || isOriginal) { _flush(); diff --git a/pkgs/source_maps/lib/refactor.dart b/pkgs/source_maps/lib/refactor.dart index 97bd2a708..98e0c9345 100644 --- a/pkgs/source_maps/lib/refactor.dart +++ b/pkgs/source_maps/lib/refactor.dart @@ -30,7 +30,7 @@ class TextEditTransaction { /// Edit the original text, replacing text on the range [begin] and [end] /// with the [replacement]. [replacement] can be either a string or a /// [NestedPrinter]. - void edit(int begin, int end, replacement) { + void edit(int begin, int end, Object replacement) { _edits.add(_TextEdit(begin, end, replacement)); } diff --git a/pkgs/source_maps/lib/source_maps.dart b/pkgs/source_maps/lib/source_maps.dart index 0c6cc084c..58f805a3a 100644 --- a/pkgs/source_maps/lib/source_maps.dart +++ b/pkgs/source_maps/lib/source_maps.dart @@ -28,8 +28,8 @@ library source_maps; import 'package:source_span/source_span.dart'; -import 'parser.dart'; import 'builder.dart'; +import 'parser.dart'; export 'builder.dart'; export 'parser.dart'; diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index 65574ca5e..2840db4e9 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -61,13 +61,13 @@ class SourceMapFileSpan implements SourceMapSpan, FileSpan { @override int compareTo(SourceSpan other) => _inner.compareTo(other); @override - String highlight({color}) => _inner.highlight(color: color); + String highlight({Object? color}) => _inner.highlight(color: color); @override SourceSpan union(SourceSpan other) => _inner.union(other); @override FileSpan expand(FileSpan other) => _inner.expand(other); @override - String message(String message, {color}) => + String message(String message, {Object? color}) => _inner.message(message, color: color); @override String toString() => diff --git a/pkgs/source_maps/lib/src/utils.dart b/pkgs/source_maps/lib/src/utils.dart index eb238342d..f70531e95 100644 --- a/pkgs/source_maps/lib/src/utils.dart +++ b/pkgs/source_maps/lib/src/utils.dart @@ -10,7 +10,7 @@ library source_maps.utils; /// and all items after `n` match too. The result is -1 when there are no /// items, 0 when all items match, and list.length when none does. // TODO(sigmund): remove this function after dartbug.com/5624 is fixed. -int binarySearch(List list, bool Function(dynamic) matches) { +int binarySearch(List list, bool Function(T) matches) { if (list.isEmpty) return -1; if (matches(list.first)) return 0; if (!matches(list.last)) return list.length; diff --git a/pkgs/source_maps/lib/src/vlq.dart b/pkgs/source_maps/lib/src/vlq.dart index 6c41b6e2c..61b476839 100644 --- a/pkgs/source_maps/lib/src/vlq.dart +++ b/pkgs/source_maps/lib/src/vlq.dart @@ -76,7 +76,7 @@ int decodeVlq(Iterator chars) { } stop = (digit & vlqContinuationBit) == 0; digit &= vlqBaseMask; - result += (digit << shift); + result += digit << shift; shift += vlqBaseShift; } diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index eaaa46cd8..f716ef6d0 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.11 +version: 0.10.12 description: A library to programmatically manipulate source map files. repository: https://github.com/dart-lang/source_maps @@ -10,6 +10,6 @@ dependencies: source_span: ^1.8.0 dev_dependencies: - lints: ^2.0.0 + dart_flutter_team_lints: ^0.1.0 term_glyph: ^1.2.0 test: ^1.16.0 diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index 7c7b142bb..cf320b6ef 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -373,7 +373,7 @@ void main() { var mapping = parseJson(map) as SingleMapping; expect(mapping.toJson(), equals(map)); expect(mapping.extensions['x_foo'], equals('a')); - expect(mapping.extensions['x_bar'].first, equals(3)); + expect((mapping.extensions['x_bar'] as List).first, equals(3)); }); group('source files', () { diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 9a403a1b3..0389631dd 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -4,11 +4,11 @@ library polymer.test.refactor_test; -import 'package:test/test.dart'; -import 'package:source_maps/refactor.dart'; import 'package:source_maps/parser.dart' show parse, Mapping; +import 'package:source_maps/refactor.dart'; import 'package:source_span/source_span.dart'; import 'package:term_glyph/term_glyph.dart' as term_glyph; +import 'package:test/test.dart'; void main() { setUpAll(() { diff --git a/pkgs/source_maps/test/utils_test.dart b/pkgs/source_maps/test/utils_test.dart index 3064d6b22..4abdce298 100644 --- a/pkgs/source_maps/test/utils_test.dart +++ b/pkgs/source_maps/test/utils_test.dart @@ -5,8 +5,8 @@ /// Tests for the binary search utility algorithm. library test.utils_test; -import 'package:test/test.dart'; import 'package:source_maps/src/utils.dart'; +import 'package:test/test.dart'; void main() { group('binary search', () { @@ -31,7 +31,7 @@ void main() { test('compare with linear search', () { for (var size = 0; size < 100; size++) { - var list = []; + var list = []; for (var i = 0; i < size; i++) { list.add(i); } @@ -44,8 +44,8 @@ void main() { }); } -int _linearSearch(list, predicate) { - if (list.length == 0) return -1; +int _linearSearch(List list, bool Function(T) predicate) { + if (list.isEmpty) return -1; for (var i = 0; i < list.length; i++) { if (predicate(list[i])) return i; } diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 5a4f02a73..94193007a 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -5,8 +5,9 @@ library test.vlq_test; import 'dart:math'; -import 'package:test/test.dart'; + import 'package:source_maps/src/vlq.dart'; +import 'package:test/test.dart'; void main() { test('encode and decode - simple values', () { From 6555abea194cc1cd10e8ccd52e5286d7278cd4e3 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 16 Feb 2023 17:31:33 -0800 Subject: [PATCH 107/133] configure publishing automation (dart-lang/source_maps#74) * configure publishing automation * update changelog --- pkgs/source_maps/.github/workflows/publish.yaml | 14 ++++++++++++++ pkgs/source_maps/CHANGELOG.md | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 pkgs/source_maps/.github/workflows/publish.yaml diff --git a/pkgs/source_maps/.github/workflows/publish.yaml b/pkgs/source_maps/.github/workflows/publish.yaml new file mode 100644 index 000000000..fcb7ccb89 --- /dev/null +++ b/pkgs/source_maps/.github/workflows/publish.yaml @@ -0,0 +1,14 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ master ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index e29a375da..275d197da 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,8 +1,8 @@ -# 0.10.12 +## 0.10.12 * Add additional types at API boundaries. -# 0.10.11 +## 0.10.11 * Populate the pubspec `repository` field. * Update the source map documentation link in the readme. From cb538c12ed484fd09ed6ae238c35303a6df3f17c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 14:38:56 -0700 Subject: [PATCH 108/133] Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/source_maps#75) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 729b3139a..00edb862a 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From d6d52d64da8619304c4fe8b7baee083e292d865a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 14:41:03 -0700 Subject: [PATCH 109/133] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/source_maps#76) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 00edb862a..bc89aa25e 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From b7769f1b1d66d36138466e9be688e8b6b62a2f56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 11:12:53 -0700 Subject: [PATCH 110/133] Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/source_maps#77) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index bc89aa25e..0acf9e85c 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From cee7105053cb97d17d481070e94fba7c5a28e9fe Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 23 May 2023 10:10:13 -0700 Subject: [PATCH 111/133] blast_repo fixes (dart-lang/source_maps#78) dependabot --- pkgs/source_maps/.github/dependabot.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/source_maps/.github/dependabot.yaml b/pkgs/source_maps/.github/dependabot.yaml index 214481934..439e796b4 100644 --- a/pkgs/source_maps/.github/dependabot.yaml +++ b/pkgs/source_maps/.github/dependabot.yaml @@ -2,7 +2,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From a9e43f06cdd1116fb7170148cbcbb96938723e62 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 12 Jun 2023 08:50:05 -0700 Subject: [PATCH 112/133] Require Dart 3, update lints (dart-lang/source_maps#79) --- pkgs/source_maps/.github/workflows/test-package.yml | 2 +- pkgs/source_maps/CHANGELOG.md | 4 ++++ pkgs/source_maps/README.md | 2 +- pkgs/source_maps/lib/src/source_map_span.dart | 2 -- pkgs/source_maps/pubspec.yaml | 6 +++--- pkgs/source_maps/test/builder_test.dart | 2 -- pkgs/source_maps/test/end2end_test.dart | 2 -- pkgs/source_maps/test/printer_test.dart | 2 -- pkgs/source_maps/test/refactor_test.dart | 4 +--- pkgs/source_maps/test/vlq_test.dart | 2 -- 10 files changed, 10 insertions(+), 18 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 0acf9e85c..1f8243089 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.18.0, dev] + sdk: [3.0.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 275d197da..5afbb6c53 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.13-wip + +- Require Dart 3.0 + ## 0.10.12 * Add additional types at API boundaries. diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index ad8fd258a..30da7f8cd 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -16,7 +16,7 @@ In this package we provide: original source map specification. These data types are great for tracking source locations on source maps, but they can also be used by tools to reporting useful error messages that include on source locations. - * A builder that creates a source map programatically and produces the encoded + * A builder that creates a source map programmatically and produces the encoded source map format. * A parser that reads the source map format and provides APIs to read the mapping information. diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index 2840db4e9..8ca12b96f 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -2,8 +2,6 @@ // 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. -library source_maps.source_map_span; - import 'package:source_span/source_span.dart'; /// A [SourceSpan] for spans coming from or being written to source maps. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index f716ef6d0..4180b8d72 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,15 +1,15 @@ name: source_maps -version: 0.10.12 +version: 0.10.13-wip description: A library to programmatically manipulate source map files. repository: https://github.com/dart-lang/source_maps environment: - sdk: '>=2.18.0 <3.0.0' + sdk: ^3.0.0 dependencies: source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^0.1.0 + dart_flutter_team_lints: ^1.0.0 term_glyph: ^1.2.0 test: ^1.16.0 diff --git a/pkgs/source_maps/test/builder_test.dart b/pkgs/source_maps/test/builder_test.dart index b9bb9c770..4f773e773 100644 --- a/pkgs/source_maps/test/builder_test.dart +++ b/pkgs/source_maps/test/builder_test.dart @@ -2,8 +2,6 @@ // 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. -library test.source_maps_test; - import 'dart:convert'; import 'package:source_maps/source_maps.dart'; diff --git a/pkgs/source_maps/test/end2end_test.dart b/pkgs/source_maps/test/end2end_test.dart index 153fcc286..84dd5badc 100644 --- a/pkgs/source_maps/test/end2end_test.dart +++ b/pkgs/source_maps/test/end2end_test.dart @@ -2,8 +2,6 @@ // 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. -library test.end2end_test; - import 'package:source_maps/source_maps.dart'; import 'package:source_span/source_span.dart'; import 'package:test/test.dart'; diff --git a/pkgs/source_maps/test/printer_test.dart b/pkgs/source_maps/test/printer_test.dart index 3db321dde..89265e36b 100644 --- a/pkgs/source_maps/test/printer_test.dart +++ b/pkgs/source_maps/test/printer_test.dart @@ -2,8 +2,6 @@ // 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. -library test.printer_test; - import 'dart:convert'; import 'package:source_maps/source_maps.dart'; diff --git a/pkgs/source_maps/test/refactor_test.dart b/pkgs/source_maps/test/refactor_test.dart index 0389631dd..5bc3818e5 100644 --- a/pkgs/source_maps/test/refactor_test.dart +++ b/pkgs/source_maps/test/refactor_test.dart @@ -2,9 +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. -library polymer.test.refactor_test; - -import 'package:source_maps/parser.dart' show parse, Mapping; +import 'package:source_maps/parser.dart' show Mapping, parse; import 'package:source_maps/refactor.dart'; import 'package:source_span/source_span.dart'; import 'package:term_glyph/term_glyph.dart' as term_glyph; diff --git a/pkgs/source_maps/test/vlq_test.dart b/pkgs/source_maps/test/vlq_test.dart index 94193007a..4568cffc4 100644 --- a/pkgs/source_maps/test/vlq_test.dart +++ b/pkgs/source_maps/test/vlq_test.dart @@ -2,8 +2,6 @@ // 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. -library test.vlq_test; - import 'dart:math'; import 'package:source_maps/src/vlq.dart'; From 79f9b5519fa3313fc8410037f19870343c835967 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:18:04 +0000 Subject: [PATCH 113/133] Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/source_maps#80) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 1f8243089..325fac8f3 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From cc7051e5cc372cc7af1f024775b2cba6865c4375 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 17:46:04 +0000 Subject: [PATCH 114/133] Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/source_maps#81) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 325fac8f3..6e4f6ec13 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 48bbfc3ca9f8857173e3b92e88d8c33e9cbedd4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:55:17 +0000 Subject: [PATCH 115/133] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/source_maps#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 6e4f6ec13..f476e3586 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From 475b676ce287374ed629175695323c99c7530a47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:37:09 +0000 Subject: [PATCH 116/133] Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/source_maps#83) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index f476e3586..8f5c3b290 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From 423525954dfa317adefcf5c232d0fad30fd682b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:16:06 +0000 Subject: [PATCH 117/133] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/source_maps#85) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 8f5c3b290..cbb07af93 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From 07d324021af0d93d5076a4a89b087ed691aaa1b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:56:40 +0000 Subject: [PATCH 118/133] Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/source_maps#84) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index cbb07af93..38ced1a4f 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} From 07f93debcd8accc838b2cfa7858f9f87b625d4da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:46:57 +0000 Subject: [PATCH 119/133] Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/source_maps#86) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.0 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.0&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 38ced1a4f..84cd3ea5c 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install From d8dfdf346b09787f26f45db95947ceb50750f82a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:44:12 +0000 Subject: [PATCH 120/133] Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/source_maps#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
Release notes

Sourced from actions/checkout's releases.

v4.1.2

We are investigating the following issue with this release and have rolled-back the v4 tag to point to v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.1...v4.1.2

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.1&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 84cd3ea5c..3e522b91d 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From c1e39ed29d384702f9fa928f0b4951db905320ae Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 9 Apr 2024 14:03:20 -0700 Subject: [PATCH 121/133] Bump lints, require Dart 3.3 (dart-lang/source_maps#88) --- .../.github/workflows/test-package.yml | 2 +- pkgs/source_maps/CHANGELOG.md | 2 +- pkgs/source_maps/lib/parser.dart | 17 +++++++++-------- pkgs/source_maps/lib/src/source_map_span.dart | 5 ++--- pkgs/source_maps/pubspec.yaml | 4 ++-- pkgs/source_maps/test/parser_test.dart | 3 +++ 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 3e522b91d..ed86d8fcd 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [3.0.0, dev] + sdk: [3.3.0, dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 5afbb6c53..9c8e7b37e 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.10.13-wip -- Require Dart 3.0 +- Require Dart 3.3 ## 0.10.12 diff --git a/pkgs/source_maps/lib/parser.dart b/pkgs/source_maps/lib/parser.dart index 701a63f1c..b699ac728 100644 --- a/pkgs/source_maps/lib/parser.dart +++ b/pkgs/source_maps/lib/parser.dart @@ -66,7 +66,7 @@ Mapping parseJson(Map map, if (map.containsKey('mappings') || map.containsKey('sources') || map.containsKey('names')) { - throw FormatException('map containing "sections" ' + throw const FormatException('map containing "sections" ' 'cannot contain "mappings", "sources", or "names".'); } return MultiSectionMapping.fromJson(map['sections'] as List, otherMaps, @@ -110,13 +110,13 @@ class MultiSectionMapping extends Mapping { {/*String|Uri*/ Object? mapUrl}) { for (var section in sections.cast()) { var offset = section['offset'] as Map?; - if (offset == null) throw FormatException('section missing offset'); + if (offset == null) throw const FormatException('section missing offset'); var line = offset['line'] as int?; - if (line == null) throw FormatException('offset missing line'); + if (line == null) throw const FormatException('offset missing line'); var column = offset['column'] as int?; - if (column == null) throw FormatException('offset missing column'); + if (column == null) throw const FormatException('offset missing column'); _lineStart.add(line); _columnStart.add(column); @@ -125,7 +125,8 @@ class MultiSectionMapping extends Mapping { var map = section['map'] as Map?; if (url != null && map != null) { - throw FormatException("section can't use both url and map entries"); + throw const FormatException( + "section can't use both url and map entries"); } else if (url != null) { var other = otherMaps?[url]; if (otherMaps == null || other == null) { @@ -137,11 +138,11 @@ class MultiSectionMapping extends Mapping { } else if (map != null) { _maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl)); } else { - throw FormatException('section missing url or map'); + throw const FormatException('section missing url or map'); } } if (_lineStart.isEmpty) { - throw FormatException('expected at least one section'); + throw const FormatException('expected at least one section'); } } @@ -342,7 +343,7 @@ class SingleMapping extends Mapping { urls.keys.toList(), names.keys.toList(), lines); } - SingleMapping.fromJson(Map map, {mapUrl}) + SingleMapping.fromJson(Map map, {Object? mapUrl}) : targetUrl = map['file'] as String?, urls = List.from(map['sources'] as List), names = List.from((map['names'] as List?) ?? []), diff --git a/pkgs/source_maps/lib/src/source_map_span.dart b/pkgs/source_maps/lib/src/source_map_span.dart index 8ca12b96f..aad8a32c6 100644 --- a/pkgs/source_maps/lib/src/source_map_span.dart +++ b/pkgs/source_maps/lib/src/source_map_span.dart @@ -14,9 +14,8 @@ class SourceMapSpan extends SourceSpanBase { /// If this is `true`, [text] is the value of the identifier. final bool isIdentifier; - SourceMapSpan(SourceLocation start, SourceLocation end, String text, - {this.isIdentifier = false}) - : super(start, end, text); + SourceMapSpan(super.start, super.end, super.text, + {this.isIdentifier = false}); /// Creates a [SourceMapSpan] for an identifier with value [text] starting at /// [start]. diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 4180b8d72..fcc99252a 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -4,12 +4,12 @@ description: A library to programmatically manipulate source map files. repository: https://github.com/dart-lang/source_maps environment: - sdk: ^3.0.0 + sdk: ^3.3.0 dependencies: source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 term_glyph: ^1.2.0 test: ^1.16.0 diff --git a/pkgs/source_maps/test/parser_test.dart b/pkgs/source_maps/test/parser_test.dart index cf320b6ef..6cfe928f2 100644 --- a/pkgs/source_maps/test/parser_test.dart +++ b/pkgs/source_maps/test/parser_test.dart @@ -2,6 +2,9 @@ // 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_for_file: inference_failure_on_collection_literal +// ignore_for_file: inference_failure_on_instance_creation + import 'dart:convert'; import 'package:source_maps/source_maps.dart'; From e7f1750b1b6f2aedbc4f3481f8ffe49eceb1c6bd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 9 Apr 2024 14:37:59 -0700 Subject: [PATCH 122/133] blast_repo fixes (dart-lang/source_maps#89) auto-publish, github-actions, no-response --- .../.github/workflows/no-response.yml | 37 +++++++++++++++++++ .../.github/workflows/publish.yaml | 5 ++- .../.github/workflows/test-package.yml | 4 +- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 pkgs/source_maps/.github/workflows/no-response.yml diff --git a/pkgs/source_maps/.github/workflows/no-response.yml b/pkgs/source_maps/.github/workflows/no-response.yml new file mode 100644 index 000000000..ab1ac4984 --- /dev/null +++ b/pkgs/source_maps/.github/workflows/no-response.yml @@ -0,0 +1,37 @@ +# A workflow to close issues where the author hasn't responded to a request for +# more information; see https://github.com/actions/stale. + +name: No Response + +# Run as a daily cron. +on: + schedule: + # Every day at 8am + - cron: '0 8 * * *' + +# All permissions not specified are set to 'none'. +permissions: + issues: write + pull-requests: write + +jobs: + no-response: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dart-lang' }} + steps: + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e + with: + # Don't automatically mark inactive issues+PRs as stale. + days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! diff --git a/pkgs/source_maps/.github/workflows/publish.yaml b/pkgs/source_maps/.github/workflows/publish.yaml index fcb7ccb89..27157a046 100644 --- a/pkgs/source_maps/.github/workflows/publish.yaml +++ b/pkgs/source_maps/.github/workflows/publish.yaml @@ -6,9 +6,12 @@ on: pull_request: branches: [ master ] push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ] + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] jobs: publish: if: ${{ github.repository_owner == 'dart-lang' }} uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index ed86d8fcd..303cc0567 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.3.0, dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 with: sdk: ${{ matrix.sdk }} - id: install From 802e91d389cdaa48544229882e683fbaeb3ebb85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 17:43:04 +0000 Subject: [PATCH 123/133] Bump dart-lang/setup-dart from 1.6.3 to 1.6.4 (dart-lang/source_maps#90) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.3 to 1.6.4.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.4

  • Rebuild JS code to include changes from v1.6.3
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.3&new-version=1.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 303cc0567..2c1a3c837 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.3.0, dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install From ea65ec8d2328bdd20bdb210d5a335c524e5f9329 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 17:50:47 +0000 Subject: [PATCH 124/133] Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/source_maps#91) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.4.
Release notes

Sourced from actions/checkout's releases.

v4.1.4

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.3...v4.1.4

v4.1.3

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.2...v4.1.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.2&new-version=4.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 2c1a3c837..c0ca0d7c4 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From 34ed8f101cc9fe9d1e1c1a2c95b07aeda729218f Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 13 May 2024 10:36:29 -0700 Subject: [PATCH 125/133] blast_repo fixes (dart-lang/source_maps#92) dependabot --- pkgs/source_maps/.github/dependabot.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/source_maps/.github/dependabot.yaml b/pkgs/source_maps/.github/dependabot.yaml index 439e796b4..bf6b38a4d 100644 --- a/pkgs/source_maps/.github/dependabot.yaml +++ b/pkgs/source_maps/.github/dependabot.yaml @@ -8,3 +8,7 @@ updates: interval: monthly labels: - autosubmit + groups: + github-actions: + patterns: + - "*" From 9e7493f33849e7a0e1785a5510a075f19bfb7b0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 17:38:27 +0000 Subject: [PATCH 126/133] Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group (dart-lang/source_maps#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.4 to 4.1.5
Release notes

Sourced from actions/checkout's releases.

v4.1.5

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.4...v4.1.5

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.4&new-version=4.1.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index c0ca0d7c4..dd3d04b81 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From e3e471cfd3e2048b184a6b3e6c5b8f1f33e5e133 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 17:12:26 +0000 Subject: [PATCH 127/133] Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group (dart-lang/source_maps#94) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.5 to 4.1.6
Release notes

Sourced from actions/checkout's releases.

v4.1.6

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.5...v4.1.6

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.5&new-version=4.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index dd3d04b81..b4952c406 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From d904e93868f23ec0508d8e6d7d98b359d4002982 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:52:49 +0000 Subject: [PATCH 128/133] Bump the github-actions group with 2 updates (dart-lang/source_maps#95) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `actions/checkout` from 4.1.6 to 4.1.7
Release notes

Sourced from actions/checkout's releases.

v4.1.7

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.6...v4.1.7

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

... (truncated)

Commits

Updates `dart-lang/setup-dart` from 1.6.4 to 1.6.5
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.5

dart-lang/source_maps#118: dart-lang/setup-dartdart-lang/source_maps#118

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.5

dart-lang/source_maps#118: dart-lang/setup-dartdart-lang/source_maps#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

... (truncated)

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index b4952c406..14bf0d49a 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,8 +49,8 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install From 3e0f94661c29a5650c4b055cc84609e6402e99a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:02:40 +0000 Subject: [PATCH 129/133] Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (dart-lang/source_maps#96) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.7 to 4.2.0
Release notes

Sourced from actions/checkout's releases.

v4.2.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.7...v4.2.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.7&new-version=4.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 14bf0d49a..f8606bf60 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 2f6ae72846656c52a13f6b14298ef003130f2322 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 17:11:48 +0000 Subject: [PATCH 130/133] Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group (dart-lang/source_maps#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.2.0 to 4.2.2
Release notes

Sourced from actions/checkout's releases.

v4.2.2

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.2.1...v4.2.2

v4.2.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.2.0...v4.2.1

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.2

v4.2.1

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.2.0&new-version=4.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index f8606bf60..730278bd1 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.3.0, dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 217ca1846c9fcf70a227fd0be0eddf52cf599eca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 17:18:08 +0000 Subject: [PATCH 131/133] Bump dart-lang/setup-dart in the github-actions group (dart-lang/source_maps#98) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `dart-lang/setup-dart` from 1.6.5 to 1.7.0
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.7.0

What's Changed

  • Install a Flutter SDK in the publish workflow allowing for publication of flutter packages.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.7.0

v1.6.5

dart-lang/source_maps#118: dart-lang/setup-dartdart-lang/source_maps#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.5&new-version=1.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/source_maps/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/pkgs/source_maps/.github/workflows/test-package.yml index 730278bd1..e6f7c8608 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/pkgs/source_maps/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.3.0, dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install From 3453d0edf2d02cf967a5e8e64a29a66b2531fbfb Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 10 Dec 2024 15:52:17 +0100 Subject: [PATCH 132/133] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/source_maps.md | 5 +++++ pkgs/source_maps/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/source_maps.md diff --git a/.github/ISSUE_TEMPLATE/source_maps.md b/.github/ISSUE_TEMPLATE/source_maps.md new file mode 100644 index 000000000..a1e390a75 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/source_maps.md @@ -0,0 +1,5 @@ +--- +name: "package:source_maps" +about: "Create a bug or file a feature request against package:source_maps." +labels: "package:source_maps" +--- \ No newline at end of file diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index fcc99252a..0c321dad9 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,7 +1,7 @@ name: source_maps version: 0.10.13-wip description: A library to programmatically manipulate source map files. -repository: https://github.com/dart-lang/source_maps +repository: https://github.com/dart-lang/tools/tree/main/pkgs/source_maps environment: sdk: ^3.3.0 From e9fad4a676a68a51302c5307e98ae053dec9b6a7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 10 Dec 2024 16:01:53 +0100 Subject: [PATCH 133/133] merge fixes --- .github/labeler.yml | 4 ++ .../workflows/source_maps.yaml | 17 +++++++-- README.md | 1 + pkgs/source_maps/.github/dependabot.yaml | 14 ------- .../.github/workflows/no-response.yml | 37 ------------------- .../.github/workflows/publish.yaml | 17 --------- pkgs/source_maps/CHANGELOG.md | 5 ++- pkgs/source_maps/README.md | 2 +- pkgs/source_maps/pubspec.yaml | 2 +- 9 files changed, 24 insertions(+), 75 deletions(-) rename pkgs/source_maps/.github/workflows/test-package.yml => .github/workflows/source_maps.yaml (84%) delete mode 100644 pkgs/source_maps/.github/dependabot.yaml delete mode 100644 pkgs/source_maps/.github/workflows/no-response.yml delete mode 100644 pkgs/source_maps/.github/workflows/publish.yaml diff --git a/.github/labeler.yml b/.github/labeler.yml index eca80bbc2..4ef83558a 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -84,6 +84,10 @@ - changed-files: - any-glob-to-any-file: 'pkgs/source_map_stack_trace/**' +'package:source_maps': + - changed-files: + - any-glob-to-any-file: 'pkgs/source_maps/**' + 'package:unified_analytics': - changed-files: - any-glob-to-any-file: 'pkgs/unified_analytics/**' diff --git a/pkgs/source_maps/.github/workflows/test-package.yml b/.github/workflows/source_maps.yaml similarity index 84% rename from pkgs/source_maps/.github/workflows/test-package.yml rename to .github/workflows/source_maps.yaml index e6f7c8608..2ae0f20c5 100644 --- a/pkgs/source_maps/.github/workflows/test-package.yml +++ b/.github/workflows/source_maps.yaml @@ -1,17 +1,28 @@ -name: Dart CI +name: package:source_maps on: # Run on PRs and pushes to the default branch. push: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/source_maps.yaml' + - 'pkgs/source_maps/**' pull_request: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/source_maps.yaml' + - 'pkgs/source_maps/**' schedule: - cron: "0 0 * * 0" env: PUB_ENVIRONMENT: bot.github + +defaults: + run: + working-directory: pkgs/source_maps/ + jobs: # Check code formatting and static analysis on a single OS (linux) # against Dart dev. diff --git a/README.md b/README.md index 50517c36e..84b357157 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ don't naturally belong to other topic monorepos (like | [mime](pkgs/mime/) | Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. | [![package issues](https://img.shields.io/badge/package:mime-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Amime) | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) | | [oauth2](pkgs/oauth2/) | A client library for authenticating with a remote service via OAuth2 on behalf of a user, and making authorized HTTP requests with the user's OAuth2 credentials. | [![package issues](https://img.shields.io/badge/package:oauth2-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aoauth2) | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) | | [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![package issues](https://img.shields.io/badge/package:source_map_stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_map_stack_trace) | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) | +| [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) | | [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) | ## Publishing automation diff --git a/pkgs/source_maps/.github/dependabot.yaml b/pkgs/source_maps/.github/dependabot.yaml deleted file mode 100644 index bf6b38a4d..000000000 --- a/pkgs/source_maps/.github/dependabot.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Dependabot configuration file. -version: 2 - -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit - groups: - github-actions: - patterns: - - "*" diff --git a/pkgs/source_maps/.github/workflows/no-response.yml b/pkgs/source_maps/.github/workflows/no-response.yml deleted file mode 100644 index ab1ac4984..000000000 --- a/pkgs/source_maps/.github/workflows/no-response.yml +++ /dev/null @@ -1,37 +0,0 @@ -# A workflow to close issues where the author hasn't responded to a request for -# more information; see https://github.com/actions/stale. - -name: No Response - -# Run as a daily cron. -on: - schedule: - # Every day at 8am - - cron: '0 8 * * *' - -# All permissions not specified are set to 'none'. -permissions: - issues: write - pull-requests: write - -jobs: - no-response: - runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dart-lang' }} - steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e - with: - # Don't automatically mark inactive issues+PRs as stale. - days-before-stale: -1 - # Close needs-info issues and PRs after 14 days of inactivity. - days-before-close: 14 - stale-issue-label: "needs-info" - close-issue-message: > - Without additional information we're not able to resolve this issue. - Feel free to add more info or respond to any questions above and we - can reopen the case. Thanks for your contribution! - stale-pr-label: "needs-info" - close-pr-message: > - Without additional information we're not able to resolve this PR. - Feel free to add more info or respond to any questions above. - Thanks for your contribution! diff --git a/pkgs/source_maps/.github/workflows/publish.yaml b/pkgs/source_maps/.github/workflows/publish.yaml deleted file mode 100644 index 27157a046..000000000 --- a/pkgs/source_maps/.github/workflows/publish.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# A CI configuration to auto-publish pub packages. - -name: Publish - -on: - pull_request: - branches: [ master ] - push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] - -jobs: - publish: - if: ${{ github.repository_owner == 'dart-lang' }} - uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main - permissions: - id-token: write # Required for authentication using OIDC - pull-requests: write # Required for writing the pull request note diff --git a/pkgs/source_maps/CHANGELOG.md b/pkgs/source_maps/CHANGELOG.md index 9c8e7b37e..ae7711e57 100644 --- a/pkgs/source_maps/CHANGELOG.md +++ b/pkgs/source_maps/CHANGELOG.md @@ -1,6 +1,7 @@ -## 0.10.13-wip +## 0.10.13 -- Require Dart 3.3 +* Require Dart 3.3 +* Move to `dart-lang/tools` monorepo. ## 0.10.12 diff --git a/pkgs/source_maps/README.md b/pkgs/source_maps/README.md index 30da7f8cd..cf8029177 100644 --- a/pkgs/source_maps/README.md +++ b/pkgs/source_maps/README.md @@ -1,4 +1,4 @@ -[![Dart CI](https://github.com/dart-lang/source_maps/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/source_maps/actions/workflows/test-package.yml) +[![Build Status](https://github.com/dart-lang/tools/actions/workflows/source_maps.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/source_maps.yaml) [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) [![package publisher](https://img.shields.io/pub/publisher/source_maps.svg)](https://pub.dev/packages/source_maps/publisher) diff --git a/pkgs/source_maps/pubspec.yaml b/pkgs/source_maps/pubspec.yaml index 0c321dad9..8518fa756 100644 --- a/pkgs/source_maps/pubspec.yaml +++ b/pkgs/source_maps/pubspec.yaml @@ -1,5 +1,5 @@ name: source_maps -version: 0.10.13-wip +version: 0.10.13 description: A library to programmatically manipulate source map files. repository: https://github.com/dart-lang/tools/tree/main/pkgs/source_maps