diff options
Diffstat (limited to 'java/java-tests/testData')
34 files changed, 434 insertions, 29 deletions
diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA127714.java b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA127714.java new file mode 100644 index 000000000000..08713f898f15 --- /dev/null +++ b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA127714.java @@ -0,0 +1,9 @@ +import a.A; + +class IDEA127714 { + { + A<E, String> strings = new A<>(E.class); + } +} + +enum E {}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA127714.jar b/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA127714.jar Binary files differnew file mode 100644 index 000000000000..915d3a074810 --- /dev/null +++ b/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA127714.jar diff --git a/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch.java b/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch.java new file mode 100644 index 000000000000..d8ea6191cef8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch.java @@ -0,0 +1,12 @@ + +class Foo { + { + try + { + + } catch (Ex<caret>ception e) + { + + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch_after.java b/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch_after.java new file mode 100644 index 000000000000..f4874b45962e --- /dev/null +++ b/java/java-tests/testData/codeInsight/completeStatement/AlreadyCompleteCatch_after.java @@ -0,0 +1,12 @@ + +class Foo { + { + try + { + + } catch (Exception e) + { + <caret> + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretCompletionFromNonPrimaryCaret.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretCompletionFromNonPrimaryCaret.java new file mode 100644 index 000000000000..077ff80bd5c7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretCompletionFromNonPrimaryCaret.java @@ -0,0 +1,4 @@ +class Foo {{ + System.<caret> + System.<caret> +}} diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics-out.java b/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics-out.java new file mode 100644 index 000000000000..41f3d57525a2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics-out.java @@ -0,0 +1,16 @@ +class Main { + void foo(List<? extends Number> list) { + list.forEach(new Consumer<Number>() { + @Override + public void consume(Number number) { + <caret> + } + }); + } +} + +class List<T> { + void forEach(Consumer<? super T> consumer); +} + +interface Consumer<T> { void consume(T t); }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics.java b/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics.java new file mode 100644 index 000000000000..b1d18904a6fb --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/DontSuggestWildcardGenerics.java @@ -0,0 +1,11 @@ +class Main { + void foo(List<? extends Number> list) { + list.forEach(new <caret>); + } +} + +class List<T> { + void forEach(Consumer<? super T> consumer); +} + +interface Consumer<T> { void consume(T t); }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartTypeSorting/PreferFieldsToConstants.java b/java/java-tests/testData/codeInsight/completion/smartTypeSorting/PreferFieldsToConstants.java new file mode 100644 index 000000000000..2b47bb58a498 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartTypeSorting/PreferFieldsToConstants.java @@ -0,0 +1,17 @@ +public class Foo { + + private LocalDate dateField; + + void foo(LocalDate date) { + + } + + void bar() { + foo(<caret>) + } +} + +class LocalDate { + public static final LocalDate MAX; + public static final LocalDate MIN; +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java index 8be16fc1db85..8ba3ea4f8037 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java @@ -94,4 +94,96 @@ class C { void asLongs(Integer i) { long l = (long) i; } + + void foo(Object o) {} + public void cast2(Byte operand) { + foo((<warning descr="Casting 'operand' to 'byte' is redundant">byte</warning>)operand); + foo((short)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Byte' to 'char'">(char)operand</error>); + foo((int)operand); + foo((long)operand); + foo((float)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Byte' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Short operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'byte'">(byte)operand</error>); + foo((<warning descr="Casting 'operand' to 'short' is redundant">short</warning>)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'char'">(char)operand</error>); + foo((int)operand); + foo((long)operand); + foo((float)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Character operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'short'">(short)operand</error>); + foo((<warning descr="Casting 'operand' to 'char' is redundant">char</warning>)operand); + foo((int)operand); + foo((long)operand); + foo((float)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Integer operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'short'">(short)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'char'">(char)operand</error>); + foo((<warning descr="Casting 'operand' to 'int' is redundant">int</warning>)operand); + foo((long)operand); + foo((float)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Long operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'short'">(short)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'char'">(char)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'int'">(int)operand</error>); + foo((<warning descr="Casting 'operand' to 'long' is redundant">long</warning>)operand); + foo((float)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Float operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'short'">(short)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'char'">(char)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'int'">(int)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'long'">(long)operand</error>); + foo((<warning descr="Casting 'operand' to 'float' is redundant">float</warning>)operand); + foo((double)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Double operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'short'">(short)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'char'">(char)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'int'">(int)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'long'">(long)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'float'">(float)operand</error>); + foo((<warning descr="Casting 'operand' to 'double' is redundant">double</warning>)operand); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'boolean'">(boolean)operand</error>); + } + public void cast2(Boolean operand) { + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'byte'">(byte)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'short'">(short)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'char'">(char)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'int'">(int)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'long'">(long)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'float'">(float)operand</error>); + foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'double'">(double)operand</error>); + foo((<warning descr="Casting 'operand' to 'boolean' is redundant">boolean</warning>)operand); + } + public void cast2(Object operand) { + foo((<warning descr="Casting 'operand' to 'byte' is redundant">byte</warning>)operand); + foo((<warning descr="Casting 'operand' to 'short' is redundant">short</warning>)operand); + foo((<warning descr="Casting 'operand' to 'char' is redundant">char</warning>)operand); + foo((<warning descr="Casting 'operand' to 'int' is redundant">int</warning>)operand); + foo((<warning descr="Casting 'operand' to 'long' is redundant">long</warning>)operand); + foo((<warning descr="Casting 'operand' to 'float' is redundant">float</warning>)operand); + foo((<warning descr="Casting 'operand' to 'double' is redundant">double</warning>)operand); + foo((<warning descr="Casting 'operand' to 'boolean' is redundant">boolean</warning>)operand); + } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128101.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128101.java new file mode 100644 index 000000000000..42be49b62f04 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128101.java @@ -0,0 +1,29 @@ +class TestIDEA128101 { + + static class Attribute<Y> {}; + static class Path<X> {}; + + static Attribute<Integer> integerAttribute; + static Attribute<String> stringAttribute; + + static <Y> Path<Y> createPath(Attribute<Y> attribute) { + return new Path<>(); + } + static <Y> Path<Y> createPath1(Attribute<Y> attribute) { + return new Path<>(); + } + static <T> void construct(Class<T> aClass, Path<?>... paths) {} + static <T, K> void construct1(Class<T> aClass, Path<K>... paths) {} + static <T, K> void construct2(Class<T> aClass, Path<? extends K>... paths) {} + static <T, K> void construct3(Class<T> aClass, Path<? super K>... paths) {} + static <T, K> void construct4(Class<T> aClass, Path<? super K> path1, Path<? super K> path2) {} + + public static void test() { + construct(String.class, createPath(integerAttribute), createPath(stringAttribute)); + construct1<error descr="Cannot resolve method 'construct1(java.lang.Class<java.lang.String>, TestIDEA128101.Path<java.lang.Integer>, TestIDEA128101.Path<java.lang.String>)'">(String.class, createPath(integerAttribute), createPath(stringAttribute))</error>; + construct2(String.class, createPath(integerAttribute), createPath(stringAttribute)); + <error descr="Type parameter K has incompatible upper bounds: Integer and String">construct3(String.class, createPath(integerAttribute), createPath(stringAttribute));</error> + <error descr="Type parameter K has incompatible upper bounds: Integer and String">construct4(String.class, createPath(integerAttribute), createPath(stringAttribute));</error> + } + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128174.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128174.java new file mode 100644 index 000000000000..650114b06e50 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA128174.java @@ -0,0 +1,24 @@ +import java.util.Collection; +import java.util.List; + +class Test { + + { + Matcher<? super List<String>> m = not(empty()); + } + + static <E> Matcher<Collection<E>> empty() { + return null; + } + + static <T> Matcher<T> not(Matcher<T> matcher) { + return null; + } + + static <T> Matcher<T> not(T value) { + return null; + } + + static class Matcher<K> {} +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromConditionalExpressionCondition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromConditionalExpressionCondition.java new file mode 100644 index 000000000000..8fad96c118ed --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromConditionalExpressionCondition.java @@ -0,0 +1,14 @@ +class Test { + static class TKey<T> { + } + + public interface Getter { + <T> T getValue(TKey<T> key); + } + + static final TKey<Boolean> KEY_B = new TKey<>(); + + public static void f(Getter getter) { + String name = getter.getValue(KEY_B) ? "foo" : "bar"; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PrimitiveWrapperConditionInReturnConstraint.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PrimitiveWrapperConditionInReturnConstraint.java new file mode 100644 index 000000000000..6788a98b215c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PrimitiveWrapperConditionInReturnConstraint.java @@ -0,0 +1,15 @@ +class Test { + static class TKey<T> { + } + + public interface Getter { + <T> T getValue(TKey<T> key); + } + + static final TKey<Integer> KEY_I = null; + + + public static void f(Getter getter, TKey<Integer> key) { + double d1 = getter.getValue (key); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/EffectiveFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/EffectiveFinal.java index 254ec7191a47..92b268394994 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/EffectiveFinal.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/EffectiveFinal.java @@ -39,7 +39,7 @@ public class XXX { void m3(int x, boolean cond) { int y; if (cond) y = 1; - foo(() -> x+<error descr="Variable used in lambda expression should be effectively final">y</error>); + foo(() -> x+<error descr="Variable 'y' might not have been initialized">y</error>); } void m4(int x, boolean cond) { @@ -128,3 +128,17 @@ class IDEA114737 { }; } } + +class IDEA128196 { + void a() { + int value; + + try { + value = 1; + } catch (Exception e) { + return; + } + + new Thread(() -> System.out.println(value)); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IDEA127765.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IDEA127765.java new file mode 100644 index 000000000000..095448e262b3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/IDEA127765.java @@ -0,0 +1,19 @@ +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; + +class IDEA127765 { + void a(final Map<String, Optional<Double>> allValues, final Function<Optional<Double>, Double> get) { + final Map<String, Double> presentValues = transformValues(filterValues(allValues, Optional::isPresent), get); + } + + public static <K, V1, V2> Map<K, V2> transformValues(Map<K, V1> fromMap, Function<? super V1, V2> function) { + return null; + } + + public static <K, V> Map<K, V> filterValues(Map<K, V> unfiltered, Predicate<? super V> valuePredicate) { + return null; + } + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterOnVarargsPlace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterOnVarargsPlace.java new file mode 100644 index 000000000000..82e3cc9aa3e6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterOnVarargsPlace.java @@ -0,0 +1,10 @@ +// "Replace with lambda" "true" +class Test2 { + + void f(Runnable... rs){} + { + f(null, () -> { + + }); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeOnVarargsPlace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeOnVarargsPlace.java new file mode 100644 index 000000000000..af9db7767997 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeOnVarargsPlace.java @@ -0,0 +1,13 @@ +// "Replace with lambda" "true" +class Test2 { + + void f(Runnable... rs){} + { + f(null, new Run<caret>nable() { + @Override + public void run() { + + } + }); + } +} diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored.java b/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored.java new file mode 100644 index 000000000000..1af8cd0813a9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored.java @@ -0,0 +1,5 @@ +public class Foo { + void m(Object o) { + !.null<caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored_after.java new file mode 100644 index 000000000000..1334be6b7029 --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/null/singleExclamationIgnored_after.java @@ -0,0 +1,5 @@ +public class Foo { + void m(Object o) { + !.null <caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_after.java b/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_after.java new file mode 100644 index 000000000000..08b2afd09cb9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_after.java @@ -0,0 +1,7 @@ +class Foo { + public static void main(String[] args) { + String s = ""; + s.replaceAll("\\<caret>"); + System.out.println(); + } +} diff --git a/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_before.java b/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_before.java new file mode 100644 index 000000000000..bee6f10053c2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/typing/invalidInitialSyntax_before.java @@ -0,0 +1,7 @@ +class Foo { + public static void main(String[] args) { + String s = ""; + s.replaceAll("<caret>"); + System.out.println(); + } +} diff --git a/java/java-tests/testData/find/findInEditor/BasicFind.gold b/java/java-tests/testData/find/findInEditor/BasicFind.gold index 14e4182499b7..46486765486d 100644 --- a/java/java-tests/testData/find/findInEditor/BasicFind.gold +++ b/java/java-tests/testData/find/findInEditor/BasicFind.gold @@ -3,8 +3,7 @@ myStringToFind =a myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -22,6 +21,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- diff --git a/java/java-tests/testData/find/findInEditor/EmacsLikeFallback.gold b/java/java-tests/testData/find/findInEditor/EmacsLikeFallback.gold index a2168ba66e2a..bfda616a3ac1 100644 --- a/java/java-tests/testData/find/findInEditor/EmacsLikeFallback.gold +++ b/java/java-tests/testData/find/findInEditor/EmacsLikeFallback.gold @@ -3,8 +3,7 @@ myStringToFind =a myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -22,6 +21,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- @@ -37,8 +37,7 @@ myStringToFind =ab myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -56,6 +55,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- @@ -70,8 +70,7 @@ myStringToFind =a myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -89,6 +88,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- diff --git a/java/java-tests/testData/find/findInEditor/ReplacementWithEmptyString.gold b/java/java-tests/testData/find/findInEditor/ReplacementWithEmptyString.gold index 478eb649684d..a4d44cbfa445 100644 --- a/java/java-tests/testData/find/findInEditor/ReplacementWithEmptyString.gold +++ b/java/java-tests/testData/find/findInEditor/ReplacementWithEmptyString.gold @@ -3,8 +3,7 @@ myStringToFind = myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -22,6 +21,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- @@ -33,8 +33,7 @@ myStringToFind =a myStringToReplace = isReplaceState =false isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -52,6 +51,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- @@ -65,8 +65,7 @@ myStringToFind =a myStringToReplace = isReplaceState =true isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -84,6 +83,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- Replacement Preview: <Empty string> @@ -99,8 +99,7 @@ myStringToFind =a myStringToReplace = isReplaceState =true isWholeWordsOnly =false -isInStringLiterals =false -isInComments =false +searchContext =ANY isFromCursor =true isForward =true isGlobal =true @@ -118,6 +117,7 @@ isWithSubdirectories =true fileFilter =null moduleName =null customScopeName =null +searchInProjectFiles =false -- diff --git a/java/java-tests/testData/inspection/dataFlow/CheckedExceptionDominance/src/Test.java b/java/java-tests/testData/inspection/dataFlow/CheckedExceptionDominance/src/Test.java index 4a0a690f0e21..4f0586d30a96 100644 --- a/java/java-tests/testData/inspection/dataFlow/CheckedExceptionDominance/src/Test.java +++ b/java/java-tests/testData/inspection/dataFlow/CheckedExceptionDominance/src/Test.java @@ -19,6 +19,6 @@ } public static void bar() throws CheckedException { - throw new CheckedException(); + if (new Random().nextInt() > 2) throw new CheckedException(); } } diff --git a/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/expected.xml b/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/expected.xml index bb6256f74012..4a088210968c 100644 --- a/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/expected.xml +++ b/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/expected.xml @@ -7,7 +7,7 @@ </problem> <problem> <file>IDEADEV10489.java</file> - <line>12</line> + <line>8</line> <description>Method invocation 's.length()' may produce NullPointerException</description> </problem> </problems>
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/src/IDEADEV10489.java b/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/src/IDEADEV10489.java index 60259479d353..ee41e588dd3e 100644 --- a/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/src/IDEADEV10489.java +++ b/java/java-tests/testData/inspection/dataFlow/IDEADEV10489/src/IDEADEV10489.java @@ -1,7 +1,5 @@ class IDEADEV10489 { - static String getS() { - return null; - } + static native String getS(); static void f() { String s = getS(); @@ -17,7 +15,5 @@ class IDEADEV10489 { } } - private static boolean foo() { - return false; - } + private static native boolean foo(); }
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFailInCatch.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertFailInCatch.java index 93fcf6d5c2d2..55c7c2b51de0 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFailInCatch.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertFailInCatch.java @@ -18,7 +18,5 @@ class Test { } } - private static @NotNull String createString() { - throw new NullPointerException(); - } + private static native @NotNull String createString(); }
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java index ecb9b264bb62..a30d934f64b6 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java @@ -1,3 +1,5 @@ +import java.util.Random; + class BrokenAlignment { public static void main(String[] args) { @@ -20,7 +22,7 @@ class BrokenAlignment { } public static void doSomething() { - throw new RuntimeException("dummy"); + if (new Random().nextInt() > 2) throw new RuntimeException("dummy"); } }
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNoArgs.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNoArgs.java new file mode 100644 index 000000000000..006c2e3407ec --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNoArgs.java @@ -0,0 +1,24 @@ +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +class Doo { + + @NotNull + public String doSomething() { + String s = getSomeString(); + if (s == null) { + throwSomeError(); + } + return s; + } + + private static void throwSomeError() { + throw new RuntimeException(); + } + + @Nullable + public String getSomeString() { + return Math.random() > 0.5 ? null : "Yeah"; + } + +} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CustomTypeQualifierDefault.java b/java/java-tests/testData/inspection/dataFlow/fixture/CustomTypeQualifierDefault.java new file mode 100644 index 000000000000..e9ec6b1dbe11 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/CustomTypeQualifierDefault.java @@ -0,0 +1,25 @@ +import foo.*; +import org.jetbrains.annotations.NotNull; + +class Some { + void foo(@NotNull String s) { + NotNullClass.foo(null); + if (<warning descr="Condition 'NotNullClass.foo(s) == null' is always 'false'">NotNullClass.foo(s) == null</warning>) {} + + NullableClass.foo(null); + if (NullableClass.foo("a") == null) {} + + AnotherPackageNotNull.foo(null); + if (<warning descr="Condition 'AnotherPackageNotNull.foo(s) == null' is always 'false'">AnotherPackageNotNull.foo(s) == null</warning>) {} + } + +} + +@bar.MethodsAreNotNullByDefault +class NotNullClass { + static native Object foo(String s); + +} +class NullableClass { + static native Object foo(String s); +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FloatComparisons.java b/java/java-tests/testData/inspection/dataFlow/fixture/FloatComparisons.java new file mode 100644 index 000000000000..5c553bcba0bf --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/FloatComparisons.java @@ -0,0 +1,7 @@ +class Test { + public static void testFunc(final float width, final float height) { + if (width < 0f || height < 0f) { + throw new IllegalArgumentException("Size must be non-negative"); + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java b/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java new file mode 100644 index 000000000000..dd815139efa5 --- /dev/null +++ b/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java @@ -0,0 +1,9 @@ +class Test { + + static void f<caret>oo() {} + static void foo2(int i) {} + + { + Runnable r = Test :: foo; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java.after b/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java.after new file mode 100644 index 000000000000..8dab0803fcec --- /dev/null +++ b/java/java-tests/testData/refactoring/renameCollisions/RenameMethodNoCollisionWithOtherSignatureMethodRef.java.after @@ -0,0 +1,9 @@ +class Test { + + static void foo2() {} + static void foo2(int i) {} + + { + Runnable r = Test ::foo2; + } +}
\ No newline at end of file |