View | Details | Raw Unified | Return to bug 295841
Collapse All | Expand All

(-)src/org/eclipse/emf/validation/marker/MarkerUtil.java (-17 / +44 lines)
Lines 167-180 Link Here
167
				final Map<URI, IFile> visitedResources = new HashMap<URI, IFile>();
167
				final Map<URI, IFile> visitedResources = new HashMap<URI, IFile>();
168
				
168
				
169
				if (validationStatus.isMultiStatus()) {
169
				if (validationStatus.isMultiStatus()) {
170
					IStatus[] children = validationStatus.getChildren();
170
					createMarkers(validationStatus, severityMask, markerType, configurator, visitedResources);
171
					for (IStatus element : children) {
172
						if (element.matches(severityMask)
173
								&& (element instanceof IConstraintStatus)) {
174
							
175
							createMarker((IConstraintStatus)element, markerType, configurator, visitedResources);
176
						}
177
					}
178
				} else if (validationStatus.matches(severityMask)
171
				} else if (validationStatus.matches(severityMask)
179
						&& (validationStatus instanceof IConstraintStatus)) {
172
						&& (validationStatus instanceof IConstraintStatus)) {
180
					
173
					
Lines 185-190 Link Here
185
		
178
		
186
		ResourcesPlugin.getWorkspace().run(runnable, null);
179
		ResourcesPlugin.getWorkspace().run(runnable, null);
187
	}
180
	}
181
	
182
	private static void createMarkers(IStatus validationStatus,
183
            int severityMask, String markerType,
184
            IMarkerConfigurator configurator, Map<URI, IFile> visitedResources)
185
            throws CoreException {
186
187
        IStatus[] children = validationStatus.getChildren();
188
        for (IStatus element : children) {
189
            // recursively unwrap all children of multi-statuses
190
            if (element.isMultiStatus()) {
191
                createMarkers(element, severityMask, markerType, configurator, visitedResources);
192
            } else if (element.matches(severityMask)
193
                    && (element instanceof IConstraintStatus)) {
194
195
                createMarker((IConstraintStatus)element, markerType, configurator, visitedResources);
196
            }
197
        }
198
    }
188
199
189
	private static void createMarker(IConstraintStatus status,
200
	private static void createMarker(IConstraintStatus status,
190
			String markerType, IMarkerConfigurator configurator,
201
			String markerType, IMarkerConfigurator configurator,
Lines 420-428 Link Here
420
431
421
				// First we need to inspect the status and if it is a
432
				// First we need to inspect the status and if it is a
422
				// multistatus then
433
				// multistatus then
423
				// we group all status related to the same file together. Each
434
				// we group all status related to the same file together. This needs 
435
				// to be done recursively for all occurring multi-statuses. Each
424
				// file
436
				// file
425
				// is associated with a status list. This way we can a file by
437
				// is associated with a status list. This way we can achieve a file by
426
				// file
438
				// file
427
				// approach, allowing us to first delete the previous markers of
439
				// approach, allowing us to first delete the previous markers of
428
				// a
440
				// a
Lines 430-442 Link Here
430
				// its
442
				// its
431
				// status list.
443
				// status list.
432
				if (validationStatus.isMultiStatus()) {
444
				if (validationStatus.isMultiStatus()) {
433
					IStatus[] children = validationStatus.getChildren();
445
					updateMarkers(validationStatus, severityMask, resourcesToVisit);
434
					for (IStatus next : children) {
435
						if (shouldAddStatus(next, severityMask)) {
436
							addStatus((IConstraintStatus) next,
437
								resourcesToVisit);
438
						}
439
					}
440
				} else if (shouldAddStatus(validationStatus, severityMask)) {
446
				} else if (shouldAddStatus(validationStatus, severityMask)) {
441
					addStatus((IConstraintStatus) validationStatus,
447
					addStatus((IConstraintStatus) validationStatus,
442
						resourcesToVisit);
448
						resourcesToVisit);
Lines 457-462 Link Here
457
		ResourcesPlugin.getWorkspace().run(runnable, null);
463
		ResourcesPlugin.getWorkspace().run(runnable, null);
458
	}
464
	}
459
	
465
	
466
	private static void updateMarkers(IStatus validationStatus,
467
            int severityMask, Map<URI, FileStatusListPair> resourcesToVisit) {
468
469
        if (validationStatus.isMultiStatus()) {
470
            IStatus[] children = validationStatus.getChildren();
471
            for (IStatus next : children) {
472
                // recursively unwrap all children of multi-statuses
473
                if (next.isMultiStatus()) {
474
                    updateMarkers(next, severityMask, resourcesToVisit);
475
                } else if (shouldAddStatus(next, severityMask)) {
476
                    addStatus((IConstraintStatus) next,
477
                        resourcesToVisit);
478
                }
479
            }
480
        } else if (shouldAddStatus(validationStatus, severityMask)) {
481
            addStatus((IConstraintStatus) validationStatus,
482
                resourcesToVisit);
483
        }
484
485
    }
486
	
460
	private static boolean shouldAddStatus(IStatus status, int severityMask) {
487
	private static boolean shouldAddStatus(IStatus status, int severityMask) {
461
		return (status.matches(severityMask) && (status instanceof IConstraintStatus))
488
		return (status.matches(severityMask) && (status instanceof IConstraintStatus))
462
			|| (status instanceof ResourceStatus);
489
			|| (status instanceof ResourceStatus);

Return to bug 295841