Quickfixes
As we said in Chapter 1, Implementing a DSL, a quickfix is a proposal to solve a problem in a program. Quickfixes are typically implemented by a context menu available from the error marker, and they are available both in the editor ruler and in the Problems view.
Note
Since quickfixes are tightly connected to validation, we describe them in this chapter. Moreover, they allow us to get familiar with the manipulation of the EMF model representing the AST of a program.
In our Entities DSL, we can provide a quickfix for each warning and error issued by our validator. As we will see later, we can also provide quickfixes for errors issued by Xtext default validators.
Xtext provides an easy mechanism to implement a quickfix connected to an error or warning issued by a validator. The Xtext generator generates an Xtend stub class for quickfixes into the UI plug-in project. In our Entities DSL example, this class is org.example.entities.ui.quickfix.EntitiesQuickfixProvider
.
A quickfix is triggered...