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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java

Issue 17826013: Use InheritanceManager to lookup 'iterator' getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 7 years, 6 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
index 3025eaef06324cc3beeca0bdb40505d43807e745..40ed43adc4b29433413fd189079076a181d3e578 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
@@ -155,6 +155,28 @@ public class InheritanceManager {
}
/**
+ * Given some {@link InterfaceType interface type} and some member name, this returns the
+ * {@link FunctionType function type} of the {@link ExecutableElement executable element} that the
+ * class either declares itself, or inherits, that has the member name, if no member is inherited
+ * {@code null} is returned. The returned {@link FunctionType function type} has all type
+ * parameters substituted with corresponding type arguments from the given {@link InterfaceType}.
+ *
+ * @param interfaceType the interface type to query
+ * @param memberName the name of the executable element to find and return
+ * @return the member's function type, or {@code null} if no such member exists
+ */
+ public FunctionType lookupMemberType(InterfaceType interfaceType, String memberName) {
+ ExecutableElement iteratorMember = lookupMember(interfaceType.getElement(), memberName);
+ if (iteratorMember == null) {
+ return null;
+ }
+ return substituteTypeArgumentsInMemberFromInheritance(
+ iteratorMember.getType(),
+ memberName,
+ interfaceType);
+ }
+
+ /**
* Set the new library element context.
*
* @param library the new library element
@@ -185,18 +207,17 @@ public class InheritanceManager {
LinkedList<InterfaceType> inheritancePath = new LinkedList<InterfaceType>();
computeInheritancePath(inheritancePath, definingType, memberName);
- if (inheritancePath == null || inheritancePath.size() < 2) {
+ if (inheritancePath == null || inheritancePath.isEmpty()) {
Brian Wilkerson 2013/06/26 20:43:08 I'm not sure why it was returning when there was o
jwren 2013/06/26 22:01:58 This looks correct. When computeInheritancePath
// TODO(jwren) log analysis engine error
return baseFunctionType;
}
FunctionType functionTypeToReturn = baseFunctionType;
// loop backward through the list substituting as we go:
- InterfaceType lastType = inheritancePath.removeLast();
- while (inheritancePath.size() > 0) {
+ while (!inheritancePath.isEmpty()) {
+ InterfaceType lastType = inheritancePath.removeLast();
Type[] parameterTypes = lastType.getElement().getType().getTypeArguments();
Type[] argumentTypes = lastType.getTypeArguments();
functionTypeToReturn = functionTypeToReturn.substitute(argumentTypes, parameterTypes);
- lastType = inheritancePath.removeLast();
}
return functionTypeToReturn;
}

Powered by Google App Engine
This is Rietveld 408576698