Author: dazarov
Date: 2012-07-25 19:02:33 -0400 (Wed, 25 Jul 2012)
New Revision: 42729
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
Log:
Make CDI Quick Fixes work for As-You-Type validator annotations
https://issues.jboss.org/browse/JBIDE-12328
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2012-07-25
22:39:31 UTC (rev 42728)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2012-07-25
23:02:33 UTC (rev 42729)
@@ -68,6 +68,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.quickfix.IQuickFixGenerator;
+import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.common.validation.java.TempJavaProblem;
import org.jboss.tools.common.validation.java.TempJavaProblemAnnotation;
@@ -104,10 +105,11 @@
}
private int getMessageID(TemporaryAnnotation annotation){
- Integer attribute = ((Integer)
annotation.getAttributes().get(CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME));
- if (attribute != null)
- return attribute.intValue();
-
+ if(annotation.getAttributes() != null){
+ Integer attribute = ((Integer)
annotation.getAttributes().get(CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME));
+ if (attribute != null)
+ return attribute.intValue();
+ }
return -1;
}
@@ -1072,7 +1074,7 @@
}else if(annotation instanceof TemporaryAnnotation){
TemporaryAnnotation tempAnnotation = (TemporaryAnnotation)annotation;
- IFile file = getFile();
+ IFile file = MarkerResolutionUtils.getFile();
int messageId = getMessageID(tempAnnotation);
int start = tempAnnotation.getPosition().getOffset();
int end = start + tempAnnotation.getPosition().getLength();
@@ -1086,20 +1088,5 @@
return null;
}
- private static IFile getFile(){
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window != null){
- IWorkbenchPage page = window.getActivePage();
- if(page != null){
- IEditorPart editor = page.getActiveEditor();
- if(editor != null){
- IEditorInput input = editor.getEditorInput();
- if(input instanceof IFileEditorInput){
- return ((IFileEditorInput) input).getFile();
- }
- }
- }
- }
- return null;
- }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-07-25
22:39:31 UTC (rev 42728)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-07-25
23:02:33 UTC (rev 42729)
@@ -15,6 +15,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
@@ -49,6 +50,12 @@
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.jboss.tools.common.util.EclipseJavaUtil;
public class MarkerResolutionUtils {
@@ -689,4 +696,21 @@
}
return buf.toString();
}
+
+ public static IFile getFile(){
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if(window != null){
+ IWorkbenchPage page = window.getActivePage();
+ if(page != null){
+ IEditorPart editor = page.getActiveEditor();
+ if(editor != null){
+ IEditorInput input = editor.getEditorInput();
+ if(input instanceof IFileEditorInput){
+ return ((IFileEditorInput) input).getFile();
+ }
+ }
+ }
+ }
+ return null;
+ }
}