use of org.eclipse.emf.ecore.resource.impl.ResourceImpl 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.emf.ecore.resource.impl.ResourceImpl 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.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class EcoreUtil2Test method testPathFragment.
@Test
public void testPathFragment() {
EClass foo = EcoreFactory.eINSTANCE.createEClass();
foo.setName("foo");
EClass bar = EcoreFactory.eINSTANCE.createEClass();
foo.setName("bar");
EPackage p = EcoreFactory.eINSTANCE.createEPackage();
bar.setName("p");
p.getEClassifiers().add(foo);
p.getEClassifiers().add(bar);
assertEquals("/-1", EcoreUtil2.getFragmentPath(foo));
assertEquals("/-1", EcoreUtil2.getFragmentPath(bar));
assertEquals("/-1", EcoreUtil2.getFragmentPath(p));
Resource resource = new ResourceImpl(URI.createURI("platform:/resource/res"));
resource.getContents().add(p);
assertEquals(URI.createURI("platform:/resource/res#//@eClassifiers.0"), EcoreUtil2.getFragmentPathURI(foo));
assertEquals(URI.createURI("platform:/resource/res#//@eClassifiers.1"), EcoreUtil2.getFragmentPathURI(bar));
assertEquals(URI.createURI("platform:/resource/res#/"), EcoreUtil2.getFragmentPathURI(p));
assertEquals(resource.getEObject("//@eClassifiers.0"), foo);
assertEquals(resource.getEObject("//@eClassifiers.1"), bar);
assertEquals(resource.getEObject("/"), p);
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class DefaultResourceDescriptionManagerTest method setUp.
@Before
public void setUp() throws Exception {
EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE);
resource = new ResourceImpl();
resource.getContents().add(copy);
IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() {
@Override
public QualifiedName getFullyQualifiedName(EObject obj) {
if (obj instanceof ENamedElement)
return QualifiedName.create(((ENamedElement) obj).getName());
return null;
}
};
DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy();
descriptionStrategy.setQualifiedNameProvider(nameProvider);
resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) {
@Override
public Iterable<QualifiedName> getImportedNames() {
return importedNames;
}
};
manager = new DefaultResourceDescriptionManager();
importedNames = Collections.emptySet();
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class AbstractScopeTest method setUp.
@Before
public void setUp() throws Exception {
resource = new ResourceImpl(URI.createURI("uri"));
annotationA = EcoreFactory.eINSTANCE.createEAnnotation();
annotationB = EcoreFactory.eINSTANCE.createEAnnotation();
resource.getContents().add(annotationA);
resource.getContents().add(annotationB);
descriptionA = EObjectDescription.create("a", annotationA);
descriptionA_aliased = EObjectDescription.create("aliasedA", annotationA);
descriptionB = EObjectDescription.create("b", annotationB);
descriptionB_as_A = EObjectDescription.create("a", annotationB);
}
Aggregations