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 /// Holds a couple utility functions used at various places in the system. | 5 /// Holds a couple utility functions used at various places in the system. |
6 library dev_compiler.src.utils; | 6 library dev_compiler.src.utils; |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 }); | 417 }); |
418 // Add getters. | 418 // Add getters. |
419 element.accessors | 419 element.accessors |
420 .where((member) => !member.isStatic && member.isGetter) | 420 .where((member) => !member.isStatic && member.isGetter) |
421 .forEach((member) { | 421 .forEach((member) { |
422 map[member.name] = member.type.returnType; | 422 map[member.name] = member.type.returnType; |
423 }); | 423 }); |
424 } | 424 } |
425 return map; | 425 return map; |
426 } | 426 } |
| 427 |
| 428 /// Searches all supertype, in order of most derived members, to see if any |
| 429 /// [match] a condition. If so, returns the first match, otherwise returns null. |
| 430 InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) { |
| 431 for (var m in type.mixins.reversed) { |
| 432 if (match(m)) return m; |
| 433 } |
| 434 var s = type.superclass; |
| 435 if (s == null) return null; |
| 436 |
| 437 if (match(s)) return type; |
| 438 return findSupertype(s, match); |
| 439 } |
OLD | NEW |