Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'script.dart'; | |
| 6 import 'scope.dart'; | |
| 7 import 'source_location.dart'; | |
| 8 | |
| 9 List<VMScriptToken> _getTokens(VMScriptRef script, Iterable<int> locations) { | |
|
nweiz
2016/05/04 23:05:52
Make this a static method in VMSourceReport—that h
kevmoo
2016/05/05 20:46:27
Done.
| |
| 10 if (locations == null) return null; | |
| 11 | |
| 12 return new List<VMScriptToken>.unmodifiable( | |
| 13 locations.map((i) => newVMScriptTokenFromScript(script, i))); | |
|
nweiz
2016/05/04 23:05:52
"i" -> "location" (or "position")
kevmoo
2016/05/05 20:46:26
Done.
| |
| 14 } | |
| 15 | |
| 16 VMSourceReport newSourceReport(Scope scope, Map json) { | |
| 17 if (json == null) return null; | |
| 18 assert(json["type"] == "SourceReport"); | |
| 19 | |
| 20 var scripts = (json['scripts'] as List) | |
| 21 .map((scriptItem) => newVMScriptRef(scope, scriptItem)) | |
|
nweiz
2016/05/04 23:05:52
Just call this variable "script", like in the othe
kevmoo
2016/05/05 20:46:26
Done.
| |
| 22 .toList(); | |
| 23 | |
| 24 var ranges = new List<VMSourceReportRange>.unmodifiable( | |
| 25 (json['ranges'] as List) | |
| 26 .map((rangeItem) => _newSourceReportRange(rangeItem, scripts))); | |
|
nweiz
2016/05/04 23:05:52
Don't do actual work in the "new*" functions. It m
kevmoo
2016/05/05 20:46:26
Acknowledged.
nweiz
2016/05/11 23:03:31
It doesn't look like this was addressed.
| |
| 27 | |
| 28 return new VMSourceReport._(ranges); | |
| 29 } | |
| 30 | |
| 31 VMSourceReportRange _newSourceReportRange(Map json, List<VMScriptRef> scripts) { | |
| 32 if (json == null) return null; | |
| 33 | |
| 34 var script = scripts[json['scriptIndex']]; | |
| 35 | |
| 36 var location = | |
| 37 newVMSourceLocationFromLocation(script, json['startPos'], json['endPos']); | |
| 38 | |
| 39 return new VMSourceReportRange._(json, script, location); | |
| 40 } | |
| 41 | |
| 42 /// A report about ranges of source code. | |
| 43 /// | |
| 44 /// [ranges] exposes code coverage and information on possible breakpoints. | |
| 45 class VMSourceReport { | |
| 46 /// Ranges in the program source corresponding | |
| 47 /// to ranges of executable code in the user's program (functions, | |
| 48 /// methods, constructors, etc.) | |
|
nweiz
2016/05/04 23:05:52
Avoid abbreviations like "etc" (https://www.dartla
kevmoo
2016/05/05 20:46:26
Done.
| |
| 49 /// | |
| 50 /// Note: | |
| 51 /// * ranges may nest in other ranges, in the case of nested | |
| 52 /// functions. | |
| 53 /// * ranges may be duplicated, in the case of mixins. | |
|
nweiz
2016/05/04 23:05:52
I think bulleted lists are generally harder to rea
kevmoo
2016/05/05 20:46:26
Replaced with sentences.
| |
| 54 final List<VMSourceReportRange> ranges; | |
| 55 | |
| 56 VMSourceReport._(this.ranges); | |
| 57 } | |
| 58 | |
| 59 /// A range of executable code (function, method, constructor, etc) | |
| 60 /// in the running program. | |
| 61 /// | |
| 62 /// This is part of a [VMSourceReport]. | |
| 63 class VMSourceReportRange { | |
| 64 VMScriptRef get script => location.script; | |
|
nweiz
2016/05/04 23:05:52
Document all public members.
kevmoo
2016/05/05 20:46:27
Done.
nweiz
2016/05/11 23:03:31
This member is still not documented.
| |
| 65 | |
| 66 final VMSourceLocation location; | |
| 67 | |
| 68 /// `true` if this range been compiled by the Dart VM. | |
|
nweiz
2016/05/04 23:05:52
I like to say "Whether" rather than "`true` if" to
kevmoo
2016/05/05 20:46:27
Acknowledged.
| |
| 69 /// | |
| 70 /// If `false`, `possibleBreakpoints`, `hits`, and `misses` will be `null`. | |
| 71 /// | |
| 72 /// Use `forceCompile` in `getSourceReport` to ensure the target scripts are | |
|
nweiz
2016/05/04 23:05:52
Make "getSourceReport" a link. Also below.
kevmoo
2016/05/05 20:46:26
I didn't do this intentionally – since there are t
nweiz
2016/05/11 23:03:31
Linking to one of them is way better than linking
| |
| 73 /// compiled. | |
| 74 final bool compiled; | |
| 75 | |
| 76 /// Token locations at which breakpoints can be set. | |
|
nweiz
2016/05/04 23:05:52
"Token locations" -> "Token positions"
kevmoo
2016/05/05 20:46:26
Done.
| |
| 77 /// | |
| 78 /// Provided only when the when the `includePossibleBreakpoints` in | |
|
nweiz
2016/05/04 23:05:52
Remove "the".
kevmoo
2016/05/05 20:46:26
Done.
| |
| 79 /// `getSourceReport` is `true` and the range has been compiled. | |
| 80 final List<VMScriptToken> possibleBreakpoints; | |
| 81 | |
| 82 /// A sorted list of token positions in a [VMSourceReportRang] which have been | |
|
nweiz
2016/05/04 23:05:52
"Rang" -> "Range"
kevmoo
2016/05/05 20:46:26
Done.
| |
| 83 /// executed. | |
| 84 /// | |
| 85 /// Provided only when the when the `includeCoverageReport` in | |
|
nweiz
2016/05/04 23:05:52
Remove "the"
kevmoo
2016/05/05 20:46:26
Done.
| |
| 86 /// `getSourceReport` is `true` and the range has been compiled. | |
| 87 final List<VMScriptToken> hits; | |
| 88 | |
| 89 /// A sorted list of token positions in a [VMSourceReportRange] which have not | |
| 90 /// yet been executed. | |
| 91 /// | |
| 92 /// Provided only when the | |
|
nweiz
2016/05/04 23:05:52
Remove "the"
kevmoo
2016/05/05 20:46:26
Done.
| |
| 93 /// `includeCoverageReport` is true and the range has been | |
| 94 /// compiled. | |
| 95 final List<VMScriptToken> misses; | |
| 96 | |
| 97 VMSourceReportRange._(Map json, VMScriptRef script, this.location) | |
| 98 : compiled = json['compiled'], | |
| 99 hits = json['coverage'] == null | |
| 100 ? null | |
| 101 : _getTokens(script, json['coverage']['hits']), | |
| 102 misses = json['coverage'] == null | |
| 103 ? null | |
| 104 : _getTokens(script, json['coverage']['misses']), | |
| 105 possibleBreakpoints = json['possibleBreakpoints'] == null | |
| 106 ? null | |
| 107 : _getTokens(script, json['possibleBreakpoints']); | |
| 108 } | |
| OLD | NEW |