Search in sources :

Example 1 with Deltas

use of org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas in project xtext-core by eclipse.

the class ReferenceUpdater method needsUpdating.

protected boolean needsUpdating(IReferenceUpdaterContext context, IUpdatableReference ref) {
    QualifiedName fqn = getQualifiedName(ref);
    if (fqn == null) {
        return false;
    }
    EObject target = ref.getTargetEObject();
    Deltas deltas = context.getEObjectDescriptionDeltas();
    Delta delta = deltas.getDelta(target);
    if (delta != null && !containsReferenceText(delta, fqn)) {
        return true;
    }
    Delta targetDelta = findContainingDelta(deltas, target);
    if (targetDelta != null && targetDelta.getObject() == target) {
        return true;
    }
    Delta sourceDelta = findContainingDelta(deltas, ref.getSourceEObject());
    return !Objects.equal(sourceDelta, targetDelta);
}
Also used : Deltas(org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas) Delta(org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Delta) QualifiedName(org.eclipse.xtext.naming.QualifiedName) EObject(org.eclipse.emf.ecore.EObject)

Example 2 with Deltas

use of org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas in project xtext-core by eclipse.

the class ChangeSerializer method endRecordChanges.

protected void endRecordChanges(IAcceptor<IEmfResourceChange> changeAcceptor) {
    if (updaters.isEmpty()) {
        return;
    }
    List<IResourceSnapshot> snapshots = getSnapshots();
    Deltas deltas = deltaProvider.getDelta(this, snapshots);
    List<ResourceUpdater> updaters = Lists.newArrayList(this.updaters.values());
    if (updateRelatedFiles && updateCrossReferences) {
        List<RelatedResource> related = relatedResourcesProvider.getRelatedResources(deltas.getSnapshots());
        for (RelatedResource ref : related) {
            RelatedResourceUpdater updater = createResourceUpdater(ref);
            updaters.add(updater);
        }
    }
    monitor.beginTask("Creating Text Changes...", updaters.size());
    for (ResourceUpdater updater : updaters) {
        updater.applyChange(deltas, changeAcceptor);
        monitor.worked(1);
        checkCanceled();
    }
    for (ResourceUpdater updater : updaters) {
        updater.unload();
    }
}
Also used : Deltas(org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas) RelatedResource(org.eclipse.xtext.ide.serializer.impl.RelatedResourcesProvider.RelatedResource) IResourceSnapshot(org.eclipse.xtext.ide.serializer.hooks.IResourceSnapshot)

Aggregations

Deltas (org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas)2 EObject (org.eclipse.emf.ecore.EObject)1 IResourceSnapshot (org.eclipse.xtext.ide.serializer.hooks.IResourceSnapshot)1 Delta (org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Delta)1 RelatedResource (org.eclipse.xtext.ide.serializer.impl.RelatedResourcesProvider.RelatedResource)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1