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. 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, relying on its advanced ...

Get Implementing Domain-Specific Languages with Xtext and Xtend now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.