Summary
In this chapter, you learned how to implement constraint checks, using the Xtext validator mechanism based on @Check
annotated methods. Just by implementing a custom validator and calling the method error
or warning
with the appropriate information, Xtext produces error and warning markers that result in marking the text regions as well as showing the markers in the various views in Eclipse.
We also showed how to implement quickfixes. We can implement a quickfix by directly modifying the text of the current program. Alternatively, since Xtext automatically synchronizes the DSL editor's contents with the EMF model of the AST, we can simply modify such model without dealing with the textual representation of the program.
In the next chapter, we will write a code generator for the Entities DSL implemented in Xtend, using its advanced features for code generation. Starting from a program written in our Entities DSL, we will generate the corresponding Java code. You will see that Xtext...