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
class ExtractMethodTest {
private final int value;
public ExtractMethodTest(int value) {
this.value = value;
}
public synchronized int calculate() {
int result;
switch (value) {
case 1:
result = value * 2;
break;
case 2:
result = value * 3;
break;
default:
result = value * 4;
break;
}
return result;
}
}
refactoring result:
After extracting the method, if inline refactoring is performed, the code will be inconsistent with the original code and an additional local variable will be declared
The text was updated successfully, but these errors were encountered:
- modify ExtractMethodRefactoring.createMethodBody() to check all
locals that needed to be created in new method to see if the old
declaration is still needed (i.e. referenced outside of the
selected statements) and if not, remove the original declaration
- modify all ExtractMethodTests where the locals are left behind
and not used elsewhere
- add new tests to ExtractMethodTests
- fixeseclipse-jdt#1357
…1399)
- modify ExtractMethodRefactoring.createMethodBody() to check all
locals that needed to be created in new method to see if the old
declaration is still needed (i.e. referenced outside of the
selected statements) and if not, remove the original declaration
- modify all ExtractMethodTests where the locals are left behind
and not used elsewhere
- add new tests to ExtractMethodTests
- fixes#1357
Eclipse version:2023-9
Repeat the steps:
class ExtractMethodTest {
private final int value;
}
refactoring result:
![image](https://private-user-images.githubusercontent.com/77560508/324741140-c1b2b51b-44f3-46fb-816b-025e221704f1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwODE5NTUsIm5iZiI6MTcyMDA4MTY1NSwicGF0aCI6Ii83NzU2MDUwOC8zMjQ3NDExNDAtYzFiMmI1MWItNDRmMy00NmZiLTgxNmItMDI1ZTIyMTcwNGYxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDA4MjczNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ0N2UxZTUxM2Y0YzEyNjE3ZWIwZTU5ZDFhYjk0M2MwYzljOWI0Yjg4OTNkOGY4ZWMzNTg1OGEwYzAxM2I2YmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GzDED2WIXOLNY4tlDa_0rCCOkl43WCe9J_dsrrNxB7Q)
After extracting the method, if inline refactoring is performed, the code will be inconsistent with the original code and an additional local variable will be declared
The text was updated successfully, but these errors were encountered: