mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
// "Add on demand static import for 'test.Foo'" "false"
|
||||
class Foo {
|
||||
{
|
||||
final Stri<caret>ng. s = toString();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ abstract class Test {
|
||||
|
||||
void foo() {
|
||||
Class<?> i = getObject().getClass();
|
||||
if (i.equals(RuntimeException.class)) {
|
||||
} else if (i.equals(IOException.class)) {
|
||||
if (RuntimeException.class.equals(i)) {
|
||||
} else if (IOException.class.equals(i)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
|
||||
void m(String s, int a) throws IOException {
|
||||
if ("a".equals(s)) {
|
||||
a();
|
||||
} else {
|
||||
d();
|
||||
}
|
||||
}
|
||||
|
||||
void a() throws IOException { }
|
||||
void d() throws IOException { }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
void test4() throws IOException {
|
||||
String variable = "abc";
|
||||
if ("abc".equals(variable)) {
|
||||
String s1 = "abcd";
|
||||
} else if ("def".equals(variable)) {
|
||||
String s1 = "abcd";
|
||||
myFunction(s1);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public void myFunction(Object o1) throws IOException {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
public void doSomething( String value) {
|
||||
if ("case1".equals(value)) {
|
||||
} else if ("case2".equals(value)) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
|
||||
void m(String s, int a) throws IOException {
|
||||
switch<caret> (s) {
|
||||
case "a": {
|
||||
a();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
d();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a() throws IOException { }
|
||||
void d() throws IOException { }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
void test4() throws IOException {
|
||||
String variable = "abc";
|
||||
<caret>switch (variable) {
|
||||
case "abc": {
|
||||
String s1 = "abcd";
|
||||
break;
|
||||
}
|
||||
case "def": {
|
||||
String s1 = "abcd";
|
||||
myFunction(s1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public void myFunction(Object o1) throws IOException {
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace 'switch' with 'if'" "true"
|
||||
class X {
|
||||
public void doSomething( String value) {
|
||||
switch<caret> ( value ) {
|
||||
case "case1":
|
||||
break;
|
||||
case "case2":
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -5,7 +5,6 @@ class C {
|
||||
if (s instanceof String) {
|
||||
String s1 = (String) s;
|
||||
<caret>
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Insert '(String)o' declaration" "true"
|
||||
class X {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String) {
|
||||
String o1 = (String) o;
|
||||
<caret>
|
||||
String substring = o.();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -5,8 +5,7 @@ class C {
|
||||
void f(Object o) {
|
||||
if (o instanceof IOException) {
|
||||
IOException o1 = (IOException) o;
|
||||
|
||||
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Insert '(String)o' declaration" "true"
|
||||
class X {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String) {
|
||||
String a;
|
||||
String b;
|
||||
String o1 = (String) o;
|
||||
<caret>
|
||||
|
||||
String c;
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -4,7 +4,6 @@ class C {
|
||||
if (o instanceof String && f == null) {
|
||||
String o1 = (String) o;
|
||||
<caret>
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
class C {
|
||||
void f(Object o, Object f) {
|
||||
if (o instanceof String) {//todo comment
|
||||
|
||||
String o1 = (String) o;
|
||||
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Insert '(String)o' declaration" "true"
|
||||
class X {
|
||||
void foo(Object o) {
|
||||
if (o insta<caret>nceof String) {
|
||||
String substring = o.();
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Insert '(String)o' declaration" "true"
|
||||
class X {
|
||||
void foo(Object o) {
|
||||
if (o insta<caret>nceof String) {
|
||||
String a;
|
||||
String b;
|
||||
|
||||
|
||||
String c;
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Insert new" "false"
|
||||
class a {
|
||||
void f() {
|
||||
if (Runtime<caret>Exception() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -6,6 +6,6 @@ public class Main {
|
||||
String myString;
|
||||
|
||||
public void testOptional(Optional<String> str) {
|
||||
str.ifPresent(s -> myString = s);
|
||||
str.ifPresent(s -> myString = s.isEmpty() ? null : s);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Main {
|
||||
|
||||
public void testOptional(Optional<String> str) {
|
||||
if (str.isPrese<caret>nt()) {
|
||||
myString = str.get();
|
||||
myString = str.get().isEmpty() ? null : str.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with '(b ? null : "foo") != null ?:'" "true"
|
||||
class A {
|
||||
void bar(String s) {}
|
||||
|
||||
void foo(boolean b){
|
||||
bar((b ? null : "foo") != null ? b ? null : "foo" : null);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with '(b ? null : "foo") != null ?:'" "true"
|
||||
class A {
|
||||
void bar(String s) {}
|
||||
|
||||
void foo(boolean b){
|
||||
bar(b ? null<caret> : "foo");
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Surround with 'if ((b ? null : "foo") != null)'" "true"
|
||||
class A {
|
||||
void bar(String s) {}
|
||||
|
||||
void foo(boolean b){
|
||||
if ((b ? null : "foo") != null) {
|
||||
bar(b ? null : "foo");
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Surround with 'if ((Math.random() > 0.5 ? null : "foo") != null)'" "false"
|
||||
class A {
|
||||
void bar(String s) {}
|
||||
|
||||
void foo(boolean b){
|
||||
bar(Math.random() > 0.5 ? null<caret> : "foo");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Surround with 'if ((b ? null : "foo") != null)'" "true"
|
||||
class A {
|
||||
void bar(String s) {}
|
||||
|
||||
void foo(boolean b){
|
||||
bar(b ? null<caret> : "foo");
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Objects.requireNonNull(arr)'" "true"
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
void test() {
|
||||
int[] arr = Math.random() > 0.5 ? null : new int[10];
|
||||
System.out.println(Objects.requireNonNull(arr)[1]);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'Objects.requireNonNull(getObject())'" "true"
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
int a;
|
||||
|
||||
static MyClass getObject() {
|
||||
return Math.random() > 0.5 ? new MyClass() : null;
|
||||
}
|
||||
void test() {
|
||||
Objects.requireNonNull(getObject()).a = 5;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with 'Objects.requireNonNull(arr)'" "true"
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
void foo(String[] arr) {}
|
||||
|
||||
void test() {
|
||||
String[] arr = Math.random() > 0.5 ? null : new String[10];
|
||||
foo(Objects.requireNonNull(arr));
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with 'Objects.requireNonNull(Math.random() > 0.5 ? null : "bar")'" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
void foo(String str) {}
|
||||
|
||||
void test() {
|
||||
foo(Objects.requireNonNull(Math.random() > 0.5 ? null : "bar"));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with 'Objects.requireNonNull(s1)'" "true"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
void test(List<String> list) {
|
||||
list.stream().map(s -> s.isEmpty() ? null : s)
|
||||
.map(s1 -> Objects.requireNonNull(s1).trim())
|
||||
.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'Objects.requireNonNull(arr)'" "true"
|
||||
|
||||
class MyClass {
|
||||
void test() {
|
||||
int[] arr = Math.random() > 0.5 ? null : new int[10];
|
||||
System.out.println(arr<caret>[1]);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with 'Objects.requireNonNull(getObject())'" "true"
|
||||
|
||||
class MyClass {
|
||||
int a;
|
||||
|
||||
static MyClass getObject() {
|
||||
return Math.random() > 0.5 ? new MyClass() : null;
|
||||
}
|
||||
void test() {
|
||||
getObject<caret>().a = 5;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Objects.requireNonNull(arr)'" "true"
|
||||
|
||||
class MyClass {
|
||||
void foo(String[] arr) {}
|
||||
|
||||
void test() {
|
||||
String[] arr = Math.random() > 0.5 ? null : new String[10];
|
||||
foo(ar<caret>r);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with 'Objects.requireNonNull(Math.random() > 0.5 ? null : "bar")'" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
void foo(String str) {}
|
||||
|
||||
void test() {
|
||||
foo(Math.random() > 0.5 ? null :<caret> "bar");
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Objects.requireNonNull(s1)'" "true"
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
void test(List<String> list) {
|
||||
list.stream().map(s -> s.isEmpty() ? null : s)
|
||||
.map(s1 -> s1.t<caret>rim())
|
||||
.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user