Adding custom entries to the Problems view

Hello, I am trying to add new custom entries to the Problems view contributed by @theia/markers.

For context, my use case is markers from a model validation. So I have a model element URI fragment, but not its location in the file. Also the model is not even necessarily a file, but may be stored in a database.

At first, I though I would have to add my own subclass of MarkerManager, but then, I realized that the ProblemWidget only looks at the ProblemManager instance. So I could use my own subclass only by creating a new separate duplicate view (which I don’t want).

This make me wonder on several questions :

  • Is the MarkerManager abstract class meant to be extended other than by ProblemManager ? Are there markers meant not to be logged in the Problems view ?
  • How am I supposed to add new kind of markers to the Problems view ? Should I force their conversion to vscode-languageserver-types Diagnostic, setting a fake range if this property does not make sense for me ?
  • Can I customize the ProblemTreeModel#getOpenerOptionsByMarker, so that I can access my element without the range, but with the actual element URI with fragment ?

And also : what is the difference in Marker between uri and owner ? I get confused on this owner property (think it would make sense for my use case to give it the model element), especially when I see marker.uri used for both properties in https://github.com/eclipse-theia/theia/blob/f8bcc19eba884cbd64112aeb691e8c97aad87197/packages/markers/src/browser/problem/problem-contribution.ts#L221

Thanks for you insights on this matter.

I found at least the answer to my first question :
The Bookmarks view logs markers, but not problems per se. So it uses a different view.

The Bookmarks view logs markers, but not problems per se. So it uses a different view.

@vhemery just to mention, the bookmarks view was never implemented, there is no such view part of the framework.

Here are the conclusions I came to:

Is the MarkerManager abstract class meant to be extended other than by ProblemManager ? Are there markers meant not to be logged in the Problems view ?

Yes, though Bookmarks view has not been implemented, the intention is here, so we can create new views with other non-problem markers.

How am I supposed to add new kind of markers to the Problems view ? Should I force their conversion to vscode-languageserver-types Diagnostic, setting a fake range if this property does not make sense for me ?

I stayed with ProblemsManager and just extended the Range interface with a new one. When creating my ModelElementRange, I use {-1,-1} start and end locations, and new property containing the extra information I need (uriFragment = URI fragment which identifies the concerned model element).

Can I customize the ProblemTreeModel#getOpenerOptionsByMarker , so that I can access my element without the range, but with the actual element URI with fragment ?

I didn’t. The Range is given in the opener options. So with the extra information I need in these options, I should be able to open my view’s widget on the appropriate model element.

what is the difference in Marker between uri and owner ?

I used the model element’s id (uriFragment) as the owner. I think https://github.com/eclipse-theia/theia/blob/f8bcc19eba884cbd64112aeb691e8c97aad87197/packages/markers/src/browser/problem/problem-contribution.ts#L221 is a bug and should use the marker.owner instead of marker.uri.
I’m creating the issue in parallel :

1 Like