public static GlobalStateMemento makeCopyOfGlobalState() { GlobalStateMemento memento = new GlobalStateMemento(); memento.validatorReg = new HashMap<EPackage, Object>(EValidator.Registry.INSTANCE); for(Map.Entry<EPackage, Object> validatorEntry: memento.validatorReg.entrySet()) { Object existingValue = validatorEntry.getValue(); if (existingValue instanceof CompositeEValidator) { validatorEntry.setValue(((CompositeEValidator) existingValue).getCopyAndClearContents()); } } memento.epackageReg = new HashMap<String, Object>(EPackage.Registry.INSTANCE); memento.protocolToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()); memento.protocolToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getContentTypeToFactoryMap()); return memento; }
@Override public void configureIScopeProviderDelegate(Binder binder) { binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class) .annotatedWith(com.google.inject.name.Names .named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)) .to(org.yakindu.sct.model.stext.scoping.StextImportAwareScopeProvider.class); binder.bind(ITypeSystem.class).toInstance(getTypeSystem()); binder.bind(boolean.class).annotatedWith(Names.named(CompositeEValidator.USE_EOBJECT_VALIDATOR)) .toInstance(false); }
protected void assertValidatorExists() { EValidator eValidator = EValidator.Registry.INSTANCE.getEValidator(XtextPackage.eINSTANCE); Assert.assertNotNull(eValidator); Assert.assertTrue(eValidator instanceof CompositeEValidator); }
/** {@inheritDoc} */ @Override public Set<Binding> getGuiceBindingsRt(final Grammar grammar) { return new BindFactory().addTypeToTypeEagerSingleton(getJavaValidatorName(grammar, ""), getJavaValidatorName(grammar, "")).addTypeToType(CompositeEValidator.class.getName(), ValidCompositeEValidator.class.getName()).getBindings(); //$NON-NLS-1$ //$NON-NLS-2$ }