| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 visitedInterfaces.remove(mixinElement); | 518 visitedInterfaces.remove(mixinElement); |
| 519 } | 519 } |
| 520 } else { | 520 } else { |
| 521 return null; | 521 return null; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 // | 525 // |
| 526 // Interface elements | 526 // Interface elements |
| 527 // | 527 // |
| 528 for (InterfaceType interfaceType in interfaces) { | 528 int interfaceLength = interfaces.length; |
| 529 for (int i = 0; i < interfaceLength; i++) { |
| 530 InterfaceType interfaceType = interfaces[i]; |
| 529 ClassElement interfaceElement = interfaceType.element; | 531 ClassElement interfaceElement = interfaceType.element; |
| 530 if (interfaceElement != null) { | 532 if (interfaceElement != null) { |
| 531 if (!visitedInterfaces.contains(interfaceElement)) { | 533 if (!visitedInterfaces.contains(interfaceElement)) { |
| 532 try { | 534 try { |
| 533 visitedInterfaces.add(interfaceElement); | 535 visitedInterfaces.add(interfaceElement); |
| 534 // | 536 // |
| 535 // Recursively compute the map for the interfaces. | 537 // Recursively compute the map for the interfaces. |
| 536 // | 538 // |
| 537 Map<String, ExecutableElement> map = | 539 Map<String, ExecutableElement> map = |
| 538 _computeInterfaceLookupMap(interfaceElement, visitedInterfaces); | 540 _computeInterfaceLookupMap(interfaceElement, visitedInterfaces); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 554 } | 556 } |
| 555 } | 557 } |
| 556 } | 558 } |
| 557 if (lookupMaps.length == 0) { | 559 if (lookupMaps.length == 0) { |
| 558 return null; | 560 return null; |
| 559 } | 561 } |
| 560 return lookupMaps; | 562 return lookupMaps; |
| 561 } | 563 } |
| 562 | 564 |
| 563 /** | 565 /** |
| 564 * Given some [ClassElement], this method finds and returns the [ExecutableEle
ment] of | 566 * Given some [classElement], this method finds and returns the executable |
| 565 * the passed name in the class element. Static members, members in super type
s and members not | 567 * element with the given [memberName] in the class element. Static members, |
| 566 * accessible from the current library are not considered. | 568 * members in super types and members not accessible from the current library |
| 567 * | 569 * are not considered. |
| 568 * @param classElt the class element to query | |
| 569 * @param memberName the name of the member to lookup in the class | |
| 570 * @return the found [ExecutableElement], or `null` if no such member was foun
d | |
| 571 */ | 570 */ |
| 572 ExecutableElement _lookupMemberInClass( | 571 ExecutableElement _lookupMemberInClass( |
| 573 ClassElement classElt, String memberName) { | 572 ClassElement classElement, String memberName) { |
| 574 List<MethodElement> methods = classElt.methods; | 573 List<MethodElement> methods = classElement.methods; |
| 575 for (MethodElement method in methods) { | 574 int methodLength = methods.length; |
| 575 for (int i = 0; i < methodLength; i++) { |
| 576 MethodElement method = methods[i]; |
| 576 if (memberName == method.name && | 577 if (memberName == method.name && |
| 577 method.isAccessibleIn(_library) && | 578 method.isAccessibleIn(_library) && |
| 578 !method.isStatic) { | 579 !method.isStatic) { |
| 579 return method; | 580 return method; |
| 580 } | 581 } |
| 581 } | 582 } |
| 582 List<PropertyAccessorElement> accessors = classElt.accessors; | 583 List<PropertyAccessorElement> accessors = classElement.accessors; |
| 583 for (PropertyAccessorElement accessor in accessors) { | 584 int accessorLength = accessors.length; |
| 585 for (int i = 0; i < accessorLength; i++) { |
| 586 PropertyAccessorElement accessor = accessors[i]; |
| 584 if (memberName == accessor.name && | 587 if (memberName == accessor.name && |
| 585 accessor.isAccessibleIn(_library) && | 588 accessor.isAccessibleIn(_library) && |
| 586 !accessor.isStatic) { | 589 !accessor.isStatic) { |
| 587 return accessor; | 590 return accessor; |
| 588 } | 591 } |
| 589 } | 592 } |
| 590 return null; | 593 return null; |
| 591 } | 594 } |
| 592 | 595 |
| 593 /** | 596 /** |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 } | 1230 } |
| 1228 | 1231 |
| 1229 /** | 1232 /** |
| 1230 * Initializes [keys] and [values]. | 1233 * Initializes [keys] and [values]. |
| 1231 */ | 1234 */ |
| 1232 void _initArrays(int initialCapacity) { | 1235 void _initArrays(int initialCapacity) { |
| 1233 _keys = new List<String>(initialCapacity); | 1236 _keys = new List<String>(initialCapacity); |
| 1234 _values = new List<ExecutableElement>(initialCapacity); | 1237 _values = new List<ExecutableElement>(initialCapacity); |
| 1235 } | 1238 } |
| 1236 } | 1239 } |
| OLD | NEW |