use of org.eclipse.xtext.naming.QualifiedName 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);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ResourceSetBasedResourceDescriptionsTest method testOneElement_Mismatch.
@Test
public void testOneElement_Mismatch() {
QualifiedName qualifiedName = QualifiedName.create("SomeName");
EClass type = EcorePackage.Literals.EPACKAGE;
Resource resource = createResource();
createNamedElement(qualifiedName, type, resource);
Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.ECLASS);
assertTrue(Iterables.isEmpty(iterable));
iterable = container.getExportedObjects(EcorePackage.Literals.ECLASS, qualifiedName, false);
assertTrue(Iterables.isEmpty(iterable));
iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, QualifiedName.create("AnotherName"), false);
assertTrue(Iterables.isEmpty(iterable));
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ResourceSetBasedResourceDescriptionsTest method testTwoElements_OneMatch.
@Test
public void testTwoElements_OneMatch() {
QualifiedName qualifiedName = QualifiedName.create("SomeName");
EClass type = EcorePackage.Literals.EPACKAGE;
Resource resource = createResource();
ENamedElement element = createNamedElement(qualifiedName, type, resource);
ENamedElement other = createNamedElement(null, EcorePackage.Literals.ECLASS, resource);
Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjectsByType(EcorePackage.Literals.ECLASSIFIER);
assertSame(other, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ResourceSetBasedResourceDescriptionsTest method testDataBasedResourceSetBasedResourceDescriptions.
@Test
public void testDataBasedResourceSetBasedResourceDescriptions() throws Exception {
ResourceDescriptionsData data = new ResourceDescriptionsData(new ArrayList<IResourceDescription>());
ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, data);
resDescs.setContext(resourceSet);
Resource resource = createResource();
QualifiedName name = QualifiedName.create("SomeName");
createNamedElement(name, EcorePackage.Literals.ECLASS, resource);
// still empty
assertFalse(resDescs.getAllResourceDescriptions().iterator().hasNext());
assertTrue(resDescs.isEmpty());
assertFalse(resDescs.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator().hasNext());
assertFalse(resDescs.getExportedObjects(EcorePackage.Literals.ECLASS, name, false).iterator().hasNext());
assertFalse(resDescs.getExportedObjects().iterator().hasNext());
// add resource description to data
IResourceDescription description = resourceDescriptionManager.getResourceDescription(resource);
data.addDescription(description.getURI(), description);
// now contained
assertSame(description, resDescs.getAllResourceDescriptions().iterator().next());
assertFalse(resDescs.isEmpty());
assertTrue(resDescs.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator().hasNext());
assertTrue(resDescs.getExportedObjects(EcorePackage.Literals.ECLASS, name, false).iterator().hasNext());
assertFalse(resDescs.getExportedObjects(EcorePackage.Literals.EATTRIBUTE, name, false).iterator().hasNext());
assertTrue(resDescs.getExportedObjects().iterator().hasNext());
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ResourceSetBasedResourceDescriptionsTest method testTwoResources_TwoMatches.
@Test
public void testTwoResources_TwoMatches() {
QualifiedName qualifiedName = QualifiedName.create("SomeName");
EClass type = EcorePackage.Literals.EPACKAGE;
Resource resource = createResource();
ENamedElement first = createNamedElement(qualifiedName, type, resource);
resource = createResource();
ENamedElement second = createNamedElement(qualifiedName, type, resource);
List<ENamedElement> expected = Lists.newArrayList(first, second);
Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
checkFindAllEObjectsResult(expected, iterable);
iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
checkFindAllEObjectsResult(expected, iterable);
iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
checkFindAllEObjectsResult(expected, iterable);
iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
checkFindAllEObjectsResult(expected, iterable);
}
Aggregations