DFA - moved the tests associated with "Simplify" quick-fix to a dedicated place

GitOrigin-RevId: 8bd67d61335fc77c2f8e115bfda45ade06041283
This commit is contained in:
Ilyas Selimov
2021-05-18 13:37:26 +07:00
committed by intellij-monorepo-bot
parent 200da820b1
commit 3642a47796
10 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
// "Simplify 'my.value() == null' to false" "true"
class Test {
void some(SuppressWarnings my) {
if (my == null) {
System.out.println("null");
}
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,9 @@
// "Simplify 'b' to true" "true"
class A {
void foo(boolean b) {
if (b) {
String s = "foo" + true + "bar";
}
}
}

View File

@@ -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");
}
}
}

View File

@@ -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++;
}
}

View File

@@ -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");
}
}
}

View File

@@ -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"));
}
}

View File

@@ -0,0 +1,9 @@
// "Simplify 'b' to true" "true"
class A {
void foo(boolean b) {
if (b) {
String s = "foo" + <caret>b + "bar";
}
}
}

View File

@@ -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");
}
}
}

View File

@@ -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++;
}
}