Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367659

Summary: [clean up] Code Clean Local Variable Declarations
Product: [Eclipse Project] JDT Reporter: Nathan Reynolds <numeralnathan>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: deepakazad, markus.kell.r
Version: 3.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Nathan Reynolds CLA 2011-12-30 11:12:39 EST
Build Identifier: 20110916-0149

Bug 367587 asks to add an option for quick fix to put local variable declarations at the top of the method instead of at the point of first assignment.

This enhancement request is to add an option to Preferences | Java | Code Style | Clean Up | Code Style | Variable declarations.  The option would control where local variable declarations are placed during cleanup.  The 2 options I can think of are at the top of the method and at first assignment.

Reproducible: Always
Comment 1 Deepak Azad CLA 2011-12-30 11:45:55 EST
A Save Action (or a Clean Up) can probably work here and makes more sense than configuring the quick fix.

Note that JDT can be extended with additional Clean ups and Save Actions. See http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_contributing_a_cleanup.htm
=> Read as: you can write a clean up for your use (and maybe later provide a patch here for consideration in JDT)
Comment 2 Deepak Azad CLA 2012-01-03 02:12:24 EST
As mentioned in bug 367587, putting all local variable declarations at the start of a method is not a popular or even a recommended style. Hence, this clean up will not be added to JDT.

(However, as mentioned in comment 1 you should be able to write your own Clean Up)