Bug 123946 - [quick assist] "Add keyword 'final' to all unchanged variables and properties"
Summary: [quick assist] "Add keyword 'final' to all unchanged variables and properties"
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Benno Baumgartner CLA
QA Contact:
URL: http://www.azew.com
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-16 06:11 EST by fx CLA
Modified: 2006-02-24 13:10 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fx CLA 2006-01-16 06:11:36 EST
This function can be provide with the "Format" function
Comment 1 fx CLA 2006-01-16 06:23:35 EST
I think this function should be provided with "Format" when you press Ctrl+Shift+F


You can config this in the Window -> Preferences -> Java -> Code Style -> Formatter -> Edit
Comment 2 Olivier Thomann CLA 2006-01-17 09:05:04 EST
The formatter has no notion of unchanged variables.
It simply manages the whitespaces for a stream of tokens.
Comment 3 fx CLA 2006-01-17 09:31:26 EST
Maybe Eclipse can use "Quick fix" to do this.
Comment 4 Olivier Thomann CLA 2006-01-17 09:33:49 EST
Then move to JDT/UI
Comment 5 Jimisola Laursen CLA 2006-02-21 17:13:43 EST
+1

A Quick Fix or similiar in Eclipse for this operations would mean a lot to improving code, hence removing simple bugs. Especially, since I don't know of any other Java IDE/tools that does this for you. 

An article "Seven Low-Cost Ways to Improve Legacy Code" http://www.onjava.com/pub/a/onjava/2004/04/28/hardcorejava.html brings this up in the third section Introduce final All Over Your Code. PMD detects this as well by warning that "Local variable could be declared final".

Just to clear things up by, bug reporter mentioned "unchanged variables and properties", that is, variables in immutable classes, local unchanged variables and all parameters except for in-out parameters.

I would really like to see this for 3.2 final release.
Comment 6 Benno Baumgartner CLA 2006-02-22 03:50:21 EST
See also Bug 108558
Comment 7 Markus Milleder CLA 2006-02-22 10:58:53 EST
The "PMD Eclipse Lite" plugin can add the "final" keyword unconditionally to all parameters

See http://sourceforge.net/projects/pmd-eclipse/
Comment 8 Benno Baumgartner CLA 2006-02-24 13:06:31 EST
fixed > I20060221-1300

Added make final if possible: quick assist and clean up for private fields, parameters and local variables.
Comment 9 Jimisola Laursen CLA 2006-02-24 13:10:19 EST
Wow, that was quick. Thanks Benno!