introduce functional variable (IDEA-141244)

This commit is contained in:
Anna Kozlova
2017-06-05 11:27:43 +03:00
parent e1ae657059
commit 5d9e95ad5d
24 changed files with 683 additions and 69 deletions
@@ -0,0 +1,14 @@
import java.util.function.Supplier;
class Test {
void foo() {
if (true) {
Supplier<String> stringSupplier = new Supplier<String>() {
public String get() {
return "Hello, world";
}
};
System.out.println(stringSupplier.get());
}
}
}
@@ -0,0 +1,12 @@
import java.util.function.Supplier;
class Test {
void foo() {
Supplier<String> stringSupplier = new Supplier<String>() {
public String get() {
return "Hello, world";
}
};
System.out.println(stringSupplier.get());
}
}
@@ -0,0 +1,15 @@
import java.util.function.Consumer;
class Test {
String myName;
void foo() {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
public void accept(String myName) {
System.out.println("Hello, world " + myName);
}
};
stringConsumer.accept(myName);
}
}
}
@@ -0,0 +1,11 @@
class Test {
void foo(String name) {
System.out.println("Hello, ");
Runnable runnable = new Runnable() {
public void run() {
System.out.println(name);
}
};
runnable.run();
}
}
@@ -0,0 +1,14 @@
import java.util.function.Consumer;
class Test {
void foo(String s) {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
public void accept(String s) {
System.out.println("Hello, world " + s);
}
};
stringConsumer.accept(s);
}
}
}
@@ -0,0 +1,17 @@
import java.util.function.Consumer;
class Test {
void foo(String s) {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
public void accept(String s) {
System.out.println("Hello, world " + s);
System.out.println();
}
};
stringConsumer.accept(s);
System.out.println();
}
}
}
@@ -0,0 +1,5 @@
class Test {
void foo() {
if (true) System.out.println(<selection>"Hello, world"</selection>);
}
}
@@ -0,0 +1,5 @@
class Test {
void foo() {
System.out.println(<selection>"Hello, world"</selection>);
}
}
@@ -0,0 +1,6 @@
class Test {
String myName;
void foo() {
if (true) <selection>System.out.println("Hello, world " + myName);</selection>
}
}
@@ -0,0 +1,6 @@
class Test {
void foo(String name) {
System.out.println("Hello, ");
<selection>System.out.println(name);</selection>
}
}
@@ -0,0 +1,5 @@
class Test {
void foo(String s) {
if (true) <selection>System.out.println("Hello, world " + s);</selection>
}
}
@@ -0,0 +1,10 @@
class Test {
void foo(String s) {
if (true) {
<selection>System.out.println("Hello, world " + s);
System.out.println();
</selection>
System.out.println();
}
}
}