diff --git a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/action/ValidateAction.java b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/action/ValidateAction.java index 004650ba55..3e794485fd 100644 --- a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/action/ValidateAction.java +++ b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/action/ValidateAction.java @@ -14,8 +14,10 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; @@ -335,8 +337,16 @@ protected void handleDiagnostic(final Diagnostic diagnostic) } ResourceSet resourceSet = domain.getResourceSet(); - Resource resource = eclipseResourcesUtil != null ? resourceSet.getResources().get(0) : null; - if (resource != null) + final Set resources = new LinkedHashSet(); + if (eclipseResourcesUtil != null) + { + for (Object data : diagnostic.getData()) + { + resources.add(data instanceof EObject ? ((EObject)data).eResource() : null); + } + resources.remove(null); + } + for (Resource resource : resources) { eclipseResourcesUtil.deleteMarkers(resource); } @@ -364,30 +374,35 @@ else if (part instanceof IViewerProvider) } } - if (resource != null) + if (eclipseResourcesUtil != null) { - final Resource finalResource = resource; IRunnableWithProgress runnable = new IRunnableWithProgress() - { - public void run(IProgressMonitor progressMonitor) { - int count = 0; - int limit = getLimit(); - for (Diagnostic childDiagnostic : diagnostic.getChildren()) + public void run(IProgressMonitor progressMonitor) { - if (progressMonitor.isCanceled() || ++count > limit) + int count = 0; + int limit = getLimit(); + for (Diagnostic childDiagnostic : diagnostic.getChildren()) { - return; + if (progressMonitor.isCanceled() || ++count > limit) + { + return; + } + List data = childDiagnostic.getData(); + if (!data.isEmpty()) + { + Object object = data.get(0); + Resource resource = object instanceof EObject ? ((EObject)object).eResource() : null; + if (resource != null) + { + eclipseResourcesUtil.createMarkers(resource, childDiagnostic); + } + } } - eclipseResourcesUtil.createMarkers(finalResource, childDiagnostic); } - } - }; + }; - if (eclipseResourcesUtil != null) - { - runnable = eclipseResourcesUtil.getWorkspaceModifyOperation(runnable); - } + runnable = eclipseResourcesUtil.getWorkspaceModifyOperation(runnable); try { @@ -403,10 +418,10 @@ public void run(IProgressMonitor progressMonitor) { // Trigger direct updating of decorations, if there are adapters. // - resource = null; + resources.clear(); } - if (resource == null) + if (resources.isEmpty()) { // If no markers are produced the decorator won't be able to respond to marker resource deltas, so inform it directly. //