eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

Provision to include custom diagnostics

Open kalel-13 opened this issue 2 years ago • 3 comments

The jdt language server could provide the ability for jdtls extensions to append some custom diagnostics.

kalel-13 avatar Jul 29 '22 05:07 kalel-13

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

jdneo avatar Aug 04 '22 07:08 jdneo

Related issue - https://github.com/eclipse/eclipse.jdt.ls/issues/2154

snjeza avatar Aug 04 '22 18:08 snjeza

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.

rgrunber avatar Aug 09 '22 15:08 rgrunber

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.

rgrunber avatar Aug 24 '22 02:08 rgrunber