Skip to content

Commit

Permalink
allow null to be returned from the Chrome sourceUriProvider (#333)
Browse files Browse the repository at this point in the history
This was an incorrect migration originally it looks like, the test package returns null in a few different cases and it was previously handled a bit weirdly (adding entries with a null key). Now these are explicitly skipped.
  • Loading branch information
jakemac53 committed Mar 2, 2021
1 parent 85141b7 commit 92ab6ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1 - 2021-02-25

* Allow the chrome `sourceUriProvider` to return `null`.

## 1.0.0 - 2021-02-25

* Migrate to null safety.
Expand Down
5 changes: 3 additions & 2 deletions lib/src/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import 'package:source_maps/parser.dart';
/// scriptId, or null if not available.
///
/// [sourceUriProvider] returns the uri for the provided sourceUrl and
/// associated scriptId.
/// associated scriptId, or null if not available.
///
/// Chrome coverage information for which the corresponding source map or source
/// content is null will be ignored.
Future<Map<String, dynamic>> parseChromeCoverage(
List<Map<String, dynamic>> preciseCoverage,
Future<String?> Function(String scriptId) sourceProvider,
Future<String?> Function(String scriptId) sourceMapProvider,
Future<Uri> Function(String sourceUrl, String scriptId) sourceUriProvider,
Future<Uri?> Function(String sourceUrl, String scriptId) sourceUriProvider,
) async {
final coverageReport = <Uri, Map<int, bool>>{};
for (var entry in preciseCoverage) {
Expand Down Expand Up @@ -58,6 +58,7 @@ Future<Map<String, dynamic>> parseChromeCoverage(
if (sourceUrl.startsWith('org-dartlang-sdk:')) continue;

final uri = await sourceUriProvider(sourceUrl, scriptId);
if (uri == null) continue;
final coverage = coverageReport.putIfAbsent(uri, () => <int, bool>{});

final sourceLine = columnEntry.sourceLine!;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: coverage
version: 1.0.0
version: 1.0.1
description: Coverage data manipulation and formatting
homepage: https://github.com/dart-lang/coverage

Expand Down

0 comments on commit 92ab6ea

Please sign in to comment.