Index: compiler/java/com/google/dart/compiler/resolver/Elements.java |
diff --git a/compiler/java/com/google/dart/compiler/resolver/Elements.java b/compiler/java/com/google/dart/compiler/resolver/Elements.java |
index c9110ee7ea4685a83edc72d367ea78340a6f961d..906407103377a90da773e4eb67aeb09815ce2695 100644 |
--- a/compiler/java/com/google/dart/compiler/resolver/Elements.java |
+++ b/compiler/java/com/google/dart/compiler/resolver/Elements.java |
@@ -5,6 +5,7 @@ |
package com.google.dart.compiler.resolver; |
import com.google.common.annotations.VisibleForTesting; |
+import com.google.common.collect.Lists; |
import com.google.dart.compiler.ast.DartClass; |
import com.google.dart.compiler.ast.DartExpression; |
import com.google.dart.compiler.ast.DartField; |
@@ -271,4 +272,45 @@ public class Elements { |
return getRawName(propertyAccess.getQualifier()) + "." + getRawName(propertyAccess.getName()); |
} |
} |
+ |
+ /** |
+ * @return the number of required (not optional/named) parameters in given {@link MethodElement}. |
+ */ |
+ public static int getNumberOfRequiredParameters(MethodElement method) { |
+ int num = 0; |
+ List<VariableElement> parameters = method.getParameters(); |
+ for (VariableElement parameter : parameters) { |
+ if (!parameter.isNamed()) { |
+ num++; |
+ } |
+ } |
+ return num; |
+ } |
+ |
+ /** |
+ * @return the names for named parameters in given {@link MethodElement}. |
+ */ |
+ public static List<String> getNamedParameters(MethodElement method) { |
+ List<String> names = Lists.newArrayList(); |
+ List<VariableElement> parameters = method.getParameters(); |
+ for (VariableElement parameter : parameters) { |
+ if (parameter.isNamed()) { |
+ names.add(parameter.getName()); |
+ } |
+ } |
+ return names; |
+ } |
+ |
+ /** |
+ * @return the names for parameters types in given {@link MethodElement}. |
+ */ |
+ public static List<String> getParameterTypeNames(MethodElement method) { |
+ List<String> names = Lists.newArrayList(); |
+ List<VariableElement> parameters = method.getParameters(); |
+ for (VariableElement parameter : parameters) { |
+ String typeName = parameter.getType().getElement().getName(); |
+ names.add(typeName); |
+ } |
+ return names; |
+ } |
} |