Search code examples
eclipse-plugindslxtext

Xtext - how to extend XtextDocument class


I need to extend XtextDocument class so i can add some properties to my dsl document. how can it be done? I tried to add bind to Ui Module but there is no bind for XtextDocument. thanks in advance


Solution

  • You can simply add a new binding to the ui module. All methods that follow the convention

    public Class<? extends ${TypeToBind}> bind${SomeName}() {
      return ${MySpecialType}.class
    }
    

    will be invoked reflectively when the injector is created. Therefore, a binding

    public Class<? extends XtextDocument> bindXtextDocument() {
      return MyDocument.class;
    }
    

    will do the trick.