diff options
Diffstat (limited to 'java/java-tests/testData')
35 files changed, 245 insertions, 33 deletions
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java new file mode 100644 index 000000000000..8b6864c5e474 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java @@ -0,0 +1,3 @@ +class Test { + Runnable r = () -> <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java new file mode 100644 index 000000000000..8bda0afcc1d6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java @@ -0,0 +1,3 @@ +class Test { + Runnable r = <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java new file mode 100644 index 000000000000..f3bc8d4b8a6c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java @@ -0,0 +1,15 @@ +class ThreadExample { + interface Function<T, R> { + + R apply(T t); + } + { + A a = new A(); + <error descr="Incompatible types. Found: '<method reference>', required: 'ThreadExample.Function<? super ThreadExample.A,? extends java.lang.String>'">Function<? super A,? extends String> foo = a::foo;</error> + } + + static class A { + public String foo() { return "a"; } + } +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java new file mode 100644 index 000000000000..97dcfd58b281 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java @@ -0,0 +1,8 @@ +// "Make 'a' not abstract" "true" +import java.io.*; + +abstract class A { + void a<caret>() { + } +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java new file mode 100644 index 000000000000..6be31221292f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java @@ -0,0 +1,8 @@ +// "Make 'a' not abstract" "true" +import java.io.*; + +abstract class A { + abstract void a<caret>() { + } +} + diff --git a/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java new file mode 100644 index 000000000000..29be0de779ed --- /dev/null +++ b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java @@ -0,0 +1,7 @@ +class Test { + private int _foo; + + Test(int foo) { + _foo = foo; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java new file mode 100644 index 000000000000..8acd4dc129fd --- /dev/null +++ b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java @@ -0,0 +1,4 @@ +class Test { + private int _foo; + <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/guarded/itself.java b/java/java-tests/testData/inspection/guarded/itself.java new file mode 100644 index 000000000000..35b784585086 --- /dev/null +++ b/java/java-tests/testData/inspection/guarded/itself.java @@ -0,0 +1,19 @@ +import net.jcip.annotations.GuardedBy; + +import java.lang.String; + +class A { + + @GuardedBy("itself") + private String _foo; + + public String getFoo() { + synchronized (_foo) { + return _foo; + } + } + + public void setFoo(String foo) { + <warning descr="Access to field '_foo' outside of declared guards">_foo</warning> = foo; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml new file mode 100644 index 000000000000..1da1935ad438 --- /dev/null +++ b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems> + <problem> + <file>Junk.java</file> + <line>4</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class> + <description>Variable <code>i</code> can have <code>final</code> modifier</description> + </problem> + <problem> + <file>Junk.java</file> + <line>3</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class> + <description>Variable <code>r</code> can have <code>final</code> modifier</description> + </problem> +</problems> + diff --git a/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java new file mode 100644 index 000000000000..f89a1e2f4786 --- /dev/null +++ b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java @@ -0,0 +1,10 @@ +public final class Junk { + public void sillyMethod() { + Runnable r = () -> { + int i = 0; + System.out.println(i); + }; + } +} + + diff --git a/java/java-tests/testData/psi/cls/mirror/Annotations.txt b/java/java-tests/testData/psi/cls/mirror/Annotations.txt index 9bbe384da735..58f2792d88f3 100644 --- a/java/java-tests/testData/psi/cls/mirror/Annotations.txt +++ b/java/java-tests/testData/psi/cls/mirror/Annotations.txt @@ -25,6 +25,9 @@ abstract class Annotations { @pkg.Annotations.A4(ids = {42, 84}) abstract void m4b(); + @pkg.Annotations.A5(b = true, value = java.lang.Integer.class) + abstract void m5(); + static @interface IndeterminateAnno { float f1() default -1.0f / 0.0; @@ -39,6 +42,12 @@ abstract class Annotations { double d3() default 1.0 / 0.0; } + static @interface A5 { + boolean b() default false; + + java.lang.Class<? extends java.lang.Number> value() default java.lang.Integer.class; + } + static @interface A4 { int[] ids() default {}; } diff --git a/java/java-tests/testData/psi/cls/mirror/Booleans.txt b/java/java-tests/testData/psi/cls/mirror/Booleans.txt deleted file mode 100644 index 8def7d921ba3..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/Booleans.txt +++ /dev/null @@ -1,18 +0,0 @@ - - // IntelliJ API Decompiler stub source generated from a class file - // Implementation of methods is not available - -package pkg; - -class Booleans { - public static final boolean TRUE = true; - public static final boolean FALSE = false; - - Booleans() { /* compiled code */ } - - @pkg.BooleanAnno(true) - public static boolean TRUE() { /* compiled code */ } - - @pkg.BooleanAnno(false) - public static boolean FALSE() { /* compiled code */ } -}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/Primitives.txt b/java/java-tests/testData/psi/cls/mirror/Primitives.txt new file mode 100644 index 000000000000..4eb6750d0451 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/Primitives.txt @@ -0,0 +1,30 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +class Primitives { + public static final boolean TRUE = true; + public static final boolean FALSE = false; + public static final byte BYTE = 1; + public static final char CHAR = '\''; + public static final short SHORT = 42; + public static final int INT = 42; + public static final long LONG = 42L; + + Primitives() { /* compiled code */ } + + @pkg.BooleanAnno(true) + public static boolean TRUE() { /* compiled code */ } + + @pkg.BooleanAnno(false) + public static boolean FALSE() { /* compiled code */ } + + @pkg.ByteAnno(1) + @pkg.CharAnno('\\') + @pkg.ShortAnno(42) + @pkg.IntAnno(42) + @pkg.LongAnno(42L) + public static void m() { /* compiled code */ } +}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class Binary files differindex 61209608ab7e..00c4747c6521 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class Binary files differindex 8d94afe68543..96bda0c34281 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class Binary files differindex 630cfd964d18..c23cb7cbb8b3 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class Binary files differindex 040a84c05353..e00c95b04881 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class Binary files differnew file mode 100644 index 000000000000..b85d9d0abc49 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class Binary files differindex d77b499c1f59..101bbd26c396 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class Binary files differindex 03f1f52f42b8..a5293f04639b 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class Binary files differindex 64ba86fc5932..118a4c4df8ca 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class b/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class Binary files differdeleted file mode 100644 index 1a71ca06f3c4..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class +++ /dev/null diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class Binary files differnew file mode 100644 index 000000000000..6250428694f7 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class Binary files differnew file mode 100644 index 000000000000..17e8b6729b29 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class Binary files differnew file mode 100644 index 000000000000..e3e7eed220b0 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class Binary files differnew file mode 100644 index 000000000000..63147056a558 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class b/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class Binary files differnew file mode 100644 index 000000000000..1e2d9f0a17ff --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class Binary files differnew file mode 100644 index 000000000000..e5583b1cca2e --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java index 5aeda680f6dd..dafd4dce2770 100644 --- a/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java @@ -16,6 +16,11 @@ abstract class Annotations { int[] ids() default { }; } + @interface A5 { + boolean b() default false; + Class<? extends Number> value() default Integer.class; + } + @A1 abstract void m1(); @A2() abstract void m2a(); @@ -26,6 +31,8 @@ abstract class Annotations { @A4 abstract void m4a(); @A4(ids = {42, 84}) abstract void m4b(); + @A5(b = true, value = Integer.class) abstract void m5(); + @interface IndeterminateAnno { float f1() default Float.NEGATIVE_INFINITY; float f2() default Float.NaN; diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java deleted file mode 100644 index 495e1ace68a3..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java +++ /dev/null @@ -1,13 +0,0 @@ -package pkg; - -class Booleans { - public static final boolean TRUE = true; - public static final boolean FALSE = false; - - @BooleanAnno(true) public static boolean TRUE() { return TRUE; } - @BooleanAnno(false) public static boolean FALSE() { return FALSE; } -} - -@interface BooleanAnno { - boolean value(); -}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java new file mode 100644 index 000000000000..4ffcf4ae3634 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java @@ -0,0 +1,42 @@ +package pkg; + +class Primitives { + public static final boolean TRUE = true; + public static final boolean FALSE = false; + + @BooleanAnno(true) public static boolean TRUE() { return TRUE; } + @BooleanAnno(false) public static boolean FALSE() { return FALSE; } + + public static final byte BYTE = 1; + public static final char CHAR = '\''; + public static final short SHORT = 42; + public static final int INT = 42; + public static final long LONG = 42L; + + @ByteAnno(1) @CharAnno('\\') @ShortAnno(42) @IntAnno(42) @LongAnno(42L) + public static void m() { } +} + +@interface BooleanAnno { + boolean value(); +} + +@interface ByteAnno { + byte value(); +} + +@interface CharAnno { + char value(); +} + +@interface ShortAnno { + short value(); +} + +@interface IntAnno { + int value(); +} + +@interface LongAnno { + long value(); +} diff --git a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt index 277fe1497cf9..5f492a770b1b 100644 --- a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt +++ b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt @@ -2,8 +2,8 @@ PsiJavaFileStub [org.jetbrains.annotations] PsiClassStub[interface annotation name=Nullable fqn=org.jetbrains.annotations.Nullable] PsiModifierListStub[mask=1025] PsiAnnotationStub[@java.lang.annotation.Documented] - PsiAnnotationStub[@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)] - PsiAnnotationStub[@java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})] + PsiAnnotationStub[@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.CLASS)] + PsiAnnotationStub[@java.lang.annotation.Target(value={java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})] PsiTypeParameterListStub PsiRefListStub[EXTENDS_LIST:] PsiRefListStub[IMPLEMENTS_LIST:] diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java new file mode 100644 index 000000000000..fcb14a849657 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class Test { + public void foo(int ii) { + Runnable r = () -> { + <selection>System.out.println(ii);</selection> + }; + } +} diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java new file mode 100644 index 000000000000..6debfdee24db --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class Test { + public void foo(int ii) { + Runnable r = () -> { + newMethod(ii); + }; + } + + private void newMethod(int ii) { + System.out.println(ii); + } +} diff --git a/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java b/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java new file mode 100644 index 000000000000..b7477fc316ef --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java @@ -0,0 +1,14 @@ +abstract class A{ + static boolean isB<caret>ool() { + return false; + } + + + interface I { + boolean b(); + } + + { + I i = A::isBool; + } +} |