Christoff Erasmus
Christoff Erasmus

Reputation: 975

Xtext issue with Code Completion

Based on the following Xtext (2.10) code snippet:

The expectation for "CRT+L":

The ISSUE:

If "CRT+L" is done on the "BEGSR" token, the "Name - ID" option is missing.

When Enter is pressed and incorrect token "BEGSR*PSSR" is created. The rule should be that "BEGSR" is always followed by a space. BUT IT IS NOT!

Please help me,

  1. Auto add space after "BEGSR"
  2. Have "Name - ID" option available when "CRL+L" on "BEGSR" token
  3. Have "ENDSR" auto added like "{}" and "()" brackets

Upvotes: 1

Views: 65

Answers (1)

Christian Dietrich
Christian Dietrich

Reputation: 11868

Xtext has two extension points for such things

  • there is the proposal provider that lets you adapt the existing proposals. It has methods for completion places like complete_<Rulename> or complete<Rulename>_<featurename> and some special rules like completeKeyword that you may override and customize.
  • auto insert on typing is called auto edit strategy and implemented by DefaultAutoEditStrategy

Upvotes: 1

Related Questions