-
Notifications
You must be signed in to change notification settings - Fork 841
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
Inline parameter name hints for Java #1247
Conversation
…ting highlight view.
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.
I'd mention the new preferenes key name in arch.xml
as <api group="property"/>
.
The feature has to be on by default, in my opinion.
Even though I agree in principle, I don't think the feature is in a state good enough to be enabled by default now. So either we wait with merging this until it is good enough, or we merge it as disabled by default, and flip the enabled/disabled by default switch when the time comes for that. |
Is it possible to have a small screenshot of this new editor feature? |
Is this features included within the next release of netbeans? |
ide/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/HighlightsList.java
Outdated
Show resolved
Hide resolved
@jlahoda fantastic! 😄 I started looking at what was required to implement this myself a couple of months ago but got waylaid. So, what are your thoughts on merging as off-by-default for NB11.1 to get some testing in the wild, with a view to on-by-default in NB12.x if not before? |
Agreed, off by default for 11.1 if possible and on by default for 12? |
I very much agree on having this in NB11.1, even off-by-default. Parameter names and in general in-line dynamic editor annotations/helpers are hype in competitor IDEs. This would allow to show that NB is not lagging behind. |
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.
Very cool. Off by default in 11.1, can this be done?
Or, it seems to be off by default already? If so, let's merge this. |
OK, then. Merging. |
Wow, this is exactly what we need for each language. I wanted to try to achieve that, but I didn't know how to create virtual text or readonly text inside the editor. Is there an public API/documentation for creating such virtual text to makes it easier @jlahoda? |
@Chris2011, yes, there is an API. A short description is in the apichanges: Basically, create a highlight that will have "virtual-text-prepend" as the highlight key, value is the virtual text. This is the place where it is used in Java, which may be useful as well: netbeans/java/java.editor/src/org/netbeans/modules/java/editor/semantic/SemanticHighlighter.java Line 75 in 0c67f21
|
Great. Thx :) |
It seems this patch only affect literals? Shouldn't it fire for every kind of parameter? Maybe configurable for performance reasons? :) |
I bet the thought is that if you're passing in an actual variable, you should just a good variable name. Otherwise you have lots of instances of:
Edit: Just to reword, I'm saying that if your variable names are good, these hints would add a lot of screen clutter. I am still interested in this feature, but I am thinking it has some interesting unintended consequences.
Please don't get too caught up deciding if you prefer example 1 or 2, my point is that it's probably a preference. |
@graben was trying to find time to look at enhancing similarly - been mentioned various times by users. While I somewhat understand @sharpedavid comment, maybe there's a way to make it configurable? Also would be great to cover parameters that are method return values. One area that would be good to drop duplication though is on varargs. Wonder how easy to just label the first? |
Just copy the "specific" code (DRAFT :)) from visitliteral to visitidentifier and visitmethodinvokation does make the feature work for variables and methods return, too. I do not see any performance issues at the moment. |
It's just a simple if around the put of the hint :) |
I also had some troubles, that not always shows the inline hint. Will show an example later by reprodcution. |
Is there an option to configure the editor behavior in this case? |
There is just activating/deactivating afaik. |
Just discovered this feature... very cool! It will be very useful during code review workflows. |
For method calls, parameter names can be injected (in a virtual text) directly into the editor. Disabled by default, as this probably needs more experience tweaking. Enable using View/Inline Hints.