-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove locals moved via extract method if they aren't used elsewhere (#…
…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
- Loading branch information
Showing
11 changed files
with
123 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
|
||
public class A_test501 { | ||
public void foo() { | ||
int x= 10; | ||
|
||
extracted(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,6 @@ | |
|
||
public class A_test502 { | ||
public void foo() { | ||
int x= 0; | ||
int y= 0; | ||
|
||
extracted(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
public class A_test509 { | ||
public void foo() { | ||
int x= 0; | ||
int y= 0; | ||
|
||
extracted(x); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
|
||
public class A_test518 { | ||
public void foo() { | ||
int i; | ||
|
||
extracted(); | ||
} | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
...ources/ExtractMethodWorkSpace/ExtractMethodTests/validSelection_in/A_testIssue1357_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package validSelection_in; | ||
|
||
public class A_testIssue1357_1 { | ||
|
||
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;/*[*/ | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ources/ExtractMethodWorkSpace/ExtractMethodTests/validSelection_in/A_testIssue1357_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package validSelection_in; | ||
|
||
public class A_testIssue1357_2 { | ||
|
||
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; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...urces/ExtractMethodWorkSpace/ExtractMethodTests/validSelection_out/A_testIssue1357_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package validSelection_out; | ||
|
||
public class A_testIssue1357_1 { | ||
|
||
public synchronized int calculate() { | ||
return extracted();/*[*/ | ||
} | ||
|
||
protected int extracted() { | ||
int result; | ||
switch (value) { | ||
case 1: | ||
result = value * 2; | ||
break; | ||
case 2: | ||
result = value * 3; | ||
break; | ||
default: | ||
result = value * 4; | ||
break; | ||
} | ||
return result; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...urces/ExtractMethodWorkSpace/ExtractMethodTests/validSelection_out/A_testIssue1357_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package validSelection_out; | ||
|
||
public class A_testIssue1357_2 { | ||
|
||
public synchronized int calculate() { | ||
int result; | ||
/*]*/result = extracted();/*[*/ | ||
return result; | ||
} | ||
|
||
protected int extracted() { | ||
int result; | ||
switch (value) { | ||
case 1: | ||
result = value * 2; | ||
break; | ||
case 2: | ||
result = value * 3; | ||
break; | ||
default: | ||
result = value * 4; | ||
break; | ||
} | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ public class A_test2001 { | |
int field= 0; | ||
|
||
void fun() { | ||
int i; | ||
extracted(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters