Community
Participate
Working Groups
Created attachment 248632 [details] The annotation-based validation framework plugins and feature == Problem statement == The standard EMF validation seems tightly coupled to the language metmodel and difficult to extend without modifying the .ecore file. Users want to have a more flexible/declarative mechanism. The idea could be to learn from Xtext and implement a validation mechanism that uses annotations to identify check methods and provide a framework that gets invoked for validation and error/info/warning methods similar to Xtext. In addition/difference to plain Xtext, it would be nice if we could register more than one validator for a given meta-model (or even on a project basis), so that we can add project/product line specific validators. The validation should integrate with the IDE (e.g. setting error log/problem markers when editing or saving) as well with an API (e.g. being able to access errors on a given resource programmatically after/before a transformation/workflow step). == Proposed solution == A check-based validation framework is attached. The framework follows the same principle of the existing check-based framework of Xtext, as it uses @Chek annotated methods for validating model objects. The framework externalizes constraint categories as well as error/warning/info constants such as severity, message, comments, etc. into an external model (check catalog). In order to guarantee backward compatibility with existing validators, and handle the contribution of other types of validators, a DispatchingValidator is also introduced. This validator is a composition of all the validators assigned to a given package, it should be the entry point for validation. It simply delegates validation to all the existing validators and its returned validation status is the logical “and” of the returned validation status of all the delegations. During this process diagnostics are chained following the delegation order, and the resulting diagnostic is the aggregation of all the delegates’ diagnostics. To be able to handle the management of validators, a CheckValidationRegistry singleton is introduced. This registry wraps the standard EValidator.Registry singleton of EMF and provides utility methods to handle registration and add/remove delegates.
Created attachment 248633 [details] An example of annotation-based validator
Closed stale issue before migration