lambda: convert anonymous to lambda inspection & fix

This commit is contained in:
Anna Kozlova
2012-08-20 21:02:43 +04:00
parent 01970963cf
commit 8b0455ce93
19 changed files with 373 additions and 1 deletions
@@ -0,0 +1,8 @@
// "Replace with lambda" "true"
class Test {
{
Comparable<String> c = (o)->{
return 0;
};
}
}
@@ -0,0 +1,14 @@
// "Replace with lambda" "true"
class Test {
{
Comparable<String> c = (final String o)->{
Runnable r = new Runnable() {
@Override
public void run() {
System.out.println(o);
}
};
return 0;
};
}
}
@@ -0,0 +1,15 @@
// "Replace with lambda" "true"
class Test2 {
interface I<X> {
X foo(List<X> list);
}
static <T> I<T> bar(I<T> i){return i;}
{
bar((List<String> list)->{
return null; //To change body of implemented methods use File | Settings | File Templates.
});
}
}
@@ -0,0 +1,8 @@
// "Replace with lambda" "true"
class Test {
{
Runnable r = ()->{
System.out.println("");
};
}
}
@@ -0,0 +1,8 @@
// "Replace with lambda" "true"
class Test {
{
Runnable[] r = new Runnable[] {()->{
System.out.println("");
}};
}
}
@@ -0,0 +1,16 @@
// "Replace with lambda" "false"
class Test {
{
A a = new A<caret>("str") {
@Override
public void foo() {
}
};
}
static class A {
A(String s) {
}
public void foo(){}
}
}
@@ -0,0 +1,11 @@
// "Replace with lambda" "false"
class Test {
{
new Ru<caret>nnable() {
@Override
public void run() {
//To change body of implemented methods use File | Settings | File Templates.
}
}.getClass();;
}
}
@@ -0,0 +1,11 @@
// "Replace with lambda" "true"
class Test {
{
Comparable<String> c = new Compa<caret>rable<String>() {
@Override
public int compareTo(String o) {
return 0;
}
};
}
}
@@ -0,0 +1,17 @@
// "Replace with lambda" "true"
class Test {
{
Comparable<String> c = new Compa<caret>rable<String>() {
@Override
public int compareTo(final String o) {
Runnable r = new Runnable() {
@Override
public void run() {
System.out.println(o);
}
};
return 0;
}
};
}
}
@@ -0,0 +1,18 @@
// "Replace with lambda" "true"
class Test2 {
interface I<X> {
X foo(List<X> list);
}
static <T> I<T> bar(I<T> i){return i;}
{
bar(new I<Stri<caret>ng>() {
@Override
public String foo(List<String> list) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
});
}
}
@@ -0,0 +1,9 @@
// "Replace with lambda" "false"
class Test {
{
Runnable a = new Run<caret>nable() {
@Override
public void run()
};
}
}
@@ -0,0 +1,11 @@
// "Replace with lambda" "true"
class Test {
{
Runnable r = new Run<caret>nable() {
@Override
public void run() {
System.out.println("");
}
};
}
}
@@ -0,0 +1,11 @@
// "Replace with lambda" "true"
class Test {
{
Runnable[] r = new Runnable[] {new Run<caret>nable() {
@Override
public void run() {
System.out.println("");
}
}};
}
}
@@ -0,0 +1,12 @@
// "Replace with lambda" "false"
class Test {
{
Runnable r = new Ru<caret>nnable() {
@Override
public void run() {
helper();
}
private void helper(){}
};
}
}