Java Code Examples for org.eclipse.emf.ecore.EValidator#Registry

The following examples show how to use org.eclipse.emf.ecore.EValidator#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: ValidatorTester.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public ValidatorTester(T validator, EValidatorRegistrar registrar, @Named(Constants.LANGUAGE_NAME) final String languageName) {
	this.validator = validator;
	EValidator.Registry originalRegistry = registrar.getRegistry();
	EValidatorRegistryImpl newRegistry = new EValidatorRegistryImpl();
	registrar.setRegistry(newRegistry);
	this.validator.register(registrar);
	diagnostician = new Diagnostician(newRegistry) {
		@Override
		public java.util.Map<Object,Object> createDefaultContext() {
			java.util.Map<Object,Object> map = super.createDefaultContext();
			map.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, languageName);
			return map;
		}
	};
	registrar.setRegistry(originalRegistry);
	validatorCalled = false;
}
 
Example 2
Source File: ValidatorTester.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public ValidatorTester(T validator, EValidatorRegistrar registrar, @Named(Constants.LANGUAGE_NAME) final String languageName) {
	this.validator = validator;
	EValidator.Registry originalRegistry = registrar.getRegistry();
	EValidatorRegistryImpl newRegistry = new EValidatorRegistryImpl();
	registrar.setRegistry(newRegistry);
	this.validator.register(registrar);
	diagnostician = new Diagnostician(newRegistry) {
		@Override
		public java.util.Map<Object,Object> createDefaultContext() {
			java.util.Map<Object,Object> map = super.createDefaultContext();
			map.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, languageName);
			return map;
		}
	};
	registrar.setRegistry(originalRegistry);
	validatorCalled = false;
}
 
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: CheckExtensionGenerator.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Catalog validates.
 *
 * @param catalog
 *          the catalog
 * @return true, if successful
 */
private boolean catalogValidates(final CheckCatalog catalog) {
  EValidator.Registry eValidatorRegistry = EValidator.Registry.INSTANCE;
  EValidator eValidator = eValidatorRegistry.getEValidator(catalog.eClass().getEPackage());
  BasicDiagnostic diag = new BasicDiagnostic();
  eValidator.validate(catalog, diag, Maps.newHashMap());
  Iterable<Diagnostic> children = diag.getChildren();
  Iterable<Diagnostic> errors = Iterables.filter(children, new Predicate<Diagnostic>() {
    @Override
    public boolean apply(final Diagnostic input) {
      return input.getSeverity() == Diagnostic.ERROR;
    }
  });
  return Iterables.isEmpty(errors);
}
 
Example 5
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
	EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
	registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
	diagnostician = new Diagnostician(registry);
}
 
Example 6
Source File: XbaseDiagnostician.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public XbaseDiagnostician(EValidator.Registry registry) {
	super(registry);
}
 
Example 7
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
	EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
	registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
	diagnostician = new Diagnostician(registry);
}
 
Example 8
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
	EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
	registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
	diagnostician = new Diagnostician(registry);
}
 
Example 9
Source File: EValidatorRegistrar.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setRegistry(EValidator.Registry registry) {
	this.registry = registry;
}
 
Example 10
Source File: EValidatorRegistrar.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public EValidator.Registry getRegistry() {
	return registry;
}
 
Example 11
Source File: CancelableDiagnostician.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public CancelableDiagnostician(EValidator.Registry registry) {
	super(registry);
}
 
Example 12
Source File: DefaultRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public EValidator.Registry bindEValidatorRegistry() {
	return EValidator.Registry.INSTANCE;
}