org.eclipse.emf.ecore.EPackage.Registry Java Examples
The following examples show how to use
org.eclipse.emf.ecore.EPackage.Registry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EcoreUtil2Test.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testExternalFormOfEReference() throws Exception { Registry registry = EPackage.Registry.INSTANCE; Set<String> uris = Sets.newHashSet(registry.keySet()); for (String string : uris) { EPackage ePackage = registry.getEPackage(string); TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(ePackage, true); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof EReference) { EReference ref = (EReference) next; String externalForm = EcoreUtil2.toExternalForm(ref); assertEquals(ref.toString() + " - " + externalForm, ref, EcoreUtil2.getEReferenceFromExternalForm(registry,externalForm)); } } } }
Example #2
Source File: EcoreUtil2Test.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
/** * This test assumes that an EPackage with indexed references is no longer available. */ @Test public void testExternalFormOfEReferenceNoNPE() throws Exception { EReference reference = EcorePackage.Literals.EATTRIBUTE__EATTRIBUTE_TYPE; URI uri = EcoreUtil.getURI(reference); String externalForm = uri.toString(); EReference foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, externalForm); assertSame(reference, foundReference); String brokenExternalFrom = makeInvalid(externalForm); assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenExternalFrom)); String shortExternalForm = EcoreUtil2.toExternalForm(reference); foundReference = EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, shortExternalForm); assertSame(reference, foundReference); String brokenShortExternalFrom = makeInvalid(shortExternalForm); assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom)); brokenShortExternalFrom = shortExternalForm.replace('A', 'a'); assertNull(EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenShortExternalFrom)); }
Example #3
Source File: EcoreUtil2Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testClone() throws Exception { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE); ResourceSetImpl rs = new ResourceSetImpl(); Resource r1 = rs.createResource(URI.createURI("foo.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE); Resource r2 = rs.createResource(URI.createURI("bar.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE); EClass a = EcoreFactory.eINSTANCE.createEClass(); a.setName("a"); EClass b = EcoreFactory.eINSTANCE.createEClass(); r1.getContents().add(a); b.setName("b"); b.getESuperTypes().add(a); r2.getContents().add(b); ResourceSetImpl clone = EcoreUtil2.clone(new ResourceSetImpl(), rs); EList<Resource> list = clone.getResources(); Resource resA = list.get(0); assertEquals(URI.createURI("foo.xmi"),resA.getURI()); assertNotSame(resA, r1); Resource resB = list.get(1); assertEquals(URI.createURI("bar.xmi"),resB.getURI()); assertNotSame(resB, r2); EClass a1 = (EClass)resA.getContents().get(0); EClass b1 = (EClass)resB.getContents().get(0); assertEquals("a", a1.getName()); assertNotSame(a, a1); assertEquals("b", b1.getName()); assertNotSame(b, b1); assertSame(b1.getESuperTypes().get(0),a1); assertSame(b.getESuperTypes().get(0),a); }
Example #4
Source File: MaterializingBackwardConverter.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** Map the reflective classifier to a registered one. */ private EClassifier resolveEClassifier(EClassifier classifier) { final EPackage sourcePackage = classifier.getEPackage(); final EPackage targetPackage = Registry.INSTANCE.getEPackage(sourcePackage .getNsURI()); return targetPackage.getEClassifier(classifier.getName()); }
Example #5
Source File: LazyLinker.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Registry getRegistry() { return registry; }
Example #6
Source File: LazyLinker.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void setRegistry(Registry registry) { this.registry = registry; }