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

feat: Create custom OxcLspDiagnosticsSupport to enhance the messages and tooltips provided by the LSP diagnostics #74

Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.iwanabethatguy.oxcintellijplugin.lsp

import com.intellij.platform.lsp.api.customization.LspDiagnosticsSupport
import org.eclipse.lsp4j.Diagnostic

@Suppress("UnstableApiUsage")
class OxcLspDiagnosticsSupport : LspDiagnosticsSupport() {

override fun getMessage(diagnostic: Diagnostic): String {
return "${diagnostic.source}: ${diagnostic.message} ${diagnostic.code.get()}"
}

override fun getTooltip(diagnostic: Diagnostic): String {
var rule = diagnostic.code.get()
if (diagnostic.codeDescription?.href != null) {
rule = "<a href=\"${diagnostic.codeDescription.href}\">${diagnostic.code.get()}</a>"
}

return "${diagnostic.source}: ${diagnostic.message} $rule"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor
import com.intellij.platform.lsp.api.customization.LspDiagnosticsSupport

@Suppress("UnstableApiUsage")
class OxcLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Oxc") {
Expand Down Expand Up @@ -63,4 +64,6 @@

override val lspHoverSupport = false

override val lspDiagnosticsSupport: LspDiagnosticsSupport? = OxcLspDiagnosticsSupport()

Check warning on line 67 in src/main/kotlin/com/github/iwanabethatguy/oxcintellijplugin/lsp/OxcLspServerDescriptor.kt

View workflow job for this annotation

GitHub Actions / Inspect code

Redundant nullable return type

'lspDiagnosticsSupport' is always non-null type

}
Loading