mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-17 20:11:25 +07:00
DFA - moved the tests associated with "Simplify" quick-fix to a dedicated place
GitOrigin-RevId: 8bd67d61335fc77c2f8e115bfda45ade06041283
This commit is contained in:
committed by
intellij-monorepo-bot
parent
200da820b1
commit
3642a47796
@@ -0,0 +1,8 @@
|
||||
// "Simplify 'my.value() == null' to false" "true"
|
||||
class Test {
|
||||
void some(SuppressWarnings my) {
|
||||
if (my == null) {
|
||||
System.out.println("null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Simplify 'Objects.nonNull(...)' to true extracting side effects" "true"
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
|
||||
class X {
|
||||
void test(Set<String> set) {
|
||||
set.add("foo");
|
||||
boolean b = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Simplify 'b' to true" "true"
|
||||
class A {
|
||||
void foo(boolean b) {
|
||||
if (b) {
|
||||
String s = "foo" + true + "bar";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Simplify 'test(...) || obj == null' to true extracting side effects" "true"
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
class X {
|
||||
@Contract("_ -> true")
|
||||
boolean test(Object obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void doSmth(Object obj) {
|
||||
while(obj != null) {
|
||||
test(obj);
|
||||
System.out.println("aaahh");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// "Simplify 'pureConsumer(...)' to true extracting side effects" "true"
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class Main {
|
||||
private static int counter = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
while (true) {
|
||||
sideEffect();
|
||||
if (!(counter < 5)) break;
|
||||
System.out.println(counter);
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(value = "!null->true;null->false", pure = true)
|
||||
private static boolean pureConsumer(Object consumed) {
|
||||
return consumed != null;
|
||||
}
|
||||
|
||||
private static int sideEffect() {
|
||||
return counter++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Simplify 'my.value() == null' to false" "true"
|
||||
class Test {
|
||||
void some(SuppressWarnings my) {
|
||||
if (my == null || my.value() =<caret>= null) {
|
||||
System.out.println("null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Simplify 'Objects.nonNull(...)' to true extracting side effects" "true"
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
|
||||
class X {
|
||||
void test(Set<String> set) {
|
||||
boolean b = Objects.nonNull(set.<caret>add("foo"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Simplify 'b' to true" "true"
|
||||
class A {
|
||||
void foo(boolean b) {
|
||||
if (b) {
|
||||
String s = "foo" + <caret>b + "bar";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Simplify 'test(...) || obj == null' to true extracting side effects" "true"
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
class X {
|
||||
@Contract("_ -> true")
|
||||
boolean test(Object obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void doSmth(Object obj) {
|
||||
while(obj != null && (test(obj) <caret>|| obj == null)) {
|
||||
System.out.println("aaahh");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Simplify 'pureConsumer(...)' to true extracting side effects" "true"
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class Main {
|
||||
private static int counter = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
while (pureConsumer<caret>(sideEffect()) & counter < 5) {
|
||||
System.out.println(counter);
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(value = "!null->true;null->false", pure = true)
|
||||
private static boolean pureConsumer(Object consumed) {
|
||||
return consumed != null;
|
||||
}
|
||||
|
||||
private static int sideEffect() {
|
||||
return counter++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user