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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java

Issue 11365011: Better warning to function-like call of getter; Quick Fix for it (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java
index 4a8ce347a377d167a0dbb4d88418660d7c5b8201..d446d9831d30f991f4b9d83c33b6c09d606b38a8 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/QuickFixProcessor.java
@@ -13,11 +13,6 @@
*/
package com.google.dart.tools.ui.internal.text.correction;
-import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_METHOD_INVOCATION_FUNCTION_NAME;
-import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_METHOD_INVOCATION_TARGET;
-import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_VARIABLE_VALUE;
-import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.getLocationInParent;
-
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -92,6 +87,11 @@ import com.google.dart.tools.ui.text.dart.IInvocationContext;
import com.google.dart.tools.ui.text.dart.IProblemLocation;
import com.google.dart.tools.ui.text.dart.IQuickFixProcessor;
+import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_METHOD_INVOCATION_FUNCTION_NAME;
+import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_METHOD_INVOCATION_TARGET;
+import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.DART_VARIABLE_VALUE;
+import static com.google.dart.tools.core.dom.PropertyDescriptorHelper.getLocationInParent;
+
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -271,6 +271,9 @@ public class QuickFixProcessor implements IQuickFixProcessor {
if (errorCode == TypeErrorCode.USE_INTEGER_DIVISION) {
addFix_useEffectiveIntegerDivision(location);
}
+ if (errorCode == TypeErrorCode.NOT_A_FUNCTION_TYPE_FIELD) {
+ addFix_removeParentheses_inGetterInvocation();
+ }
}
});
}
@@ -288,7 +291,8 @@ public class QuickFixProcessor implements IQuickFixProcessor {
|| errorCode == TypeErrorCode.IS_STATIC_METHOD_IN
|| errorCode == TypeErrorCode.NO_SUCH_TYPE
|| errorCode == ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR
- || errorCode == TypeErrorCode.USE_INTEGER_DIVISION;
+ || errorCode == TypeErrorCode.USE_INTEGER_DIVISION
+ || errorCode == TypeErrorCode.NOT_A_FUNCTION_TYPE_FIELD;
}
private void addFix_createConstructor() {
@@ -479,6 +483,17 @@ public class QuickFixProcessor implements IQuickFixProcessor {
}
}
+ private void addFix_removeParentheses_inGetterInvocation() throws Exception {
+ if (getLocationInParent(node) == DART_METHOD_INVOCATION_FUNCTION_NAME) {
+ DartNode invocation = node.getParent();
+ addRemoveEdit(SourceRangeFactory.forEndEnd(node, invocation));
+ // add proposal
+ addUnitCorrectionProposal(
+ CorrectionMessages.QuickFixProcessor_removeParentheses_inGetterInvocation,
+ DartPluginImages.get(DartPluginImages.IMG_CORRECTION_CHANGE));
+ }
+ }
+
private void addFix_unresolvedClass_create(IProblemLocation location) {
if (mayBeTypeIdentifier(node)) {
String name = ((DartIdentifier) node).getName();

Powered by Google App Engine
This is Rietveld 408576698