| 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 /// Mixins that implement convenience methods on [Element] subclasses. | 5 /// Mixins that implement convenience methods on [Element] subclasses. |
| 6 | 6 |
| 7 library elements.common; | 7 library elements.common; |
| 8 | 8 |
| 9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
| 10 Names, | 10 Names, |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // this signature must not have more required parameters. Having more | 503 // this signature must not have more required parameters. Having more |
| 504 // optional parameters is not a problem, they simply are never provided | 504 // optional parameters is not a problem, they simply are never provided |
| 505 // by call sites of a call to a method with the other signature. | 505 // by call sites of a call to a method with the other signature. |
| 506 int otherTotalCount = signature.parameterCount; | 506 int otherTotalCount = signature.parameterCount; |
| 507 return requiredParameterCount <= otherTotalCount | 507 return requiredParameterCount <= otherTotalCount |
| 508 && parameterCount >= otherTotalCount; | 508 && parameterCount >= otherTotalCount; |
| 509 } | 509 } |
| 510 return true; | 510 return true; |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 |
| 514 abstract class MixinApplicationElementCommon |
| 515 implements MixinApplicationElement { |
| 516 Link<ConstructorElement> get constructors { |
| 517 throw new UnsupportedError('Unimplemented $this.constructors'); |
| 518 } |
| 519 |
| 520 FunctionElement _lookupLocalConstructor(String name) { |
| 521 for (Link<Element> link = constructors; |
| 522 !link.isEmpty; |
| 523 link = link.tail) { |
| 524 if (link.head.name == name) return link.head; |
| 525 } |
| 526 return null; |
| 527 } |
| 528 |
| 529 @override |
| 530 Element localLookup(String name) { |
| 531 Element constructor = _lookupLocalConstructor(name); |
| 532 if (constructor != null) return constructor; |
| 533 if (mixin == null) return null; |
| 534 Element mixedInElement = mixin.localLookup(name); |
| 535 if (mixedInElement == null) return null; |
| 536 return mixedInElement.isInstanceMember ? mixedInElement : null; |
| 537 } |
| 538 |
| 539 @override |
| 540 void forEachLocalMember(void f(Element member)) { |
| 541 constructors.forEach(f); |
| 542 if (mixin != null) mixin.forEachLocalMember((Element mixedInElement) { |
| 543 if (mixedInElement.isInstanceMember) f(mixedInElement); |
| 544 }); |
| 545 } |
| 546 } |
| OLD | NEW |