use of org.eclipse.emf.ecore.change.FeatureChange in project xtext-core by eclipse.
the class ChangeTreeProvider method createChangeTree.
public ResourceSetRecording createChangeTree(ResourceSet resourceSet, Collection<IResourceSnapshot> snapshots, ChangeDescription desc) {
ResourceSetRecording rs = new ResourceSetRecording(resourceSet);
Map<Resource, ResourceRecording> result = Maps.newLinkedHashMap();
Map<EObject, EObjectChange> objectChanges = Maps.newLinkedHashMap();
for (IResourceSnapshot snap : snapshots) {
Resource resource = snap.getResource();
ResourceRecording recording = new ResourceRecording(rs, resource);
recording.snapshot = snap;
result.put(resource, recording);
}
for (ResourceChange rc : desc.getResourceChanges()) {
Resource resource = rc.getResource();
ResourceRecording recording = result.get(resource);
if (recording == null) {
recording = new ResourceRecording(rs, resource);
result.put(resource, recording);
}
recording.resourceChange = rc;
}
for (Entry<EObject, EList<FeatureChange>> e : desc.getObjectChanges().entrySet()) {
EList<FeatureChange> featureChange = e.getValue();
EObject object = e.getKey();
objectChanges.put(object, new EObjectChange(object, featureChange));
}
for (EObjectChange change : Lists.newArrayList(objectChanges.values())) {
EObjectChange current = change;
while (true) {
EObject container = current.eObject.eContainer();
if (container != null) {
EObjectChange next = objectChanges.get(container);
if (next == null) {
next = new EObjectChange(container);
next.children.add(current);
objectChanges.put(container, next);
} else {
if (!next.children.add(current)) {
break;
}
}
current = next;
} else {
Resource resource = current.eObject.eResource();
ResourceRecording resourceChange = result.get(resource);
if (resourceChange == null) {
resourceChange = new ResourceRecording(rs, resource);
result.put(resource, resourceChange);
// TODO: check that only recorded resources contain
// modification
}
resourceChange.roots.add(current);
break;
}
}
}
rs.resources = ImmutableList.copyOf(result.values());
rs.objects = ImmutableMap.copyOf(objectChanges);
return rs;
}
use of org.eclipse.emf.ecore.change.FeatureChange in project xtext-core by eclipse.
the class PartialSerializer method trySerializeIndividualFeatures.
protected List<SerializationStrategy> trySerializeIndividualFeatures(EObjectChange change, IEObjectRegion original, ISerializationContext context, IConstraint constraint) {
List<SerializationStrategy> result = Lists.newArrayList();
EObject object = change.getEObject();
for (FeatureChange featureChange : change.getChanges()) {
EStructuralFeature feature = featureChange.getFeature();
List<SerializationStrategy> values = null;
// } else {
if (feature.isMany()) {
values = trySerializeMultiValue(object, featureChange, original, constraint);
} else {
values = trySerializeSingleValue(object, featureChange, original, constraint);
}
// }
if (values == null) {
return null;
}
result.addAll(values);
}
return result;
}
Aggregations