In this chapter, we will introduce the concept of validation, and in particular, the Xtext mechanism to implement validation: the validator. With validation, you can implement additional constraint checks of a DSL, which cannot be done at parsing time. Xtext allows you to implement such constraint checks in an easy and declarative way. You only need to communicate to Xtext the possible errors or warnings, and it will take care of generating the error markers accordingly in the IDE. The validation will take place in the background while the user of the DSL is typing in the editor so that an immediate feedback is provided. We will also show how to implement quickfixes corresponding to the errors and warnings generated during validation, in order to help the user to solve problems due to validation errors.
This chapter will cover the following topics:
An introduction to validation in Xtext
The default Xtext validator for checking duplicate names
Some examples of custom validations...