Search in sources :

Example 1 with GenericResourceDescriptionManager

use of org.eclipse.xtext.resource.generic.GenericResourceDescriptionManager in project xtext-eclipse by eclipse.

the class GenericResourceDescriptionManagerTest method testCreateDeltaAndIsAffected.

@Test
public void testCreateDeltaAndIsAffected() {
    GenericResourceDescriptionManager manager = getEmfResourceDescriptionsManager();
    EClass eClass = EcoreFactory.eINSTANCE.createEClass();
    eClass.setName("Test");
    eClass.getESuperTypes().add(EcorePackage.Literals.EPACKAGE);
    Resource resource = new XMIResourceImpl(URI.createFileURI("test.ecore"));
    resource.getContents().add(eClass);
    EPackage copyOfEPackage = EcoreUtil.copy(EcorePackage.eINSTANCE);
    Resource ecoreResource = new XMIResourceImpl(URI.createURI(copyOfEPackage.getNsURI()));
    ecoreResource.getContents().add(copyOfEPackage);
    IResourceDescription oldDescription = new CopiedResourceDescription(manager.getResourceDescription(ecoreResource));
    oldDescription.getExportedObjects();
    copyOfEPackage.setName("ecore_new");
    IResourceDescription newDescription = manager.getResourceDescription(ecoreResource);
    Delta delta = manager.createDelta(oldDescription, newDescription);
    assertTrue(delta.haveEObjectDescriptionsChanged());
    IResourceDescription referrerDescription = manager.getResourceDescription(resource);
    assertTrue(manager.isAffected(delta, referrerDescription));
}
Also used : CopiedResourceDescription(org.eclipse.xtext.builder.clustering.CopiedResourceDescription) EClass(org.eclipse.emf.ecore.EClass) GenericResourceDescriptionManager(org.eclipse.xtext.resource.generic.GenericResourceDescriptionManager) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) Resource(org.eclipse.emf.ecore.resource.Resource) XMIResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.Test)

Aggregations

EClass (org.eclipse.emf.ecore.EClass)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)1 CopiedResourceDescription (org.eclipse.xtext.builder.clustering.CopiedResourceDescription)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 GenericResourceDescriptionManager (org.eclipse.xtext.resource.generic.GenericResourceDescriptionManager)1 Test (org.junit.Test)1