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);
}
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);
}
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);
}
Aggregations