@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); resourceSet.setClasspathURIContext(getClasspathURIContext()); }
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); EcoreResourceFactoryImpl resFactory = new EcoreResourceFactoryImpl(); set.getResourceFactoryRegistry().getExtensionToFactoryMap() .put("ecore", resFactory); aRes = (XMIResource) set.createResource(URI.createPlatformResourceURI( "/myProject/main/src/some/package/a.ecore", true)); InputStream stream = new ByteArrayInputStream( aResContent.getBytes("US-ASCII")); aRes.load(stream, set.getLoadOptions()); stream.close(); bRes = (XMIResource) set.createResource(URI.createPlatformResourceURI( "/myProject/model/b.ecore", true)); stream = new ByteArrayInputStream( bResContent.getBytes("US-ASCII")); bRes.load(stream, set.getLoadOptions()); stream.close(); }
@Override public Injector getInjector() { if (injector == null) { stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); this.injector = internalCreateInjector(); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); } return injector; }
@Override public Injector getInjector() { if (injector == null) { stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); try { this.injector = internalCreateInjector(); } catch (Throwable e) { // ############################################################################# // IDE-2514: Temporarily exists on exception due to PolymorphicDispatcher problem boolean polymorphicDispatchProblem = false; if (e.getMessage().contains("Comparison method violates its general contract!")) { String pdName = PolymorphicDispatcher.class.getName(); for (StackTraceElement ste : e.getStackTrace()) { String steName = ste.toString(); if (steName.contains(pdName)) { polymorphicDispatchProblem = true; } } } if (polymorphicDispatchProblem) { String msg = "Comparison method violates its general contract!\n\t"; msg += "at org.eclipse.n4js.N4JSInjectorProvider.getInjector(N4JSInjectorProvider.java:90)\\n\\t"; msg += "Reason might be the PolymorphicDispatcher"; msg += "Exit."; System.err.println(msg); System.exit(-1); } else { throw e; } // Fail fast End // ############################################################################# } stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); } return injector; }
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); }
@Override public Injector getInjector() { if (injector == null) { stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); this.injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration(); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); } return injector; }
@Before public void setUp() { this.globalState = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); this.resourceSet = this.getNewResourceSet(); this.primaryResource = this.resourceSet.createResource(this.getResourceURI()); this.referencedResource = this.resourceSet.createResource(this.getReferencedURI()); }
public WrappingInjectorProvider(IInjectorProvider delegate) { this.delegate = delegate; stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); this.injector = createInjector(); if (delegate instanceof IRegistryConfigurator) { ((IRegistryConfigurator) delegate).setupRegistry(); } registerFactory(injector); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); if (delegate instanceof IRegistryConfigurator) { ((IRegistryConfigurator) delegate).restoreRegistry(); } }