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

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

Issue 18121002: Report PRIVATE_OPTIONAL_PARAMETER in more cases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« 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 f34557be7529a8d5a17aa2fbfb5c079acd440187..a9e6de9b79957a2c59d2bc0aadb2ad131506d582 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
@@ -472,12 +472,6 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
@Override
- public Void visitDefaultFormalParameter(DefaultFormalParameter node) {
- checkForPrivateOptionalParameter(node);
- return super.visitDefaultFormalParameter(node);
- }
-
- @Override
public Void visitDoStatement(DoStatement node) {
checkForNonBoolCondition(node.getCondition());
return super.visitDoStatement(node);
@@ -519,6 +513,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
@Override
public Void visitFieldFormalParameter(FieldFormalParameter node) {
checkForConstFormalParameter(node);
+ checkForPrivateOptionalParameter(node);
checkForFieldInitializingFormalRedirectingConstructor(node);
return super.visitFieldFormalParameter(node);
}
@@ -752,6 +747,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
@Override
public Void visitSimpleFormalParameter(SimpleFormalParameter node) {
checkForConstFormalParameter(node);
+ checkForPrivateOptionalParameter(node);
return super.visitSimpleFormalParameter(node);
}
@@ -3551,17 +3547,19 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
* @return {@code true} if and only if an error code is generated on the passed node
* @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER
*/
- private boolean checkForPrivateOptionalParameter(DefaultFormalParameter node) {
- Token separator = node.getSeparator();
- if (separator != null && separator.getLexeme().equals(":")) {
- NormalFormalParameter parameter = node.getParameter();
- SimpleIdentifier name = parameter.getIdentifier();
- if (!name.isSynthetic() && name.getName().startsWith("_")) {
- errorReporter.reportError(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, node);
- return true;
- }
+ private boolean checkForPrivateOptionalParameter(FormalParameter node) {
+ // should be named parameter
+ if (node.getKind() != ParameterKind.NAMED) {
+ return false;
}
- return false;
+ // name should start with '_'
+ SimpleIdentifier name = node.getIdentifier();
+ if (name.isSynthetic() || !name.getName().startsWith("_")) {
+ return false;
+ }
+ // report problem
+ errorReporter.reportError(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, node);
+ 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