Quick fix for terminal rules in xtext

164 views Asked by At

my DSL grammer look like (only necessary part is displayed )

assemblerProgram: // standard way of defining model
content += CommandLine+
;

CommandLine: 
ControlInstructions | Pointaddress ;

Pointaddress:
name = POINTINGADD

terminal POINTINGADD:('_')('a'..'z'|'A'..'Z')? ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

where POINTINGADD is a terminal rule which say that name should starts with "_".

Now I want to implement a quick fix for this terminal rule. is it possible? and which path should I follow?

thanks in advance.

1

There are 1 answers

1
Stephan Herrmann On BEST ANSWER

If you want to implement a "semantic" quickfix (i.e., one that operates on the model rather than on text), it's probably better to have a more lenient grammar, which does accept names without the leading underscore, then create a validation that complains about this and assigns a specific error code, which can finally be used to trigger the quickfix.

Alternatively, when dealing with syntax errors indeed, the documentation recommends to use ISyntaxErrorMessageProvider, but I haven't yet used this approach.