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

Unified Diff: pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/resolver/scope.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart
diff --git a/pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart b/pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart
index dbe0aa73b279e3caa9f528490d3b0aa2d31d745a..c2a0ed5e1caf4f8b3f017e3d53c65927c7fda87a 100644
--- a/pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart
@@ -53,7 +53,8 @@ class InheritanceManager {
InheritanceManager(LibraryElement library) {
this._library = library;
_classLookup = new HashMap<ClassElement, Map<String, ExecutableElement>>();
- _interfaceLookup = new HashMap<ClassElement, Map<String, ExecutableElement>>();
+ _interfaceLookup =
+ new HashMap<ClassElement, Map<String, ExecutableElement>>();
}
/**
@@ -86,7 +87,8 @@ class InheritanceManager {
*/
@deprecated
MemberMap getMapOfMembersInheritedFromClasses(ClassElement classElt) =>
- new MemberMap.fromMap(_computeClassChainLookupMap(classElt, new HashSet<ClassElement>()));
+ new MemberMap.fromMap(
+ _computeClassChainLookupMap(classElt, new HashSet<ClassElement>()));
/**
* Get and return a mapping between the set of all string names of the members inherited from the
@@ -98,14 +100,16 @@ class InheritanceManager {
*/
@deprecated
MemberMap getMapOfMembersInheritedFromInterfaces(ClassElement classElt) =>
- new MemberMap.fromMap(_computeInterfaceLookupMap(classElt, new HashSet<ClassElement>()));
+ new MemberMap.fromMap(
+ _computeInterfaceLookupMap(classElt, new HashSet<ClassElement>()));
/**
* Return a table mapping the string names of the members inherited from the
* passed [ClassElement]'s superclass hierarchy, and the associated executable
* element.
*/
- Map<String, ExecutableElement> getMembersInheritedFromClasses(ClassElement classElt) =>
+ Map<String, ExecutableElement> getMembersInheritedFromClasses(
+ ClassElement classElt) =>
_computeClassChainLookupMap(classElt, new HashSet<ClassElement>());
/**
@@ -113,7 +117,8 @@ class InheritanceManager {
* passed [ClassElement]'s interface hierarchy, and the associated executable
* element.
*/
- Map<String, ExecutableElement> getMembersInheritedFromInterfaces(ClassElement classElt) =>
+ Map<String, ExecutableElement> getMembersInheritedFromInterfaces(
+ ClassElement classElt) =>
_computeInterfaceLookupMap(classElt, new HashSet<ClassElement>());
/**
@@ -132,12 +137,11 @@ class InheritanceManager {
if (memberName == null || memberName.isEmpty) {
return null;
}
- ExecutableElement executable =
- _computeClassChainLookupMap(classElt, new HashSet<ClassElement>())
- [memberName];
+ ExecutableElement executable = _computeClassChainLookupMap(
+ classElt, new HashSet<ClassElement>())[memberName];
if (executable == null) {
- return _computeInterfaceLookupMap(classElt, new HashSet<ClassElement>())
- [memberName];
+ return _computeInterfaceLookupMap(classElt, new HashSet<ClassElement>())[
+ memberName];
}
return executable;
}
@@ -183,10 +187,8 @@ class InheritanceManager {
ExecutableElement overriddenElement = interfaceMap[memberName];
if (overriddenElement != null) {
if (overriddenElement is MultiplyInheritedExecutableElement) {
- MultiplyInheritedExecutableElement multiplyInheritedElement =
- overriddenElement;
for (ExecutableElement element
- in multiplyInheritedElement.inheritedElements) {
+ in overriddenElement.inheritedElements) {
result.add(element);
}
} else {
@@ -305,8 +307,9 @@ class InheritanceManager {
if (!visitedClasses.contains(mixinElement)) {
visitedClasses.add(mixinElement);
try {
- Map<String, ExecutableElement> map = new Map<String, ExecutableElement>.from(
- _computeClassChainLookupMap(mixinElement, visitedClasses));
+ Map<String, ExecutableElement> map =
+ new Map<String, ExecutableElement>.from(
+ _computeClassChainLookupMap(mixinElement, visitedClasses));
//
// Substitute the super types down the hierarchy.
//
@@ -462,7 +465,8 @@ class InheritanceManager {
List<InterfaceType> mixins = classElt.mixins;
List<InterfaceType> interfaces = classElt.interfaces;
// Recursively collect the list of mappings from all of the interface types
- List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, ExecutableElement>>();
+ List<Map<String, ExecutableElement>> lookupMaps =
+ new List<Map<String, ExecutableElement>>();
//
// Superclass element
//
@@ -602,8 +606,8 @@ class InheritanceManager {
* @param type the type that will be recorded into the passed map
* @param doIncludeAbstract `true` if abstract members will be put into the map
*/
- void _recordMapWithClassMembers(
- Map<String, ExecutableElement> map, InterfaceType type, bool doIncludeAbstract) {
+ void _recordMapWithClassMembers(Map<String, ExecutableElement> map,
+ InterfaceType type, bool doIncludeAbstract) {
List<MethodElement> methods = type.methods;
for (MethodElement method in methods) {
if (method.isAccessibleIn(_library) &&
@@ -656,9 +660,10 @@ class InheritanceManager {
* defined in superclasses of [classElt].
* @return the inheritance lookup map for [classElt].
*/
- Map<String, ExecutableElement> _resolveInheritanceLookup(ClassElement classElt,
- Map<String, List<ExecutableElement>> unionMap) {
- Map<String, ExecutableElement> resultMap = new Map<String, ExecutableElement>();
+ Map<String, ExecutableElement> _resolveInheritanceLookup(
+ ClassElement classElt, Map<String, List<ExecutableElement>> unionMap) {
+ Map<String, ExecutableElement> resultMap =
+ new Map<String, ExecutableElement>();
unionMap.forEach((String key, List<ExecutableElement> list) {
int numOfEltsWithMatchingNames = list.length;
if (numOfEltsWithMatchingNames == 1) {
@@ -945,7 +950,8 @@ class InheritanceManager {
SimpleIdentifier nameIdentifier =
new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, name, 0));
ExecutableElementImpl executable;
- if (elementArrayToMerge[0] is MethodElement) {
+ ExecutableElement elementToMerge = elementArrayToMerge[0];
+ if (elementToMerge is MethodElement) {
MultiplyInheritedMethodElementImpl unionedMethod =
new MultiplyInheritedMethodElementImpl(nameIdentifier);
unionedMethod.inheritedElements = elementArrayToMerge;
@@ -954,9 +960,9 @@ class InheritanceManager {
MultiplyInheritedPropertyAccessorElementImpl unionedPropertyAccessor =
new MultiplyInheritedPropertyAccessorElementImpl(nameIdentifier);
unionedPropertyAccessor.getter =
- (elementArrayToMerge[0] as PropertyAccessorElement).isGetter;
+ (elementToMerge as PropertyAccessorElement).isGetter;
unionedPropertyAccessor.setter =
- (elementArrayToMerge[0] as PropertyAccessorElement).isSetter;
+ (elementToMerge as PropertyAccessorElement).isSetter;
unionedPropertyAccessor.inheritedElements = elementArrayToMerge;
executable = unionedPropertyAccessor;
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/resolver/scope.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698