use of org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method initialize.
@Override
public void initialize(final Injector injector) {
super.initialize(injector);
boolean _containsKey = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("genmodel");
boolean _not = (!_containsKey);
if (_not) {
Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
EcoreResourceFactoryImpl _ecoreResourceFactoryImpl = new EcoreResourceFactoryImpl();
_extensionToFactoryMap.put("genmodel", _ecoreResourceFactoryImpl);
}
GenModelPackage.eINSTANCE.getGenAnnotation();
}
use of org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl in project xtext-core by eclipse.
the class TerminalsStandaloneSetupGenerated method createInjectorAndDoEMFRegistration.
@Override
public Injector createInjectorAndDoEMFRegistration() {
// register default ePackages
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtextbin", new BinaryGrammarResourceFactoryImpl());
if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
Injector injector = createInjector();
register(injector);
return injector;
}
use of org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl in project xtext-core by eclipse.
the class XtextLinkingService method createPackage.
private List<EObject> createPackage(GeneratedMetamodel generatedMetamodel, ILeafNode text) {
final String nsURI = getMetamodelNsURI(text);
final URI uri = URI.createURI(nsURI);
if (uri == null || isReferencedByUsedGrammar(generatedMetamodel, nsURI))
return Collections.emptyList();
EPackage pack = ((GeneratedMetamodelImpl) generatedMetamodel).basicGetEPackage();
if (pack != null && !pack.eIsProxy())
return singletonList((EObject) pack);
final EPackage generatedEPackage = EcoreFactory.eINSTANCE.createEPackage();
generatedEPackage.setName(generatedMetamodel.getName());
generatedEPackage.setNsPrefix(generatedMetamodel.getName());
generatedEPackage.setNsURI(nsURI);
final Resource generatedPackageResource = new EcoreResourceFactoryImpl().createResource(uri);
XtextResourceSet resourceSet = (XtextResourceSet) generatedMetamodel.eResource().getResourceSet();
if (!resourceSet.getURIResourceMap().containsKey(generatedPackageResource.getURI())) {
generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
} else {
generatedPackageResource.setURI(URI.createURI(nsURI + "_" + generatedMetamodel.hashCode()));
generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
}
generatedPackageResource.getContents().add(generatedEPackage);
return Collections.<EObject>singletonList(generatedEPackage);
}
Aggregations