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

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

Issue 10816034: Basic 'Quick Fix' support and one fix as example/test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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/editor/DartMarkerAnnotation.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartMarkerAnnotation.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartMarkerAnnotation.java
index cd731f1fdf95ae567c31b00270ab314207b4e1a1..a5902fcea4d68a7e437851f21cd7b17d24d58994 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartMarkerAnnotation.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartMarkerAnnotation.java
@@ -13,9 +13,13 @@
*/
package com.google.dart.tools.ui.internal.text.editor;
+import com.google.dart.compiler.ErrorCode;
+import com.google.dart.compiler.util.apache.StringUtils;
import com.google.dart.tools.core.DartCore;
import com.google.dart.tools.core.model.CompilationUnit;
import com.google.dart.tools.core.model.DartElement;
+import com.google.dart.tools.internal.corext.refactoring.util.ExecutionUtils;
+import com.google.dart.tools.internal.corext.refactoring.util.RunnableObjectEx;
import com.google.dart.tools.ui.CorrectionEngine;
import org.eclipse.core.resources.IMarker;
@@ -32,6 +36,19 @@ public class DartMarkerAnnotation extends MarkerAnnotation implements IJavaAnnot
public static final String INFO_ANNOTATION_TYPE = "com.google.dart.tools.ui.info"; //$NON-NLS-1$
public static final String TASK_ANNOTATION_TYPE = "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
+ /**
+ * @return <code>true</code> if the marker can be treated as a Dart annotation.
+ */
+ static final boolean isJavaAnnotation(IMarker marker) {
+ // Performance
+ String markerType = MarkerUtilities.getMarkerType(marker);
+ if (DartCore.DART_PROBLEM_MARKER_TYPE.equals(markerType)) {
+ return true;
+ }
+ // Generic
+ return MarkerUtilities.isMarkerType(marker, DartCore.DART_PROBLEM_MARKER_TYPE);
+ }
+
private IJavaAnnotation fOverlay;
public DartMarkerAnnotation(IMarker marker) {
@@ -62,15 +79,26 @@ public class DartMarkerAnnotation extends MarkerAnnotation implements IJavaAnnot
}
@Override
- public int getId() {
+ public ErrorCode getId() {
IMarker marker = getMarker();
if (marker == null || !marker.exists()) {
- return -1;
+ return null;
}
if (isProblem()) {
- // TODO(devoncarew): inlined from IJavaScriptModelMarker.ID
- return marker.getAttribute("id", -1);
+ final String qualifiedName = marker.getAttribute("errorCode", (String) null);
+ if (qualifiedName != null) {
+ return ExecutionUtils.runObjectIgnore(new RunnableObjectEx<ErrorCode>() {
+ @Override
+ public ErrorCode runObject() throws Exception {
+ String className = StringUtils.substringBeforeLast(qualifiedName, ".");
+ String fieldName = StringUtils.substringAfterLast(qualifiedName, ".");
+ Class<?> errorCodeClass = ErrorCode.class.getClassLoader().loadClass(className);
messick 2012/07/24 16:49:54 I think this would be better if ErrorCode has a he
+ return (ErrorCode) errorCodeClass.getField(fieldName).get(null);
+ }
+ }, null);
+ }
+ return null;
}
// if (TASK_ANNOTATION_TYPE.equals(getAnnotationType())) {
@@ -83,7 +111,7 @@ public class DartMarkerAnnotation extends MarkerAnnotation implements IJavaAnnot
// }
// }
- return -1;
+ return null;
}
@Override

Powered by Google App Engine
This is Rietveld 408576698