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

Add 'final' to 'Extract to local variable' result if requested #3198

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

hopehadfield
Copy link
Contributor

Applies when the java.codeGeneration.addFinalForNewDeclaration setting is set to all or variables. Also applicable for the 'replace all occurrences' extract proposal.

Closes redhat-developer/vscode-java#3308

extract-to-final-local-var

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good overall. I would rename the commit to :

Add 'final' to 'Extract to local variable' result if requested.

  • 'Extract to local variable' / 'Extract to local variable (replace all occurrences)' will respect java.codeGeneration.addFinalForNewDeclaration

@hopehadfield hopehadfield force-pushed the 3308-extract-local-var branch from ec32754 to 1a84f2b Compare June 20, 2024 13:54
@hopehadfield hopehadfield changed the title Add 'final' to 'Extract to Local Variable' result Add 'final' to 'Extract to local variable' result if requested Jun 20, 2024
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to address that comment I made about shortening the setFinal logic. Then we can merge.

I was considering ExtractFieldRefactoring as well, but a final field that isn't also static might be a more rare case.

Also, if you could adjust the body of the commit message so the line is longer than 80 characters. Update: Not longer..

- 'Extract to local variable' / 'Extract to local variable
  (replace all occurrences)' will respect
  'java.codeGeneration.addFinalForNewDeclaration'

Signed-off-by: Hope Hadfield <[email protected]>
@hopehadfield hopehadfield force-pushed the 3308-extract-local-var branch from 1a84f2b to b0cd695 Compare June 20, 2024 19:58
@rgrunber rgrunber merged commit 3e93eb1 into eclipse-jdtls:master Jun 21, 2024
7 checks passed
@hopehadfield hopehadfield deleted the 3308-extract-local-var branch June 26, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide option to extract to local *final* variable
2 participants