eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
Provision to include custom diagnostics
The jdt language server could provide the ability for jdtls extensions to append some custom diagnostics.
Have you tried to create markers to the file that you want to add diagnostics?
Here is how JDT.LS convert markers to diagnostics: https://github.com/eclipse/eclipse.jdt.ls/blob/dd610bd7f0adef3fda56a9209f4b5a78e4139725/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/WorkspaceDiagnosticsHandler.java#L200
Related issue - https://github.com/eclipse/eclipse.jdt.ls/issues/2154
Really nice timing on fixing that issue :) I think it should make providing diagnostics a lot easier for other JDT-LS extensions. Feel free to report if there's something not working.
Closing this issue for now but feel free to re-open if there is still an issue.
As an example, see https://github.com/jbangdev/jbang-eclipse/blob/c50a5d6be22d57ecbb4b6c39d8a385fb877a6c7b/dev.jbang.eclipse.core/src/main/java/dev/jbang/eclipse/core/internal/project/ProjectConfigurationManager.java#L439 . With an IResource#createMarker(..)
, it should be enough to have the language server generate the markers on the corresponding file.
See https://github.com/eclipse/eclipse.jdt.ls/wiki/Contribute-an-extension-bundle#use-the-jdtls-extension for more details on contributing an extension to JDT-LS.