use of org.eclipse.xtext.ui.editor.model.edit.BatchModification in project xtext-eclipse by eclipse.
the class WorkbenchMarkerResolutionAdapter method run.
@Override
public void run(IMarker[] markers, IProgressMonitor progressMonitor) {
Map<IProject, List<IMarker>> markersByProject = //
Arrays.asList(markers).stream().collect(Collectors.groupingBy(marker -> marker.getResource().getProject()));
SubMonitor monitor = SubMonitor.convert(progressMonitor);
monitor.beginTask("Applying resolutions", markersByProject.size());
markersByProject.forEach((key, value) -> {
BatchModification batch = batchModificationProvider.get();
batch.setProject(key);
List<IBatchableModification> modifications = new ArrayList<>();
List<IMarker> markersInProject = value;
markersInProject.forEach(marker -> {
IssueResolution resolution = resolution(marker);
if (resolution != null) {
IModification modification = resolution.getModification();
if (modification instanceof IBatchableModification) {
modifications.add((IBatchableModification) modification);
}
}
});
cancelIfNeeded(monitor);
batch.apply(modifications, monitor.newChild(1));
cancelIfNeeded(monitor);
});
monitor.done();
}
Aggregations