diff options
Diffstat (limited to 'java/java-tests')
186 files changed, 2157 insertions, 418 deletions
diff --git a/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement.java b/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement.java new file mode 100644 index 000000000000..e92cc86cc8eb --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement.java @@ -0,0 +1,8 @@ +/** + * @see XHell<caret> + */ +package foo.bar; + +class XHello { + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement_after.java b/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement_after.java new file mode 100644 index 000000000000..8cbb31c1688f --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/javadoc/QualifyClassReferenceInPackageStatement_after.java @@ -0,0 +1,8 @@ +/** + * @see foo.bar.XHello<caret> + */ +package foo.bar; + +class XHello { + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/keywords/arrayClass.java b/java/java-tests/testData/codeInsight/completion/keywords/arrayClass.java new file mode 100644 index 000000000000..80690075bcea --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/keywords/arrayClass.java @@ -0,0 +1,5 @@ +public class Util { + int goo() { + String[].<caret>x + } +} diff --git a/java/java-tests/testData/codeInsight/completion/keywords/finalAfterCase.java b/java/java-tests/testData/codeInsight/completion/keywords/finalAfterCase.java new file mode 100644 index 000000000000..0d201763da54 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/keywords/finalAfterCase.java @@ -0,0 +1,8 @@ +public class StructuredConfigKey { + { + switch (x) { + case 2: + <caret> + } + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java new file mode 100644 index 000000000000..85d7845803d8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java @@ -0,0 +1,7 @@ +interface Foo<T> { + void run(T t, int myInt); +} + +public class A implements Foo<String> { + p<caret> +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java new file mode 100644 index 000000000000..a13b20e89807 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java @@ -0,0 +1,10 @@ +interface Foo<T> { + void run(T t, int myInt); +} + +public class A implements Foo<String> { + @Override + public void run(String s, int myInt) { + <selection>//To change body of implemented methods use File | Settings | File Templates.</selection> + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/TypeParameterItemPresentation.java b/java/java-tests/testData/codeInsight/completion/normal/TypeParameterItemPresentation.java new file mode 100644 index 000000000000..c56297de58d7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/TypeParameterItemPresentation.java @@ -0,0 +1,5 @@ +public class Foo<Param> { + <Param2> int goo() { + Pa<caret> + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/AlphaSortingStartMatchesFirst.java b/java/java-tests/testData/codeInsight/completion/normalSorting/AlphaSortingStartMatchesFirst.java new file mode 100644 index 000000000000..87423fdc5cfb --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/AlphaSortingStartMatchesFirst.java @@ -0,0 +1,12 @@ +class Goo { + { + int xxfoo; + int fooxx; + int xxgoo; + int gooxx; + int xxbar; + int barxx; + xx<caret> + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/LocalVarsOverStats.java b/java/java-tests/testData/codeInsight/completion/normalSorting/LocalVarsOverStats.java new file mode 100644 index 000000000000..ec010fe2ac72 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/LocalVarsOverStats.java @@ -0,0 +1,8 @@ +public class Foo { + + void foo(PsiElement psiElement) { + psiEl<caret> + } +} + +class PsiElement {}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java index bec60ac2de6b..49ce3eb54d4b 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java @@ -1,5 +1,5 @@ class Super { void foo(String[] params, int... indices) { - foo(new String[]{<caret>}, 0); + foo(new String[<caret>], 0); } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods-out.java b/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods-out.java new file mode 100644 index 000000000000..f6b90f287be6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods-out.java @@ -0,0 +1,18 @@ +interface Predicate<T> { + public boolean test(T t); + public default Predicate<T> and(Predicate<? super T> p) { + return null; + } +} + + +public class Test1 { + { + Predicate p = new Predicate() { + @Override + public boolean test(Object o) { + <selection>return false; //To change body of implemented methods use File | Settings | File Templates.</selection> + } + }; + } +} diff --git a/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods.java b/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods.java new file mode 100644 index 000000000000..ea35c5cb45c5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/IgnoreDefaultMethods.java @@ -0,0 +1,13 @@ +interface Predicate<T> { + public boolean test(T t); + public default Predicate<T> and(Predicate<? super T> p) { + return null; + } +} + + +public class Test1 { + { + Predicate p = new Predic<caret> + } +} diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java index fa6f209bf19b..e98107784592 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java @@ -1,5 +1,5 @@ class Test { public void foo() { - Runnable r = () -> {<caret>}; + Runnable r = () -> {n<caret>}; } } diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java index 7b403c035879..a9a9766a2724 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java @@ -1,5 +1,5 @@ class Test { public void foo() { - new Thread(() -> <caret>); + new Thread(() -> n<caret>); } } diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java index e41c2a19a0d3..b0dee48e23d7 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java @@ -1,5 +1,5 @@ class Test { public void foo() { - Runnable r = () -> <caret> + Runnable r = () -> n<caret> } } diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ThrowExceptionConstructor-out.java b/java/java-tests/testData/codeInsight/completion/smartType/ThrowExceptionConstructor-out.java index 7d740e51351c..d105afd9a5d7 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/ThrowExceptionConstructor-out.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/ThrowExceptionConstructor-out.java @@ -4,6 +4,6 @@ class MyException extends RuntimeException { class XXX { { - throw new MyException(new String[]{<caret>}); + throw new MyException(new String[<caret>]); } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassConstantReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassConstantReference.java new file mode 100644 index 000000000000..ba341f1b7489 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassConstantReference.java @@ -0,0 +1,11 @@ +class Test { + public Test() { + this(Const.CONST); + } + + public Test(int l) {} + + private class Const { + private static final int CONST = 42; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java index e87c5db28998..647df2b9e7b0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java @@ -95,4 +95,18 @@ class WithFileInputStream { private FileInputStream(String str) { } } -}
\ No newline at end of file +} + +class ContainingKlass { + public static class Inner { + } + + private static class OuterInner { + private static final class Inner { + private Inner s() { + return this; + } + } + } +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java index becdda581a2a..45f728d465f8 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java @@ -1,24 +1,4 @@ -/* - * 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. - */ - -/// assignment compatible types -import java.io.*; -import java.net.*; - -public class a { +public class NumericLiterals { final int FI = 2; final int FIBIG = 200000000; @@ -38,7 +18,8 @@ public class a { int i13 = <error descr="Integer number too large">040000000000</error>; int i14 = 020000000000; int i15 = <error descr="Integer number too large">0xf044332211</error>; - int octale = 017777777777; // negative + int oi1 = 017777777777; + int oi2 = <error descr="Integer number too large">08</error>; int bi1 = <error descr="Binary literals are not supported at this language level">0b0010</error>; int bi2 = <error descr="Binary literals are not supported at this language level">0B0010</error>; int bi3 = <error descr="Underscores in literals are not supported at this language level">1_2</error>; @@ -53,8 +34,8 @@ public class a { long l8 = 0xffffffffffffffffL; long l9 = <error descr="Long number too large">0xffffffffffffffff9L</error>; long l10 = 0x8000000000000000L; - long octalValue = 01777777777777777777600L; - long octalValua = 01777777777777777777777L; + long ol1 = 01777777777777777777600L; + long ol2 = 01777777777777777777777L; long bl1 = <error descr="Binary literals are not supported at this language level">0b0010l</error>; long bl2 = <error descr="Binary literals are not supported at this language level">0B0010L</error>; long bl3 = <error descr="Underscores in literals are not supported at this language level">10_24L</error>; @@ -63,7 +44,8 @@ public class a { float f2 = <error descr="Floating point number too large">1e39f</error>; float f3 = 0E1F; float f4 = <error descr="Hexadecimal floating point literals are not supported at this language level">0xabc.defP2f</error>; - float bf1 = <error descr="Underscores in literals are not supported at this language level">3.141_592f</error>; + float f5 = <error descr="Underscores in literals are not supported at this language level">3.141_592f</error>; + float f6 = .0f; double dd1 = <error descr="Floating point number too small">1e-324</error>; double dd2 = <error descr="Floating point number too large">1e309</error>; @@ -81,5 +63,6 @@ public class a { double d10 = <error descr="Malformed floating point literal">1e-F</error>; double d11 = <error descr="Malformed floating point literal">1e-f</error>; double d12 = <error descr="Underscores in literals are not supported at this language level">3.141_592_653_589_793d</error>; + double d13 = <error descr="Malformed floating point literal">.0e</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/Test.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/Test.java index 64f17b3299c0..6402fa536bbc 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/Test.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/Test.java @@ -1,4 +1,5 @@ public class Test { public Test(int i) { + new x(); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/x.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/x.java new file mode 100644 index 000000000000..88b90d97d842 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/importDefaultPackage/x.java @@ -0,0 +1 @@ +class x { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/lang.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/lang.java new file mode 100644 index 000000000000..39f8b0f7f30c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/lang.java @@ -0,0 +1,3 @@ +package java; + +<error descr="Class 'java.lang' clashes with package of same name">class lang</error> { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub.java new file mode 100644 index 000000000000..3b442d2610ac --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub.java @@ -0,0 +1,3 @@ +package pkg; + +<error descr="Class 'pkg.sub' clashes with package of same name">public class sub</error> { }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub/Test.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub/Test.java new file mode 100644 index 000000000000..f2dbcbd38b91 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash1/pkg/sub/Test.java @@ -0,0 +1,3 @@ +package <error descr="Package 'pkg.sub' clashes with class of same name">pkg.sub</error>; + +public class Test { }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/Sub.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/Sub.java new file mode 100644 index 000000000000..bea47a75e0e3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/Sub.java @@ -0,0 +1,3 @@ +package pkg; + +public class Sub { }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/sub/Test.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/sub/Test.java new file mode 100644 index 000000000000..bf2f203764d6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageClassClash2/pkg/sub/Test.java @@ -0,0 +1,3 @@ +package pkg.sub; + +public class Test { }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/main/Main.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/main/Main.java new file mode 100644 index 000000000000..ec7d7e6611ae --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/main/Main.java @@ -0,0 +1,12 @@ +package main; + +public class Main { + public static void main(String[] args) { + pkg.sub.Test obj = new pkg.sub.Test(); + obj.m1(); + obj.<error descr="Cannot resolve method 'm2()'">m2</error>(); + + pkg.sub.Test.s1(); + pkg.sub.Test.<error descr="Cannot resolve method 's2()'">s2</error>(); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub.java new file mode 100644 index 000000000000..21764febddbc --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub.java @@ -0,0 +1,9 @@ +package pkg; + +class sub { + public static class Test { + public void m2() { } + + public static void s2() { } + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub/Test.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub/Test.java new file mode 100644 index 000000000000..90c5d6ebfb13 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/packageObscuring/pkg/sub/Test.java @@ -0,0 +1,7 @@ +package pkg.sub; + +public class Test { + public void m1() { } + + public static void s1() { } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/JavacQuirks.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/JavacQuirks.java index e95529cd16c1..e95529cd16c1 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/JavacQuirks.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/JavacQuirks.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AmbiguousMethodCallIDEA100314.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AmbiguousMethodCallIDEA100314.java new file mode 100644 index 000000000000..2c155443365c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AmbiguousMethodCallIDEA100314.java @@ -0,0 +1,13 @@ +class Intellij { + + public static <T> T getProperty(final String str, final Class<T> cls) { + return null; + } + + public static <T> T getProperty(final String str, final T defaultValue) { + return null; + } + + String[] ids = Intellij.getProperty(" ", String[].class); + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/NumericLiterals.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/NumericLiterals.java index bf9f96ff1e96..cb59ded58cc6 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/NumericLiterals.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/NumericLiterals.java @@ -7,6 +7,11 @@ public class NumericLiterals { int i5 = 0b0001_0010_0100_1000; int i6 = <error descr="Binary numbers must contain at least one binary digit">0b</error>; int i7 = <error descr="Integer number too large">0b1_1111_1111_1111_1111_1111_1111_1111_1111</error>; + int i8 = <error descr="Illegal underscore">0_</error>; + int i9 = <error descr="Integer number too large">0_8</error>; + int i10 = <error descr="Illegal underscore">0x_f</error>; + int i11 = <error descr="Illegal underscore">0b_1</error>; + int i12 = <error descr="Integer number too large">0B2</error>; long l1 = 1_2L; long l2 = 012__34l; @@ -41,5 +46,7 @@ public class NumericLiterals { double d10 = 0x.a_bcP1___23d; double d11 = <error descr="Floating point number too small">1e-3_2_4</error>; double d12 = <error descr="Floating point number too large">0xa_bc.de_fP1_234D</error>; + double d13 = <error descr="Illegal underscore">0x1.0_p-1</error>; + double d14 = <error descr="Illegal underscore">1.0e_1022</error>; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99357.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99357.java new file mode 100644 index 000000000000..e6635ac196f4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99357.java @@ -0,0 +1,12 @@ +class Test { + public static void main(String[] args) { + Foo f = new Foo(); + System.out.println(f.get()); + } +} + +class Foo<<warning descr="Type parameter 'T' is never used">T</warning>> { + public <T1> T1 get() { + return null; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java new file mode 100644 index 000000000000..7cab4aff7f31 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java @@ -0,0 +1,29 @@ +import java.util.*; +class A<<warning descr="Type parameter 'T' is never used">T</warning>> { +} + +class B<<warning descr="Type parameter 'S' is never used">S</warning>> extends A { +} + +class C extends A<String> { +} + + +class D extends A { +} + + +public class Main { + public static void test(Collection<? extends A> <warning descr="Parameter 'c' is never used">c</warning>) {} + + public static void main(String[] args) { + Collection<B> bs = new ArrayList<B>(); + test(bs); + + Collection<C> cs = new ArrayList<C>(); + test(cs); + + Collection<D> ds = new ArrayList<D>(); + test(ds); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA86875.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA86875.java new file mode 100644 index 000000000000..c5a65df099ab --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA86875.java @@ -0,0 +1,11 @@ +interface Base<E> {} +interface Base2<E> {} + +class A<E extends Cloneable> { + <P, K extends Base<E>&Base2<P>> void m(K k, P p) { + E e = null; + m(k, e); + } + + void m(Base<E> k, E e) {} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99061.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99061.java new file mode 100644 index 000000000000..b6e8f3cfa619 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99061.java @@ -0,0 +1,11 @@ +class Test { + { + String a = cast("str"); + Integer[] b = cast(new Integer[0]); + Object[] c = cast(new Object[0]); + } + + private <T> T cast(Object obj) { + return (T)obj; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99347.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99347.java new file mode 100644 index 000000000000..9c4922400b7d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA99347.java @@ -0,0 +1,12 @@ +interface Errors { + java.util.Collection<java.lang.String> getErrorMessages(); + +} + +class Test extends AbstrClass implements Errors { +} + + +abstract class AbstrClass { + public java.util.Collection getErrorMessages() {return null;} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference.java new file mode 100644 index 000000000000..49c813e2a878 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference.java @@ -0,0 +1,26 @@ +import java.util.*; + +class Main { + + void foo(List<Integer> list) { + bar(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>()); + bar1(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>()); + } + + <U, S_IN, S_OUT, R> R bar(List<S_IN> list, + Fun<S_IN, S_OUT> f1, + Fun<S_OUT, R> f2) { + return null; + } + + <R, S_IN, S_OUT> R bar1(List<S_IN> list, + Fun<S_IN, S_OUT> f1, + Fun<S_OUT, R> f2) { + return null; + } + + + public interface Fun<T, R> { + public R _(T t); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference1.java new file mode 100644 index 000000000000..3033b3971428 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference1.java @@ -0,0 +1,14 @@ +class Main { + + <R> void bar(Fun<Integer, R> collector) { } + + <T, D> Fun<T, Integer> foo(D d) { return null; } + + public void test() { + bar(foo("")); + } + + interface Fun<T, R> { + R _(T t); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromSiblings.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromSiblings.java new file mode 100644 index 000000000000..1cad86808b98 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromSiblings.java @@ -0,0 +1,24 @@ +import java.util.*; + +class Main { + + void test(List<Integer> li) { + Fun<Stream<Integer>, Stream<Integer>> f = s -> s.substr(0); + foo(li, f, Collections.emptyList()); + + foo(li, s -> s.substr(0), Collections.emptyList()); + } + + <T, U, S_OUT extends Stream<U>, It extends Iterable<U>> Collection<U> + foo(Collection<T> coll, Fun<Stream<T>, S_OUT> f, It it) { + return null; + } + + interface Stream<T> { + Stream<T> substr(long startingOffset); + } + + interface Fun<T, R> { + R _(T t); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java new file mode 100644 index 000000000000..0c91d21fdbfd --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java @@ -0,0 +1,15 @@ +import java.util.*; +public class Main { + public static <T> T foo() {return null;} + + public static <B> List<B> bar(B b) {return null;} + static { + List<String> s = bar(foo()); + } + + + public static <B> B bar1(B b) {return null;} + static { + String s1 = bar1(foo()); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCallsSameMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCallsSameMethod.java new file mode 100644 index 000000000000..e4d33d38747f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCallsSameMethod.java @@ -0,0 +1,9 @@ +class Main { + static <T> T foo(T t) { return null; } + + static { + long l1 = foo(foo(1)); + Integer i = 1; + long l2 = foo(foo(i)); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ReturnStmt.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ReturnStmt.java new file mode 100644 index 000000000000..dae02b68773f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ReturnStmt.java @@ -0,0 +1,27 @@ +import java.util.*; +class Main { + + <T, R> Collector<T, R> m(Supplier<? extends R> supplier, BiConsumer<R, T> accumulator) { + return null; + } + + <T, C extends Collection<T>> Collector<T, C> test1(Supplier<C> collectionFactory) { + return m(collectionFactory, Collection::add); + } + + Collector<String, StringBuilder> test2(Supplier<StringBuilder> sb) { + return m(sb, StringBuilder::append); + } + + interface Supplier<T> { + public T get(); + } + + interface Collector<T, R> { + } + + interface BiConsumer<T, U> { + void accept(T t, U u); + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution.java new file mode 100644 index 000000000000..43c4ba966b7b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution.java @@ -0,0 +1,26 @@ +public interface IDEA99969 { + default IntStream distinct(Stream s) { + return s.map(i -> (int) i); + } +} +interface Stream<T> { + <R> Stream<R> map(Function<? super T, ? extends R> mapper); + IntStream map(IntFunction<? super T> mapper); + LongStream map(LongFunction<? super T> mapper); +} + +interface Function<T, R> { + public R apply(T t); +} + +interface IntFunction<T> { + public int applyAsInt(T t); +} + +interface LongFunction<T> { + public long applyAsLong(T t); +} + + +interface IntStream {} +interface LongStream {} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java new file mode 100644 index 000000000000..c0908783911c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java @@ -0,0 +1,30 @@ +class IntStream { + private void foo(IntStream s) { + s.map(i -> 1 << i); + s.map(i -> 1); + s.map(i -> i); + } + + public static void main(String[] args) { + new IntStream().foo(null); + } + + private IntStream map(IntUnaryOperator mapper) { + System.out.println(mapper); + return null; + } + + private <T> IntStream <warning descr="Private method 'map(ObjIntFunction<T>)' is never used">map</warning>(ObjIntFunction<T> mapper) { + System.out.println(mapper); + return null; + } +} + +interface IntUnaryOperator { + public int applyAsInt(int operand); +} + +interface ObjIntFunction<T> { + public T apply(int i); +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java new file mode 100644 index 000000000000..05b2585c8405 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java @@ -0,0 +1,5 @@ +<error descr="Multiple non-overriding abstract methods found">@FunctionalInterface</error> +interface Test { + void foo(); + void bar(); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompleteSubst.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompleteSubst.java index 9085c69489d3..366bea30534d 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompleteSubst.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompleteSubst.java @@ -48,7 +48,7 @@ class LambdaTest2<TypeParam> { U map(T t); } - public <U> LambdaTest<U> map(final Mapper<? super TypeParam, ? extends U> mapper) { + public <U> LambdaTest2<U> map(final Mapper<? super TypeParam, ? extends U> mapper) { return null; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IntersectionTypeInCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IntersectionTypeInCast.java new file mode 100644 index 000000000000..49a261c8b8de --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IntersectionTypeInCast.java @@ -0,0 +1,8 @@ +import java.io.Serializable; +import java.util.*; + +class Test { + public static <K extends Comparable<? super K>, V> Comparator<Map.Entry<K, V>> foo() { + return (Comparator<Map.Entry<K, V>> & Serializable)(c1, c2) -> c1.getKey().compareTo(c2.getKey()); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/UnhandledExceptions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/UnhandledExceptions.java new file mode 100644 index 000000000000..077940408e56 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/UnhandledExceptions.java @@ -0,0 +1,19 @@ +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = (t) -> <error descr="Unhandled exception: ExTest.Ex">ExTest.maybeThrow(t)</error>; + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DefaultMethodVisibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/DefaultMethodVisibility.java index 4a2c0eeb4801..4a2c0eeb4801 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DefaultMethodVisibility.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/DefaultMethodVisibility.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ExtensionMethodSyntax.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/ExtensionMethodSyntax.java index a5e0917301b6..a5e0917301b6 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ExtensionMethodSyntax.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/ExtensionMethodSyntax.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ExtensionMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/ExtensionMethods.java index a7fcb99947c1..44a2a1aaf39f 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ExtensionMethods.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/ExtensionMethods.java @@ -50,7 +50,7 @@ class D { } interface IllegalMods { - <error descr="Illegal combination of modifiers: 'static' and 'abstract'">static</error> void m1(); + <error descr="Static methods in interfaces should have a body">static void m1()</error>; <error descr="Illegal combination of modifiers: 'static' and 'default'">static</error> void m2() default { } <error descr="Illegal combination of modifiers: 'static' and 'default'">static</error> <error descr="Illegal combination of modifiers: 'default' and 'static'">default</error> void m3() { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritUnrelatedDefaults.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritUnrelatedDefaults.java new file mode 100644 index 000000000000..bbcf8b47d745 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritUnrelatedDefaults.java @@ -0,0 +1,3 @@ +interface B { default void foo() {} } +interface C { default void foo() {} } +class <error descr="D inherits unrelated defaults for foo() from types B and C">D</error> implements B, C {} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/NotInheritFromUnrelatedDefault.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/NotInheritFromUnrelatedDefault.java new file mode 100644 index 000000000000..cfc1ee7abec4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/NotInheritFromUnrelatedDefault.java @@ -0,0 +1,15 @@ +interface FirstParent { + + default int doSomething() { + return 1; + } +} + +interface SecondParent { + + int doSomething(); +} + +class <error descr="Class 'SecondParent' must either be declared abstract or implement abstract method 'doSomething()' in 'SecondParent'">FirstSon</error> implements FirstParent, SecondParent {} + +<error descr="Class 'SecondSon' must either be declared abstract or implement abstract method 'doSomething()' in 'SecondParent'">class SecondSon implements SecondParent, FirstParent</error> {}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/staticMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/staticMethod.java new file mode 100644 index 000000000000..d1a1f41c7bc0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/staticMethod.java @@ -0,0 +1,4 @@ +interface Foo { + public static void bar1() {} + public <error descr="Illegal combination of modifiers: 'abstract' and 'static'">abstract</error> static void bar2() {} +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java new file mode 100644 index 000000000000..269b075c4d84 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java @@ -0,0 +1,14 @@ +public class Main { + public static <T> void make(final Consumer<? super T> consumer) { + Sink<T> accept = (Sink<T>) consumer::accept; + Consumer<T> accept1 = (Consumer<T>)consumer::accept; + } +} + +interface Sink<T> extends Consumer<T> { + +} + +interface Consumer<T> { + public void accept(T t); +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java new file mode 100644 index 000000000000..86d8bea66f7d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java @@ -0,0 +1,23 @@ +import java.util.ArrayList; +import java.util.List; + +public class IDEA99970 { + public static <T, C> Collector<T, C> toCollection(Supplier<C> collectionFactory) { + return null; + } + + public static <T> Collector<T, List<T>> toList() { + return toCollection(ArrayList<T>::new); + } + + public static <T> Collector<T, List<T>> toList1() { + return toCollection(ArrayList<T>::new); + } + +} + +interface Supplier<T> { + public T get(); +} + +interface Collector<T, R> {}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IntersectionTypeInCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IntersectionTypeInCast.java new file mode 100644 index 000000000000..f3c5e504f1e0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IntersectionTypeInCast.java @@ -0,0 +1,6 @@ +import java.io.Serializable; +class Test { + { + Runnable r = (Runnable & Serializable)Test::new; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/UnhandledExceptions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/UnhandledExceptions.java new file mode 100644 index 000000000000..a03154d9ecf4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/UnhandledExceptions.java @@ -0,0 +1,19 @@ +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = <error descr="Unhandled exception: ExTest.Ex">ExTest::maybeThrow</error>; + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParamsWithWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParamsWithWildcards.java new file mode 100644 index 000000000000..0bbcdd54dd92 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParamsWithWildcards.java @@ -0,0 +1,9 @@ +class Test { + public interface I<K, V> { + public V put(K k); + } + + { + final I<? super Long, CharSequence> i = (Number n) -> n.toString(); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/Raw.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/Raw.java index e99747fa6169..eeaa80410bb6 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/Raw.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/Raw.java @@ -1,7 +1,7 @@ class Test { { - <error descr="Incompatible types. Found: '<lambda expression>', required: 'java.lang.Comparable'">Comparable c = (String o)->{ + Comparable c = (<error descr="Incompatible parameter types in lambda expression">String o</error>)->{ return 0; - };</error> + }; } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createClassFromNew/beforeQualifiedNew.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createClassFromNew/beforeQualifiedNew.java new file mode 100644 index 000000000000..516a79faae83 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createClassFromNew/beforeQualifiedNew.java @@ -0,0 +1,6 @@ +// "Create Class 'ArrayList'" "false" +public class Test { + public static void main() { + q.new <caret>ArrayList(); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew1.java new file mode 100644 index 000000000000..ce4542d9e4f9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew1.java @@ -0,0 +1,6 @@ +// "Create Inner Class 'ArrayList'" "false" +public class Test { + public static void main() { + q.new <caret>ArrayList(); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew2.java new file mode 100644 index 000000000000..6fa79f02d8d9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeQualifiedNew2.java @@ -0,0 +1,9 @@ +// "Create Inner Class 'ArrayList'" "false" +public class Test { + public static void main() { + Inner q = new Inner(); + q.new <caret>ArrayList(); + } + + static class Inner { } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/afterInSimpleMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/afterInSimpleMethod.java new file mode 100644 index 000000000000..f4477b22bed5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/afterInSimpleMethod.java @@ -0,0 +1,11 @@ +// "Insert '(NodeInfo)parent' declaration" "true" +public abstract class A { + public void getNodeElements(Object parent) { + if (!(parent instanceof NodeInfo)) return; + NodeInfo nodeInfo = (NodeInfo) parent; + <caret> + } + + private static class NodeInfo { + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/beforeInSimpleMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/beforeInSimpleMethod.java new file mode 100644 index 000000000000..8a78a53124e2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalVarFromInstanceof/beforeInSimpleMethod.java @@ -0,0 +1,9 @@ +// "Insert '(NodeInfo)parent' declaration" "true" +public abstract class A { + public void getNodeElements(Object parent) { + if (!(parent instanceof <caret>NodeInfo)) return; + } + + private static class NodeInfo { + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterAmbiguosResult.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterAmbiguosResult.java new file mode 100644 index 000000000000..c6614e06a7fb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterAmbiguosResult.java @@ -0,0 +1,21 @@ +// "Replace lambda with method reference" "true" +import java.util.*; +class IDEA100385 { + void foo(N<Double> n, List<Double> l){ + n.forEach((DoubleConsumer) l::add); + } + static interface N<E> { + default void forEach(DoubleConsumer consumer) { + } + void forEach(Consumer<? super E> consumer); + } + + interface DoubleConsumer { + void _(double d); + } + + interface Consumer<T> { + public void accept(T t); + } + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLocalClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLocalClass.java new file mode 100644 index 000000000000..27a9470f21dd --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLocalClass.java @@ -0,0 +1,37 @@ +// "Replace lambda with method reference" "true" +public class IDEA100452 { + public static <T> MatchOp<T> match(MatchOp.MatchKind matchKind) { + class MatchSink extends BooleanTerminalSink<T> { + + private MatchSink() { + super(matchKind); + } + + @Override + public void accept(T t) { + } + } + + Supplier<BooleanTerminalSink<T>> s = MatchSink::new; + return new MatchOp<>(1, matchKind, s); + } + + static abstract class BooleanTerminalSink<T> { + public BooleanTerminalSink(MatchOp.MatchKind matchKind) { + + } + + public abstract void accept(T t); + } + static interface Supplier<T> { + public T get(); + } + + static class MatchOp<H> { + public MatchOp(int i, MatchKind matchKind, Supplier<BooleanTerminalSink<H>> s) { + //To change body of created methods use File | Settings | File Templates. + } + + static enum MatchKind {} + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeAmbiguosResult.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeAmbiguosResult.java new file mode 100644 index 000000000000..077b9e6c91f2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeAmbiguosResult.java @@ -0,0 +1,23 @@ +// "Replace lambda with method reference" "true" +import java.util.*; +class IDEA100385 { + void foo(N<Double> n, List<Double> l){ + n.forEach((double e) -> { + l.ad<caret>d(e); + }); + } + static interface N<E> { + default void forEach(DoubleConsumer consumer) { + } + void forEach(Consumer<? super E> consumer); + } + + interface DoubleConsumer { + void _(double d); + } + + interface Consumer<T> { + public void accept(T t); + } + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLocalClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLocalClass.java new file mode 100644 index 000000000000..9dfd3b42f1b3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLocalClass.java @@ -0,0 +1,37 @@ +// "Replace lambda with method reference" "true" +public class IDEA100452 { + public static <T> MatchOp<T> match(MatchOp.MatchKind matchKind) { + class MatchSink extends BooleanTerminalSink<T> { + + private MatchSink() { + super(matchKind); + } + + @Override + public void accept(T t) { + } + } + + Supplier<BooleanTerminalSink<T>> s = () -> new Match<caret>Sink(); + return new MatchOp<>(1, matchKind, s); + } + + static abstract class BooleanTerminalSink<T> { + public BooleanTerminalSink(MatchOp.MatchKind matchKind) { + + } + + public abstract void accept(T t); + } + static interface Supplier<T> { + public T get(); + } + + static class MatchOp<H> { + public MatchOp(int i, MatchKind matchKind, Supplier<BooleanTerminalSink<H>> s) { + //To change body of created methods use File | Settings | File Templates. + } + + static enum MatchKind {} + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/afterChain.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/afterChain.java new file mode 100644 index 000000000000..7d3370d33743 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/afterChain.java @@ -0,0 +1,10 @@ +// "Replace with 'integer != null ?:'" "true" + +import java.lang.Integer; + +class A{ + void test(){ + Integer integer = null; + int i = integer != null ? integer.toString().length() : <selection>0</selection>; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/beforeChain.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/beforeChain.java new file mode 100644 index 000000000000..4728847e397b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator/beforeChain.java @@ -0,0 +1,10 @@ +// "Replace with 'integer != null ?:'" "true" + +import java.lang.Integer; + +class A{ + void test(){ + Integer integer = null; + int i = in<caret>teger.toString().length(); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterLambdaCodeBlock.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterLambdaCodeBlock.java new file mode 100644 index 000000000000..67eeb7469d52 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterLambdaCodeBlock.java @@ -0,0 +1,26 @@ +// "Surround with try/catch" "true" +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = (t) -> { + try { + return ExTest.maybeThrow(t); + } catch (Ex ex) { + <selection>ex.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection> + } + }; + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaCodeBlock.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaCodeBlock.java new file mode 100644 index 000000000000..1b296d021490 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaCodeBlock.java @@ -0,0 +1,20 @@ +// "Surround with try/catch" "true" +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = (t) -> { return ExTest.may<caret>beThrow(t);}; + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaExpr.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaExpr.java new file mode 100644 index 000000000000..2cb6adb41d38 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeLambdaExpr.java @@ -0,0 +1,20 @@ +// "Surround with try/catch" "false" +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = (t) -> ExTest.may<caret>beThrow(t); + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeMethodRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeMethodRef.java new file mode 100644 index 000000000000..80cc540bed71 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeMethodRef.java @@ -0,0 +1,20 @@ +// "Surround with try/catch" "false" +public class ExTest { + public static void maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + Block<String> b = ExTest::may<caret>beThrow(t); + } + + + private static class Ex extends Throwable { + public Ex(String s) { + } + } +} + +interface Block<T> { + public void accept(T t); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/documentation/inherit.gif b/java/java-tests/testData/codeInsight/documentation/inherit.gif Binary files differnew file mode 100644 index 000000000000..c814867a13de --- /dev/null +++ b/java/java-tests/testData/codeInsight/documentation/inherit.gif diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis1.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis1.java new file mode 100644 index 000000000000..4584077665e2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis1.java @@ -0,0 +1,11 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if ((!a || !b) && !c) { + System.out.println(1); + } + else { + System.out.println(0); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis2.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis2.java new file mode 100644 index 000000000000..fd19babc6d64 --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis2.java @@ -0,0 +1,11 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if (!a || !b || !c) { + System.out.println(1); + } + else { + System.out.println(0); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis3.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis3.java new file mode 100644 index 000000000000..ca8ef27512f5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterParenthesis3.java @@ -0,0 +1,11 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if ((!a && !b) || !c) { + System.out.println(1); + } + else { + System.out.println(0); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis1.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis1.java new file mode 100644 index 000000000000..910ff076934f --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis1.java @@ -0,0 +1,10 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if (a &<caret>& b || c) { + System.out.println(0); + } else { + System.out.println(1); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis2.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis2.java new file mode 100644 index 000000000000..4aab06463a17 --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis2.java @@ -0,0 +1,10 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if (a &<caret>& b && c) { + System.out.println(0); + } else { + System.out.println(1); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis3.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis3.java new file mode 100644 index 000000000000..256ef0b2efc3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeParenthesis3.java @@ -0,0 +1,10 @@ +// "Invert If Condition" "true" +class Inversion { + public void context(boolean a, boolean b, boolean c) { + if ((a |<caret>| b) && c) { + System.out.println(0); + } else { + System.out.println(1); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html new file mode 100644 index 000000000000..f4ba3cbff9d1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html @@ -0,0 +1 @@ +<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://Test"><code>Test</code></a></b></small><PRE>public int <b>field = anotherField</b></PRE></body></html>
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java new file mode 100644 index 000000000000..39a7384fdbb1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java @@ -0,0 +1,4 @@ +class Test { + public int field = anotherField; + public static int anotherField = 1; +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/splitIfAction/afterWithoutSpaces.java b/java/java-tests/testData/codeInsight/splitIfAction/afterWithoutSpaces.java new file mode 100644 index 000000000000..f776d7d19b7d --- /dev/null +++ b/java/java-tests/testData/codeInsight/splitIfAction/afterWithoutSpaces.java @@ -0,0 +1,8 @@ +public class SplitCondition { + private static void appendString(StringBuilder builder, boolean condition) { + if (condition) { + if (builder.length() > 0) { + } + } + } +} diff --git a/java/java-tests/testData/codeInsight/splitIfAction/beforeWithoutSpaces.java b/java/java-tests/testData/codeInsight/splitIfAction/beforeWithoutSpaces.java new file mode 100644 index 000000000000..b573566020ce --- /dev/null +++ b/java/java-tests/testData/codeInsight/splitIfAction/beforeWithoutSpaces.java @@ -0,0 +1,6 @@ +public class SplitCondition { + private static void appendString(StringBuilder builder, boolean condition) { + if (condition&<caret>&builder.length() > 0) { + } + } +} diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass.log b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass.log new file mode 100644 index 000000000000..39635f36edb8 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass.log @@ -0,0 +1,10 @@ +Compiling files: +src2/pkg/Constants.java +End of files +Cleaning output files: +out/production/addDuplicateClass/pkg/Constants.class +End of files +Compiling files: +src/pkg/Constants.java +src2/pkg/Constants.java +End of files diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/misc.xml b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/misc.xml new file mode 100644 index 000000000000..9a249d2930c5 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/misc.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="EntryPointsManager"> + <entry_points version="2.0" /> + </component> + <component name="ProjectResources"> + <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> + diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/modules.xml b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/modules.xml new file mode 100644 index 000000000000..6c4ca79986a8 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/.idea/modules.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/addDuplicateClass.iml" filepath="$PROJECT_DIR$/addDuplicateClass.iml" /> + </modules> + </component> +</project> + diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/addDuplicateClass.iml b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/addDuplicateClass.iml new file mode 100644 index 000000000000..119c6ef0a879 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/addDuplicateClass.iml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src2" isTestSource="false" /> + </content> + <orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="common" /> + </component> +</module> + diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Client.java b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Client.java new file mode 100644 index 000000000000..8d9b52bd6ff2 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Client.java @@ -0,0 +1,6 @@ +package pkg; +public class Client { + public static void main(String[] args) { + System.out.println(Constants.NUMBER); + } +} diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Constants.java b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Constants.java new file mode 100644 index 000000000000..edc79841dffe --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src/pkg/Constants.java @@ -0,0 +1,4 @@ +package pkg; +public class Constants { + public static final Integer NUMBER = new Integer(10); +} diff --git a/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src2/pkg/Constants.java.new b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src2/pkg/Constants.java.new new file mode 100644 index 000000000000..0f9f6ffd7960 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/common/addDuplicateClass/src2/pkg/Constants.java.new @@ -0,0 +1,3 @@ +package pkg; +public class Constants { +} diff --git a/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod.log b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod.log new file mode 100644 index 000000000000..ea3129552780 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod.log @@ -0,0 +1,12 @@ +Cleaning output files: +out/production/RemoveMoreAccessibleMethod/x/Concrete.class +End of files +Compiling files: +src/x/Concrete.java +End of files +Cleaning output files: +out/production/RemoveMoreAccessibleMethod/x/y/Client.class +End of files +Compiling files: +src/x/y/Client.java +End of files diff --git a/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Abstract.java b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Abstract.java new file mode 100644 index 000000000000..ab43a5b2ae00 --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Abstract.java @@ -0,0 +1,6 @@ +package x; + +public class Abstract { + protected void method(int a) { + } +} diff --git a/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java new file mode 100644 index 000000000000..8a992bb4ca8d --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java @@ -0,0 +1,7 @@ +package x; + +public class Concrete extends Abstract{ + @Override + public void method(int a) { + } +} diff --git a/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java.new b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java.new new file mode 100644 index 000000000000..1502b7ddf13b --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/Concrete.java.new @@ -0,0 +1,4 @@ +package x; + +public class Concrete extends Abstract{ +} diff --git a/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/y/Client.java b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/y/Client.java new file mode 100644 index 000000000000..6a759deba6bc --- /dev/null +++ b/java/java-tests/testData/compileServer/incremental/membersChange/removeMoreAccessibleMethod/src/x/y/Client.java @@ -0,0 +1,11 @@ +package x.y; + +import x.*; + +public class Client { + private static Concrete concrete; + + public static void main(String[] args) { + concrete.method(10); + } +} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java index 8cf8bbdd8c2f..12c6fb1ad9bf 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java @@ -12,28 +12,28 @@ public class BrokenAlignment { data = new Data(null, <warning descr="Passing 'null' argument to non annotated parameter">null</warning>); System.out.println(<warning descr="Method invocation 'data.getText().hashCode()' may produce 'java.lang.NullPointerException'">data.getText().hashCode()</warning>); - if (data.inner() != null) { - System.out.println(data.inner().hashCode()); - System.out.println(<warning descr="Method invocation 'data.inner().getText().hashCode()' may produce 'java.lang.NullPointerException'">data.inner().getText().hashCode()</warning>); - if (data.inner() != null) { - System.out.println(data.inner().hashCode()); + if (data.getInner() != null) { + System.out.println(data.getInner().hashCode()); + System.out.println(<warning descr="Method invocation 'data.getInner().getText().hashCode()' may produce 'java.lang.NullPointerException'">data.getInner().getText().hashCode()</warning>); + if (data.getInner() != null) { + System.out.println(data.getInner().hashCode()); } data = new Data(null, <warning descr="Passing 'null' argument to non annotated parameter">null</warning>); - System.out.println(<warning descr="Method invocation 'data.inner().hashCode()' may produce 'java.lang.NullPointerException'">data.inner().hashCode()</warning>); + System.out.println(<warning descr="Method invocation 'data.getInner().hashCode()' may produce 'java.lang.NullPointerException'">data.getInner().hashCode()</warning>); } } void main2(Data data) { - if (data.inner() != null && data.inner().getText() != null) { - System.out.println(data.inner().hashCode()); - System.out.println(data.inner().getText().hashCode()); + if (data.getInner() != null && data.getInner().getText() != null) { + System.out.println(data.getInner().hashCode()); + System.out.println(data.getInner().getText().hashCode()); } } void main3(Data data) { - if (data.innerOverridden() != null) { - System.out.println(data.innerOverridden().hashCode()); + if (data.getInnerOverridden() != null) { + System.out.println(data.getInnerOverridden().hashCode()); } if (data.something() != null) { System.out.println(<warning descr="Method invocation 'data.something().hashCode()' may produce 'java.lang.NullPointerException'">data.something().hashCode()</warning>); @@ -55,12 +55,12 @@ public class BrokenAlignment { } @Nullable - public Data inner() { + public Data getInner() { return inner; } @Nullable - public Data innerOverridden() { + public Data getInnerOverridden() { return inner; } @@ -77,8 +77,8 @@ public class BrokenAlignment { @Nullable @Override - public Data innerOverridden() { - return super.innerOverridden(); + public Data getInnerOverridden() { + return super.getInnerOverridden(); } } }
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/EffectivelyUnqualified.java b/java/java-tests/testData/inspection/dataFlow/fixture/EffectivelyUnqualified.java new file mode 100644 index 000000000000..86ed56676e26 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/EffectivelyUnqualified.java @@ -0,0 +1,12 @@ +abstract class Foo { + protected String bar; +} + +class FF extends Foo { + class FFI extends Foo { + void f() { + if (this.bar == FF.this.bar); + if (<warning descr="Condition 'this.bar == FFI.this.bar' is always 'true'">this.bar == FFI.this.bar</warning>); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/EqualsHasNoSideEffects.java b/java/java-tests/testData/inspection/dataFlow/fixture/EqualsHasNoSideEffects.java new file mode 100644 index 000000000000..20d33e187598 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/EqualsHasNoSideEffects.java @@ -0,0 +1,22 @@ +class DefaultObjectIdentifier { + String user; + String requestorClass; + public boolean equals(Object otherObject) { + if (otherObject == null || !(otherObject instanceof DefaultObjectIdentifier)) + return false; + else { + DefaultObjectIdentifier identifier = (DefaultObjectIdentifier) otherObject; + if (user == null && identifier.user != null) + return false; + else if (requestorClass == null && identifier.requestorClass != null) + return false; + else if (((user == null && <warning descr="Condition 'identifier.user == null' is always 'true' when reached">identifier.user == null</warning>) + || (this.user.equals(identifier.user))) + && + ((requestorClass == null && <warning descr="Condition 'identifier.requestorClass == null' is always 'true' when reached">identifier.requestorClass == null</warning>) + || this.requestorClass.equals(identifier.requestorClass))) + return true; + else + return false; + } + }}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MutableNotAnnotatedFieldsTreatment.java b/java/java-tests/testData/inspection/dataFlow/fixture/MutableNotAnnotatedFieldsTreatment.java index a7c67e05861f..c542ba8fc158 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/MutableNotAnnotatedFieldsTreatment.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/MutableNotAnnotatedFieldsTreatment.java @@ -32,11 +32,11 @@ class Foo { System.out.println(data.hashCode()); } - void dontWarnWhenDoubleChecked(Foo f) { + void warnWhenDoubleChecked(Foo f) { if (f.data == null) { return; } - if (f.data == null) { + if (<warning descr="Condition 'f.data == null' is always 'false'">f.data == null</warning>) { return; } System.out.println(f.data.hashCode()); @@ -53,13 +53,13 @@ class Foo { } System.out.println(data.hashCode()); } - - void dontWarnWhenDoubleChecked_This_WithMethodCall() { + + void warnWhenDoubleChecked_This_WithMethodCall() { if (data == null) { return; } System.out.println(data.hashCode()); - if (data == null) { + if (<warning descr="Condition 'data == null' is always 'false'">data == null</warning>) { return; } System.out.println(data.hashCode()); diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MutableNullableFieldsTreatment.java b/java/java-tests/testData/inspection/dataFlow/fixture/MutableNullableFieldsTreatment.java index ee2b1813b4d2..107d11f2bd75 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/MutableNullableFieldsTreatment.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/MutableNullableFieldsTreatment.java @@ -34,11 +34,11 @@ class Foo { System.out.println(data.hashCode()); } - void dontWarnWhenDoubleChecked(Foo f) { + void warnWhenDoubleChecked(Foo f) { if (f.data == null) { return; } - if (f.data == null) { + if (<warning descr="Condition 'f.data == null' is always 'false'">f.data == null</warning>) { return; } System.out.println(f.data.hashCode()); @@ -56,12 +56,12 @@ class Foo { System.out.println(data.hashCode()); } - void dontWarnWhenDoubleChecked_This_WithMethodCall() { + void warnWhenDoubleChecked_This_WithMethodCall() { if (data == null) { return; } System.out.println(data.hashCode()); - if (data == null) { + if (<warning descr="Condition 'data == null' is always 'false'">data == null</warning>) { return; } System.out.println(data.hashCode()); diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/OmnipresentExceptions.java b/java/java-tests/testData/inspection/dataFlow/fixture/OmnipresentExceptions.java new file mode 100644 index 000000000000..185c8ef269b1 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/OmnipresentExceptions.java @@ -0,0 +1,30 @@ +class Test { + Object m1(String[] args) throws Exception { + try { + return <warning descr="'null' is returned by the method which isn't declared as @Nullable">null</warning>; + } + catch (Throwable t) { + if (t instanceof Error) { + System.err.println("1"); + } + if (!(t instanceof RuntimeException)) { + System.err.println("2"); + } + return null; + } + } + + void m2(String[] args) throws Exception { + try { + System.out.println(); + } + catch (Throwable t) { + if (t instanceof Error) { + System.err.println("1"); + } + if (!(t instanceof RuntimeException)) { + System.err.println("2"); + } + } + } +} diff --git a/java/java-tests/testData/inspection/dataFlow/TryWithResourcesInstanceOf.java b/java/java-tests/testData/inspection/dataFlow/fixture/TryWithResourcesInstanceOf.java index f2ac4a8f3ba4..f2ac4a8f3ba4 100644 --- a/java/java-tests/testData/inspection/dataFlow/TryWithResourcesInstanceOf.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/TryWithResourcesInstanceOf.java diff --git a/java/java-tests/testData/inspection/dataFlow/TryWithResourcesNullability.java b/java/java-tests/testData/inspection/dataFlow/fixture/TryWithResourcesNullability.java index 80435df3b452..80435df3b452 100644 --- a/java/java-tests/testData/inspection/dataFlow/TryWithResourcesNullability.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/TryWithResourcesNullability.java diff --git a/java/java-tests/testData/inspection/sillyAssignment/multiple/src/Test.java b/java/java-tests/testData/inspection/sillyAssignment/multiple/src/Test.java index 0b3feb5b6203..2ddf2b6d6d10 100644 --- a/java/java-tests/testData/inspection/sillyAssignment/multiple/src/Test.java +++ b/java/java-tests/testData/inspection/sillyAssignment/multiple/src/Test.java @@ -20,5 +20,18 @@ public class Test extends Super { } class Super { int h; + int bar; } + +class Outer extends Super { + class Inner extends Super { + void f() { + this.bar = Outer.this.bar; + bar = Outer.this.bar; + this.bar = Outer.super.bar; + bar = Outer.super.bar; + super.bar = Outer.super.bar; + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/introduceVariable/genericWithTwoParameters/after/Client.java b/java/java-tests/testData/refactoring/introduceVariable/genericWithTwoParameters/after/Client.java index 4760e5ef0e09..38d94b3a880b 100644 --- a/java/java-tests/testData/refactoring/introduceVariable/genericWithTwoParameters/after/Client.java +++ b/java/java-tests/testData/refactoring/introduceVariable/genericWithTwoParameters/after/Client.java @@ -2,6 +2,6 @@ import util.Pair; class Client { void method() { - Pair<String,Pair<Integer,Boolean>> p = PairProvider.getPair(); + Pair<String, Pair<Integer,Boolean>> p = PairProvider.getPair(); } }
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext.java b/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext.java new file mode 100644 index 000000000000..7fc1574ce187 --- /dev/null +++ b/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext.java @@ -0,0 +1,7 @@ +class Test { + String myFoo; + static { + String f<caret>oo = ""; + System.out.println(myFoo); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext_after.java b/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext_after.java new file mode 100644 index 000000000000..6d3f3b994262 --- /dev/null +++ b/java/java-tests/testData/refactoring/renameLocal/RenameToFieldNameInStaticContext_after.java @@ -0,0 +1,7 @@ +class Test { + String myFoo; + static { + String myFoo = ""; + System.out.println(myFoo); + } +}
\ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy index 1fc4145095c2..c70c166a19b0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy @@ -197,6 +197,44 @@ class A { ''' } + public void "test static import before an identifier"() { + myFixture.addClass ''' +package test.t1; + +public enum DemoEnum +{ + XXONE, + TWO +}''' + doTest """ +import test.t1.DemoEnum; + +public class Demo { + + public static void doStuff(DemoEnum enumValue, String value) {} + public static void main(String[] args) + { + String val = "anyValue"; + doStuff(XXON<caret>val); + } +} +""", true, """ +import test.t1.DemoEnum; + +import static test.t1.DemoEnum.XXONE; + +public class Demo { + + public static void doStuff(DemoEnum enumValue, String value) {} + public static void main(String[] args) + { + String val = "anyValue"; + doStuff(XXONE<caret>val); + } +} +""" + } + private void doTest(String input, boolean importStatic, String output) { myFixture.configureByText("a.java", input) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy new file mode 100644 index 000000000000..d8a49bfd7cae --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.codeInsight.completion + +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +/** + * @author peter + */ +class HippieCompletionTest extends LightCodeInsightFixtureTestCase { + + public void testDollars() { + myFixture.configureByText "a.txt", ''' +$some_long_variable_name = Obj::instance(); +$some_lon<caret> +''' + myFixture.performEditorAction("HippieCompletion") + myFixture.checkResult ''' +$some_long_variable_name = Obj::instance(); +$some_long_variable_name<caret> +''' + } + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index 904e83c41fe9..bc2a12897497 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -60,14 +60,14 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } """) type('i') - assertContains("if", "iterable", "int") + assertContains("iterable", "if", "int") type('t') assertContains "iterable" assertEquals 'iterable', lookup.currentItem.lookupString type('er') - assertContains("iter", "iterable") + assertContains "iterable", "iter" assertEquals 'iterable', lookup.currentItem.lookupString assert lookup.focused @@ -76,7 +76,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } def assertContains(String... items) { - assert myFixture.lookupElementStrings.containsAll(items as List) + myFixture.assertPreferredCompletionItems(0, items) } public void testRecalculateItemsOnBackspace() { @@ -89,7 +89,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } """) type "r" - assertContains "iter", "iterable" + assertContains "iterable", "iter" type '\b' assertContains "iterable" @@ -104,7 +104,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertContains "iterable" type "r" - assertContains "iter", "iterable" + assertContains "iterable", "iter" } public void testExplicitSelectionShouldSurvive() { @@ -124,8 +124,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertEquals 'iterable2', lookup.currentItem.lookupString type "r" - assertContains "iter", "iterable", 'iterable2' - assertEquals 'iterable2', lookup.currentItem.lookupString + myFixture.assertPreferredCompletionItems 2, "iterable", "iter", 'iterable2' } @@ -146,8 +145,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertEquals 'iterable2', lookup.currentItem.lookupString type "r" - assertContains "iter", "iterable", 'iterable2' - assertEquals 'iterable2', lookup.currentItem.lookupString + myFixture.assertPreferredCompletionItems 2, "iterable", "iter", 'iterable2' } @@ -554,7 +552,7 @@ public interface Test { """) type('i') def offset = myFixture.editor.caretModel.offset - assertContains "if", "iterable", "int" + assertContains "iterable", "if", "int" edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } assert myFixture.editor.caretModel.offset == offset + 1 @@ -569,7 +567,7 @@ public interface Test { joinAutopopup() joinCompletion() assert !lookup.calculating - assertContains "if", "iterable", "int" + assertContains "iterable", "if", "int" assertEquals 'iterable', lookup.currentItem.lookupString edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } @@ -656,26 +654,6 @@ public interface Test { } } - public void testTemplateSelectionByComma() { - myFixture.configureByText("a.java", """ -class Foo { - int itea = 2; - int itera = 2; - - { - it<caret> - } -} -""") - type 'e' - assertContains "itea", "itera" - type 'r' - assertContains "iter", "itera" - type ',' - assert !lookup - assert myFixture.editor.document.text.contains('itera,') - } - public void testTemplateSelectionBySpace() { myFixture.configureByText("a.java", """ class Foo { @@ -959,7 +937,7 @@ class Foo { } type('_') - assertContains 'x__foo', 'x__goo' + myFixture.assertPreferredCompletionItems 1, 'x__foo', 'x__goo' edt { assert goo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP) @@ -1076,14 +1054,6 @@ public class UTest { return editor } - public void _testCharSelectionUndo() { - myFixture.configureByText "a.java", "class Foo {{ <caret> }}" - def editor = openEditorForUndo(); - type('ArrStoExce.') - edt { UndoManager.getInstance(project).undo(editor) } - assert myFixture.editor.document.text.contains('ArrStoExce.') - } - public void testAutopopupTypingUndo() { myFixture.configureByText "a.java", "class Foo {{ <caret> }}" def editor = openEditorForUndo(); @@ -1288,7 +1258,14 @@ class Foo { } @Override + protected void setUp() { + super.setUp() + CodeInsightSettings.instance.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = true + } + + @Override protected void tearDown() { + CodeInsightSettings.instance.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = false CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER super.tearDown() } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java index 1f16310242b1..3c17cc882e85 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java @@ -74,7 +74,7 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase { public void testSee0() throws Exception { configureByFile("See0.java"); - assertStringItems("foo", "clone", "equals", "getClass", "hashCode", "notify", "notifyAll", "Object", "toString", "wait", "wait", "wait", "finalize", "registerNatives"); + myFixture.assertPreferredCompletionItems(0, "foo", "clone", "equals", "hashCode"); } public void testSee1() throws Exception { @@ -198,6 +198,12 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase { assertTrue(getLookupElementStrings().containsAll(Arrays.asList("io", "lang", "util"))); } + public void testQualifyClassReferenceInPackageStatement() throws Exception { + configureByFile(getTestName(false) + ".java"); + myFixture.type('\n'); + checkResultByFile(getTestName(false) + "_after.java"); + } + public void testCustomReferenceProvider() throws Exception { PsiReferenceRegistrarImpl registrar = (PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(StdLanguages.JAVA); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index c50a4b5de7cc..55b27122e5f8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -109,11 +109,13 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testReturnInTernary() throws Exception { doTest(1, "return"); } public void testFinalAfterParameterAnno() throws Exception { doTest(2, "final", "float", "class"); } public void testFinalAfterParameterAnno2() throws Exception { doTest(2, "final", "float", "class"); } + public void testFinalAfterCase() throws Exception { doTest(3, "final", "float", "class"); } public void testFinalInTryWithResources() throws Exception { doTest(1, "final", "float", "class"); } public void testClassInMethod() throws Exception { doTest(2, "class", "char"); } public void testIntInClassArray() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInClassArray2() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInClassArray3() throws Throwable { doTest(2, "int", "char", "final"); } + public void testArrayClass() throws Throwable { doTest(1, "class", "interface"); } public void testIntInGenerics() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInGenerics2() throws Throwable { doTest(2, "int", "char", "final"); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy index 81466459ec26..6b5607b47cc1 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -195,7 +195,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { public void testDeclaredMembersGoFirst() throws Exception { invokeCompletion(getTestName(false) + ".java"); - assertStringItems("fromThis", "overridden", "fromSuper", "equals", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", + assertStringItems("fromThis", "overridden", "fromSuper", "equals", "hashCode", "toString", "getClass", "notify", "notifyAll", "wait", "wait", "wait"); } @@ -314,6 +314,11 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { } } + public void testAlphaSortingStartMatchesFirst() { + UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = true + checkPreferredItems 0, 'xxbar', 'xxfoo', 'xxgoo', 'barxx', 'fooxx', 'gooxx' + } + public void testSortSameNamedVariantsByProximity() { myFixture.addClass("public class Bar {}"); for (int i = 0; i < 10; i++) { @@ -465,7 +470,7 @@ import java.lang.annotation.Target; repeatCompletion 'b' myFixture.completeBasic(); - assertPreferredItems(0, '_boo2', '_foo2', 'return', '_boo1', '_foo1', '_goo1', '_goo2') + assertPreferredItems(0, 'return', '_boo2', '_foo2', '_boo1', '_foo1', '_goo1', '_goo2') myFixture.type('_'); assertPreferredItems(0, '_boo2', '_foo2', '_boo1', '_foo1', '_goo1', '_goo2') myFixture.type('g') @@ -544,4 +549,11 @@ import java.lang.annotation.Target; checkPreferredItems(0, 'vx') } + public void testLocalVarsOverStats() { + CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE; + checkPreferredItems 0, 'psiElement', 'PsiElement' + incUseCount lookup, 1 + assertPreferredItems 0, 'psiElement', 'PsiElement' + } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 880e7b175c7a..0c7e3f1ce4bf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -85,6 +85,20 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { public void testSimpleVariable() throws Exception { doTest('\n') } + public void testTypeParameterItemPresentation() { + configure() + LookupElementPresentation presentation = renderElement(myItems[0]) + assert "Param" == presentation.itemText + assert presentation.tailText == " (type parameter of Foo)" + assert !presentation.typeText + assert !presentation.icon + assert !presentation.itemTextBold + + presentation = renderElement(myItems[1]) + assert "Param2" == presentation.itemText + assert presentation.tailText == " (type parameter of goo)" + } + public void testMethodItemPresentation() { configure() LookupElementPresentation presentation = renderElement(myItems[0]) @@ -839,7 +853,7 @@ public class ListUtils { final String path = getTestName(false) + ".java"; configureByFile(path); checkResultByFile(path); - assertStringItems("fai1", "fai2"); + assertStringItems("fai1", "fai2", "FunctionalInterface"); } public void testProtectedInaccessibleOnSecondInvocation() throws Throwable { @@ -1302,5 +1316,20 @@ class XInternalError {} assert lookup.items.size() == 1 } + public void testImplementViaCompletion() { + configure() + myFixture.assertPreferredCompletionItems 0, 'private', 'protected', 'public', 'public void run' + def item = lookup.items[3] + + def p = LookupElementPresentation.renderElement(item) + assert p.itemText == 'public void run' + assert p.tailText == '(s, myInt) {...}' + assert p.typeText == 'Foo' + + lookup.currentItem = item + myFixture.type('\n') + checkResult() + } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java index 06beba331d5c..f8ea1ba949bc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.completion; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.lookup.Lookup; -import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.testFramework.LightProjectDescriptor; import org.jetbrains.annotations.NotNull; @@ -63,6 +62,10 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testIgnoreDefaultMethods() { + doTest(); + } + private void doTest() { configureByFile("/" + getTestName(false) + ".java"); assertNotNull(myItems); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy index b14a645bc5ae..fa418ec9c5fb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy @@ -95,7 +95,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testDontPreferKeywords() throws Throwable { - checkPreferredItems(0, "o1", "foo", "name", "this", "getClass"); + checkPreferredItems(0, "o1", "foo", "name", "this"); } public void testEnumValueOf() throws Throwable { @@ -129,11 +129,11 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testSmartEquals2() throws Throwable { - checkPreferredItems(0, "foo", "this", "o", "s", "getClass"); + checkPreferredItems(0, "foo", "this", "o", "s"); } public void testSmartEquals3() throws Throwable { - checkPreferredItems(0, "b", "this", "a", "z", "getClass"); + checkPreferredItems(0, "b", "this", "a", "z"); } public void testSmartCollectionsNew() throws Throwable { @@ -222,7 +222,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testFactoryMethodForDefaultType() throws Throwable { - checkPreferredItems(0, "create", "this", "getClass"); + checkPreferredItems(0, "create", "this"); } public void testLocalVarsBeforeClassLiterals() throws Throwable { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java index 7741a09efe0a..a8fc06a8faad 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java @@ -348,6 +348,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { String path = "/generics"; configureByFile(path + "/before9.java"); + selectItem(myItems[1]); checkResultByFile(path + "/after9.java"); } @@ -421,7 +422,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testArrayAccessIndex() throws Throwable { doTest(); } - public void testThrowExceptionConstructor() throws Throwable { doTest(); } + public void testThrowExceptionConstructor() throws Throwable { doTest('\n'); } public void testJavadocThrows() throws Throwable { doTest(); } @@ -470,7 +471,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testVoidExpectedType() throws Throwable { configureByTestName(); - assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "getClass", "equals", "hashCode", "toString"); + assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "equals", "hashCode", "toString", "getClass"); type("eq"); assertEquals("equals", assertOneElement(getLookup().getItems()).getLookupString()); select(); @@ -594,16 +595,18 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testNewVararg() throws Throwable { configureByTestName(); - assertStringItems("Foo", "Foo"); + assertStringItems("Foo", "Foo", "Foo"); assertEquals("{...} (default package)", LookupElementPresentation.renderElement(myItems[0]).getTailText()); assertEquals("[] (default package)", LookupElementPresentation.renderElement(myItems[1]).getTailText()); + assertEquals("[]{...} (default package)", LookupElementPresentation.renderElement(myItems[2]).getTailText()); } public void testNewVararg2() throws Throwable { configureByTestName(); - assertStringItems("String", "String"); + assertStringItems("String", "String", "String"); assertEquals(" (java.lang)", LookupElementPresentation.renderElement(myItems[0]).getTailText()); assertEquals("[] (java.lang)", LookupElementPresentation.renderElement(myItems[1]).getTailText()); + assertEquals("[]{...} (java.lang)", LookupElementPresentation.renderElement(myItems[2]).getTailText()); } public void testNewByteArray() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java index a5cdf9d20882..076773a62e34 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -27,7 +27,6 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -50,8 +49,8 @@ import java.io.File; import java.util.Collection; /** - * This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run - * For "lightweight" tests use LightAdvHighlightingTest + * This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run. + * For "lightweight" tests use LightAdvHighlightingTest. */ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting"; @@ -158,7 +157,7 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { doTest(BASE_PATH + "/alreadyImportedClass/pack/AlreadyImportedClass.java", BASE_PATH + "/alreadyImportedClass", false, false); } - public void testImportDefaultPackage() throws Exception { + public void testImportDefaultPackage1() throws Exception { doTest(BASE_PATH + "/importDefaultPackage/x/Usage.java", BASE_PATH + "/importDefaultPackage", false, false); } @@ -166,6 +165,10 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { doTest(BASE_PATH + "/importDefaultPackage/x/ImportOnDemandUsage.java", BASE_PATH + "/importDefaultPackage", false, false); } + public void testImportDefaultPackage3() throws Exception { + doTest(BASE_PATH + "/importDefaultPackage/Test.java", BASE_PATH + "/importDefaultPackage", false, false); + } + public void testImportDefaultPackageInvalid() throws Exception { doTest(BASE_PATH + "/importDefaultPackage/x/InvalidUse.java", BASE_PATH + "/importDefaultPackage", false, false); } @@ -232,15 +235,16 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testMultiJDKConflict() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); + ModuleManager moduleManager = ModuleManager.getInstance(getProject()); - final Module java4 = moduleManager.findModuleByName("java4"); + Module java4 = moduleManager.findModuleByName("java4"); Module java5 = moduleManager.findModuleByName("java5"); ModuleRootModificationUtil.setModuleSdk(java4, IdeaTestUtil.getMockJdk17("java 1.4")); ModuleRootModificationUtil.setModuleSdk(java5, IdeaTestUtil.getMockJdk17("java 1.5")); ModuleRootModificationUtil.addDependency(java5, java4); - assert root != null; configureByExistingFile(root.findFileByRelativePath("moduleJava5/com/Java5.java")); Collection<HighlightInfo> infos = highlightErrors(); assertEmpty(infos); @@ -249,9 +253,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testSameFQNClasses() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); - assert root != null; configureByExistingFile(root.findFileByRelativePath("client/src/BugTest.java")); Collection<HighlightInfo> infos = highlightErrors(); assertEmpty(infos); @@ -260,9 +264,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testSameClassesInSourceAndLib() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); - assert root != null; configureByExistingFile(root.findFileByRelativePath("src/ppp/SomeClass.java")); PsiField field = ((PsiJavaFile)myFile).getClasses()[0].findFieldByName("f", false); assert field != null; @@ -270,8 +274,8 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { assert aClass != null; assertEquals("ppp.BadClass", aClass.getQualifiedName()); //lies in source - final VirtualFile vFile1 = myFile.getVirtualFile(); - final VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile(); + VirtualFile vFile1 = myFile.getVirtualFile(); + VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile(); assert vFile1 != null; assert vFile2 != null; assertEquals(vFile1.getParent(), vFile2.getParent()); @@ -281,4 +285,28 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_4); doTest(BASE_PATH + "/notAKeywords/Test.java", BASE_PATH + "/notAKeywords", false, false); } + + public void testPackageAndClassConflict11() throws Exception { + doTest(BASE_PATH + "/packageClassClash1/pkg/sub/Test.java", BASE_PATH + "/packageClassClash1", false, false); + } + + public void testPackageAndClassConflict12() throws Exception { + doTest(BASE_PATH + "/packageClassClash1/pkg/sub.java", BASE_PATH + "/packageClassClash1", false, false); + } + + public void testPackageAndClassConflict21() throws Exception { + doTest(BASE_PATH + "/packageClassClash2/pkg/sub/Test.java", BASE_PATH + "/packageClassClash2", false, false); + } + + public void testPackageAndClassConflict22() throws Exception { + doTest(BASE_PATH + "/packageClassClash2/pkg/Sub.java", BASE_PATH + "/packageClassClash2", false, false); + } + + public void testDefaultPackageAndClassConflict() throws Exception { + doTest(BASE_PATH + "/lang.java", false, false); + } + + public void testPackageObscuring() throws Exception { + doTest(BASE_PATH + "/packageObscuring/main/Main.java", BASE_PATH + "/packageObscuring", false, false); + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java index c716dbfab8c4..dfb7db246247 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java @@ -22,6 +22,7 @@ import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; /** * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up @@ -40,6 +41,7 @@ public class AmbiguousMethodCallTest extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index b1b0fcb3b5b0..678bb665de9e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -29,10 +29,12 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/genericsHighlighting"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UncheckedWarningLocalInspection(), new UnusedSymbolLocalInspection(), new UnusedImportLocalInspection()}; @@ -199,6 +201,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA67597() { doTest5(false); } public void testIDEA57539() { doTest5(false); } public void testIDEA67570() { doTest5(false); } + public void testIDEA99061() { doTest5(false); } + public void testIDEA99347() { doTest5(false); } + public void testIDEA86875() { doTest5(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java index 1c63f947f882..0c561dfdace5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java @@ -18,6 +18,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase { return JavaTestUtil.getJavaTestDataPath(); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java new file mode 100644 index 000000000000..02de38b62f5e --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.codeInsight.daemon; + +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.compiler.JavacQuirksInspection; +import com.intellij.codeInspection.redundantCast.RedundantCastInspection; +import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; +import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up + * For "heavyweight" tests use AdvHighlightingTest + */ +public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting6"; + + private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) { + setLanguageLevel(LanguageLevel.JDK_1_6); + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_6, myTestRootDisposable); + enableInspectionTools(classes); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + } + + private void doTest(boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos, Class<?>... classes) { + enableInspectionTools(classes); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); + } + + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + new UncheckedWarningLocalInspection(), + new JavacQuirksInspection(), + new RedundantCastInspection() + }; + } + + public void testJavacQuirks() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 9b72a23757f7..53710582edd5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -21,7 +21,6 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.defUse.DefUseInspection; -import com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.reference.RefElement; @@ -30,6 +29,9 @@ import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import org.jdom.Element; @@ -46,6 +48,8 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting7"; private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) { + setLanguageLevel(LanguageLevel.JDK_1_7); + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, myTestRootDisposable); enableInspectionTools(classes); doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } @@ -55,6 +59,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -93,7 +98,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testDiamondNeg12() throws Exception { doTest(false, false); } public void testDiamondNeg13() throws Exception { doTest(false, false); } public void testDiamondNeg14() throws Exception { doTest(false, false); } - public void testDiamondMisc() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_7); doTest(false, false); } + public void testDiamondMisc() throws Exception { doTest(false, false); } public void testHighlightInaccessibleFromClassModifierList() throws Exception { doTest(false, false); } public void testInnerInTypeArguments() throws Exception { doTest(false, false); } @@ -129,7 +134,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { } } - public void testJavacQuirks() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); } public void testNumericLiterals() throws Exception { doTest(false, false); } public void testMultiCatch() throws Exception { doTest(false, false); } public void testTryWithResources() throws Exception { doTest(false, false); } @@ -146,8 +150,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testExtendsBound() throws Exception { doTest(false, false); } public void testIDEA84533() throws Exception { doTest(false, false); } public void testClassLiteral() throws Exception { doTest(false, false); } - public void testExtensionMethods() throws Exception { doTest(false, false); } - public void testExtensionMethodSyntax() throws Exception { doTest(true, false, DeprecatedDefenderSyntaxInspection.class); } public void testMethodReferences() throws Exception { doTest(false, true, false); } public void testUsedMethodsByMethodReferences() throws Exception { doTest(true, true, false); } public void testLambdaExpressions() throws Exception { doTest(false, true, false); } @@ -157,9 +159,11 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testUncheckedWarningIDEA70620() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA60166() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA21432() throws Exception { doTest(true, false); } + public void testUncheckedWarningIDEA99357() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA26738() throws Exception { doTest(true, false); } - public void testDefaultMethodVisibility() throws Exception { doTest(true, false); } + public void testUncheckedWarningIDEA99536() throws Exception { doTest(true, false); } public void testEnclosingInstance() throws Exception { doTest(false, false); } public void testWrongArgsAndUnknownTypeParams() throws Exception { doTest(false, false); } public void testAmbiguousMethodCallIDEA97983() throws Exception { doTest(false, false); } + public void testAmbiguousMethodCallIDEA100314() throws Exception { doTest(false, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 99b1ebcd6de2..3f4c1500c9fd 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -73,6 +73,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { setLanguageLevel(LanguageLevel.JDK_1_4); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -360,4 +361,5 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { public void testThisBeforeSuper() throws Exception { doTest(false, false); } public void testExplicitConstructorInvocation() throws Exception { doTest(false, false); } public void testThisInInterface() throws Exception { doTest(false, false); } + public void testInnerClassConstantReference() throws Exception { doTest(false, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java index bac292138b6b..072726efe7fe 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java @@ -35,6 +35,7 @@ import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.openapi.vfs.encoding.EncodingProjectManager; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.nio.charset.Charset; import java.util.Collection; @@ -43,6 +44,7 @@ import java.util.List; public class LossyEncodingTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lossyEncoding"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new LossyEncodingInspection()}; @@ -50,7 +52,9 @@ public class LossyEncodingTest extends LightDaemonAnalyzerTestCase { public void testText() throws Exception { doTest("Text.txt"); - EncodingManager.getInstance().setEncoding(myVFile, Charset.forName("US-ASCII")); + Charset ascii = CharsetToolkit.forName("US-ASCII"); + EncodingManager.getInstance().setEncoding(myVFile, ascii); + assertEquals(ascii, myVFile.getCharset()); int start = myEditor.getCaretModel().getOffset(); type((char)0x445); type((char)0x438); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java index 4bdee1a1897e..6e68611e77ff 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java @@ -23,6 +23,7 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class SuppressWarningsTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting"; @@ -31,6 +32,7 @@ public class SuppressWarningsTest extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java new file mode 100644 index 000000000000..762814e6049c --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.codeInsight.daemon.lambda; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; +import org.jetbrains.annotations.NonNls; + +public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference"; + + public void testNestedCalls() throws Exception { + doTest(); + } + + public void testNestedCallsSameMethod() throws Exception { + doTest(); + } + + public void testChainedInference() throws Exception { + doTest(); + } + + public void testChainedInference1() throws Exception { + doTest(); + } + + public void testReturnStmt() throws Exception { + doTest(); + } + + public void testInferenceFromSiblings() throws Exception { + doTest(); + } + + private void doTest() throws Exception { + doTest(false); + } + + private void doTest(final boolean checkWarnings) throws Exception { + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_8, getTestRootDisposable()); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java new file mode 100644 index 000000000000..9778a6ae2886 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.codeInsight.daemon.lambda; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection; +import org.jetbrains.annotations.NonNls; + +public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods"; + + public void testStaticMethod() throws Exception { + doTest(); + } + + public void testNotInheritFromUnrelatedDefault() throws Exception { doTest(true, false); } + public void testDefaultMethodVisibility() throws Exception { doTest(true, false); } + public void testInheritUnrelatedDefaults() throws Exception { doTest(true, false); } + public void testExtensionMethods() throws Exception { doTest(false, false); } + public void testExtensionMethodSyntax() throws Exception { + enableInspectionTools(DeprecatedDefenderSyntaxInspection.class); + doTest(true, false); + } + + private void doTest() throws Exception { + doTest(false, false); + } + + private void doTest(final boolean checkWarnings, final boolean checkInfos) throws Exception { + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java index 6b9e16ae63e0..a88f0c8f1dc2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java @@ -16,11 +16,22 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/highlighting"; + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + }; + } + public void testStaticAccess() throws Exception { doTest(); } @@ -28,11 +39,11 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testEffectiveFinal() throws Exception { doTest(); } - + public void testReassignUsedVars() throws Exception { doTest(); } - + public void testLambdaContext() throws Exception { doTest(); } @@ -40,7 +51,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testReturnTypeCompatibility() throws Exception { doTest(); } - + public void testTypeArgsConsistency() throws Exception { doTest(); } @@ -55,7 +66,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testTypeArgsConsistencyWithoutParams() throws Exception { doTest(); - } + } public void testIncompatibleReturnTypes() throws Exception { doTest(); @@ -72,7 +83,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testInferFromTypeArgs() throws Exception { doTest(); } - + public void testAmbiguity1() throws Exception { doTest(); } @@ -80,7 +91,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void _testAmbiguity2() throws Exception { doTest(); } - + public void testAmbiguityVarargs() throws Exception { doTest(); } @@ -88,7 +99,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testAmbiguityRawGenerics() throws Exception { doTest(); } - + public void testDefaultMethod() throws Exception { doTest(); } @@ -104,7 +115,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testReturnTypeCompatibility1() throws Exception { doTest(); } - + public void testNoInferenceResult() throws Exception { doTest(); } @@ -128,7 +139,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testConditionalExpr() throws Exception { doTest(); } - + public void testIncompleteSubst() throws Exception { doTest(); } @@ -141,10 +152,14 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testUnhandledExceptions() throws Exception { + doTest(); + } + public void testReturnValue() throws Exception { doTest(); } - + public void testAlreadyUsedParamName() throws Exception { doTest(); } @@ -177,7 +192,27 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIntersectionTypeInCast() throws Exception { + doTest(); + } + + public void testAmbiguitySpecificReturn() throws Exception { + doTest(true); + } + + public void testFunctionalInterfaceAnnotation() throws Exception { + doTest(); + } + + public void testAmbiguityReturnValueResolution() throws Exception { + doTest(); + } + private void doTest() throws Exception { - doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); + doTest(false); + } + + private void doTest(final boolean checkWarnings) throws Exception { + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java index ec1c083f372a..f93f7ac9025c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java @@ -41,6 +41,10 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testFormalParamsWithWildcards() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java index 5b38de1fb98e..997e0d563f1c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java @@ -22,10 +22,12 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/methodRef"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -153,6 +155,22 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(true); } + public void testIntersectionTypeInCast() throws Exception { + doTest(false); + } + + public void testUnhandledExceptions() throws Exception { + doTest(); + } + + public void testCapturedWildcards() throws Exception { + doTest(); + } + + public void testConstructorNonAbstractAbstractExpected() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java index 59683ae56fcc..f285ee489727 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java @@ -6,6 +6,7 @@ import com.intellij.codeInspection.nullable.NullableStuffInspection; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiMethod; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class AnnotateMethodTest extends LightQuickFix15TestCase { private boolean myMustBeAvailableAfterInvoke; @@ -15,6 +16,7 @@ public class AnnotateMethodTest extends LightQuickFix15TestCase { return "/codeInsight/daemonCodeAnalyzer/quickFix/annotateMethod"; } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new NullableStuffInspection(){ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java index 892a92bc7569..c21eac60b308 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeLambdaInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Anonymous2LambdaInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java index e7fb3bedbf44..402409c6f6c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Anonymous2MethodReferenceInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java index 98e438b71345..db262aa3696c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java @@ -1,8 +1,13 @@ package com.intellij.codeInsight.daemon.quickFix; -public class ChangeNewOperatorTypeTest extends LightQuickFix15TestCase { +import com.intellij.pom.java.LanguageLevel; - public void test() throws Exception { doAllTests(); } +public class ChangeNewOperatorTypeTest extends LightQuickFixTestCase { + + public void test() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); + doAllTests(); + } @Override protected String getBasePath() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java index b90ee60adde4..82fcd0e2e466 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2013 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. + */ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; @@ -6,10 +21,9 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager; * @author ven */ public class CreateClassFromNewTest extends LightQuickFixTestCase { - public void test() throws Exception { CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_CLASS_LBRACE = true; - doAllTests(); + doAllTests(); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java index 65c09a604bc5..94f8a9c65ce8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java @@ -2,11 +2,13 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; /** * @author cdr */ public class CreateConstructorParameterFromFieldTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java index 902f0ff881d9..7b53bd1505ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java @@ -1,13 +1,30 @@ +/* + * Copyright 2000-2013 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. + */ package com.intellij.codeInsight.daemon.quickFix; /** * @author yole */ public class CreateInnerClassFromNewTest extends LightQuickFixTestCase { - public void test() throws Exception { doAllTests(); } + public void test() throws Exception { + doAllTests(); + } @Override protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew"; } -}
\ No newline at end of file +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java index 3ad579bdf7e8..393f5208cbb9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java @@ -3,7 +3,7 @@ package com.intellij.codeInsight.daemon.quickFix; /** * @author ven */ -public class CreateMethodFromUsageTest extends LightQuickFix15TestCase { +public class CreateMethodFromUsageTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java index a2fea9938009..0895fd970d43 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java @@ -24,6 +24,7 @@ public class EmptyIntentionInspectionQuickFixTest extends LightQuickFixTestCase{ return "/codeInsight/daemonCodeAnalyzer/quickFix/emptyIntention"; } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DefUseInspection(), new LocalInspectionTool() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java index e45590611ea0..3da506a90583 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java @@ -4,9 +4,11 @@ import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; +import org.jetbrains.annotations.NotNull; public class EnableOptimizeImportsOnTheFlyTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UnusedImportLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java index 8da26aa6bb27..3cfb844aaaee 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java @@ -7,8 +7,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class FixAllQuickfixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java index 1d0d11432ad4..9907b329e760 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java @@ -2,10 +2,12 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import org.jetbrains.annotations.NotNull; public class GenerifyFileTest extends LightQuickFixAvailabilityTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] {new UncheckedWarningLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java index 2d6cb90a87bf..d55341d7af7e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java @@ -4,6 +4,7 @@ import com.intellij.codeInsight.daemon.quickFix.LightQuickFix15TestCase; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.i18n.I18nInspection; import com.intellij.openapi.util.Comparing; +import org.jetbrains.annotations.NotNull; /** * @author yole @@ -11,6 +12,7 @@ import com.intellij.openapi.util.Comparing; public class I18nQuickFixTest extends LightQuickFix15TestCase { private boolean myMustBeAvailableAfterInvoke; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new I18nInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java index 4dadabcca79a..4b3c868eabce 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java @@ -2,8 +2,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class InitializeFinalFieldInConstructorFixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java index 6c40bf65b1db..17e729ebee42 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java @@ -12,9 +12,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection; +import org.jetbrains.annotations.NotNull; public class JavadocInspectionQuickFixTest extends LightQuickFix15TestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { final JavaDocLocalInspection javaDocLocalInspection = new JavaDocLocalInspection(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java index dfed9a8c0fd9..af915d61836b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LambdaCanBeMethReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Lambda2MethodReferenceInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java index a97e7ae4bfb4..457d783a7bb4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java @@ -15,8 +15,15 @@ */ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + /** * @author ven */ public abstract class LightQuickFix15TestCase extends LightQuickFixTestCase { + @Override + protected void doAllTests() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_5); + super.doAllTests(); + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java index c0eaeb8c1352..6c578808307a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java @@ -1,5 +1,7 @@ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + public class ModifierTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } @@ -7,4 +9,9 @@ public class ModifierTest extends LightQuickFixTestCase { protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/modifier"; } + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java index 9199e149583a..b5ed93893702 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection; +import org.jetbrains.annotations.NotNull; public class RedundantLambdaCodeBlockInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java index 248fc1e0e32b..f341e1d6363c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; public class RemoveRedundantUncheckedSuppressionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { final PossibleHeapPollutionVarargsInspection varargsInspection = new PossibleHeapPollutionVarargsInspection(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java index fade977647a2..fd6afa2fbadf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java @@ -3,11 +3,13 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class RemoveUnusedParameterTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java index f1821a6d5e3b..41b0863ac461 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java @@ -3,8 +3,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class RemoveUnusedVariableTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java index 6419088e9583..3692eecbf886 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java @@ -23,8 +23,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; import com.intellij.codeInspection.nullable.NullableStuffInspection; +import org.jetbrains.annotations.NotNull; public class ReplaceWithTernaryOperatorTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DataFlowInspection(), new NullableStuffInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java index 8b7212e527d7..6b4605b2565e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection; +import org.jetbrains.annotations.NotNull; public class SafeVarargsCanBeUsedTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java index 76136b5fb8ef..bd3f7a0c7731 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java @@ -17,10 +17,12 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; //todo test3 should be checked if it compiles - as now javac infers Object instead of String?! public class Simplify2DiamondInspectionsTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java index 9931d17a85bc..13ebabffecf8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java @@ -26,6 +26,7 @@ import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspec import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration; import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class Suppress15InspectionsTest extends LightQuickFixTestCase { @@ -35,6 +36,7 @@ public class Suppress15InspectionsTest extends LightQuickFixTestCase { enableInspectionTool(new GlobalInspectionToolWrapper(new UnusedParametersInspection())); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java index c096ff5a6ac0..4f3a1bbef42a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java @@ -5,6 +5,7 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NotNull; public class SuppressLocalInspectionTest extends LightQuickFixTestCase { @@ -15,6 +16,7 @@ public class SuppressLocalInspectionTest extends LightQuickFixTestCase { LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_3); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new LocalCanBeFinal()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java index 04a6a0567eb2..78ecf4f3113b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java @@ -11,6 +11,7 @@ import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NotNull; public class SuppressNonInspectionsTest extends LightQuickFixTestCase { @@ -21,6 +22,7 @@ public class SuppressNonInspectionsTest extends LightQuickFixTestCase { LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_3); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java index 9a4a1699ccd5..19ed7fc148c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java @@ -22,8 +22,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; +import org.jetbrains.annotations.NotNull; public class SurroundWithIfFixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DataFlowInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java index 2f940e97197a..6ee5908adc68 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java @@ -16,7 +16,7 @@ package com.intellij.codeInsight.daemon.quickFix; -public class VariableTypeFromCallTest extends LightQuickFix15TestCase { +public class VariableTypeFromCallTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java new file mode 100644 index 000000000000..f5bd537a6788 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.codeInsight.documentation; + +import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.javadoc.JavaDocExternalFilter; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.testFramework.LightCodeInsightTestCase; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; + +/** + * @author Denis Zhdanov + * @since 1/15/13 7:26 PM + */ +public class RefConvertorsTest extends LightCodeInsightTestCase { + + private File myExtractedImagesDir; + + @Override + protected void setUp() throws Exception { + super.setUp(); + String tempDirectory = FileUtilRt.getTempDirectory(); + myExtractedImagesDir = new File(tempDirectory, AbstractExternalFilter.QUICK_DOC_DIR_NAME); + } + + @Override + protected void tearDown() throws Exception { + FileUtilRt.delete(myExtractedImagesDir); + super.tearDown(); + } + + public void testImgInsideJar() throws Exception { + String imgJarName = "test-img"; + File imgJar = new File(myExtractedImagesDir, imgJarName + ".jar"); + boolean exist = FileUtil.createIfDoesntExist(imgJar); + assertTrue(exist); + + JarOutputStream out = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(imgJar))); + try { + out.putNextEntry(new JarEntry("resources/inherit.gif")); + FileInputStream fIn = new FileInputStream(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/documentation/inherit.gif"); + try { + FileUtil.copy(fIn, out); + } + finally { + fIn.close(); + } + } + finally { + out.close(); + } + + String textBefore = + "<HTML>" + + "java.lang.Object\n" + + " <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + + "</HTML>"; + + File f = new File(myExtractedImagesDir, imgJarName); + f = new File(f, "resources"); + File extractedImgFile = new File(f, "inherit.gif"); + String expectedTextAfter = String.format( + "<HTML>" + + "java.lang.Object\n" + + " <IMG SRC=\"%s%s\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + + "</HTML>", + LocalFileSystem.PROTOCOL_PREFIX, + extractedImgFile.getAbsolutePath()); + + JavaDocExternalFilter filter = new JavaDocExternalFilter(getProject()); + String textAfter = filter.correctRefs( + String.format("%s%s!/org/bouncycastle/asn1/BERSequenceParser.html", JarFileSystem.PROTOCOL_PREFIX, imgJar.getAbsolutePath()), + textBefore + ); + assertEquals(expectedTextAfter, textAfter); + assertTrue(extractedImgFile.isFile()); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java index c6454a1e4ce0..c9653c3eabdb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java @@ -10,51 +10,45 @@ import com.intellij.testFramework.LightCodeInsightTestCase; public class SplitIfActionTest extends LightCodeInsightTestCase { public void test1() throws Exception { CodeStyleSettingsManager.getSettings(getProject()).ELSE_ON_NEW_LINE= true; - configureByFile("/codeInsight/splitIfAction/before1.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after1.java"); + doTest(); } public void test2() throws Exception { - configureByFile("/codeInsight/splitIfAction/before2.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after2.java"); + doTest(); } public void test3() throws Exception { - configureByFile("/codeInsight/splitIfAction/before3.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after3.java"); + doTest(); } public void test4() throws Exception { - configureByFile("/codeInsight/splitIfAction/before4.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after4.java"); + doTest(); } public void test5() throws Exception { - configureByFile("/codeInsight/splitIfAction/before5.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after5.java"); + doTest(); } - public void test6() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeParenthesis.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/afterParenthesis.java"); + public void testParenthesis() throws Exception { + doTest(); } - public void test7() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeOrParenthesis.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/afterOrParenthesis.java"); + public void testOrParenthesis() throws Exception { + doTest(); } public void testComment() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeComment.java"); + doTest(); + } + + public void testWithoutSpaces() throws Exception { + doTest(); + } + + private void doTest() throws Exception { + configureByFile("/codeInsight/splitIfAction/before" + getTestName(false)+ ".java"); perform(); - checkResultByFile("/codeInsight/splitIfAction/afterComment.java"); + checkResultByFile("/codeInsight/splitIfAction/after" + getTestName(false) + ".java"); } public void test8() throws Exception { @@ -64,7 +58,6 @@ public class SplitIfActionTest extends LightCodeInsightTestCase { } - private void perform() throws Exception { SplitIfAction action = new SplitIfAction(); assertTrue(action.isAvailable(getProject(), getEditor(), getFile())); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index 666709af1083..e6595b98b11a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -58,6 +58,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { public void testInitializerWithNew() throws Exception { doTestField(); } + + public void testInitializerWithReference() throws Exception { + doTestField(); + } private void doTestField() throws Exception { PsiClass psiClass = getTestClass(); @@ -80,6 +84,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html"); String htmlText = FileUtil.loadFile(htmlPath); String docInfo = new JavaDocInfoGenerator(getProject(), field).generateDocInfo(null); + assertNotNull(docInfo); assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim())); } @@ -90,6 +95,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { final String info = new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null); String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html")); + assertNotNull(info); assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(info.trim())); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index bd3eb0a5ac68..d739f69d91c8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -178,7 +178,7 @@ class Foo { assert !state } - public void "_test non-imported classes in className macro"() { + public void "test non-imported classes in className macro"() { myFixture.addClass('package bar; public class Bar {}') myFixture.configureByText 'a.java', ''' class Foo { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java deleted file mode 100644 index 600b822e2780..000000000000 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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. - */ -package com.intellij.codeInspection; - -import com.intellij.JavaTestUtil; -import com.intellij.codeInsight.NullableNotNullManager; -import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.util.Disposer; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; -import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; - -/** - * @author peter - */ -public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCase { - @Override - protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) { - moduleBuilder.setLanguageLevel(LanguageLevel.HIGHEST); - } - - @Override - protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; - } - - private void doTest() { - final DataFlowInspection inspection = new DataFlowInspection(); - inspection.SUGGEST_NULLABLE_ANNOTATIONS = true; - myFixture.enableInspections(inspection); - myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); - } - - public void testTryInAnonymous() throws Throwable { doTest(); } - public void testNullableAnonymousMethod() throws Throwable { doTest(); } - public void testNullableAnonymousParameter() throws Throwable { doTest(); } - public void testNullableAnonymousVolatile() throws Throwable { doTest(); } - public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); } - public void testLocalClass() throws Throwable { doTest(); } - - public void testFieldInAnonymous() throws Throwable { doTest(); } - public void testFieldInitializerInAnonymous() throws Throwable { doTest(); } - public void testNullableField() throws Throwable { doTest(); } - public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); } - public void testAnnReport() throws Throwable { doTest(); } - - public void testBigMethodNotComplex() throws Throwable { doTest(); } - public void testBuildRegexpNotComplex() throws Throwable { doTest(); } - public void testTernaryInWhileNotComplex() throws Throwable { doTest(); } - public void testTryCatchInForNotComplex() throws Throwable { doTest(); } - public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); } - - public void testGeneratedEquals() throws Throwable { doTest(); } - - public void testIDEA84489() throws Throwable { doTest(); } - public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); } - public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); } - - public void testBoxing128() throws Throwable { doTest(); } - public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); } - public void testMultiCatch() throws Throwable { doTest(); } - public void testContinueFlushesLoopVariable() throws Throwable { doTest(); } - - public void testEqualsNotNull() throws Throwable { doTest(); } - public void testVisitFinallyOnce() throws Throwable { doTest(); } - public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); } - public void testEqualsEnumConstant() throws Throwable { doTest(); } - public void testEqualsConstant() throws Throwable { doTest(); } - public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } - public void testGreaterIsNotEquals() throws Throwable { doTest(); } - public void testNotGreaterIsNotEquals() throws Throwable { doTest(); } - - public void testChainedFinalFieldsDfa() throws Throwable { doTest(); } - public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); } - public void testThisFieldGetters() throws Throwable { doTest(); } - public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); } - - public void testAssigningUnknownToNullable() throws Throwable { doTest(); } - public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); } - - public void testSynchronizingOnNullable() throws Throwable { doTest(); } - public void testReturningNullFromVoidMethod() throws Throwable { doTest(); } - - public void testCatchRuntimeException() throws Throwable { doTest(); } - - public void testAssertFailInCatch() throws Throwable { - myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}"); - doTest(); - } - - public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); } - - public void testPassingNullableIntoVararg() throws Throwable { doTest(); } - public void testEqualsImpliesNotNull() throws Throwable { doTest(); } - - public void testAnnotatedTypeParameters() throws Throwable { - setupCustomAnnotations(); - doTest(); - } - - private void setupCustomAnnotations() { - myFixture.addClass("package foo; public @interface Nullable {}"); - myFixture.addClass("package foo; public @interface NotNull {}"); - final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject()); - nnnManager.setNotNulls("foo.NotNull"); - nnnManager.setNullables("foo.Nullable"); - Disposer.register(myTestRootDisposable, new Disposable() { - @Override - public void dispose() { - nnnManager.setNotNulls(); - nnnManager.setNullables(); - } - }); - } - - public void testSkipAssertions() { - final DataFlowInspection inspection = new DataFlowInspection(); - inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true; - myFixture.enableInspections(inspection); - myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); - } - - public void testCheckFieldInitializers() { - doTest(); - } - - public void testConstantDoubleComparisons() { doTest(); } - - public void _testMutableNullableFieldsTreatment() { doTest(); } - public void _testMutableVolatileNullableFieldsTreatment() { doTest(); } - public void testMutableNotAnnotatedFieldsTreatment() { doTest(); } - - public void testMethodCallFlushesField() { doTest(); } - public void testUnknownFloatMayBeNaN() { doTest(); } - public void testLastConstantConditionInAnd() { doTest(); } - - public void testTransientFinalField() { doTest(); } - public void _testSymmetricUncheckedCast() { doTest(); } - public void testNullCheckDoesntAffectUncheckedCast() { doTest(); } - - public void testNullableForeachVariable() { - setupCustomAnnotations(); - doTest(); - } - -} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index 480d955128bc..56fa8115d95f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -15,22 +15,147 @@ */ package com.intellij.codeInspection; -import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.NullableNotNullManager; import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import org.jetbrains.annotations.NonNls; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.util.Disposer; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -public class DataFlowInspectionTest extends LightDaemonAnalyzerTestCase { - @NonNls static final String BASE_PATH = "/inspection/dataFlow"; +/** + * @author peter + */ +public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { + + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; + } private void doTest() { - doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false); + final DataFlowInspection inspection = new DataFlowInspection(); + inspection.SUGGEST_NULLABLE_ANNOTATIONS = true; + myFixture.enableInspections(inspection); + myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); } - @Override - protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{new DataFlowInspection()}; + public void testTryInAnonymous() throws Throwable { doTest(); } + public void testNullableAnonymousMethod() throws Throwable { doTest(); } + public void testNullableAnonymousParameter() throws Throwable { doTest(); } + public void testNullableAnonymousVolatile() throws Throwable { doTest(); } + public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); } + public void testLocalClass() throws Throwable { doTest(); } + + public void testFieldInAnonymous() throws Throwable { doTest(); } + public void testFieldInitializerInAnonymous() throws Throwable { doTest(); } + public void testNullableField() throws Throwable { doTest(); } + public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); } + public void testAnnReport() throws Throwable { doTest(); } + + public void testBigMethodNotComplex() throws Throwable { doTest(); } + public void testBuildRegexpNotComplex() throws Throwable { doTest(); } + public void testTernaryInWhileNotComplex() throws Throwable { doTest(); } + public void testTryCatchInForNotComplex() throws Throwable { doTest(); } + public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); } + + public void testGeneratedEquals() throws Throwable { doTest(); } + + public void testIDEA84489() throws Throwable { doTest(); } + public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); } + public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); } + + public void testBoxing128() throws Throwable { doTest(); } + public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); } + public void testMultiCatch() throws Throwable { doTest(); } + public void testContinueFlushesLoopVariable() throws Throwable { doTest(); } + + public void testEqualsNotNull() throws Throwable { doTest(); } + public void testVisitFinallyOnce() throws Throwable { doTest(); } + public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); } + public void testEqualsEnumConstant() throws Throwable { doTest(); } + public void testEqualsConstant() throws Throwable { doTest(); } + public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } + public void testGreaterIsNotEquals() throws Throwable { doTest(); } + public void testNotGreaterIsNotEquals() throws Throwable { doTest(); } + + public void testChainedFinalFieldsDfa() throws Throwable { doTest(); } + public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); } + public void testThisFieldGetters() throws Throwable { doTest(); } + public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); } + + public void testAssigningUnknownToNullable() throws Throwable { doTest(); } + public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); } + + public void testSynchronizingOnNullable() throws Throwable { doTest(); } + public void testReturningNullFromVoidMethod() throws Throwable { doTest(); } + + public void testCatchRuntimeException() throws Throwable { doTest(); } + + public void testAssertFailInCatch() throws Throwable { + myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}"); + doTest(); + } + + public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); } + + public void testPassingNullableIntoVararg() throws Throwable { doTest(); } + public void testEqualsImpliesNotNull() throws Throwable { doTest(); } + public void testEffectivelyUnqualified() throws Throwable { doTest(); } + + public void testAnnotatedTypeParameters() throws Throwable { + setupCustomAnnotations(); + doTest(); + } + + private void setupCustomAnnotations() { + myFixture.addClass("package foo; public @interface Nullable {}"); + myFixture.addClass("package foo; public @interface NotNull {}"); + final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject()); + nnnManager.setNotNulls("foo.NotNull"); + nnnManager.setNullables("foo.Nullable"); + Disposer.register(myTestRootDisposable, new Disposable() { + @Override + public void dispose() { + nnnManager.setNotNulls(); + nnnManager.setNullables(); + } + }); + } + + public void testSkipAssertions() { + final DataFlowInspection inspection = new DataFlowInspection(); + inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true; + myFixture.enableInspections(inspection); + myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); + } + + public void testCheckFieldInitializers() { + doTest(); + } + + public void testConstantDoubleComparisons() { doTest(); } + + public void testMutableNullableFieldsTreatment() { doTest(); } + public void testMutableVolatileNullableFieldsTreatment() { doTest(); } + public void testMutableNotAnnotatedFieldsTreatment() { doTest(); } + + public void testMethodCallFlushesField() { doTest(); } + public void testUnknownFloatMayBeNaN() { doTest(); } + public void testLastConstantConditionInAnd() { doTest(); } + + public void testTransientFinalField() { doTest(); } + public void _testSymmetricUncheckedCast() { doTest(); } + public void testNullCheckDoesntAffectUncheckedCast() { doTest(); } + + public void testNullableForeachVariable() { + setupCustomAnnotations(); + doTest(); } public void testTryWithResourcesNullability() { doTest(); } public void testTryWithResourcesInstanceOf() { doTest(); } + public void testOmnipresentExceptions() { doTest(); } + + public void testEqualsHasNoSideEffects() { doTest(); } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java index 07d2bf4fc99e..480a910cc394 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java @@ -23,7 +23,6 @@ public class DataFlowInspectionTestSuite { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(DataFlowInspectionTest.class); - suite.addTestSuite(DataFlowInspectionFixtureTest.class); suite.addTestSuite(DataFlowInspectionAncientTest.class); suite.addTestSuite(SliceTreeTest.class); return suite; diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java index dab2baf370b2..872ae1277119 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java @@ -21,7 +21,6 @@ import com.intellij.codeInsight.CodeInsightTestCase; import com.intellij.codeInspection.actions.RunInspectionIntention; import com.intellij.codeInspection.ex.*; import com.intellij.codeInspection.visibility.VisibilityInspection; -import com.intellij.profile.codeInspection.InspectionProfileManager; import java.util.ArrayList; import java.util.Arrays; @@ -56,7 +55,7 @@ public class GlobalInspectionContextTest extends CodeInsightTestCase { } public void testRunInspectionContext() throws Exception { - InspectionProfile profile = (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile(); + InspectionProfile profile = new InspectionProfileImpl("foo"); InspectionProfileEntry[] tools = profile.getInspectionTools(null); for (InspectionProfileEntry tool : tools) { if (!tool.isEnabledByDefault()) { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java index 409426b19c0b..b8ad3a04614d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.dataFlow.DataFlowInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.ex.*; import com.intellij.openapi.util.JDOMUtil; @@ -254,7 +255,8 @@ public class InspectionProfileTest extends LightIdeaTestCase { assertEquals(0, countInitializedTools(profile)); InspectionProfileEntry[] tools = profile.getInspectionTools(null); assertTrue(tools.length > 0); - InspectionProfileEntry tool = tools[0]; + InspectionProfileEntry tool = profile.getInspectionTool(new DataFlowInspection().getShortName()); + assertNotNull(tool); String id = tool.getShortName(); System.out.println(id); if (profile.isToolEnabled(HighlightDisplayKey.findById(id))) { @@ -263,9 +265,15 @@ public class InspectionProfileTest extends LightIdeaTestCase { else { profile.enableTool(id); } + assertEquals(0, countInitializedTools(profile)); profile.writeExternal(new Element("profile")); List<InspectionProfileEntry> initializedTools = getInitializedTools(profile); - assertEquals(initializedTools.toString(), 1, initializedTools.size()); + if (initializedTools.size() != 1) { + for (InspectionProfileEntry initializedTool : initializedTools) { + System.out.println(initializedTool.getShortName()); + } + fail(); + } } public void testInspectionInitializationForSerialization() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java index 01d2908f7c0c..ab3a853a96bb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java @@ -23,6 +23,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; import com.intellij.testFramework.LightIdeaTestCase; +import org.jetbrains.annotations.NotNull; /** * @author Dmitry Avdeev @@ -46,19 +47,65 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase { panel.reset(); assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 0, InspectionProfileTest.countInitializedTools(model)); - LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper)model.getInspectionTool(myInspection.getShortName()); - assert wrapper != null; - JavaDocLocalInspection tool = (JavaDocLocalInspection)wrapper.getTool(); + JavaDocLocalInspection tool = getInspection(model); assertEquals("", tool.myAdditionalJavadocTags); tool.myAdditionalJavadocTags = "foo"; model.setModified(true); panel.apply(); assertEquals(1, InspectionProfileTest.countInitializedTools(model)); - wrapper = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName()); - assert wrapper != null; - tool = (JavaDocLocalInspection)wrapper.getTool(); - assertEquals("foo", tool.myAdditionalJavadocTags); + assertEquals("foo", getInspection(profile).myAdditionalJavadocTags); + } + + public void testModifyInstantiatedTool() throws Exception { + Project project = ProjectManager.getInstance().getDefaultProject(); + InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); + InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE); + profile.initInspectionTools(project); + assertEquals(0, InspectionProfileTest.countInitializedTools(profile)); + + JavaDocLocalInspection originalTool = getInspection(profile); + originalTool.myAdditionalJavadocTags = "foo"; + + InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel(); + + SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model); + panel.setVisible(true); + panel.reset(); + assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 1, InspectionProfileTest.countInitializedTools(model)); + + JavaDocLocalInspection copyTool = getInspection(model); + copyTool.myAdditionalJavadocTags = "bar"; + + model.setModified(true); + panel.apply(); + assertEquals(1, InspectionProfileTest.countInitializedTools(model)); + + assertEquals("bar", getInspection(profile).myAdditionalJavadocTags); + } + + public void testDoNotChangeSettingsOnCancel() throws Exception { + Project project = ProjectManager.getInstance().getDefaultProject(); + InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); + InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE); + profile.initInspectionTools(project); + assertEquals(0, InspectionProfileTest.countInitializedTools(profile)); + + JavaDocLocalInspection originalTool = getInspection(profile); + assertEquals("", originalTool.myAdditionalJavadocTags); + + InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel(); + JavaDocLocalInspection copyTool = getInspection(model); + copyTool.myAdditionalJavadocTags = "foo"; + // this change IS NOT COMMITTED + + assertEquals("", getInspection(profile).myAdditionalJavadocTags); + } + + private JavaDocLocalInspection getInspection(InspectionProfileImpl profile) { + LocalInspectionToolWrapper original = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName()); + assert original != null; + return (JavaDocLocalInspection)original.getTool(); } @Override @@ -75,6 +122,7 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase { private final JavaDocLocalInspection myInspection = new JavaDocLocalInspection(); + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] {myInspection}; diff --git a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java index b1639bc4b4be..113211720e39 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -52,6 +52,17 @@ public class JavaLexerTest extends LexerTestCase { "DOUBLE_LITERAL ('3.14')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('1e-9d')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('1e137')"); + + doTest(". e0 x1 ax .e .p 08 .0e .0f", + "DOT ('.')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('e0')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('x1')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('ax')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('e')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('p')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('08')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('.0e')\nWHITE_SPACE (' ')\n" + + "FLOAT_LITERAL ('.0f')"); } public void testTigerNumericLiterals() { @@ -66,6 +77,9 @@ public class JavaLexerTest extends LexerTestCase { "DOUBLE_LITERAL ('0xab.P12')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('0x.abcP123d')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('0xabc.defP1234D')"); + + doTest("p0", + "IDENTIFIER ('p0')"); } public void testCoinNumericLiterals() { @@ -116,15 +130,18 @@ public class JavaLexerTest extends LexerTestCase { } public void testMalformedCoinLiterals() { - doTest("0_ _1 0_8 0x_f 0b_1 0B2 0x1.0_p-1 1.0e_1022", - "INTEGER_LITERAL ('0')\nIDENTIFIER ('_')\nWHITE_SPACE (' ')\n" + + doTest("_1 _b ._ 0_ 0_8 0x_f 0b_1 0B2 0x1.0_p-1 1.0e_1022 0._1", "IDENTIFIER ('_1')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0')\nIDENTIFIER ('_8')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0x')\nIDENTIFIER ('_f')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0b')\nIDENTIFIER ('_1')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0B')\nINTEGER_LITERAL ('2')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0x1')\nDOUBLE_LITERAL ('.0')\nIDENTIFIER ('_p')\nMINUS ('-')\nINTEGER_LITERAL ('1')\nWHITE_SPACE (' ')\n" + - "DOUBLE_LITERAL ('1.0e')\nIDENTIFIER ('_1022')"); + "IDENTIFIER ('_b')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('_')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0_')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0_8')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0x_f')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0b_1')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0B2')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('0x1.0_p-1')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('1.0e_1022')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('0._1')"); } public void testMalformedOperators() { diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java index 88151e01c8fd..072e6b3ff52a 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java @@ -168,6 +168,8 @@ public class DirectoryIndexTest extends IdeaTestCase { }); myIndex = DirectoryIndex.getInstance(myProject); + // to not interfere with previous test firing vfs events + VirtualFileManager.getInstance().syncRefresh(); } private CompilerProjectExtension getCompilerProjectExtension() { diff --git a/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java new file mode 100644 index 000000000000..1cd630ccc2db --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.psi; + +import com.intellij.core.CoreJavaFileManager; +import com.intellij.ide.highlighter.JavaFileType; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.PsiTestCase; +import com.intellij.testFramework.PsiTestUtil; + + +public class CoreJavaFileManagerTest extends PsiTestCase { + + public void testNotNullInnerClass() throws Exception { + VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete); + VirtualFile pkg = root.createChildDirectory(this, "foo"); + PsiDirectory dir = myPsiManager.findDirectory(pkg); + assertNotNull(dir); + String text = "package foo;\n\n" + + "public class Nested {\n" + + "public class InnerGeneral {}\n" + + "public class Inner$ {}\n" + + "\n" + + "public Inner$ inner() {\n" + + " return new Inner$();\n" + + "}\n" + + "\n" + + "}"; + PsiElement created = dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText("Nested.java", JavaFileType.INSTANCE, text)); + + GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); + CoreJavaFileManager manager = new CoreJavaFileManager(myPsiManager); + manager.addToClasspath(root); + + PsiClass clazz = manager.findClass("foo.Nested", scope); + assertNotNull(clazz); + + PsiClass clazzInnerGeneral = manager.findClass("foo.Nested.InnerGeneral", scope); + assertNotNull(clazzInnerGeneral); + + PsiClass clazzInner$ = manager.findClass("foo.Nested.Inner$", scope); + assertNotNull(clazzInner$); + + PsiClass clazzInner$Wrong1 = manager.findClass("foo.Nested.Inner$X", scope); + assertNull(clazzInner$Wrong1); + + PsiClass clazzInner$Wrong2 = manager.findClass("foo.Nested.Inner$$X", scope); + assertNull(clazzInner$Wrong2); + + PsiClass clazzInner$Wrong3 = manager.findClass("foo.Nested.Inner$$", scope); + assertNull(clazzInner$Wrong3); + } + +} diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java index 49fcdd73f39e..c1d20b4481c5 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -41,6 +41,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; public class PsiConcurrencyStressTest extends PsiTestCase { + private static final boolean SKIP = "true".equalsIgnoreCase(System.getProperty("skip.psi.concurrency.test")); + + @Override + public void runBare() throws Throwable { + if (!SKIP) { + super.runBare(); + } + } @Override protected void setUp() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy index 2d0830edcbd5..b9a5732b83c6 100644 --- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy @@ -61,10 +61,10 @@ class StubAstSwitchTest extends LightCodeInsightFixtureTestCase { } public void "test traversing PSI and switching concurrently"() { - int count = 1000 + int count = 100 List<PsiClass> classList = (0..<count).collect { myFixture.addClass("class Foo$it { " + - (0..<10).collect { "void foo$it(int i, boolean b, Object o) {}" }.join("\n") + + (0..<100).collect { "void foo$it(int i, boolean b, Object o) {}" }.join("\n") + " }") } CountDownLatch latch = new CountDownLatch(count) diff --git a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java index 1ae10fadaeb1..1613f6344e08 100644 --- a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java @@ -454,6 +454,6 @@ public class TypesTest extends GenericsTestCase { assertEquals(PsiType.INT, plusBytePrefix.getType()); final PsiStatement declaration = factory.createStatementFromText("Byte b = 1;", null); final PsiExpression plusPlusPostfix = factory.createExpressionFromText("b++", declaration); - assertEquals(PsiType.BYTE, plusPlusPostfix.getType()); + assertEquals(PsiType.BYTE.getBoxedType(declaration), plusPlusPostfix.getType()); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy index 2c24ba632bb7..36d6b534c67d 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy @@ -131,8 +131,8 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { assert fooInheritors(m1) == [fooMethod(other0), fooMethod(b1)] as Set } - private PsiMethod fooMethod(PsiClass c) { c.findMethodsByName('foo', false)[0] } - private Set<PsiMethod> fooInheritors(PsiClass c) { OverridingMethodsSearch.search(fooMethod(c)).findAll() as Set } + private static PsiMethod fooMethod(PsiClass c) { c.findMethodsByName('foo', false)[0] } + private static Set<PsiMethod> fooInheritors(PsiClass c) { OverridingMethodsSearch.search(fooMethod(c)).findAll() as Set } public void "test do not parse not stubbed sources in class jars"() { def lib = LocalFileSystem.getInstance().refreshAndFindFileByPath(PathManagerEx.getTestDataPath() + "/libResolve/classesAndSources") @@ -150,6 +150,9 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten() PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' }) assert !javaSrc.node.parsed + + assert pkg.containsClassNamed('LibraryClass') + assert !javaSrc.node.parsed } } diff --git a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java index 01fb2d1e512e..fe43ca04330e 100644 --- a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java @@ -19,13 +19,13 @@ import com.intellij.JavaTestUtil; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.todo.TodoConfiguration; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.projectRoots.impl.ProjectRootUtil; -import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -284,26 +284,7 @@ public class UpdateCacheTest extends PsiTestCase{ PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to update caches - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - final ModifiableRootModel rootModel1 = ModuleRootManager.getInstance(myModule).getModifiableModel(); - final ContentEntry[] content1 = rootModel1.getContentEntries(); - contentLoop: - for (ContentEntry contentEntry : content1) { - if (root.equals(contentEntry.getFile())) { - final ExcludeFolder[] excludeFolders = contentEntry.getExcludeFolders(); - for (ExcludeFolder excludeFolder : excludeFolders) { - if (dir.equals(excludeFolder.getFile())) { - contentEntry.removeExcludeFolder(excludeFolder); - break contentLoop; - } - } - } - } - rootModel1.commit(); - } - }); - + PsiTestUtil.removeExcludedRoot(myModule, dir); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); assertNotNull(exceptionClass); @@ -338,9 +319,8 @@ public class UpdateCacheTest extends PsiTestCase{ checkTodos(new String[]{"2.java", "New.java"}); } - public void testRemoveSourceRoot() throws Exception{ - final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule); - final VirtualFile root = rootManager.getContentRoots()[0]; + public void testRemoveSourceRoot() { + final VirtualFile root = ModuleRootManager.getInstance(myModule).getContentRoots()[0]; PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to initialize caches @@ -356,27 +336,9 @@ public class UpdateCacheTest extends PsiTestCase{ PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to update caches - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - VirtualFile[] sourceRoots = rootManager.getSourceRoots(); - LOG.assertTrue(sourceRoots.length == 1); - final ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel(); - final ContentEntry[] content1 = rootModel.getContentEntries(); - contentLoop: - for (ContentEntry contentEntry : content1) { - if (root.equals(contentEntry.getFile())) { - final SourceFolder[] sourceFolders = contentEntry.getSourceFolders(); - for (SourceFolder sourceFolder : sourceFolders) { - if (sourceRoots[0].equals(sourceFolder.getFile())) { - contentEntry.removeSourceFolder(sourceFolder); - break contentLoop; - } - } - } - } - rootModel.commit(); - } - }); + VirtualFile[] sourceRoots = ModuleRootManager.getInstance(myModule).getSourceRoots(); + LOG.assertTrue(sourceRoots.length == 1); + PsiTestUtil.removeSourceRoot(myModule, sourceRoots[0]); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java index a57526b3e9ba..c254828e4d36 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java @@ -109,6 +109,10 @@ public class RenameLocalTest extends LightRefactoringTestCase { doTestInplaceRename("r1"); } + public void testRenameToFieldNameInStaticContext() throws Exception { + doTestInplaceRename("myFoo"); + } + public void testRenameInPlaceInStaticContextWithConflictingField() throws Exception { doTestInplaceRename("s"); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java index 0fff5440c057..a157129cbe4e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java @@ -4,6 +4,7 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLocalVariable; import com.intellij.psi.PsiReference; @@ -221,6 +222,7 @@ public class InlineLocalTest extends LightCodeInsightTestCase { private void doTest(final boolean inlineDef) throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); String name = getTestName(false); String fileName = "/refactoring/inlineLocal/" + name + ".java"; configureByFile(fileName); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index 98a2685d5575..b29fe84bc2c4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -17,6 +17,7 @@ package com.intellij.refactoring.inline; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiReference; @@ -158,6 +159,7 @@ public class InlineMethodTest extends LightRefactoringTestCase { } public void testInferredType() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); doTest(); } |