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

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

Issue 11364020: Issue 5722. Better 'missing part of' error message. 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 d446d9831d30f991f4b9d83c33b6c09d606b38a8..cb49563a988dfca7fdcd0a787afbdc67b9328ebe 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
@@ -17,6 +17,7 @@ import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import com.google.dart.compiler.DartCompilerErrorCode;
import com.google.dart.compiler.ErrorCode;
import com.google.dart.compiler.PackageLibraryManager;
import com.google.dart.compiler.Source;
@@ -76,6 +77,7 @@ import com.google.dart.tools.ui.DartPluginImages;
import com.google.dart.tools.ui.DartToolsPlugin;
import com.google.dart.tools.ui.DartUI;
import com.google.dart.tools.ui.ISharedImages;
+import com.google.dart.tools.ui.internal.cleanup.migration.Migrate_1M1_library_CleanUp;
import com.google.dart.tools.ui.internal.text.correction.proposals.CUCorrectionProposal;
import com.google.dart.tools.ui.internal.text.correction.proposals.LinkedCorrectionProposal;
import com.google.dart.tools.ui.internal.text.correction.proposals.SourceBuilder;
@@ -154,10 +156,6 @@ public class QuickFixProcessor implements IQuickFixProcessor {
DartElementImageDescriptor.CONSTRUCTOR,
DartElementImageProvider.SMALL_SIZE);
-// private static ReplaceEdit createInsertEdit(int offset, String text) {
-// return new ReplaceEdit(offset, 0, text);
-// }
-
private static final Image OBJ_CONSTRUCTOR_IMG = DartToolsPlugin.getImageDescriptorRegistry().get(
OBJ_CONSTRUCTOR_DESC);
@@ -175,6 +173,10 @@ public class QuickFixProcessor implements IQuickFixProcessor {
}
}
+// private static ReplaceEdit createInsertEdit(int offset, String text) {
+// return new ReplaceEdit(offset, 0, text);
+// }
+
private static ReplaceEdit createRemoveEdit(SourceRange range) {
return createReplaceEdit(range, "");
}
@@ -238,12 +240,22 @@ public class QuickFixProcessor implements IQuickFixProcessor {
utils = new ExtractUtils(unit, context.getASTRoot());
for (final IProblemLocation location : locations) {
resetProposalElements();
+ final ErrorCode errorCode = location.getProblemId();
+ // proposals without node
+ ExecutionUtils.runIgnore(new RunnableEx() {
+ @Override
+ public void run() throws Exception {
+ if (errorCode == DartCompilerErrorCode.MISSING_PART_OF_DIRECTIVE) {
+ addFix_addPartOf();
+ }
+ }
+ });
+ // prepare and use node
node = location.getCoveringNode(utils.getUnitNode());
if (node != null) {
ExecutionUtils.runIgnore(new RunnableEx() {
@Override
public void run() throws Exception {
- ErrorCode errorCode = location.getProblemId();
if (errorCode == ResolverErrorCode.CANNOT_RESOLVE_METHOD
|| errorCode == ResolverErrorCode.CANNOT_RESOLVE_METHOD_IN_CLASS
|| errorCode == TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED) {
@@ -292,7 +304,17 @@ public class QuickFixProcessor implements IQuickFixProcessor {
|| errorCode == TypeErrorCode.NO_SUCH_TYPE
|| errorCode == ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR
|| errorCode == TypeErrorCode.USE_INTEGER_DIVISION
- || errorCode == TypeErrorCode.NOT_A_FUNCTION_TYPE_FIELD;
+ || errorCode == TypeErrorCode.NOT_A_FUNCTION_TYPE_FIELD
+ || errorCode == DartCompilerErrorCode.MISSING_PART_OF_DIRECTIVE;
+ }
+
+ private void addFix_addPartOf() throws Exception {
+ TextEdit textEdit = Migrate_1M1_library_CleanUp.createEditInsertPartOf(utils);
+ textEdits.add(textEdit);
+ // add proposal
+ addUnitCorrectionProposal(
+ CorrectionMessages.QuickFixProcessor_addPartOf,
+ DartPluginImages.get(DartPluginImages.IMG_CORRECTION_CHANGE));
}
private void addFix_createConstructor() {

Powered by Google App Engine
This is Rietveld 408576698