use of org.eclipse.emf.ecore.EcoreFactory 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.emf.ecore.EcoreFactory in project xtext-core by eclipse.
the class EClassInfoTest method testChangeable.
public void testChangeable() {
EcorePackage pack = EcorePackage.eINSTANCE;
EClass eClass = pack.getEClass();
EClassInfo objectUnderTest = new EClassifierInfo.EClassInfo(eClass, false, Collections.<String>emptySet(), null);
EcoreFactory fac = EcoreFactory.eINSTANCE;
EReference reference = fac.createEReference();
reference.setName("newReference");
reference.setEType(eClass);
reference.setChangeable(true);
reference.setContainment(true);
eClass.getEStructuralFeatures().add(reference);
assertEquals(true, objectUnderTest.containsCompatibleFeature("newReference", false, true, eClass, new StringBuilder()));
reference.setChangeable(false);
assertEquals(false, objectUnderTest.containsCompatibleFeature("newReference", false, true, eClass, new StringBuilder()));
}
use of org.eclipse.emf.ecore.EcoreFactory in project xtext-core by eclipse.
the class ResourceSetReferencingResourceSetTest method getResource.
private Resource getResource(String resourceURI, String references) {
XMIResourceImpl res = new XMIResourceImpl();
res.setURI(URI.createURI(resourceURI));
EcoreFactory f = EcoreFactory.eINSTANCE;
EClass class1 = f.createEClass();
res.getContents().add(class1);
class1.setName("mytype");
if (references != null) {
EClass referencedProxy = f.createEClass();
String fragment = res.getURIFragment(class1);
((InternalEObject) referencedProxy).eSetProxyURI(URI.createURI(references).appendFragment(fragment));
class1.getESuperTypes().add(referencedProxy);
}
return res;
}
use of org.eclipse.emf.ecore.EcoreFactory in project xtext-core by eclipse.
the class DefaultResourceDescriptionTest method setUp.
@Before
public void setUp() throws Exception {
resource = new XMLResourceImpl();
resource.setURI(URI.createURI("foo:/test"));
nameProvider = new IQualifiedNameProvider.AbstractImpl() {
@Override
public QualifiedName getFullyQualifiedName(EObject obj) {
if (obj instanceof ENamedElement)
return QualifiedName.create(((ENamedElement) obj).getName());
return null;
}
};
strategy = new DefaultResourceDescriptionStrategy();
strategy.setQualifiedNameProvider(nameProvider);
description = new DefaultResourceDescription(resource, strategy);
EcoreFactory f = EcoreFactory.eINSTANCE;
pack = f.createEPackage();
pack.setName("MyPackage");
eClass = f.createEClass();
eClass.setName("MyEClass");
dtype = f.createEDataType();
dtype.setName("MyDatatype");
pack.getEClassifiers().add(eClass);
pack.getEClassifiers().add(dtype);
resource.getContents().add(pack);
}
Aggregations