Getting Xtext model todo comments into the task list

Wouldn’t it be nice, if the todo comments from your DSL would make it to the task list, as you know it from the java editor?

The sample project is based on Xtext 1. All relevant code is in the UI project. The plugin.xml (very end) contains the definition of a marker with taskmarker supertype. XtextTaskCalculator contains the code for creating the markers on saving a file. Basically it iterates over all elements of the node model and asks an injected ITaskElementChecker if that element contains a task, if so the marker is created. The MydslTaskElementChecker triggers for single line comments starting with //TODO.

For some reason the marker ID defined in the plugin.xml (Xtask) has to be prefixed when creating the marker (org.xtext.example.mydsl.ui.Xtask)…
(When experiencing problems here, you might want to add an annotationTypes extension and browse the markerTypes available. There you will get the fully qualified name of the marker)

Download: sample project

11 Responses to “Getting Xtext model todo comments into the task list”

  1. Christoph Kulla Says:

    That looks great! Are there any plans to add this to the Xtext 2 code base?

  2. Alexander Nittka Says:

    I don’t know if there is a corresponding feature request. But I won’t need to tell you that adapting the sample code for use in Xtext 2 is a matter of minutes. Generalising and smoothing it for integration into the framework will require much more work.

  3. Christian Dietrich Says:

    Nice! Some additional Highlighting and it looks the very same as with javas todos.

  4. Alexander Nittka Says:

    Of course, one problem with the example is that the markers are updated only on a save action in the editor. So if you check out a project, you’d have to open every single model file and modify it, before you see the tasks. For a full grown use case, the marker creation would have to be integrated differently.

  5. Jörg Reichert Says:

    Great, exactly what I was looking for. I ported it to Xtext 2 and added the Semantic Highlighter. The task markers are also calculated when the editor is open.

    Download: TODO_Example_Xtext2.zip

  6. Andreas Mülder Says:

    Cool! Thanks for the port to Xtext 2 Jörg!

  7. Dietmar Stoll Says:

    Jörg, thanks for the update on your github repository: https://github.com/joergreichert/XtextPlayground

  8. Alexander Nittka Says:

    Please also note the following suggested approach:

    http://www.eclipse.org/forums/index.php/mv/msg/203531/1105319/#msg_1105319

  9. Jörg Reichert Says:

    I created a first version of a generator fragment, that can be used in every grammar project to generate the infrastructure for the task marker support.

    See the open issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=380449

  10. Tristan Prudhomme Says:

    I’ve installed the fragment generator for TODOs from the XtextPlayground update site.

    My markers where highligthed correctly but not appear in the task view panel .

    I’m lost for the moment …

    Thanks a lot

  11. Alexander Nittka Says:

    The best thing to do is filing an issue in the XtextPlayground repo. Additional information about the Xtext version you are using would be helpful.

Leave a Reply