inline to anonymous: convert to lambda when applicable (IDEA-173821)

This commit is contained in:
Anna Kozlova
2017-06-07 18:59:35 +03:00
parent 101ae53c3b
commit 3e7e52a4df
4 changed files with 40 additions and 5 deletions

View File

@@ -0,0 +1,14 @@
import java.util.*;
class Main {
public class <caret>MyComparator implements Comparator<String> {
@Override
public int compare(String s1, String s2) {
return 0;
}
}
void sort(List<String> scores) {
scores.sort(new MyComparator());
}
}

View File

@@ -0,0 +1,8 @@
import java.util.*;
class Main {
void sort(List<String> scores) {
scores.sort((s1, s2) -> 0);
}
}

View File

@@ -54,6 +54,10 @@ public class InlineToAnonymousClassTest extends LightRefactoringTestCase {
doTest(false, false);
}
public void testConvertToLambdaJava8() throws Exception {
doTest(false, false);
}
public void testClassInitializer() throws Exception {
doTest(false, false);
}
@@ -499,6 +503,9 @@ public class InlineToAnonymousClassTest extends LightRefactoringTestCase {
@Override
protected LanguageLevel getLanguageLevel() {
if (getTestName(false).endsWith("Java8")) {
return LanguageLevel.JDK_1_8;
}
return LanguageLevel.JDK_1_7;
}
}