EditorConfig documentation test

GitOrigin-RevId: fd52ace3d7a32ecd02c2c5ab90e077967604c15e
This commit is contained in:
Rustam Vishnyakov
2019-06-16 04:03:21 +03:00
committed by intellij-monorepo-bot
parent e6e3eaa09d
commit 123242c4b2
11726 changed files with 314322 additions and 158040 deletions
@@ -0,0 +1,6 @@
package c;
import a.*;
class Test extends Base {
Test() { }
}
@@ -21,6 +21,6 @@ class UnsupportedFeatures {
java.lang.annotation.ElementType t = null;
switch (<error descr="Incompatible types. Found: 'java.lang.annotation.ElementType', required: 'byte, char, short or int'">t</error>) { }
String raw = <error descr="Raw string literals are not supported at language level '1.4'">`hi there`</error>;
String raw = <error descr="Text block literals are not supported at language level '1.4'">"""hi there"""</error>;
}
}
@@ -0,0 +1,11 @@
interface Predicate<<warning descr="Type parameter 'T' is never used">T</warning>> {}
class Foo {
static <C extends I> void process(Predicate<C> <warning descr="Parameter 'predicate' is never used">predicate</warning>, C <warning descr="Parameter 'context' is never used">context</warning>) {}
}
interface I {}
class Bar implements I {
Predicate p;
{
Foo.process(p, new Bar());
}
}
@@ -0,0 +1,13 @@
class ErrorTest {
public static <E1 extends Throwable> void rethrow(Thrower<? extends E1> thrower) {
try {
thrower.doThrow();
}
catch (Throwable e) {
<error descr="Unhandled exception: E1">throw e;</error>
}
}
interface Thrower<E extends Throwable> {
void doThrow() throws E;
}
}
@@ -0,0 +1,3 @@
class Foo<T> {
@<error descr="Annotation type expected">T</error>(value =2) void foo() {}
}
@@ -0,0 +1,11 @@
class MyTest<T> {
static void m(Ref<? super String> commentRef) {
commentRef = coalesce(commentRef, commentRef);
}
static <T> T coalesce(T t1, T t2) {
return t1;
}
static class Ref<T> { }
}
@@ -0,0 +1,15 @@
interface Either {
public static final class Left<L> {
private final L value;
private Left(L value) {
this.value = value;
}
}
}
class Main {
{
new <error descr="'Left(L)' has private access in 'Either.Left'">Either.Left<></error>("");
}
}
@@ -0,0 +1,21 @@
import java.util.function.*;
class A {
{
B<Double> local;
method(local = new B<>(new C<>((supplier) -> supplier.get())));
}
void method(B<?> value) {
}
}
class B<T> {
B(C<T> c) { }
}
class C<T> {
C(Function<Supplier<T>, T> f) { }
}
@@ -0,0 +1,64 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
class MyTest {
public static <T, E, A, R> CompletableFuture<R> mapCollect(Iterator<T> iterator, Function<T, CompletableFuture<E>> body, Collector<E, A, R> collector) {
throw new RuntimeException();
}
public static void main(String[] args) throws Exception {
Collection<Pair<String, Integer>> test = new ArrayList<>();
final CompletableFuture<Map<Object, Object>> future = mapCollect(
test.iterator(),
e -> CompletableFuture.completedFuture(new Pair(e.getKey(), e.getValue())),
Collectors.toMap(
e -> e.getKey(),
e -> e.getValue()
)
);
future.get();
}
public static void main2(String[] args) throws Exception {
Collection<Pair<String, Integer>> test = new ArrayList<>();
final CompletableFuture<Map<Object, Object>> future = mapCollect(
test.iterator(),
e -> CompletableFuture.completedFuture(Pair.of(e.getKey(), e.getValue())),
Collectors.toMap(
e -> e.getKey(),
e -> e.getValue()
)
);
future.get();
}
public static class Pair<K,V> {
private final K key;
private final V value;
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
public K getKey() {
return key;
}
public V getValue() {
return value;
}
public static <A, B> Pair<A, B> of(A a, B b) {
return new Pair<A,B>(a, b);
}
}
}
@@ -0,0 +1,14 @@
import java.util.List;
import java.util.Set;
abstract class Overloadsss {
abstract <T> List<T> foo(List<T> l);
abstract <T> Set<T> foo(Set<T> s);
abstract <K> List<K> bar1(List<K> l);
abstract <K> Set<K> bar1(Set<K> s);
{
List<String> l1 = foo(<caret>bar1(null));
}
}
@@ -0,0 +1,7 @@
class C {
void m(Foo f) {}
{
m(() -> {});
}
}
@@ -0,0 +1,12 @@
import java.util.function.Predicate;
class Foo<T> {
public Foo(Predicate<T> p) {
}
void m(Predicate<String> p){
new Foo<>(p == null ? null : acc -> p.test<error descr="'test(java.lang.String)' in 'java.util.function.Predicate' cannot be applied to '(java.lang.Object)'">(acc)</error>);
new Foo<>(acc -> p.test<error descr="'test(java.lang.String)' in 'java.util.function.Predicate' cannot be applied to '(java.lang.Object)'">(acc)</error>);
}
}
@@ -10,7 +10,7 @@ class MyTest {
public <T> void from(Collection<T> elements) { }
public void foo(final Stream<String> artifactStream) {
from(artifactStream.collect(Collectors.toCollection(<error descr="Bad return type in method reference: cannot convert java.util.TreeSet<java.lang.String> to C">TreeSet<String>::new</error>)));
from<error descr="Ambiguous method call: both 'MyTest.from(Page<String>)' and 'MyTest.from(Collection<String>)' match">(artifactStream.collect(Collectors.toCollection(TreeSet<String>::new)))</error>;
}
interface Page<T> extends Iterable<T> {}
@@ -0,0 +1,18 @@
interface I {
void f();
}
class B implements I {
@Override
public void f() {
}
}
class MyTest {
void m(I i) {}
void n(int ik) {
m(ik > 0 ? () -> {} : new B());
}
}
@@ -1,6 +1,6 @@
class IntStream {
private void foo(IntStream s) {
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> 1 << i);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> <error descr="Operator '<<' cannot be applied to 'int', '<lambda parameter>'">1 << i</error>);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> 1);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> i);
}
@@ -26,7 +26,7 @@ class AlienTest {
IInt i1 = MyTest::<error descr="Cannot resolve method 'abracadabra'">abracadabra</error>;
IInt i2 = MyTest::<error descr="Incompatible types: int is not convertible to String">foo</error>;
IInt i3 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IIntInt'">IIntInt i4 = MyTest::bar;</error>
IIntInt i4 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
IInt i5 = <error descr="Non-static method cannot be referenced from a static context">MyTest::baz</error>;
IInt i6 = <error descr="'foo(int)' is not public in 'MyTest.Foo'. Cannot be accessed from outside package">MyTest.foo::foo</error>;
IInt i7 = MyTest.<error descr="'MyTest.Foo' has private access in 'MyTest'">Foo</error>::foo;
@@ -22,7 +22,7 @@ class MyTest {
{
Bar1 b1 = MyTest :: foo;
bar<error descr="Ambiguous method call: both 'MyTest.bar(Bar1)' and 'MyTest.bar(Bar2)' match">(MyTest :: foo)</error>;
bar(MyTest :: <error descr="Cannot resolve method 'foo'">foo</error>);
}
}
@@ -13,7 +13,7 @@ class Foo<R> {
public void foo() {
reduce(Moo::new);
reduce(<error descr="Bad return type in method reference: cannot convert Foo<R>.AMoo to S">AMoo::new</error>);
reduce<error descr="'reduce(Foo.Factory<S>)' in 'Foo' cannot be applied to '(<method reference>)'">(AMoo::new)</error>;
reduce(AAMoo::new);
reduce(AAAMoo::new);
}
@@ -71,7 +71,7 @@ class StaticInner1 {
static void call3(I2 s) {}
static {
call3<error descr="Ambiguous method call: both 'StaticInner1.call3(I1)' and 'StaticInner1.call3(I2)' match">(StaticInner1.Inner :: new)</error>;
call3(StaticInner1.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>);
}
}
@@ -6,7 +6,7 @@ interface Func<TIn, TOut>{
class Main {
public static void main(final String[] args) {
<error descr="Incompatible types. Found: '<method reference>', required: 'Func<java.lang.Integer,java.lang.String>'">Func<Integer, String> func = Integer::toString;</error>
Func<Integer, String> func = Integer::<error descr="Cannot resolve method 'toString'">toString</error>;
System.out.println(func.run(6));
}
}
@@ -2,7 +2,7 @@ import java.util.*;
class LambdaTest {
public void testR() {
<error descr="Incompatible types. Found: 'java.lang.String', required: '<method reference>'">new ArrayList<String>() :: size = ""</error>;
new ArrayList<String>() :: <error descr="Cannot resolve method 'size'">size</error> = "";
}
}
@@ -57,10 +57,10 @@ class MyTest1 {
I2 s2 = MyTest1 :: m2;
call2(MyTest1::m2);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I2'">I2 s3 = MyTest1 :: m3;</error>
call2<error descr="'call2(MyTest1.I2)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m3)</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I2'">I2 s4 = MyTest1 ::m4;</error>
call2<error descr="'call2(MyTest1.I2)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m4)</error>;
I2 s3 = MyTest1 :: <error descr="Cannot resolve method 'm3'">m3</error>;
call2(MyTest1::<error descr="Cannot resolve method 'm3'">m3</error>);
I2 s4 = MyTest1 ::<error descr="Cannot resolve method 'm4'">m4</error>;
call2(MyTest1::<error descr="Cannot resolve method 'm4'">m4</error>);
}
}
@@ -106,19 +106,19 @@ class MyTest2 {
I2 s2 = MyTest2 :: m2;
call2(MyTest2::m2);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I2'">I2 s3 = MyTest2 :: m3;</error>
call2<error descr="'call2(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m3)</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I2'">I2 s4 = MyTest2 ::m4;</error>
call2<error descr="'call2(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m4)</error>;
I2 s3 = MyTest2 :: <error descr="Cannot resolve method 'm3'">m3</error>;
call2(MyTest2::<error descr="Cannot resolve method 'm3'">m3</error>);
I2 s4 = MyTest2 ::<error descr="Cannot resolve method 'm4'">m4</error>;
call2(MyTest2::<error descr="Cannot resolve method 'm4'">m4</error>);
}
static void call3(I1 s) {}
static void call3(I2 s) {}
static {
call3(MyTest2::m1);
call3<error descr="Ambiguous method call: both 'MyTest2.call3(I1)' and 'MyTest2.call3(I2)' match">(MyTest2::m2)</error>;
call3(MyTest2::<error descr="Cannot resolve method 'm2'">m2</error>);
call3(MyTest2::m3);
call3<error descr="'call3(MyTest2.I2)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m4)</error>;
call3(MyTest2::<error descr="Cannot resolve method 'm4'">m4</error>);
}
}
@@ -14,7 +14,7 @@ class Test {
class Test2 {
static void m(Integer <warning descr="Parameter 'i' is never used">i</warning>) { }
static void m(Integer i) { }
interface I1 {
void m(int x);
@@ -0,0 +1,20 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
class MyTest {
{
foo(() -> build(id(x -> x)));
}
static <I> I id(I i) {
return i;
}
static <K> void foo(Runnable e) {}
static <TT> List<TT> build(Function<String, TT> transformers) {
return null;
}
}
@@ -77,7 +77,7 @@ abstract class AbstractCollection<E> implements Collection<E> {
public boolean add(E e) {
return true;
}
public boolean addAll(Collection<? extends E> <warning descr="Parameter 'c' is never used">c</warning>) {
public boolean addAll(Collection<? extends E> c) {
boolean modified = false;
return modified;
}
@@ -7,7 +7,7 @@ interface B<BT> {
class Test {
public static void test() {
method1(Test::<error descr="Incompatible types: A<capture of ? super M> is not convertible to A<? super String>">method2</error>);
method1<error descr="'method1(B<A<? super M>>)' in 'Test' cannot be applied to '(<method reference>)'">(Test::method2)</error>;
}
static <M> void method1(B<A<? super M>> arg) { }
@@ -0,0 +1,23 @@
class Logger {}
class Test {
public static void main(String[] args) {
User user = new User();
Logger logger = null;
foo<error descr="'foo(T, java.util.logging.Logger, java.util.function.Function<T,java.lang.String>)' in 'Test' cannot be applied to '(User, Logger, <method reference>)'">(user, logger, User::getId)</error>;
}
private static <T> void foo(T val, java.util.logging.Logger logger, java.util.function.Function<T, String> idFunction) { }
}
class User {
private String Id;
public String getId() {
return Id;
}
public void setId(String id) {
this.Id = id;
}
}
@@ -6,11 +6,11 @@ class Test {
Test m(List<Integer> l1, List<Integer> l2);
}
static Test meth(List<Integer>... <warning descr="Parameter 'lli' is never used">lli</warning>) {
static Test meth(List<Integer>... lli) {
return null;
}
Test(List<Integer>... <warning descr="Parameter 'lli' is never used">lli</warning>) {}
Test(List<Integer>... lli) {}
{
I <warning descr="Variable 'i1' is never used">i1</warning> = <warning descr="Unchecked generics array creation for varargs parameter">Test::meth</warning>;
@@ -31,8 +31,8 @@ class Test {
String i1 = instanceCall(this::m0);
String i2 = instanceCall(this::m1);
String i3 = instanceCall(this::m2);
String i4 = instanceCall<error descr="Ambiguous method call: both 'Test.instanceCall(I0)' and 'Test.instanceCall(I1<Object>)' match">(this::m01)</error>;
String i5 = instanceCall<error descr="Ambiguous method call: both 'Test.instanceCall(I0)' and 'Test.instanceCall(I1<Object>)' match">(this::m012)</error>;
String i4 = instanceCall(this::<error descr="Cannot resolve method 'm01'">m01</error>);
String i5 = instanceCall(this::<error descr="Cannot resolve method 'm012'">m012</error>);
}
void n0() { }
@@ -53,7 +53,7 @@ class Test {
Test s1 = staticCall(Test::n0);
Test s2 = staticCall(Test::n1);
Test s3 = staticCall<error descr="Cannot resolve method 'staticCall(<method reference>)'">(Test::n2)</error>;
Test s4 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Object>)' and 'Test.staticCall(I2<Object, String>)' match">(Test::n01)</error>;
Test s5 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Object>)' and 'Test.staticCall(I2<Object, String>)' match">(Test::n012)</error>;
Test s4 = staticCall(Test::<error descr="Cannot resolve method 'n01'">n01</error>);
Test s5 = staticCall(Test::<error descr="Cannot resolve method 'n012'">n012</error>);
}
}
@@ -34,7 +34,7 @@ class Test {
{
Set<String> m = replyWith(this::query);
System.out.println(m);
Set<String> m1 = replyWith<error descr="Ambiguous method call: both 'Test.replyWith(Function<Object, List<Object>>)' and 'Test.replyWith(Callable<List<Object>>)' match">(this::query1)</error>;
Set<String> m1 = replyWith(this::<error descr="Cannot resolve method 'query1'">query1</error>);
System.out.println(m1);
}
}
@@ -10,6 +10,6 @@ class Test {
static void m(Test t, Object s) {}
static void test() {
<error descr="Incompatible types. Found: '<method reference>', required: 'Test.I'">I i = Test::m;</error>
I i = Test::<error descr="Cannot resolve method 'm'">m</error>;
}
}
@@ -1,7 +1,7 @@
import java.util.stream.Stream;
class A {
private void test5(Integer <warning descr="Parameter 'i' is never used">i</warning>, String... <warning descr="Parameter 'strings' is never used">strings</warning>) {}
private void test5(Integer i, String... strings) {}
private void <warning descr="Private method 'test5(java.lang.Integer, java.lang.Integer, java.lang.String...)' is never used">test5</warning>(Integer i, Integer b, String... strings) {
System.out.println(i);
System.out.println(b);
@@ -0,0 +1,13 @@
class MyTest {
static class Foo<X> {
<T> void test(X x) { }
}
static class Bar extends Foo<Integer> {
void test(Double x) { }
void call() {
test<error descr="Ambiguous method call: both 'Bar.test(Double)' and 'Foo.test(Integer)' match">(null)</error>;
}
}
}
@@ -14,7 +14,7 @@ class Test {
}
void fooBar(IntStream1 instr){
Supplier<Stream<Integer>> si = () -> instr.<error descr="Ambiguous method call: both 'IntStream1.map(IntFunction<Integer>)' and 'IntStream1.map(IntUnaryOperator)' match">map</error> ((i) -> (( <error descr="Operator '%' cannot be applied to '<lambda parameter>', 'int'">i % 2</error>) == 0) ? i : -i).boxed();
Supplier<Stream<Integer>> si = () -> instr.<error descr="Ambiguous method call: both 'IntStream1.map(IntFunction<Integer>)' and 'IntStream1.map(IntUnaryOperator)' match">map</error> ((i) -> (( <error descr="Operator '%' cannot be applied to '<lambda parameter>', 'int'">i % 2</error>) == 0) ? i : <error descr="Operator '-' cannot be applied to '<lambda parameter>'">-i</error>).boxed();
System.out.println(si);
Supplier<Stream<Integer>> si1 = () -> instr.map <error descr="Ambiguous method call: both 'IntStream1.map(IntFunction<Integer>)' and 'IntStream1.map(IntUnaryOperator)' match">(null)</error>.boxed();
System.out.println(si1);
@@ -12,7 +12,7 @@ class MyTest<T> {
public static class Builder<E> {
public Builder<E> add(E <warning descr="Parameter 'element' is never used">element</warning>) {
public Builder<E> add(E element) {
return this;
}
@@ -8,6 +8,6 @@ class Main {
}
public static boolean checkForJdk(String <warning descr="Parameter 'homePath' is never used">homePath</warning>) {return false;}
public static boolean checkForJdk(File <warning descr="Parameter 'homePath' is never used">homePath</warning>) {return false;}
public static boolean checkForJdk(File homePath) {return false;}
}
@@ -0,0 +1,14 @@
interface A {
void enableInspections(B... providers);
void enableInspections(Runnable r, String... inspections);
}
interface B {
Class[] get();
}
class C {
void foo(A a) {
a.enableInspections(() -> new Class[]{});
}
}
@@ -0,0 +1,33 @@
import java.util.function.Function;
class Main {
void m(B b) {
Function<A<String>, String> f1 = A<String>::getName;
Function<A<String>, String> f10 = A::getName;
Function<B, String> f2 = B::getName;
Function<B, String> f3 = b::<error descr="Cannot resolve method 'getName'">getName</error>;
}
}
interface I {
String getName();
static String getName(final I i) {
return null;
}
}
class A<T> implements I {
@Override
public String getName() {
return null;
}
}
class B implements I {
@Override
public String getName() {
return null;
}
}
@@ -12,4 +12,17 @@ interface Test {
static void of(String... lists) { }
}
interface Entry<T> { }
interface ClassA<T> {
static <T> void f(Iterable<T> values) {
}
}
interface ClassB<T> extends ClassA<Entry<T>> {
static <T> void f(Iterable<? extends Entry<? extends T>> values) {}
static void m(Iterable<Entry<String>> x) {
f(x);
}
}
@@ -14,10 +14,10 @@ abstract class Test {
foo(x -> {
return x += 1;
});
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> x += 1);
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> <error descr="Incompatible types. Found: 'int', required: '<lambda parameter>'">x += 1</error>);
foo(x -> 1);
foo(x -> <error descr="Operator '!' cannot be applied to 'int'">!x</error>);
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> ++x);
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> <error descr="Operator '++' cannot be applied to '<lambda parameter>'">++x</error>);
foo(x -> o instanceof String ? 1 : 0);
}
}
@@ -0,0 +1,8 @@
// "Assert 'obj instanceof String'" "true"
class X {
void test(Object obj) {
if (obj instanceof Integer) System.out.println();
assert obj instanceof String;
String string = (String)obj;
}
}
@@ -0,0 +1,7 @@
// "Assert 'obj instanceof String'" "true"
class X {
void test(Object obj) {
if (obj instanceof Integer) System.out.println();
String string = (<caret>String)obj;
}
}
@@ -0,0 +1,4 @@
// "Collapse repeating annotations" "true"
@SuppressWarnings({"foo", "bar", "baz"})
class X{}
@@ -0,0 +1,10 @@
// "Collapse repeating annotations" "true"
@XYZ(data = {1, 2, 3, 4})
@XYZ(5)
class X{}
@interface XYZ {
int value() default 0;
int[] data();
}
@@ -0,0 +1,4 @@
// "Collapse repeating annotations" "true"
@SuppressWarnings({"foo", "bar", "baz"})
class X{}
@@ -0,0 +1,4 @@
// "Collapse repeating annotations" "true"
@SuppressWarnings({"foo", "bar"})
class X{}
@@ -0,0 +1,5 @@
// "Collapse repeating annotations" "true"
@SuppressWarnings({"foo", "bar"})
@<caret>SuppressWarnings("baz")
class X{}
@@ -0,0 +1,12 @@
// "Collapse repeating annotations" "true"
@X<caret>YZ(data = 1)
@XYZ(data = {2, 3})
@XYZ(data = {4})
@XYZ(5)
class X{}
@interface XYZ {
int value() default 0;
int[] data();
}
@@ -0,0 +1,6 @@
// "Collapse repeating annotations" "true"
@<caret>SuppressWarnings("foo")
@SuppressWarnings("bar")
@SuppressWarnings("baz")
class X{}
@@ -0,0 +1,5 @@
// "Collapse repeating annotations" "true"
@<caret>SuppressWarnings("foo")
@SuppressWarnings("bar")
class X{}
@@ -0,0 +1,11 @@
// "Create local variable 'inner'" "true"
class OuterGeneric<T> {
class Inner {
}
static OuterGeneric<Object>.Inner create() {
return null;
}
public static void main(String[] args) {
OuterGeneric.Inner inner = create();
}
}
@@ -0,0 +1,11 @@
// "Create local variable 'inner'" "true"
class OuterGeneric<T> {
class Inner {
}
static OuterGeneric<Object>.Inner create() {
return null;
}
public static void main(String[] args) {
i<caret>nner = create();
}
}
@@ -0,0 +1,6 @@
// "Create type parameter 'T'" "false"
class Test {
@<caret>T
void foo() {}
}
@@ -0,0 +1,9 @@
// "Replace explicit type with 'var'" "true"
class MyTest {
private void m() {
var r = new Runnable() {
@Override
public void run() {}
};
}
}
@@ -0,0 +1,9 @@
// "Replace explicit type with 'var'" "true"
class MyTest {
private void m() {
Ru<caret>nnable r = new Runnable() {
@Override
public void run() {}
};
}
}
@@ -0,0 +1,25 @@
// "Make 'b' return 'java.lang.Integer'" "true"
class MyClass {
interface BaseInterface {
Object b();
}
class BooleanImpl implements BaseInterface {
@Override
public Boolean b() {
return true;
}
}
class IntegerImpl implements BaseInterface {
@Override
public Integer b() {
return 1;
}
}
}
@@ -0,0 +1,25 @@
// "Make 'b' return 'java.lang.Integer'" "true"
class MyClass {
interface BaseInterface {
Object b();
}
class BooleanImpl implements BaseInterface {
@Override
public Boolean b() {
return true;
}
}
class IntegerImpl implements BaseInterface {
@Override
public String b() {
return <caret>1;
}
}
}
@@ -0,0 +1,7 @@
// "Add method body" "true"
interface Some {
public static void m() {
<caret>
}
}
@@ -0,0 +1,6 @@
// "Make 'm' not default" "true"
class Some {
public void <caret>m() {
}
}
@@ -0,0 +1,5 @@
// "Add method body" "true"
interface Some {
public static void <caret>m();
}
@@ -0,0 +1,6 @@
// "Delete method body" "false"
class Some {
public default void <caret>m() {
}
}
@@ -0,0 +1,6 @@
// "Make 'm' not default" "true"
class Some {
public default void <caret>m() {
}
}
@@ -0,0 +1,14 @@
// "Replace Optional.isPresent() condition with functional style expression" "false"
import java.util.Optional;
class Test {
Object get() {
Optional<String> obj = Stream.of("one", "two").filter(s -> Math.sqrt(s.length()) > 100).findFirst();
if (obj.<caret>isPresent()) {
return obj.get();
} else {
return 7;
}
}
}
@@ -0,0 +1,13 @@
// "Simplify boolean expression" "true"
class X {
void test(int a, int b) {
if (a + 1 + foo(a, b) > 5) {
}
}
private int foo(int a, int b) {
return a+b;
}
}
@@ -0,0 +1,13 @@
// "Simplify boolean expression" "true"
class X {
void test(int a, int b) {
if (<caret>true && (a + 1) + foo((a), b) > 5) {
}
}
private int foo(int a, int b) {
return a+b;
}
}
@@ -0,0 +1,16 @@
// "Sort content" "true"
enum Colors {
CLUBS,
DIAMOND,
HEARTS,
SPADES
public enum Direction {
UP, DOWN
}
//1
}
@@ -0,0 +1,15 @@
// "Sort content" "true"
enum Colors {
SPADES,
DIAMOND,
HEARTS,
CLU<caret>BS
public enum Direction {
UP,DOWN
}
//1
}
@@ -0,0 +1,17 @@
// "Replace Stream API chain with loop" "true"
import java.util.StringJoiner;
import java.util.stream.*;
public class Test {
private static final String ARRAY_ELEMENT_SEPARATOR = ", ", ARRAY_START = "[", ARRAY_END = "]";
public static String nullSafeToString(byte[] array) {
StringJoiner joiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
for (int i = 0; i < array.length; i++) {
String s = String.valueOf(array[i]);
joiner.add(s);
}
return joiner.toString();
}
}
@@ -43,4 +43,14 @@ public class Main {
interface Visitor { }
}
class X implements Iterable<String> {
class Y {
void test() {
for (String s : X.this) {
System.out.println(s);
}
}
}
}
}
@@ -31,4 +31,15 @@ public class Main {
}
}
class X implements Map<String, String> {
class Y {
void test() {
for (Entry<String, String> entry : X.this.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
System.out.println(k + "-" + v);
}
}
}
}
}
@@ -0,0 +1,12 @@
// "Replace Stream API chain with loop" "true"
import java.util.stream.*;
public class Test {
private static final String ARRAY_ELEMENT_SEPARATOR = ", ", ARRAY_START = "[", ARRAY_END = "]";
public static String nullSafeToString(byte[] array) {
return IntStream.range(0, array.length).mapToObj(i -> String.valueOf(array[i]))
.collec<caret>t(Collectors.joining(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END));
}
}
@@ -33,4 +33,12 @@ public class Main {
interface Visitor { }
}
class X implements Iterable<String> {
class Y {
void test() {
forEach(System.out::println);
}
}
}
}
@@ -21,4 +21,11 @@ public class Main {
map.forEach(otherMap::putIfAbsent);
}
class X implements Map<String, String> {
class Y {
void test() {
forEach((k, v) -> System.out.println(k + "-" + v));
}
}
}
}
@@ -0,0 +1,9 @@
// "Surround with 'if (obj instanceof String)'" "true"
class X {
void test(Object obj) {
if (obj instanceof Integer) System.out.println();
if (obj instanceof String) {
String string = (String)obj;
}
}
}
@@ -0,0 +1,7 @@
// "Surround with 'if (obj instanceof String)'" "true"
class X {
void test(Object obj) {
if (obj instanceof Integer) System.out.println();
String string = (<caret>String)obj;
}
}