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

Extracting local variables and reconstructing causes conflicts with parameter names #3595

Closed
DongChunHao opened this issue Apr 25, 2024 · 1 comment

Comments

@DongChunHao
Copy link

[provide a description of the issue]

Environment

Operating System: Windows11
JDK version: 17
Visual Studio Code version: 1.88
Java extension version: 1.29

Steps To Reproduce
  1. select "5"
  2. click “Refacator-Extract local variable”
  3. new variable name " localVar"

public class Example {
public void method(int localVar) {
// extract variable: 5, rename localVar
System.out.println(5);
}
}

refactoring result:

public class Example {
public void method(int localVar) {
// extract variable: 5, rename localVar
int localVar = 5;
System.out.println(localVar);
}
}

Reason: When extracting local variables, there was no detection of naming conflicts between the new variable name and the context

Expected behavior: Check for naming conflicts before and after refactoring, and provide warning prompts

@rgrunber
Copy link
Member

I would close this in favour of #3594 . It's a bit different, but someone investigating would probably be able to handle this along with that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants