use of org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent in project xtext-eclipse by eclipse.
the class DirtyStateAwareResourceDescriptions method globalDescriptionsChanged.
public void globalDescriptionsChanged(IResourceDescription.Event event) {
ResourceDescriptionChangeEvent changeEvent = new ResourceDescriptionChangeEvent(Iterables.filter(event.getDeltas(), new Predicate<IResourceDescription.Delta>() {
@Override
public boolean apply(Delta input) {
URI uri = input.getUri();
return !dirtyStateManager.hasContent(uri);
}
}));
notifyListeners(changeEvent);
}
use of org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent in project xtext-eclipse by eclipse.
the class AbstractBuilderState method update.
@Override
public synchronized ImmutableList<IResourceDescription.Delta> update(BuildData buildData, IProgressMonitor monitor) {
ensureLoaded();
final SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.AbstractBuilderState_0, 1);
subMonitor.subTask(Messages.AbstractBuilderState_0);
if (buildData.isEmpty())
return ImmutableList.of();
if (monitor.isCanceled())
throw new OperationCanceledException();
final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
final Collection<IResourceDescription.Delta> result = doUpdate(buildData, newData, subMonitor.split(1));
if (monitor.isCanceled())
throw new OperationCanceledException();
final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result);
// update the reference
setResourceDescriptionsData(newData);
notifyListeners(event);
return event.getDeltas();
}
use of org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent in project xtext-eclipse by eclipse.
the class AbstractBuilderState method clean.
@Override
public synchronized ImmutableList<IResourceDescription.Delta> clean(Set<URI> toBeRemoved, IProgressMonitor monitor) throws OperationCanceledException {
ensureLoaded();
toBeRemoved = ensureNotNull(toBeRemoved);
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.AbstractBuilderState_0, 2);
subMonitor.subTask(Messages.AbstractBuilderState_0);
if (toBeRemoved.isEmpty())
return ImmutableList.of();
if (monitor.isCanceled())
throw new OperationCanceledException();
Collection<IResourceDescription.Delta> deltas = doClean(toBeRemoved, subMonitor.split(1));
final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
if (monitor.isCanceled())
throw new OperationCanceledException();
for (IResourceDescription.Delta delta : deltas) {
newData.removeDescription(delta.getOld().getURI());
}
ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(deltas);
if (monitor.isCanceled())
throw new OperationCanceledException();
int i = 0;
subMonitor.setWorkRemaining(toBeRemoved.size() / MONITOR_CHUNK_SIZE_CLEAN + 1);
for (IResourceDescription.Delta delta : event.getDeltas()) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
updateMarkers(delta, null, subMonitor);
i++;
if (i % MONITOR_CHUNK_SIZE_CLEAN == 0)
subMonitor.worked(1);
}
// update the reference
setResourceDescriptionsData(newData);
notifyListeners(event);
return event.getDeltas();
}
use of org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent in project xtext-eclipse by eclipse.
the class DirtyStateManager method notifyListeners.
/**
* @since 2.22
*/
protected void notifyListeners(IResourceDescription prevDirtyDescription, IDirtyResource dirtyResource) {
IResourceDescription.Delta delta = new IResourceDescription.Delta() {
@Override
public boolean haveEObjectDescriptionsChanged() {
return true;
}
@Override
public IResourceDescription getOld() {
return prevDirtyDescription;
}
@Override
public IResourceDescription getNew() {
return dirtyResource.getDescription();
}
@Override
public URI getUri() {
return dirtyResource.getURI();
}
};
notifyListeners(new ResourceDescriptionChangeEvent(Collections.singletonList(delta)));
}
use of org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent in project xtext-core by eclipse.
the class StateBasedContainerTest method testBug352214.
@Override
@Test
public void testBug352214() {
// initialize uri map
container.getResourceDescriptions();
ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(Collections.<IResourceDescription.Delta>singletonList(new ChangedResourceDescriptionDelta(resourceDescription, null)));
simulateEmpty = true;
container.descriptionsChanged(event);
assertEquals(0, container.getResourceDescriptionCount());
assertTrue(Iterables.all(container.getResourceDescriptions(), Predicates.notNull()));
assertFalse(container.hasResourceDescription(uri));
assertNull(container.getResourceDescription(uri));
}
Aggregations