Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ public IMarkerResolution[] getResolutions(IMarker marker) {
String propertyPageId = info.getPropertyPageId();
String preferencePageId = info.getPreferencePageId();
String pluginId = info.getPluginId();
int severity = marker.getAttribute(IMarker.SEVERITY, 0);
if(severity == IMarker.SEVERITY_WARNING){
IJavaElement element = findJavaElement((IFile)resource, position);
if(element != null){
if(element instanceof IMethod){
ILocalVariable parameter = findParameter((IMethod)element, position);
if(parameter != null){
resolutions.add(new AddSuppressWarningsMarkerResolution((IFile)resource, parameter, preferenceKey));
if(resource instanceof IFile) {
int severity = marker.getAttribute(IMarker.SEVERITY, 0);
if(severity == IMarker.SEVERITY_WARNING){
IJavaElement element = findJavaElement((IFile)resource, position);
if(element != null){
if(element instanceof IMethod){
ILocalVariable parameter = findParameter((IMethod)element, position);
if(parameter != null){
resolutions.add(new AddSuppressWarningsMarkerResolution((IFile)resource, parameter, preferenceKey));
}
}
resolutions.add(new AddSuppressWarningsMarkerResolution((IFile)resource, element, preferenceKey));
}
resolutions.add(new AddSuppressWarningsMarkerResolution((IFile)resource, element, preferenceKey));
}
}
resolutions.add(new ConfigureProblemSeverityMarkerResolution(resource.getProject(), preferencePageId, propertyPageId, preferenceKey, pluginId));
Expand Down Expand Up @@ -113,7 +115,7 @@ private ILocalVariable findParameter(IMethod method, int position) throws JavaMo
}

private boolean hasResolutions(String preferenceKey, String markerType, IPreferenceInfo markerInfo, IResource resource){
return preferenceKey != null && markerType != null && markerInfo != null && resource instanceof IFile;
return preferenceKey != null && markerType != null && markerInfo != null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -30,6 +31,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.wst.validation.internal.MarkerManager;
import org.eclipse.wst.validation.internal.TaskListUtility;
import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
Expand Down Expand Up @@ -604,7 +606,26 @@ public void removeAllMessagesFromResource(IResource resource) {
// reporter.removeAllMessages(validationManager, resource);
WorkbenchReporter.removeAllMessages(resource, new String[]{getMarkerOwner().getName()}, null);
}


/**
* Removes markers from the project. Doesn't remove markers from child resources.
*/
public void removeAllMessagesFromProject(IProject project) {
Set<IMarker> markersToRemove = new HashSet<IMarker>();
try {
IMarker[] allMarkers = project.findMarkers(DEFAULT_VALIDATION_MARKER, true, IResource.DEPTH_ZERO);
for (IMarker marker : allMarkers) {
Object owner = marker.getAttribute(VALIDATION_MARKER_OWNER);
if(getMarkerOwner().getName().equals(owner)) {
markersToRemove.add(marker);
}
}
ResourcesPlugin.getWorkspace().deleteMarkers(markersToRemove.toArray(new IMarker[markersToRemove.size()]));
} catch (CoreException e) {
CommonPlugin.getDefault().logError(e);
}
}

/*
* register IPreferenceInfo in PreferenceInfoManager
* validator is supposed to have own implementation of IPreferenceInfo
Expand Down