org.eclipse.xtext.validation.CompositeEValidator Java Examples

The following examples show how to use org.eclipse.xtext.validation.CompositeEValidator. 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: GlobalRegistries.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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());
	
	memento.annotationValidatorMap = new HashMap<>(getAnnotationValidatorMap());
	return memento;
}
 
Example #2
Source File: GlobalRegistries.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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());
	
	memento.annotationValidatorMap = new HashMap<>(getAnnotationValidatorMap());
	return memento;
}
 
Example #3
Source File: InjectorProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUiTestBetweenTwoRuntimeTests() {
	URI workWithMe = URI.createURI("dummy:/sample." + EXTENSION);
	Assert.assertEquals(EXTENSION, workWithMe.fileExtension());
	
	// the first test is a runtime test
	FoldingTestLanguageInjectorProvider runtime = new FoldingTestLanguageInjectorProvider();
	runtime.setupRegistry();
	Injector runtimeInjector = runtime.getInjector();
	EValidator.Registry runtimeRegistry = runtimeInjector.getInstance(EValidator.Registry.class);
	EValidator validator = runtimeRegistry.getEValidator(FoldingPackage.eINSTANCE);
	runtime.restoreRegistry();
	
	// trigger ui injector initialization from second test case
	FoldingTestLanguageUiInjectorProvider ui = new FoldingTestLanguageUiInjectorProvider();
	Injector uiInjector = ui.getInjector();
	EValidator.Registry uiValidatorRegistry = uiInjector.getInstance(EValidator.Registry.class);
	
	Assert.assertSame(runtimeRegistry, uiValidatorRegistry);
	
	CompositeEValidator uiValidator = (CompositeEValidator) uiValidatorRegistry.getEValidator(FoldingPackage.eINSTANCE);
	List<EValidatorEqualitySupport> validators = new ArrayList<>(uiValidator.getContents());
	Assert.assertNotNull(validator);
	
	// run next runtime test 
	runtime.setupRegistry();
	runtime.restoreRegistry();
	
	// run next ui test and check that we see the correct validator configuration
	
	CompositeEValidator newValidator = (CompositeEValidator) uiValidatorRegistry.getEValidator(FoldingPackage.eINSTANCE);
	Assert.assertEquals(validators, newValidator.getContents());
}
 
Example #4
Source File: SARLRuntimeModule.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder) {
	super.configure(binder);
	binder.bind(boolean.class).annotatedWith(Names.named(CompositeEValidator.USE_EOBJECT_VALIDATOR))
			.toInstance(false);
	// Configure a system singleton for issue severities provider
	final ConfigurableIssueSeveritiesProviderProvider provider = new ConfigurableIssueSeveritiesProviderProvider();
	binder.bind(ConfigurableIssueSeveritiesProvider.class).toProvider(provider);
	binder.bind(IssueSeveritiesProvider.class).toProvider(provider);
	binder.bind(IConfigurableIssueSeveritiesProvider.class).toProvider(provider);

}
 
Example #5
Source File: Bug367679Test.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void assertValidatorExists() {
	EValidator eValidator = EValidator.Registry.INSTANCE.getEValidator(XtextPackage.eINSTANCE);
	Assert.assertNotNull(eValidator);
	Assert.assertTrue(eValidator instanceof CompositeEValidator);
}
 
Example #6
Source File: XtendRuntimeModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void configure(Binder binder) {
	super.configure(binder);
	binder.bind(boolean.class).annotatedWith(Names.named(CompositeEValidator.USE_EOBJECT_VALIDATOR)).toInstance(false);
}
 
Example #7
Source File: Bug367679Test.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected void assertValidatorExists() {
	EValidator eValidator = EValidator.Registry.INSTANCE.getEValidator(XtextPackage.eINSTANCE);
	Assert.assertNotNull(eValidator);
	Assert.assertTrue(eValidator instanceof CompositeEValidator);
}
 
Example #8
Source File: ValidValidatorFragment.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/** {@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$
}