-
Notifications
You must be signed in to change notification settings - Fork 874
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
Make more hints for java available #5013
Conversation
@neilcsmith-net @mbien @jtulach: What do you think? I agree, that |
@matthiasblaesing I had no time to look at the code yet but having more granularity for this setting is great, +1 from me. The short version about my opinion on inline hints taken from past discussions: I am not a fan of inline-text since the demand for them indicates problems with the code ("code smell"). Code has to be readable without them. Wanting to see the type of a So how should an IDE make (somewhat) badly written code more readable without influencing how new code is written? I am not sure. (one thought: if you really want to see the type of a But more options is a good start +1 from me - good job Matthias. I wouldn't say no to having them on by default - I just would prefer not to due to the reasons given. |
....editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java
Outdated
Show resolved
Hide resolved
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.
tested it and it works great. Please take a look at the lazyInit
comment before merge.
...a.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java
Outdated
Show resolved
Hide resolved
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsPanel.java
Outdated
Show resolved
Hide resolved
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsPanel.java
Outdated
Show resolved
Hide resolved
2699a11
to
60fb7d5
Compare
…ethod invocations as well.
…esult is used e.g. as a method argument.
60fb7d5
to
0409f6e
Compare
I pushed an updated version the changes:
Result: This has all inline hints enabled and shows the new tooltip |
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.
Won't get a chance to test it properly until next week, but from the image and description of other changes, it looks great to me! Thanks for persevering.
0409f6e
to
088a30e
Compare
I'll merge this next weekend, if none objects before then. |
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.
took another look and it still looks good to me
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.
Sorry, I missed this one. I unfortunately didn't have time to try yet. I think it is great to have configuration for the inline hints, seems fine with a few comments.
Besides the inline comment:
-I am not sure about the Ctrl-P - feels a bit unconceptial, it will be difficult to enhance this to other possible cases (like for implicitly typed lambda parameters, which, frankly, and not really different to vars). The tooltip for Ctrl-mouse is showing types of variables (and could be fixed to also work over var
), and if a shortcut is needed to allow pure keyboard access, chossing a different action might be more viable for the long term.
-showing the type for var
at the end of the line is a nice trick, but I am not sure if it will scale. Specifically, if we try to add the same feature for implicitly type lambda parameters, it will be hard to put the types at the end of the line. Ultimately, var
will be the an outlier in how other similar things will be handled. (And, overall, we may need to add more stuff at the end of lines - debugging info comes to mind.)
|
||
private static boolean inited = false; | ||
private static Preferences preferences; | ||
private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() { |
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.
Not sure if this listening and updating settings is really needed - it would probably be enough to read the settings at the start of the task. Listening on the change is often only needed to trigger re-run of the tasks when the settings change.
Well - I used the existing code path, that runs through the completion (type tooltip) code path. From a code perspective it seemed logical. Though...
I did not know of the CTRL-mouse way yet. It indeed looks like the right appoach. Could you give me a hint where this is handled (@jlahoda)? For the placement of the var type - indeed from a readability perspective I think it would be better placed behind the var, though the same is true for the method invocations. |
@jlahoda that depends a little whether you consider if it's conceptually the Personally I'm not sure completely inline hints scale anyway. Some users get confused by non-editable text appearing in amongst their text, and they affect formatting of code (eg. by default we show a right margin guide, which becomes less useful the more hints there are). Whereas there's at least more space at line ends to show information in a potentially less confusing way? Or we could consider vertical space instead? I have less concerns where hints are not enabled by default though. |
The Ctrl-mouse tooltips are computed here:
It may be needed to add the
It is all used from here (among other places): https://github.com/apache/netbeans/blob/master/java/java.editor/src/org/netbeans/modules/java/editor/hyperlink/JavaHyperlinkProvider.java Thanks. |
The cursor was display in prepend text and EOL special char was overprinted.
088a30e
to
f148d56
Compare
@jlahoda thank you. Indeed the So I dropped that part from this PR. The reading of the preferences was simplified and happens now on invocation. @neilcsmith-net @mbien I returned to the original implementation for the var types. The moment you enable inline hints, the layout is already screwed. Maybe my taste is damaged from working with typescript, but having seen that syntax it looks more natural this way. I still agree, that inline hints should not be needed, but I can imagine situations were I might be happy to have it. The screenshot shows, that the rendering of the prepend text still works after simplification and now the "prepend text", the cursor and the end-of-line character are all fully rendered (fourth line). |
i have been testing this PR with the following setup and it worked quite well:
this avoids basically all issues I would encounter while writing code (since its off when i write code). like a cursor which jumps around the inline text which is something I would have to get used to first. It also doesn't interfere in how I write or format code - while aiding with code readability when needed. I really like that. wondering if it would make sense to add a toolbar toggle icon to the editor toolbar so that this feature and particular usecase could be easier discovered. (doesn't have to be with this PR, just something to think about maybe?) |
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.
+1 to merging, given we keep extra hints disabled. (I do understand that enabling hints screws the layout anyway, but there are degrees of that!)
I'd be inclined to -1 any further hints being displayed by default, at least as and until we've had a good conversation on usability and discoverability.
I do wonder, looking at some other IDEs, whether the push-to-hint approach is a better default one.
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.
Looks good to me, thanks!
Lets get this in. Thank you all for taking part in the discussion and review! |
There are two PRs currently bitrotting: #2785 and #4522. Both add type information to the java editor view. The type information is shown like the parameter name hint, that is already part of NetBeans. For a visual example please have a look at the linked PRs.
This PR bundles the two, fixes a compilation problem and adds an option to enable and disable the hints individually: