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 'breakpoint.dart'; | 5 import 'breakpoint.dart'; |
6 import 'scope.dart'; | 6 import 'scope.dart'; |
7 import 'script.dart'; | 7 import 'script.dart'; |
8 | 8 |
9 VMSourceLocation newVMSourceLocation(Scope scope, | 9 VMSourceLocation newVMSourceLocation(Scope scope, Map json) { |
10 Map json) { | |
11 if (json == null) return null; | 10 if (json == null) return null; |
12 assert(json["type"] == "SourceLocation"); | 11 assert(json["type"] == "SourceLocation"); |
13 return new VMSourceLocation._(scope, json); | 12 |
13 var script = newVMScriptRef(scope, json["script"]); | |
14 return new VMSourceLocation._(script, json["tokenPos"], json["endTokenPos"]); | |
14 } | 15 } |
15 | 16 |
17 VMSourceLocation newVMSourceLocationFromLocation( | |
nweiz
2016/05/04 23:05:51
Similarly, I'd call this "FromPositions".
kevmoo
2016/05/05 20:46:26
Done.
| |
18 VMScriptRef script, int tokenPos, int endTokenPos) => | |
nweiz
2016/05/04 23:05:51
Indent +4.
kevmoo
2016/05/05 20:46:26
Done.
| |
19 new VMSourceLocation._(script, tokenPos, endTokenPos); | |
20 | |
16 /// A location or span of code in a Dart script. | 21 /// A location or span of code in a Dart script. |
17 class VMSourceLocation implements VMBreakpointLocation { | 22 class VMSourceLocation implements VMBreakpointLocation { |
18 /// The script containing the source location. | 23 /// The script containing the source location. |
19 final VMScriptRef script; | 24 final VMScriptRef script; |
20 | 25 |
21 /// The canonical source URI of [script]. | 26 /// The canonical source URI of [script]. |
22 Uri get uri => script.uri; | 27 Uri get uri => script.uri; |
23 | 28 |
24 /// If this is a span, this represents the start of that span. | 29 /// If this is a span, this represents the start of that span. |
25 final VMScriptToken token; | 30 final VMScriptToken token; |
26 | 31 |
27 /// The final token of the location, or `null` if this is not a span. | 32 /// The final token of the location, or `null` if this is not a span. |
28 final VMScriptToken end; | 33 final VMScriptToken end; |
29 | 34 |
30 VMSourceLocation._(Scope scope, Map json) | 35 VMSourceLocation._(VMScriptRef script, int tokenPos, int endTokenPos) |
nweiz
2016/05/04 23:05:51
Rather than changing the calling convention for th
kevmoo
2016/05/05 20:46:26
Done.
| |
31 : script = newVMScriptRef(scope, json["script"]), | 36 : this.script = script, |
32 token = newVMScriptToken( | 37 token = newVMScriptTokenFromScript(script, tokenPos), |
33 scope.isolateId, json["script"]["id"], json["tokenPos"]), | 38 end = newVMScriptTokenFromScript(script, endTokenPos); |
34 end = newVMScriptToken( | |
35 scope.isolateId, json["script"]["id"], json["endTokenPos"]); | |
36 | 39 |
37 String toString() => | 40 String toString() => |
38 end == null ? "$script at $token" : "$script from $token to $end"; | 41 end == null ? "$script at $token" : "$script from $token to $end"; |
39 } | 42 } |
OLD | NEW |