Search in sources :

Example 1 with IEObjectDescriptionProvider

use of org.eclipse.xtext.ide.serializer.hooks.IEObjectDescriptionProvider in project xtext-core by eclipse.

the class EObjectDescriptionDeltaProvider method getDelta.

public Deltas getDelta(ChangeSerializer serializer, Collection<IResourceSnapshot> snapshots) {
    Map<EObject, IEObjectSnapshot> old = Maps.newHashMap();
    Map<EObject, Group> groups = Maps.newHashMap();
    for (IResourceSnapshot rs : snapshots) {
        old.putAll(rs.getObjects());
    }
    for (IResourceSnapshot rs : snapshots) {
        IEObjectDescriptionProvider p = serializer.getService(rs.getResource(), IEObjectDescriptionProvider.class);
        Iterable<IEObjectDescription> descriptions = p.getEObjectDescriptions(rs.getResource());
        for (IEObjectDescription desc : descriptions) {
            EObject obj = EcoreUtil.resolve(desc.getEObjectOrProxy(), rs.getResource());
            Group delta = groups.get(obj);
            if (delta == null) {
                delta = new Group(obj);
                delta.snapshot = old.get(obj);
                groups.put(obj, delta);
            }
            delta.descriptions.add(desc);
        }
    }
    Deltas result = new Deltas();
    result.snapshots = snapshots;
    for (Group g : groups.values()) {
        Delta delta = createDelta(g.object, g.snapshot, g.descriptions);
        if (delta.hasQualifiedNameChanged() || delta.hasSimpleNameOrUserdataChanged()) {
            result.deltas.put(delta.object, delta);
        }
    }
    return result;
}
Also used : IEObjectSnapshot(org.eclipse.xtext.ide.serializer.hooks.IEObjectSnapshot) IResourceSnapshot(org.eclipse.xtext.ide.serializer.hooks.IResourceSnapshot) EObject(org.eclipse.emf.ecore.EObject) IEObjectDescriptionProvider(org.eclipse.xtext.ide.serializer.hooks.IEObjectDescriptionProvider) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 IEObjectDescriptionProvider (org.eclipse.xtext.ide.serializer.hooks.IEObjectDescriptionProvider)1 IEObjectSnapshot (org.eclipse.xtext.ide.serializer.hooks.IEObjectSnapshot)1 IResourceSnapshot (org.eclipse.xtext.ide.serializer.hooks.IResourceSnapshot)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1