Adding inlay hints in the VS Code extension.#6053
Conversation
| js.runUserActionTask(cc -> { | ||
| cc.toPhase(JavaSource.Phase.RESOLVED); | ||
| Preferences preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default"); | ||
| preferences.putBoolean(JAVA_INLINE_HINT_PARAMETER_NAME, enabled.contains("parameter")); |
There was a problem hiding this comment.
Preferences.put!? Quite a hacky solution. I'd replace this with "branding API"_ and specified different default in nbcode suite.
|
Btw. Metals - the VSCode support for Scala is using Italics to render the additional inline hints: |
5dbbf28 to
f54619a
Compare
|
I've updated the patch, make a general provider (so that other languages can contribute as well), the settings in Any insights/feedback? Might be good to finalize this at some point. Thanks! |
jtulach
left a comment
There was a problem hiding this comment.
Thanks for making this work!
| @MimeLocation(subfolderName = "CodeLensProvider") | ||
| public interface InlayHintsProvider { | ||
|
|
||
| public Set<String> supportedHintTypes(); |
There was a problem hiding this comment.
Missing documentation and explanation of what this is for.
| */ | ||
| public CompletableFuture<List<? extends InlayHint>> codeLens(@NonNull Context context); | ||
|
|
||
| public static final class Context { |
| private final @NonNull Set<String> requestedHintTypes; | ||
| private final @NullAllowed Range range; | ||
|
|
||
| public Context(@NonNull FileObject file, @NonNull Set<String> requestedHintTypes, @NullAllowed Range range) { |
There was a problem hiding this comment.
This should be "module private", right?
There was a problem hiding this comment.
Sadly, I think java.lsp.server needs to create the Context, so that it can call the inlayHints method.
| public static Settings getDefault() { | ||
| Preferences preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default"); | ||
| return new Settings(preferences.getBoolean(JAVA_INLINE_HINT_PARAMETER_NAME, DEFAULT_VALUES.get(JAVA_INLINE_HINT_PARAMETER_NAME)), | ||
| preferences.getBoolean(JAVA_INLINE_HINT_CHAINED_TYPES, DEFAULT_VALUES.get(JAVA_INLINE_HINT_CHAINED_TYPES)), |
There was a problem hiding this comment.
How is this connected with vscode/package.json?
There was a problem hiding this comment.
A different instance of Settings is created, and used when running the semantic highlighter. It is created here:
The instance created here is only used when running inside the NetBeans IDE.
999706b to
5f2b8b4
Compare
5f2b8b4 to
a3c2f88
Compare
|
Commit squashed, tests are passing. Unless there are objections, I probably should integrate in the next day or so. @dbalek, @MartinBalin |
| * | ||
| * @since 1.33 | ||
| */ | ||
| @MimeLocation(subfolderName = "CodeLensProvider") |
There was a problem hiding this comment.
Why are the registrations located under CodeLensProvider ?
a3c2f88 to
105eea1
Compare


Adding ability to show the inline hints (using "inlayHints" of the LSP), showing the same hints as for NetBeans. Enabled by default, but can be adjusted either in global settings (Editor/Inlay Hints), or individual Java-specific capabilities can be enabled/disabled in the extension settings.
It looks like this:

^Add meaningful description above
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.