Search in sources :

Example 1 with Notifier

use of org.eclipse.emf.common.notify.Notifier in project xtext-core by eclipse.

the class ChangeSerializer method applyModifications.

@Override
public void applyModifications(IAcceptor<IEmfResourceChange> changeAcceptor) {
    monitor.setTaskName("Preparing Text Changes...");
    Set<Resource> resources = Sets.newLinkedHashSet();
    for (Pair<Notifier, IModification<? extends Notifier>> p : modifications) {
        Notifier context = p.getFirst();
        if (context instanceof EObject)
            resources.add(((EObject) context).eResource());
        else if (context instanceof Resource)
            resources.add((Resource) context);
        else if (context instanceof ResourceSet) {
            throw new IllegalStateException("Not supported");
        }
    }
    for (Resource res : resources) {
        // TODO: use the exact context
        beginRecordChanges(res);
    }
    checkCanceled();
    for (Pair<Notifier, IModification<? extends Notifier>> entry : modifications) {
        apply(entry.getFirst(), entry.getSecond());
    }
    checkCanceled();
    endRecordChanges(changeAcceptor);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) RelatedResource(org.eclipse.xtext.ide.serializer.impl.RelatedResourcesProvider.RelatedResource) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Notifier(org.eclipse.emf.common.notify.Notifier)

Aggregations

Notifier (org.eclipse.emf.common.notify.Notifier)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 RelatedResource (org.eclipse.xtext.ide.serializer.impl.RelatedResourcesProvider.RelatedResource)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1