| OLD | NEW |
| 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 library observe.src.path_observer; | 5 library observe.src.path_observer; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 @MirrorsUsed(metaTargets: const [Reflectable, ObservableProperty], | 8 @MirrorsUsed(metaTargets: const [Reflectable, ObservableProperty], |
| 9 override: 'observe.src.path_observer') | 9 override: 'observe.src.path_observer') |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return object[MirrorSystem.getName(property)]; | 237 return object[MirrorSystem.getName(property)]; |
| 238 } | 238 } |
| 239 } on NoSuchMethodError catch (e) { | 239 } on NoSuchMethodError catch (e) { |
| 240 // Rethrow, unless the type implements noSuchMethod, in which case we | 240 // Rethrow, unless the type implements noSuchMethod, in which case we |
| 241 // interpret the exception as a signal that the method was not found. | 241 // interpret the exception as a signal that the method was not found. |
| 242 if (!_hasMethod(type, #noSuchMethod)) rethrow; | 242 if (!_hasMethod(type, #noSuchMethod)) rethrow; |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 if (_logger.isLoggable(Level.FINER)) { | 246 if (_logger.isLoggable(Level.FINER)) { |
| 247 _logger.log("can't get $property in $object"); | 247 _logger.finer("can't get $property in $object"); |
| 248 } | 248 } |
| 249 return null; | 249 return null; |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool _setObjectProperty(object, property, value) { | 252 bool _setObjectProperty(object, property, value) { |
| 253 if (object == null) return false; | 253 if (object == null) return false; |
| 254 | 254 |
| 255 if (property is int) { | 255 if (property is int) { |
| 256 if (object is List && property >= 0 && property < object.length) { | 256 if (object is List && property >= 0 && property < object.length) { |
| 257 object[property] = value; | 257 object[property] = value; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 269 if (_hasMethod(type, const Symbol('[]='))) { | 269 if (_hasMethod(type, const Symbol('[]='))) { |
| 270 object[MirrorSystem.getName(property)] = value; | 270 object[MirrorSystem.getName(property)] = value; |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 } on NoSuchMethodError catch (e) { | 273 } on NoSuchMethodError catch (e) { |
| 274 if (!_hasMethod(type, #noSuchMethod)) rethrow; | 274 if (!_hasMethod(type, #noSuchMethod)) rethrow; |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (_logger.isLoggable(Level.FINER)) { | 278 if (_logger.isLoggable(Level.FINER)) { |
| 279 _logger.log("can't set $property in $object"); | 279 _logger.finer("can't set $property in $object"); |
| 280 } | 280 } |
| 281 return false; | 281 return false; |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool _maybeHasGetter(ClassMirror type, Symbol name) { | 284 bool _maybeHasGetter(ClassMirror type, Symbol name) { |
| 285 while (type != objectType) { | 285 while (type != objectType) { |
| 286 final members = type.declarations; | 286 final members = type.declarations; |
| 287 if (members.containsKey(name)) return true; | 287 if (members.containsKey(name)) return true; |
| 288 if (members.containsKey(#noSuchMethod)) return true; | 288 if (members.containsKey(#noSuchMethod)) return true; |
| 289 type = _safeSuperclass(type); | 289 type = _safeSuperclass(type); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 bool _isPathValid(String s) { | 348 bool _isPathValid(String s) { |
| 349 s = s.replaceAll(_spacesRegExp, ''); | 349 s = s.replaceAll(_spacesRegExp, ''); |
| 350 | 350 |
| 351 if (s == '') return true; | 351 if (s == '') return true; |
| 352 if (s[0] == '.') return false; | 352 if (s[0] == '.') return false; |
| 353 return _pathRegExp.hasMatch(s); | 353 return _pathRegExp.hasMatch(s); |
| 354 } | 354 } |
| 355 | 355 |
| 356 final _logger = new Logger('observe.PathObserver'); | 356 final _logger = new Logger('observe.PathObserver'); |
| OLD | NEW |