-
Notifications
You must be signed in to change notification settings - Fork 144
refactor: change data in bsp.Diagnostic to contain a workspaceEdit #1969
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
Conversation
modules/build/src/main/scala/scala/build/bsp/protocol/DiagnosticData.scala
Outdated
Show resolved
Hide resolved
modules/build/src/main/scala/scala/build/bsp/protocol/DiagnosticData.scala
Outdated
Show resolved
Hide resolved
modules/build/src/main/scala/scala/build/bsp/protocol/DiagnosticData.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to fix the tests, but I wanted to get the full structure up here and get some feedback.
modules/build/src/main/scala/scala/build/bsp/protocol/WorkspaceEdit.scala
Outdated
Show resolved
Hide resolved
modules/build/src/main/scala/scala/build/bsp/protocol/ResourceOperation.scala
Outdated
Show resolved
Hide resolved
modules/build/src/main/scala/scala/build/bsp/protocol/ResourceOperation.scala
Outdated
Show resolved
Hide resolved
This change is part of the discussion that we had at the Scala Tooling Summit where we decided that using a `WorkspaceEdit` rather than a `TextEdit` provided a more future-proof way of actionable diagnostics since it's richer. This PR makes that changes, but in a limited way. - It only actually changes this when we go from the `Diagnostic` to a BSP Diagnostic. It doesn't for example change the `TextEdit` that the internal representation of Diagnostic has. That's left as is to minimize changes internally. - Right now really only `changes` are supported in the `WorkspaceEdit` mainly because that's all we really need at this time. In the future this could be expanded to use the richer `documentChanges` if the BSP client supports it. - This also changes the structure of `data` slightly to not have the actual edit be at the top level and instead nests it under an `edit` key. There is no gaurauntee that we won't have other keys in `data` in the future, so this sort of allows for that and ensures that we don't get stuck with only being able to have the actual `WorkspaceEdit` at the top level in the `data` object. Fixes VirtusLab#1957
I saw there is issue with generating the native image and therefore native tests fail, I think that reflection configuration is missing for graalvm. Let me check and I will get back to you |
I think my commit should resolve the issues with the native tests. It was added the |
Ahh perfect, thanks! This should be ready to review now but I'll also work on a draft pr in Metals just to show that this still works as expected there as well. |
Thanks for your contribution @ckipp01 , overall LGTM. So I wait until you finish your work in Metals. |
Previously in scala-cli the diagnostic `data` for actionable diagnostics were `textEdit`s, whereas now they are nested under `edits` and are `workspaceEdit`s. This change will ensure they still work for the old format and also for the new. This relates to the changes in VirtusLab/scala-cli#1969.
Alright, so this should be ready to go now. I have a PR in Metals that shows that it can still handle the old way of doing it, and we can add another test in there as well for the new way of doing it when we get a new release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
edit: will merge this after scalameta/metals#5173 is ready
That pr is actually ready. The only reason it's marked as a draft is because it's waiting for this one 😆 . |
och, but if we don't merge it in Metals it will be broken there 😅 We should merge the Metals one first IMHO |
Previously in scala-cli the diagnostic `data` for actionable diagnostics were `textEdit`s, whereas now they are nested under `edits` and are `workspaceEdit`s. This change will ensure they still work for the old format and also for the new. This relates to the changes in VirtusLab/scala-cli#1969.
The metals PR is merged 🎉 Do you need help finishing this one @ckipp01 ? |
Hey! I'll actually jump back on this now. I'll get to it this week. |
This is a simplified version of VirtusLab#1969 that gets rid of the `ActionableDiagnostic` that is used internally and instead just ensures that any time a `TextEdit` is created there is a `title`. Then we take all the information already contained in the `Diagnostic` and make a `ScalaAction` from it to be forwarded via the diagnostic data.
Superseded by #2284 |
This is a simplified version of VirtusLab#1969 that gets rid of the `ActionableDiagnostic` that is used internally and instead just ensures that any time a `TextEdit` is created there is a `title`. Then we take all the information already contained in the `Diagnostic` and make a `ScalaAction` from it to be forwarded via the diagnostic data.
This is a simplified version of VirtusLab#1969 that gets rid of the `ActionableDiagnostic` that is used internally and instead just ensures that any time a `TextEdit` is created there is a `title`. Then we take all the information already contained in the `Diagnostic` and make a `ScalaAction` from it to be forwarded via the diagnostic data.
* feat: use the new ScalaAction from BSP4J This is a simplified version of #1969 that gets rid of the `ActionableDiagnostic` that is used internally and instead just ensures that any time a `TextEdit` is created there is a `title`. Then we take all the information already contained in the `Diagnostic` and make a `ScalaAction` from it to be forwarded via the diagnostic data. * fix: make sure reflect config is updated * refactor: remove unused imports * fix: make sure data kind is set
This change is part of the discussion that we had at the Scala Tooling
Summit where we decided that using a
WorkspaceEdit
rather than aTextEdit
provided a more future-proof way of actionable diagnosticssince it's richer. This PR makes that changes, but in a limited way.
Diagnostic
to aBSP Diagnostic. It doesn't for example change the
TextEdit
that theinternal representation of Diagnostic has. That's left as is to
minimize changes internally.
changes
are supported in theWorkspaceEdit
mainly because that's all we really need at this time. In the future
this could be expanded to use the richer
documentChanges
if the BSPclient supports it.
data
slightly to not have theactual edit be at the top level and instead nests it under an
edit
key. There is no gaurantee that we won't have other keys in
data
inthe future, so this sort of allows for that and ensures that we don't
get stuck with only being able to have the actual
WorkspaceEdit
atthe top level in the
data
object.Fixes #1957