Search code examples
eclipsedslxtext

Xtext cross-references work only with an Xtext Java Project?


I followed this tutorial Second Iteration: Adding Packages and Imports by Xtext. I was trying to make a cross reference like the one shown in the last picture of the tutorial, that I paste here: Xtext Tutorial

In first example of the tutorial page I had simply to create a java project and a file mymodel.dmodel and everything works fine.

I noticed that in second example (named Second Iteration: Adding Packages and Imports) the cross-references don't work (I have some Could'nt resolve reference errors) with a simple java project. However it works fine if I convert the project to an Xtext project.

Is this a normal behaviour or have I missed some configuration steps?


Solution

  • To get the cross references work you need

    1. A project with xtext nature + builder (that is what convert to xtext project does, this is an "add xtext" not a "remove java" operation
    2. Build automatically should be enabled
    3. Depending on the project type
      1. Java Project: Put the files in a source folder
      2. Non Java (General -> Project): Put the files anywhere