Search in sources :

Example 1 with CacheAdapter

use of org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter in project xtext-core by eclipse.

the class OnChangeEvictingCacheAdapterTest method testCacheSurvivesChangeToDiagnostics.

@Test
public void testCacheSurvivesChangeToDiagnostics() throws Exception {
    EcoreFactory factory = EcoreFactory.eINSTANCE;
    EClass eClass = factory.createEClass();
    Resource resource = new ResourceImpl();
    resource.getContents().add(eClass);
    CacheAdapter ca = new OnChangeEvictingCache().getOrCreate(resource);
    setValue(ca);
    List<Diagnostic> errors = resource.getErrors();
    assertIsSet(ca);
    errors.clear();
    assertIsSet(ca);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) Resource(org.eclipse.emf.ecore.resource.Resource) CacheAdapter(org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter) Diagnostic(org.eclipse.emf.ecore.resource.Resource.Diagnostic) Test(org.junit.Test)

Example 2 with CacheAdapter

use of org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter in project xtext-core by eclipse.

the class OnChangeEvictingCacheAdapterTest method testAdapterIsCleared.

@Test
public void testAdapterIsCleared() throws Exception {
    EcoreFactory factory = EcoreFactory.eINSTANCE;
    EClass eClass = factory.createEClass();
    Resource resource = new ResourceImpl();
    resource.getContents().add(eClass);
    CacheAdapter ca = new OnChangeEvictingCache().getOrCreate(resource);
    setValue(ca);
    EAttribute attribute = factory.createEAttribute();
    assertIsSet(ca);
    eClass.getEStructuralFeatures().add(attribute);
    assertIsNull(ca);
    setValue(ca);
    attribute.setName("Foo");
    assertIsNull(ca);
    setValue(ca);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EAttribute(org.eclipse.emf.ecore.EAttribute) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) Resource(org.eclipse.emf.ecore.resource.Resource) CacheAdapter(org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter) Test(org.junit.Test)

Example 3 with CacheAdapter

use of org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter in project xtext-core by eclipse.

the class OnChangeEvictingCacheAdapterTest method testCacheSurvivesChangesToAdapters.

@Test
public void testCacheSurvivesChangesToAdapters() throws Exception {
    EcoreFactory factory = EcoreFactory.eINSTANCE;
    EClass eClass = factory.createEClass();
    Resource resource = new ResourceImpl();
    resource.getContents().add(eClass);
    CacheAdapter ca = new OnChangeEvictingCache().getOrCreate(resource);
    setValue(ca);
    List<Adapter> adapters = resource.eAdapters();
    assertIsSet(ca);
    AdapterImpl adapter = new AdapterImpl();
    adapters.add(adapter);
    assertIsSet(ca);
    adapters.remove(adapter);
    assertIsSet(ca);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) AdapterImpl(org.eclipse.emf.common.notify.impl.AdapterImpl) EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) Resource(org.eclipse.emf.ecore.resource.Resource) CacheAdapter(org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter) CacheAdapter(org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) Test(org.junit.Test)

Aggregations

EClass (org.eclipse.emf.ecore.EClass)3 EcoreFactory (org.eclipse.emf.ecore.EcoreFactory)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 ResourceImpl (org.eclipse.emf.ecore.resource.impl.ResourceImpl)3 CacheAdapter (org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter)3 Test (org.junit.Test)3 Adapter (org.eclipse.emf.common.notify.Adapter)1 AdapterImpl (org.eclipse.emf.common.notify.impl.AdapterImpl)1 EAttribute (org.eclipse.emf.ecore.EAttribute)1 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)1