Java 类org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta 实例源码

项目:xtext-core    文件:DefaultResourceDescriptionManagerTest.java   
@Test public void testIsAffected() {
    DefaultResourceDescriptionDelta delta = new DefaultResourceDescriptionDelta(null, resourceDescription);
    assertFalse(manager.isAffected(delta, resourceDescription));
    importedNames = Collections.singleton(QualifiedName.create("eclass"));
    assertTrue(manager.isAffected(delta, resourceDescription));
    importedNames = Collections.singleton(QualifiedName.create("ECLASS"));
    assertFalse(manager.isAffected(delta, resourceDescription));
}
项目:n4js    文件:N4JSGenerateImmediatelyBuilderState.java   
/**
 * Overriding this method to make sure that resources of all affected URIs are fully re-loaded if needed, instead of
 * only loading the TModule from the corresponding resource description.
 * <p>
 * This is required in case the URIs in an affected resource contain indices of a changed resource; just loading the
 * TModule from the user data won't update these indices. For details see the example provided in IDEBUG-347.
 * <p>
 * NOTE: this should be removed once the URI scheme has been changed to use names instead of indices.
 */
@Override
protected void queueAffectedResources(
        Set<URI> allRemainingURIs,
        IResourceDescriptions oldState,
        CurrentDescriptions newState,
        Collection<Delta> changedDeltas,
        Collection<Delta> allDeltas,
        BuildData buildData,
        final IProgressMonitor monitor) {

    // don't wanna copy super-class method, so using this helper to get the set of affected URIs:
    final Set<URI> affectedURIs = new HashSet<>(allRemainingURIs);

    super.queueAffectedResources(allRemainingURIs, oldState, newState, changedDeltas, allDeltas, buildData,
            monitor);

    // affected URIs have been removed from allRemainingURIs by super class
    affectedURIs.removeAll(allRemainingURIs);

    for (URI currAffURI : affectedURIs) {
        final IResourceDescription resDesc = this.getResourceDescription(currAffURI);
        if (!N4MF_MANIFEST.equals(currAffURI.lastSegment())) {

            /*-
             * This logic here is required to get rid of the invalid serialized TModules information from the index
             * which are working with an index based approach. Consider the below example:
             *
             * -------Module A------
             *1    //class XYZ { }
             *2    function foo() { }
             *3    export public class A { }
             *
             * -------Module B------
             *1    import { A } from "A"
             *2    import { C } from "C"
             *3
             *4    var arrCC : Array<A>;
             *5    var t2 : C = new C();
             *6    t2.m(arrCC);
             *
             * -------Module C------
             *1    import { A } from "A"
             *2
             *3    export public class C {
             *4        m(param : Array<A>) { }
             *5    }
             *
             *
             * Commenting out line 1 in module A will trigger rebuild of A, and related module B and C in this order.
             * When loading module B, module C has to be resolved as it imports it, quickly jump to module C and load
             * class A from module A, class A used to have index 1 (in the serialized TModule in the Xtext index) as
             * it was the second top level element, but that is not true any more, because 'foo' was just commented out,
             * so index 1 in module A is not class A any more but 'foo'. With this, line 6 in module B will fail,
             * because it will think that the method 'm' accepts an array of 'foo' and not A any more.
             *
             * The following code will be executed after A was processed and B and C are the "affectedURIs". With this
             * code, we make sure that the cached TModule of C (in the user data of C's resource description) won't be
             * used while processing B during proxy resolution.
             */
            newState.register(new DefaultResourceDescriptionDelta(resDesc,
                    new ResourceDescriptionWithoutModuleUserData(resDesc)));
        }
    }
}
项目:xtext-extras    文件:JavaResourceDescriptionManager.java   
@Override
public IResourceDescription.Delta createDelta(final IResourceDescription oldDescription, final IResourceDescription newDescription) {
  return new DefaultResourceDescriptionDelta(oldDescription, newDescription);
}
项目:xtext-core    文件:GenericResourceDescriptionManager.java   
@Override
public Delta createDelta(IResourceDescription oldDescription, IResourceDescription newDescription) {
    return new DefaultResourceDescriptionDelta(oldDescription, newDescription);
}