redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.05k stars 420 forks source link

Change color of methods without reference #3681

Open raulvaldoleiros opened 1 week ago

raulvaldoleiros commented 1 week ago

It would be great if vscode java changed the color method, maybe to grey, on methods without any reference to it.

Similar to what intellij have.

rgrunber commented 1 week ago

There's a few workarounds / other ways to achieve something similar, though I guess this is definitely something that could be done, given that we have the data from reference code lens (ie. 0 references), and could just use the semantic highlighting on the language server side to correctly set the highlighting.

Using java.referencesCodeLens.enabled: true (assuming editor.codeLens: true is also set), you would see 0 references over any method declaration that is not referenced anywhere.

For private methods only (a little simpler because they need not be searched throughout the entire project), there's :

.vscode/settings.json

{
    "java.settings.url": ".vscode/settings.prefs",
}

settings.prefs

org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
raulvaldoleiros commented 21 hours ago

Hi @rgrunber,

Thanks for the update. For private methods sonarlint shows a warning message and change the method color to grey. image

For non-private methods the referencesCodeLens shows there isn't references but don't change the method color. image

I will use your suggestion for referenceCodeLens, thanks 👍 IMHO this improvement should be considerer for your future backlog.