Skip to content
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

Merged
merged 15 commits into from Jun 14, 2019

Conversation

@jlahoda
Copy link
Contributor

commented May 12, 2019

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.

@jlahoda jlahoda requested review from geertjanw and JaroslavTulach May 12, 2019

@JaroslavTulach
Copy link
Contributor

left a comment

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.

@jlahoda

This comment has been minimized.

Copy link
Contributor Author

commented May 12, 2019

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.

@AlexFalappa

This comment has been minimized.

Copy link
Contributor

commented May 15, 2019

Is it possible to have a small screenshot of this new editor feature?

@wumpz

This comment has been minimized.

Copy link

commented May 23, 2019

Is this features included within the next release of netbeans?

@jlahoda

This comment has been minimized.

Copy link
Contributor Author

commented May 24, 2019

Screenshot:
inline-names

<summary>Prepended text for highlights</summary>
<version major="2" minor="24"/>
<date day="14" month="5" year="2019"/>
<author login="markiewb"/>

This comment has been minimized.

Copy link
@junichi11

junichi11 May 24, 2019

Member

Maybe, it seems that you forgot to change the author.

@@ -157,12 +159,14 @@ public AttributeSet cutSameFont(Font defaultFont, int maxEndOffset, int wsEndOff

// Extends beyond first highlight
Font firstFont = ViewUtils.getFont(firstAttrs, defaultFont);
Object firstPrependText = usePrependText && firstAttrs != null ? firstAttrs.getAttribute("virtual-text-prepend") : null;

This comment has been minimized.

Copy link
@junichi11

junichi11 May 24, 2019

Member

Is // NOI18N missing?
Should introduce the constant somewhere? But I could be wrong.

@junichi11 junichi11 added the Java label May 29, 2019

@neilcsmith-net

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

@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?

@svenreimers

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

Agreed, off by default for 11.1 if possible and on by default for 12?

@AlexFalappa

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2019

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.

@geertjanw
Copy link
Member

left a comment

Very cool. Off by default in 11.1, can this be done?

@geertjanw

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

Or, it seems to be off by default already? If so, let's merge this.

@geertjanw

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

OK, then. Merging.

@geertjanw geertjanw merged commit 8971234 into apache:master Jun 14, 2019

@Chris2011

This comment has been minimized.

Copy link
Contributor

commented Jun 14, 2019

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?

@jlahoda

This comment has been minimized.

Copy link
Contributor Author

commented Jun 23, 2019

@Chris2011, yes, there is an API. A short description is in the apichanges:
https://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-lib2/apichanges.html#PrependedTextOpt

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:

@Chris2011

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2019

Great. Thx :)

@graben

This comment has been minimized.

Copy link

commented Jul 10, 2019

It seems this patch only affect literals? Shouldn't it fire for every kind of parameter? Maybe configurable for performance reasons? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.