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

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

Issue 23455028: Mirrors overhaul. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r29550. Created 7 years, 1 month 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 | dart/pkg/path/lib/path.dart » ('j') | 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 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.log("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.members; 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);
290 } 290 }
291 return false; 291 return false;
292 } 292 }
293 293
294 // TODO(jmesserly): workaround for: 294 // TODO(jmesserly): workaround for:
295 // https://code.google.com/p/dart/issues/detail?id=10029 295 // https://code.google.com/p/dart/issues/detail?id=10029
296 Symbol _setterName(Symbol getter) => 296 Symbol _setterName(Symbol getter) =>
297 new Symbol('${MirrorSystem.getName(getter)}='); 297 new Symbol('${MirrorSystem.getName(getter)}=');
298 298
299 bool _maybeHasSetter(ClassMirror type, Symbol name) { 299 bool _maybeHasSetter(ClassMirror type, Symbol name) {
300 var setterName = _setterName(name); 300 var setterName = _setterName(name);
301 while (type != objectType) { 301 while (type != objectType) {
302 final members = type.members; 302 final members = type.declarations;
303 if (members[name] is VariableMirror) return true; 303 if (members[name] is VariableMirror) return true;
304 if (members.containsKey(setterName)) return true; 304 if (members.containsKey(setterName)) return true;
305 if (members.containsKey(#noSuchMethod)) return true; 305 if (members.containsKey(#noSuchMethod)) return true;
306 type = _safeSuperclass(type); 306 type = _safeSuperclass(type);
307 } 307 }
308 return false; 308 return false;
309 } 309 }
310 310
311 /** 311 /**
312 * True if the type has a method, other than on Object. 312 * True if the type has a method, other than on Object.
313 * Doesn't consider noSuchMethod, unless [name] is `#noSuchMethod`. 313 * Doesn't consider noSuchMethod, unless [name] is `#noSuchMethod`.
314 */ 314 */
315 bool _hasMethod(ClassMirror type, Symbol name) { 315 bool _hasMethod(ClassMirror type, Symbol name) {
316 while (type != objectType) { 316 while (type != objectType) {
317 final member = type.members[name]; 317 final member = type.declarations[name];
318 if (member is MethodMirror && member.isRegularMethod) return true; 318 if (member is MethodMirror && member.isRegularMethod) return true;
319 type = _safeSuperclass(type); 319 type = _safeSuperclass(type);
320 } 320 }
321 return false; 321 return false;
322 } 322 }
323 323
324 ClassMirror _safeSuperclass(ClassMirror type) { 324 ClassMirror _safeSuperclass(ClassMirror type) {
325 try { 325 try {
326 return type.superclass; 326 return type.superclass;
327 } on UnsupportedError catch (e) { 327 } on UnsupportedError catch (e) {
(...skipping 19 matching lines...) Expand all
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');
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/path/lib/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698