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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 952913003: Use direct lookup rather than iteration (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months 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 | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.resolver.error_verifier; 5 library engine.resolver.error_verifier;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/static_type_analyzer.dart'; 10 import 'package:analyzer/src/generated/static_type_analyzer.dart';
(...skipping 3795 matching lines...) Expand 10 before | Expand all | Expand 10 after
3806 InterfaceType superclassType = _enclosingClass.supertype; 3806 InterfaceType superclassType = _enclosingClass.supertype;
3807 ClassElement superclassElement = 3807 ClassElement superclassElement =
3808 superclassType == null ? null : superclassType.element; 3808 superclassType == null ? null : superclassType.element;
3809 bool executableElementPrivate = 3809 bool executableElementPrivate =
3810 Identifier.isPrivateName(executableElementName); 3810 Identifier.isPrivateName(executableElementName);
3811 while (superclassElement != null && 3811 while (superclassElement != null &&
3812 !visitedClasses.contains(superclassElement)) { 3812 !visitedClasses.contains(superclassElement)) {
3813 visitedClasses.add(superclassElement); 3813 visitedClasses.add(superclassElement);
3814 LibraryElement superclassLibrary = superclassElement.library; 3814 LibraryElement superclassLibrary = superclassElement.library;
3815 // Check fields. 3815 // Check fields.
3816 List<FieldElement> fieldElts = superclassElement.fields; 3816 FieldElement fieldElt = superclassElement.getField(executableElementName );
3817 for (FieldElement fieldElt in fieldElts) { 3817 if (fieldElt != null) {
3818 // We need the same name.
3819 if (fieldElt.name != executableElementName) {
3820 continue;
3821 }
3822 // Ignore if private in a different library - cannot collide. 3818 // Ignore if private in a different library - cannot collide.
3823 if (executableElementPrivate && 3819 if (executableElementPrivate &&
3824 _currentLibrary != superclassLibrary) { 3820 _currentLibrary != superclassLibrary) {
3825 continue; 3821 continue;
3826 } 3822 }
3827 // instance vs. static 3823 // instance vs. static
3828 if (fieldElt.isStatic) { 3824 if (fieldElt.isStatic) {
3829 _errorReporter.reportErrorForNode( 3825 _errorReporter.reportErrorForNode(
3830 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_ STATIC, 3826 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_ STATIC,
3831 errorNameTarget, 3827 errorNameTarget,
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS]. 4576 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS].
4581 */ 4577 */
4582 bool 4578 bool
4583 _checkForNonAbstractClassInheritsAbstractMember(SimpleIdentifier className Node) { 4579 _checkForNonAbstractClassInheritsAbstractMember(SimpleIdentifier className Node) {
4584 if (_enclosingClass.isAbstract) { 4580 if (_enclosingClass.isAbstract) {
4585 return false; 4581 return false;
4586 } 4582 }
4587 // 4583 //
4588 // Store in local sets the set of all method and accessor names 4584 // Store in local sets the set of all method and accessor names
4589 // 4585 //
4590 List<MethodElement> methods = _enclosingClass.methods; 4586 MethodElement method =
4591 for (MethodElement method in methods) { 4587 _enclosingClass.getMethod(FunctionElement.NO_SUCH_METHOD_METHOD_NAME);
4592 String methodName = method.name; 4588 if (method != null) {
4593 // If the enclosing class declares the method noSuchMethod(), then return. 4589 // If the enclosing class declares the method noSuchMethod(), then return.
4594 // From Spec: It is a static warning if a concrete class does not have an 4590 // From Spec: It is a static warning if a concrete class does not have an
4595 // implementation for a method in any of its superinterfaces unless it 4591 // implementation for a method in any of its superinterfaces unless it
4596 // declares its own noSuchMethod method (7.10). 4592 // declares its own noSuchMethod method (7.10).
4597 if (methodName == FunctionElement.NO_SUCH_METHOD_METHOD_NAME) { 4593 return false;
4598 return false;
4599 }
4600 } 4594 }
4601 HashSet<ExecutableElement> missingOverrides = 4595 HashSet<ExecutableElement> missingOverrides =
4602 new HashSet<ExecutableElement>(); 4596 new HashSet<ExecutableElement>();
4603 // 4597 //
4604 // Loop through the set of all executable elements declared in the implicit 4598 // Loop through the set of all executable elements declared in the implicit
4605 // interface. 4599 // interface.
4606 // 4600 //
4607 MemberMap membersInheritedFromInterfaces = 4601 MemberMap membersInheritedFromInterfaces =
4608 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(_enclosingCla ss); 4602 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(_enclosingCla ss);
4609 MemberMap membersInheritedFromSuperclasses = 4603 MemberMap membersInheritedFromSuperclasses =
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
6330 toCheck.add(type.element); 6324 toCheck.add(type.element);
6331 // type arguments 6325 // type arguments
6332 if (type is InterfaceType) { 6326 if (type is InterfaceType) {
6333 InterfaceType interfaceType = type; 6327 InterfaceType interfaceType = type;
6334 for (DartType typeArgument in interfaceType.typeArguments) { 6328 for (DartType typeArgument in interfaceType.typeArguments) {
6335 _addTypeToCheck(typeArgument); 6329 _addTypeToCheck(typeArgument);
6336 } 6330 }
6337 } 6331 }
6338 } 6332 }
6339 } 6333 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698