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;
}
Aggregations