Search in sources :

Example 1 with ErlElementDelta

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;
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlElementDelta(org.erlide.engine.model.root.IErlElementDelta) IErlElementDelta(org.erlide.engine.model.root.IErlElementDelta) ErlElementDelta(org.erlide.engine.internal.model.root.ErlElementDelta) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Aggregations

IResourceDelta (org.eclipse.core.resources.IResourceDelta)1 ErlElementDelta (org.erlide.engine.internal.model.root.ErlElementDelta)1 IErlElement (org.erlide.engine.model.IErlElement)1 IErlElementDelta (org.erlide.engine.model.root.IErlElementDelta)1