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

improvement: Forward all LSP data from BSP #7294

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class Diagnostics(
def reset(): Unit = {
val keys = diagnostics.keys
diagnostics.clear()
keys.foreach { key => publishDiagnostics(key) }
keys.foreach { desc => publishDiagnostics(desc) }
}

def reset(paths: Seq[AbsolutePath]): Unit =
Expand Down Expand Up @@ -323,23 +323,18 @@ final class Diagnostics(
adjustWithinToken = shouldAdjustWithinToken(d),
)
.map { range =>
val ld = new l.Diagnostic(
range,
d.getMessage,
d.getSeverity,
d.getSource,
)
d.setRange(range)
// Scala 3 sets the diagnostic code to -1 for NoExplanation Messages. Ideally
// this will change and we won't need this check in the future, but for now
// let's not forward them.
// let's not forward them, since they are not valid for all clients.
val isScala3NoExplanationDiag = d.getCode() != null && d
.getCode()
.isLeft() && d.getCode().getLeft() == "-1"
if (!isScala3NoExplanationDiag) ld.setCode(d.getCode())

ld.setTags(d.getTags())
adjustedDiagnosticData(d, edit).map(newData => ld.setData(newData))
ld
if (isScala3NoExplanationDiag) {
d.setCode(null: l.jsonrpc.messages.Either[String, Integer])
}
adjustedDiagnosticData(d, edit).map(newData => d.setData(newData))
d
}
if (result.isEmpty) {
d.getRange.toMeta(snapshot).foreach { pos =>
Expand Down
Loading