Author: dazarov
Date: 2012-07-18 14:07:02 -0400 (Wed, 18 Jul 2012)
New Revision: 42634
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
Log:
Make Quick Fix "Add @SuppressWarnings" work on Temporary annotations https://issues.jboss.org/browse/JBIDE-12303
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-07-18 12:09:03 UTC (rev 42633)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-07-18 18:07:02 UTC (rev 42634)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaMarkerAnnotation;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.ui.IMarkerResolution;
@@ -49,9 +50,8 @@
String preferenceKey = getPreferenceKey(marker);
String preferencePageId = getPreferencePageId(marker);
if(preferenceKey != null && preferencePageId != null){
- boolean enabled = marker.getAttribute(ValidationErrorManager.SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, false);
int severity = marker.getAttribute(IMarker.SEVERITY, 0);
- if(enabled && severity == IMarker.SEVERITY_WARNING){
+ if(severity == IMarker.SEVERITY_WARNING){
IJavaElement element = findJavaElement(file, position);
if(element != null){
if(element instanceof IMethod){
@@ -169,22 +169,24 @@
if(preferenceKey != null && preferencePageId != null){
if(annotation instanceof TempJavaProblemAnnotation){
TempJavaProblemAnnotation tAnnotation = (TempJavaProblemAnnotation)annotation;
- int position = getPosition(tAnnotation);
- IFile file = getFile(tAnnotation);
- if(file != null){
- IJavaElement element = findJavaElement(tAnnotation, position);
- if(element != null){
- if(element instanceof IMethod){
- try{
- ILocalVariable parameter = findParameter((IMethod)element, position);
- if(parameter != null){
- proposals.add(new AddSuppressWarningsMarkerResolution(file, parameter, preferenceKey, tAnnotation.getCompilationUnit()));
+ if(JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(tAnnotation.getType())){
+ int position = getPosition(tAnnotation);
+ IFile file = getFile(tAnnotation);
+ if(file != null){
+ IJavaElement element = findJavaElement(tAnnotation, position);
+ if(element != null){
+ if(element instanceof IMethod){
+ try{
+ ILocalVariable parameter = findParameter((IMethod)element, position);
+ if(parameter != null){
+ proposals.add(new AddSuppressWarningsMarkerResolution(file, parameter, preferenceKey, tAnnotation.getCompilationUnit()));
+ }
+ }catch(JavaModelException ex){
+ CommonUIPlugin.getDefault().logError(ex);
}
- }catch(JavaModelException ex){
- CommonUIPlugin.getDefault().logError(ex);
}
+ proposals.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey, tAnnotation.getCompilationUnit()));
}
- proposals.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey, tAnnotation.getCompilationUnit()));
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-07-18 12:09:03 UTC (rev 42633)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-07-18 18:07:02 UTC (rev 42634)
@@ -51,7 +51,6 @@
static String VALIDATION_MARKER_GROUP = "groupName"; //$NON-NLS-1$
public static final String PREFERENCE_KEY_ATTRIBUTE_NAME = "preference_key"; //$NON-NLS-1$
public static final String PREFERENCE_PAGE_ID_NAME = "preference_page_id"; //$NON-NLS-1$
- public static final String SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE = "sup_warn_ena"; //$NON-NLS-1$
public static final String MESSAGE_ID_ATTRIBUTE_NAME = "Message_id"; //$NON-NLS-1$
protected IStatus OK_STATUS = new Status(IStatus.OK, "org.eclipse.wst.validation", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -174,13 +173,6 @@
CommonPlugin.getDefault().logError(e);
}
- if(marker != null){
- try {
- marker.setAttribute(SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, true);
- } catch (CoreException e) {
- CommonPlugin.getDefault().logError(e);
- }
- }
return marker;
}