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

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

Issue 56773002: Issue 13241. Report StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use InheritanceManager Created 7 years, 1 month 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/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 2610ff3a79837bb12abc1341896fcc5712a5ffcc..7d3ba329684240b43a16c73b72e76fd8c8e63316 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
@@ -814,6 +814,8 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
checkForOptionalParameterInOperator(node);
checkForWrongNumberOfParametersForOperator(node);
checkForNonVoidReturnTypeForOperator(node);
+ } else {
+ checkForConflictingInstanceMethodSetter(node);
}
checkForConcreteClassWithAbstractMember(node);
checkForAllInvalidOverrideErrorCodes(node);
@@ -2262,6 +2264,43 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies that the enclosing class does not have a setter with the same name as the passed
+ * instance method declaration.
+ *
+ * @param node the method declaration to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see StaticWarningCode#CONFLICTING_INSTANCE_METHOD_SETTER
+ */
+ private boolean checkForConflictingInstanceMethodSetter(MethodDeclaration node) {
+ if (node.isStatic()) {
+ return false;
+ }
+ // prepare name
+ SimpleIdentifier nameNode = node.getName();
+ if (nameNode == null) {
+ return false;
+ }
+ String name = nameNode.getName();
+ // ensure that we have enclosing class
+ if (enclosingClass == null) {
+ return false;
+ }
+ // try to find setter
+ ExecutableElement setter = inheritanceManager.lookupMember(enclosingClass, name + "=");
+ if (setter == null) {
+ return false;
+ }
+ // report problem
+ errorReporter.reportError(
+ StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER,
+ nameNode,
+ enclosingClass.getDisplayName(),
+ name,
+ setter.getEnclosingElement().getDisplayName());
+ return true;
+ }
+
+ /**
* This verifies that the enclosing class does not have an instance member with the same name as
* the passed static getter method declaration.
*

Powered by Google App Engine
This is Rietveld 408576698