OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:math' as math; | 6 import 'dart:math' as math; |
7 | 7 |
8 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; | 8 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; |
9 import 'package:source_span/source_span.dart'; | 9 import 'package:source_span/source_span.dart'; |
10 | 10 |
11 import 'breakpoint.dart'; | 11 import 'breakpoint.dart'; |
12 import 'class.dart'; | 12 import 'class.dart'; |
13 import 'library.dart'; | 13 import 'library.dart'; |
14 import 'object.dart'; | 14 import 'object.dart'; |
15 import 'scope.dart'; | 15 import 'scope.dart'; |
16 import 'source_location.dart'; | 16 import 'source_location.dart'; |
17 import 'source_report.dart'; | |
17 | 18 |
18 VMScriptRef newVMScriptRef(Scope scope, Map json) { | 19 VMScriptRef newVMScriptRef(Scope scope, Map json) { |
19 if (json == null) return null; | 20 if (json == null) return null; |
20 assert(json["type"] == "@Script" || json["type"] == "Script"); | 21 assert(json["type"] == "@Script" || json["type"] == "Script"); |
21 return new VMScriptRef._(scope, json); | 22 return new VMScriptRef._(scope, json); |
22 } | 23 } |
23 | 24 |
24 VMScriptToken newVMScriptToken(String isolateId, String scriptId, | 25 VMScriptToken newVMScriptToken(String isolateId, String scriptId, |
25 int position) { | 26 int position) { |
26 if (position == null) return null; | 27 if (position == null) return null; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 try { | 62 try { |
62 var response = await _scope.sendRequest("addBreakpoint", params); | 63 var response = await _scope.sendRequest("addBreakpoint", params); |
63 return newVMBreakpoint(_scope, response); | 64 return newVMBreakpoint(_scope, response); |
64 } on rpc.RpcException catch (error) { | 65 } on rpc.RpcException catch (error) { |
65 // Error 102 indicates that the breakpoint couldn't be created. | 66 // Error 102 indicates that the breakpoint couldn't be created. |
66 if (error.code == 102) return null; | 67 if (error.code == 102) return null; |
67 rethrow; | 68 rethrow; |
68 } | 69 } |
69 } | 70 } |
70 | 71 |
72 /// Generates a set of reports tied to this script. | |
73 /// | |
74 /// Set [includeCoverageReport] to `true` to include code coverage | |
75 /// information. | |
76 /// | |
77 /// Set [includePossibleBreakpoints] to `true` to provide a list of token | |
78 /// positions which correspond to possible breakpoints. | |
79 /// | |
80 /// Either or both of the [tokenPos] and [endTokenPos] parameters may be | |
81 /// provided to restrict the analysis to a subrange of a script | |
82 /// (for example, these can be used to restrict the report to the range of a | |
83 /// particular class or function). | |
84 /// | |
85 /// Set [forceCompilation] to `true` to force compilation of all functions in | |
86 /// the range of the report. | |
87 /// Forcing compilation can cause a compilation error, which could terminate | |
88 /// the running Dart program. | |
89 Future<VMSourceReport> getSourceReport( | |
90 {bool includeCoverageReport, | |
91 bool includePossibleBreakpoints, | |
92 int tokenPos, | |
93 int endTokenPos, | |
nweiz
2016/04/29 00:52:43
These should come after [forceCompile]. That way t
kevmoo
2016/04/29 23:36:54
Done
nweiz
2016/05/04 23:05:51
I don't understand how users would possibly get in
kevmoo
2016/05/05 20:46:25
This was fixed – now uses tokens
nweiz
2016/05/11 23:03:30
What I'm saying is that it should take a single So
kevmoo
2016/05/12 05:22:34
But one cannot create a SourceLocation from whole
nweiz
2016/05/17 20:54:41
That is not a use-case I'm concerned about.
I'm t
kevmoo
2016/05/17 22:12:01
Acknowledged.
| |
94 bool forceCompile}) async { | |
95 var reports = <String>[]; | |
96 if (includeCoverageReport == true) { | |
97 reports.add('Coverage'); | |
98 } | |
99 | |
100 if (includePossibleBreakpoints == true) { | |
101 reports.add('PossibleBreakpoints'); | |
102 } | |
103 | |
104 var params = <String, dynamic>{'reports': reports, 'scriptId': _id}; | |
105 | |
106 if (tokenPos != null) { | |
107 params['tokenPos'] = tokenPos; | |
108 } | |
109 | |
110 if (endTokenPos != null) { | |
111 params['endTokenPos'] = endTokenPos; | |
112 } | |
113 | |
114 var json = await _scope.sendRequest('getSourceReport', params); | |
115 | |
116 return newSourceReport(_scope, json); | |
117 } | |
nweiz
2016/04/29 00:52:43
Most of the same comments for the other method app
kevmoo
2016/04/29 23:36:54
Acknowledged.
| |
118 | |
71 bool operator ==(other) => other is VMScriptRef && | 119 bool operator ==(other) => other is VMScriptRef && |
72 (_fixedId ? _id == other._id : super == other); | 120 (_fixedId ? _id == other._id : super == other); |
73 | 121 |
74 int get hashCode => _fixedId ? _id.hashCode : super.hashCode; | 122 int get hashCode => _fixedId ? _id.hashCode : super.hashCode; |
75 | 123 |
76 String toString() => uri.toString(); | 124 String toString() => uri.toString(); |
77 } | 125 } |
78 | 126 |
79 /// A script in the Dart VM. | 127 /// A script in the Dart VM. |
80 class VMScript extends VMScriptRef implements VMObject { | 128 class VMScript extends VMScriptRef implements VMObject { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 var start = math.min(this._start, other._start); | 355 var start = math.min(this._start, other._start); |
308 var end = math.max(this._end, other._end); | 356 var end = math.max(this._end, other._end); |
309 return new _ScriptSpan(_script, start, end); | 357 return new _ScriptSpan(_script, start, end); |
310 } else { | 358 } else { |
311 var start = math.min(this._start, other.start.offset); | 359 var start = math.min(this._start, other.start.offset); |
312 var end = math.max(this._end, other.end.offset); | 360 var end = math.max(this._end, other.end.offset); |
313 return file.span(start, end); | 361 return file.span(start, end); |
314 } | 362 } |
315 } | 363 } |
316 } | 364 } |
OLD | NEW |