OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of service; | 5 part of service; |
6 | 6 |
7 /// Helper function for canceling a Future<StreamSubscription>. | 7 /// Helper function for canceling a Future<StreamSubscription>. |
8 Future cancelFutureSubscription( | 8 Future cancelFutureSubscription( |
9 Future<StreamSubscription> subscriptionFuture) async { | 9 Future<StreamSubscription> subscriptionFuture) async { |
10 if (subscriptionFuture != null) { | 10 if (subscriptionFuture != null) { |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 abstract class ServiceObjectOwner extends ServiceObject { | 422 abstract class ServiceObjectOwner extends ServiceObject { |
423 /// Creates an empty [ServiceObjectOwner]. | 423 /// Creates an empty [ServiceObjectOwner]. |
424 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); | 424 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); |
425 | 425 |
426 /// Builds a [ServiceObject] corresponding to the [id] from [map]. | 426 /// Builds a [ServiceObject] corresponding to the [id] from [map]. |
427 /// The result may come from the cache. The result will not necessarily | 427 /// The result may come from the cache. The result will not necessarily |
428 /// be [loaded]. | 428 /// be [loaded]. |
429 ServiceObject getFromMap(ObservableMap map); | 429 ServiceObject getFromMap(ObservableMap map); |
430 } | 430 } |
431 | 431 |
432 abstract class Location { | |
433 Script get script; | |
434 int get tokenPos; | |
435 } | |
436 | |
432 /// A [SourceLocation] represents a location or range in the source code. | 437 /// A [SourceLocation] represents a location or range in the source code. |
433 class SourceLocation extends ServiceObject { | 438 class SourceLocation extends ServiceObject implements Location { |
434 Script script; | 439 Script script; |
435 int tokenPos; | 440 int tokenPos; |
436 int endTokenPos; | 441 int endTokenPos; |
437 | 442 |
438 Future<int> getLine() async { | 443 Future<int> getLine() async { |
439 await script.load(); | 444 await script.load(); |
440 return script.tokenToLine(tokenPos); | 445 return script.tokenToLine(tokenPos); |
441 } | 446 } |
442 | 447 |
443 Future<int> getColumn() async { | 448 Future<int> getColumn() async { |
(...skipping 23 matching lines...) Expand all Loading... | |
467 if (endTokenPos == null) { | 472 if (endTokenPos == null) { |
468 return '${script.name}:token(${tokenPos})'; | 473 return '${script.name}:token(${tokenPos})'; |
469 } else { | 474 } else { |
470 return '${script.name}:tokens(${tokenPos}-${endTokenPos})'; | 475 return '${script.name}:tokens(${tokenPos}-${endTokenPos})'; |
471 } | 476 } |
472 } | 477 } |
473 } | 478 } |
474 | 479 |
475 /// An [UnresolvedSourceLocation] represents a location in the source | 480 /// An [UnresolvedSourceLocation] represents a location in the source |
476 // code which has not been precisely mapped to a token position. | 481 // code which has not been precisely mapped to a token position. |
477 class UnresolvedSourceLocation extends ServiceObject { | 482 class UnresolvedSourceLocation extends ServiceObject implements Location { |
478 Script script; | 483 Script script; |
479 String scriptUri; | 484 String scriptUri; |
480 int line; | 485 int line; |
481 int column; | 486 int column; |
482 int tokenPos; | 487 int tokenPos; |
483 | 488 |
484 Future<int> getLine() async { | 489 Future<int> getLine() async { |
485 if (tokenPos != null) { | 490 if (tokenPos != null) { |
486 await script.load(); | 491 await script.load(); |
487 return script.tokenToLine(tokenPos); | 492 return script.tokenToLine(tokenPos); |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1495 // TODO(turnidge): Pass line as an int instead of a string. | 1500 // TODO(turnidge): Pass line as an int instead of a string. |
1496 try { | 1501 try { |
1497 Map params = { | 1502 Map params = { |
1498 'scriptId': script.id, | 1503 'scriptId': script.id, |
1499 'line': line.toString(), | 1504 'line': line.toString(), |
1500 }; | 1505 }; |
1501 if (col != null) { | 1506 if (col != null) { |
1502 params['column'] = col.toString(); | 1507 params['column'] = col.toString(); |
1503 } | 1508 } |
1504 Breakpoint bpt = await invokeRpc('addBreakpoint', params); | 1509 Breakpoint bpt = await invokeRpc('addBreakpoint', params); |
1505 if (bpt.resolved && | 1510 if (bpt.resolved && script.loaded) { |
1506 script.loaded && | 1511 SourceLocation loc = bpt.location; |
Ivan Posva
2015/09/09 17:09:27
Was this change still needed after adding the Loca
| |
1507 script.tokenToLine(bpt.location.tokenPos) != line) { | 1512 if (script.tokenToLine(loc.tokenPos) != line) { |
1508 // TODO(turnidge): Can this still happen? | 1513 script.getLine(line).possibleBpt = false; |
1509 script.getLine(line).possibleBpt = false; | 1514 } |
1510 } | 1515 } |
1511 return bpt; | 1516 return bpt; |
1512 } on ServerRpcException catch(e) { | 1517 } on ServerRpcException catch(e) { |
1513 if (e.code == ServerRpcException.kCannotAddBreakpoint) { | 1518 if (e.code == ServerRpcException.kCannotAddBreakpoint) { |
1514 // Unable to set a breakpoint at the desired line. | 1519 // Unable to set a breakpoint at the desired line. |
1515 script.getLine(line).possibleBpt = false; | 1520 script.getLine(line).possibleBpt = false; |
1516 } | 1521 } |
1517 rethrow; | 1522 rethrow; |
1518 } | 1523 } |
1519 } | 1524 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1965 | 1970 |
1966 // TODO(turnidge): Add state to track if a breakpoint has been | 1971 // TODO(turnidge): Add state to track if a breakpoint has been |
1967 // removed from the program. Remove from the cache when deleted. | 1972 // removed from the program. Remove from the cache when deleted. |
1968 bool get canCache => true; | 1973 bool get canCache => true; |
1969 bool get immutable => false; | 1974 bool get immutable => false; |
1970 | 1975 |
1971 // A unique integer identifier for this breakpoint. | 1976 // A unique integer identifier for this breakpoint. |
1972 @observable int number; | 1977 @observable int number; |
1973 | 1978 |
1974 // Either SourceLocation or UnresolvedSourceLocation. | 1979 // Either SourceLocation or UnresolvedSourceLocation. |
1975 @observable ServiceObject location; | 1980 @observable Location location; |
1976 | 1981 |
1977 // The breakpoint is in a file which is not yet loaded. | 1982 // The breakpoint is in a file which is not yet loaded. |
1978 @observable bool latent; | 1983 @observable bool latent; |
1979 | 1984 |
1980 // The breakpoint has been assigned to a final source location. | 1985 // The breakpoint has been assigned to a final source location. |
1981 @observable bool resolved; | 1986 @observable bool resolved; |
1982 | 1987 |
1983 void _update(ObservableMap map, bool mapIsRef) { | 1988 void _update(ObservableMap map, bool mapIsRef) { |
1984 _loaded = true; | 1989 _loaded = true; |
1985 _upgradeCollection(map, owner); | 1990 _upgradeCollection(map, owner); |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2996 var hits = _hits[line.line]; | 3001 var hits = _hits[line.line]; |
2997 line.hits = hits; | 3002 line.hits = hits; |
2998 } | 3003 } |
2999 } | 3004 } |
3000 | 3005 |
3001 void _addBreakpoint(Breakpoint bpt) { | 3006 void _addBreakpoint(Breakpoint bpt) { |
3002 var line; | 3007 var line; |
3003 if (bpt.location.tokenPos != null) { | 3008 if (bpt.location.tokenPos != null) { |
3004 line = tokenToLine(bpt.location.tokenPos); | 3009 line = tokenToLine(bpt.location.tokenPos); |
3005 } else { | 3010 } else { |
3006 line = bpt.location.line; | 3011 UnresolvedSourceLocation loc = bpt.location; |
3012 line = loc.line; | |
3007 } | 3013 } |
3008 getLine(line).addBreakpoint(bpt); | 3014 getLine(line).addBreakpoint(bpt); |
3009 } | 3015 } |
3010 | 3016 |
3011 void _removeBreakpoint(Breakpoint bpt) { | 3017 void _removeBreakpoint(Breakpoint bpt) { |
3012 var line; | 3018 var line; |
3013 if (bpt.location.tokenPos != null) { | 3019 if (bpt.location.tokenPos != null) { |
3014 line = tokenToLine(bpt.location.tokenPos); | 3020 line = tokenToLine(bpt.location.tokenPos); |
3015 } else { | 3021 } else { |
3016 line = bpt.location.line; | 3022 UnresolvedSourceLocation loc = bpt.location; |
3023 line = loc.line; | |
3017 } | 3024 } |
3018 if (line != null) { | 3025 if (line != null) { |
3019 getLine(line).removeBreakpoint(bpt); | 3026 getLine(line).removeBreakpoint(bpt); |
3020 } | 3027 } |
3021 } | 3028 } |
3022 | 3029 |
3023 List<LocalVarLocation> scanLineForLocalVariableLocations(Pattern pattern, | 3030 List<LocalVarLocation> scanLineForLocalVariableLocations(Pattern pattern, |
3024 String name, | 3031 String name, |
3025 String lineContents, | 3032 String lineContents, |
3026 int lineNumber, | 3033 int lineNumber, |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3936 var v = list[i]; | 3943 var v = list[i]; |
3937 if ((v is ObservableMap) && _isServiceMap(v)) { | 3944 if ((v is ObservableMap) && _isServiceMap(v)) { |
3938 list[i] = owner.getFromMap(v); | 3945 list[i] = owner.getFromMap(v); |
3939 } else if (v is ObservableList) { | 3946 } else if (v is ObservableList) { |
3940 _upgradeObservableList(v, owner); | 3947 _upgradeObservableList(v, owner); |
3941 } else if (v is ObservableMap) { | 3948 } else if (v is ObservableMap) { |
3942 _upgradeObservableMap(v, owner); | 3949 _upgradeObservableMap(v, owner); |
3943 } | 3950 } |
3944 } | 3951 } |
3945 } | 3952 } |
OLD | NEW |