-
Notifications
You must be signed in to change notification settings - Fork 917
Adding inlay hints in the VS Code extension. #6053
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this work!
| @MimeLocation(subfolderName = "CodeLensProvider") | ||
| public interface InlayHintsProvider { | ||
|
|
||
| public Set<String> supportedHintTypes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation and explanation of what this is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| */ | ||
| public CompletableFuture<List<? extends InlayHint>> codeLens(@NonNull Context context); | ||
|
|
||
| public static final class Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "module private", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this connected with vscode/package.json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A different instance of Settings is created, and used when running the semantic highlighter. It is created here:
netbeans/java/java.editor/src/org/netbeans/modules/java/editor/semantic/InlayHintsProviderImpl.java
Line 63 in dd86bb8
| new SemanticHighlighterBase.Settings(context.getRequestedHintTypes().contains("parameter"), |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.