Search in sources :

Example 1 with ChangedResourceDescriptionDelta

use of org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta in project xtext-core by eclipse.

the class StateBasedContainerTest method testBug352214.

@Override
@Test
public void testBug352214() {
    // initialize uri map
    container.getResourceDescriptions();
    ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(Collections.<IResourceDescription.Delta>singletonList(new ChangedResourceDescriptionDelta(resourceDescription, null)));
    simulateEmpty = true;
    container.descriptionsChanged(event);
    assertEquals(0, container.getResourceDescriptionCount());
    assertTrue(Iterables.all(container.getResourceDescriptions(), Predicates.notNull()));
    assertFalse(container.hasResourceDescription(uri));
    assertNull(container.getResourceDescription(uri));
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ChangedResourceDescriptionDelta(org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta) ResourceDescriptionChangeEvent(org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent) ResourceDescriptionsBasedContainerTest(org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedContainerTest) Test(org.junit.Test)

Example 2 with ChangedResourceDescriptionDelta

use of org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta in project xtext-eclipse by eclipse.

the class ValidationJobScheduler method doScheduleInitialValidation.

protected void doScheduleInitialValidation(XtextDocument document) {
    URI uri = document.getResourceURI();
    if (uri == null)
        return;
    IResourceDescription documentDescription = resourceDescriptions.getResourceDescription(uri);
    if (documentDescription == null) {
        // resource was just created - build is likely to be running in background
        return;
    }
    if (dirtyStateManager instanceof IDirtyStateManagerExtension && builderStateProvider != null) {
        IResourceDescriptions persistedDescriptions = builderStateProvider.get();
        List<URI> dirtyResourceURIs = ((IDirtyStateManagerExtension) dirtyStateManager).getDirtyResourceURIs();
        for (URI dirtyResourceURI : dirtyResourceURIs) {
            IResourceDescription dirtyDescription = dirtyStateManager.getDirtyResourceDescription(dirtyResourceURI);
            if (dirtyDescription != null) {
                IResourceDescription persistedDescription = persistedDescriptions.getResourceDescription(dirtyResourceURI);
                // Shortcut to make sure we don't waste time with more involving haveEObjectDescriptionChanged computation
                ChangedResourceDescriptionDelta delta = new ChangedResourceDescriptionDelta(persistedDescription, dirtyDescription);
                if (resourceDescriptionManager.isAffected(delta, documentDescription)) {
                    document.checkAndUpdateAnnotations();
                    return;
                }
            }
        }
    } else {
        Set<URI> outgoingReferences = descriptionUtils.collectOutgoingReferences(documentDescription);
        for (URI outgoing : outgoingReferences) {
            if (isDirty(outgoing)) {
                document.checkAndUpdateAnnotations();
                return;
            }
        }
    }
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ChangedResourceDescriptionDelta(org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) URI(org.eclipse.emf.common.util.URI)

Example 3 with ChangedResourceDescriptionDelta

use of org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta in project xtext-eclipse by eclipse.

the class JdtToBeBuiltComputer method queueJavaChange.

protected void queueJavaChange(String typeName) {
    URI typeURI = URIHelperConstants.OBJECTS_URI.appendSegment(typeName);
    QualifiedName qualifiedName = QualifiedName.create(Strings.split(typeName, '.'));
    NameBasedEObjectDescription nameBasedEObjectDescription = new NameBasedEObjectDescription(qualifiedName);
    TypeResourceDescription oldDescription = new TypeResourceDescription(typeURI, Collections.<IEObjectDescription>singletonList(nameBasedEObjectDescription));
    Delta delta = new ChangedResourceDescriptionDelta(oldDescription, null);
    queuedBuildData.queueChange(delta);
}
Also used : ChangedResourceDescriptionDelta(org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta) NameBasedEObjectDescription(org.eclipse.xtext.common.types.ui.notification.NameBasedEObjectDescription) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) ChangedResourceDescriptionDelta(org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta) QualifiedName(org.eclipse.xtext.naming.QualifiedName) TypeResourceDescription(org.eclipse.xtext.common.types.ui.notification.TypeResourceDescription) URI(org.eclipse.emf.common.util.URI)

Aggregations

ChangedResourceDescriptionDelta (org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta)3 URI (org.eclipse.emf.common.util.URI)2 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)2 NameBasedEObjectDescription (org.eclipse.xtext.common.types.ui.notification.NameBasedEObjectDescription)1 TypeResourceDescription (org.eclipse.xtext.common.types.ui.notification.TypeResourceDescription)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 IResourceDescriptions (org.eclipse.xtext.resource.IResourceDescriptions)1 ResourceDescriptionChangeEvent (org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)1 ResourceDescriptionsBasedContainerTest (org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedContainerTest)1 Test (org.junit.Test)1