use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.
the class NamesAreUniqueValidationHelperTest method testCreatedErrors_05_context.
@Test
public void testCreatedErrors_05_context() {
maxCallCount = 0;
ImmutableList<ENamedElement> elements = ImmutableList.of(createEPackage(), createEDataType(), createEPackage());
for (ENamedElement classifier : elements) {
classifier.setName("Same");
}
expected.add(elements.get(0));
expected.add(elements.get(2));
helper.checkUniqueNames(new LocalUniqueNameContext(elements, this), this);
assertEquals(elements.size(), callCount);
assertTrue(expected.isEmpty());
}
use of org.eclipse.emf.ecore.ENamedElement 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.emf.ecore.ENamedElement 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);
}
use of org.eclipse.emf.ecore.ENamedElement 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.emf.ecore.ENamedElement in project xtext-core by eclipse.
the class EmfFormatter method refToStr.
private static void refToStr(EObject obj, EReference ref, String indent, Appendable buf) throws Exception {
Object o = obj.eGet(ref);
if (o instanceof EObject) {
EObject eo = (EObject) o;
if (eo instanceof ENamedElement)
buf.append("'").append(((ENamedElement) eo).getName()).append("' ");
buf.append("ref: ");
getURI(obj, eo, buf);
return;
}
if (o instanceof Collection<?>) {
String innerIndent = indent + INDENT;
buf.append("[");
int counter = 0;
Collection<?> coll = (Collection<?>) o;
for (Iterator<?> i = coll.iterator(); i.hasNext(); ) {
Object item = i.next();
if (counter == 0)
buf.append('\n');
buf.append(innerIndent);
printInt(counter++, coll.size(), buf);
buf.append(": ");
getURI(obj, (EObject) item, buf);
if (i.hasNext())
buf.append(",\n");
else
buf.append('\n').append(indent);
}
buf.append("]");
return;
}
buf.append("?????");
}
Aggregations