| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// A library with code coverage models. | 5 /// A library with code coverage models. |
| 6 library runtime.coverage.model; | 6 library runtime.coverage.model; |
| 7 | 7 |
| 8 import 'dart:collection' show SplayTreeMap; | 8 import 'dart:collection' show SplayTreeMap; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/source.dart' show Source, SourceRange; | 10 import 'package:analyzer/src/generated/source.dart' show Source, SourceRange; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 sink.writeln('$prefix "children": {'); | 82 sink.writeln('$prefix "children": {'); |
| 83 children.fold(null, (prev, child) { | 83 children.fold(null, (prev, child) { |
| 84 if (prev != null) sink.writeln(','); | 84 if (prev != null) sink.writeln(','); |
| 85 return child..write(sink, executedIds, '$prefix '); | 85 return child..write(sink, executedIds, '$prefix '); |
| 86 }); | 86 }); |
| 87 sink.writeln(); | 87 sink.writeln(); |
| 88 sink.writeln('$prefix }'); | 88 sink.writeln('$prefix }'); |
| 89 } | 89 } |
| 90 // Print source and line ranges. | 90 // Print source and line ranges. |
| 91 if (children.isEmpty) { | 91 if (children.isEmpty) { |
| 92 sink.write('${prefix} "ranges": ['); | 92 sink.write('$prefix "ranges": ['); |
| 93 var rangePrinter = new RangePrinter(unit, sink, executedIds); | 93 var rangePrinter = new RangePrinter(unit, sink, executedIds); |
| 94 idToRange.forEach(rangePrinter.handle); | 94 idToRange.forEach(rangePrinter.handle); |
| 95 rangePrinter.printRange(); | 95 rangePrinter.printRange(); |
| 96 sink.writeln(']'); | 96 sink.writeln(']'); |
| 97 } | 97 } |
| 98 // Close this node. | 98 // Close this node. |
| 99 sink.write('$prefix}'); | 99 sink.write('$prefix}'); |
| 100 } | 100 } |
| 101 | 101 |
| 102 UnitInfo get unit => parent.unit; | 102 UnitInfo get unit => parent.unit; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 : super(appInfo, null, 'unit', path) { | 159 : super(appInfo, null, 'unit', path) { |
| 160 lineOffsets = getLineOffsets(content); | 160 lineOffsets = getLineOffsets(content); |
| 161 } | 161 } |
| 162 | 162 |
| 163 UnitInfo get unit => this; | 163 UnitInfo get unit => this; |
| 164 | 164 |
| 165 int getLine(int offset) { | 165 int getLine(int offset) { |
| 166 return binarySearch(lineOffsets, (x) => x >= offset); | 166 return binarySearch(lineOffsets, (x) => x >= offset); |
| 167 } | 167 } |
| 168 } | 168 } |
| OLD | NEW |