Bug 201406 - Automatically added final modifiers
Automatically added final modifiers
Status: REOPENED
Product: java
Classification: Unclassified
Component: Hints
7.0.1
PC Linux
: P3 with 6 votes (vote)
: 7.1
Assigned To: Jan Lahoda
issues@java
http://twelve-programmers.blogspot.co...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-29 16:52 UTC by gualtiero65
Modified: 2017-04-19 14:52 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gualtiero65 2011-08-29 16:52:55 UTC
Hi,

it would be nice to have NB to automatically add (as Hint and/or as formatting opion) final modifier to private fields, method parameters and local variables.

This is a feature I used in Eclipse. See the URL for better explanation.

Thanks,

Gualtiero
Comment 1 markiewb 2012-12-28 22:33:48 UTC

*** This bug has been marked as a duplicate of bug 125566 ***
Comment 2 runiter 2016-02-17 15:01:31 UTC
Although netbean now hints that a field can be declared as final, this is not sufficient as the original poster had requested final to be added everywhere including "local variables" and "method parameters" (as is the case in eclipse).

Also hinting alone is not sufficient. It'd be much nicer if netbean could automatically add final wherever possible (add it as an option to onSave actions instead of hint). This is also the case in eclipse.

For these reasons I'm re-opening this issue.
Comment 3 jason3421 2017-04-19 14:52:48 UTC
IntelliJ also allows this: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206185619-Auto-add-the-final-modifier-to-newly-declared-variables-values

Here is an idea for an additional feature that will help Netbeans stand even higher above Eclipse/IntelliJ. Allow the user (me!) to set a font color for non-final variables and optionally hide the final keyword all together (i.e. it's not displayed in the IDE!). E.g. say 'orange' (for me) represents all non-final variables, that's my chosen visual representation for non-final variables, done :) The 'final' attribute can then be cleanly added to the popup that already shows the variable type (cursor on variable, ctrl + space to see that popup). Thanks for reading!


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo