mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
IDEA-162190 Inspection to convert anonymous ThreadLocal subclass to ThreadLocal.withInitial
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "true"
|
||||
public class Main {
|
||||
public void testThread() {
|
||||
// Comment outside
|
||||
// Ending comment
|
||||
new Thread(() -> {
|
||||
// Comment inside
|
||||
System.out.println("Hello from thread!");
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Replace anonymous class with ThreadLocal.withInitial" "true"
|
||||
public class Main {
|
||||
// comment
|
||||
ThreadLocal<? extends CharSequence> tlr = ThreadLocal.withInitial(() -> "initial");
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "true"
|
||||
public class Main {
|
||||
public void testThread() {
|
||||
new <caret>Thread() {
|
||||
// Comment outside
|
||||
@Override
|
||||
public void run() {
|
||||
// Comment inside
|
||||
System.out.println("Hello from thread!");
|
||||
}
|
||||
// Ending comment
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "false"
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class Main {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Anno{}
|
||||
|
||||
public void testThread() {
|
||||
new <caret>Thread() {
|
||||
@Override
|
||||
@Anno
|
||||
public void run() {
|
||||
System.out.println("Hello from thread! "+x);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "false"
|
||||
public class Main {
|
||||
public void testThread() {
|
||||
new <caret>Thread() {
|
||||
int x = 5;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Hello from thread! "+x);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace anonymous class with ThreadLocal.withInitial" "true"
|
||||
public class Main {
|
||||
ThreadLocal<? extends CharSequence> tlr = new Th<caret>readLocal<String>() {
|
||||
// comment
|
||||
@Override
|
||||
protected String initialValue() {
|
||||
return "initial";
|
||||
}
|
||||
};
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "false"
|
||||
public class Main {
|
||||
public void testThread() {
|
||||
new <caret>Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Hello from thread!");
|
||||
super.run();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace anonymous class with constructor accepting lambda" "false"
|
||||
public class Main {
|
||||
public void testThread() {
|
||||
new <caret>Thread() {
|
||||
@Override
|
||||
public void start() {
|
||||
System.out.println("Hello from thread!");
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user