You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider adding an option when refactoring using “extract to local variable”, to add the final keyword to the variable created by the refactoring.
Steps To Reproduce
select statement that yields a result
trigger code actions
select “Extract to local variable”
Current Result
The statement is refactored so as to assign its result to a new variable. If I want the said variable to be final, then I have to afterwards go and add the final keyword before the variable declaration.
Expected Result
An option is provided so that the new variable is final, in other words, so that the final keyword is added automatically.
Additional Informations
Some authors claim that variables should be final whenever possible. See for example here for a small glimpse about this debate. Please consider providing help for those authors who like this style.
Icing on the cake
Detect automatically (as is done, I think, with the current option “Change modifiers to final when possible”) whether it is possible to make the variable final and provide a global setting to automatically make variables final, when refactoring using “extract to local variable”, whenever possible.
The text was updated successfully, but these errors were encountered:
Note that we partly did this for other quick-assists in eclipse-jdtls/eclipse.jdt.ls#2371 . It's controlled by java.codeGeneration.addFinalForNewDeclaration and can be none, variables, fields, all . Looks like it was only done for a handful of quick assists (eg. Assign statement to new (local variable|field), Create (local variable|field), Assign parameter to new field, Assign all parameters to new fields ).
If we can support this for the extract quick-assist through the same setting ,it makes sense to do.
Please consider adding an option when refactoring using “extract to local variable”, to add the
final
keyword to the variable created by the refactoring.Steps To Reproduce
Current Result
The statement is refactored so as to assign its result to a new variable. If I want the said variable to be
final
, then I have to afterwards go and add thefinal
keyword before the variable declaration.Expected Result
An option is provided so that the new variable is
final
, in other words, so that thefinal
keyword is added automatically.Additional Informations
Some authors claim that variables should be final whenever possible. See for example here for a small glimpse about this debate. Please consider providing help for those authors who like this style.
Icing on the cake
Detect automatically (as is done, I think, with the current option “Change modifiers to final when possible”) whether it is possible to make the variable final and provide a global setting to automatically make variables final, when refactoring using “extract to local variable”, whenever possible.
The text was updated successfully, but these errors were encountered: