From 92e818859323a2b43503849e73e196d91d09dd4c Mon Sep 17 00:00:00 2001 From: dimvar Date: Fri, 16 Jun 2017 17:49:23 -0700 Subject: [PATCH] Change getMinArguments/getMaxArguments to getMinArity/getMaxArity. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=159298105 --- .../jscomp/CheckEventfulObjectDisposal.java | 2 +- src/com/google/javascript/jscomp/TypeCheck.java | 12 ++++++------ src/com/google/javascript/jscomp/TypeInference.java | 2 +- .../google/javascript/jscomp/TypedCodeGenerator.java | 6 +++--- .../google/javascript/jscomp/newtypes/JSType.java | 4 ++-- src/com/google/javascript/rhino/FunctionTypeI.java | 4 ++-- .../google/javascript/rhino/jstype/FunctionType.java | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/com/google/javascript/jscomp/CheckEventfulObjectDisposal.java b/src/com/google/javascript/jscomp/CheckEventfulObjectDisposal.java index 29bd470869c..94aa60eeec0 100644 --- a/src/com/google/javascript/jscomp/CheckEventfulObjectDisposal.java +++ b/src/com/google/javascript/jscomp/CheckEventfulObjectDisposal.java @@ -1109,7 +1109,7 @@ public void visitFunction(NodeTraversal t, Node n) { positionalDisposedParameters.add(DISPOSE_ALL); } else { // Record index of parameters that are disposed. - for (int index = 0; index < funType.getMaxArguments(); ++index) { + for (int index = 0; index < funType.getMaxArity(); ++index) { // Bail out if the paramNode is not there. if (paramNode == null) { break; diff --git a/src/com/google/javascript/jscomp/TypeCheck.java b/src/com/google/javascript/jscomp/TypeCheck.java index 1fda6b2415c..6f7b6561e0a 100644 --- a/src/com/google/javascript/jscomp/TypeCheck.java +++ b/src/com/google/javascript/jscomp/TypeCheck.java @@ -1910,14 +1910,14 @@ private void visitParameterList(NodeTraversal t, Node call, } int numArgs = call.getChildCount() - 1; - int minArgs = functionType.getMinArguments(); - int maxArgs = functionType.getMaxArguments(); - if (minArgs > numArgs || maxArgs < numArgs) { + int minArity = functionType.getMinArity(); + int maxArity = functionType.getMaxArity(); + if (minArity > numArgs || maxArity < numArgs) { report(t, call, WRONG_ARGUMENT_COUNT, typeRegistry.getReadableTypeNameNoDeref(call.getFirstChild()), - String.valueOf(numArgs), String.valueOf(minArgs), - maxArgs != Integer.MAX_VALUE ? - " and no more than " + maxArgs + " argument(s)" : ""); + String.valueOf(numArgs), String.valueOf(minArity), + maxArity == Integer.MAX_VALUE ? "" + : " and no more than " + maxArity + " argument(s)"); } } diff --git a/src/com/google/javascript/jscomp/TypeInference.java b/src/com/google/javascript/jscomp/TypeInference.java index 648fe2e42a7..def10399df7 100644 --- a/src/com/google/javascript/jscomp/TypeInference.java +++ b/src/com/google/javascript/jscomp/TypeInference.java @@ -1172,7 +1172,7 @@ private FunctionType matchFunction( // For now, we just make sure the current type has enough // arguments to match the expected type, and return the // expected type if it does. - if (currentType.getMaxArguments() <= expectedType.getMaxArguments()) { + if (currentType.getMaxArity() <= expectedType.getMaxArity()) { return expectedType; } } diff --git a/src/com/google/javascript/jscomp/TypedCodeGenerator.java b/src/com/google/javascript/jscomp/TypedCodeGenerator.java index eccfb624456..40400de40db 100644 --- a/src/com/google/javascript/jscomp/TypedCodeGenerator.java +++ b/src/com/google/javascript/jscomp/TypedCodeGenerator.java @@ -130,12 +130,12 @@ private String getFunctionAnnotation(Node fnNode) { } // Param types - int minArgs = funType.getMinArguments(); - int maxArgs = funType.getMaxArguments(); + int minArity = funType.getMinArity(); + int maxArity = funType.getMaxArity(); List formals = ImmutableList.copyOf(funType.getParameterTypes()); for (int i = 0; i < formals.size(); i++) { sb.append(" * "); - appendAnnotation(sb, "param", getParameterJSDocType(formals, i, minArgs, maxArgs)); + appendAnnotation(sb, "param", getParameterJSDocType(formals, i, minArity, maxArity)); sb.append(" ") .append(paramNode == null ? "p" + i : paramNode.getString()) .append("\n"); diff --git a/src/com/google/javascript/jscomp/newtypes/JSType.java b/src/com/google/javascript/jscomp/newtypes/JSType.java index 86a287511e2..32ef1b83a1d 100644 --- a/src/com/google/javascript/jscomp/newtypes/JSType.java +++ b/src/com/google/javascript/jscomp/newtypes/JSType.java @@ -1865,13 +1865,13 @@ public final boolean acceptsArguments(List argumentTypes) { } @Override - public final int getMinArguments() { + public final int getMinArity() { Preconditions.checkState(this.isFunctionType()); return this.getFunTypeIfSingletonObj().getMinArity(); } @Override - public final int getMaxArguments() { + public final int getMaxArity() { Preconditions.checkState(this.isFunctionType()); return this.getFunTypeIfSingletonObj().getMaxArity(); } diff --git a/src/com/google/javascript/rhino/FunctionTypeI.java b/src/com/google/javascript/rhino/FunctionTypeI.java index 435a999698b..fd6d363daa8 100644 --- a/src/com/google/javascript/rhino/FunctionTypeI.java +++ b/src/com/google/javascript/rhino/FunctionTypeI.java @@ -99,10 +99,10 @@ public interface FunctionTypeI extends TypeI { Iterable getParameterTypes(); /** Returns the number of required arguments. */ - int getMinArguments(); + int getMinArity(); /** Returns the maximum number of allowed arguments, or Integer.MAX_VALUE if variadic. */ - int getMaxArguments(); + int getMaxArity(); /** Returns the names of all type parameters. */ Collection getTypeParameters(); diff --git a/src/com/google/javascript/rhino/jstype/FunctionType.java b/src/com/google/javascript/rhino/jstype/FunctionType.java index 017943ab951..eca6660db51 100644 --- a/src/com/google/javascript/rhino/jstype/FunctionType.java +++ b/src/com/google/javascript/rhino/jstype/FunctionType.java @@ -326,7 +326,7 @@ public Node getParametersNode() { /** Gets the minimum number of arguments that this function requires. */ @Override - public int getMinArguments() { + public int getMinArity() { // NOTE(nicksantos): There are some native functions that have optional // parameters before required parameters. This algorithm finds the position // of the last required parameter. @@ -346,7 +346,7 @@ public int getMinArguments() { * or Integer.MAX_VALUE if this is a variable argument function. */ @Override - public int getMaxArguments() { + public int getMaxArity() { Node params = getParametersNode(); if (params != null) { Node lastParam = params.getLastChild(); @@ -1563,6 +1563,6 @@ public boolean acceptsArguments(List argumentTypes) { } int numArgs = argumentTypes.size(); - return this.getMinArguments() <= numArgs && numArgs <= this.getMaxArguments(); + return this.getMinArity() <= numArgs && numArgs <= this.getMaxArity(); } }