use of org.erlide.engine.internal.model.root.ErlElementDelta in project erlide_eclipse by erlang.
the class ErlModelDeltaManager method mergeDeltas.
IErlElementDelta mergeDeltas(final Collection<IErlElementDelta> deltas) {
synchronized (deltas) {
if (deltas.isEmpty()) {
return null;
}
if (deltas.size() == 1) {
return deltas.iterator().next();
}
final Iterator<IErlElementDelta> iterator = deltas.iterator();
final IErlElement cRoot = ErlangEngine.getInstance().getModel();
final ErlElementDelta rootDelta = new ErlElementDelta(0, 0, cRoot);
boolean insertedTree = false;
while (iterator.hasNext()) {
final ErlElementDelta delta = (ErlElementDelta) iterator.next();
final IErlElement element = delta.getElement();
if (cRoot.equals(element)) {
final IErlElementDelta[] children = delta.getChildren(IErlElementDelta.ALL);
for (final IErlElementDelta element0 : children) {
final ErlElementDelta projectDelta = (ErlElementDelta) element0;
rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
insertedTree = true;
}
final IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
if (resourceDeltas != null) {
for (final IResourceDelta element0 : resourceDeltas) {
rootDelta.addResourceDelta(element0);
insertedTree = true;
}
}
} else {
rootDelta.insertDeltaTree(element, delta);
insertedTree = true;
}
}
if (insertedTree) {
return rootDelta;
}
return null;
}
}
Aggregations