Java: Slightly increased the limit for size of subexpression that can be an extracted method's parameter (IDEA-181195)

This commit is contained in:
Pavel Dolgov
2019-02-12 14:26:37 +03:00
parent f33d435dbe
commit 0d8a4fd924
4 changed files with 34 additions and 1 deletions
@@ -12,7 +12,7 @@ import java.util.List;
* @author Pavel.Dolgov
*/
class ComplexityHolder {
static final int MAX_ACCEPTABLE = 9;
static final int MAX_ACCEPTABLE = 12;
static final int TOO_COMPLEX = 100;
private final ObjectIntHashMap<PsiExpression> myCache = new ObjectIntHashMap<>();
@@ -0,0 +1,11 @@
class C {
void foo(String x, int a, int b) {
String s1 = <selection>sum(a, b).substring(2, Math.max(a, b))</selection>;
String s2 = sum(a, 0).substring(2, Math.min(a, b) + 1);
String s3 = x.substring(2, a - b);
}
String sum(int a, int b) {
return a + " " + b;
}
}
@@ -0,0 +1,18 @@
import org.jetbrains.annotations.NotNull;
class C {
void foo(String x, int a, int b) {
String s1 = newMethod(sum(a, b), Math.max(a, b));
String s2 = newMethod(sum(a, 0), Math.min(a, b) + 1);
String s3 = newMethod(x, a - b);
}
@NotNull
private String newMethod(String sum, int max) {
return sum.substring(2, max);
}
String sum(int a, int b) {
return a + " " + b;
}
}
@@ -947,6 +947,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
doDuplicatesTest();
}
public void testParametrizedDuplicateExpression() throws Exception {
doDuplicatesTest();
}
public void testSuggestChangeSignatureWithChangedParameterName() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".java");
boolean success = performExtractMethod(true, true, getEditor(), getFile(), getProject(), false, null, false, "p");