It is useful to open Xtext resources in EMF tree editors, e.g. in the Sample Reflective Ecore Model Editor. However, in several cases, e.g. when using Xbase expressions, it is required to initialize a specific resource-set that initializes the Xtext environment.
This Xtext extension provides a generator fragment for Xtext workflows that adds this feature to existing languages.
For more details, look at the announcement blog post or download it from the update site: http://eclipse.cubussapiens.hu
- Add
hu.cubussapiens.xtext.reflectiveeditor
as a dependency to your language project. - Add
import hu.cubussapiens.xtext.reflectiveeditor.generator.*
to the editor generation workflow. - Add the reflective editor generation fragment after the last fragment in your workflow file, as seen below.
- Regenerate your editor
- Make sure, that the new editor extension generated in
plugin.xml_gen
is copied toplugin.xml
. If not, copy it manually. - Then your model files can be opened with a specific, reflective editor. Use
Open with
/«Languagename» Reflective Editor
.
The reflective editor generation fragment was created similar to existing fragments. The file.extensions
parameter is defined
the same way in the default Xtext 2.0 workflow file.
fragment = ReflectiveXtextEditorFragment {
fileExtensions = file.extensions
}