| OLD | NEW |
| 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; | 5 library engine.resolver; |
| 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/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 * See [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]. | 1115 * See [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]. |
| 1116 */ | 1116 */ |
| 1117 bool _checkForCaseExpressionTypeImplementsEquals(SwitchStatement node, | 1117 bool _checkForCaseExpressionTypeImplementsEquals(SwitchStatement node, |
| 1118 DartType type) { | 1118 DartType type) { |
| 1119 if (!_implementsEqualsWhenNotAllowed(type)) { | 1119 if (!_implementsEqualsWhenNotAllowed(type)) { |
| 1120 return false; | 1120 return false; |
| 1121 } | 1121 } |
| 1122 // report error | 1122 // report error |
| 1123 _errorReporter.reportErrorForToken( | 1123 _errorReporter.reportErrorForToken( |
| 1124 CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, | 1124 CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, |
| 1125 node.keyword, | 1125 node.switchKeyword, |
| 1126 [type.displayName]); | 1126 [type.displayName]); |
| 1127 return true; | 1127 return true; |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 /** | 1130 /** |
| 1131 * @return `true` if given [Type] implements operator <i>==</i>, and it is not | 1131 * @return `true` if given [Type] implements operator <i>==</i>, and it is not |
| 1132 * <i>int</i> or <i>String</i>. | 1132 * <i>int</i> or <i>String</i>. |
| 1133 */ | 1133 */ |
| 1134 bool _implementsEqualsWhenNotAllowed(DartType type) { | 1134 bool _implementsEqualsWhenNotAllowed(DartType type) { |
| 1135 // ignore int or String | 1135 // ignore int or String |
| (...skipping 4320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5456 NodeList<Directive> directives = node.directives; | 5456 NodeList<Directive> directives = node.directives; |
| 5457 for (Directive directive in directives) { | 5457 for (Directive directive in directives) { |
| 5458 if (directive is ImportDirective) { | 5458 if (directive is ImportDirective) { |
| 5459 ImportDirective importDirective = directive; | 5459 ImportDirective importDirective = directive; |
| 5460 LibraryElement libraryElement = importDirective.uriElement; | 5460 LibraryElement libraryElement = importDirective.uriElement; |
| 5461 if (libraryElement != null) { | 5461 if (libraryElement != null) { |
| 5462 _unusedImports.add(importDirective); | 5462 _unusedImports.add(importDirective); |
| 5463 // | 5463 // |
| 5464 // Initialize prefixElementMap | 5464 // Initialize prefixElementMap |
| 5465 // | 5465 // |
| 5466 if (importDirective.asToken != null) { | 5466 if (importDirective.asKeyword != null) { |
| 5467 SimpleIdentifier prefixIdentifier = importDirective.prefix; | 5467 SimpleIdentifier prefixIdentifier = importDirective.prefix; |
| 5468 if (prefixIdentifier != null) { | 5468 if (prefixIdentifier != null) { |
| 5469 Element element = prefixIdentifier.staticElement; | 5469 Element element = prefixIdentifier.staticElement; |
| 5470 if (element is PrefixElement) { | 5470 if (element is PrefixElement) { |
| 5471 PrefixElement prefixElementKey = element; | 5471 PrefixElement prefixElementKey = element; |
| 5472 List<ImportDirective> list = | 5472 List<ImportDirective> list = |
| 5473 _prefixElementMap[prefixElementKey]; | 5473 _prefixElementMap[prefixElementKey]; |
| 5474 if (list == null) { | 5474 if (list == null) { |
| 5475 list = new List<ImportDirective>(); | 5475 list = new List<ImportDirective>(); |
| 5476 _prefixElementMap[prefixElementKey] = list; | 5476 _prefixElementMap[prefixElementKey] = list; |
| (...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8086 // The imported source will be null if the URI in the import | 8086 // The imported source will be null if the URI in the import |
| 8087 // directive was invalid. | 8087 // directive was invalid. |
| 8088 Library importedLibrary = _libraryMap[importedSource]; | 8088 Library importedLibrary = _libraryMap[importedSource]; |
| 8089 if (importedLibrary != null) { | 8089 if (importedLibrary != null) { |
| 8090 ImportElementImpl importElement = | 8090 ImportElementImpl importElement = |
| 8091 new ImportElementImpl(directive.offset); | 8091 new ImportElementImpl(directive.offset); |
| 8092 StringLiteral uriLiteral = importDirective.uri; | 8092 StringLiteral uriLiteral = importDirective.uri; |
| 8093 importElement.uriOffset = uriLiteral.offset; | 8093 importElement.uriOffset = uriLiteral.offset; |
| 8094 importElement.uriEnd = uriLiteral.end; | 8094 importElement.uriEnd = uriLiteral.end; |
| 8095 importElement.uri = uriContent; | 8095 importElement.uri = uriContent; |
| 8096 importElement.deferred = importDirective.deferredToken != null; | 8096 importElement.deferred = importDirective.deferredKeyword != null; |
| 8097 importElement.combinators = _buildCombinators(importDirective); | 8097 importElement.combinators = _buildCombinators(importDirective); |
| 8098 LibraryElement importedLibraryElement = | 8098 LibraryElement importedLibraryElement = |
| 8099 importedLibrary.libraryElement; | 8099 importedLibrary.libraryElement; |
| 8100 if (importedLibraryElement != null) { | 8100 if (importedLibraryElement != null) { |
| 8101 importElement.importedLibrary = importedLibraryElement; | 8101 importElement.importedLibrary = importedLibraryElement; |
| 8102 } | 8102 } |
| 8103 SimpleIdentifier prefixNode = directive.prefix; | 8103 SimpleIdentifier prefixNode = directive.prefix; |
| 8104 if (prefixNode != null) { | 8104 if (prefixNode != null) { |
| 8105 importElement.prefixOffset = prefixNode.offset; | 8105 importElement.prefixOffset = prefixNode.offset; |
| 8106 String prefixName = prefixNode.name; | 8106 String prefixName = prefixNode.name; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8801 ResolvableLibrary importedLibrary = _libraryMap[importedSource]; | 8801 ResolvableLibrary importedLibrary = _libraryMap[importedSource]; |
| 8802 if (importedLibrary != null) { | 8802 if (importedLibrary != null) { |
| 8803 ImportElementImpl importElement = | 8803 ImportElementImpl importElement = |
| 8804 new ImportElementImpl(directive.offset); | 8804 new ImportElementImpl(directive.offset); |
| 8805 StringLiteral uriLiteral = importDirective.uri; | 8805 StringLiteral uriLiteral = importDirective.uri; |
| 8806 if (uriLiteral != null) { | 8806 if (uriLiteral != null) { |
| 8807 importElement.uriOffset = uriLiteral.offset; | 8807 importElement.uriOffset = uriLiteral.offset; |
| 8808 importElement.uriEnd = uriLiteral.end; | 8808 importElement.uriEnd = uriLiteral.end; |
| 8809 } | 8809 } |
| 8810 importElement.uri = uriContent; | 8810 importElement.uri = uriContent; |
| 8811 importElement.deferred = importDirective.deferredToken != null; | 8811 importElement.deferred = importDirective.deferredKeyword != null; |
| 8812 importElement.combinators = _buildCombinators(importDirective); | 8812 importElement.combinators = _buildCombinators(importDirective); |
| 8813 LibraryElement importedLibraryElement = | 8813 LibraryElement importedLibraryElement = |
| 8814 importedLibrary.libraryElement; | 8814 importedLibrary.libraryElement; |
| 8815 if (importedLibraryElement != null) { | 8815 if (importedLibraryElement != null) { |
| 8816 importElement.importedLibrary = importedLibraryElement; | 8816 importElement.importedLibrary = importedLibraryElement; |
| 8817 } | 8817 } |
| 8818 SimpleIdentifier prefixNode = directive.prefix; | 8818 SimpleIdentifier prefixNode = directive.prefix; |
| 8819 if (prefixNode != null) { | 8819 if (prefixNode != null) { |
| 8820 importElement.prefixOffset = prefixNode.offset; | 8820 importElement.prefixOffset = prefixNode.offset; |
| 8821 String prefixName = prefixNode.name; | 8821 String prefixName = prefixNode.name; |
| (...skipping 6831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15653 * library. | 15653 * library. |
| 15654 */ | 15654 */ |
| 15655 final HashSet<String> members = new HashSet<String>(); | 15655 final HashSet<String> members = new HashSet<String>(); |
| 15656 | 15656 |
| 15657 /** | 15657 /** |
| 15658 * Names of resolved or unresolved class members that are read in the | 15658 * Names of resolved or unresolved class members that are read in the |
| 15659 * library. | 15659 * library. |
| 15660 */ | 15660 */ |
| 15661 final HashSet<String> readMembers = new HashSet<String>(); | 15661 final HashSet<String> readMembers = new HashSet<String>(); |
| 15662 } | 15662 } |
| OLD | NEW |