Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSPDiagnosticsToMarkers usage of LSPEclipseUtils.toOffset #160

Open
rubenporras opened this issue Jun 28, 2022 · 4 comments
Open

LSPDiagnosticsToMarkers usage of LSPEclipseUtils.toOffset #160

rubenporras opened this issue Jun 28, 2022 · 4 comments
Labels
question Further information is requested

Comments

@rubenporras
Copy link
Contributor

rubenporras commented Jun 28, 2022

I have noticed that LSPDiagnosticsToMarkers uses LSPEclipseUtils.toOffset to recalculate the start and end positions of the diagnostics published by the language server.

This is a performance issue for us because our filesystem implementation is based on remote files, and for the recalculation of these offsets the text of the resource must be fetch from the remote connection. We have many of these remote files with markers that need to be propagated, so it is an overhead of several seconds that would be very nice to avoid.

I see that the offsets are used to detect markers which are already present, and for this usage, the offsets coming from the server should be good enough.

I see that the offsets are also saved as marker attributes (IMarker.CHAR_START and IMarker.CHAR_END). Is there a requirement in the platform that tells that the offsets must be relative to the start of the document instead of to the start of the line of the marker? I could not find this in the documentation on the IMarker class. The problems view does not show this attributes, so I think the only problem would be the editor itself.

Is the reason of this recalculation of offsets that org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel.createPositionFromMarker(IMarker) needs offsets relative to the beginning of he document? If so, would it be possible to subclass it to use offsets relative to the line and use that subclass to show the markers in the org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor? Does it sound like something we could do?

Thanks

@rubenporras rubenporras added the question Further information is requested label Jun 28, 2022
@mickaelistria
Copy link
Contributor

Is there a requirement in the platform that tells that the offsets must be relative to the start of the document instead of to the start of the line of the marker

Although it's not a written down explicitly, it's indeed a requirement. See all references to IMarker.CHAR_START in eclipse.platform.text repo.

The problems view does not show this attributes, so I think the only problem would be the editor itself.

Those attributes are used -among others- to draw the red squiggle underline at the right location.

Is the reason of this recalculation of offsets that org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel.createPositionFromMarker(IMarker) needs offsets relative to the beginning of he document?

Yes.

If so, would it be possible to subclass it to use offsets relative to the line and use that subclass to show the markers in the org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor?

That's something to discuss on a different issue against eclipse.platform.text repo.

@mickaelistria
Copy link
Contributor

I think it'd be simpler to ask LSP to allow a documentPosition,

@rubenporras
Copy link
Contributor Author

You mean asking for it in https://github.com/microsoft/language-server-protocol?

@mickaelistria
Copy link
Contributor

yes, explaining the case of remote documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants