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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 15028010: Report CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER for top-level setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
index b61fcbf8f1b2a156dbddac38030a180031cc8189..634f2c734ccd12e75add075944aa6bcf5dc987f3 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
@@ -342,8 +342,12 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
try {
enclosingFunction = node.getElement();
if (node.isSetter()) {
- // TODO(scheglov) add also this
-// checkForWrongNumberOfParametersForSetter(node);
+ FunctionExpression functionExpression = node.getFunctionExpression();
+ if (functionExpression != null) {
+ checkForWrongNumberOfParametersForSetter(
+ node.getName(),
+ functionExpression.getParameters());
+ }
checkForNonVoidReturnTypeForSetter(node.getReturnType());
}
return super.visitFunctionDeclaration(node);
@@ -440,7 +444,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
try {
enclosingFunction = node.getElement();
if (node.isSetter()) {
- checkForWrongNumberOfParametersForSetter(node);
+ checkForWrongNumberOfParametersForSetter(node.getName(), node.getParameters());
checkForNonVoidReturnTypeForSetter(node.getReturnType());
} else if (node.isOperator()) {
checkForOptionalParameterInOperator(node);
@@ -1713,25 +1717,28 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
- * This verifies if the passed setter method declaration, has only one parameter.
+ * This verifies if the passed setter parameter list have only one parameter.
* <p>
* This method assumes that the method declaration was tested to be a setter before being called.
*
- * @param node the method declaration to evaluate
+ * @param setterName the name of the setter to report problems on
+ * @param parameterList the parameter list to evaluate
* @return {@code true} if and only if an error code is generated on the passed node
* @see CompileTimeErrorCode#WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
*/
- private boolean checkForWrongNumberOfParametersForSetter(MethodDeclaration node) {
- FormalParameterList parameterList = node.getParameters();
+ private boolean checkForWrongNumberOfParametersForSetter(SimpleIdentifier setterName,
+ FormalParameterList parameterList) {
+ if (setterName == null) {
+ return false;
+ }
if (parameterList == null) {
return false;
}
- NodeList<FormalParameter> formalParameters = parameterList.getParameters();
- int numberOfParameters = formalParameters.size();
+ int numberOfParameters = parameterList.getParameters().size();
if (numberOfParameters != 1) {
errorReporter.reportError(
CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER,
- node.getName(),
+ setterName,
numberOfParameters);
return true;
}
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698