Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: pkg/observe/lib/src/path_observer.dart

Issue 23479002: Suppressing first-chance exception in path_observer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of observe; 5 part of observe;
6 6
7 // This code is inspired by ChangeSummary: 7 // This code is inspired by ChangeSummary:
8 // https://github.com/rafaelw/ChangeSummary/blob/master/change_summary.js 8 // https://github.com/rafaelw/ChangeSummary/blob/master/change_summary.js
9 // ...which underlies MDV. Since we don't need the functionality of 9 // ...which underlies MDV. Since we don't need the functionality of
10 // ChangeSummary, we just implement what we need for data bindings. 10 // ChangeSummary, we just implement what we need for data bindings.
(...skipping 27 matching lines...) Expand all
38 * See [PathObserver.bindSync] and [PathObserver.value]. 38 * See [PathObserver.bindSync] and [PathObserver.value].
39 */ 39 */
40 PathObserver(Object object, String path) 40 PathObserver(Object object, String path)
41 : path = path, 41 : path = path,
42 _isValid = _isPathValid(path), 42 _isValid = _isPathValid(path),
43 _segments = <Object>[] { 43 _segments = <Object>[] {
44 44
45 if (_isValid) { 45 if (_isValid) {
46 for (var segment in path.trim().split('.')) { 46 for (var segment in path.trim().split('.')) {
47 if (segment == '') continue; 47 if (segment == '') continue;
48 var index = int.parse(segment, onError: (_) => null); 48 var index = int.parse(segment, radix: 10, onError: (_) => null);
49 _segments.add(index != null ? index : new Symbol(segment)); 49 _segments.add(index != null ? index : new Symbol(segment));
50 } 50 }
51 } 51 }
52 52
53 // Initialize arrays. 53 // Initialize arrays.
54 // Note that the path itself can't change after it is initially 54 // Note that the path itself can't change after it is initially
55 // constructed, even though the objects along the path can change. 55 // constructed, even though the objects along the path can change.
56 _values = new List<Object>(_segments.length + 1); 56 _values = new List<Object>(_segments.length + 1);
57 _values[0] = object; 57 _values[0] = object;
58 _subs = new List<StreamSubscription>(_segments.length); 58 _subs = new List<StreamSubscription>(_segments.length);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 final _spacesRegExp = new RegExp(r'\s'); 235 final _spacesRegExp = new RegExp(r'\s');
236 236
237 bool _isPathValid(String s) { 237 bool _isPathValid(String s) {
238 s = s.replaceAll(_spacesRegExp, ''); 238 s = s.replaceAll(_spacesRegExp, '');
239 239
240 if (s == '') return true; 240 if (s == '') return true;
241 if (s[0] == '.') return false; 241 if (s[0] == '.') return false;
242 return _pathRegExp.hasMatch(s); 242 return _pathRegExp.hasMatch(s);
243 } 243 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698